Pārlūkot izejas kodu

新建订单 订单类型根据自定义分类ordertype

xiaohaizhao 1 gadu atpakaļ
vecāks
revīzija
174cdbb17e

+ 26 - 2
packageA/orderForm/add/add.js

@@ -20,6 +20,7 @@ Page({
         })
     },
     onLoad(options) {
+        this.getOrderList()
         this.setData({
             type: options.type || '标准订单',
             sa_projectid: options.sa_projectid || 0,
@@ -49,6 +50,29 @@ Page({
             });
         })
     },
+    /* 获取orderList */
+    getOrderList() {
+        _Http.basic({
+            "classname": "sysmanage.develop.optiontype.optiontype",
+            "method": "optiontypeselect",
+            "content": {
+                "typename": "ordertype"
+            }
+        }).then(res => {
+            console.log("订单类型", res)
+            let orderList = [];
+            try {
+                orderList = res.data.map(v => v.value);
+            } catch (error) {
+
+            }
+            if (orderList.length == 0) orderList.push("标准订单")
+            this.setData({
+                orderList,
+                type: orderList[0]
+            })
+        })
+    },
     /* 选择品牌 */
     onSelectBrand(e) {
         let {
@@ -126,9 +150,9 @@ Page({
             this.setData({
                 loading: false
             })
-            console.log("创建标准订单", res);
+            console.log("创建" + this.data.type, res);
             wx.showToast({
-                title: res.msg != '成功' ? res.msg : '创建成功',
+                title: res.msg != '成功' ? res.msg || '创建失败' : '创建成功',
                 icon: "none",
                 mask: true
             });

+ 1 - 2
packageA/orderForm/add/add.wxml

@@ -22,8 +22,7 @@
         订单类型
     </view>
     <view class="content">
-        <van-button custom-class='but {{type=="标准订单"?"active":""}}' data-name="标准订单" bindtap="onSelectType">标准订单</van-button>
-        <van-button custom-class='but {{type=="特殊订单"?"active":""}}' data-name="特殊订单" bindtap="onSelectType">特殊订单</van-button>
+        <van-button wx:for="{{orderList}}" custom-class='but {{type==item?"active":""}}' data-name="{{item}}" bindtap="onSelectType">{{item}}</van-button>
     </view>
 </view>
 <view class="groud" wx:if="{{brandList.length}}">

+ 26 - 6
packageA/orderForm/index.js

@@ -51,6 +51,7 @@ Page({
     this.getList()
     this.getBrand()
     this.getDomain()
+    this.getOrderList()
   },
   /* 获取产品 */
   getList(init = false) {
@@ -149,6 +150,26 @@ Page({
       if (res.msg == '成功') this.data.brandList = res.data
     })
   },
+  /* 获取orderList */
+  getOrderList() {
+    _Http.basic({
+      "classname": "sysmanage.develop.optiontype.optiontype",
+      "method": "optiontypeselect",
+      "content": {
+        "typename": "ordertype"
+      }
+    }).then(res => {
+      console.log("订单类型", res)
+      let orderList = [];
+      try {
+        orderList = res.data.map(v => v.value);
+      } catch (error) {}
+      if (orderList.length == 0) orderList.push("标准订单")
+      this.setData({
+        orderList
+      })
+    })
+  },
   /* 获取领域 */
   getDomain() {
     _Http.basic({
@@ -191,11 +212,11 @@ Page({
     }, 300);
   },
   createOrder() {
-    if (this.data.brandList.length == 1 && this.data.filtratelist[1].list.length == 1) {
-
+    let orderList = this.data.orderList;
+    if (this.data.brandList.length == 1 && this.data.filtratelist[1].list.length == 1 && orderList.length == 1) {
       wx.showModal({
         title: '提示',
-        content: '是否确定创建标准订单',
+        content: `是否确定创建${orderList[0]}`,
         complete: ({
           confirm
         }) => {
@@ -208,12 +229,12 @@ Page({
               sa_contractid: 0,
               sa_projectid: 0,
               "sa_brandid": this.data.brandList[0].sa_brandid, //品牌ID
-              "type": "标准订单", //订单类型
+              "type": orderList[0], //订单类型
               "tradefield": this.data.filtratelist[1].list[0].tradefield, //必选
               sys_enterpriseid: 0
             }
           }).then(res => {
-            console.log("创建标准订单", res);
+            console.log(`创建${orderList[0]}`, res);
             wx.showToast({
               title: res.msg != '成功' ? res.msg : '创建成功',
               icon: "none",
@@ -227,7 +248,6 @@ Page({
           })
         }
       })
-
     } else {
       wx.navigateTo({
         url: '/packageA/orderForm/add/add?type=标准订单',