Browse Source

地址管理

xiaohaizhao 6 months ago
parent
commit
a7bd2efa53

+ 187 - 0
prsx/hospital/address/add/index.js

@@ -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
+        })
+    }
+})

+ 4 - 0
prsx/hospital/address/add/index.json

@@ -0,0 +1,4 @@
+{
+    "usingComponents": {},
+    "navigationBarTitleText": "填写地址"
+}

+ 71 - 0
prsx/hospital/address/add/index.scss

@@ -0,0 +1,71 @@
+.types {
+    background-color: #fff;
+    padding: 20rpx 30rpx;
+    box-sizing: border-box;
+    display: flex;
+
+    .title {
+        width: 200rpx;
+        font-size: 28rpx;
+        color: #666;
+        flex-shrink: 0;
+    }
+
+    .tags {
+        display: flex;
+        flex-wrap: wrap;
+
+        .tag {
+            padding: 8rpx 15rpx;
+            border-radius: 16rpx;
+            border: 1rpx solid #ddd;
+            font-size: 26rpx;
+            margin-right: 15rpx;
+            margin-bottom: 15rpx;
+            color: #999;
+        }
+
+        .active {
+            color: var(--assist);
+            border-color: var(--assist) ;
+        }
+    }
+}
+
+.radio-box {
+    display: flex;
+    padding-left: 20rpx;
+    padding-top: 10rpx;
+    height: 60rpx;
+    background-color: #fff;
+
+    .radio {
+        font-size: 26rpx;
+        font-family: PingFang SC-Regular, PingFang SC;
+        color: #666666;
+    }
+}
+
+.footer {
+    display: flex;
+    align-items: center;
+    justify-content: flex-end;
+    position: fixed;
+    width: 750rpx;
+    height: 130rpx;
+    background: #FFFFFF;
+    box-shadow: 0px -4rpx 16rpx 2rpx rgba(150, 157, 165, 0.16);
+    bottom: 0;
+
+    .but {
+        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;
+    }
+}

+ 15 - 0
prsx/hospital/address/add/index.wxml

@@ -0,0 +1,15 @@
+<Yl_field id='Form' form="{{form}}" bind:onConfirm='onConfirm' />
+<view class="types">
+    <view class="title">{{language['地址类型']||'地址类型'}}</view>
+
+    <view class="tags">
+        <view class="tag {{pre.query(tags,item.tag)?'active':''}}" wx:for="{{tagList}}" wx:key="sys_systemtagdetailid" data-item="{{item}}" bindtap="selectTag">{{item.tag}}</view>
+    </view>
+</view>
+<view class="radio-box">
+    <van-checkbox icon-size='14' label-class='radio' value="{{ content.isdefault == 1 }}" bind:change="checkboxChange">{{language['设置为默认地址']||'设置为默认地址'}}</van-checkbox>
+</view>
+<view class="footer">
+    <van-button custom-class='but' disabled='{{disabled}}' bindtap="submit">{{language['保存']||'保存'}}</van-button>
+</view>
+<wxs src="../../../../utils/wxmlQueryPer.wxs" module="pre" />

+ 105 - 0
prsx/hospital/address/index.js

