xiaohaizhao 2 месяцев назад
Родитель
Сommit
df5c5603e0
5 измененных файлов с 175 добавлено и 32 удалено
  1. 58 29
      CRM/customer/create.js
  2. 113 1
      CRM/customer/detail.js
  3. 2 0
      CRM/customer/detail.wxml
  4. 1 1
      components/Yl_Field/index.wxml
  5. 1 1
      packageA/repair/detail.wxml

+ 58 - 29
CRM/customer/create.js

@@ -58,23 +58,7 @@ Page({
       errMsg: "",
       errMsg: "",
       type: "radio",
       type: "radio",
       value: "",
       value: "",
-      radioList: [{
-          id: "线索",
-          name: "线索"
-        },
-        {
-          id: "客户上门",
-          name: "客户上门"
-        },
-        {
-          id: "线上",
-          name: "线上"
-        },
-        {
-          id: "其他",
-          name: "其他"
-        }
-      ],
+      radioList: [],
       valueName: "source",
       valueName: "source",
       required: true,
       required: true,
       checking: "base"
       checking: "base"
@@ -150,12 +134,45 @@ Page({
       checking: "base"
       checking: "base"
     }],
     }],
     "content": {
     "content": {
-      "sa_customersid": "0"
+      "sa_customersid": "0",
+      sat_orderclueid: 0
     }
     }
   },
   },
   onLoad(options) {
   onLoad(options) {
-    this.getCustomerSourceList();
-
+    // 如果是编辑模式,获取客户详情
+    if (options.edit) {
+      let data = _Http.detail;
+      let form = this.data.form.filter(v => v.label != '选择线索');
+      data.region = data.province ? [data.province, data.city, data.county] : [];
+      form = form.map(v => {
+        switch (v.valueName) {
+          case "source":
+            if (data.source == '线索转化') {
+              v.radioList = [{
+                name: '线索转化',
+                id: '线索转化'
+              }];
+              v.disabled = true;
+            } else {
+              this.getCustomerSourceList();
+            }
+            v.value = data[v.valueName] || ''
+            break;
+          default:
+            v.value = data[v.valueName] || ''
+            break;
+        }
+        return v
+      })
+      this.setData({
+        "content.sa_customersid": data.sa_customersid,
+        "content.sat_orderclueid": data.sat_orderclueid,
+        form
+      });
+      this.selectComponent("#Form").confirm()
+    } else {
+      this.getCustomerSourceList();
+    }
   },
   },
   // 获取客户来源列表
   // 获取客户来源列表
   getCustomerSourceList() {
   getCustomerSourceList() {
@@ -211,15 +228,27 @@ Page({
       })
       })
       console.log("创建客户", res)
       console.log("创建客户", res)
       if (res.code == 1) {
       if (res.code == 1) {
-        wx.navigateTo({
-          url: '/CRM/customer/detail?id=' + res.data.sa_customersid,
-          success: (result) => {
-            wx.showToast({
-              title: "成功",
-              icon: "none"
-            })
-          },
-        })
+        if (content.sa_customersid == 0) {
+          wx.redirectTo({
+            url: '/CRM/customer/detail?id=' + res.data.sa_customersid,
+            success: (result) => {
+              wx.showToast({
+                title: "创建成功",
+                icon: "none"
+              })
+            },
+          })
+        } else {
+          getCurrentPages().find(v => v.__route__ == 'CRM/customer/detail').getDetail()
+          wx.navigateBack({
+            success: (res) => {
+              wx.showToast({
+                title: "编辑成功",
+                icon: "none"
+              })
+            },
+          })
+        }
       }
       }
 
 
 
 

+ 113 - 1
CRM/customer/detail.js

@@ -26,7 +26,23 @@ Page({
       }
       }
     ],
     ],
     tabsActive: 0,
     tabsActive: 0,
