Procházet zdrojové kódy

维修审批界面显示待审批工单数量

guarantee-lsq před 2 týdny
rodič
revize
faa7276a23

+ 62 - 0
src/components/Menu/menu.js

@@ -1,5 +1,6 @@
 import Menu from 'ant-design-vue/es/menu'
 import Icon from 'ant-design-vue/es/icon'
+import Badge from 'ant-design-vue/es/badge'
 
 const { Item, SubMenu } = Menu
 
@@ -38,10 +39,17 @@ export default {
       const keys = []
       vm.menu.forEach(item => keys.push(item.path))
       return keys
+    },
+    waitCount () {
+      return this.$store.state.user.waitCount
+    },
+    transferCount () {
+      return this.$store.state.user.transferCount
     }
   },
   mounted () {
     this.updateMenu()
+    this.dumpApprovalMenu()
   },
   watch: {
     collapsed (val) {
@@ -57,6 +65,22 @@ export default {
     }
   },
   methods: {
+    // 调试用:打印所有「审批」相关菜单的真实 title/path/name/children
+    dumpApprovalMenu: function () {
+      const walk = (arr) => {
+        if (!arr) return
+        arr.forEach(m => {
+          const mt = (m.meta && m.meta.title) || ''
+          const rt = (m.title) || ''
+          const t = mt || rt
+          if (t.indexOf('审批') >= 0 || t === '我的审批' || (m.children && m.children.some(c => ((c.meta && c.meta.title) || '').indexOf('审批') >= 0))) {
+            console.log('MENU-DEBUG', JSON.stringify({ title: t, metaTitle: mt, rawTitle: rt, path: m.path, name: m.name, childCount: m.children ? m.children.length : 0, childTitles: m.children ? m.children.map(c => (c.meta && c.meta.title) || c.title) : [] }))
+          }
+          walk(m.children)
+        })
+      }
+      walk(this.menu)
+    },
     // select menu item
     onOpenChange (openKeys) {
       // 在水平模式下时执行,并且不再执行后续
@@ -113,11 +137,41 @@ export default {
         })
       }
 
+      // 菜单红点:维修审批 / 转派审批 各自待办数(原生角标,避免 antd Badge 在 Menu.Item 内不显示)
+      let badge = null
+      const _t = (menu.meta.title || '')
+      let count = 0
+      if (_t.indexOf('维修审批') >= 0) {
+        count = this.waitCount
+      } else if (_t.indexOf('转派审批') >= 0) {
+        count = this.transferCount
+      }
+      if (count > 0) {
+        badge = (
+          <span style={{ position: 'relative', display: 'inline-block', marginLeft: '8px', verticalAlign: 'middle' }}>
+            <sup style={{ position: 'absolute', top: '-12px', right: '-12px', minWidth: '18px', height: '18px', lineHeight: '18px', borderRadius: '9px', background: '#f5222d', color: '#fff', fontSize: '12px', fontStyle: 'normal', fontWeight: 'normal', padding: '0 4px', textAlign: 'center', whiteSpace: 'nowrap', boxSizing: 'border-box' }}>{count}</sup>
+          </span>
+        )
+      }
+      if (_t.indexOf('审批') >= 0) {
+        console.log('ITEM-BADGE', JSON.stringify({ mt: _t, path: menu.path, wc: this.waitCount, tc: this.transferCount, hasBadge: !!badge }))
+      }
+      if (_t.indexOf('维修审批') >= 0) {
+        this.$nextTick(() => {
+          document.querySelectorAll('.ant-menu-item').forEach(el => {
+            if (el.textContent.indexOf('维修审批') >= 0) {
+              console.log('ITEM-DOM', el.outerHTML.slice(0, 600))
+            }
+          })
+        })
+      }
+
       return (
         <Item {...{ key: menu.path }}>
           <tag {...{ props, attrs }}>
             {this.renderIcon(menu.meta.icon)}
             <span>{menu.meta.title}</span>
+            {badge}
           </tag>
         </Item>
       )
@@ -127,11 +181,19 @@ export default {
       if (!menu.hideChildrenInMenu) {
         menu.children.forEach(item => itemArr.push(this.renderItem(item)))
       }
+      // 菜单红点:父级「我的审批」= 维修审批数 + 转派审批数(indexOf 兼容 title 带空格/后缀)
+      let badge = null
+      const _p = (menu.meta.title || '')
+      if (_p.indexOf('我的审批') >= 0) {
+        console.log('SUBMENU-BADGE', JSON.stringify({ mt: _p, path: menu.path, wc: this.waitCount, tc: this.transferCount, sum: this.waitCount + this.transferCount }))
+        badge = <Badge count={this.waitCount + this.transferCount} offset={[10, -4]} />
+      }
       return (
         <SubMenu {...{ key: menu.path }}>
           <span slot="title">
             {this.renderIcon(menu.meta.icon)}
             <span>{menu.meta.title}</span>
+            {badge}
           </span>
           {itemArr}
         </SubMenu>

+ 15 - 0
src/components/Menu/menu.render.js

@@ -42,6 +42,7 @@ export default {
   },
   created () {
     this.updateMenu()
+    this.dumpApprovalMenu()
   },
   watch: {
     collapsed (val) {
@@ -57,6 +58,20 @@ export default {
     }
   },
   methods: {
+    // 调试用:打印所有「审批」相关菜单的真实 title/path/name/children,供确认后端菜单数据
+    dumpApprovalMenu: function () {
+      const walk = (arr) => {
+        if (!arr) return
+        arr.forEach(m => {
+          const t = (m.meta && m.meta.title) || (m.title) || ''
+          if (t.indexOf('审批') >= 0 || t === '我的审批' || (m.children && m.children.some(c => ((c.meta && c.meta.title) || '').indexOf('审批') >= 0))) {
+            console.log('MENU-DEBUG', JSON.stringify({ title: t, path: m.path, name: m.name, childCount: m.children ? m.children.length : 0, childTitles: m.children ? m.children.map(c => (c.meta && c.meta.title) || c.title) : [] }))
+          }
+          walk(m.children)
+        })
+      }
+      walk(this.menu)
+    },
     renderIcon: function (h, icon) {
       if (icon === 'none' || icon === undefined) {
         return null

+ 17 - 0
src/store/modules/user.js

@@ -5,6 +5,7 @@ import { configData } from '@/api/upms/config'
 import { ACCESS_TOKEN } from '@/store/mutation-types'
 import DictCache from '@/utils/dict'
 import { welcome } from '@/utils/util'
+import { getRepairApplicationFormPage } from '@/api/repair/application-form'
 
 const user = {
   state: {
@@ -13,6 +14,8 @@ const user = {
     welcome: '',
     avatar: '',
     rmbRate: 1,
+    waitCount: 0,
+    transferCount: 0,
     permissions: [],
     roles: [],
     info: {
@@ -45,6 +48,12 @@ const user = {
     },
     SET_RMB_RATE: (state, rmbRate) => {
       state.rmbRate = rmbRate
+    },
+    SET_WAIT_COUNT: (state, count) => {
+      state.waitCount = count
+    },
+    SET_TRANSFER_COUNT: (state, count) => {
+      state.transferCount = count
     }
   },
 
@@ -141,6 +150,14 @@ const user = {
             commit('SET_RMB_RATE', rmbRate)
           })
 
+          // 菜单红点:维修审批待办数(searchType=3 审核中+已驳回)、转派审批待办数(status=8 转派审批)
+          getRepairApplicationFormPage({ searchType: 3, current: 1, size: 1 }).then(res => {
+            commit('SET_WAIT_COUNT', (res.data && res.data.total) || 0)
+          }).catch(() => {})
+          getRepairApplicationFormPage({ status: 8, type: 1, current: 1, size: 1 }).then(res => {
+            commit('SET_TRANSFER_COUNT', (res.data && res.data.total) || 0)
+          }).catch(() => {})
+
           resolve(response)
         }).catch(error => {
           reject(error)

+ 5 - 1
src/views/repair/application-form/RepairCheckForm.vue

@@ -183,7 +183,11 @@ export default {
             sortBy: 'asc, desc',
             sortName: 'status, apply_time'
           }
-        }).then(res => res.data)
+        }).then(res => {
+          const data = res.data
+          this.$store.commit('SET_WAIT_COUNT', (data && data.total) || 0)
+          return data
+        })
       }
     }
   },

+ 3 - 1
src/views/repair/application-form/TransferApproval.vue

@@ -143,7 +143,9 @@ export default {
         }
         return getRepairApplicationFormPage(parameter)
           .then(res => {
-            return res.data
+            const data = res.data
+            this.$store.commit('SET_TRANSFER_COUNT', (data && data.total) || 0)
+            return data
           })
       }
     }