@@ -0,0 +1,105 @@
+const _Http = getApp().globalData.http;
+Component({
+    properties: {
+        disabled: {
+            type: Boolean
+        },
+        type: {
+            type: String,
+            value: "客户"
+        }
+    },
+    options: {
+        addGlobalClass: true
+    },
+    lifetimes: {
+        attached: function () {
+            getApp().globalData.Language.getLanguagePackage(this)
+        }
+    },
+    data: {
+        sys_enterpriseid: 0,
+        list: [],
+        content: {
+            "nacache": true,
+            "pageNumber": 1,
+            "pageSize": 15,
+            "pageTotal": 1,
+            "total": null,
+            "where": {
+                "condition": "",
+                "workaddress": 1
+            }
+        }
+    },
+    methods: {
+        changeTotal() {
+            this.setData({
+                "content.total": this.data.content.total - 1
+            })
+        },
+        /* 获取地址列表 */
+        getList(id, init) {
+            let content = this.data.content;
+            content.sys_enterpriseid = id || this.data.sys_enterpriseid;
+            if (init) {
+                content.pageNumber = 1
+                content.pageTotal = 1
+            }
+            _Http.basic({
+                "id": "20221022165503",
+                content
+            }).then(res => {
+                console.log("地址列表", res)
+                if (res.code != '1') return wx.showToast({
+                    title: res.data,
+                    icon: "none"
+                })
+                this.setData({
+                    list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
+                    "content.pageNumber": res.pageNumber + 1,
+                    "content.pageSize": res.pageSize,
+                    "content.pageTotal": res.pageTotal,
+                    "content.total": res.total,
+                    sys_enterpriseid: content.sys_enterpriseid
+                })
+                // this.getTags();
+                setTimeout(() => {
+                    this.selectComponent("#List").initRadio();
+                }, 300)
+
+            })
+        },
+        toSearch() {
+            if (this.data.showSearch && this.data.content.where.condition) {
+                this.data.content.where.condition = '';
+                this.getList("", true);
+            } else if (this.data.condition) {
+                this.data.content.where.condition = this.data.condition;
+                this.setData({
+                    condition: this.data.condition
+                })
+                this.getList("", true);
+            }
+            this.setData({
+                showSearch: !this.data.showSearch
+            })
+            setTimeout(() => {
+                this.setData({
+                    focus: this.data.showSearch
+                })
+            }, 300)
+        },
+        onChange({
+            detail
+        }) {
+            this.data.condition = detail;
+        },
+        onSearch({
+            detail
+        }) {
+            this.data.content.where.condition = detail;
+            this.getList("", true)
+        },
+    }
+})

+ 6 - 0
prsx/hospital/address/index.json

@@ -0,0 +1,6 @@
+{
+    "component": true,
+    "usingComponents": {
+        "List": "./list/index"
+    }
+}

+ 40 - 0
prsx/hospital/address/index.scss

@@ -0,0 +1,40 @@
+.head {
+	display: flex;
+	align-items: center;
+	width: 100vw;
+	height: 120rpx;
+	padding: 0 20rpx 0 30rpx;
+	box-sizing: border-box;
+
+	.count {
+		font-size: 28rpx;
+		font-family: PingFang SC-Regular, PingFang SC;
+		color: #333333;
+	}
+
+	.expand {
+		flex: 1;
+		display: flex;
+		justify-content: flex-end;
+		align-items: center;
+
+		.but {
+			flex-shrink: 0;
+			display: flex;
+			align-items: center;
+			justify-content: center;
+			width: 80rpx;
+			height: 80rpx;
+			background: #FFFFFF;
+			border-radius: 8rpx;
+			border: 2rpx solid #CCCCCC;
+			margin-left: 20rpx;
+			color: #666666;
+		}
+	}
+}
+
+.custom-class {
+	--search-background-color: #fff !important;
+	padding-right: 10rpx !important;
+}

+ 16 - 0
prsx/hospital/address/index.wxml

@@ -0,0 +1,16 @@
+<view class="head">
+    <view class="count">
+        总共{{content.total}}个
+    </view>
+    <view class="expand">
+        <van-search wx:if="{{showSearch}}" custom-class='custom-class' focus='{{focus}}' value="{{ condition }}" shape="round" bind:change='onChange' bind:search='onSearch' bind:clear='onSearch' placeholder="搜索关键词" background='#F4F5F7' />
+        <navigator url="#" class="but" bindtap="toSearch">
+            <van-icon name="search" />
+        </navigator>
+        <navigator wx:if="{{disabled}}" url="/prsx/hospital/address/add/index?sys_enterpriseid={{sys_enterpriseid}}&type={{type}}" class="but">
+            <van-icon name="plus" />
+        </navigator>
+    </view>
+</view>
+
+<List id='List' list='{{list}}' disabled='{{disabled}}' type='{{type}}' bindchangeTotal='changeTotal' />

+ 140 - 0
prsx/hospital/address/list/index.js

