From c99b4166febfde47d5b350d30bac443a11de42f5 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期五, 31 十月 2025 15:11:21 +0800
Subject: [PATCH] 协同审批-添加导出功能

---
 src/views/collaborativeApproval/sealManagement/index.vue |  286 ++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 181 insertions(+), 105 deletions(-)

diff --git a/src/views/collaborativeApproval/sealManagement/index.vue b/src/views/collaborativeApproval/sealManagement/index.vue
index 0ee068b..9d2d043 100644
--- a/src/views/collaborativeApproval/sealManagement/index.vue
+++ b/src/views/collaborativeApproval/sealManagement/index.vue
@@ -3,32 +3,32 @@
     <el-card class="box-card">
       <template #header>
         <div class="card-header">
-          <span>鐢ㄥ嵃绠$悊涓庤绔犲埗搴﹀彂甯�</span>
-          <el-button type="primary" @click="showSealApplyDialog = true">
-            <el-icon><Plus /></el-icon>
-            鐢宠鐢ㄥ嵃
-          </el-button>
+          <span>鐢ㄥ嵃绠$悊鍙戝竷</span>
         </div>
       </template>
 
-      <el-tabs v-model="activeTab" type="border-card">
-        <!-- 鐢ㄥ嵃鐢宠绠$悊 -->
-        <el-tab-pane label="鐢ㄥ嵃鐢宠绠$悊" name="seal">
-          <div class="tab-content">
-            <el-row :gutter="20" class="mb-20">
+      
+   <!-- 鐢ㄥ嵃鐢宠绠$悊 -->
+        <div class="tab-content">
+            <el-row :gutter="20" class="mb-20 ">
+              <span class="ml-10">鐢ㄥ嵃鏍囬锛�</span>
               <el-col :span="6">
                 <el-input v-model="sealSearchForm.title" placeholder="璇疯緭鍏ョ敵璇锋爣棰�" clearable />
               </el-col>
-              <el-col :span="4">
+              <span class="search_title">瀹℃壒鐘舵�侊細</span>
+              <el-col :span="6">
                 <el-select v-model="sealSearchForm.status" placeholder="瀹℃壒鐘舵��" clearable>
                   <el-option label="寰呭鎵�" value="pending" />
                   <el-option label="宸查�氳繃" value="approved" />
                   <el-option label="宸叉嫆缁�" value="rejected" />
                 </el-select>
               </el-col>
-              <el-col :span="4">
+              <el-col :span="8">
                 <el-button type="primary" @click="searchSealApplications">鎼滅储</el-button>
                 <el-button @click="resetSealSearch">閲嶇疆</el-button>
+                <el-button @click="handleExport">瀵煎嚭</el-button>
+                <el-button type="primary" @click="showSealApplyDialog = true">鐢宠鐢ㄥ嵃
+                </el-button>
               </el-col>
             </el-row>
 
@@ -72,74 +72,7 @@
                 </template>
               </el-table-column>
             </el-table>
