Bladeren bron

员工(非店主)添加"我已离职"

shizhongqi 1 jaar geleden
bovenliggende
commit
656bd29395
2 gewijzigde bestanden met toevoegingen van 55 en 6 verwijderingen
  1. 50 5
      hdApp/src/admin/home/workbench.vue
  2. 5 1
      hdApp/src/api/admin/index.js

+ 50 - 5
hdApp/src/admin/home/workbench.vue

@@ -35,7 +35,7 @@
             {{ $util.numberFormat(data.todayData.order) || 0 }}
           </div>
         </navigator>
-        <div class="info-list" @click="">
+        <div class="info-list">
           <div class="info-list-name">昨天</div>
           <div class="info-list-value">
             {{ $util.numberFormat(0) || 0 }}
@@ -293,7 +293,7 @@ import autoUpdateMixins from "@/mixins/autoUpdate";
 import { ghsList } from "@/api/purchase";
 import { changeDelStatus } from "@/api/ghs";
 import {currentShop} from "@/api/shop";
-import { clearLogin,hasNotice } from "@/api/admin";
+import { clearLogin,hasNotice,delStaff } from "@/api/admin";
 export default {
   name: "workbench",
   components: { NotLogin },
@@ -438,14 +438,27 @@ export default {
 		},
     goMore(){
       let that = this
+      let shopkeeper = this.loginInfo.staff && this.loginInfo.staff.founder == 2 //判断店主(老板)
+      let items = ['已屏蔽商家', '我已离职', '开关商城', '也要一个此商城', '修改密码', '退出登录'];
+      if(shopkeeper) {
+        items = ['已屏蔽商家', '改进建议', '开关商城', '也要一个此商城', '修改密码', '退出登录'];
+      }
       uni.showActionSheet({
-        itemList: ['已屏蔽商家', '改进建议','开关商城','也要一个此商城','修改密码','退出登录'],
+        itemList: items,
         success: function (res) {
           if(res.tapIndex == 0){
             that.$util.pageTo({url: '/pagesPurchase/pb'})
           }
           if(res.tapIndex == 1){
-            that.suggest()
+            if(shopkeeper){
+              // 店主显示改进建议
+              that.suggest()
+            }else{
+              // 员工显示离职确认
+              that.$util.confirmModal({content:'确认离职?'}, () => {
+                that.handleStaffResignation()
+              })
+            }
           }
           if(res.tapIndex == 2){
             that.$util.pageTo({url:'/pagesPurchase/open'})
@@ -460,7 +473,7 @@ export default {
             that.$util.confirmModal({content:'确认退出?'},() => {
               // #ifdef APP-PLUS
               uni.clearStorage()
-              that.$store.commit("setLoginInfo", {})
+              that.$store.commit("setLoginInfo", {})
               plus.runtime.restart()
               // #endif
               // #ifdef MP-WEIXIN
@@ -683,6 +696,38 @@ export default {
           }
         })
     },
+    handleStaffResignation() {
+      let that = this
+      // 显示加载提示
+      uni.showLoading({ title: '处理中...' })
+      
+      delStaff({adminId: that.loginInfo.admin.id, staffId: that.loginInfo.shopAdminId }).then(res => {
+        uni.hideLoading()
+        if(res.code == 1){
+          that.$msg('离职成功')
+          // 清理本地数据
+          uni.clearStorage()
+          that.$store.commit("setLoginInfo", {})
+          
+          // 根据不同平台处理重启
+          // #ifdef APP-PLUS
+          plus.runtime.restart()
+          // #endif
+          // #ifdef MP-WEIXIN
+          uni.reLaunch({url:'/admin/home/workbench'})
+          // #endif
+          // #ifdef H5
+          window.location.reload()
+          // #endif
+        } else {
+          that.$msg(res.msg || '离职失败,请重试')
+        }
+      }).catch(err => {
+        uni.hideLoading()
+        console.error('离职API调用失败:', err)
+        that.$msg('网络错误,请重试')
+      })
+    }
   }
 };
 </script>

+ 5 - 1
hdApp/src/api/admin/index.js

@@ -31,4 +31,8 @@ export const modifyPassword = data => {
 
 export const hasNotice = data => {
 	return https.get("/admin/has-notice", data);
-};
+};
+
+export const delStaff = data => {
+	return https.post('/admin/del-staff', data)
+}