123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- const deleteMark = require("../../../../utils/deleteMark"),
- _Http = getApp().globalData.http;
- let count = null;
- Component({
- properties: {
- endInsert: {
- type:Function
- },
- type: {
- type:String
- },
- content: {
- type: Object,
- value: {
- "sat_orderclueid": 0,
- "name": "",
- "phonenumber": "",
- "province": "",
- "city": "",
- "county": "",
- "address": "",
- "notes": "",
- "cluesource": ""
- },
- }
- },
- data: {
- region: ['', '', ''],
- disabled: true,
- loading: false
- },
- lifetimes: {
- ready: function () {
- this.isDisabled();
- }
- },
- methods: {
- initData() {
- let content = this.data.content;
- for (let i in content) {
- if (content[i] == '-') content[i] = ""
- };
- this.setData({
- content,
- "region[0]": content.province,
- "region[1]": content.city,
- "region[2]": content.county
- })
- },
-
- submit() {
- if (this.data.disabled || this.data.loading) return;
- if (!deleteMark.CheckPhoneNumber(this.data.content.phonenumber)) return;
- const that = this;
- if (this.data.type == '添加线索') return this.handleEdit();
- wx.showModal({
- title: "提示",
- content: "是否确认本次修改",
- success: ({
- confirm
- }) => {
- if (confirm) that.handleEdit();
- }
- })
- },
- handleEdit() {
- 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.msg,
- icon: "none"
- });
- wx.showToast({
- title: '保存成功!',
- })
- setTimeout(() => {
- this.triggerEvent("endInsert");
- }, 300);
- })
- },
-
- 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)
- })
- }, 500);
- },
-
- 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();
- }
- }
- })
|