|
|
@@ -0,0 +1,187 @@
|
|
|
+const _Http = getApp().globalData.http;
|
|
|
+Page({
|
|
|
+ data: {
|
|
|
+ form: [{
|
|
|
+ label: "联系人",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "text",
|
|
|
+ value: "",
|
|
|
+ placeholder: "联系人",
|
|
|
+ valueName: "name",
|
|
|
+ required: true,
|
|
|
+ checking: "base"
|
|
|
+ }, {
|
|
|
+ label: "联系方式",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "number",
|
|
|
+ value: "",
|
|
|
+ placeholder: "联系方式",
|
|
|
+ valueName: "phonenumber",
|
|
|
+ required: true,
|
|
|
+ checking: "phone"
|
|
|
+ }, {
|
|
|
+ label: "省市县",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "region",
|
|
|
+ value: [],
|
|
|
+ placeholder: "省,市,县",
|
|
|
+ valueName: "region",
|
|
|
+ required: true
|
|
|
+ }, {
|
|
|
+ label: "详细地址",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "textarea",
|
|
|
+ value: "",
|
|
|
+ placeholder: "例: 科创园11栋1103室",
|
|
|
+ valueName: "address",
|
|
|
+ required: false,
|
|
|
+ checking: "base"
|
|
|
+ }],
|
|
|
+ disabled: true,
|
|
|
+ "content": {
|
|
|
+ "contactsid": 0, //地址id
|
|
|
+ "sys_enterpriseid": 0, //绑定数据
|
|
|
+ "sex": "",
|
|
|
+ "depname": "",
|
|
|
+ "position": "",
|
|
|
+ "isleader": 0,
|
|
|
+ "birthday": "",
|
|
|
+ "email": "",
|
|
|
+ "remarks": "",
|
|
|
+ "workaddress": 1,
|
|
|
+ "isdefault": 0, //是否默认地址
|
|
|
+ "isprimary": 0 //是否为主地址
|
|
|
+ },
|
|
|
+ tags: []
|
|
|
+ },
|
|
|
+ onLoad(options) {
|
|
|
+ getApp().globalData.Language.getLanguagePackage(this, '填写地址');
|
|
|
+ if (options.sys_enterpriseid) this.setData({
|
|
|
+ "content.sys_enterpriseid": options.sys_enterpriseid
|
|
|
+ })
|
|
|
+ if (options.data) {
|
|
|
+ let item = JSON.parse(options.data)
|
|
|
+ this.setData({
|
|
|
+ content: {
|
|
|
+ ...this.data.content,
|
|
|
+ ...item
|
|
|
+ },
|
|
|
+ "content.isdefault": item.isdefault,
|
|
|
+ 'form[0].value': item.name,
|
|
|
+ 'form[1].value': item.phonenumber,
|
|
|
+ 'form[2].value': item.city ? [item.province, item.city, item.county] : "",
|
|
|
+ 'form[3].value': item.address,
|
|
|
+ tags: item.tag,
|
|
|
+ 'content.isdefault': item.isdefault,
|
|
|
+ "disabled": false
|
|
|
+ })
|
|
|
+ };
|
|
|
+ _Http.basic({
|
|
|
+ "id": 20220929085401,
|
|
|
+ "content": {
|
|
|
+ "ownertable": "sys_enterprise_contacts",
|
|
|
+ "ownerid": 0
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log("数据标签", res)
|
|
|
+ this.setData({
|
|
|
+ tagList: res.data.option
|
|
|
+ })
|
|
|
+ })
|
|
|
+ if (options.type == '竞争对手') this.setData({
|
|
|
+ form: this.data.form.map(v => {
|
|
|
+ v.required = false
|
|
|
+ if (v.valueName == "phonenumber") {
|
|
|
+ v.checking = ""
|
|
|
+ v.type = "text"
|
|
|
+ }
|
|
|
+ return v
|
|
|
+ }),
|
|
|
+ disabled: false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ selectTag(e) {
|
|
|
+ const {
|
|
|
+ tag
|
|
|
+ } = e.currentTarget.dataset.item;
|
|
|
+ let i = this.data.tags.findIndex(v => tag == v);
|
|
|
+ if (i == -1) {
|
|
|
+ this.data.tags.push(tag);
|
|
|
+ } else {
|
|
|
+ this.data.tags.splice(i, 1)
|
|
|
+ };
|
|
|
+ this.setData({
|
|
|
+ tags: this.data.tags
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
+ /* 提交数据 */
|
|
|
+ submit() {
|
|
|
+ let data = this.selectComponent("#Form").submit();
|
|
|
+ if (!data || this.data.disabled) return;
|
|
|
+ const content = {
|
|
|
+ ...this.data.content,
|
|
|
+ ...data,
|
|
|
+ "province": data.region[0],
|
|
|
+ "city": data.region[1],
|
|
|
+ "county": data.region[2],
|
|
|
+ };
|
|
|
+ delete(content.region);
|
|
|
+ _Http.basic({
|
|
|
+ "id": "20221018141802",
|
|
|
+ content
|
|
|
+ }).then(res => {
|
|
|
+ console.log('新建地址', res)
|
|
|
+ if (res.code != '1') return wx.showToast({
|
|
|
+ title: res.data,
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ _Http.basic({
|
|
|
+ "id": 20220929090901,
|
|
|
+ "content": {
|
|
|
+ "ownertable": "sys_enterprise_contacts",
|
|
|
+ "ownerid": res.data.contactsid,
|
|
|
+ "datatag": this.data.tags
|
|
|
+ }
|
|
|
+ }).then(s => {
|
|
|
+ console.log("设置地址标签", s)
|
|
|
+ wx.showToast({
|
|
|
+ title: getApp().globalData.Language.getMapText('保存成功'),
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ res.data.tag = this.data.tags;
|
|
|
+ setTimeout(() => {
|
|
|
+ getCurrentPages().forEach(v => {
|
|
|
+ //更新列表
|
|
|
+ if (v.selectComponent("#Address")) {
|
|
|
+ let page = v.selectComponent("#Address");
|
|
|
+ page.getList('', true)
|
|
|
+ wx.navigateBack();
|
|
|
+ };
|
|
|
+ })
|
|
|
+ }, 300)
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 设置默认 */
|
|
|
+ checkboxChange() {
|
|
|
+ this.setData({
|
|
|
+ "content.isdefault": this.data.content.isdefault == 1 ? 0 : 1
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 表单是否填写完成 */
|
|
|
+ onConfirm({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ this.setData({
|
|
|
+ disabled: detail
|
|
|
+ })
|
|
|
+ }
|
|
|
+})
|