|
|
@@ -1,8 +1,12 @@
|
|
|
-const _Http = getApp().globalData.http;
|
|
|
-
|
|
|
+let _Http = getApp().globalData.http,
|
|
|
+ count = null;
|
|
|
Page({
|
|
|
data: {
|
|
|
showAll: false,
|
|
|
+ queryShow: false,
|
|
|
+ repetitionShow: false,
|
|
|
+ repetitionList: [],
|
|
|
+ isSubmit: false,
|
|
|
form: [{
|
|
|
label: "企业名称",
|
|
|
error: false,
|
|
|
@@ -12,6 +16,7 @@ Page({
|
|
|
placeholder: "企业全称",
|
|
|
valueName: "enterprisename",
|
|
|
checking: "base",
|
|
|
+ slot: "info",
|
|
|
required: true
|
|
|
}, {
|
|
|
label: "品牌名称",
|
|
|
@@ -80,6 +85,81 @@ Page({
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
+ /* 引入 */
|
|
|
+ introduce(e) {
|
|
|
+ let {
|
|
|
+ item
|
|
|
+ } = e.currentTarget.dataset,
|
|
|
+ that = this;
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: `是否确定引入“${item.companyName}”信息`,
|
|
|
+ complete: (res) => {
|
|
|
+ if (res.confirm) {
|
|
|
+ that.setData({
|
|
|
+ [`form[0].value`]: item.companyName,
|
|
|
+ queryShow: false,
|
|
|
+ queryList: null
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 工商查询 */
|
|
|
+ queryClient(e) {
|
|
|
+ let data = this.selectComponent("#Form").query();
|
|
|
+ this.setData({
|
|
|
+ form: this.data.form.map(v => {
|
|
|
+ v.value = data[v.valueName];
|
|
|
+ return v
|
|
|
+ }),
|
|
|
+ })
|
|
|
+ console.log(this.data.form)
|
|
|
+ if (data.enterprisename == '') return wx.showToast({
|
|
|
+ title: `您还未填写企业名称`,
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ _Http.basic({
|
|
|
+ id: 20221208103601,
|
|
|
+ content: {
|
|
|
+ pageNumber: 1,
|
|
|
+ pageTotal: 1,
|
|
|
+ pageSize: 5,
|
|
|
+ keyword: data.enterprisename,
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log("工商查询", res)
|
|
|
+ if (!res.data[0]) return wx.showToast({
|
|
|
+ title: '未查询到相关企业!',
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ queryList: res.data,
|
|
|
+ queryShow: true
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onClose() {
|
|
|
+ this.setData({
|
|
|
+ queryShow: false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ repClose() {
|
|
|
+ if (this.data.isSubmit) {
|
|
|
+ let that = this;
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: `是否继续创建`,
|
|
|
+ complete: (res) => {
|
|
|
+ if (res.confirm) that.handleSubmit(true);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ repetitionShow: false,
|
|
|
+ isSubmit: false
|
|
|
+ })
|
|
|
+ },
|
|
|
/* 表单必填项是否完成 */
|
|
|
onConfirm({
|
|
|
detail
|
|
|
@@ -96,7 +176,91 @@ Page({
|
|
|
showAll: detail
|
|
|
})
|
|
|
},
|
|
|
- submit() {
|
|
|
+ /* 查询是否重复 */
|
|
|
+ async queryRepetition(e) {
|
|
|
+ let {
|
|
|
+ enterprisename
|
|
|
+ } = this.selectComponent("#Form").query();
|
|
|
+ if (enterprisename == '') return wx.showToast({
|
|
|
+ title: `您还未填写企业名称`,
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ let res = await this.handleQueryRepetition({
|
|
|
+ sa_customersid: 0,
|
|
|
+ enterprisename,
|
|
|
+ taxno: "",
|
|
|
+ address: ""
|
|
|
+ });
|
|
|
+ console.log("查询重复", res)
|
|
|
+ if (res.msg != '成功') return wx.showToast({
|
|
|
+ title: res.msg,
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ countDown: 6
|
|
|
+ });
|
|
|
+ count = setInterval(() => {
|
|
|
+ let countDown = this.data.countDown;
|
|
|
+ if (countDown == 0) {
|
|
|
+ clearInterval(count);
|
|
|
+ this.setData({
|
|
|
+ countDown: ""
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ countDown--;
|
|
|
+ this.setData({
|
|
|
+ countDown
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
+ if (res.total == 0) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '未查询到疑似重复的客户信息',
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: `查询到${res.total}条疑似重复客户信息`,
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ repetitionShow: true,
|
|
|
+ repetitionList: res.data
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /* 处理查重 */
|
|
|
+ handleQueryRepetition(content) {
|
|
|
+ return _Http.basic({
|
|
|
+ "id": 20221208172002,
|
|
|
+ content
|
|
|
+ })
|
|
|
+ },
|
|
|
+ async submit() {
|
|
|
+ let data = this.selectComponent("#Form").submit();
|
|
|
+ let query = await this.handleQueryRepetition({
|
|
|
+ sa_customersid: 0,
|
|
|
+ enterprisename: data.enterprisename,
|
|
|
+ taxno: "",
|
|
|
+ address: ""
|
|
|
+ });
|
|
|
+
|
|
|
+ if (query.total != 0) {
|
|
|
+ wx.showToast({
|
|
|
+ title: `查询到${query.total}条疑似重复信息`,
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ repetitionShow: true,
|
|
|
+ repetitionList: query.data,
|
|
|
+ isSubmit: true
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.handleSubmit();
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ handleSubmit(tag = false) {
|
|
|
let content = {
|
|
|
...this.data.content,
|
|
|
...this.selectComponent("#Form").submit()
|
|
|
@@ -114,18 +278,29 @@ Page({
|
|
|
title: '保存成功',
|
|
|
icon: "none"
|
|
|
})
|
|
|
+ //绑定疑似重复标签
|
|
|
+ if (tag) _Http.basic({
|
|
|
+ "id": 20220929090901,
|
|
|
+ "content": {
|
|
|
+ "ownertable": "sa_competitor",
|
|
|
+ "ownerid": res.data.sa_competitorid,
|
|
|
+ "datatag": ["疑似重复"]
|
|
|
+ }
|
|
|
+ })
|
|
|
setTimeout(() => {
|
|
|
let pages = getCurrentPages(),
|
|
|
page = pages[pages.length - 2];
|
|
|
if (page.__route__ == 'packageA/opponent/index') {
|
|
|
- wx.navigateBack();
|
|
|
page.getList(true);
|
|
|
+ wx.redirectTo({
|
|
|
+ url: './detail?id=' + res.data.sa_competitorid,
|
|
|
+ })
|
|
|
} else if (page.__route__ == 'packageA/opponent/detail') {
|
|
|
wx.navigateBack();
|
|
|
page.getDetail();
|
|
|
}
|
|
|
- }, 300)
|
|
|
+ }, tag ? 500 : 300)
|
|
|
|
|
|
})
|
|
|
- },
|
|
|
+ }
|
|
|
})
|