chris před 3 roky
rodič
revize
5c6d847658

+ 1 - 1
src/api/file.js

@@ -1,4 +1,4 @@
 import request from '@/utils/httpRequest'
 
-export const uploadUrl = request.adornUrl('/file-service/minio-file/file-upload')
+export const uploadUrl = request.adornUrl('/file-service/minio-file/files-upload')
 export const downloadUrl = request.adornUrl('/file-service/minio-file/download/')

+ 35 - 18
src/views/modules/cus/communicate-add-or-update.vue

@@ -199,11 +199,11 @@
       }
     },
     methods: {
-      async init (id, disabled) {
+      async init (id, display) {
         this.dataForm = {}
         this.visible = true
         this.id = id || 0
-        this.display = disabled
+        this.display = display
         await getType().then(({data}) => {
           if (data && data.code === '200') {
             this.options = data.data
@@ -215,7 +215,7 @@
           }
         })
         if (!id) return
-        await getCoDetail().then(({data}) => {
+        await getCoDetail(this.id).then(({data}) => {
           if (data && data.code === '200') {
             this.dataForm = data.data
           }
@@ -225,34 +225,51 @@
         this.$refs.upload.submit()
       },
       handleRemove (file, fileList) {
-        console.log(file, fileList)
+        let _tmp = this.fileList
+        // eslint-disable-next-line one-var
+        let i = 0, len = _tmp.length
+        for (; i < len; i++) {
+          // eslint-disable-next-line no-cond-assign
+          if (_tmp[i].name === file.name) {
+            _tmp.splice(i, 1)
+            break
+          }
+        }
+        this.fileList = _tmp
       },
       handlePreview (file) {
-        let res = file.response
-        if (res && res.code === '200') {
+        if (file && file.url) {
           // 获取文件路径
-          this.previewPath = downloadUrl + file.response.data.fileUrl
-          this.previewName = file.response.data.originFileName
+          this.previewPath = downloadUrl + file.url
+          this.previewName = file.name
           this.previewVisible = true
         }
       },
       handleSuccess (response, file, fileList) {
-        console.log(file)
-      },
-      uploadFiles (params) {
-        let files = this.fileList
-        console.log(params)
-        console.log(files)
-      },
-      onChangeFiles (file, fileList) {
-        this.fileList.push(file)
+        if (response && response.code === '200') {
+          let lst = response.data
+          for (let i = 0; i < lst.length; i++) {
+            this.fileList.push({
+              name: lst[i].originFileName,
+              url: lst[i].fileUrl
+            })
+          }
+        }
       },
       // 表单提交
       dataFormSubmit () {
         this.$refs['dataForm'].validate((valid) => {
           if (valid) {
             console.log('fileList = ' + this.fileList)
-            // this.dataForm.attachList = this.fileList
+            if (this.fileList.length > 0) {
+              let fList = this.fileList
+              for (let i = 0; i < fList.length; i++) {
+                this.dataForm.attachList.push({
+                  fileName: fList[i].originFileName,
+                  url: fList[i].fileUrl
+                })
+              }
+            }
             this.dataForm.cusRCommProductVOS = this.cusRCommProductVOS
             this.$http({
               url: this.$http.adornUrl(`/biz-service/cusCommunication/save`),

+ 33 - 2
src/views/modules/cus/communicate.vue

@@ -77,6 +77,7 @@
         <template slot-scope="scope">
           <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.coId, true)">查看</el-button>
           <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.coId, false)">编辑</el-button>
+          <el-button style="color: red" type="text" size="small" @click="deleteHandle(scope.row.coId)">删除</el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -159,11 +160,41 @@
         this.dataListSelections = val
       },
       // 新增 / 修改
-      addOrUpdateHandle (id, disable) {
+      addOrUpdateHandle (id, display) {
         this.addOrUpdateVisible = true
         this.$nextTick(() => {
-          this.$refs.addOrUpdate.init(id, disable)
+          this.$refs.addOrUpdate.init(id, display)
         })
+      },
+      // 删除
+      deleteHandle (id) {
+        if (!id) return
+        let ids = []
+        ids.push(id)
+        this.$confirm(`确定删除?`, '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          this.$http({
+            url: this.$http.adornUrl(`/biz-service/cusCommunication/delete`),
+            method: 'DELETE',
+            data: ids
+          }).then(({data}) => {
+            if (data && data.code === '200') {
+              this.$message({
+                message: '操作成功',
+                type: 'success',
+                duration: 1500,
+                onClose: () => {
+                  this.getDataList()
+                }
+              })
+            } else {
+              this.$message.error(data.msg)
+            }
+          })
+        }).catch(() => {})
       }
     }
   }