-          </div>
-        </el-tab-pane>
-
-        <!-- 瑙勭珷鍒跺害绠$悊 -->
-        <el-tab-pane label="瑙勭珷鍒跺害绠$悊" name="regulations">
-          <div class="tab-content">
-            <el-row :gutter="20" class="mb-20">
-              <el-col :span="6">
-                <el-input v-model="regulationSearchForm.title" placeholder="璇疯緭鍏ュ埗搴︽爣棰�" clearable />
-              </el-col>
-              <el-col :span="4">
-                <el-select v-model="regulationSearchForm.category" placeholder="鍒跺害鍒嗙被" clearable>
-                  <el-option label="浜轰簨鍒跺害" value="hr" />
-                  <el-option label="璐㈠姟鍒跺害" value="finance" />
-                  <el-option label="瀹夊叏鍒跺害" value="safety" />
-                  <el-option label="鎶�鏈埗搴�" value="tech" />
-                </el-select>
-              </el-col>
-              <el-col :span="8">
-                <el-button type="primary" @click="searchRegulations">鎼滅储</el-button>
-                <el-button @click="resetRegulationSearch">閲嶇疆</el-button>
-                <el-button type="success" @click="handleAdd">
-                  鍙戝竷鍒跺害
-                </el-button>
-              </el-col>
-            </el-row>
-
-            <el-table :data="regulations" border v-loading="tableLoading"  style="width: 100%">
-              <el-table-column prop="regulationNum" label="鍒跺害缂栧彿" width="120" />
-              <el-table-column prop="title" label="鍒跺害鏍囬" min-width="200" />
-              <el-table-column prop="category" label="鍒嗙被" width="120">
-                <template #default="scope">
-                  <el-tag>{{ getCategoryText(scope.row.category) }}</el-tag>
-                </template>
-              </el-table-column>
-              <el-table-column prop="version" label="鐗堟湰" width="80" />
-              <el-table-column prop="createUserName" label="鍙戝竷浜�" width="120" />
-              <el-table-column prop="createTime" label="鍙戝竷鏃堕棿" width="180" />
-              <el-table-column prop="status" label="鐘舵��" width="100">
-                <template #default="scope">
-                  <el-tag :type="scope.row.status === 'active' ? 'success' : 'info'">
-                    {{ scope.row.status === 'active' ? '鐢熸晥涓�' : '宸插簾姝�' }}
-                  </el-tag>
-                </template>
-              </el-table-column>
-              <el-table-column prop="readCount" label="宸茶浜烘暟" width="100" />
-              <el-table-column label="鎿嶄綔" width="250" fixed="right">
-                <template #default="scope">
-                  <el-button link @click="viewRegulation(scope.row)">鏌ョ湅</el-button>
-                  <el-button link type="primary" @click="handleEdit(scope.row)">缂栬緫</el-button>
-                  <el-button link type="danger" @click="repealEdit(scope.row)">搴熷純</el-button>
-                  <el-button link type="success" @click="viewVersionHistory(scope.row)">鐗堟湰鍘嗗彶</el-button>
-                  <el-button link type="warning" @click="viewReadStatus(scope.row)">闃呰鐘舵��</el-button>
-                </template>
-              </el-table-column>
-            </el-table>
-                  <!-- 鍒嗛〉 -->
-            <pagination
-              v-show="total > 0"
-              :total="total"
-              layout="total, sizes, prev, pager, next, jumper"
-              :page="page.current"
-              :limit="page.size"
-              @pagination="paginationChange"
-            />
-          </div>
-        </el-tab-pane>
-      </el-tabs>
+        </div> 
     </el-card>
 
     <!-- 鐢ㄥ嵃鐢宠瀵硅瘽妗� -->
@@ -179,7 +112,7 @@
     </el-dialog>
 
     <!-- 瑙勭珷鍒跺害鍙戝竷瀵硅瘽妗� -->
-    <el-dialog v-model="showRegulationDialog" :title="operationType === 'add' ? '鍙戝竷鍒跺害' : '缂栬緫鍒跺害'" width="800px">
+    <!-- <el-dialog v-model="showRegulationDialog" :title="operationType === 'add' ? '鍙戝竷鍒跺害' : '缂栬緫鍒跺害'" width="800px">
       <el-form :model="regulationForm" :rules="regulationRules" ref="regulationFormRef" label-width="100px">
         <el-form-item label="鍒跺害缂栧彿" prop="regulationNum">
           <el-input v-model="regulationForm.regulationNum" placeholder="璇疯緭鍏ュ埗搴︾紪鍙�" />
@@ -225,7 +158,7 @@
           <el-button type="primary" @click="submitRegulation">鍙戝竷鍒跺害</el-button>
         </span>
       </template>
-    </el-dialog>
+    </el-dialog> -->
 
     <!-- 鐢ㄥ嵃璇︽儏瀵硅瘽妗� -->
     <el-dialog v-model="showSealDetailDialog" title="鐢ㄥ嵃鐢宠璇︽儏" width="700px">
@@ -262,6 +195,10 @@
           <h4>鍒跺害鍐呭</h4>
           <div class="regulation-content">{{ currentRegulationDetail.content }}</div>
         </div>
+        <!-- 濡傛灉tableData>0 鏄剧ず -->
+        <div style="margin: 10px 0;" v-if="tableData && tableData.length > 0" >
+          <el-button type="success" @click="resetForm(currentRegulationDetail)">纭鏌ョ湅</el-button>
+        </div>
       </div>
     </el-dialog>
 