-    sa_customersid: ''
+    sa_customersid: '',
+    tabbarList: [{
+        label: "编辑",
+        icon: "icon-dibu-bianji"
+      }, {
+        label: "开单",
+        icon: "icon-tabgenjinjilu"
+      },
+      {
+        label: "无效",
+        icon: "icon-tabxiangxixinxi1"
+      },
+      {
+        label: "删除",
+        icon: "icon-guanlian-shanchu"
+      }
+    ]
   },
   },
   onLoad(options) {
   onLoad(options) {
     this.setData({
     this.setData({
@@ -98,5 +114,101 @@ Page({
   /* 页面触底 */
   /* 页面触底 */
   onReachBottom() {
   onReachBottom() {
     this.partialRenewal();
     this.partialRenewal();
+  },
+  /* 底部功能栏点击事件 */
+  tabbarOnClick({
+    detail
+  }) {
+    let data = this.data.detail;
+    switch (detail.label) {
+      case '编辑':
+        _Http.detail = data
+        wx.navigateTo({
+          url: `/CRM/customer/create?edit=true`
+        });
+        break;
+      case 'invalid':
+        // 标记客户为无效
+        wx.showModal({
+          title: '确认无效',
+          content: '确定要将此客户标记为无效吗?',
+          success: (res) => {
+            if (res.confirm) {
+              // 调用API标记客户为无效
+              _Http.basic({
+                "id": "2026030916370001",
+                content: {
+                  sa_customersid: customerId,
+                  status: "无效客户"
+                }
+              }).then(res => {
+                if (res.code == 1) {
+                  wx.showToast({
+                    title: '标记成功',
+                    icon: 'success'
+                  });
+                  this.getDetail();
+                } else {
+                  wx.showToast({
+                    title: res.msg,
+                    icon: 'none'
+                  });
+                }
+              }).catch(() => {
+                wx.showToast({
+                  title: '网络错误',
+                  icon: 'none'
+                });
+              });
+            }
+          }
+        });
+        break;
+      case 'order':
+        // 为客户开单
+        wx.navigateTo({
+          url: `/CRM/order/create?customerId=${customerId}`
+        });
+        break;
+      case 'delete':
+        // 删除客户
+        wx.showModal({
+          title: '确认删除',
+          content: '确定要删除此客户吗?',
+          success: (res) => {
+            if (res.confirm) {
+              // 调用API删除客户
+              _Http.basic({
+                "id": "2026030916370001",
+                content: {
+                  sa_customersid: customerId,
+                  datastatus: 1 // 假设1表示删除
+                }
+              }).then(res => {
+                if (res.code == 1) {
+                  wx.showToast({
+                    title: '删除成功',
+                    icon: 'success'
+                  });
+                  setTimeout(() => {
+                    wx.navigateBack();
+                  }, 1000);
+                } else {
+                  wx.showToast({
+                    title: res.msg,
+                    icon: 'none'
+                  });
+                }
+              }).catch(() => {
+                wx.showToast({
+                  title: '网络错误',
+                  icon: 'none'
+                });
+              });
+            }
+          }
+        });
+        break;
+    }
   }
   }
 });
 });

+ 2 - 0
CRM/customer/detail.wxml

@@ -49,6 +49,8 @@
 
 
 <view style="height: 130rpx;" />
 <view style="height: 130rpx;" />
 
 
+<Yl_Tabbar list='{{tabbarList}}' bind:callback="tabbarOnClick" />
+
 <wxs module="set">
 <wxs module="set">
   module.exports = {
   module.exports = {
     color: function (statu) {
     color: function (statu) {

+ 1 - 1
components/Yl_Field/index.wxml

@@ -141,7 +141,7 @@
 			</view>
 			</view>
 			<view style="position: relative;">
 			<view style="position: relative;">
 				<view class="content" style="margin-bottom: -10rpx">
 				<view class="content" style="margin-bottom: -10rpx">
-					<van-radio-group value="{{ item.value }}" data-item="{{item}}" bind:change="radioChange">
+					<van-radio-group value="{{ item.value }}" disabled="{{item.disabled}}" data-item="{{item}}" bind:change="radioChange">
 						<view style="display: flex; flex-wrap: wrap;">
 						<view style="display: flex; flex-wrap: wrap;">
 							<van-radio wx:for="{{item.radioList}}" wx:for-item="it" wx:for-index="i" wx:key="it.name"
 							<van-radio wx:for="{{item.radioList}}" wx:for-item="it" wx:for-index="i" wx:key="it.name"
 								icon-size="16" custom-class="radio" name="{{it.id}}">{{it.name}}</van-radio>
 								icon-size="16" custom-class="radio" name="{{it.id}}">{{it.name}}</van-radio>

+ 1 - 1
packageA/repair/detail.wxml

@@ -38,7 +38,7 @@
 	</view>
 	</view>
 </Yl_FunTabs>
 </Yl_FunTabs>
 <view style="height: 140rpx;" />
 <view style="height: 140rpx;" />
-<view class="footer">
+<view class="footer" wx:if="{{detail.status=='新建' || detail.status=='已撤回' || detail.status=='提交'}}" >
 	<view></view>
 	<view></view>
 	<view wx:if="{{detail.status=='新建' || detail.status=='已撤回'}}" class="but-box">
 	<view wx:if="{{detail.status=='新建' || detail.status=='已撤回'}}" class="but-box">
 		<van-button custom-class='but' color="#3874F6" data-name="编辑" bind:click="tabbarOnClick">编辑</van-button>
 		<van-button custom-class='but' color="#3874F6" data-name="编辑" bind:click="tabbarOnClick">编辑</van-button>