From e5454b769d44a34af423bf87ac8a740bf8c20341 Mon Sep 17 00:00:00 2001
From: Crunchy <3114200645@qq.com>
Date: 星期二, 29 四月 2025 13:25:29 +0800
Subject: [PATCH] Merge branch 'dev' into dev_tides

---
 src/views/CNAS/personnel/personnelInfo/tabs/job-responsibilities.vue |  161 +++++++++++++++++++++++++----------------------------
 1 files changed, 77 insertions(+), 84 deletions(-)

diff --git a/src/views/CNAS/personnel/personnelInfo/tabs/job-responsibilities.vue b/src/views/CNAS/personnel/personnelInfo/tabs/job-responsibilities.vue
index 2f7d422..c048536 100644
--- a/src/views/CNAS/personnel/personnelInfo/tabs/job-responsibilities.vue
+++ b/src/views/CNAS/personnel/personnelInfo/tabs/job-responsibilities.vue
@@ -1,17 +1,25 @@
 <!-- 宀椾綅鑱岃矗 -->
 <template>
   <div class="view">
-    <div style="text-align: left; margin-bottom: 15px;padding: 0 10px">
-      <label>鍛樺伐锛�</label>
-      <el-input v-model="userName" clearable placeholder="璇疯緭鍏ュ憳宸�" size="small" style="width: 20vh;"></el-input>
-      <el-button size="small" type="primary" @click="refreshTable">鏌ヨ</el-button>
-      <div v-if="isDepartment" style="float: right;">
+    <div style="display: flex;justify-content: space-between">
+      <div style="display: flex;">
+        <div style="margin-bottom: 18px;margin-right: 10px;display: flex;align-items: center;line-height: 32px;">
+          <span style="width: 50px;font-size: 14px;font-weight: 700;color: #606266;">鍛樺伐</span>
+          <el-input size="small" placeholder="璇疯緭鍏�" clearable v-model="userName"
+                    @keyup.enter.native="refreshTable"></el-input>
+        </div>
+        <div style="line-height: 30px;">
+          <el-button size="small" type="primary" @click="refreshTable">鏌ヨ</el-button>
+        </div>
+      </div>
+      <div style="line-height: 30px;">
         <el-button size="small" type="primary" @click="addPost">鏂板</el-button>
         <!--        <el-button size="small" type="primary">瀵煎嚭excel</el-button>-->
       </div>
     </div>
-    <div class="table" style="padding: 0 10px">
-      <el-table :data="tableData" height="70vh" style="width: 100%">
+    <div class="table">
+      <el-table :data="tableData" v-loading="tableLoading" height="66.5vh" style="width: 100%"
+                :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }" border>
         <el-table-column label="搴忓彿" type="index" width="60"></el-table-column>
         <el-table-column label="鍛樺伐缂栧彿" min-width="120" prop="account"></el-table-column>
         <el-table-column label="宀椾綅鍚嶇О" min-width="180" prop="postName"></el-table-column>
@@ -22,32 +30,31 @@
         <el-table-column label="浠昏亴浜哄鏍告棩鏈�" min-width="180" prop="incumbentDate"></el-table-column>
         <el-table-column label="涓荤" min-width="180" prop="supervisorName"></el-table-column>
         <el-table-column label="涓荤瀹℃牳鏃ユ湡" min-width="180" prop="supervisorDate"></el-table-column>
-        <el-table-column fixed="right" label="鎿嶄綔" width="140">
+        <el-table-column fixed="right" label="鎿嶄綔" width="140" align="center">
           <template v-slot="scope">
             <el-button v-if="!isDepartment || scope.row.currentState === '鍏抽棴'" size="small" type="text"
-                       @click="handleViewClick(scope.row, 'view')">鏌ョ湅
+              @click="handleViewClick(scope.row, 'view')">鏌ョ湅
             </el-button>
             <el-button v-if="isDepartment && scope.row.currentState !== '鍏抽棴'" size="small" type="text"
-                       @click="handleViewClick(scope.row, 'edit')">缂栬緫
+              @click="handleViewClick(scope.row, 'edit')">缂栬緫
             </el-button>
             <el-button size="small" type="text" @click="downLoadPost(scope.row)">瀵煎嚭</el-button>
-            <el-button v-if="isDepartment" size="small" type="text" @click="deletePost(scope.row)">鍒犻櫎</el-button>
+            <el-button v-if="isDepartment" size="small" style="color: #f56c6c" type="text"
+              @click="deletePost(scope.row)">鍒犻櫎</el-button>
           </template>
         </el-table-column>
       </el-table>
       <el-pagination :current-page="1" :page-size="search.size" :page-sizes="[10, 20, 30, 50, 100]"
-                     :total="search.total" layout="->,total, sizes, prev, pager, next, jumper"
-                     @size-change="handleSizeChange"
-                     @current-change="handleCurrentChange">
+        :total="search.total" layout="->,total, sizes, prev, pager, next, jumper" background style="margin-top: 10px"
+        @size-change="handleSizeChange" @current-change="handleCurrentChange">
       </el-pagination>
     </div>
     <!-- 鏂板宀椾綅鑱岃矗 -->
