From 43981545c5aefdb4248d89e3121a200d53332c7a Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期二, 22 十月 2024 17:44:21 +0800 Subject: [PATCH] 1. 添加子任务编辑功能(暂存) --- src/views/fysp/task/components/CompSubTaskSelect.vue | 6 + src/views/fysp/task/TaskProxy.js | 23 +++++ src/api/fysp/subtaskApi.js | 10 + src/views/fysp/task/components/CompDayTask.vue | 108 ++++++++++++++++---------- src/components.d.ts | 1 src/views/fysp/task/components/CompSubTaskEdit.vue | 15 +++ src/components/form/FYForm.vue | 4 src/views/fysp/task/components/CompSubTaskList.vue | 44 +++++++--- src/views/fysp/task/TaskManage.vue | 10 ++ src/views/fysp/task/components/CompMonitorPlan.vue | 18 +++- 10 files changed, 165 insertions(+), 74 deletions(-) diff --git a/src/api/fysp/subtaskApi.js b/src/api/fysp/subtaskApi.js index 972f307..0e91dc7 100644 --- a/src/api/fysp/subtaskApi.js +++ b/src/api/fysp/subtaskApi.js @@ -3,10 +3,14 @@ export default { /** * 璋冩暣瀛愪换鍔′俊鎭� - * @param {Object} subtask - * @returns + * @param {Object} subtask + * @returns */ - adjustSubtask(subtask){ + adjustSubtask(subtask) { return $fysp.post(`subtask/adjust`, subtask).then((res) => res.data); }, + + putSubtasks(subtaskList) { + return $fysp.put(`subtask/addlist`, subtaskList).then((res) => res.data); + } }; diff --git a/src/components.d.ts b/src/components.d.ts index 37e7435..eb01fe9 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -62,7 +62,6 @@ ElTabs: typeof import('element-plus/es')['ElTabs'] ElTag: typeof import('element-plus/es')['ElTag'] ElText: typeof import('element-plus/es')['ElText'] - ElTooltip: typeof import('element-plus/es')['ElTooltip'] ElTree: typeof import('element-plus/es')['ElTree'] ElUpload: typeof import('element-plus/es')['ElUpload'] Footer: typeof import('./components/core/Footer.vue')['default'] diff --git a/src/components/form/FYForm.vue b/src/components/form/FYForm.vue index f8654cc..ef4cbb8 100644 --- a/src/components/form/FYForm.vue +++ b/src/components/form/FYForm.vue @@ -120,15 +120,13 @@ 'submit', formObj, () => { - loading.value = false; resolve(); }, (err) => { - loading.value = false; reject(err ? err : ''); } ); - }); + }).finally(() => (loading.value = false)); } //鍙栨秷鎸夐挳瑙﹀彂 diff --git a/src/views/fysp/task/TaskManage.vue b/src/views/fysp/task/TaskManage.vue index 8940905..c46b0af 100644 --- a/src/views/fysp/task/TaskManage.vue +++ b/src/views/fysp/task/TaskManage.vue @@ -41,6 +41,7 @@ <el-row> <el-col :span="curSubTaskList ? 16 : 24"> <CompMonitorPlan + ref="planRef" :task="curTask.data" @date-change="onDateChange" ></CompMonitorPlan> @@ -52,6 +53,7 @@ :loading="subTaskLoading" height="56vh" @add="subTaskDrawer = true" + @submit="handleSubtaskSubmit" ></CompSubTaskList> </el-col> </el-row> @@ -242,11 +244,11 @@ this.sideLoading = false; this.mainLoading = true; this.curSubTaskList = undefined; + this.curTask = task; taskApi .fetchMonitorObjectVersion(task.data.tguid) .then((res) => { this.curMonitorObjList = res; - this.curTask = task; }) .finally(() => { this.mainLoading = false; @@ -293,6 +295,12 @@ task: encodeURIComponent(JSON.stringify(value)) } }); + }, + handleSubtaskSubmit() { + this.subTaskLoading = true; + this.$refs.planRef + .fetchDayTasks() + .finally(() => (this.subTaskLoading = false)); } }, mounted() { diff --git a/src/views/fysp/task/TaskProxy.js b/src/views/fysp/task/TaskProxy.js index 076fcbb..7433661 100644 --- a/src/views/fysp/task/TaskProxy.js +++ b/src/views/fysp/task/TaskProxy.js @@ -4,5 +4,28 @@ */ ceateSubTask(){ + }, + + /** + * 鏍规嵁澶氶�変笅鎷夋鐨勯�夐」鍊硷紝杩斿洖浠诲姟鎵ц浜哄璞� + * @returns + */ + getExecutors(data, executorOptions) { + const ids = []; + const uNames = []; + const rNames = []; + executorOptions.forEach((e) => { + const index = data.indexOf(e.value); + if (index != -1) { + ids.push(e.data.guid); + uNames.push(e.data.acountname); + rNames.push(e.data.realname); + } + }); + return { + id: ids.join('#'), + uName: uNames.join('#'), + rName: rNames.join('#') + }; } } \ No newline at end of file diff --git a/src/views/fysp/task/components/CompDayTask.vue b/src/views/fysp/task/components/CompDayTask.vue index db5bab8..f476c5b 100644 --- a/src/views/fysp/task/components/CompDayTask.vue +++ b/src/views/fysp/task/components/CompDayTask.vue @@ -9,56 +9,39 @@ :data="seletedSceneList" :dayTask="dayTask" @delete="deleteScene" + @submit="createSubtasks" ></CompSubTaskSelect> <div> <!-- <el-scrollbar height="50vh"> --> - <CompMonitorObj :data="curMonitorObjList" height="50vh"> - <template #default="{ item }"> - <el-button - v-if="item.select" - size="small" - type="info" - plain - disabled - icon="select" - >閫夋嫨</el-button - > - <el-button - v-else - size="small" - type="primary" - plain - @click="selectScene(item)" - >閫夋嫨</el-button - > - </template> - </CompMonitorObj> + <CompMonitorObj :data="curMonitorObjList" height="50vh"> + <template #default="{ item }"> + <el-button + v-if="item.select" + size="small" + type="info" + plain + disabled + icon="select" + >閫夋嫨</el-button + > + <el-button + v-else + size="small" + type="primary" + plain + @click="selectScene(item)" + >閫夋嫨</el-button + > + </template> + </CompMonitorObj> <!-- </el-scrollbar> --> </div> </el-col> <el-col :span="8"> - <el-row justify="space-between"> - <el-text>鍗曟棩璁″垝</el-text> - <el-button type="success" size="small" @click="editTask" - >鏂板</el-button - > - </el-row> - <el-divider /> - <div> - <el-scrollbar :height="height"> - <ItemSubTask - v-for="stask in curSubTaskList" - :key="stask.guid" - :item="stask" - > - <template #default="{ item }"> - <el-button type="danger" size="small" @click="editTask" - >绉婚櫎</el-button - > - </template> - </ItemSubTask> - </el-scrollbar> - </div> + <CompSubTaskList + v-model="curSubTaskList" + :height="height" + ></CompSubTaskList> </el-col> </el-row> </template> @@ -67,10 +50,13 @@ import { useCloned } from '@vueuse/core'; import { useRoute, useRouter } from 'vue-router'; import taskApi from '@/api/fysp/taskApi'; +import subtaskApi from '@/api/fysp/subtaskApi'; import TaskProxy from '../TaskProxy'; import CompMonitorObj from './CompMonitorObj.vue'; import CompSubTaskSelect from './CompSubTaskSelect.vue'; +import CompSubTaskList from './CompSubTaskList.vue'; +import dayjs from 'dayjs'; const route = useRoute(); @@ -137,5 +123,41 @@ const index = seletedSceneList.value.indexOf(item); seletedSceneList.value.splice(index, 1); } + +function createSubtasks(executors) { + const dt = props.dayTask; + const subtasks = seletedSceneList.value.map((_) => { + const s = _.scene + return { + // 涓婚敭鐢辨湇鍔$鍒涘缓 + stguid: undefined, + tguid: dt.tsGuid, + tsguid: dt.guid, + name: `${s.name}宸℃煡`, + typeno: 1, + type: '宸℃煡', + provincecode: s.provincecode, + provincename: s.provincename, + citycode: s.citycode, + cityname: s.cityname, + districtcode: s.districtcode, + districtname: s.districtname, + scensename: s.name, + scenseid: s.guid, + scenseaddress: s.location, + planstarttime: dt.date, + planendtime: dayjs(dt.date).endOf('day').set('millisecond', 0).toDate(), + deployerguid: 'rAR0A4gJdlOZEqZs', + deployerusername: 'ccheck', + deployerrealname: '鏁存敼瀹℃牳', + executorguids: executors.ids, + executorusernames: executors.uName, + executorrealtimes: executors.rName, + status: '鏈墽琛�', + remark: undefined + }; + }); + subtaskApi.putSubtasks(subtasks) +} </script> <style scoped></style> diff --git a/src/views/fysp/task/components/CompMonitorPlan.vue b/src/views/fysp/task/components/CompMonitorPlan.vue index 037c36c..5b86666 100644 --- a/src/views/fysp/task/components/CompMonitorPlan.vue +++ b/src/views/fysp/task/components/CompMonitorPlan.vue @@ -57,7 +57,7 @@ }); const emit = defineEmits(['dateChange']); // 閫変腑鏃ユ湡 -const dateValue = ref(new Date()); +const dateValue = ref(); // 鏃ュ巻鏍囬 const title = computed(() => { if (props.task) { @@ -101,12 +101,16 @@ // 鑾峰彇鏃ヤ换鍔$粺璁′俊鎭� const dayTaskLoading = ref(false); const dayTaskList = ref([]); -function fetchDayTasks(topTaskId) { +function fetchDayTasks() { dayTaskLoading.value = true; - taskApi - .fetchDayTasks(topTaskId) + return taskApi + .fetchDayTasks(props.task.tguid) .then((res) => { dayTaskList.value = res; + // 濡傛灉宸查�夋棩鏈熷瓨鍦紝鍦ㄩ噸鏂拌幏鍙栨棩浠诲姟缁熻淇℃伅鍚庯紝鍐嶆瑙﹀彂鐐瑰嚮浜嬩欢 + if (dateValue.value) { + onDateChange(dateValue.value) + } }) .finally(() => (dayTaskLoading.value = false)); } @@ -150,12 +154,14 @@ watch( () => props.task, (nV) => { - if (nV.tguid) { - fetchDayTasks(nV.tguid); + if (nV && nV.tguid) { + fetchDayTasks(); } }, { immediate: true } ); + +defineExpose({ fetchDayTasks }); </script> <style scoped> .li-01 { diff --git a/src/views/fysp/task/components/CompSubTaskEdit.vue b/src/views/fysp/task/components/CompSubTaskEdit.vue index a7d6f47..f80a20a 100644 --- a/src/views/fysp/task/components/CompSubTaskEdit.vue +++ b/src/views/fysp/task/components/CompSubTaskEdit.vue @@ -1,5 +1,6 @@ <template> <FYForm + ref="formRef" :form-info="formInfo" :rules="rules" :useCancel="true" @@ -23,6 +24,7 @@ :initValue="false" type="date" v-model:value="formObj.planstarttime" + @change="handleTimeChange" ></FYOptionTime> <el-form-item label="鎵ц浜�" prop="_executors"> <el-select @@ -49,6 +51,7 @@ import { ref, computed, onMounted, reactive } from 'vue'; import subtaskApi from '@/api/fysp/subtaskApi'; import userApi from '@/api/fysp/userApi'; +import dayjs from 'dayjs'; const props = defineProps({ //鍩烘湰淇℃伅 @@ -57,8 +60,9 @@ create: Boolean }); -const emit = defineEmits(['submit', 'cancel']); +const emit = defineEmits(['submit', 'cancel', 'update:modelValue']); +const formRef = ref(null); // 浠诲姟鎵ц浜洪�夐」 const executorOptions = ref([]); const formInfo = computed(() => { @@ -86,6 +90,10 @@ } ] }); + +function handleTimeChange(time) { + formRef.value.formObj.planendtime = dayjs(time).endOf('day').set('millisecond', 0) +} function getExecutors(data) { const ids = []; @@ -123,6 +131,7 @@ return subtaskApi .adjustSubtask(v) .then(() => { + emit('update:modelValue', v) emit('submit', v); success(); }) @@ -131,6 +140,10 @@ }); } function submit(v, success, fail) { + const executors = getExecutors(v.value); + v.value.executorguids = executors.id + v.value.executorusernames = executors.uName + v.value.executorrealtimes = executors.rName return props.create ? createScene(v.value, success, fail) : updateScene(v.value, success, fail); diff --git a/src/views/fysp/task/components/CompSubTaskList.vue b/src/views/fysp/task/components/CompSubTaskList.vue index b678652..fa2e87d 100644 --- a/src/views/fysp/task/components/CompSubTaskList.vue +++ b/src/views/fysp/task/components/CompSubTaskList.vue @@ -2,7 +2,7 @@ <el-row justify="space-between"> <el-text>鍗曟棩璁″垝</el-text> <el-button - v-show="create && modelValue && modelValue.length > 0" + v-show="create && data && data.length > 0" type="success" size="small" @click="add" @@ -13,16 +13,21 @@ <div> <el-scrollbar v-loading="loading" :height="height"> <el-space - v-if="modelValue && modelValue.length > 0" + v-if="data && data.length > 0" fill :fill-ratio="100" direction="vertical" style="width: 100%" > - <ItemSubTask v-for="s in modelValue" :key="s.guid" :item="s"> + <ItemSubTask v-for="s in data" :key="s.guid" :item="s"> <template #default="{ item }"> <el-space direction="vertical"> - <el-button plain type="primary" size="small" @click="edit(item)" + <el-button + :disabled="item.status != '鏈墽琛�'" + plain + type="primary" + size="small" + @click="edit(item)" >缂栬緫</el-button > <el-button @@ -38,7 +43,7 @@ </el-space> <div v-else> <el-empty description="鏃犱换鍔¤褰�" /> - <el-row justify="center"> + <el-row v-if="create" justify="center"> <el-button type="success" size="small" @click="add" >娣诲姞浠诲姟</el-button > @@ -57,7 +62,7 @@ > <CompSubTaskEdit v-model="activeItem" - @submit="dialogVisible = false" + @submit="onEditSubmit" @cancel="dialogVisible = false" ></CompSubTaskEdit> </el-dialog> @@ -78,11 +83,11 @@ loading: Boolean }); -const dialogVisible = ref(false) -const activeItem = ref(null) +const dialogVisible = ref(false); +const activeItem = ref(null); const data = computed(() => props.modelValue); -const emit = defineEmits(['edit', 'add', 'remove', 'update:modelValue']); +const emit = defineEmits(['submit', 'add', 'remove', 'update:modelValue']); function remove(item) { if (item.status == '鏈墽琛�') { @@ -101,16 +106,25 @@ } function edit(item) { - activeItem.value = item - dialogVisible.value = true - emit('edit'); + activeItem.value = item; + dialogVisible.value = true; +} + +function onEditSubmit(item) { + dialogVisible.value = false; + const index = data.value.findIndex((v) => { + return item.stguid == v.stguid; + }); + data.value.splice(index, 1, item); + emit('update:modelValue', data.value); + emit('submit'); } function add() { emit('add'); } -onUnmounted(()=>{ - dialogVisible.value = false -}) +onUnmounted(() => { + dialogVisible.value = false; +}); </script> diff --git a/src/views/fysp/task/components/CompSubTaskSelect.vue b/src/views/fysp/task/components/CompSubTaskSelect.vue index cdf66b9..53a4e03 100644 --- a/src/views/fysp/task/components/CompSubTaskSelect.vue +++ b/src/views/fysp/task/components/CompSubTaskSelect.vue @@ -73,6 +73,7 @@ import { ref, reactive, watch, computed, onMounted } from 'vue'; import { ElMessageBox, ElNotification, ElMessage } from 'element-plus'; import taskApi from '@/api/fysp/taskApi'; +import TaskProxy from '../TaskProxy'; onMounted(() => { // if (props.height) { @@ -91,7 +92,7 @@ dayTask: Object }); -const emit = defineEmits(['delete']); +const emit = defineEmits(['submit', 'delete']); const scrollHeight = ref('14vh'); @@ -120,6 +121,9 @@ fail('鏈�夋嫨鐩戠鍦烘櫙'); } else { success(); + // 灏嗕换鍔℃墽琛屼汉鏍煎紡鍖栧苟浼犻�� + const param = TaskProxy.getExecutors(v.value.executor, executors.value) + emit('submit', param) } } -- Gitblit v1.9.3