From e888346ebcd8e3e099a15c7edd7bf367c057193a Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期二, 04 三月 2025 15:33:33 +0800
Subject: [PATCH] Merge branch 'refs/heads/dev'

---
 src/views/CNAS/systemManagement/documentControl/components/FileList.vue |  438 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 438 insertions(+), 0 deletions(-)

diff --git a/src/views/CNAS/systemManagement/documentControl/components/FileList.vue b/src/views/CNAS/systemManagement/documentControl/components/FileList.vue
new file mode 100644
index 0000000..88bc13d
--- /dev/null
+++ b/src/views/CNAS/systemManagement/documentControl/components/FileList.vue
@@ -0,0 +1,438 @@
+<template>
+  <!-- 鏂囦欢娓呭崟 -->
+  <div class="file-list" style="height: 100%;">
+    <div class="search">
+      <div class="search_thing">
+        <div class="search_label">鏂囦欢鍚嶇О锛�</div>
+        <div class="search_input"><el-input size="small" placeholder="璇疯緭鍏�" clearable v-model="queryParams.name"
+            @keyup.enter.native="refreshTable()"></el-input></div>
+      </div>
+      <div class="search_thing">
+        <div class="search_label">鏂囦欢鐘舵�侊細</div>
+        <div class="search_input">
+          <el-select v-model="queryParams.state" size="small" @change="refreshTable()">
+            <el-option :label="item.label" :value="item.value" v-for="(item, index) in fileState"
+              :key="index"></el-option>
+          </el-select>
+        </div>
+      </div>
+      <div class="search_thing" style="padding-left: 30px;">
+        <el-button size="small" @click="refresh()">閲� 缃�</el-button>
+        <el-button size="small" type="primary" @click="refreshTable()">鏌� 璇�</el-button>
+      </div>
+      <div class="btns" style="padding-left: 30px;">
+        <el-upload :action="action" :multiple="false" accept='.xls,.xlsx' :headers="uploadHeader"
+          :on-change="beforeUpload" :on-error="onError" ref='upload' :on-success="handleSuccessUp"
+          :show-file-list="false">
+          <el-button size="small" type="primary" :loading="upLoading">瀵煎叆</el-button></el-upload>
+      </div>
+    </div>
+    <div class="table">
+      <lims-table :tableData="tableData" :column="column" :page="page" :tableLoading="tableLoading"
+        :height="'calc(100vh - 290px)'" @pagination="pagination"></lims-table>
+    </div>
+    <el-dialog title="涓婁紶" :visible.sync="addDialogVisible" width="1000px" top="3vh">
+      <UpPdfStamp ref="UpPdfStamp" v-if="addDialogVisible" @uploadPDF="uploadPDF" :isUpFile="true"
+        @uploadPDFErr="uploadPDFErr"></UpPdfStamp>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="addDialogVisible = false">鍙� 娑�</el-button>
+        <el-button type="primary" @click="handleAdd" v-loading="addLoading">纭� 瀹�</el-button>
+      </span>
+    </el-dialog>
+    <el-dialog title="鏌ョ湅闄勪欢" :visible.sync="lookDialogVisible" width="800px" top="5vh" fullscreen>
+      <filePreview v-if="lookDialogVisible" :fileUrl="javaApi + '/word/' + currentInfo.url" :currentFile="{}"
+        style="max-height: 90vh;overflow-y: auto;" />
+    </el-dialog>
+    <!-- 鏂板/缂栬緫 -->
+    <el-dialog :title="title" :visible.sync="addDia" width="500px">
+      <el-form :model="currentInfo" ref="currentInfoForm" :rules="rules" label-position="right" label-width="120px">
+        <el-form-item label="鏂囦欢缂栧彿" prop="documentCode">
+          <el-input size="small" placeholder="璇疯緭鍏�" clearable v-model="currentInfo.documentCode"></el-input>
+        </el-form-item>
+        <el-form-item label="绫诲埆" prop="type">
+          <el-select v-model="currentInfo.type" size="small" clearable placeholder="璇烽�夋嫨" style="width: 100%">
+            <el-option v-for="item in fileType" :key="item.value" :label="item.label" :value="item.value">
+            </el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="鍚嶇О" prop="name">
+          <el-input size="small" placeholder="璇疯緭鍏�" clearable v-model="currentInfo.name">
+          </el-input>
+        </el-form-item>
+        <el-form-item label="鏂囦欢鐗堟湰" prop="version">
+          <el-input size="small" placeholder="璇疯緭鍏�" clearable v-model="currentInfo.version">
+          </el-input>
+        </el-form-item>
+        <el-form-item label="浣滆��" prop="writer">
+          <el-input size="small" placeholder="璇疯緭鍏�" clearable v-model="currentInfo.writer">
+          </el-input>
+        </el-form-item>
+        <el-form-item label="鐢熸晥鏃ユ湡" prop="effectiveDate">
+          <el-date-picker v-model="currentInfo.effectiveDate" format="yyyy-MM-dd" value-format="yyyy-MM-dd" type="date"
+            size="small" placeholder="閫夋嫨鏃ユ湡">
+          </el-date-picker>
+        </el-form-item>
+        <el-form-item label="鏂囦欢鐘舵��" prop="state">
+          <el-select v-model="currentInfo.state" size="small" clearable placeholder="璇烽�夋嫨" style="width: 100%">
+            <el-option v-for="item in fileState" :key="item.value" :label="item.label" :value="item.value">
+            </el-option>
+          </el-select>
+        </el-form-item>
+      </el-form>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="addDia = false">鍙� 娑�</el-button>
+        <el-button :loading="uploading" type="primary" @click="submitProduct('currentInfoForm')">纭� 璁�</el-button>
+      </span>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import UpPdfStamp from '@/components/UpPdfStamp/index.vue'
+import filePreview from '@/components/Preview/filePreview.vue'
+import limsTable from "@/components/Table/lims-table.vue";
+import {
+  uploadFileManageDocumentList,
+  pageManageDocumentList,
+  delManageDocumentList,
+  doManageDocumentList,
+} from '@/api/cnas/systemManagement/documentControl.js'
+export default {
+  components: {
+    UpPdfStamp,
+    filePreview,
+    limsTable,
+  },
+  data() {
+    return {
+      addDialogVisible: false,
+      lookDialogVisible: false,
+      addPower: false,
+      upLoading: false,
+      addLoading: false,
+      currentInfo: {},
+      fileType: [],
+      fileState: [],
+      title: '鏂板',
+      queryParams: {},
+      tableData: [],
+      column: [
+        { label: "鏂囦欢缂栧彿", prop: "documentCode" },
+        {
+          label: "绫诲埆", prop: "type", width: "120px", dataType: "tag",
+          formatData: (params) => {
+            return this.fileType.find((m) => m.value == params).label;
+          },
+          formatType: (params) => {
+            return this.fileType.find((m) => m.value == params).type;
+          },
+        },
+        {
+          label: "鍚嶇О",
+          prop: "name",
+        },
+        { label: "鏂囦欢鐗堟湰", prop: "version" },
+        { label: "浣滆��", prop: "writer" },
+        { label: "鐢熸晥鏃ユ湡", prop: "effectiveDate" },
+        {
+          label: "鏂囦欢鐘舵��", prop: "state", dataType: "tag",
+          formatData: (params) => {
+            return this.fileState.find((m) => m.value == params).label;
+          },
+          formatType: (params) => {
+            return this.fileState.find((m) => m.value == params).type;
+          },
+        },
+        {
+          dataType: "action",
+          fixed: "right",
+          label: "鎿嶄綔",
+          operation: [
+            {
+              name: "缂栬緫",
+              type: "text",
+              clickFun: (row) => {
+                this.openAdd("缂栬緫", row);
+              },
+            },
+            {
+              name: "涓婁紶",
+              type: "text",
+              clickFun: (row) => {
+                this.handleUp(row);
+              },
+            },
+            {
+              name: "涓嬭浇",
+              type: "text",
+              clickFun: (row) => {
+                this.handleDown(row);
+              },
+            },
+            {
+              name: "鏌ョ湅闄勪欢",
+              type: "text",
+              clickFun: (row) => {
+                this.handleLook(row);
+              },
+            },
+            {
+              name: "鍒犻櫎",
+              type: "text",
+              clickFun: (row) => {
+                this.handleDelete(row);
+              },
+            },
+          ],
+        },
+      ],
+      page: {
+        total: 0,
+        size: 10,
+        current: 0,
+      },
+      tableLoading: false,
+      addDia: false,
+      rules: {
+        documentCode: [{ required: true, message: "璇疯緭鍏ユ枃浠剁紪鍙�", trigger: "blur" }],
+      },
+      uploading: false,
+    }
+  },
+  // 鐢ㄤ簬涓婁紶鏂囦欢鐨勪俊鎭�
+  computed: {
+    action() {
+      return this.javaApi + '/manageDocumentList/exportManageDocumentList'
+    }
+  },
+  mounted() {
+    this.getList()
+    this.selectEnumByCategory()
+  },
+  methods: {
+    getList() {
+      this.tableLoading = true;
+      let param = { ...this.queryParams, ...this.page };
+      delete param.total;
+      pageManageDocumentList({ ...param })
+        .then((res) => {
+          this.tableLoading = false;
+          if (res.code === 200) {
+            this.tableData = res.data.records;
+            this.page.total = res.data.total;
+          }
+        })
+        .catch((err) => {
+          this.tableLoading = false;
+        });
+    },
+    pagination({ page, limit }) {
+      this.page.current = page;
+      this.page.size = limit;
+      this.getList();
+    },
+    refreshTable() {
+      this.page.current = 1;
+      this.getList();
+    },
+    refresh() {
+      this.queryParams = {};
+      this.page.current = 1;
+      this.getList();
+    },
+    openAdd(title, row) {
+      this.title = title;
+      if (row) {
+        this.currentInfo = row;
+      } else {
+        this.currentInfo = {};
+      }
+      this.addDia = true;
+    },
+    // 涓嬭浇鏂囦欢
+    handleDown(row) {
+      if (!row.url) return this.$message.warning('鏂囦欢鏈笂浼�')
+      let url = this.javaApi + '/word/' + row.url
+      this.$download.saveAs(url, row.url);
+    },
+    // 鏌ョ湅鏂囦欢
+    handleLook(row) {
+      if (!row.url) return this.$message.warning('鏂囦欢鏈笂浼�')
+      this.currentInfo = row
+      this.lookDialogVisible = true
+    },
+    getPower() {
+      let power = JSON.parse(sessionStorage.getItem('power'))
+      let up = false
+      let upFile = false
+      let add = false
+      for (var i = 0; i < power.length; i++) {
+        if (power[i].menuMethod == 'doManageDocumentList') {
+          up = true
+        }
+        if (power[i].menuMethod == 'exportManageDocumentList') {
+          add = true
+        }
+        if (power[i].menuMethod == 'uploadFileManageDocumentList') {
+          upFile = true
+        }
+      }
+      if (!upFile) {
+        this.componentData.do.splice(1, 1)
+      }
+      if (!up) {
+        this.componentData.do.splice(0, 1)
+      }
+      this.addPower = add
+    },
+    // 涓婁紶鏂囦欢
+    handleUp(row) {
+      this.currentInfo = row
+      this.addDialogVisible = true;
+    },
+    // 鎻愪氦涓婁紶
+    handleAdd() {
+      this.addLoading = true
+      this.$refs['UpPdfStamp'].generatePDF()
+    },
+    uploadPDFErr() {
+      this.addLoading = false
+    },
+    beforeUpload(file) {
+      if (file.size > 1024 * 1024 * 10) {
+        this.$message.error('涓婁紶鏂囦欢涓嶈秴杩�10M');
+        this.$refs.upload.clearFiles()
+        return false;
+      } else {
+        // this.upLoading = true;
+        return true;
+      }
+    },
+    onError(err, file, fileList) {
+      this.$message.error('涓婁紶澶辫触')
+      this.$refs.upload.clearFiles()
+    },
+    handleSuccessUp(response) {
+      this.upLoading = false;
+      if (response.code == 200) {
+        this.$message.success('涓婁紶鎴愬姛');
+        this.refreshTable()
+      }else {
+        this.$message.error(response.msg);
+      }
+    },
+    selectEnumByCategory() {
+      // 鏂囦欢绫诲埆
+      this.getDicts("document_type").then((response) => {
+        this.fileType = this.dictToValue(response.data);
+      });
+      // 鏂囦欢鐘舵��
+      this.getDicts("document_state").then((response) => {
+        this.fileState = this.dictToValue(response.data);
+      });
+    },
+    async uploadPDF(pdfBlob, fileName) {
+      const formData = new FormData();
+      formData.append('file', pdfBlob, fileName); // 鏂囦欢瀛楁
+      formData.append('id', this.currentInfo.id); // 鏂囦欢鍚嶅瓧娈�
+
+      try {
+        let res = await uploadFileManageDocumentList(formData)
+        this.addLoading = false
+        if (res.code == 200) {
+          this.$message({ message: '涓婁紶鎴愬姛', type: 'success' });
+          this.addDialogVisible = false;
+          this.refreshTable()
+          return true
+        } else {
+          this.$message({ message: '涓婁紶澶辫触', type: 'error' });
+          return false
+        }
+      } catch (e) {
+        this.addLoading = false
+      }
+
+    },
+    handleDelete(row) {
+      this.$confirm("鏄惁鍒犻櫎璇ユ潯鏁版嵁?", "鎻愮ず", {
+        confirmButtonText: "纭畾",
+        cancelButtonText: "鍙栨秷",
+        type: "warning",
+      })
+        .then(() => {
+          delManageDocumentList({ id: row.id }).then((res) => {
+            if (res.code == 201) return;
+            this.$message.success("鍒犻櫎鎴愬姛");
+            this.refresh();
+          });
+        })
+        .catch(() => { });
+    },
+    submitProduct(formName) {
+      this.$refs[formName].validate((valid) => {
+        if (valid) {
+          this.uploading = true;
+          doManageDocumentList(this.currentInfo)
+            .then((res) => {
+              this.uploading = false;
+              if (res.code != 200) {
+                return;
+              }
+              this.$message.success("鎻愪氦鎴愬姛");
+              this.refresh();
+              this.addDia = false;
+            })
+            .catch((err) => {
+              this.uploading = false;
+            });
+        } else {
+          return false;
+        }
+      });
+    },
+  }
+}
+</script>
+
+<style scoped>
+.title {
+  height: 60px;
+  line-height: 60px;
+}
+
+.search {
+  background-color: #fff;
+  height: 40px;
+  display: flex;
+  align-items: center;
+  position: relative;
+}
+
+.search_thing {
+  width: 350px;
+  display: flex;
+  align-items: center;
+}
+
+.search_label {
+  width: 110px;
+  font-size: 14px;
+  text-align: right;
+}
+
+.search_input {
+  width: calc(100% - 110px);
+}
+
+.table {
+  background-color: #fff;
+  height: calc(100% - 60px - 80px);
+  padding: 20px;
+}
+
+.btns {
+  position: absolute;
+  right: 20px;
+  top: 5px;
+}
+</style>

--
Gitblit v1.9.3