@@ -0,0 +1,140 @@
+const _Http = getApp().globalData.http;
+Component({
+    options: {
+        addGlobalClass: true
+    },
+    properties: {
+        list: {
+            type: Array
+        },
+        changeTotal: {
+            type: Function
+        },
+        disabled: {
+            type: Boolean
+        },
+        type: {
+            type: String
+        }
+    },
+    data: {
+        radio: 0, //默认
+    },
+    lifetimes: {
+        attached: function () {
+            getApp().globalData.Language.getLanguagePackage(this)
+        }
+    },
+    methods: {
+        // 修改默认
+        radioChange({
+            detail
+        }) {
+            let list = this.data.list,
+                data = list.find(v => v.contactsid == detail)
+            _Http.basic({
+                "id": "20221018144702",
+                "content": {
+                    "contactsid": data.contactsid,
+                    "sys_enterpriseid": data.sys_enterpriseid
+                }
+            }, false).then(res => {
+                if (res.code != '1') return wx.showToast({
+                    title: res.data,
+                    icon: "none"
+                });
+
+                getCurrentPages().forEach(v => {
+                    //更新列表
+                    if (["prsx/hospital/detail"].includes(v.__route__)) {
+                        let page = v.selectComponent("#Address").selectComponent("#List");
+                        const lists = page.data.list.map(value => {
+                            value.isdefault = value.contactsid == data.contactsid ? 1 : 0
+                            return value
+                        });
+                        page.setData({
+                            list: lists
+                        })
+                        setTimeout(() => {
+                            page.initRadio();
+                        }, 200)
+                    };
+                })
+            })
+        }, //处理操作
+        handleItem(e) {
+            const {
+                name,
+                item
+            } = e.target.dataset,
+                that = this;
+            if (!name) return;
+            switch (name) {
+                case 'call':
+                    wx.makePhoneCall({
+                        phoneNumber: item.phonenumber,
+                    })
+                    break;
+                case 'copy':
+                    let str = `${getApp().globalData.Language.getMapText('联系人')}:${item.name}\n${getApp().globalData.Language.getMapText('手机号码')}:${item.phonenumber}\n${getApp().globalData.Language.getMapText('所在地区')}:${item.province+item.city+item.county}\n${getApp().globalData.Language.getMapText('详细地址')}:${item.province+item.city+item.county+item.address}`
+                    wx.setClipboardData({
+                        data: str,
+                    })
+                    break;
+                case 'edit':
+                    wx.navigateTo({
+                        url: '/prsx/hospital/address/add/index?data=' + JSON.stringify(item) + '&type=' + this.data.type,
+                    })
+                    break;
+                case 'delete':
+                    wx.showModal({
+                        title: getApp().globalData.Language.getMapText('提示'),
+                        content: getApp().globalData.Language.getMapText('是否确认删除') + `"${item.name}"`,
+                        cancelText: getApp().globalData.Language.getMapText('取消'),
+                        confirmText: getApp().globalData.Language.getMapText('确定'),
+                        complete: (res) => {
+                            if (res.confirm) {
+                                _Http.basic({
+                                    "id": "20221018145502",
+                                    "content": {
+                                        "contactsid": item.contactsid,
+                                        "sys_enterpriseid": item.sys_enterpriseid
+                                    }
+                                }).then(res => {
+                                    console.log("删除地址", res)
+                                    if (res.code != '1') return wx.showToast({
+                                        title: res.data,
+                                        icon: "none"
+                                    });
+                                    wx.showToast({
+                                        title: getApp().globalData.Language.getMapText('删除成功') + `!`,
+                                        icon: "none"
+                                    });
+                                    getCurrentPages().forEach(v => {
+                                        if (v.__route__ == "packageA/setclient/detail" || v.__route__ == "packageA/opponent/detail" || v.__route__ == "packageA/publicCustomer/detail") {
+                                            let model = v.selectComponent("#Address");
+                                            model.setData({
+                                                list: model.data.list.filter(value => value.contactsid != item.contactsid)
+                                            });
+                                            model.changeTotal();
+                                        } else if (v.__route__ == "packageA/setclient/modules/address/search/index") {
+                                            v.setData({
+                                                list: v.data.list.filter(value => value.contactsid != item.contactsid)
+                                            });
+                                        }
+                                    })
+                                })
+                            }
+                        }
+                    })
+                    break;
+            }
+        },
+        initRadio() {
+            let data = this.data.list.find(v => v.isdefault == 1);
+            this.setData({
+                radio: data ? data.contactsid : 0
+            })
+        },
+    }
+})

