mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-12 04:16:47 +08:00
645 lines
19 KiB
Vue
645 lines
19 KiB
Vue
<template>
|
||
<a-drawer
|
||
:visible="addactiveVisible"
|
||
class="drawerStyle addactiveDrawer"
|
||
width="80%"
|
||
title="添加活动"
|
||
placement="right"
|
||
@after-visible-change="afterVisibleChange"
|
||
>
|
||
<div class="drawerMain">
|
||
<div class="header">
|
||
<div class="headerTitle">{{ edit ? "编辑" : "添加" }}活动</div>
|
||
<img
|
||
style="width: 29px; height: 29px; cursor: pointer"
|
||
src="../../assets/images/basicinfo/close.png"
|
||
@click="closeDrawer"
|
||
/>
|
||
</div>
|
||
<div class="contentMain">
|
||
<div class="main_left">
|
||
<div class="main_item">
|
||
<div class="signbox">
|
||
<div class="sign">
|
||
<img
|
||
src="@/assets/images/coursewareManage/asterisk.png"
|
||
alt=""
|
||
/>
|
||
</div>
|
||
<span style="margin-right: 3px">活动名称:</span>
|
||
</div>
|
||
<div class="btnbox">
|
||
<a-input
|
||
v-model:value="inputV1"
|
||
style="width: 424px; height: 32px"
|
||
placeholder="请输入活动名称"
|
||
maxlength="20"
|
||
/>
|
||
</div>
|
||
</div>
|
||
<div class="main_item2">
|
||
<div class="signbox">
|
||
<div class="sign">
|
||
<img
|
||
src="@/assets/images/coursewareManage/asterisk.png"
|
||
alt=""
|
||
/>
|
||
</div>
|
||
<span style="margin-right: 3px">活动公告:</span>
|
||
</div>
|
||
<div class="textarea">
|
||
<a-textarea
|
||
v-model:value="textV1"
|
||
placeholder="请输入活动公告"
|
||
allow-clear
|
||
maxlength="150"
|
||
/>
|
||
</div>
|
||
</div>
|
||
<div class="main_item2">
|
||
<div class="signbox">
|
||
<span style="margin-right: 3px">活动说明:</span>
|
||
</div>
|
||
<div class="textarea">
|
||
<a-textarea
|
||
v-model:value="textV2"
|
||
placeholder="请输入活动说明"
|
||
allow-clear
|
||
maxlength="150"
|
||
/>
|
||
</div>
|
||
</div>
|
||
<div class="main_item">
|
||
<div class="signbox">
|
||
<div class="sign">
|
||
<img
|
||
src="@/assets/images/coursewareManage/asterisk.png"
|
||
alt=""
|
||
/>
|
||
</div>
|
||
<span style="margin-right: 3px">活动时间:</span>
|
||
</div>
|
||
<div class="btnbox">
|
||
<a-range-picker
|
||
style="width: 424px"
|
||
v-model:value="time"
|
||
:placeholder="[' 开始时间', ' 结束时间']"
|
||
/>
|
||
</div>
|
||
</div>
|
||
<div class="main_item">
|
||
<div class="signbox">
|
||
<div class="sign">
|
||
<img
|
||
src="@/assets/images/coursewareManage/asterisk.png"
|
||
alt=""
|
||
/>
|
||
</div>
|
||
<span style="margin-right: 3px">活动时长:</span>
|
||
</div>
|
||
<div class="btnbox">
|
||
<a-input-number
|
||
:min="0"
|
||
:precision="0"
|
||
style="
|
||
width: 388px;
|
||
height: 32px;
|
||
border-radius: 8px;
|
||
overflow: hidden;
|
||
"
|
||
v-model:value="inputV2"
|
||
/>
|
||
<span style="margin-left: 5px">分钟</span>
|
||
</div>
|
||
</div>
|
||
<div class="main_item">
|
||
<div class="signbox">
|
||
<div class="sign">
|
||
<img
|
||
src="@/assets/images/coursewareManage/asterisk.png"
|
||
alt=""
|
||
/>
|
||
</div>
|
||
<span style="margin-right: 3px">活动地址:</span>
|
||
</div>
|
||
<div class="btnbox">
|
||
<a-input
|
||
v-model:value="inputV3"
|
||
style="width: 424px; height: 32px"
|
||
placeholder="请输入活动地址"
|
||
/>
|
||
</div>
|
||
</div>
|
||
<div class="main_item2">
|
||
<div class="signbox">
|
||
<span style="margin-right: 3px">考勤设置:</span>
|
||
</div>
|
||
<div class="kqszbox">
|
||
<div class="qdqtbox">
|
||
<div class="qdbtn"><div class="btntext">签到</div></div>
|
||
</div>
|
||
<div class="setbox">
|
||
<div class="timerbox">
|
||
<span>开始前:</span>
|
||
<a-input-number
|
||
:min="0"
|
||
:max="30"
|
||
:precision="0"
|
||
style="
|
||
width: 88px;
|
||
height: 32px;
|
||
border-radius: 8px;
|
||
overflow: hidden;
|
||
"
|
||
v-model:value="inputV4"
|
||
/>
|
||
<span style="color: #999999; margin-left: 8px">分钟</span>
|
||
</div>
|
||
<div class="timerbox">
|
||
<span>开始后:</span>
|
||
<a-input-number
|
||
:min="0"
|
||
:max="30"
|
||
:precision="0"
|
||
style="
|
||
width: 88px;
|
||
height: 32px;
|
||
border-radius: 8px;
|
||
overflow: hidden;
|
||
"
|
||
v-model:value="inputV5"
|
||
/>
|
||
<span style="color: #999999; margin-left: 8px">分钟</span>
|
||
</div>
|
||
</div>
|
||
<div class="qdqtbox">
|
||
<div class="qtbtn"><div class="btntext">签退</div></div>
|
||
</div>
|
||
<div class="setbox">
|
||
<div class="timerbox">
|
||
<span>结束前:</span>
|
||
<a-input-number
|
||
:min="0"
|
||
:max="30"
|
||
:precision="0"
|
||
style="
|
||
width: 88px;
|
||
height: 32px;
|
||
border-radius: 8px;
|
||
overflow: hidden;
|
||
"
|
||
v-model:value="inputV6"
|
||
/>
|
||
<span style="color: #999999; margin-left: 8px"
|
||
>分钟(提前签退则记为早退)</span
|
||
>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="main_item">
|
||
<div class="signbox">
|
||
<span style="margin-right: 3px">完成标准设置:</span>
|
||
</div>
|
||
<div class="btnbox">
|
||
<a-radio-group v-model:value="radioV1">
|
||
<a-radio v-model:checked="checked" :value="1" @click="cloradio1"
|
||
>仅签到</a-radio
|
||
>
|
||
<a-radio v-model:checked="checked" :value="2" @click="cloradio1"
|
||
>签到、签退全部完成</a-radio
|
||
>
|
||
</a-radio-group>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="main_btns">
|
||
<button class="btn1" @click="closeDrawer">取消</button>
|
||
<button class="btn2" @click="updateActivityInfo">确定</button>
|
||
</div>
|
||
</div>
|
||
</a-drawer>
|
||
</template>
|
||
<script>
|
||
import { reactive, toRefs } from "vue";
|
||
import * as api from "../../api/indexActivity";
|
||
import * as apiTask from "../../api/indexTaskadd";
|
||
import { RouterEditTask } from "@/api/indexTask";
|
||
import { message } from "ant-design-vue";
|
||
import dayjs from "dayjs";
|
||
export default {
|
||
name: "AddActive",
|
||
// components: {
|
||
// },
|
||
props: {
|
||
addactiveVisible: {
|
||
type: Boolean,
|
||
default: false,
|
||
},
|
||
EditActiveId: {
|
||
type: Number,
|
||
default: null,
|
||
},
|
||
edit: {
|
||
// 是否为编辑
|
||
type: Boolean,
|
||
default: null,
|
||
},
|
||
projectId: {
|
||
type: Number,
|
||
default: null,
|
||
},
|
||
chooseStageId: {
|
||
type: Number,
|
||
default: null,
|
||
},
|
||
routerTaskId: {
|
||
type: Number,
|
||
default: 0,
|
||
},
|
||
isLevel: {
|
||
// 是否是关卡页面触发
|
||
type: Number,
|
||
default: null,
|
||
},
|
||
EditWorkId: {
|
||
// 要编辑的workId
|
||
type: Number,
|
||
default: null,
|
||
},
|
||
projectTaskId: {
|
||
// 要编辑的projectId
|
||
type: Number,
|
||
default: null,
|
||
},
|
||
routerId: {
|
||
type: Number,
|
||
default: null,
|
||
},
|
||
isactive: {
|
||
type: Number,
|
||
default: null,
|
||
},
|
||
},
|
||
setup(props, ctx) {
|
||
const state = reactive({
|
||
inputV1: "",
|
||
inputV2: "",
|
||
inputV3: "",
|
||
inputV4: "",
|
||
inputV5: "",
|
||
inputV6: "",
|
||
textV1: "",
|
||
textV2: "",
|
||
radioV1: "",
|
||
time: "",
|
||
});
|
||
const closeDrawer = () => {
|
||
ctx.emit("update:addactiveVisible", false);
|
||
ctx.emit("update:edit", false);
|
||
state.radioV1 = "";
|
||
state.inputV1 = "";
|
||
state.inputV2 = "";
|
||
state.inputV3 = "";
|
||
state.inputV4 = "";
|
||
state.inputV5 = "";
|
||
state.inputV6 = "";
|
||
state.textV1 = "";
|
||
state.textV2 = "";
|
||
state.time = "";
|
||
message.success(`${props.edit ? "编辑" : "新增"}关卡任务成功`);
|
||
localStorage.setItem("stageId", props.chooseStageId);
|
||
localStorage.setItem("chapterId", props.isactive);
|
||
};
|
||
const queryActive = () => {
|
||
api
|
||
.getActivity(props.EditActiveId)
|
||
.then((res) => {
|
||
//更新讨论信息
|
||
state.inputV1 = res.data.data.activityName;
|
||
state.textV1 = res.data.data.activityNotice;
|
||
state.textV2 = res.data.data.activityExplain;
|
||
state.inputV2 = res.data.data.activityDuration;
|
||
state.inputV3 = res.data.data.activityAddress;
|
||
state.inputV5 = res.data.data.afterSignIn;
|
||
state.inputV6 = res.data.data.signOutTime;
|
||
state.inputV4 = res.data.data.beforeSignIn;
|
||
state.radioV1 = Number(res.data.data.standardSettings);
|
||
|
||
state.time = [
|
||
dayjs(res.data.data.activityStartTime, "YYYY-MM-DD"),
|
||
dayjs(res.data.data.activityEndTime, "YYYY-MM-DD"),
|
||
];
|
||
})
|
||
.catch(() => {
|
||
});
|
||
};
|
||
const afterVisibleChange = (bool) => {
|
||
if (bool && props.edit) {
|
||
queryActive();
|
||
}
|
||
};
|
||
const cloradio1 = (value) => {
|
||
if (value != "") {
|
||
state.radioV1 = "";
|
||
}
|
||
};
|
||
const updateTask = (res) => {
|
||
if (props.isLevel == 1) {
|
||
RouterEditTask({
|
||
chapterId: props.isactive,
|
||
courseId: res.data.data.activityId,
|
||
duration: res.data.data.activityDuration,
|
||
name: res.data.data.activityName,
|
||
routerId: props.routerId,
|
||
routerTaskId: props.routerTaskId || 0,
|
||
type: 9,
|
||
})
|
||
.then(() => {
|
||
message.success(`${props.edit ? "编辑" : "新增"}关卡任务成功`);
|
||
})
|
||
.catch(() => {
|
||
message.error(`${props.edit ? "编辑" : "新增"}关卡任务失败`);
|
||
});
|
||
} else if (props.isLevel == 2) {
|
||
apiTask
|
||
.addTask({
|
||
courseId: res.data.data.activityId,
|
||
duration: res.data.data.activityDuration,
|
||
name: res.data.data.activityName,
|
||
projectId: props.projectId,
|
||
projectTaskId: props.projectTaskId || 0,
|
||
stageId: props.chooseStageId,
|
||
type: 9,
|
||
})
|
||
.then(() => {
|
||
message.success(`${props.edit ? "编辑" : "新增"}阶段任务成功`);
|
||
})
|
||
.catch(() => {
|
||
message.error(`${props.edit ? "编辑" : "新增"}阶段任务失败`);
|
||
});
|
||
} else if (props.isLevel == 3) {
|
||
apiTask
|
||
.addTempTask({
|
||
courseId: res.data.data.activityId,
|
||
duration: res.data.data.activityDuration,
|
||
name: res.data.data.activityName,
|
||
projectTemplateId: props.projectTemplateId,
|
||
projectTaskId: props.projectTaskId || 0,
|
||
stageId: props.chooseStageId,
|
||
type: 9,
|
||
})
|
||
.then(() => {
|
||
message.success(`${props.edit ? "编辑" : "新增"}阶段任务成功`);
|
||
})
|
||
.catch(() => {
|
||
message.error(`${props.edit ? "编辑" : "新增"}阶段任务失败`);
|
||
});
|
||
|
||
console.log("");
|
||
}
|
||
};
|
||
//创建活动
|
||
const updateActivityInfo = () => {
|
||
if (!state.inputV1) {
|
||
message.destroy();
|
||
return message.warning("请输入活动名称");
|
||
}
|
||
if (!state.textV1) {
|
||
message.destroy();
|
||
return message.warning("请输入活动公告");
|
||
}
|
||
if (!state.time) {
|
||
message.destroy();
|
||
return message.warning("请输入活动时间");
|
||
}
|
||
if (!state.inputV2) {
|
||
message.destroy();
|
||
return message.warning("请输入活动时长");
|
||
}
|
||
if (!state.inputV3) {
|
||
message.destroy();
|
||
return message.warning("请输入活动地址");
|
||
}
|
||
|
||
let obj = {
|
||
activityAddress: state.inputV3, //活动地址
|
||
activityDuration: state.inputV2, //活动时长
|
||
activityExplain: state.textV2, //活动说明
|
||
activityEndTime: dayjs(state.time[1]).format("YYYY-MM-DD"), //活动结束时间
|
||
activityId: props.edit ? props.EditActiveId : 0, //活动ID
|
||
activityName: state.inputV1, //活动名称
|
||
activityNotice: state.textV1, //活动公告
|
||
activityStartTime: dayjs(state.time[0]).format("YYYY-MM-DD"), //活动开始时间
|
||
activityTag: "", //活动逻辑删除标识
|
||
afterSignIn: state.inputV5, //活动开始后多少分钟签到
|
||
beforeSignIn: state.inputV4, //活动开始前多少分钟签到
|
||
signOutTime: state.inputV6, //签退开始时间
|
||
standardSettings: state.radioV1, //标准设置
|
||
};
|
||
if (props.edit) {
|
||
//更新编辑活动信息
|
||
api
|
||
.updateActivity(obj)
|
||
.then((res) => {
|
||
closeDrawer();
|
||
updateTask(res);
|
||
ctx.emit("changeData", false);
|
||
message.success("更新成功");
|
||
})
|
||
.catch(() => {
|
||
message.error("更新失败");
|
||
});
|
||
} else {
|
||
//新建活动信息
|
||
api
|
||
.createActivity(obj)
|
||
.then((res) => {
|
||
message.success("创建成功");
|
||
closeDrawer();
|
||
updateTask(res);
|
||
ctx.emit("changeData", false);
|
||
})
|
||
.catch(() => {
|
||
message.error("创建失败");
|
||
});
|
||
}
|
||
};
|
||
|
||
return {
|
||
...toRefs(state),
|
||
afterVisibleChange,
|
||
closeDrawer,
|
||
cloradio1,
|
||
updateActivityInfo,
|
||
};
|
||
},
|
||
};
|
||
</script>
|
||
<style lang="scss">
|
||
.ant-table-striped :deep(.table-striped) td {
|
||
background-color: #fafafa !important;
|
||
}
|
||
.addactiveDrawer {
|
||
.drawerMain {
|
||
.header {
|
||
height: 73px;
|
||
border-bottom: 1px solid #e8e8e8;
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
flex-shrink: 0;
|
||
.headerTitle {
|
||
font-size: 18px;
|
||
font-weight: 600;
|
||
color: #333333;
|
||
line-height: 25px;
|
||
margin-left: 24px;
|
||
}
|
||
}
|
||
.contentMain {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
.ant-input {
|
||
height: 88px;
|
||
width: 384px;
|
||
border-radius: 8px;
|
||
}
|
||
.ant-picker {
|
||
border-radius: 8px;
|
||
}
|
||
.main_left {
|
||
margin-top: 32px;
|
||
padding-right: 30px;
|
||
flex: 1;
|
||
border-right: 1px solid #e8e8e8;
|
||
.main_item {
|
||
display: flex;
|
||
align-items: center;
|
||
margin-top: 32px;
|
||
margin-bottom: 32px;
|
||
.signbox {
|
||
width: 120px;
|
||
display: flex;
|
||
justify-content: end;
|
||
align-items: center;
|
||
.sign {
|
||
margin-right: 5px;
|
||
}
|
||
}
|
||
.btnbox {
|
||
display: flex;
|
||
flex: 1;
|
||
align-items: center;
|
||
.xkbtn {
|
||
cursor: pointer;
|
||
width: 130px;
|
||
height: 40px;
|
||
background: #388be1;
|
||
border-radius: 8px;
|
||
border: 0;
|
||
margin-right: 8px;
|
||
color: #fff;
|
||
}
|
||
}
|
||
}
|
||
.main_item2 {
|
||
display: flex;
|
||
align-items: flex-start;
|
||
margin-bottom: 32px;
|
||
.signbox {
|
||
width: 120px;
|
||
display: flex;
|
||
justify-content: end;
|
||
align-items: center;
|
||
.sign {
|
||
margin-right: 5px;
|
||
}
|
||
}
|
||
.kqszbox {
|
||
.qdqtbox {
|
||
margin-left: 5px;
|
||
cursor: pointer;
|
||
}
|
||
.qdbtn,
|
||
.qtbtn {
|
||
width: 75px;
|
||
height: 24px;
|
||
background: rgba(56, 139, 225, 0.16);
|
||
border-radius: 2px;
|
||
border: 1px solid #387df7;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
.btntext {
|
||
color: #387df7;
|
||
}
|
||
}
|
||
.setbox {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
margin-top: 10px;
|
||
margin-bottom: 24px;
|
||
.timerbox {
|
||
margin-top: 6px;
|
||
margin-right: 32px;
|
||
display: flex;
|
||
align-items: center;
|
||
flex-wrap: nowrap;
|
||
}
|
||
}
|
||
}
|
||
.btnbox2 {
|
||
display: flex;
|
||
flex-direction: column;
|
||
justify-content: flex-start;
|
||
.xkbtn {
|
||
cursor: pointer;
|
||
width: 130px;
|
||
height: 40px;
|
||
background: #388be1;
|
||
border-radius: 8px;
|
||
border: 0;
|
||
margin-right: 16px 8px 32px 0;
|
||
color: #fff;
|
||
margin-top: 16px;
|
||
margin-bottom: 60px;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
.main_btns {
|
||
height: 72px;
|
||
width: 100%;
|
||
bottom: 0;
|
||
left: 0;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
box-shadow: 0px 1px 35px 0px rgba(118, 136, 166, 0.16);
|
||
.btn1 {
|
||
width: 100px;
|
||
height: 40px;
|
||
border: 1px solid #4ea6ff;
|
||
border-radius: 8px;
|
||
color: #4ea6ff;
|
||
background-color: #fff;
|
||
cursor: pointer;
|
||
}
|
||
.btn2 {
|
||
cursor: pointer;
|
||
width: 100px;
|
||
height: 40px;
|
||
background: #4ea6ff;
|
||
border-radius: 8px;
|
||
border: 0;
|
||
margin-left: 15px;
|
||
color: #fff;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
</style>
|
||
|