zhuhao 1 vuosi sitten
vanhempi
commit
32031e8c89
1 muutettua tiedostoa jossa 200 lisäystä ja 14 poistoa
  1. 200 14
      src/views/report/components/reportFile/reportFileTable.vue

+ 200 - 14
src/views/report/components/reportFile/reportFileTable.vue

@@ -51,12 +51,33 @@
             @current-change="handleCurrentChange" layout="total, prev, pager, next, jumper" background></el-pagination>
         </div>
       </el-main>
-      
     </el-container>
+
+    <el-dialog :title="title" :visible.sync="dialogVisible" width="500px" append-to-body destroy-on-close
+      :close-on-click-modal="false" :before-close="handleClose">
+      <el-form :model="form" :rules="rules" ref="form" label-width="80px" label-position="left">
+        <el-form-item label="文件名称" prop="name">
+          <el-input v-model="ruleForm.name" placeholder="请输入文件名称"></el-input>
+        </el-form-item>
+        <el-form-item label="文件选择" class="margin-bottom_0" required>
+          <myUpload :file-list="form.systemFileList" @on-change="onchangeFile" @on-remove="onRemove"
+            style="height: 185px;" :autoUpload="true">
+          </myUpload>
+        </el-form-item>
+        <el-form-item label="备注" prop="remark">
+          <el-input v-model="ruleForm.remark" placeholder="请输入备注" type="textarea"></el-input>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="handleClose">取 消</el-button>
+        <el-button type="primary" @click="submit">确 定</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
 <script>
+import { downLoad2 } from "@/utils"
 export default {
   data() {
     return {
@@ -108,7 +129,19 @@ export default {
       //排序字段
       sort: [{ "orderBy": "createTime", "orderType": 1 }],
       // 表格loading
-      loading: false
+      loading: false,
+      // 
+      title: '',
+      // 控制弹窗显示
+      dialogVisible: false,
+      // 表单数据
+      form: {
+        systemFileList: [],
+      },
+      // 表单校验
+      rules: {
+        name: [{ required: true, message: '请输入文件名称', trigger: 'blur' },],
+      },
     }
   },
   async mounted() {
@@ -120,44 +153,197 @@ export default {
     // this.getList()
   },
   methods: {
+    //校验文件是否全部上传
+    validFile() {
+      if (this.form.systemFileList && this.form.systemFileList.length > 0) {
+        return this.form.systemFileList.filter(item => {
+          return !item.guid
+        }).length > 0
+      } else {
+        return false
+      }
+    },
+    // 弹窗确定
+    submit() {
+      // 判断文件是否都上传完毕
+      var allUpload = this.validFile()
+      if (allUpload) {
+        this.$message.warning('文件未全部上传,请耐心等待')
+        return false
+      }
+      this.form.fileGuids = this.form.systemFileList.map(item => {
+        return item.guid
+      })
+      this.$refs.form.validate((valid) => {
+        if (valid) {
+          let params = {
+            
+          }
+          if (!this.form.id) {
+            this.$api.add(params).then(res => {
+              if (res.code == 200) {
+                this.$message.success('新增成功')
+                this.getList()
+                this.handleClose()
+              }
+            }).catch(error => {
+
+            })
+          } else {
+            this.$api.edit(params).then(res => {
+              if (res.code == 200) {
+                this.$message.success('编辑成功')
+                this.getList()
+                this.handleClose()
+              }
+            }).catch(error => {
+
+            })
+          }
+        }
+      })
+
+    },
+    // 关闭弹窗
+    handleClose() {
+      this.$refs.form.resetFields()
+      this.form = {
+        systemFileList: [],
+      }
+      this.dialogVisible = false
+    },
+    // 上传的文件监听
+    onchangeFile(file, fileList) {
+      if (file.guid && this.form.systemFileList && this.form.systemFileList.length > 0) {
+        let index = this.form.systemFileList.findIndex(item => {
+          return item.uid == file.uid
+        })
+        if (index != -1) {
+          this.form.systemFileList.splice(index, 1, file)
+        } else {
+          this.form.systemFileList.push(file.raw)
+        }
+      } else {
+        this.form.systemFileList.push(file.raw)
+      }
+    },
+    // 删除上传的文件
+    onRemove(file, fileList) {
+      let index = this.form.systemFileList.findIndex(item => {
+        return item.uid == file.uid
+      })
+      if (index != -1) {
+        this.form.systemFileList.splice(index, 1)
+      }
+    },
+    // 新增
+    handleAdd() {
+      this.dialogVisible = true
+    },
     getList() {
       let params = {
-        
+        reportId: null,//放在外面还是searchQuery里面??
+        ...this.queryParams,//分页信息
+        searchQuery: this.$commonJS.objectToString(this.searchOption),//检索条件
+        orderDTOList: this.sort,//排序信息
       }
+      this.loading = false
       this.$api.query(params).then(res => {
         if (res.code == 200) {
-          
+          this.tableData = res.data
+          this.total = res.data.total
+          this.loading = true
         }
+      }).catch(error => {
+        this.tableData = []
+        this.total = 0
       })
     },
     // 分页
     handleCurrentChange(val) {
       this.queryParams.current = val
-      
+      this.getList()
     },
     // 排序
-    sortChange() { },
-    // 新增
-    handleAdd() { },
+    sortChange({ column, prop, order }) {
+      //如需要多个字段排序,则不需要清空
+      var params = {
+        sort: this.sort,
+        column,
+        prop,
+        order,
+      }
+      this.sort = this.$commonJS.getSortData(params)
+      this.queryParams.current = 1
+      this.getList()
+    },
     // 检索
-    search(val) { },
+    search(val) {
+      let params = {}
+      val.forEach(item => {
+        if (item.type == 3) {
+          params[item.value] = item.searchValue.map(itemValue => {
+            return itemValue.value
+          })
+        } else {
+          params[item.value] = item.searchValue.label
+        }
+      })
+      // 返回字符串
+      this.searchOption = params
+      // 调用查询接口
+      this.queryParams.current = 1
+      this.getList()
+    },
     // 编辑等下拉菜单
     handleCommand(ev, row) {
       switch (ev) {
-        case 'e':
-
+        case 'e'://编辑
+          this.handleEdit(row)
           break;
-        case 'e':
-
+        case '0'://下载
+          this.downloads(row)
           break;
-        case 'e':
+        case '1'://预览
 
           break;
+        case '2'://删除
+          this.handleDelete(row)
+          break;
 
         default:
           break;
       }
     },
+    handleEdit(row) {
+      this.form = row
+      this.dialogVisible = true
+    },
+    // 删除
+    handleDelete(data) {
+      this.handleDeletes([data.id])
+    },
+    handleDeletes(ids) {
+      this.$confirm(str, '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        this.$api.delete(ids).then(response => {
+          if (response.code == 200) {
+            this.$message.success('删除成功')
+            this.queryParams.current = 1
+            this.getList()
+          }
+        })
+      }).catch(() => {
+        this.$message.info('操作已取消')
+      });
+    },
+    // 下载
+    downloads(data) {
+      downLoad2(data.guid)
+    },
   },
 }
 </script>