|
@@ -30,9 +30,10 @@ const form = reactive({
|
|
|
cycle: "月度",
|
|
|
cycleValue: "",
|
|
|
assessmentType: null,
|
|
|
- assessmentObjectList: [
|
|
|
+ listArr: [
|
|
|
{
|
|
|
assessmentObjectId: "",
|
|
|
+ idList: [],
|
|
|
assessmentObjectName: "",
|
|
|
assessmentModelId: "",
|
|
|
assessmentModelName: ""
|
|
@@ -61,12 +62,25 @@ const handleClose = () => {
|
|
|
// // catch error
|
|
|
// });
|
|
|
};
|
|
|
+const arrList = ref([]); // 考核对象与模版设置
|
|
|
+const transformArrayFormat = data => {
|
|
|
+ return data
|
|
|
+ .map(item => {
|
|
|
+ return item.idList.map((id, index) => {
|
|
|
+ return {
|
|
|
+ assessmentObjectId: item.assessmentObjectId[index],
|
|
|
+ assessmentObjectName: item.assessmentObjectName[index],
|
|
|
+ assessmentModelId: item.assessmentModelId,
|
|
|
+ assessmentModelName: item.assessmentModelName
|
|
|
+ };
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .flat();
|
|
|
+};
|
|
|
// 添加部门保存
|
|
|
const saveDepartment = async () => {
|
|
|
form.cycleValue = dayjs(form.cycleValue).format(format.value);
|
|
|
- //
|
|
|
- console.log("form", dayjs(form.cycleValue).format(format.value));
|
|
|
- console.log(form, "获取的数据");
|
|
|
+ form.assessmentObjectList = transformArrayFormat(form.listArr);
|
|
|
const { code, msg } = await postAddAssessment(form);
|
|
|
if (code === 200) {
|
|
|
ElMessage({
|
|
@@ -86,8 +100,9 @@ const open = (item: any, index: string) => {
|
|
|
cycle: "月度",
|
|
|
cycleValue: "",
|
|
|
assessmentType: null,
|
|
|
- assessmentObjectList: [
|
|
|
+ listArr: [
|
|
|
{
|
|
|
+ idList: [],
|
|
|
assessmentObjectId: null,
|
|
|
assessmentObjectName: null,
|
|
|
assessmentModelId: null,
|
|
@@ -101,16 +116,18 @@ const open = (item: any, index: string) => {
|
|
|
dialogVisibleAdd.value = true;
|
|
|
};
|
|
|
const addNew = () => {
|
|
|
- form.assessmentObjectList.push({
|
|
|
+ form.listArr.push({
|
|
|
assessmentObjectId: "",
|
|
|
+ idList: [],
|
|
|
assessmentObjectName: "",
|
|
|
assessmentModelId: "",
|
|
|
assessmentModelName: ""
|
|
|
});
|
|
|
+ arrList.value.push([]);
|
|
|
// form.assessmentObjectList.left.push({ value: "" });
|
|
|
};
|
|
|
const deleteItem = (index: any) => {
|
|
|
- form.assessmentObjectList.splice(index, 1);
|
|
|
+ form.listArr.splice(index, 1);
|
|
|
// form.assessmentObjectList.right.splice(index, 1);
|
|
|
};
|
|
|
// 单选
|
|
@@ -119,9 +136,7 @@ const quarterValue = ref(true);
|
|
|
const format = ref<any>("YYYY-MM");
|
|
|
const pickerType = ref<any>("month");
|
|
|
const handleRegionChange = (value: any) => {
|
|
|
- console.log(value);
|
|
|
timeType.value = value;
|
|
|
- console.log("111", form.cycleValue);
|
|
|
switch (value) {
|
|
|
case "年度":
|
|
|
form.cycleValue = "";
|
|
@@ -200,57 +215,76 @@ const templateparams = reactive({
|
|
|
pageSize: 100
|
|
|
});
|
|
|
const resTmp = ref([]);
|
|
|
-// const postListTreeWithUserApi = async () => {
|
|
|
-// const res = await postListTreeWithUser();
|
|
|
|
|
|
-// console.log("人员", res.data);
|
|
|
-// console.log("人员", transformData(res.data));
|
|
|
-// treeDept.value = [];
|
|
|
-// let aa = res.data;
|
|
|
-// treeDept.value = transformData(aa);
|
|
|
-// };
|
|
|
+// 医疗 -- 部门负责人
|
|
|
+const selectRefs = ref();
|
|
|
+const handChange = index => {
|
|
|
+ const arr = treeDeptList.value.filter(item => {
|
|
|
+ return form.listArr[index].idList.includes(item.userCode);
|
|
|
+ });
|
|
|
+ form.listArr[index].assessmentObjectId = arr.map(item => item.userCode);
|
|
|
+ form.listArr[index].assessmentObjectName = arr.map(item => item.realName);
|
|
|
+};
|
|
|
+
|
|
|
const assessmentTypeRef = ref();
|
|
|
const handleRreeSelect = index => {
|
|
|
- const node = assessmentTypeRef.value[index].getCheckedNodes();
|
|
|
- form.assessmentObjectList[index].assessmentObjectName =
|
|
|
- node[node.length - 1].deptName;
|
|
|
+ const arr = assessmentTypeRef.value[index].getCheckedNodes().filter(item => {
|
|
|
+ return item.children.length == 0;
|
|
|
+ });
|
|
|
+ form.listArr[index].assessmentObjectId = arr.map(item => item.value);
|
|
|
+ form.listArr[index].assessmentObjectName = arr.map(item => item.label);
|
|
|
};
|
|
|
const handleSelect = index => {
|
|
|
- // console.log(index,'form.assessmentObjectList',form.assessmentObjectList[index].am);
|
|
|
- form.assessmentObjectList[index].assessmentModelName =
|
|
|
- form.assessmentObjectList[index].am.tpName;
|
|
|
- form.assessmentObjectList[index].assessmentModelId =
|
|
|
- form.assessmentObjectList[index].am.id;
|
|
|
- // resTmp.value.map(item => {
|
|
|
- // console.log(item);
|
|
|
- // if (item.id == node) {
|
|
|
- // form.assessmentObjectList.assessmentModelName = item.tpName;
|
|
|
- // }
|
|
|
- // });
|
|
|
+ form.listArr[index].assessmentModelName = form.listArr[index].am.tpName;
|
|
|
+ form.listArr[index].assessmentModelId = form.listArr[index].am.id;
|
|
|
};
|
|
|
const aaaa = a => {
|
|
|
console.log(a);
|
|
|
};
|
|
|
// 考核类型
|
|
|
const dpetTree = ref();
|
|
|
+// 转换函数 --- 部门
|
|
|
+const convertDepartmentDataRecursive = data => {
|
|
|
+ return data.map(department => {
|
|
|
+ const { deptCode, deptName, childrenRes } = department;
|
|
|
+ return {
|
|
|
+ value: deptCode,
|
|
|
+ label: deptName,
|
|
|
+ children:
|
|
|
+ childrenRes.length > 0
|
|
|
+ ? childrenRes.map(child => convertDepartmentDataRecursive([child])[0])
|
|
|
+ : []
|
|
|
+ };
|
|
|
+ });
|
|
|
+};
|
|
|
+// 转换函数 --- 人员
|
|
|
+const convertDepartmentDataRecursive_Person = data => {
|
|
|
+ return data.map(department => {
|
|
|
+ const { userNameNew, userCodeNew, children } = department;
|
|
|
+ return {
|
|
|
+ value: userCodeNew,
|
|
|
+ label: userNameNew,
|
|
|
+ children:
|
|
|
+ children.length > 0
|
|
|
+ ? children.map(
|
|
|
+ child => convertDepartmentDataRecursive_Person([child])[0]
|
|
|
+ )
|
|
|
+ : []
|
|
|
+ };
|
|
|
+ });
|
|
|
+};
|
|
|
+const treeDeptListOkay = ref([]);
|
|
|
const assessmentTypeApi = async value => {
|
|
|
// 人员,医疗组,负责人
|
|
|
const { data, code } = await getTemplateInfoList(templateparams);
|
|
|
resTmp.value = data.records;
|
|
|
- console.log(value);
|
|
|
- // treeDept
|
|
|
- // postUserList,
|
|
|
- // postOrganizationUserPage,
|
|
|
- // getLeaderList
|
|
|
- const password = localStorage.getItem("password");
|
|
|
- const rolesName = localStorage.getItem("rolesName");
|
|
|
switch (value) {
|
|
|
case 0:
|
|
|
postListTreeWithUserApi();
|
|
|
break;
|
|
|
case 1:
|
|
|
const { data, code } = await postListTree();
|
|
|
- dpetTree.value = data;
|
|
|
+ dpetTree.value = convertDepartmentDataRecursive(data);
|
|
|
break;
|
|
|
case 2:
|
|
|
const yiliao = await postOrganizationUserPage({
|
|
@@ -270,6 +304,7 @@ const monthTime = ref("");
|
|
|
defineExpose({
|
|
|
open
|
|
|
});
|
|
|
+const idList = ref([]);
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
@@ -386,51 +421,45 @@ defineExpose({
|
|
|
<div class="w-1/3">
|
|
|
<el-form
|
|
|
label-position="top"
|
|
|
- :model="form.assessmentObjectList"
|
|
|
+ :model="form.listArr"
|
|
|
:rules="formLeftRules"
|
|
|
>
|
|
|
<el-form-item label="被考核对象" prop="left">
|
|
|
<div
|
|
|
- v-for="(item, index) in form.assessmentObjectList"
|
|
|
+ v-for="(item, index) in form.listArr"
|
|
|
:key="index"
|
|
|
class="w-full mt-1"
|
|
|
>
|
|
|
<el-tree-select
|
|
|
v-if="form.assessmentType === 0"
|
|
|
ref="assessmentTypeRef"
|
|
|
- v-model="item.assessmentObjectId"
|
|
|
- :data="treeDept"
|
|
|
+ v-model="item.idList"
|
|
|
+ multiple
|
|
|
+ :data="convertDepartmentDataRecursive_Person(treeDept)"
|
|
|
:render-after-expand="false"
|
|
|
show-checkbox
|
|
|
- :props="{
|
|
|
- label: 'userNameNew',
|
|
|
- value: 'userCodeNew',
|
|
|
- children: 'children'
|
|
|
- }"
|
|
|
style="width: 180px"
|
|
|
@check-change="handleRreeSelect(index)"
|
|
|
/>
|
|
|
<el-tree-select
|
|
|
v-if="form.assessmentType === 1"
|
|
|
ref="assessmentTypeRef"
|
|
|
- v-model="item.assessmentObjectId"
|
|
|
+ v-model="item.idList"
|
|
|
:data="dpetTree"
|
|
|
- :render-after-expand="false"
|
|
|
show-checkbox
|
|
|
- :props="{
|
|
|
- label: 'deptName',
|
|
|
- value: 'deptCode',
|
|
|
- children: 'childrenRes'
|
|
|
- }"
|
|
|
+ multiple
|
|
|
style="width: 180px"
|
|
|
+ :render-after-expand="false"
|
|
|
@check-change="handleRreeSelect(index)"
|
|
|
/>
|
|
|
<el-select
|
|
|
v-if="
|
|
|
form.assessmentType != 0 && form.assessmentType != 1
|
|
|
"
|
|
|
- v-model="item.assessmentObjectId"
|
|
|
- @change="handChange"
|
|
|
+ ref="selectRefs"
|
|
|
+ v-model="item.idList"
|
|
|
+ multiple
|
|
|
+ @change="handChange(index)"
|
|
|
>
|
|
|
<el-option
|
|
|
v-for="(it, id) in treeDeptList"
|
|
@@ -446,12 +475,12 @@ defineExpose({
|
|
|
<div class="w-1/2 ml-7">
|
|
|
<el-form
|
|
|
label-position="top"
|
|
|
- :model="form.assessmentObjectList"
|
|
|
+ :model="form.listArr"
|
|
|
:rules="formRightRules"
|
|
|
>
|
|
|
<el-form-item label="考核模板" prop="right">
|
|
|
<div
|
|
|
- v-for="(item, index) in form.assessmentObjectList"
|
|
|
+ v-for="(item, index) in form.listArr"
|
|
|
:key="index"
|
|
|
class="w-full flex mt-1"
|
|
|
>
|