+ 7 - 0
prsx/hospital/address/list/index.json

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

+ 80 - 0
prsx/hospital/address/list/index.scss

@@ -0,0 +1,80 @@
+.add-box {
+    width: 100vw;
+    padding-left: 30rpx;
+    padding-top: 20rpx;
+    box-sizing: border-box;
+    background-color: #fff;
+    margin-bottom: 20rpx;
+
+    .detail {
+        width: 100%;
+        border-bottom: 1px solid #DDDDDD;
+        padding-bottom: 20rpx;
+
+        .label {
+            line-height: 42rpx;
+            font-size: 30rpx;
+            font-family: PingFang SC-Regular, PingFang SC;
+            color: #333333;
+            padding-right: 30rpx;
+        }
+
+        .tags {
+            display: flex;
+            font-size: 24rpx;
+            flex-wrap: wrap;
+
+            .tag {
+                flex-shrink: 0;
+                margin-top: 6rpx;
+                background: #FAAB16;
+                color: #ffffff;
+                margin-right: 10rpx;
+                display: flex;
+                align-items: center;
+                height: 40rpx;
+                font-size: 20rpx;
+                padding: 0 10rpx;
+                border-radius: 20rpx;
+                font-family: PingFang SC-Regular, PingFang SC;
+            }
+        }
+
+        .detail-add {
+            font-size: 24rpx;
+            font-family: PingFang SC-Regular, PingFang SC;
+            color: #333333;
+            margin-top: 20rpx;
+        }
+    }
+
+    .editor {
+        display: flex;
+        justify-content: space-between;
+        align-items: center;
+        width: 100%;
+        height: 80rpx;
+
+        .radio {
+            font-size: 24rpx;
+            font-family: PingFang SC-Regular, PingFang SC;
+            color: #666666;
+            margin-left: -10rpx;
+        }
+
+        .icon-but {
+            padding-right: 30rpx;
+
+            navigator {
+                display: inline-block;
+                width: 60rpx;
+                height: 60rpx;
+                line-height: 60rpx;
+                text-align: center;
+                margin-left: 30rpx;
+                width: 32px;
+                color: #707070;
+            }
+        }
+    }
+}

+ 25 - 0
prsx/hospital/address/list/index.wxml

@@ -0,0 +1,25 @@
+<van-radio-group value="{{ radio }}" bind:change="radioChange">
+    <view class="add-box" wx:for="{{list}}" wx:key="changeuserid">
+        <view class="detail">
+            <view class="label" style="padding-left: 42rpx;">
+                {{item.name}} {{item.phonenumber}}
+            </view>
+            <view class="label">
+                <text class="iconfont icon-a-wodemendianxinxidizhi" style="color: #3874F6;" /> {{item.province + item.city + item.county + item.address}}
+            </view>
+            <view class="tags">
+                <view class="tag" wx:for="{{item.tag}}" wx:key="index">{{language[item]||item}}</view>
+            </view>
+        </view>
+        <view class="editor">
+            <van-radio icon-size='14' label-class='radio' name="{{item.contactsid}}">{{language['默认收货地址']||'默认收货地址'}}</van-radio>
+            <view class="icon-but" bindtap="handleItem">
+                <navigator url="#" data-item="{{item}}" data-name="call" class="iconfont icon-a-wodemendianxinxidianhua" />
+                <navigator url="#" data-item="{{item}}" data-name="copy" class="iconfont icon-a-yingxiaowuliaofuzhi" />
+                <navigator url="#" data-item="{{item}}" wx:if="{{disabled}}" data-name="edit" class="iconfont icon-bianji" />
+                <navigator url="#" data-item="{{item}}" wx:if="{{disabled}}" data-name="delete" class="iconfont icon-shanchu" />
+            </view>
+        </view>
+    </view>
+</van-radio-group>
+<My_empty wx:if="{{list.length==0}}" />