+ 1 - 1
src/views/repair/application-form/modules/Detail.vue

@@ -77,7 +77,7 @@
             </detail-list-item>
           </detail-list>
           <a-divider v-if="dispatchList != null" orientation="left">转派详情</a-divider>
-          <detail-list v-for="(item, index) in dispatchList" title="" :key="index" :col="3">
+          <detail-list v-for="(item, index) in dispatchList" title="" :key="index" :col="4">
             <detail-list-item term="转派人">{{ item.username }}</detail-list-item>
             <detail-list-item term="转派时间">{{ item.time }}</detail-list-item>
             <detail-list-item term="转派备注">{{ item.remark }}</detail-list-item>

+ 1 - 1
src/views/repair/application-form/modules/DetailCheck.vue

@@ -88,7 +88,7 @@
             </detail-list-item>
           </detail-list>
           <a-divider v-if="dispatchList != null" orientation="left">转派详情</a-divider>
-          <detail-list v-for="(item, index) in dispatchList" title="" :key="index" :col="3">
+          <detail-list v-for="(item, index) in dispatchList" title="" :key="index" :col="4">
             <detail-list-item term="转派人">{{ item.username }}</detail-list-item>
             <detail-list-item term="转派时间">{{ item.time }}</detail-list-item>
             <detail-list-item term="转派备注">{{ item.remark }}</detail-list-item>

