From 6d479f9fbc15e96383fe25270575c976e4356e89 Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期五, 16 五月 2025 17:23:46 +0800 Subject: [PATCH] 新建工地夜间施工管理页面(待完成) --- src/views/fysp/check/components/ComChangeEdit.vue | 65 +++++++++++++++++++------------- 1 files changed, 39 insertions(+), 26 deletions(-) diff --git a/src/views/fysp/check/components/ComChangeEdit.vue b/src/views/fysp/check/components/ComChangeEdit.vue index 1ae4e56..b8b5b27 100644 --- a/src/views/fysp/check/components/ComChangeEdit.vue +++ b/src/views/fysp/check/components/ComChangeEdit.vue @@ -46,32 +46,31 @@ </el-col> </el-row> <div class="flex-div"> - <el-button type="primary" @click="onSubmit">淇濆瓨</el-button> - <el-button @click="$emit('submit', false)">鍙栨秷</el-button> + <el-button type="primary" @click="onSubmit" :loading="loading" + >淇濆瓨</el-button + > + <el-button @click="onCancel">鍙栨秷</el-button> </div> <el-image-viewer - v-if="previewDialogVisible" - :url-list="fileList.map((item) => item.url)" - :initial-index="initialIndex" - @close="previewDialogVisible = false" - alt="棰勮" - class="preview-pic" - /> + v-if="previewDialogVisible" + :url-list="fileList.map((item) => item.url)" + :initial-index="initialIndex" + @close="previewDialogVisible = false" + alt="棰勮" + class="preview-pic" + /> </template> </CompGenericWrapper> </template> <script> import problemApi from '@/api/fysp/problemApi.js'; -import CompGenericWrapper from './CompGenericWrapper.vue'; import { $fysp } from '@/api/index.js'; import fileUtil from '@/utils/fileUtils.js'; import { useCloned } from '@vueuse/core'; import { ElMessage } from 'element-plus'; export default { - emits: ['submit'], - components: { - CompGenericWrapper - }, + emits: ['submit', 'cancel'], + components: {}, watch: { oldChangeFileList: { handler(nv, ov) { @@ -119,13 +118,15 @@ deleteImg: [], ledgerPicDialog: false, - anyPhotoDialog: false + anyPhotoDialog: false, + + loading: false }; }, mounted() {}, methods: { pictureValidate() { - if (this.changeType == 1 && this.fileList.length < 1) { + if (this.fileList.length < 1) { ElMessage({ message: '鑷冲皯涓婁紶涓�寮犲浘鐗�', type: 'error' @@ -162,10 +163,15 @@ this.fileList = useCloned(beforeEditImgList).cloned.value; this.oldFileList = useCloned(beforeEditImgList).cloned.value; }, + onCancel() { + this.$emit('cancel'); + this.$emit('update:visible', false); + }, onSubmit() { if (!this.pictureValidate()) { return; } + this.loading = true; // 鏁版嵁鍑嗗 let data = new FormData(); var picUrls = []; @@ -188,28 +194,35 @@ } }); - const that = this; let deleteImgCopy = this.deleteImg; if (this.changeType == 1) { - fileUtil.getImageFiles(picUrls, function (files) { + fileUtil.getImageFiles(picUrls, (files) => { data.append('deleteImg', deleteImgCopy); - data.append('problemId', that.problemId); + data.append('problemId', this.problemId); files.forEach((image) => { data.append('images', image); }); - problemApi.updateChange(data).then((res) => {}); + problemApi + .updateChange(data) + .then((res) => { + this.$emit('submit', true); + }) + .finally(() => (this.loading = false)); }); - that.$emit('submit', true); } else { - fileUtil.getImageFiles(picUrls, function (files) { - data.append('problemId', that.problemId); + fileUtil.getImageFiles(picUrls, (files) => { + data.append('problemId', this.problemId); files.forEach((image) => { data.append('images', image); }); - problemApi.changeProblem(data).then((res) => {}); - that.$emit('submit', true); + problemApi + .changeProblem(data) + .then((res) => { + this.$emit('submit', true); + }) + .finally(() => (this.loading = false)); }); } }, @@ -220,7 +233,7 @@ } }, handlePictureCardPreview(uploadFile) { - this.initialIndex = this.fileList.indexOf(uploadFile) + this.initialIndex = this.fileList.indexOf(uploadFile); this.previewDialogVisible = true; this.previewDialogImageUrl = uploadFile.url; }, -- Gitblit v1.9.3