+ 5 - 1
prsx/hospital/detail.js

@@ -14,6 +14,10 @@ Page({
         let tabsList = [{
             label: "详细信息",
             icon: "icon-tabxiangxixinxi1"
+        }, {
+            label: "地址管理",
+            icon: "icon-tabdizhi",
+            model: "#Address"
         }];
         this.setData({
             sa_customersid: options.id,
@@ -233,7 +237,7 @@ Page({
                 })
                 break;
             case "跟进":
-                this.selectComponent("#Trace").insetr();
+                that.selectComponent("#Trace").toAdd()
                 break;
             default:
                 console.log(detail)

+ 2 - 1
prsx/hospital/detail.json

@@ -1,7 +1,8 @@
 {
     "usingComponents": {
         "van-dialog": "@vant/weapp/dialog/index",
-        "Trace": "/prsx/trace/index"
+        "Trace": "/prsx/trace/index",
+        "Address": "/prsx/hospital/address/index"
     },
     "navigationBarTitleText": "医院详情"
 }

+ 1 - 0
prsx/hospital/detail.wxml

@@ -18,6 +18,7 @@
 <Yl_FunTabs list='{{tabsList}}' active='{{tabsActive}}' bind:onChenge="tabsChange">
     <Preview slot='详细信息' list1='{{list1}}' list2='{{list2}}' />
     <Trace resource='医院管理' slot='跟进动态' id='Trace' ownertable='sa_customers' ownerid='{{sa_customersid}}' disabled="{{detail.status != '已终止'}}" ownerid1='{{detail.sys_enterpriseid}}' />
+    <Address slot='地址管理' id='Address' disabled="{{(per.query(appAuth.options,'address')||isAdmin||isLeader)&& detail.status != '已终止'}}" />
     <Record slot="操作" id="Record" ownertable='sa_customers' ownerid='{{sa_customersid}}' />
     <Files slot="附件" id="Files" ownertable='sa_customers' ownerid='{{sa_customersid}}' disabled="{{detail.status != '已终止'}}" />
 </Yl_FunTabs>

+ 1 - 0
prsx/hospital/insert.js

@@ -172,6 +172,7 @@ Page({
                 let item = form.find(v => v.laber == '负责人');
                 if (item) item.disabled = true;
                 hrid = wx.getStorageSync('userMsg').hrid;
+                // item.value = [wx.getStorageSync('userMsg').name, [wx.getStorageSync('userMsg').userid]]
             }
         }
 

+ 1 - 1
prsx/hospital/insert.wxml

@@ -27,7 +27,7 @@
 		<view class="exp">开发状态:<text style="color: {{sColors[item.status]}}" F>{{item.status||" --"}}</text></view>
 		<view class="exp">成交状态:<text style="color: {{sColors[item.tradingstatus]}}">{{item.tradingstatus||" --"}}</text></view>
 		<view class="exp" style="color: {{item.chars['name'] ? 'red' : '#666666'}}">负责人:{{item.leader[0].name||" --"}}</view>
-		<view class="exp" style="color: {{item.chars['areaname'] ? 'red' : '#666666'}}">营销区域:{{item.leader[0].areaname||" --"}}</view>
+		<view class="exp" style="color: {{item.chars['areaname'] ? 'red' : '#666666'}}">营销区域:{{item.areaname||" --"}}</view>
 		<block wx:if="{{item.systemapp=='回收站'}}">
 			<icon style="padding-left:10rpx;" type="warn" size="11" color='red' />
 			<text style="color: red;margin-left: 2rpx;">{{language['当前重复客户归属回收站,请联系管理处理!']||'当前重复客户归属回收站,请联系管理处理!'}}</text>