From a78e352b672fd6b634c24e0d9cf184f56b846f6a Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 28 十月 2025 15:25:45 +0800
Subject: [PATCH] 库存预警,无用功能隐藏

---
 src/views/collaborativeApproval/sealManagement/index.vue |  206 ++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 161 insertions(+), 45 deletions(-)

diff --git a/src/views/collaborativeApproval/sealManagement/index.vue b/src/views/collaborativeApproval/sealManagement/index.vue
index 1f88715..42d3ecf 100644
--- a/src/views/collaborativeApproval/sealManagement/index.vue
+++ b/src/views/collaborativeApproval/sealManagement/index.vue
@@ -3,22 +3,19 @@
     <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>
+              <span class="search_title">瀹℃壒鐘舵�侊細</span>
               <el-col :span="4">
                 <el-select v-model="sealSearchForm.status" placeholder="瀹℃壒鐘舵��" clearable>
                   <el-option label="寰呭鎵�" value="pending" />
@@ -29,6 +26,8 @@
               <el-col :span="4">
                 <el-button type="primary" @click="searchSealApplications">鎼滅储</el-button>
                 <el-button @click="resetSealSearch">閲嶇疆</el-button>
+                <el-button type="primary" @click="showSealApplyDialog = true">鐢宠鐢ㄥ嵃
+                </el-button>
               </el-col>
             </el-row>
 
@@ -72,12 +71,16 @@
                 </template>
               </el-table-column>
             </el-table>
-          </div>
-        </el-tab-pane>
+        </div> 
+    </el-card>
+      
+        
+          
+        
 
         <!-- 瑙勭珷鍒跺害绠$悊 -->
-        <el-tab-pane label="瑙勭珷鍒跺害绠$悊" name="regulations">
-          <div class="tab-content">
+        
+          <!-- <div class="tab-content">
             <el-row :gutter="20" class="mb-20">
               <el-col :span="6">
                 <el-input v-model="regulationSearchForm.title" placeholder="璇疯緭鍏ュ埗搴︽爣棰�" clearable />
@@ -124,23 +127,13 @@
                   <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> -->
+                  <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>
-    </el-card>
+                
+          </div> -->
+        
 
     <!-- 鐢ㄥ嵃鐢宠瀵硅瘽妗� -->
     <el-dialog v-model="showSealApplyDialog" title="鐢宠鐢ㄥ嵃" width="600px">
@@ -179,7 +172,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 +218,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 +255,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>
 
@@ -286,7 +283,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">
@@ -304,13 +301,20 @@
 import { ref, reactive, onMounted } 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)
@@ -363,6 +367,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' }],
@@ -383,11 +397,10 @@
 
 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) => {
@@ -596,11 +609,33 @@
     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) => {
@@ -615,18 +650,99 @@
     }
   })
 }
+// 鏌ョ湅鍒跺害璇︽儏
+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 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 => {

--
Gitblit v1.9.3