From c87ec8dac5f2b8f16036b794850b8f4e552a71d7 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期五, 28 二月 2025 15:40:04 +0800
Subject: [PATCH] 人员-任职授权记录搬迁

---
 src/views/CNAS/personnel/personnelInfo/index.vue                 |    6 
 src/views/CNAS/personnel/personnelInfo/components/mandateAdd.vue |  200 ++++++++++++++++++
 src/api/cnas/personal/personPostAuthorizationRecord.js           |   35 +++
 src/views/CNAS/personnel/personnelInfo/tabs/mandate.vue          |  404 +++++++++++++----------------------
 4 files changed, 391 insertions(+), 254 deletions(-)

diff --git a/src/api/cnas/personal/personPostAuthorizationRecord.js b/src/api/cnas/personal/personPostAuthorizationRecord.js
new file mode 100644
index 0000000..b3be2eb
--- /dev/null
+++ b/src/api/cnas/personal/personPostAuthorizationRecord.js
@@ -0,0 +1,35 @@
+import request from "@/utils/request";
+
+// 浠昏亴鎺堟潈璁板綍鏌ヨ琛ㄦ牸
+export function PersonPostAuthorizationRecordPage(query) {
+  return request({
+    url: "/personPostAuthorizationRecord/PersonPostAuthorizationRecordPage",
+    method: "get",
+    params: query
+  });
+}
+// 浠昏亴鎺堟潈璁板綍鍒犻櫎
+export function deletePersonPostAuthorizationRecord(query) {
+  return request({
+    url: "/personPostAuthorizationRecord/deletePersonPostAuthorizationRecord",
+    method: "delete",
+    params: query
+  });
+}
+// 浠昏亴鎺堟潈瀵煎嚭
+export function exportPersonPostAuthorizationRecord(query) {
+  return request({
+    url: "/personPostAuthorizationRecord/exportPersonPostAuthorizationRecord",
+    method: "get",
+    params: query,
+    responseType: "blob"
+  });
+}
+// 浠昏亴鎺堟潈瀵煎嚭
+export function addOrUpdatePersonPostAuthorizationRecord(query) {
+  return request({
+    url: "/personPostAuthorizationRecord/addOrUpdatePersonPostAuthorizationRecord",
+    method: "post",
+    data: query,
+  });
+}
diff --git a/src/views/CNAS/personnel/personnelInfo/components/mandateAdd.vue b/src/views/CNAS/personnel/personnelInfo/components/mandateAdd.vue
new file mode 100644
index 0000000..9e77475
--- /dev/null
+++ b/src/views/CNAS/personnel/personnelInfo/components/mandateAdd.vue
@@ -0,0 +1,200 @@
+<template>
+  <div class="add">
+    <el-dialog
+      :title="isEdit ?'缂栬緫闄勪欢璧勬枡':'鏂板闄勪欢璧勬枡'"
+      :visible.sync="dialogVisible"
+      width="50%"
+    >
+      <el-form
+        ref="ruleForm"
+        :rules="rules"
+        :model="form"
+        label-width="130px"
+        size="medium"
+      >
+        <el-form-item label="璇佷功缂栧彿" prop="certificateNumber">
+          <el-input v-model="form.certificateNumber" placeholder="璇疯緭鍏�" style="width: 100%">
+          </el-input>
+        </el-form-item >
+        <el-form-item label="琚换鑱屼汉鍛�" prop="userId">
+          <el-select v-model="form.userId" placeholder="璇烽�夋嫨">
+            <el-option
+              v-for="(item, index) in userList"
+              :key="index"
+              :label="item.name"
+              :value="item.id"
+            ></el-option>
+          </el-select>
+        </el-form-item >
+        <el-form-item label="浠昏亴宀椾綅" prop="post">
+          <el-input v-model="form.post" placeholder="璇疯緭鍏�"></el-input>
+        </el-form-item >
+        <el-form-item label="鐞嗚鑰冭瘯鎴愮哗" prop="num1">
+          <el-input v-model="form.num1" placeholder="璇疯緭鍏�"></el-input>
+        </el-form-item >
+        <el-form-item label="鎿嶄綔鎶�鑳借�冭瘯鎴愮哗" prop="num2">
+          <el-input v-model="form.num2" placeholder="璇疯緭鍏�"></el-input>
+        </el-form-item >
+        <el-form-item label="鎿嶄綔绫诲瀷" prop="operationType">
+          <el-input v-model="form.operationType" placeholder="璇烽�夋嫨"></el-input>
+        </el-form-item >
+        <el-row>
+          <el-col :span="20">
+            <el-form-item label="涓婂矖璇佷功">
+              <el-input v-model="form.systemFileName" size="small" disabled>
+                <el-button slot="append" icon="el-icon-delete-solid"
+                           @click="deleteFile(form.systemFileName)"></el-button>
+              </el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="4">
+            <el-upload ref="upload" style="float: left; margin: 0 12px 0 20px;" :action="action"
+                       :headers="uploadHeader"
+                       :show-file-list="false"
+                       :on-success="onSuccess">
+              <el-button class="uploadFile" slot="trigger" size="small" type="primary">涓婁紶</el-button>
+            </el-upload>
+          </el-col>
+        </el-row>
+        <el-form-item label="澶囨敞">
+          <el-input v-model="form.remarks" placeholder="璇烽�夋嫨"></el-input>
+        </el-form-item >
+      </el-form>
+      <div slot="footer" class="foot">
+        <el-button @click="dialogVisible = false">鍙� 娑�</el-button>
+        <el-button type="primary" :loading="loading" @click="submitForm">纭� 瀹�</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+<script>
+import {deleteCNASFile} from "@/api/cnas/personal/personalList";
+import {selectUserCondition} from "@/api/business/inspectionTask";
+import {addOrUpdatePersonPostAuthorizationRecord} from "@/api/cnas/personal/personPostAuthorizationRecord";
+
+export default {
+  data() {
+    return {
+      isEdit: false,
+      dialogVisible: false,
+      form: {
+        id: undefined,
+        certificateNumber: undefined,
+        userId: undefined,
+        post: undefined,
+        operationType: undefined,
+        fileList: [],
+        fileName: undefined,
+        systemFileName: undefined,
+        remarks: undefined,
+        num2:undefined,
+        num1:undefined
+      },
+      rules: {
+        certificateNumber: [{ required: true, message: '璇疯緭鍏ヨ瘉涔︾紪鍙�', trigger: 'blur' }],
+        userId: [{ required: true, message: '璇烽�夋嫨琚换鑱屼汉鍛�', trigger: 'change' }],
+        post: [{ required: true, message: '浠昏亴宀椾綅', trigger: 'blur' }],
+        operationType: [{ required: true, message: '鎿嶄綔绫诲瀷', trigger: 'blur' }],
+      },
+      loading: false,
+      userList: []
+    }
+  },
+  computed: {
+    action() {
+      return this.javaApi + '/personBasicInfo/saveCNASFile'
+    }
+  },
+  methods: {
+    onSuccess(response, file, fileList) {
+      this.$set(this.form, "systemFileName", response.data)
+    },
+    deleteFile(fileName) {
+      deleteCNASFile({fileName: fileName}).then(res => {
+        this.$message.success('鍒犻櫎鎴愬姛锛�')
+        this.$set(this.form, "systemFileName", null)
+      })
+    },
+    async openDialog(row, type) {
+      await this.getUserList()
+      this.dialogVisible = true
+      if(type) {
+        this.isEdit = true
+        this.form.id = row.id
+        this.form.certificateNumber = row.certificateNumber
+        this.form.userId = Number(row.userId)
+        this.form.post = row.post
+        this.form.operationType = row.operationType
+        this.form.systemFileName = row.systemFileName
+        this.form.remarks = row.remarks
+        this.form.num1 = row.num1
+        this.form.num2 = row.num2
+      } else {
+        this.resetForm('ruleForm')
+      }
+    },
+    closeDialog() {
+      this.resetForm('ruleForm')
+      this.dialogVisible = false
+    },
+    /**
+     * @desc 鑾峰彇鐢ㄦ埛淇℃伅
+     */
+    async getUserList() {
+      selectUserCondition().then((res) => {
+        this.userList = res.data;
+      })
+    },
+    /**
+     * @desc 鎻愪氦琛ㄥ崟
+     */
+    submitForm() {
+      this.$refs.ruleForm.validate((valid) => {
+        if(valid) {
+          const params = {
+            id: this.form.id,
+            certificateNumber: this.form.certificateNumber,
+            userId: this.form.userId,
+            post: this.form.post,
+            operationType: this.form.operationType,
+            systemFileName: this.form.systemFileName,
+            remarks: this.form.remarks,
+            num1: this.form.num1,
+            num2: this.form.num2
+          }
+          this.loading = true
+          addOrUpdatePersonPostAuthorizationRecord(params).then(res => {
+            this.loading = false
+            this.closeDialog()
+            this.$emit('refresh')
+          }).catch(err => {
+            this.loading = false
+          })
+        }
+      })
+    },
+    /**
+     * @desc 涓婁紶鏂囦欢
+     */
+    beforeUpload(file) {
+      if (file.size > 1024 * 1024 * 10) {
+        this.$message.error('涓婁紶鏂囦欢涓嶈秴杩�10M');
+        this.$refs.upload.clearFiles()
+        return false;
+      } else {
+        this.form.fileList = [file]
+        this.form.fileName = file.name
+        return true;
+      }
+    },
+  }
+}
+</script>
+<style scoped>
+.foot {
+    width: 100%;
+}
+.add >>> .el-dialog__footer {
+    padding-right: 20px;
+}
+</style>
diff --git a/src/views/CNAS/personnel/personnelInfo/index.vue b/src/views/CNAS/personnel/personnelInfo/index.vue
index 5cbb11a..0fa410d 100644
--- a/src/views/CNAS/personnel/personnelInfo/index.vue
+++ b/src/views/CNAS/personnel/personnelInfo/index.vue
@@ -75,9 +75,9 @@
                            :departId="departId"
                            :isDepartment="isDepartment"></training-record>
         </el-tab-pane>