-    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :visible.sync="dialogVisible"
-               title="鏂板宀椾綅鑱岃矗"
-               width="50%" @close="resetForm">
+    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :visible.sync="dialogVisible" title="鏂板宀椾綅鑱岃矗"
+      width="50%" @close="resetForm">
       <el-steps :active="currentStep" align-center finish-status="success">
         <el-step v-for="(v, i) in steps" :key="i" :title="v" style="cursor:pointer"
-                 @click.native="choiceStep(i)"></el-step>
+          @click.native="choiceStep(i)"></el-step>
       </el-steps>
       <el-form ref="form" :model="form" :rules="rules" label-width="130px">
         <div>
@@ -57,44 +64,36 @@
               <el-col :span="12">
                 <el-form-item label="宀椾綅鍚嶇О锛�" prop="postName">
                   <el-input v-model="form.postName" :disabled="currentStep !== 0 || operationType === 'view'"
-                            size="small"></el-input>
+                    size="small"></el-input>
                 </el-form-item>
               </el-col>
               <el-col :span="24">
                 <el-form-item label="宸ヤ綔鐩爣锛�" prop="jobObjective">
                   <el-input v-model="form.jobObjective" :disabled="currentStep !== 0 || operationType === 'view'"
-                            size="small"
-                            type="textarea"></el-input>
+                    size="small" type="textarea"></el-input>
                 </el-form-item>
               </el-col>
               <el-col :span="24">
                 <el-form-item label="宀椾綅鑱岃矗锛�" prop="jobResponsibilities">
                   <el-input v-model="form.jobResponsibilities" :disabled="currentStep !== 0 || operationType === 'view'"
-                            size="small"
-                            type="textarea"></el-input>
+                    size="small" type="textarea"></el-input>
                 </el-form-item>
               </el-col>
               <el-col v-if="currentStep === 0 || operationType === 'view'" :span="12">
-                <el-form-item
-                  :rules="[{ required: currentStep === 0, message: '璇烽�夋嫨浠昏亴浜�', trigger: 'change' }]"
-                  label="浠昏亴浜猴細"
-                  prop="incumbentId">
-                  <el-select v-model="form.incumbentId" :disabled="operationType === 'view'" clearable
-                             filterable
-                             placeholder="璇烽�夋嫨浠昏亴浜�" size="small" style="width: 100%;">
+                <el-form-item :rules="[{ required: currentStep === 0, message: '璇烽�夋嫨浠昏亴浜�', trigger: 'change' }]"
+                  label="浠昏亴浜猴細" prop="incumbentId">
+                  <el-select v-model="form.incumbentId" :disabled="operationType === 'view'" clearable filterable
+                    placeholder="璇烽�夋嫨浠昏亴浜�" size="small" style="width: 100%;">
                     <el-option v-for="item in responsibleOptions" :key="item.id" :label="item.name" :value="item.id">
                     </el-option>
                   </el-select>
                 </el-form-item>
               </el-col>
               <el-col v-if="currentStep === 1 || operationType === 'view'" :span="12">
-                <el-form-item
-                  :rules="[{ required: currentStep === 1, message: '璇烽�夋嫨涓荤', trigger: 'blur' }]"
-                  label="涓荤锛�"
+                <el-form-item :rules="[{ required: currentStep === 1, message: '璇烽�夋嫨涓荤', trigger: 'blur' }]" label="涓荤锛�"
                   prop="supervisorId">
                   <el-select v-model="form.supervisorId" :disabled="currentStep !== 1 || operationType === 'view'"
-                             clearable filterable
-                             placeholder="璇烽�夋嫨涓荤" size="small" style="width: 100%;">
+                    clearable filterable placeholder="璇烽�夋嫨涓荤" size="small" style="width: 100%;">
                     <el-option v-for="item in responsibleOptions" :key="item.id" :label="item.name" :value="item.id">
                     </el-option>
                   </el-select>
@@ -115,21 +114,30 @@
       <span slot="footer" class="dialog-footer">
         <el-button v-if="currentStep !== 0 && currentStep !== 3" @click="submitForm('3reject')">椹冲洖</el-button>
         <el-button v-if="currentStep === 0" @click="submitForm('2save')">淇濆瓨</el-button>
-        <el-button v-if="currentStep !== 3" type="primary"
-                   @click="submitForm('1submit')">{{ currentStep === 0 ? '鎻愪氦' : '閫氳繃' }}</el-button>
+        <el-button v-if="currentStep !== 3" type="primary" @click="submitForm('1submit')">{{ currentStep === 0 ? '鎻愪氦' :
+          '閫氳繃'
+          }}</el-button>
       </span>
     </el-dialog>
   </div>
 </template>
 
 <script>
