diff --git a/base-vue/src/utils/dict.js b/base-vue/src/utils/dict.js index da2fa4f..c9b4e89 100644 --- a/base-vue/src/utils/dict.js +++ b/base-vue/src/utils/dict.js @@ -37,6 +37,9 @@ function dictDetail (names) { }, filters: { dictLabel (index, array) { + if (array === null || array === undefined) { + return null + } const value = String(index) const valueToLabelMap = new Map(array.map(item => [String(item.value), item.label])) const label = valueToLabelMap.get(value) diff --git a/base-vue/src/views/modules/contract/contract-add-or-update.vue b/base-vue/src/views/modules/contract/contract-add-or-update.vue index ae2083c..e7c4095 100644 --- a/base-vue/src/views/modules/contract/contract-add-or-update.vue +++ b/base-vue/src/views/modules/contract/contract-add-or-update.vue @@ -3,159 +3,178 @@ :title="!dataForm.contractId ? '新增' : '修改'" :close-on-click-modal="false" :visible.sync="visible"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 选择物料 - - - - - - - + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
{{e.realName}}
+
+ + +
+
+
+ + + 文件 + 上传到服务器 +
可上传任意格式文件,且不超过100M
+
+
+
+
+ + + + 选择物料 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
- - - - - - - - - - - - - - - - - - - - - - - - - - 取消 确定 @@ -248,7 +267,9 @@ clientId: '', isAcceptance: 0, remarks: '', - totalSum: 0 + totalSum: 0, + filename: null, + storageId: null }, dataRule: { contractType: [ @@ -270,7 +291,10 @@ totalPage: 0, dataListLoading: false, dataListSelections: [], - materData: [] + materData: [], + activeName: 'first', + headers: { 'Token': this.$cookie.get('token') }, + fileData: [] } }, props: { @@ -306,11 +330,22 @@ this.dataForm.materialJson = data.contract.materialJson this.dataForm.isAcceptance = data.contract.isAcceptance this.dataForm.remarks = data.contract.remarks + this.materData = JSON.parse(data.contract.materialJson) } }) + this.getFile() } }) }, + getFile () { + this.$http({ + url: this.$http.adornUrl('/api/localStorage'), + method: 'get', + params: this.$http.adornParams({'contractId': this.dataForm.contractId}) + }).then(({data}) => { + this.fileData = [...data] + }) + }, addMaterial () { this.innerVisible = true this.getDataList() @@ -326,6 +361,10 @@ }, // 表单提交 dataFormSubmit () { + let ids = this.fileData.length > 0 ? this.fileData.map(item => item.storageId).join(',') : '' + if (ids) { + ids += ',' + } this.$refs['dataForm'].validate((valid) => { if (valid) { this.$http({ @@ -340,7 +379,7 @@ 'materialJson': JSON.stringify(this.materData), 'isAcceptance': this.dataForm.isAcceptance, 'remarks': this.dataForm.remarks, - 'totalSum': this.dataForm.totalSum + 'storageId': `${ids}${this.dataForm.storageId}` }) }).then(({data}) => { if (data && data.code === 0) { @@ -349,6 +388,7 @@ type: 'success', duration: 1500, onClose: () => { + this.$refs.upload.clearFiles() this.visible = false this.$emit('refreshDataList') } @@ -403,12 +443,61 @@ }, deleteHandle(index) { this.materData.splice(index, 1) + }, + // 上传文件 + beforeUpload(file) { + let isLt2M = true + isLt2M = file.size / 1024 / 1024 < 100 + if (!isLt2M) { + this.$message.error('上传文件大小不能超过 100MB!') + return + } + this.dataForm.filename = file.name + return isLt2M + }, + handleSuccess(response, file, fileList) { + this.$notify({title: '上传成功',type: 'success'}) + this.dataForm.storageId = response.storageId + }, + handleError(e, file, fileList) { + const msg = JSON.parse(e.message) + this.$notify({ + title: msg.message, + type: 'error', + duration: 2500 + }) + }, + handleRemove (file, fileList) { + this.dataForm.storageId = null + }, + submitUpload () { + this.$refs.upload.submit() + }, + deleteFile (e, i) { + this.fileData.splice(i, 1) + }, + downloadFile (e) { + const link = document.createElement('a') + link.href = e.path + link.download = e.realName + link.click() } } }