-<!--        <el-tab-pane label="浠昏亴鎺堟潈璁板綍" name="浠昏亴鎺堟潈璁板綍">-->
-<!--          <Mandate v-if="activeName === '浠昏亴鎺堟潈璁板綍'" ref="manDateRef" :departId="departId" :isDepartment="isDepartment"></Mandate>-->
-<!--        </el-tab-pane>-->
+        <el-tab-pane label="浠昏亴鎺堟潈璁板綍" name="浠昏亴鎺堟潈璁板綍">
+          <Mandate v-if="activeName === '浠昏亴鎺堟潈璁板綍'" ref="manDateRef" :departId="departId" :isDepartment="isDepartment"></Mandate>
+        </el-tab-pane>
 <!--        <el-tab-pane label="浜哄憳鑳藉姏" name="浜哄憳鑳藉姏">-->
 <!--          <personnel-capacity v-if="activeName === '浜哄憳鑳藉姏'" ref="personnelCapacity"-->
 <!--                              :departId="departId"-->
diff --git a/src/views/CNAS/personnel/personnelInfo/tabs/mandate.vue b/src/views/CNAS/personnel/personnelInfo/tabs/mandate.vue
index 72b75ba..691970d 100644
--- a/src/views/CNAS/personnel/personnelInfo/tabs/mandate.vue
+++ b/src/views/CNAS/personnel/personnelInfo/tabs/mandate.vue
@@ -1,47 +1,31 @@
 <template>