@@ -270,8 +207,14 @@
       <el-table :data="versionHistory" style="width: 100%;margin-bottom: 10px">
         <el-table-column prop="version" label="鐗堟湰鍙�" width="100" />
         <el-table-column prop="updateTime" label="鏇存柊鏃堕棿" width="180" />
-        <el-table-column prop="updater" label="鏇存柊浜�" width="120" />
-        <el-table-column prop="changeLog" label="鍙樻洿璇存槑" />
+        <el-table-column prop="createUserName" label="鏇存柊浜�" width="120" />
+        <el-table-column prop="changeLog" label="鍙樻洿璇存槑">
+          <template #default="scope">
+            <el-tag :type="scope.row.status === 'active' ? 'success' : 'info'">
+              {{ scope.row.status === 'active' ? '鐢熸晥涓�' : '宸插簾姝�' }}
+            </el-tag>
+          </template>
+        </el-table-column>
       </el-table>
     </el-dialog>
 
@@ -280,7 +223,7 @@
       <el-table :data="readStatusList" style="width: 100%;margin-bottom: 10px">
         <el-table-column prop="employee" label="鍛樺伐濮撳悕" width="120" />
         <el-table-column prop="department" label="鎵�灞為儴闂�" width="150" />
-        <el-table-column prop="readTime" label="闃呰鏃堕棿" width="180" />
+        <el-table-column prop="createTime" label="闃呰鏃堕棿" width="180" />
         <el-table-column prop="confirmTime" label="纭鏃堕棿" width="180" />
         <el-table-column prop="status" label="鐘舵��" width="100">
           <template #default="scope">
@@ -295,16 +238,23 @@
 </template>
 
 <script setup>
-import { ref, reactive, onMounted } from 'vue'
+import { ref, reactive, onMounted, getCurrentInstance } from 'vue'
 import { ElMessage, ElMessageBox } from 'element-plus'
 import { Plus } from '@element-plus/icons-vue'
-import { listSealApplication, addSealApplication, updateSealApplication,listRuleManagement,addRuleManagement,updateRuleManagement,delRuleManagement  } from '@/api/collaborativeApproval/sealManagement.js'
+import { listSealApplication, addSealApplication, updateSealApplication,listRuleManagement,addRuleManagement,updateRuleManagement,delRuleManagement,getReadingStatusByRuleId,getReadingStatusList,addReadingStatus,updateReadingStatus  } from '@/api/collaborativeApproval/sealManagement.js'
 import { el } from 'element-plus/es/locales.mjs'
+import { getUserProfile } from '@/api/system/user.js'
+import {staffJoinDel, staffJoinListPage} from "@/api/personnelManagement/onboarding.js";
+import useUserStore from '@/store/modules/user'
+import { userLoginFacotryList } from "@/api/system/user.js"
 
 // 鍝嶅簲寮忔暟鎹�
+const currentUser = ref(null)
 const activeTab = ref('seal')
 const operationType = ref('add')
+const tableData = ref([])
 // 鐢ㄥ嵃鐢宠鐩稿叧
+const userStore = useUserStore()
 const showSealApplyDialog = ref(false)
 const tableLoading = ref(false)
 const showSealDetailDialog = ref(false)
@@ -357,6 +307,16 @@
   requireConfirm: false
 })
 
