| | |
| | | </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) { |
| | |
| | | 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' |
| | |
| | | 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 = []; |
| | |
| | | } |
| | | }); |
| | | |
| | | 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)); |
| | | }); |
| | | } |
| | | }, |
| | |
| | | } |
| | | }, |
| | | handlePictureCardPreview(uploadFile) { |
| | | this.initialIndex = this.fileList.indexOf(uploadFile) |
| | | this.initialIndex = this.fileList.indexOf(uploadFile); |
| | | this.previewDialogVisible = true; |
| | | this.previewDialogImageUrl = uploadFile.url; |
| | | }, |