From 4b04e7fd4fcad9af480a003509288aa6070b137e Mon Sep 17 00:00:00 2001 From: jinlin <jinlin> Date: 星期日, 04 二月 2024 13:51:45 +0800 Subject: [PATCH] 修改 --- web/src/components/table-uploader/src/table-uploader.vue | 186 ++++++++++++++++++++++------------------------ 1 files changed, 88 insertions(+), 98 deletions(-) diff --git a/web/src/components/table-uploader/src/table-uploader.vue b/web/src/components/table-uploader/src/table-uploader.vue index 73483a3..89fc419 100644 --- a/web/src/components/table-uploader/src/table-uploader.vue +++ b/web/src/components/table-uploader/src/table-uploader.vue @@ -2,11 +2,12 @@ <div> <div class="config-uploader1" v-if="oss"> <div v-for="group in (oss.groups || [])" :key="group.busiFieldGroup"> - <zt-form-item v-for="field in group.fields" :prop="field.busiField" - :key="field.busiField" :rules="field.isRequired ? 'required':''" style="width: 100%;margin-bottom: 0"> - <zt-uploader v-model="dataForm[field.busiField]" multiple :limit="field.fileLimit" :file-type="field.fileType" - :accept="field.accept" :file-size="field.fileSize" @input="change(field.busiField)"/> - </zt-form-item> + <zt-form-item v-for="field in group.fields" :prop="field.busiField" + :key="field.busiField" :rules="field.isRequired ? 'required':''" + style="width: 100%;margin-bottom: 0"> + <zt-uploader v-model="dataForm[field.busiField]" multiple :limit="field.fileLimit" :file-type="field.fileType" + :accept="field.accept" :file-size="field.fileSize" @input="change(field.busiField)"/> + </zt-form-item> </div> </div> </div> @@ -14,107 +15,96 @@ </template> <script> -export default { - name: 'TableUploader', - components: {}, - props: { - value: Object, - dataForm: Object, - image:false, - busiType: String // 涓氬姟绫诲瀷 - }, - data() { - return { - activeNames: ['1'], - oss: null - } - }, - computed: { - fields() { - let arr = [] - if (this.dataForm.files && this.dataForm.files.groups) { - this.dataForm.files.groups.forEach(group => { - group.fields.forEach(field => arr.push(field)) - }) - } - return arr - } - }, - watch: { - value(val, oldval) { - if (JSON.stringify(val) !== JSON.stringify(oldval)) { - this.oss = { - ...this.getOss(), - ...(val || {}) - } - console.log(this.oss,"this.oss") - // this.dataForm.files = this.oss - this.$set(this.dataForm, 'files', this.oss) - // 鍒嗚В鍒版瘡涓瓧娈电粰dataForm璧嬪�� - this.fields.forEach(field => { - // this.dataForm[field.busiField] = field.files - this.$set(this.dataForm, field.busiField, field.files) - }) - console.log(this.dataForm,'this.dataForm') - } - } - }, - mounted() { + import cloneDeep from "lodash/cloneDeep"; - this.oss = this.getOss() - if (this.oss) { - this.oss.groups.forEach(group => { - this.activeNames.push(group.busiFieldGroup) - }) - // this.dataForm.files = this.oss - this.$set(this.dataForm, 'files', this.oss) - } - }, - methods: { - getOss() { - let arr = (this.$store.state.oss.configs || []).filter(config => config.busiType === this.busiType) - if (arr.length > 0) { - return JSON.parse(JSON.stringify(arr[0])) - } - return null + export default { + name: 'TableUploader', + components: {}, + props: { + value: Object, + dataForm: Object, + image: false, + busiType: String // 涓氬姟绫诲瀷 }, - change(busiField) { - console.log(busiField,'busiField busiField') - - this.fields.forEach(field => { - if (field.busiField === busiField) { - field.files.length = 0 - this.dataForm[busiField].forEach(file => { - console.log(file,"change file") - field.files.push(file) + data() { + return { + activeNames: ['1'], + oss: null + } + }, + computed: { + fields() { + let arr = [] + if (this.dataForm.files && this.dataForm.files.groups) { + this.dataForm.files.groups.forEach(group => { + group.fields.forEach(field => arr.push(field)) }) } - }) - }, - getUploaderImg(list){ - // this.imageList = list - if(list[0].url){ - this.$emit('getImageUrl',list[0].url) + return arr } + }, + mounted() { + if (this.value) + this.oss = this.value + else + this.oss = this.getOss() + if (this.oss) { + this.oss.groups.forEach(group => { + this.activeNames.push(group.busiFieldGroup) + }) + // this.dataForm.files = this.oss + this.$set(this.dataForm, 'files', this.oss) + this.fields.forEach(field => { + // this.dataForm[field.busiField] = field.files + this.$set(this.dataForm, field.busiField, field.files) + }) + } + }, + methods: { + getOss() { + let arr = (this.$store.state.oss.configs || []).filter(config => config.busiType === this.busiType) + if (arr.length > 0) { + return JSON.parse(JSON.stringify(arr[0])) + } + return null + }, + change(busiField) { + this.fields.forEach(field => { + if (field.busiField === busiField) { + field.files.length = 0 + this.dataForm[busiField].forEach(file => { + field.files.push(file) + }) + } + }) + }, + getUploaderImg(list) { + // this.imageList = list + if (list[0].url) { + this.$emit('getImageUrl', list[0].url) + } + } } } -} </script> <style> -.config-uploader1 label { - width: 30px !important; -} -.config-uploader1 a{ - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - width: 180px; -} -.config-uploader1 .zt-upload { - line-height: 0; -} -.zt .el-upload-list__item .el-progress{ - top:15px !important; -} + .config-uploader1 label { + width: 30px !important; + } + + .config-uploader1 a { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + width: 180px; + } + + .config-uploader1 .zt-upload { + line-height: 0; + } + + .zt .el-upload-list__item .el-progress { + top: 15px !important; + } </style> -- Gitblit v1.9.1