+const readStatus = ref({
+  id: '',
+  ruleId: '',
+  employee: '',
+  department: '',
+  createTime: '',
+  confirmTime: '',
+  status: 'unconfirmed'
+})
+
 const regulationRules = {
   title: [{ required: true, message: '璇疯緭鍏ュ埗搴︽爣棰�', trigger: 'blur' }],
   category: [{ required: true, message: '璇烽�夋嫨鍒跺害鍒嗙被', trigger: 'change' }],
@@ -375,17 +335,12 @@
 
 const regulations = ref([])
 
-const versionHistory = ref([
-  { version: 'v2.1', updateTime: '2025-01-10 09:00:00', updater: '浜轰簨閮�', changeLog: '鏇存柊鑰冨嫟鏃堕棿瑙勫畾' },
-  { version: 'v2.0', updateTime: '2023-12-15 10:30:00', updater: '浜轰簨閮�', changeLog: '鏂板鍔犵彮绠$悊瑙勫畾' },
-  { version: 'v1.0', updateTime: '2023-11-01 14:00:00', updater: '浜轰簨閮�', changeLog: '棣栨鍙戝竷' }
-])
+const versionHistory = ref([])
 
-const readStatusList = ref([
-  { employee: '闄堝織寮�', department: '閿�鍞儴', readTime: '2025-01-11 10:30:00', confirmTime: '2025-01-11 10:35:00', status: 'confirmed' },
-  { employee: '鍒橀泤濠�', department: '鎶�鏈儴', readTime: '2025-01-11 14:20:00', confirmTime: '', status: 'unconfirmed' },
-  { employee: '鐜嬪缓鍥�', department: '璐㈠姟閮�', readTime: '2025-01-12 09:15:00', confirmTime: '2025-01-12 09:20:00', status: 'confirmed' }
-])
+const readStatusList = ref([])
+  // { employee: '闄堝織寮�', department: '閿�鍞儴', readTime: '2025-01-11 10:30:00', confirmTime: '2025-01-11 10:35:00', status: 'confirmed' },
+  // { employee: '鍒橀泤濠�', department: '鎶�鏈儴', readTime: '2025-01-11 14:20:00', confirmTime: '', status: 'unconfirmed' },
+  // { employee: '鐜嬪缓鍥�', department: '璐㈠姟閮�', readTime: '2025-01-12 09:15:00', confirmTime: '2025-01-12 09:20:00', status: 'confirmed' }
 
 // 鐢ㄥ嵃鐢宠鐘舵��
 const getStatusType = (status) => {
@@ -594,28 +549,146 @@
     ElMessage.success('宸叉嫆缁濈敵璇�')
   })
 }
-// 鏌ョ湅鍒跺害璇︽儏
-const viewRegulation = (row) => {
-  currentRegulationDetail.value = row
-  showRegulationDetailDialog.value = true
-}
+// 鑾峰彇鍦ㄨ亴鍛樺伐鍒楄〃
+const getList = () => {
+  tableLoading.value = true;
+      //鑾峰彇褰撳墠鐧诲綍鐢ㄦ埛淇℃伅
+  getUserProfile().then(res => {
+    if(res.code == 200){
+      console.log(res.data.userName)
+      currentUser.value = res.data.userName
+    }
+  })
+  staffJoinListPage({staffState: 1}).then(res => {
+    tableLoading.value = false;
+    // tableData.value = res.data.records
+    // //绛涢�夊嚭鍜宑urrentUser鍚屽悕鐨勪汉鍛�
+    tableData.value = res.data.records.filter(item => item.staffName === currentUser.value)
+    console.log("tableData",tableData.value) 
+    page.total = res.data.total;
+      
+    if(tableData.value.length == 0){
+    ElMessage.error('褰撳墠鐢ㄦ埛鏈姞鍏ヤ换浣曢儴闂�')
+    }
+  }).catch(err => {
+    tableLoading.value = false;
+  })
+
+
+};
 
 // 鏌ョ湅鍒跺害鐗堟湰鍘嗗彶
 const viewVersionHistory = (row) => {
   showVersionHistoryDialog.value = true
+  const params = {
+
+    category: row.category
+  }
+  listRuleManagement(page,params).then(res => {
+    if(res.code == 200){
+      versionHistory.value = res.data.records
+    }
+  })
+}
+// 鏌ョ湅鍒跺害璇︽儏
+const viewRegulation = (row) => {
+  getList()
+  currentRegulationDetail.value = row
+  showRegulationDetailDialog.value = true
+  getReadingStatusByRuleId(row.id).then(res => {
+    if(res.code == 200){
+      readStatusList.value = res.data
+      if(readStatusList.value.length==0 && tableData.value.length>0){
+          const params = {
+          ruleId: row.id,
+          employee: tableData.value[0].staffName,
+          department: tableData.value[0].postJob,
+          status: 'unconfirmed'
+        }
+        addReadingStatus(params).then(res => {
+          if(res.code == 200){
+            ElMessage.success('鍒跺害闃呰鎴愬姛')
+          }
+        })
+      }
+    }
+  })
+  
 }
 // 鏌ョ湅鍒跺害闃呰鐘舵��
 const viewReadStatus = (row) => {
   showReadStatusDialog.value = true
+  //鏌ョ湅闃呰鐘舵�佸垪琛�
+  getReadingStatusByRuleId(row.id).then(res => {
+    if(res.code == 200){
+      readStatusList.value = res.data
+    }
+  })
 }
