xiaohaizhao 2 месяцев назад
Родитель
Сommit
48814ef8bd

+ 5 - 0
CRM/customer/detail.js

@@ -135,6 +135,11 @@ Page({
           url: `/CRM/customer/create?edit=true`
           url: `/CRM/customer/create?edit=true`
         });
         });
         break;
         break;
+      case '开单':
+        wx.navigateTo({
+          url: `/CRM/customer/modules/orderCreate/create?sa_customersid=${this.data.sa_customersid}}`
+        });
+        break;
       case '新建跟进':
       case '新建跟进':
         wx.navigateTo({
         wx.navigateTo({
           url: `/CRM/customer/modules/followRecord/create?ownerid=${this.data.sa_customersid}`
           url: `/CRM/customer/modules/followRecord/create?ownerid=${this.data.sa_customersid}`

+ 1 - 0
CRM/customer/detail.wxml

@@ -79,6 +79,7 @@
           break;
           break;
         case "正式客户":
         case "正式客户":
         case "正式":
         case "正式":
+        case "合作中":
           color = '#52C41A';
           color = '#52C41A';
           break;
           break;
         case "无效客户":
         case "无效客户":

+ 1 - 0
CRM/customer/index.wxml

@@ -92,6 +92,7 @@
           break;
           break;
         case "正式客户":
         case "正式客户":
         case "正式":
         case "正式":
+        case "合作中":
           color = '#52C41A';
           color = '#52C41A';
           break;
           break;
         case "无效客户":
         case "无效客户":

+ 223 - 0
CRM/customer/modules/orderCreate/create.js

@@ -0,0 +1,223 @@
+const _Http = getApp().globalData.http;
+
+Page({
+  data: {
+    loading: false,
+    disabled: false,
+    showAll: false,
+    activeTab: 0,
+    form: [{
+        label: "客户",
+        error: false,
+        errMsg: "",
+        type: "text",
+        value: "",
+        placeholder: "客户名称",
+        valueName: "name",
+        required: false,
+        checking: "base",
+        disabled: true
+      },
+      {
+        label: "门店",
+        error: false,
+        errMsg: "",
+        type: "text",
+        value: "",
+        placeholder: "门店名称",
+        valueName: "storename",
+        required: false,
+        checking: "base",
+        disabled: true
+      },
+      {
+        label: "开单日期",
+        error: false,
+        errMsg: "",
+        type: "date",
+        value: "",
+        placeholder: "请选择开单日期",
+        valueName: "billdate",
+        required: false,
+        checking: "base"
+      },
+      {
+        label: "订单数量",
+        error: false,
+        errMsg: "",
+        type: "number",
+        value: "0",
+        placeholder: "订单数量",
+        valueName: "orderCount",
+        required: false,
+        checking: "base",
+        disabled: true
+      },
+      {
+        label: "订单金额",
+        error: false,
+        errMsg: "",
+        type: "number",
+        value: "0",
+        placeholder: "订单金额",
+        valueName: "amount",
+        required: false,
+        checking: "base",
+        disabled: true
+      },
+      {
+        label: "备注",
+        error: false,
+        errMsg: "",
+        type: "textarea",
+        value: "",
+        placeholder: "请输入备注",
+        valueName: "remarks",
+        required: false,
+        checking: "base"
+      }
+    ],
+    "content": {
+      "sa_custorderid": 0,
+      "sa_customersid": "",
+      "name": "",
+      "storename": "",
+      "billdate": "",
+      "orderCount": 0,
+      "amount": 0,
+      "remarks": "",
+      "siteid": "MD"
+    }
+  },
+  onLoad(options) {
+    // 获取客户ID和客户信息
+    if (options.sa_customersid) {
+      this.setData({
+        "content.sa_customersid": options.sa_customersid
+      });
+
+      // 如果传递了客户信息,填充到表单
+      try {
+        const customerInfo = getCurrentPages().find(v => v.__route__ == 'CRM/customer/detail').data.detail;
+        let form = this.data.form;
+        console.log("customerInfo", customerInfo)
+        // 填充客户信息到表单
+        form.forEach(item => {
+          if (item.valueName === 'name' && customerInfo.name) {
+            item.value = customerInfo.name;
+          }
+          if (item.valueName === 'storename' && customerInfo.storename) {
+            item.value = customerInfo.storename;
+          }
+        });
+        this.setData({
+          form
+        });
+      } catch (error) {
+        console.error("解析客户信息失败", error);
+      }
+    }
+
+    // 设置默认开单日期为当天
+    const today = new Date().toISOString().split('T')[0];
+    let form = this.data.form;
+    form.forEach(item => {
+      if (item.valueName === 'billdate') {
+        item.value = today;
+        this.setData({
+          "content.billdate": today
+        });
+      }
+    });
+    this.setData({
+      form
+    });
+  },
+  submit() {
+    this.setData({
+      loading: true
+    });
+    let formData = this.selectComponent("#Form").submit();
+
+    if (!formData) {
+      this.setData({
+        loading: false
+      });
+      return;
+    }
+
+    let content = {
+      ...this.data.content,
+      ...formData
+    };
+
+    _Http.basic({
+      "id": "2026031309441701", // 创建订单的接口ID
+      content
+    }).then(res => {
+      this.setData({
+        loading: false
+      });
+      console.log("保存订单", res);
+      if (res.code == 1) {
+        // 刷新客户详情页面
+        const pages = getCurrentPages();
+        const detailPage = pages.find(v => v.__route__ == 'CRM/customer/detail');
+        if (detailPage) {
+          detailPage.partialRenewal(true);
+        }
+        wx.navigateBack({
+          success() {
+            wx.showToast({
+              title: "开单成功",
+              icon: "success"
+            });
+          }
+        });
+      } else {
+        wx.showToast({
+          title: res.msg || '保存失败',
+          icon: 'none'
+        });
+      }
+    }).catch(err => {
+      this.setData({
+        loading: false
+      });
+      console.error("保存订单失败", err);
+      wx.showToast({
+        title: '网络错误',
+        icon: 'none'
+      });
+    });
+  },
+  interrupt({
+    detail
+  }) {
+    // 处理中断逻辑,如果需要的话
+  },
+  /* 表单必填项是否完成 */
+  onConfirm({
+    detail
+  }) {
+    this.setData({
+      disabled: detail
+    });
+  },
+  onChange(e) {
+    this.setData({
+      showAll: e.detail
+    });
+  },
+  closePage() {
+    wx.navigateBack({
+      delta: 1
+    });
+  },
+  // tab切换
+  onTabChange(e) {
+    this.setData({
+      activeTab: e.detail
+    });
+  }
+});

+ 7 - 0
CRM/customer/modules/orderCreate/create.json

@@ -0,0 +1,7 @@
+{
+  "usingComponents": {
+    "Yl_Field": "../../../../components/Yl_Field/index",
+    "Yl_Headline": "../../../../components/Yl_Headline/index",
+    "van-button": "@vant/weapp/button/index"
+  }
+}

+ 23 - 0
CRM/customer/modules/orderCreate/create.scss

@@ -0,0 +1,23 @@
+.new-footer {
+  position: fixed;
+  display: flex;
+  justify-content: flex-end;
+  left: 0;
+  bottom: 0;
+  width: 100%;
+  padding: 20rpx 30rpx;
+  padding-top: 10rpx;
+  box-sizing: border-box;
+  background-color: #fff;
+  box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.1);
+}
+
+.new-submit {
+  width: 180rpx;
+  height: 80rpx;
+  line-height: 80rpx;
+  border-radius: 8rpx !important;
+  font-size: 32rpx;
+  background-color: #3874F6;
+  color: #fff;
+}

+ 25 - 0
CRM/customer/modules/orderCreate/create.wxml

@@ -0,0 +1,25 @@
+<Yl_Headline title='开单信息' type='switch' switchLabel='仅显示必填信息' switch='{{showAll}}' bind:callBack='onChange' />
+<Yl_Field id='Form' form='{{form}}' showAll='{{!showAll}}' bind:onConfirm='onConfirm' bind:interrupt="interrupt" />
+<view style="height: 20rpx;"></view>
+<!-- Tab切换 -->
+<van-tabs active="{{activeTab}}" color='#3874F6' title-active-color='#3874F6' bind:change="onTabChange">
+  <van-tab title="商品">
+    <view style="padding: 20rpx;">
+      <view class="empty">
+        <text>请添加商品</text>
+      </view>
+    </view>
+  </van-tab>
+  <van-tab title="附件">
+    <view style="padding: 20rpx;">
+      <view class="empty">
+        <text>请添加附件</text>
+      </view>
+    </view>
+  </van-tab>
+</van-tabs>
+
+<view style="height: 150rpx;" />
+<view class="new-footer">
+  <van-button custom-class='new-submit' color='#3874F6' disabled='{{disabled || loading}}' loading='{{loading}}' bind:tap='submit'>确定</van-button>
+</view>

+ 2 - 1
app.json

@@ -124,7 +124,8 @@
         "lead/index",
         "lead/index",
         "lead/detail",
         "lead/detail",
         "customer/modules/order/details",
         "customer/modules/order/details",
-        "customer/modules/followRecord/create"
+        "customer/modules/followRecord/create",
+        "customer/modules/orderCreate/create"
       ]
       ]
     }
     }
   ],
   ],