+ 14 - 6
src/views/repair/application-form/modules/DetailRepair.vue

@@ -141,7 +141,7 @@
           </detail-list>
           <div v-if="dispatchList == null || dispatchList.length === 0" style="margin-bottom: 16px; color: #999;">暂无派工记录</div>
           <a-divider v-if="transferList != null" orientation="left">转派记录</a-divider>
-          <detail-list v-for="(item, index) in transferList" title="" :key="index" :col="3">
+          <detail-list v-for="(item, index) in transferList" title="" :key="index" :col="4">
             <detail-list-item term="转派人">{{ item.operatorName }}</detail-list-item>
             <detail-list-item term="转派时间">{{ item.time }}</detail-list-item>
             <detail-list-item term="转派备注">{{ item.remark }}</detail-list-item>
@@ -159,11 +159,11 @@
             <detail-list-item term="审核开始时间">{{ model.checkStartTime }}</detail-list-item>
             <detail-list-item term="审核结束时间">{{ model.checkEndTime }}</detail-list-item>
             <detail-list-item term="审核人员">{{ model.checkUserName }}</detail-list-item>
-            <detail-list-item term="审核描述">{{ model.checkContent }}</detail-list-item>
+<!--            <detail-list-item term="审核描述">{{ model.checkContent }}</detail-list-item>-->
           </detail-list>
-          <detail-list title="审核图片:" :col="6">
+<!--          <detail-list title="审核图片:" :col="6">
             <upload-image-detail :images-list="model.checkFileList" />
-          </detail-list>
+          </detail-list>-->
         </a-layout-content>
         <a-layout-sider style="background-color: rgb(255, 255, 255)">
           <div style="margin-top: 30px;margin-left: 30px;">
@@ -275,7 +275,7 @@
     <detail-out ref="detailOutModal" @ok="handleOk" />
     <edit-form ref="editForm" @ok="handleOk" />
     <RejectForm ref="rejectForm" @ok="handleOk" />
-    <transfer-form ref="transferForm" @ok="handleOk" />
+    <transfer-form ref="transferForm" @ok="handleTransferOk" />
   </div>
 </template>
 
@@ -287,7 +287,8 @@ import {
   approve,
   receive,
   startRepair,
-  pauseRepair, continueRepair, endRepair
+  pauseRepair, continueRepair, endRepair,
+  getRepairApplicationFormPage
 } from '@/api/repair/application-form'
 import { getRepairEntrustByRepairId } from '@/api/repair/entrust'
 import DetailOut from './DetailRepairOut'
@@ -826,6 +827,13 @@ export default {
       })
       this.init()
     },
+    // 转派成功:同步刷新「转派审批」待办角标(口径与 store GetInfo 一致)
+    handleTransferOk() {
+      getRepairApplicationFormPage({ status: 8, type: 1, current: 1, size: 1 }).then(res => {
+        this.$store.commit('SET_TRANSFER_COUNT', (res.data && res.data.total) || 0)
+      }).catch(() => {})
+      this.handleOk()
+    },
     handleFinish() {
       const modal = this.$refs.finishForm
       modal.base(this.model)