| <template> | 
|   <el-collapse class="config-uploader" v-model="activeNames" v-if="oss"> | 
|     <el-collapse-item :name="group.busiFieldGroup" v-for="group in (oss.groups || [])" :key="group.busiFieldGroup"> | 
|       <template slot="title"> | 
|         <el-tag>文件附件</el-tag> | 
|       </template> | 
|       <el-table :data="group.fields" :show-header="false"> | 
|         <el-table-column width="250" style="text-align: left;white-space:nowrap;"> | 
|           <template slot-scope="scope"> | 
|             <span>文件名</span> | 
|           </template> | 
|         </el-table-column> | 
|         <el-table-column align="left"> | 
|           <template slot-scope="scope"> | 
|             <zt-uploader v-model="dataForm[scope.row.busiField]" multiple :limit="scope.row.fileLimit" :file-type="scope.row.fileType" | 
|                          :accept="scope.row.accept" :file-size="scope.row.fileSize" @input="change(scope.row.busiField)"/> | 
|           </template> | 
|         </el-table-column> | 
|       </el-table> | 
|     </el-collapse-item> | 
|   </el-collapse> | 
| </template> | 
| <script> | 
|   | 
|   export default { | 
|     name: 'SysFileManagement', | 
|     components: {}, | 
|     props: { | 
|       value: Object, | 
|       dataForm: Object, | 
|       busiType: String // 业务类型 | 
|     }, | 
|     data() { | 
|       return { | 
|         activeNames: [], | 
|         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 || {}) | 
|           } | 
|           // 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) | 
|           }) | 
|         } | 
|       } | 
|     }, | 
|     mounted() { | 
|       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 | 
|       }, | 
|       change(busiField) { | 
|         this.fields.forEach(field => { | 
|           if (field.busiField === busiField) { | 
|             field.files.length = 0 | 
|             this.dataForm[busiField].forEach(file => field.files.push(file)) | 
|           } | 
|         }) | 
|       } | 
|     } | 
|   } | 
| </script> | 
| <style> | 
|   .config-uploader label { | 
|     width: 260px !important; | 
|   } | 
| </style> |