Jelajahi Sumber

feat:2026-01-05功能需求开发1.0

yingjian.wu 1 hari lalu
induk
melakukan
82c2624a06
3 mengubah file dengan 96 tambahan dan 15 penghapusan
  1. 16 1
      api/hexiao.js
  2. 0 13
      pages/hexiao/jxs/add_ywy.vue
  3. 80 1
      pages/hexiao/jxs/ywy_list.vue

+ 16 - 1
api/hexiao.js

@@ -476,6 +476,13 @@ export function updateYwy(data){
         data: data
     })
 }
+export function transferStoreOwnership(data){
+    return request({
+        url: `/ywy/transferStoreOwnership`,
+        method: 'post',
+        data: data
+    })
+}
 export function delYwy(id){
     return request({
         url: `/jxs/deleteYwy`,
@@ -707,4 +714,12 @@ export function queryStoreSummary(data){
         method: 'post',
         data: data
     })
-}
+}
+
+export function queryStoreExpandCount(data){
+    return request({
+        url: `/ywy/queryStoreCountByDate`,
+        method: 'post',
+        data: data
+    })
+}

+ 0 - 13
pages/hexiao/jxs/add_ywy.vue

@@ -24,14 +24,6 @@
         />
       </view>
 
-      <view class="form-item item-flex" v-if="formData.id != 0">
-        <text class="form-label">业务员状态</text>
-        <view class="switch-wrapper">
-          <text :class="formData.isJob ? 'status-active' : ''">在职</text>
-          <switch :checked="formData.isJob" @change="statusChange" color="#409eff" />
-        </view>
-      </view>
-
       <picker mode="selector" :range="areaList" range-key="area_name" @change="handleAreaChange">
         <view class="form-item item-flex">
           <text class="form-label">所属区域</text>
@@ -104,11 +96,6 @@ export default {
         }
       })
     },
-    // 监听 Switch 开关变化
-    statusChange(e) {
-      this.formData.isJob = e.detail.value;
-    },
-
     // 关键改动:处理 Picker 的 change 事件
     handleAreaChange(e) {
       const selectedIndex = e.detail.value; // 获取用户选择的索引

+ 80 - 1
pages/hexiao/jxs/ywy_list.vue

@@ -79,6 +79,10 @@
             <uni-icons type="home-filled" size="18" color="#3c82f8"></uni-icons>
             <text>巡店记录</text>
           </view>
+          <view class="action-btn leave-btn" v-if="item.is_job" @click="leaveSalesperson(item)">
+            <uni-icons type="minus" size="18" color="#f59e0b"></uni-icons>
+            <text>离职</text>
+          </view>
           <view class="action-btn delete-btn" @click="deleteSalesperson(item.id)">
             <uni-icons type="trash-filled" size="18" color="#e54d42"></uni-icons>
             <text>删除</text>
@@ -96,7 +100,7 @@
 </template>
 
 <script>
- import {ywyList,delYwy} from "@/api/hexiao";
+ import {ywyList,delYwy,transferStoreOwnership} from "@/api/hexiao";
 
 export default {
   data() {
@@ -208,6 +212,80 @@ export default {
         }
       });
     },
+    leaveSalesperson(item) {
+      if (!item.is_job) {
+        uni.showToast({ title: '业务员已离职', icon: 'none' });
+        return;
+      }
+      uni.showModal({
+        title: '确认离职',
+        content: `确认将${item.nick_name}设置为离职吗?`,
+        confirmColor: '#e54d42',
+        success: (res) => {
+          if (!res.confirm) return;
+          uni.showModal({
+            title: '门店继承',
+            content: '是否需要选择在职业务员进行门店继承?',
+            confirmText: '需要',
+            cancelText: '不需要',
+            success: (inheritRes) => {
+              if (inheritRes.confirm) {
+                this.chooseSuccessor(item);
+                return;
+              }
+              if (inheritRes.cancel) {
+                this.submitLeave(item.id);
+              }
+            }
+          });
+        }
+      });
+    },
+    chooseSuccessor(item) {
+      const candidates = this.salespersonList.filter((person) => person.is_job && person.id !== item.id);
+      if (candidates.length === 0) {
+        uni.showToast({ title: '暂无可继承的在职业务员,已直接离职', icon: 'none' });
+        this.submitLeave(item.id);
+        return;
+      }
+      const itemList = candidates.map((person) => {
+        const phone = person.tel_ ? ` ${person.tel_}` : '';
+        return `${person.nick_name}${phone}`;
+      });
+      uni.showActionSheet({
+        itemList,
+        success: (res) => {
+          const selected = candidates[res.tapIndex];
+          if (selected) {
+            this.submitLeave(item.id, selected.id);
+          }
+        },
+        fail: () => {
+          this.submitLeave(item.id);
+        }
+      });
+    },
+    submitLeave(ywyId, inheritYwyId) {
+      uni.showLoading({ title: '处理中...' });
+      const data = {
+        leavingYwyId: ywyId,
+        inheritYwyId: inheritYwyId || 0
+      };
+      transferStoreOwnership(data)
+        .then((res) => {
+          uni.hideLoading();
+          if (res.code === 0) {
+            uni.showToast({ title: '已离职' });
+            this.fetchSalespeople(true);
+            return;
+          }
+          uni.showToast({ title: res.message || '操作失败', icon: 'none' });
+        })
+        .catch(() => {
+          uni.hideLoading();
+          uni.showToast({ title: '操作失败', icon: 'none' });
+        });
+    },
     addNewSalesperson() {
       console.log('跳转到新增业务员页面');
       uni.navigateTo({ url: '/pages/hexiao/jxs/add_ywy' });
@@ -322,6 +400,7 @@ export default {
   font-size: 26rpx;
   color: #3c82f8;
   text { margin-left: 8rpx; }
+  &.leave-btn { color: #f59e0b; }
   &.delete-btn { color: #e54d42; }
 }