zhaoxiaohai hace 3 años
padre
commit
fc826bcdbe

+ 231 - 0
packageA/publicCustomer/addAndEditor.js

@@ -0,0 +1,231 @@
+const _Http = getApp().globalData.http;
+
+Page({
+    data: {
+        showAll: false,
+        form: [{
+            label: "企业名称",
+            error: false,
+            errMsg: "",
+            type: "textarea",
+            value: "",
+            placeholder: "企业全称",
+            valueName: "enterprisename",
+            checking: "base",
+            required: true
+        }, {
+            label: "选择公海池",
+            error: false,
+            errMsg: "",
+            type: "route",
+            url: "/packageA/publicCustomer/pond/index",
+            radio: true,
+            value: "",
+            params: {
+                "id": 20221206195102,
+                "content": {
+                    "pageNumber": 1,
+                    "pageSize": 20,
+                    "where": {
+                        "condition": ""
+                    }
+                }
+            },
+            placeholder: "选择所属公海池",
+            valueName: "sa_customerpoolid",
+            checking: "base",
+            required: true
+        }, {
+            label: "企业简称",
+            error: false,
+            errMsg: "",
+            type: "textarea",
+            value: "",
+            placeholder: "企业简称",
+            valueName: "abbreviation",
+            checking: "base",
+            required: false
+        }, {
+            label: "统一社会信用代码",
+            error: false,
+            errMsg: "",
+            type: "textarea",
+            value: "",
+            placeholder: "企业税号/注册号/营业执照号码",
+            valueName: "taxno",
+            checking: "base",
+            required: false
+        }, {
+            label: "法定代表人",
+            error: false,
+            errMsg: "",
+            type: "text",
+            value: "",
+            placeholder: "企业法人",
+            valueName: "contact",
+            checking: "base",
+            required: false
+        }, {
+            label: "法人电话号码",
+            error: false,
+            errMsg: "",
+            type: "number",
+            value: "",
+            placeholder: "法人联系手机号",
+            valueName: "phonenumber",
+            checking: "phone",
+            required: false
+        }, {
+            label: "所属行业",
+            error: false,
+            errMsg: "",
+            type: "option", //自定义选择  配合预定接口
+            optionNmae: "industry", //选择类型
+            optionType: "radio", //复选   radio 单选
+            value: "",
+            placeholder: "企业所属行业",
+            valueName: "industry",
+            checking: "base",
+            required: false
+        }, {
+            label: "地区",
+            error: false,
+            errMsg: "",
+            type: "region",
+            value: [],
+            placeholder: "所属地区 省/市/区",
+            valueName: "region",
+            required: false
+        }, {
+            label: "注册地址",
+            error: false,
+            errMsg: "",
+            type: "textarea",
+            value: "",
+            placeholder: "企业注册地址",
+            valueName: "address",
+            checking: "base",
+            required: false
+        }, {
+            label: "客户类型",
+            error: false,
+            errMsg: "",
+            type: "option",
+            optionNmae: "customertypemx",
+            optionType: "radio", //复选   radio 单选
+            value: "",
+            placeholder: "客户类型",
+            valueName: "type",
+            checking: "base",
+            required: true
+        }, {
+            label: "客户级别",
+            error: false,
+            errMsg: "",
+            type: "option",
+            optionNmae: "agentgrade",
+            optionType: "radio", //复选   radio 单选
+            value: "",
+            placeholder: "客户数字级别",
+            valueName: "grade",
+            checking: "base",
+            required: false
+        }],
+        content: {
+            "sa_customersid": 0, //新增是传0
+            "parentid": 0, //上级客户ID,默认或没有上级的时候传0
+            "sys_enterpriseid": 0, //合作企业档案ID,新增是传0,更新
+            "source": "", //客户来源
+        },
+        disabled: true
+    },
+    setOption(item) {
+        let i = this.data.form.findIndex(v => v.valueName == item.valueName);
+        this.setData({
+            [`form[${i}]`]: item
+        })
+    },
+    onLoad(options) {
+        if (options.data) {
+            let data = JSON.parse(options.data);
+            this.setData({
+                disabled: false,
+                content: {
+                    sa_customersid: data.sa_customersid,
+                    parentid: data.parentid,
+                    sys_enterpriseid: data.sys_enterpriseid,
+                    sa_customerpoolid: data.sa_customerpoolid,
+                    source: data.source,
+                },
+                form: this.data.form.map(v => {
+                    if (v.valueName != 'region') {
+                        v.value = data[v.valueName];
+                    } else {
+                        v.value = data.province ? [data.province, data.city, data.county] : []
+                    }
+                    return v
+                })
+            })
+        }
+    },
+    /* 表单必填项是否完成 */
+    onConfirm({
+        detail
+    }) {
+        this.setData({
+            disabled: detail
+        })
+    },
+    // 是否显示全部
+    onChange({
+        detail
+    }) {
+        this.setData({
+            showAll: detail
+        })
+    },
+    submit() {
+        let data = this.selectComponent("#Form").submit();
+        if (data.region.length != 0) {
+            data.province = data.region[0]
+            data.city = data.region[1]
+            data.county = data.region[2]
+        };
+        data.sa_customerpoolid = data.sa_customerpoolid[1][0]
+        delete(data.region);
+        _Http.basic({
+            "id": 20221010164302,
+            "content": {
+                ...this.data.content,
+                ...data,
+            }
+        }).then(res => {
+            console.log("新建客户", res)
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            })
+            wx.showToast({
+                title: '保存成功',
+                icon: "none"
+            })
+            setTimeout(() => {
+                getCurrentPages().forEach(v => {
+                    switch (v.__route__) {
+                        case 'packageA/publicCustomer/index':
+                            v.getList(true);
+                            break;
+                        case 'packageA/publicCustomer/detail':
+                            wx.navigateBack()
+                            v.getDetail();
+                            break;
+                    }
+                })
+                let pages = getCurrentPages();
+                if (pages[pages.length - 2].__route__ == 'packageA/publicCustomer/index') wx.redirectTo({
+                    url: '/packageA/publicCustomer/detail?id=' + res.data.sa_customersid,
+                })
+            }, 300)
+        })
+    },
+})