-    <div class="flex_column">
-<!--        <TableCard :showForm="isDepartment" title="浠昏亴鎺堟潈璁板綍">-->
-<!--            <template v-slot:form>-->
-<!--                <div v-if="isDepartment" class="w100 items_center justify_between">-->
-<!--                    <div></div>-->
-<!--                    <div>-->
-<!--                        <el-button size="small" type="primary" @click="openDialog">鏂板</el-button>-->
-<!--                    </div>-->
-<!--                </div>-->
-<!--            </template>-->
-<!--            <template v-slot:table>-->
-<!--                <ZTTable-->
-<!--                    :column="columnData"-->
-<!--                    :height="'calc(100vh - 21em)'"-->
-<!--                    :table-data="tableData"-->
-<!--                    :table-loading="loading"-->
-<!--                    style="margin-top: 18px; padding: 0 15px;"-->
-<!--                ></ZTTable>-->
-<!--                <el-divider></el-divider>-->
-<!--                <div class="pagination">-->
-<!--                    <div></div>-->
-<!--                    <el-pagination-->
-<!--                        :page-size="pagination.pageSize"-->
-<!--                        :page-sizes="[10, 20, 30, 40]"-->
-<!--                        :total="pagination.total"-->
-<!--                        layout="total, sizes, prev, pager, next, jumper"-->
-<!--                        @current-change="currentChange"-->
-<!--                        @size-change="sizeChange"-->
-<!--                    >-->
-<!--                    </el-pagination>-->
-<!--                </div>-->
-<!--            </template>-->
-<!--        </TableCard>-->
-        <Add ref="mandateModal" @refresh="getTableData"></Add>
+  <div class="flex_column">
+    <div>
+      <div v-if="isDepartment" style="display: flex;justify-content: space-between;margin-bottom: 10px">
+        <el-button size="small" type="primary" @click="getTableData">鍒锋柊</el-button>
+        <el-button size="small" type="primary" icon="el-icon-plus" @click="openDialog">鏂板</el-button>
+      </div>
+      <lims-table :tableData="tableData" :column="columnData"
+                  @pagination="page" :height="'calc(100vh - 18em)'"
+                  :page="pagination" :tableLoading="loading"></lims-table>
     </div>
