zhaoxiaohai před 3 roky
rodič
revize
c8aaaf7455

+ 87 - 0
pages/threadedTree/modules/insert/insert.js

@@ -0,0 +1,87 @@
+const deleteMark = require("../../../../utils/deleteMark"),
+    _Http = getApp().globalData.http;
+let count = null;
+Component({
+    properties: {
+        endInsert: {
+            type: Function
+        }
+    },
+    data: {
+        region: ['', '', ''], //省市县选择
+        "content": {
+            "sat_orderclueid": 0,
+            "name": "",
+            "phonenumber": "",
+            "province": "",
+            "city": "",
+            "county": "",
+            "address": "",
+            "notes": "",
+            "cluesource": ""
+        },
+        disabled: true,
+        loading: false
+    },
+    methods: {
+        /* 提交 */
+        submit() {
+            if (this.data.disabled || this.data.loading) return;
+            if (!deleteMark.CheckPhoneNumber(this.data.content.phonenumber)) return;
+            this.setData({
+                loading: true
+            });
+            _Http.basic({
+                "classname": "saletool.orderclue.web.orderclue",
+                "method": "edit",
+                content: this.data.content
+            }).then(res => {
+                this.setData({
+                    loading: false
+                });
+                if (res.msg != '成功') return wx.showToast({
+                    title: res.data,
+                    icon: "none"
+                });
+                this.triggerEvent("endInsert");
+            })
+        },
+        /* 输入框输入内容 */
+        inputChange(e) {
+            let text = e.type == 'input' ? e.detail.value : e.detail;
+            text = deleteMark.queryStr(text);
+            const {
+                label
+            } = e.currentTarget.dataset;
+            this.setData({
+                ["content." + label]: text
+            })
+            if (['phonenumber', 'province', 'cluesource'].includes(label)) this.isDisabled();
+        },
+        /* 是否禁用 */
+        isDisabled() {
+            clearTimeout(count)
+            count = setTimeout(() => {
+                let {
+                    phonenumber,
+                    province,
+                    cluesource
+                } = this.data.content;
+                this.setData({
+                    disabled: !(phonenumber && province && cluesource)
+                })
+            }, 1000);
+        },
+        /* 省市县选择器 */
+        bindRegionChange: function (e) {
+            let region = e.detail.value;
+            this.setData({
+                region,
+                "content.province": region[0],
+                "content.city": region[1],
+                "content.county": region[2],
+            })
+            this.isDisabled();
+        }
+    }
+})

+ 7 - 0
pages/threadedTree/modules/insert/insert.json

@@ -0,0 +1,7 @@
+{
+    "component": true,
+    "usingComponents": {
+        "van-field": "@vant/weapp/field/index",
+        "van-area": "@vant/weapp/area/index"
+    }
+}

+ 78 - 0
pages/threadedTree/modules/insert/insert.scss

@@ -0,0 +1,78 @@
+.box {
+  width: 100vw;
+  box-sizing: border-box;
+
+  .label {
+    height: 40rpx;
+    font-size: 28rpx;
+    font-family: PingFang SC-Regular, PingFang SC;
+    color: #333333;
+    line-height: 40rpx;
+    margin-top: 40rpx;
+    margin-left: 30rpx;
+
+    text {
+      color: #FF3B30;
+      margin-right: 8rpx;
+    }
+  }
+
+  .input-class {
+    width: 690rpx;
+    height: 90rpx;
+    background: #FFFFFF;
+    border-radius: 16rpx;
+    border: 1px solid #CCCCCC;
+    padding: 0 30rpx;
+  }
+}
+
+/* 选择器样式 */
+.selector {
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+  width: 690rpx;
+  height: 90rpx;
+  background: #FFFFFF;
+  border-radius: 16rpx;
+  border: 1px solid #CCCCCC;
+  margin: 0 auto;
+  margin-top: 20rpx;
+  padding: 0 30rpx;
+  box-sizing: border-box;
+
+}
+
+.selector,
+.input-class,
+.textarea {
+  font-size: 28rpx;
+  font-family: PingFang SC-Regular, PingFang SC;
+  color: #666666;
+}
+
+.textarea {
+  display: block;
+  height: 300rpx;
+  padding: 26rpx 30rpx;
+}
+
+
+.button-box {
+  width: 100vw;
+  text-align: center;
+  margin-top: 60rpx;
+  padding-bottom: 150rpx;
+
+  .button {
+    width: 500rpx !important;
+    height: 90rpx !important;
+    background: #3874F6 !important;
+    border-radius: 45rpx !important;
+    font-size: 28rpx !important;
+    font-family: PingFang SC-Bold, PingFang SC !important;
+    font-weight: bold !important;
+    color: #FFFFFF !important;
+  }
+}

+ 22 - 0
pages/threadedTree/modules/insert/insert.wxml

@@ -0,0 +1,22 @@
+<view class="box">
+  <view class="label">客户名称:</view>
+  <van-field value="{{ content.name }}" input-class='input-class' border="{{ false }}" data-label="name" bind:change="inputChange" />
+  <view class="label"><text>*</text>手机号码:</view>
+  <van-field value="{{ content.phonenumber }}" type='number' input-class='input-class' border="{{ false }}" data-label="phonenumber" bind:change="inputChange" />
+  <view class="label"><text>*</text>省市县:</view>
+  <picker mode="region" bindchange="bindRegionChange" value="{{region}}">
+    <view class="selector">
+      <view>{{region[0]?region:'请选择'}}</view>
+      <van-icon name="arrow-down" />
+    </view>
+  </picker>
+  <view class="label">地址:</view>
+  <van-field value="{{ content.address }}" input-class='input-class' border="{{ false }}" data-label="address" bind:change="inputChange" />
+  <view class="label"><text>*</text>来源:</view>
+  <van-field value="{{ content.cluesource }}" input-class='input-class' border="{{ false }}" data-label="cluesource" bind:change="inputChange" />
+  <view class="label">备注:</view>
+  <textarea value='{{content.notes}}' class="textarea selector" data-label="notes" bind:input="inputChange" placeholder="请输入备注"></textarea>
+</view>
+<view class="button-box">
+  <van-button disabled='{{disabled}}' custom-class='button' loading='{{loading}}' loading-text="保存中..." bindtap="submit">保存</van-button>
+</view>