mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-11 03:46:45 +08:00
feat:增加单层项目、单层子项目、班级的编辑。
This commit is contained in:
@@ -3,9 +3,9 @@
|
||||
<div class="projectAdd">
|
||||
<div class="header">
|
||||
<span class="title">创建/编辑单层项目</span>
|
||||
<router-link to="/projectmanage" class="goback">
|
||||
<div @click="backPage" style="cursor: pointer;" to="/projectmanage" class="goback">
|
||||
<span class="return"></span><span class="returntext">返回</span>
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="main">
|
||||
@@ -72,8 +72,8 @@
|
||||
</div>
|
||||
|
||||
<div class="in">
|
||||
<a-range-picker separator="至" :placeholder="[' 开始时间', ' 结束时间']"
|
||||
style="width: 100%; height: 40px; border-radius: 5px" show-time @change="onRangeChange" />
|
||||
<a-range-picker separator="至" :placeholder="[' 开始时间', ' 结束时间']" v-model:value="rangevalue"
|
||||
style="width: 100%; height: 40px; border-radius: 5px" @change="onRangeChange" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="name">
|
||||
@@ -167,7 +167,7 @@
|
||||
">BOEU实施</span></a-radio>
|
||||
</div>
|
||||
</div>
|
||||
<div class="name name2">
|
||||
<!-- <div class="name name2">
|
||||
<div class="namebox" style="margin-top: 8px">
|
||||
<img class="nameimg" src="../../assets/images/basicinfo/asterisk.png" />
|
||||
<div class="inname">附件</div>
|
||||
@@ -177,24 +177,28 @@
|
||||
<img v-if="fileList1.length < 6" class="fileimg" src="../../assets/images/projectadd/enclosure.png" />
|
||||
<a-upload :disabled="fileList1.length > 5" :before-upload="beforeUpload1" v-model:file-list="fileList1"
|
||||
@remove="removeFile" name="file" action="/api/file/upload" :headers="headers" @change="handleChange1">
|
||||
<!-- <a-button> -->
|
||||
<!-- <upload-outlined></upload-outlined> -->
|
||||
<span v-if="fileList1.length > 5" class="filetext">上传数量已经达到最大值</span>
|
||||
<span v-else class="filetext">上传附件</span>
|
||||
<!-- </a-button> -->
|
||||
</a-upload>
|
||||
</div>
|
||||
<div class="support">
|
||||
支持.pdf,.ppt,.pptx,.doc,.docx,.xls,.xlsx,.jpg,.jpeg,.png,.gif,.zip
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="template">
|
||||
<div class="name">
|
||||
<div class="inname" style="width: 50px">模版</div>
|
||||
<div class="in select" style="margin-left: 2px">
|
||||
<a-select :getPopupContainer="
|
||||
<a-select v-if="isEdit" disabled="true" :getPopupContainer="
|
||||
(triggerNode) => {
|
||||
return triggerNode.parentNode || document.body;
|
||||
}
|
||||
" v-model:value="classifySelect5" placeholder="请选择模版" :size="size" style="width: 100%" :options="classifyList5"
|
||||
@change="classificationChange5">
|
||||
</a-select>
|
||||
<a-select v-else :getPopupContainer="
|
||||
(triggerNode) => {
|
||||
return triggerNode.parentNode || document.body;
|
||||
}
|
||||
@@ -208,7 +212,7 @@
|
||||
<div class="footer">
|
||||
<div class="btn">
|
||||
<a-button v-on:click="createProject" type="primary" class="btn1">确定</a-button>
|
||||
<a-button class="btn2">取消</a-button>
|
||||
<a-button @click="backPage" class="btn2">取消</a-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -216,13 +220,138 @@
|
||||
<script>
|
||||
import { reactive, toRefs, ref } from "vue";
|
||||
import { message } from "ant-design-vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import dayjs from 'dayjs';
|
||||
import * as api from "../../api/index";
|
||||
import { storage } from '../../api/storage';
|
||||
import { toDate } from '../../api/method'
|
||||
|
||||
export default {
|
||||
name: "projectAdd",
|
||||
setup() {
|
||||
api.getProjectDetail({ projectId: 3 }).then(res => { console.log(res) }).catch(err => { console.log(err) })
|
||||
// 编辑页面跳转过来时候,自动填充表格
|
||||
const routers = useRoute();
|
||||
const isEdit = ref(false);
|
||||
let peojectID = "";
|
||||
|
||||
if (routers.query.projectId) {
|
||||
storage.set("projectAddId", routers.query.projectId);
|
||||
isEdit.value = true;
|
||||
peojectID = routers.query.projectId;
|
||||
// 需要编辑
|
||||
api.getProjectDetail({ projectId: routers.query.projectId }).then(res => {
|
||||
if (res.status == 200 && res.data.code == 200) {
|
||||
let info = res.data.data.projectInfo;
|
||||
console.log(info)
|
||||
// projectName classifySelect imageUrl * classifySelect1 * remark checked classifySelect3 classifySelect4 changeChecked1 *
|
||||
projectName.value = info.name;
|
||||
state.classifySelect = classifyList.value[1]; // info.category
|
||||
imageUrl.value = info.picUrl;
|
||||
|
||||
let start = toDate(info.beginTime/1000,'YYYY/MM/DD');
|
||||
let end = toDate(info.endTime/1000,'YYYY/MM/DD');
|
||||
state.rangevalue = [
|
||||
dayjs(start, 'YYYY/MM/DD'),
|
||||
dayjs(end, 'YYYY/MM/DD'),
|
||||
];
|
||||
|
||||
let manageName = info.manager.split(",");
|
||||
let manageValue = info.managerId.split(",");
|
||||
let optionsManage = []
|
||||
for (let i = 0; i < manageName.length; i++) {
|
||||
let obj = {
|
||||
label: manageName[i],
|
||||
value: manageValue[i]
|
||||
}
|
||||
optionsManage.push(obj)
|
||||
}
|
||||
console.log(optionsManage)
|
||||
state.classifySelect1 = optionsManage;
|
||||
state.classifySelect2 = classifyList2.value[info.sourceBelongId - 1];
|
||||
remark.value = info.remark;
|
||||
state.checked = info.boeFlag ? info.boeFlag : false;
|
||||
state.classifySelect3 = classifyList3.value[info.level];
|
||||
state.classifySelect4 = classifyList4.value[info.systemId - 1];
|
||||
state.checked1 = info.boeFlag ? info.boeFlag : false;
|
||||
// fileList1.value = info.attach.split(",");
|
||||
|
||||
projectType = 1;
|
||||
picUrl = info.picUrl;
|
||||
beginTime = Number(info.beginTime/1000);
|
||||
endTime = Number(info.endTime/1000);
|
||||
manager = info.manager;
|
||||
managerId = info.managerId;
|
||||
sourceBelongIdC = Number(info.sourceBelongId);
|
||||
courseSyncFlag = info.courseSyncFlag;
|
||||
levels = info.level;
|
||||
systemid = info.systemId;
|
||||
boeFlag = info.boeFlag;
|
||||
}
|
||||
}).catch(err => { console.log(err) })
|
||||
} else {
|
||||
if (storage.get("projectAddId")) {
|
||||
isEdit.value = true;
|
||||
peojectID = storage.get("projectAddId");
|
||||
// 需要编辑
|
||||
api.getProjectDetail({ projectId: storage.get("projectAddId") }).then(res => {
|
||||
if (res.status == 200 && res.data.code == 200) {
|
||||
let info = res.data.data.projectInfo;
|
||||
console.log("我是从本地存储获取的id", info)
|
||||
projectName.value = info.name;
|
||||
state.classifySelect = classifyList.value[1]; // info.category
|
||||
imageUrl.value = info.picUrl;
|
||||
|
||||
let start = toDate(info.beginTime/1000,'YYYY/MM/DD');
|
||||
let end = toDate(info.endTime/1000,'YYYY/MM/DD');
|
||||
state.rangevalue = [
|
||||
dayjs(start, 'YYYY/MM/DD'),
|
||||
dayjs(end, 'YYYY/MM/DD'),
|
||||
];
|
||||
|
||||
let manageName = info.manager.split(",");
|
||||
let manageValue = info.managerId.split(",");
|
||||
let optionsManage = []
|
||||
for (let i = 0; i < manageName.length; i++) {
|
||||
let obj = {
|
||||
label: manageName[i],
|
||||
value: manageValue[i]
|
||||
}
|
||||
optionsManage.push(obj)
|
||||
}
|
||||
console.log(optionsManage)
|
||||
state.classifySelect1 = optionsManage;
|
||||
state.classifySelect2 = classifyList2.value[info.sourceBelongId - 1];
|
||||
remark.value = info.remark;
|
||||
state.checked = info.boeFlag ? info.boeFlag : false;
|
||||
state.classifySelect3 = classifyList3.value[info.level];
|
||||
state.classifySelect4 = classifyList4.value[info.systemId - 1];
|
||||
state.checked1 = info.boeFlag ? info.boeFlag : false;
|
||||
|
||||
projectType = 1;
|
||||
picUrl = info.picUrl;
|
||||
beginTime = Number(info.beginTime/1000);
|
||||
endTime = Number(info.endTime/1000);
|
||||
manager = info.manager;
|
||||
managerId = info.managerId;
|
||||
sourceBelongIdC = Number(info.sourceBelongId);
|
||||
courseSyncFlag = info.courseSyncFlag;
|
||||
levels = info.level;
|
||||
systemid = info.systemId;
|
||||
boeFlag = info.boeFlag;
|
||||
}
|
||||
}).catch(err => { console.log(err) })
|
||||
}
|
||||
}
|
||||
|
||||
const backPage = () => {
|
||||
storage.remove("projectAddId");
|
||||
setTimeout(() => {
|
||||
router.push({
|
||||
path: "/projectmanage"
|
||||
});
|
||||
}, 400);
|
||||
}
|
||||
|
||||
const router = useRouter();
|
||||
const state = reactive({
|
||||
classifySelect: null,
|
||||
@@ -232,6 +361,11 @@ export default {
|
||||
valueE: null,
|
||||
valueE1: null,
|
||||
valueE2: null,
|
||||
classifySelect1: [],
|
||||
classifySelect2: [],
|
||||
classifySelect3: [],
|
||||
classifySelect4: [],
|
||||
rangevalue: []
|
||||
});
|
||||
|
||||
const projectName = ref("");
|
||||
@@ -347,6 +481,8 @@ export default {
|
||||
|
||||
let beginTime = "";
|
||||
let endTime = "";
|
||||
const dateFormatList = ['YYYY/MM/DD'];
|
||||
|
||||
const onRangeChange = (value, dateString) => {
|
||||
console.log("Selected Time: ", value);
|
||||
// 项目时间选择函数
|
||||
@@ -368,8 +504,8 @@ export default {
|
||||
|
||||
let manager = "";
|
||||
let managerId = "";
|
||||
const classificationChange1 = (key) => {
|
||||
console.log(`selected ${key}`, classifyList1);
|
||||
const classificationChange1 = (key, options) => {
|
||||
console.log(`selected ${key}`, options);
|
||||
let mstr = "";
|
||||
let midstr = "";
|
||||
for (let i = 0; i < key.length; i++) {
|
||||
@@ -382,6 +518,14 @@ export default {
|
||||
}
|
||||
}
|
||||
console.log(mstr, midstr);
|
||||
state.classifySelect1 = options;
|
||||
let newoptions = [];
|
||||
for (let i = 0; i < state.classifySelect1.length; i++) {
|
||||
if (state.classifySelect1[i].value) {
|
||||
newoptions.push(state.classifySelect1[i])
|
||||
}
|
||||
}
|
||||
state.classifySelect1 = newoptions;
|
||||
manager = mstr;
|
||||
managerId = midstr;
|
||||
};
|
||||
@@ -393,8 +537,10 @@ export default {
|
||||
{ value: 3, label: "项目三" },
|
||||
]);
|
||||
|
||||
let sourceBelongIdC = '';
|
||||
const classificationChange2 = (key) => {
|
||||
console.log(`selected ${key}`, classifyList2);
|
||||
sourceBelongIdC = key;
|
||||
};
|
||||
|
||||
// 项目级别
|
||||
@@ -404,8 +550,11 @@ export default {
|
||||
{ value: 3, label: "现地级" },
|
||||
{ value: 4, label: "部门级" },
|
||||
]);
|
||||
|
||||
let levels = "";
|
||||
const classificationChange3 = (key) => {
|
||||
console.log(`selected ${key}`, classifyList3);
|
||||
levels = key;
|
||||
};
|
||||
|
||||
// 培训体系
|
||||
@@ -415,8 +564,11 @@ export default {
|
||||
{ value: 3, label: "现地级" },
|
||||
{ value: 4, label: "部门级" },
|
||||
]);
|
||||
|
||||
let systemid = "";
|
||||
const classificationChange4 = (key) => {
|
||||
console.log(`selected ${key}`, classifyList4);
|
||||
systemid = key;
|
||||
};
|
||||
|
||||
// 模版
|
||||
@@ -479,66 +631,128 @@ export default {
|
||||
sourceBelongId: "请选择资源归属",
|
||||
level: "请填写项目级别",
|
||||
systemId: "请填写项目培训体系",
|
||||
boeFlag: "请选择是否BOE实施",
|
||||
attach: "请上传附件",
|
||||
boeFlag: "请选择是否BOE实施"
|
||||
};
|
||||
|
||||
|
||||
const createProject = () => {
|
||||
let obj = {
|
||||
name: projectName["value"],
|
||||
category: projectType,
|
||||
picUrl: picUrl,
|
||||
beginTime: beginTime,
|
||||
endTime: endTime,
|
||||
manager: manager,
|
||||
managerId: managerId,
|
||||
sourceBelongId: 11,
|
||||
remark: remark["value"],
|
||||
courseSyncFlag: courseSyncFlag,
|
||||
level: 3,
|
||||
systemId: 4,
|
||||
boeFlag: boeFlag,
|
||||
attach: attach,
|
||||
type: 3,
|
||||
templateId: 10,
|
||||
parentId: 0,
|
||||
notice: "",
|
||||
noticeFlag: 0,
|
||||
status: 0,
|
||||
};
|
||||
console.log("提交的数据格式 %o", obj);
|
||||
for (let i in errorMsgs) {
|
||||
console.log(obj[i]);
|
||||
if (obj[i] === "" || obj[i] === undefined) {
|
||||
message.destroy();
|
||||
message.warning(errorMsgs[i]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
console.log('我是否要编辑项目', isEdit.value)
|
||||
if (isEdit.value) {
|
||||
console.log('我要编辑项目', peojectID)
|
||||
let obj = {
|
||||
projectId: Number(peojectID),
|
||||
name: projectName["value"],
|
||||
category: projectType,
|
||||
picUrl: picUrl,
|
||||
beginTime: beginTime,
|
||||
endTime: endTime,
|
||||
manager: manager,
|
||||
managerId: managerId,
|
||||
sourceBelongId: sourceBelongIdC,
|
||||
remark: remark["value"],
|
||||
courseSyncFlag: courseSyncFlag,
|
||||
level: levels,
|
||||
systemId: systemid,
|
||||
boeFlag: boeFlag,
|
||||
attach: attach,
|
||||
type: 3,
|
||||
templateId: 0,
|
||||
parentId: 0,
|
||||
notice: "",
|
||||
noticeFlag: 0,
|
||||
status: 0,
|
||||
};
|
||||
|
||||
api
|
||||
.createProject(obj)
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
if (res.status == 200 && res.data.code == 200) {
|
||||
console.log(obj);
|
||||
|
||||
for (let i in errorMsgs) {
|
||||
console.log(obj[i]);
|
||||
if (obj[i] === "" || obj[i] === undefined) {
|
||||
message.destroy();
|
||||
message.success("创建成功");
|
||||
setTimeout(() => {
|
||||
router.push({
|
||||
path: "/taskpage",
|
||||
query: { id: res.data.data.projectId },
|
||||
});
|
||||
}, 1000);
|
||||
} else {
|
||||
message.warning(errorMsgs[i]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
api
|
||||
.createProject(obj)
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
if (res.status == 200 && res.data.code == 200) {
|
||||
message.destroy();
|
||||
message.success("编辑成功");
|
||||
setTimeout(() => {
|
||||
router.push({
|
||||
path: "/projectmanage"
|
||||
});
|
||||
}, 1000);
|
||||
} else {
|
||||
message.destroy();
|
||||
message.error("编辑失败,请检查当前网络状态。");
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
message.destroy();
|
||||
message.error("编辑失败,请检查当前网络状态。");
|
||||
});
|
||||
|
||||
} else {
|
||||
let obj = {
|
||||
name: projectName["value"],
|
||||
category: projectType,
|
||||
picUrl: picUrl,
|
||||
beginTime: beginTime,
|
||||
endTime: endTime,
|
||||
manager: manager,
|
||||
managerId: managerId,
|
||||
sourceBelongId: sourceBelongIdC,
|
||||
remark: remark["value"],
|
||||
courseSyncFlag: courseSyncFlag,
|
||||
level: levels,
|
||||
systemId: systemid,
|
||||
boeFlag: boeFlag,
|
||||
attach: attach,
|
||||
type: 3,
|
||||
templateId: 10,
|
||||
parentId: 0,
|
||||
notice: "",
|
||||
noticeFlag: 0,
|
||||
status: 0,
|
||||
};
|
||||
console.log("提交的数据格式 %o", obj);
|
||||
for (let i in errorMsgs) {
|
||||
console.log(obj[i]);
|
||||
if (obj[i] === "" || obj[i] === undefined) {
|
||||
message.destroy();
|
||||
message.warning(errorMsgs[i]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
api
|
||||
.createProject(obj)
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
if (res.status == 200 && res.data.code == 200) {
|
||||
message.destroy();
|
||||
message.success("创建成功");
|
||||
setTimeout(() => {
|
||||
router.push({
|
||||
path: "/taskpage",
|
||||
query: { id: res.data.data.projectId },
|
||||
});
|
||||
}, 1000);
|
||||
} else {
|
||||
message.destroy();
|
||||
message.error("创建失败,请检查当前网络状态。");
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
message.destroy();
|
||||
message.error("创建失败,请检查当前网络状态。");
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
message.destroy();
|
||||
message.error("创建失败,请检查当前网络状态。");
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
@@ -571,6 +785,10 @@ export default {
|
||||
uplodaFileCount,
|
||||
createProject,
|
||||
removeFile,
|
||||
|
||||
isEdit,
|
||||
backPage,
|
||||
dateFormatList,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user