+ 4 - 0
packageA/publicCustomer/addAndEditor.json

@@ -0,0 +1,4 @@
+{
+    "usingComponents": {},
+    "navigationBarTitleText": "编辑公海客户"
+}

+ 23 - 0
packageA/publicCustomer/addAndEditor.scss

@@ -0,0 +1,23 @@
+.new-footer {
+    display: flex;
+    align-items: center;
+    justify-content: flex-end;
+    position: fixed;
+    width: 100vw;
+    height: 130rpx;
+    background: #FFFFFF;
+    box-shadow: 0px -4rpx 16rpx 2rpx rgba(150, 157, 165, 0.16);
+    bottom: 0;
+
+    .new-submit {
+        width: 156rpx;
+        height: 90rpx;
+        background: #3874F6;
+        border-radius: 8rpx;
+        font-size: 28rpx;
+        font-family: PingFang SC-Bold, PingFang SC;
+        font-weight: bold;
+        color: #FFFFFF;
+        margin-right: 30rpx;
+    }
+}

+ 6 - 0
packageA/publicCustomer/addAndEditor.wxml

@@ -0,0 +1,6 @@
+<Yl_Headline title='基本信息' type='switch' switchLabel='仅显示必填信息' switch='{{showAll}}' bind:callBack='onChange' />
+<Yl_field id='Form' form='{{form}}' showAll='{{!showAll}}' bind:onConfirm='onConfirm' />
+<view style="height: 100rpx;" />
+<view class="new-footer">
+    <van-button custom-class='new-submit' disabled='{{disabled}}' bindclick='submit'>提交</van-button>
+</view>

+ 1 - 1
packageA/publicCustomer/detail.js

@@ -88,7 +88,7 @@ Page({
             'content.total': page.data.content.total - 1
         })
         wx.redirectTo({
-            url: '/packageA/setclient/delete?id=' + this.data.detail.sa_customersid,
+            url: '/packageA/setclient/detail?id=' + this.data.detail.sa_customersid,
         })
     },
     //详情按钮回调

+ 5 - 4
packageA/publicCustomer/index.js