-// import { dateFormat } from '../../../util/date';
+import { dateFormat } from '@/utils/date'
+import {
+  exportPersonJobResponsibilities, personJobResponsibilitiesDelete,
+  personJobResponsibilitiesSave,
+  personJobResponsibilitiesSelect
+} from "@/api/cnas/personal/personJobResponsibilities";
+import { selectUserCondition } from "@/api/cnas/resourceDemand/facilitiesEnvironment/facilitiesAndEnvironment";
+import { mapGetters } from "vuex";
 
 export default {
   data() {
     return {
       userName: '',
       tableData: [],
+      tableLoading: false,
       responsibleOptions: [],
       search: {
         size: 20,
@@ -192,19 +200,32 @@
     // 鏌ヨ鍒楄〃淇℃伅
     getPostList(userId) {
       this.search.userId = userId;
-      const name = this.isDepartment ? 'departmentId' : 'userId';
-      this.$axios.get(this.$api.personnel.personJobResponsibilitiesSelect + '?userName=' + this.userName + `&${name}=` + this.search.userId + '&size=' + this.search.size + '&current=' + this.search.current).then(res => {
-        if (res.code === 201) return;
+      const params = this.isDepartment ? {
+        userName: this.userName,
+        departmentId: this.search.userId,
+        size: this.search.size,
+        current: this.search.current,
+      } : {
+        userName: this.userName,
+        userId: this.search.userId,
+        size: this.search.size,
+        current: this.search.current,
+      }
+      this.tableLoading = true
+      personJobResponsibilitiesSelect(params).then(res => {
+        this.tableLoading = false
         this.tableData = res.data.records;
         this.search.total = res.data.total;
-      });
+      }).catch(err => {
+        this.tableLoading = false
+      })
     },
     //鎻愪氦琛ㄥ崟
     async submitForm(saveState) {
       this.$refs.form.validate((valid) => {
         if (valid === true || saveState !== '1submit') {
           // 缁欏綋鍓嶇幆鑺傝缃垱寤轰汉涓庢椂闂�
-          let user = JSON.parse(localStorage.getItem('user'));
+          let user = this.nickName;
           const dateTime = dateFormat(new Date());
           // 鑾峰彇褰撳墠鐜妭鎿嶄綔浜轰笌鏃ユ湡
           switch (this.currentStep) {
@@ -254,12 +275,7 @@
           }
           // 鑾峰彇褰撳墠鐘舵��
           this.form.currentState = currentStepAction === 3 ? '鍏抽棴' : this.steps[currentStepAction];
-          this.$axios.post(this.$api.personnel.personJobResponsibilitiesSave, this.form, {
-            headers: {
-              'Content-Type': 'application/json'
-            },
-            noQs: true
-          }).then(res => {
+          personJobResponsibilitiesSave(this.form).then(res => {
             if (res.code == 200) {
               this.$message.success('鎻愪氦鎴愬姛');
               this.getPostList(this.departId);
@@ -307,34 +323,9 @@
     },
     // 涓嬭浇宀椾綅鑱岃矗
     downLoadPost(row) {
-      this.$axios.post(this.$api.personPostAuthorizationRecord.exportPersonJobResponsibilities,{id:row.id},{responseType: "blob"}).then(res => {
-        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.incumbentName+'-宀椾綅鑱岃矗'+'.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.incumbentName+'-宀椾綅鑱岃矗'+'.docx';
-            link.click();
-            this.$message.success('瀵煎嚭鎴愬姛')
-          }
-        }
+      exportPersonJobResponsibilities({ id: row.id }).then(res => {
+        const blob = new Blob([res], { type: 'application/octet-stream' });
+        this.$download.saveAs(blob, row.incumbentName + '-宀椾綅鑱岃矗' + '.docx');
       })
     },
     // 鍒犻櫎宀椾綅鑱岃矗
@@ -344,7 +335,7 @@
         cancelButtonText: '鍙栨秷',
         type: 'warning'
       }).then(() => {
-        this.$axios.delete(this.$api.personnel.personJobResponsibilitiesDelete + '?id=' + row.id).then(res => {
+        personJobResponsibilitiesDelete({ id: row.id }).then(res => {
           if (res.code == 200) {
             this.$message.success('鍒犻櫎鎴愬姛');
             this.getPostList(this.departId);
@@ -362,11 +353,11 @@
     },
     // 鑾峰彇璐熻矗浜轰俊鎭帴鍙�
     getUserList() {
-      this.$axios.get(this.$api.deviceScope.selectUserList).then(res => {
+      selectUserCondition({type: 2}).then(res => {
         if (res.code == 200) {
-          this.responsibleOptions = res.data;
+          this.responsibleOptions = res.data
         }
-      });
+      })
     },
     choiceStep(index) {
       this.currentStepClick = index;
@@ -386,8 +377,10 @@
         this.getPostList(newId);
       }
     }
-  }
+  },
+  computed: {
+    ...mapGetters(['nickName'])
+  },
 };
 </script>
-<style scoped>
-</style>
+<style scoped></style>

--
Gitblit v1.9.3