Ver código fonte

feat 上货逻辑修复

wzh 4 meses atrás
pai
commit
7fec758860

+ 10 - 0
api/hexiao.js

@@ -175,3 +175,13 @@ export function delYwy(id){
         }
         }
     })
     })
 }
 }
+
+export function getYwyByIdDetail(id){
+    return request({
+        url: `/jxs/getYwyByIdDetail`,
+        method: 'post',
+        params: {
+            ywyId:id
+        }
+    })
+}

+ 25 - 8
pages/cjx/hexiao/jxs/add_ywy.vue

@@ -53,7 +53,7 @@
 </template>
 </template>
 
 
 <script>
 <script>
-import {areaList,addYwy,updateYwy,getYwyDetail} from "@/api/hexiao";
+import {areaList,addYwy,updateYwy,getYwyByIdDetail} from "@/api/hexiao";
 
 
 export default {
 export default {
   data() {
   data() {
@@ -61,6 +61,7 @@ export default {
       // 区域列表数据
       // 区域列表数据
       areaList: [
       areaList: [
       ],
       ],
+      areaMap :{},
       // 表单数据
       // 表单数据
       formData: {
       formData: {
         id:0,
         id:0,
@@ -73,20 +74,34 @@ export default {
     };
     };
   },
   },
   onLoad(opt) {
   onLoad(opt) {
-    if(opt.id){
-      getYwyDetail(opt.id).then(res=>{
-        let data = res.data;
-      })
-    }
     // 在实际项目中,您应该在这里通过API获取区域列表
     // 在实际项目中,您应该在这里通过API获取区域列表
-    this.fetchAreaList();
+    this.fetchAreaList(opt);
   },
   },
   methods: {
   methods: {
 
 
-    fetchAreaList () {
+    fetchAreaList (opt) {
       // 模拟区域列表数据
       // 模拟区域列表数据
       areaList().then(res=>{
       areaList().then(res=>{
+        this.areaMap = {};
         this.areaList = res.data;
         this.areaList = res.data;
+        for (let i = 0; i < this.areaList.length; i++) {
+          let area = this.areaList[i];
+          this.areaMap [area.id] = area;
+        }
+        if(opt.id){
+          getYwyByIdDetail(opt.id).then(res=>{
+            let data = res.data;
+            this.formData = {
+              id: data.id,
+              name: data.nick_name,
+              account: data.tel_,
+              isJob: data.is_job,
+              regionId: data.area_id
+            }
+            let area = this.areaMap[data.area_id]
+            this.formData.region = area.area_name;
+          })
+        }
       })
       })
     },
     },
     // 监听 Switch 开关变化
     // 监听 Switch 开关变化
@@ -147,6 +162,8 @@ export default {
           uni.navigateBack();
           uni.navigateBack();
         })
         })
       }else{
       }else{
+        data.isJob = this.formData.isJob?1:0;
+        data.ywyId = this.formData.id;
         updateYwy(data).then(res=>{
         updateYwy(data).then(res=>{
           uni.hideLoading();
           uni.hideLoading();
           uni.showToast({
           uni.showToast({

+ 5 - 3
pages/cjx/hexiao/jxs/ywy_list.vue

@@ -25,8 +25,8 @@
             <uni-icons type="person-filled" size="22" color="#3c82f8"></uni-icons>
             <uni-icons type="person-filled" size="22" color="#3c82f8"></uni-icons>
             <text class="salesperson-name">{{ item.nick_name }}</text>
             <text class="salesperson-name">{{ item.nick_name }}</text>
           </view>
           </view>
-          <view class="status-badge" :class="item.status_ === 1 ? 'active' : 'inactive'">
-            {{ item.status_ === 1 ? '在职' : '离职' }}
+          <view class="status-badge" :class="item.is_job  ? 'active' : 'inactive'">
+            {{ item.is_job  ? '在职' : '离职' }}
           </view>
           </view>
         </view>
         </view>
 
 
@@ -156,7 +156,9 @@ export default {
     },
     },
     goToStores(id) { console.log('查看门店列表 ID:', id); this.build()},
     goToStores(id) { console.log('查看门店列表 ID:', id); this.build()},
     viewSalesData(id) { console.log('查看销售数据 ID:', id); this.build() },
     viewSalesData(id) { console.log('查看销售数据 ID:', id); this.build() },
-    editSalesperson(id) { console.log('编辑业务员 ID:', id); },
+    editSalesperson(id) {
+      uni.navigateTo({ url: '/pages/cjx/hexiao/jxs/add_ywy?id='+id });
+      console.log('编辑业务员 ID:', id); },
     viewPatrolRecords(id) { console.log('查看巡店记录 ID:', id); this.build()},
     viewPatrolRecords(id) { console.log('查看巡店记录 ID:', id); this.build()},
     deleteSalesperson(id) {
     deleteSalesperson(id) {
       let self = this;
       let self = this;

+ 7 - 4
pages/cjx/hexiao/login.vue

@@ -57,7 +57,7 @@
 <script>
 <script>
 // 1. 导入你的API方法
 // 1. 导入你的API方法
 import { getVerificationCode, login } from '@/api/hexiao.js';
 import { getVerificationCode, login } from '@/api/hexiao.js';
-import {getAdminToken, setAdminInfo, setAdminToken} from "../../../utils/auth";
+import {getAdminInfo, getAdminToken, setAdminInfo, setAdminToken} from "../../../utils/auth";
 
 
 export default {
 export default {
   data() {
   data() {
@@ -81,18 +81,21 @@ export default {
   },
   },
   onLoad(){
   onLoad(){
     let token = getAdminToken()
     let token = getAdminToken()
+    debugger;
     if(token){
     if(token){
       this.doLoginSuccess();
       this.doLoginSuccess();
     }
     }
   },
   },
   methods: {
   methods: {
     doLoginSuccess(){
     doLoginSuccess(){
-      let userType = 0;
+
+      let info = getAdminInfo()
+      let userType = info.roleType;
       let pageUrl = '/pages/cjx/hexiao/ywy/index';
       let pageUrl = '/pages/cjx/hexiao/ywy/index';
-      if(this.userType === 'distributor'){
+      if(userType === 1){
         pageUrl = '/pages/cjx/hexiao/jxs/index';
         pageUrl = '/pages/cjx/hexiao/jxs/index';
       }
       }
-      if(this.userType === 'salesman'){
+      if(userType === 2){
          pageUrl = '/pages/cjx/hexiao/ywy/index';
          pageUrl = '/pages/cjx/hexiao/ywy/index';
       }
       }
       uni.reLaunch({
       uni.reLaunch({

+ 13 - 13
pages/cjx/hexiao/ywy/add_goods_record.vue

@@ -1,18 +1,18 @@
 <template>
 <template>
   <view class="page-container">
   <view class="page-container">
-    <view class="search-wrapper">
-      <view class="search-bar">
-        <uni-icons type="search" size="20" color="#999"></uni-icons>
-        <input
-            class="search-input"
-            v-model="searchQuery"
-            placeholder="输入门店名称/上货日期搜索"
-            placeholder-class="placeholder"
-            confirm-type="search"
-            @confirm="handleSearch"
-        />
-      </view>
-    </view>
+<!--    <view class="search-wrapper">-->
+<!--      <view class="search-bar">-->
+<!--        <uni-icons type="search" size="20" color="#999"></uni-icons>-->
+<!--        <input-->
+<!--            class="search-input"-->
+<!--            v-model="searchQuery"-->
+<!--            placeholder="输入门店名称/上货日期搜索"-->
+<!--            placeholder-class="placeholder"-->
+<!--            confirm-type="search"-->
+<!--            @confirm="handleSearch"-->
+<!--        />-->
+<!--      </view>-->
+<!--    </view>-->
 
 
     <scroll-view class="list-container" scroll-y="true" @scrolltolower="loadMore">
     <scroll-view class="list-container" scroll-y="true" @scrolltolower="loadMore">
       <view v-if="recordList.length === 0 && loadStatus !== 'loading'" class="empty-list">
       <view v-if="recordList.length === 0 && loadStatus !== 'loading'" class="empty-list">

+ 6 - 6
pages/cjx/hexiao/ywy/retail.vue

@@ -92,10 +92,10 @@ export default {
     };
     };
   },
   },
   onShow(){
   onShow(){
-    this.fetchStoreList();
+    this.fetchStoreList(true);
   },
   },
   onLoad() {
   onLoad() {
-   this.fetchStoreList();
+   this.fetchStoreList(true);
   },
   },
   methods: {
   methods: {
     fetchStoreList(isRefresh = false) {
     fetchStoreList(isRefresh = false) {
@@ -130,13 +130,13 @@ export default {
     },
     },
     handleSearch() {
     handleSearch() {
         this.pagination.page = 1;
         this.pagination.page = 1;
-        this.fetchStoreList();
+        this.fetchStoreList(true);
     },
     },
     viewDetails(id) {
     viewDetails(id) {
-      uni.navigateTo({ url: '/pages/cjx/hexiao/add_retail?edit=0&id='+id });
+      uni.navigateTo({ url: '/pages/cjx/hexiao/ywy/add_retail?edit=0&id='+id });
       console.log('查看详情 ID:', id);
       console.log('查看详情 ID:', id);
       },
       },
-    editStore(id) {    uni.navigateTo({ url: '/pages/cjx/hexiao/add_retail?edit=1&id='+id });},
+    editStore(id) {    uni.navigateTo({ url: '/pages/cjx/hexiao/ywy/add_retail?edit=1&id='+id });},
     patrolStore(id) { console.log('巡店 ID:', id); },
     patrolStore(id) { console.log('巡店 ID:', id); },
     deleteStore(id) {
     deleteStore(id) {
       let self = this;
       let self = this;
@@ -158,7 +158,7 @@ export default {
       this.fetchStoreList(true);
       this.fetchStoreList(true);
     },
     },
     addNewStore() {
     addNewStore() {
-      uni.navigateTo({ url: `/pages/cjx/hexiao/add_retail?edit=1` });
+      uni.navigateTo({ url: `/pages/cjx/hexiao/ywy/add_retail?edit=1` });
      }
      }
   }
   }
 }
 }

+ 11 - 1
pages/cjx/hexiao/ywy/scan_code.vue

@@ -63,6 +63,7 @@ export default {
   },
   },
   methods: {
   methods: {
     getCodeNumber(code){
     getCodeNumber(code){
+
       if (this.codeList.includes(code)) {
       if (this.codeList.includes(code)) {
         uni.showToast({
         uni.showToast({
           title: '该码已存在',
           title: '该码已存在',
@@ -101,8 +102,17 @@ export default {
     },
     },
     // 3. 处理相机扫码成功的事件
     // 3. 处理相机扫码成功的事件
     onScanCodeSuccess(e) {
     onScanCodeSuccess(e) {
-      const code = e.detail.result;
+      let code = e.detail.result;
       console.log('扫描到的内容:', code);
       console.log('扫描到的内容:', code);
+      if(code.length != "https://e.dnzc.vip/abce563011c5347f".length){
+        uni.showToast({
+          title: '二维码有误',
+          icon: 'none'
+        });
+        return;
+      }
+      let index = code.lastIndexOf("/");
+      code = code.substr(index+1);
       this.getCodeNumber(code)
       this.getCodeNumber(code)
 
 
     },
     },