@@ -55,7 +55,7 @@ Page({
             content.where.enddate = data.enddate;
         }
         _Http.basic({
-            "id": 20221014164702,
+            "id": 20221011133602,
             content
         }).then(res => {
             console.log("公海客户列表", res)
@@ -122,6 +122,7 @@ Page({
         _Http.basic({
             "id": 20221206195102,
             "content": {
+                nocache: true,
                 "pageNumber": 1,
                 "pageSize": 20,
                 "where": {
@@ -205,11 +206,11 @@ Page({
                 });
                 break;
         };
-        
+
     },
-    addOpponent() {
+    addPublicCustomer() {
         wx.navigateTo({
-            url: './add'
+            url: './addAndEditor'
         })
     },
     onShareAppMessage() {

+ 1 - 1
packageA/publicCustomer/index.wxml

@@ -24,4 +24,4 @@
     </view>
 </Yl_filtrate>
 <!-- 浮动按钮 -->
-<Yl_FloatingButton bindtap="addOpponent" />
+<Yl_FloatingButton bindtap="addPublicCustomer" />

+ 104 - 0
packageA/publicCustomer/pond/index.js

@@ -0,0 +1,104 @@
+const _Http = getApp().globalData.http;
+Page({
+    data: {
+        item: null, //自定义表单组件使用
+        result: [], //选中结果
+        idName: 'sa_customerpoolid', //选择ID
+        list: [],
+        radio: true
+    },
+    onLoad(options) {
+        if (options.item) {
+            let item = JSON.parse(options.item);
+            this.setData({
+                item,
+                params: item.params,
+                result: item.value.length ? item.value[1] : []
+            })
+        };
+        this.getList();
+    },
+    /* 提交 */
+    submit() {
+        let pages = getCurrentPages(), //页面
+            item = this.data.item, //表单
+            result = this.data.result, //选中结果
+            list = this.data.result.map(value => this.data.list.find(v => v[this.data.idName] == value)); //选中列表
+        try {
+            if (item) { //判断是否表单调用,表单的话吧数据交还给表单
+                let page = pages[pages.length - 2].selectComponent(item.model || "#Form");
+                item.value = this.data.radio ? [list[0].poolname, result] : [list.map(v => v.poolname), result];
+                page.handleRoute(item);
+            } else if (this.data.params.model) {
+                //判断是否上级页面中的组件调用
+                let page = pages[pages.length - 2].selectComponent(this.data.params.model);
+                page.handleSelectContacts(result, list)
+            } else {
+                //上级页面调用
+                pages[pages.length - 2].handleSelectContacts(result, list)
+            }
+        } catch (e) {
+            console.log(e)
+            wx.showToast({
+                title: '操作失败',
+                icon: "none"
+            })
+        }
+    },
+    /* 开始搜索 */
+    onSearch({
+        detail
+    }) {
+        if (this.data.params.content.where.condition == detail) return;
+        this.setData({
+            'params.content.where.condition': detail
+        });
+        this.getList(true)
+    },
+    onClear() {
+        this.setData({
+            'params.content.where.condition': ""
+        });
+        this.getList(true)
+    },
+    /* 选中 */
+    onChange(e) {
+        const id = e.currentTarget.dataset.item[this.data.idName] + "";
+        if (!id) return;
+        let result = this.data.result;
+        if (this.data.radio) {
+            result = [id]
+        } else {
+            if (result.some(v => v == id)) {
+                result = result.filter(v => v != id)
+            } else {
+                result.push(id)
+            }
+        }
+        this.setData({
+            result
+        })
+        if (this.data.radio) this.submit();
+    },
+    //获取列表
+    getList(init = false) {
+        let params = this.data.params;
+        if (init) params.content.pageNumber = 1;
+        if (params.content.pageNumber > params.content.pageTotal) return;
+        _Http.basic(params).then(res => {
+            console.log("联系人", res)
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            });
+            this.setData({
+                list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
+                "params.content.pageNumber": res.pageNumber + 1,
+                "params.content.pageTotal": res.pageTotal,
+            })
+        })
+    },
+    onReachBottom() {
+        this.getList();
+    }
+})

+ 4 - 0
packageA/publicCustomer/pond/index.json

@@ -0,0 +1,4 @@
+{
+    "usingComponents": {},
+    "navigationBarTitleText": "选择联系人"
+}

+ 16 - 0
packageA/publicCustomer/pond/index.scss

@@ -0,0 +1,16 @@
+.box {
+    width: 100vw;
+    background-color: #fff;
+    box-sizing: border-box;
+
+    .item {
+        display: flex;
+        width: 100%;
+        padding-left: 30rpx;
+        box-sizing: border-box;
+        width: 100%;
+        height: 100rpx;
+        line-height: 100rpx;
+        border-bottom: 1rpx solid #ddd;
+    }
+}

+ 10 - 0
packageA/publicCustomer/pond/index.wxml

@@ -0,0 +1,10 @@
+<van-search value="{{ value }}" shape="round" background="#fff" placeholder="搜索姓名、手机号" bind:search='onSearch' bind:clear='onClear' />
+<view style="height: 20rpx;" />
+<view class="box">
+    <navigator url="#" class="item" wx:for="{{list}}" wx:key="index" data-item="{{item}}" bindtap="onChange">
+        {{item.poolname}}
+    </navigator>
+</view>
+
+<My_empty wx:if="{{list.length==0}}" />
+<view style="height: 130rpx;" />