+    <Add ref="mandateModal" @refresh="getTableData"></Add>
+  </div>
 </template>
 <script>
-// import Add from "./Add.vue"
+import Add from "../components/mandateAdd.vue"
+import limsTable from "@/components/Table/lims-table.vue";
+import {
+  deletePersonPostAuthorizationRecord, exportPersonPostAuthorizationRecord,
+  PersonPostAuthorizationRecordPage
+} from "@/api/cnas/personal/personPostAuthorizationRecord";
+import {delCustomById} from "@/api/system/customer";
 
 export default {
-    components: {
-        // Add
-    },
+  components: {
+    limsTable,
+    Add
+  },
   props: {
     departId: {
       type: Number,
@@ -54,223 +38,141 @@
       default: false
     }
   },
-    data() {
-        return {
-            // departId: 0,
-            columnData: [
-                {
-                    label: '搴忓彿',
-                    prop: 'id'
-                }, {
-                    label: '璇佷功缂栧彿',
-                    prop: 'certificateNumber'
-                }, {
-                    label: '琚换鑱屼汉鍛�',
-                    prop: 'userName'
-                }, {
-                    label: '浠昏亴宀椾綅',
-                    prop: 'post'
-                }, {
-                    label: '鐞嗚鑰冭瘯鎴愮哗',
-                    prop: 'num1'
-                },{
-                    label: '鎿嶄綔鎶�鑳借�冭瘯鎴愮哗',
-                    prop: 'num2'
-                },{
-                    label: '鎿嶄綔鏃堕棿',
-                    prop: 'updateTime'
-                }, {
-                    label: '澶囨敞',
-                    prop: 'remarks',
-                    width: 300
-                }, {
-                    label: '鎿嶄綔',
-                    dataType: 'action',
-                    width: 160,
-                fixed: 'right',
-                    operation: [
-                        {
-                            name: '缂栬緫',
-                            type: 'text',
-                            clickFun: (row) => {
-                                this.openDialog(row, true)
-                            }
-                        }, {
-                            name: '涓嬭浇',
-                            type: 'text',
-                            clickFun: (row) => {
-                                this.handleDown(row)
-                            }
-                        }, {
-                            name: '鍒犻櫎',
-                            type: 'text',
-                            color: '#f56c6c',
-                            clickFun: (row) => {
-                                this.deleteNotify(row.id)
-                            }
-                        }
-                    ]
-                },
-            ],
-            tableData: [],
-            pagination: {
-                current: 1,
-                pageSize: 20,
-                total: 0
-            },
-            loading: false
-        }
-    },
-    mounted() {
-      this.getTableData()
-        console.log(this.departId)
-    },
-    methods: {
-        openDialog(row, type=false) {
-            this.$refs.mandateModal.openDialog(row, type)
-        },
-        /**
-         * @desc 鏌ヨ琛ㄦ牸鏁版嵁
-         */
-        async getTableData() {
-            this.loading = true
-          const params = this.isDepartment ? {
-            departLimsId: this.departId,
-            current: this.pagination.current,
-            size: this.pagination.pageSize
-          } : {
-            userId: this.departId,
-            current: this.pagination.current,
-            size: this.pagination.pageSize
-          }
-            const { code, data } = await this.$axios({
-                method: 'get',
-                url: getPersonPostAuthorizationRecordPage,
-                params: params
-            })
-            if(code == 200) {
-                this.pagination.total = data.total
-                this.tableData = data.records
-                this.loading = false
-            }
-        },
-        /**
-         * @desc 褰撳墠椤垫敼鍙�
-         */
-        currentChange(current) {
-            this.pagination.current = current
-            this.getTableData()
-        },
-        /**
-         * @desc 姣忛〉涓暟鏀瑰彉
-         */
-        sizeChange(pageSize) {
-            this.pagination.pageSize = pageSize
-            this.getTableData()
-        },
-        /**
-         * @desc 鍒犻櫎浠昏亴璁板綍
-         */
-        deleteNotify(id) {
-            this.$confirm('姝ゆ搷浣滃皢姘镐箙鍒犻櫎璇ユ枃浠�, 鏄惁缁х画?', '鎻愮ず', {
-                confirmButtonText: '纭畾',
-                cancelButtonText: '鍙栨秷',
-                type: 'warning'
-            }).then(() => {
-                this.delMandate(id)
-            })
-        },
-        /**
-         * @desc api鍒犻櫎
-         */
-        async delMandate(id) {
-            const formData = new FormData()
-            formData.append('id', id)
-            const { code, data } = await this.$axios({
-                method: 'delete',
-                url: deletePersonPostAuthorizationRecord,
-                data: formData,
-                noQs: true
-            })
-            if(code == 200) {
-                this.$message({ message: '鍒犻櫎鎴愬姛', type: 'success' })
-                this.getTableData()
-            } else {
-                this.$message({ message: '鍒犻櫎澶辫触', type: 'error' })
-            }
-        },
-        /**
-         * @desc 鑾峰彇璁惧id
-         */
-        getDepart(id) {
-            this.departId = id
-            this.getTableData()
-        },
-        handleDown(row){
-          this.$axios.post(this.$api.personPostAuthorizationRecord.exportPersonPostAuthorizationRecord,{id:row.id},{responseType: "blob"}).then(res => {
-            if(res.code == 201){
-              this.$message.error(res.message)
-              return
-            }
-            const blob = new Blob([res],{ type: 'application/octet-stream' });
-            //灏咮lob 瀵硅薄杞崲鎴愬瓧绗︿覆
-            let reader = new FileReader();
-            reader.readAsText(blob, 'utf-8');
-            reader.onload = () => {
-              try {
-                let result = JSON.parse(reader.result);
-                if (result.message) {
-                  this.$message.error(result.message);
-                } else {
-                  const url = URL.createObjectURL(blob);
-                  const link = document.createElement('a');
-                  link.href = url;
-                  link.download = '浠昏亴鎺堟潈-'+row.certificateNumber+'-'+row.post + '.docx';
-                  link.click();
-                  this.$message.success('瀵煎嚭鎴愬姛')
-                }
-              } catch (err) {
-                console.log(err);
-                const url = URL.createObjectURL(blob);
-                const link = document.createElement('a');
-                link.href = url;
-                link.download = '浠昏亴鎺堟潈-'+row.certificateNumber+'-'+row.post + '.docx';
-                link.click();
-                this.$message.success('瀵煎嚭鎴愬姛')
+  data() {
+    return {
+      columnData: [
+        {
+          label: '搴忓彿',
+          prop: 'id'
+        }, {
+          label: '璇佷功缂栧彿',
+          prop: 'certificateNumber'
+        }, {
+          label: '琚换鑱屼汉鍛�',
+          prop: 'userName'
+        }, {
+          label: '浠昏亴宀椾綅',
+          prop: 'post'
+        }, {
+          label: '鐞嗚鑰冭瘯鎴愮哗',
+          prop: 'num1',
+          width: 120
+        },{
+          label: '鎿嶄綔鎶�鑳借�冭瘯鎴愮哗',
+          prop: 'num2',
+          width: 150
+        },{
+          label: '鎿嶄綔鏃堕棿',
+          prop: 'updateTime'
+        }, {
+          label: '澶囨敞',
+          prop: 'remarks',
+          width: 300
+        }, {
+          label: '鎿嶄綔',
+          dataType: 'action',
+          width: 160,
+          fixed: 'right',
+          operation: [
+            {
+              name: '缂栬緫',
+              type: 'text',
+              clickFun: (row) => {
+                this.openDialog(row, true)
+              }
+            }, {
+              name: '涓嬭浇',
+              type: 'text',
+              clickFun: (row) => {
+                this.handleDown(row)
+              }
+            }, {
+              name: '鍒犻櫎',
+              type: 'text',
+              color: '#f56c6c',
+              clickFun: (row) => {
+                this.deleteNotify(row.id)
               }
             }
-          })
-        }
+          ]
+        },
+      ],
+      tableData: [],
+      pagination: {
+        current: 1,
+        size: 20,
+        total: 0
+      },
+      loading: false
+    }
+  },
+  mounted() {
+    this.getTableData()
+  },
+  methods: {
+    openDialog(row, type=false) {
+      this.$refs.mandateModal.openDialog(row, type)
     },
-//   watch: {
-//     departId: {
-//       handler(newId, oldId) {
-//         if (newId) {
-//           this.getTableData();
-//         }
-//       }
-//     }
-//   }
+    /**
+     * @desc 鏌ヨ琛ㄦ牸鏁版嵁
+     */
+    async getTableData() {
+      const params = this.isDepartment ? {
+        departLimsId: this.departId,
+        current: this.pagination.current,
+        size: this.pagination.pageSize
+      } : {
+        userId: this.departId,
+        current: this.pagination.current,
+        size: this.pagination.pageSize
+      }
+      this.loading = true
+      PersonPostAuthorizationRecordPage(params).then(res => {
+        this.loading = false
+        this.tableData = res.data.records
+        this.pagination.total = res.data.total
+      }).catch(err => {
+        this.loading = false
+      })
+    },
+    page (page) {
+      this.pagination.size = page.limit
+      this.getTableData()
+    },
+    /**
+     * @desc 鍒犻櫎浠昏亴璁板綍
+     */
+    deleteNotify(id) {
+      this.$confirm('鏄惁鍒犻櫎褰撳墠鏁版嵁?', "璀﹀憡", {
+        confirmButtonText: "纭畾",
+        cancelButtonText: "鍙栨秷",
+        type: "warning"
+      }).then(() => {
+        deletePersonPostAuthorizationRecord({id: id}).then(res => {
+          this.$message.success('鍒犻櫎鎴愬姛')
+          this.getTableData()
+        }).catch(e => {
+          this.$message.error('鍒犻櫎澶辫触')
+        })
+      }).catch(() => {})
+    },
+    handleDown(row){
+      exportPersonPostAuthorizationRecord({id:row.id}).then(res => {
+        const blob = new Blob([res],{ type: 'application/octet-stream' });
+        this.$download.saveAs(blob, '浠昏亴鎺堟潈-'+row.certificateNumber+'-'+row.post + '.docx')
+      })
+    }
+  },
+  watch: {
+    departId: {
+      handler(newId, oldId) {
+        if (newId) {
+          this.getTableData();
+        }
+      }
+    }
+  }
 }
 </script>
 <style scoped>
-.flex_column {
-    display: flex;
-    flex-direction: column;
-    justify-content: space-between;
-}
-.w100 {
-    width: 100%;
-}
-.pagination {
-    display: flex;
-    justify-content: space-between
-}
-.items_center {
-    display: flex;
-    align-items: center;
-}
-.justify_between {
-    justify-content: space-between
-}
 </style>

--
Gitblit v1.9.3