+
+//纭鏌ョ湅
+const resetForm = (row) => {
+  console.log("row",row)
+  row.readCount = row.readCount + 1
+  
+  updateRuleManagement(row).then(res => {
+    if(res.code == 200){
+      ElMessage.success('鏌ョ湅鏁伴噺淇敼鎴愬姛')
+      //淇敼闃呰鐘舵��
+      //鏍规嵁鍒跺害id鍜屽綋鍓嶇櫥褰曠殑鍛樺伐寰楀埌闃呰鐘舵��
+      // let item = readStatusList.value.filter(item => item.employee == tableData.value[0].staffName )
+      // if(item.length>0){
+      //   item[0].status = 'confirmed',
+      //   item[0].confirmTime = new Date().toISOString().replace('T', ' ').split('.')[0];
+      // }
+      // 绛涢�夊綋鍓嶅憳宸ュ搴旇鍒跺害鐨勯槄璇荤姸鎬佽褰�
+      let statusItem = readStatusList.value.find(item => item.employee === tableData.value[0].staffName && item.ruleId === row.id);
+
+      if (statusItem) {
+        // 濡傛灉鎵惧埌璁板綍锛屾洿鏂扮姸鎬佸拰纭鏃堕棿
+        statusItem.status = 'confirmed';
+        // 鏍煎紡鍖栨椂闂翠负"YYYY-MM-DD HH:mm:ss"鏍煎紡
+        const now = new Date();
+        statusItem.confirmTime = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')} ${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}:${String(now.getSeconds()).padStart(2, '0')}`;
+        // statusItem.confirmTime = new Date().toISOString().replace('T', ' ').split('.')[0];
+        
+        updateReadingStatus(statusItem).then(res => {
+          if(res.code == 200){
+            ElMessage.success('鍒跺害闃呰鐘舵�佷慨鏀规垚鍔�')
+          }
+        })
+      }
+
+    }
+  })
+}
+
+// 瀵煎嚭鐢ㄥ嵃鐢宠
+const { proxy } = getCurrentInstance()
+const handleExport = () => {
+  proxy.download('/sealApplicationManagement/export', { ...sealSearchForm }, '鐢ㄥ嵃鐢宠.xlsx')
+}
+
 // 鑾峰彇鍗扮珷鐢宠鍒楄〃鏁版嵁
 const getSealApplicationList = async () => {
   tableLoading.value = true
   listSealApplication(page,sealSearchForm)
   .then(res => {
-
-    sealApplications.value = res.data.records
-    page.value.total = res.data.total;
+    //鑾峰彇褰撳墠鐧诲綍鐨勯儴闂ㄤ俊鎭�
+// 鑾峰彇褰撳墠鐧诲綍鐨勯儴闂ㄤ俊鎭苟杩囨护鏁版嵁
+    const currentFactoryName = userStore.currentFactoryName
+    if (currentFactoryName) {
+      // 鏍规嵁currentFactoryName杩囨护鍑篸epartment鐩稿悓鐨勬暟鎹�
+      sealApplications.value = res.data.records.filter(item => item.department === currentFactoryName)
+      // 鏇存柊杩囨护鍚庣殑鎬绘暟
+      page.value.total = sealApplications.value.length
+    } else {
+      // 濡傛灉娌℃湁currentFactoryName锛屽垯鏄剧ず鎵�鏈夋暟鎹�
+      sealApplications.value = res.data.records
+      page.value.total = res.data.total
+    }
+    // sealApplications.value = res.data.records
+    // page.value.total = res.data.total;
     tableLoading.value = false;
 
   }).catch(err => {
@@ -629,6 +702,8 @@
   .then(res => {
 
     regulations.value = res.data.records
+    // 杩囨护鎺夊凡搴熷純鐨勫埗搴�
+    // regulations.value = res.data.records.filter(item => item.status !== 'repealed')
     page.value.total = res.data.total;
     tableLoading.value = false;
 
@@ -677,6 +752,7 @@
   border-radius: 4px;
   line-height: 1.6;
   white-space: pre-wrap;
+  height: 200px;
 }
 
 .dialog-footer {

--
Gitblit v1.9.3