#
whycq
2023-08-28 fe1ea4c1ed20b5375020b0400bee713f20a15c5c
#
2个文件已添加
460 ■■■■■ 已修改文件
pages/business/saleManage/addSaleManage.vue 261 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/business/saleManage/saleManage.vue 199 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/business/saleManage/addSaleManage.vue
New file
@@ -0,0 +1,261 @@
<template>
    <view>
        <view class="container">
            <uni-forms ref="baseForm" :modelValue="baseFormData">
                <uni-forms-item label="项目名称" required name="name">
                    <uni-easyinput v-model="baseFormData.name" placeholder="请输入项目名称" />
                </uni-forms-item>
                <uni-forms-item label="所属公司" required name="company">
                    <view @click="autoLoad('company','')">
                        <uni-combox :candidates="companies" placeholder="请选所属公司"
                        v-model="baseFormData.company" @input="autoLoad('company',baseFormData.company)"></uni-combox>
                    </view>
                </uni-forms-item>
                <uni-forms-item label="省市区" name="citysData">
                    <uni-data-picker @change="areaChange" placeholder="请选择省市区" popup-title="请选择所在地区" :localdata="citysData" v-model="baseFormData.pcd">
                    </uni-data-picker>
                </uni-forms-item>
                <uni-forms-item label="负责人" name="director">
                    <view @click="autoLoad('user','')">
                        <uni-combox :candidates="directors" placeholder="请选择负责人"
                        v-model="baseFormData.director" @input="autoLoad('user',baseFormData.director)"></uni-combox>
                    </view>
                </uni-forms-item>
                <uni-forms-item label="甲方单位" name="cstmr">
                    <view @click="autoLoad('cstmr','')">
                        <uni-combox :candidates="cstmrs" placeholder="请选择甲方单位"
                        v-model="baseFormData.cstmr" @input="autoLoad('user',baseFormData.cstmr)"></uni-combox>
                    </view>
                </uni-forms-item>
                <uni-forms-item label="项目总金额" name="money">
                    <uni-easyinput v-model="baseFormData.money" placeholder="请输入项目总金额" />
                </uni-forms-item>
                <uni-forms-item label="项目地址" name="addr">
                    <uni-easyinput v-model="baseFormData.addr" placeholder="请输入项目地址" />
                </uni-forms-item>
                <uni-forms-item label="备注" name="remarks">
                    <uni-easyinput type="textarea" v-model="baseFormData.remarks" placeholder="请输入备注" />
                </uni-forms-item>
            </uni-forms>
            <button type="primary" @click="addCstmr()">添加</button>
        </view>
    </view>
</template>
<script>
    import test from '../../../static/js/citys-data.js'
    export default {
        data() {
            return {
                cstmrTypes: [],
                cstmrType: '',
                companies: [],
                company: '',
                directors: [],
                director: '',
                cstmrs: [],
                cstmr: '',
                cstmrTypeList: [],
                directorList: [],
                baseFormData: {
                    citysData: [],
                    cstmrType: '',
                    company: '',
                    director: '',
                    rela: '',
                    remarks: '',
                    cstmr: ''
                },
                rules: {
                    name: {
                        rules: [{
                            required: true,
                            errorMessage: '请填写客户名称',
                        }]
                    },
                    rela: {
                        rules: [{
                            required: false,
                            errorMessage: '请填写客户名称',
                        }]
                    },
                    cstmrType: {
                        rules: [{
                            required: true,
                            errorMessage: '请选择客户类别',
                        }]
                    },
                    company: {
                        rules: [{
                            required: true,
                            errorMessage: '请选所属公司',
                        }]
                    },
                    type: {
                        rules: [{
                            required: true,
                            errorMessage: '请选择区分',
                        }]
                    },
                    tel: {
                        rules: [{
                            required: true,
                            errorMessage: '请输入电话号码',
                        }]
                    },
                    contacts: {
                        rules: [{
                            required: true,
                            errorMessage: '请输入客户联系人',
                        }]
                    },
                    remarks: {
                        rules: [{
                            required: false,
                            errorMessage: '请输入客户联系人',
                        }]
                    }
                },
                // 单选数据源
                type$: [{
                    text: '内销',
                    value: 1
                }, {
                    text: '外销',
                    value: 2
                }],
                citysData: [],
                citysDataTemp: ''
            }
        },
        onReady() {
                // 需要在onReady中设置规则
                this.$refs.baseForm.setRules(this.rules)
        },
        onShow() {
            // 获取省市区
            this.citysData = test.citysData
            this.autoLoad('company','')
            this.autoLoad('user','')
        },
        methods: {
            bindPickerChange: function(e) {
                this.cstmrTypeIndex = e.detail.value
                this.baseFormData.cstmrType = this.cstmrTypes[e.detail.value].id
            },
            areaChange(e) {
                this.citysDataTemp = e.detail.value[0].value + ',' + e.detail.value[1].value + ',' + e.detail.value[2].value
            },
            autoLoad(type,condition) {
                let that = this
                that.cstmrTypes = []
                that.companies = []
                that.directors = []
                that.directorList = []
                that.cstmrs = []
                var a = that.baseUrl + '/' + type + 'Query/auth'
                uni.request({
                    url: that.baseUrl + '/' + type + 'Query' +'/auth',
                    header:{'token':uni.getStorageSync('token')},
                    data: {condition:condition},
                    method: 'GET',
                    success(result) {
                        var res = result.data
                        if (res.code === 200) {
                            var element;
                            if (type == 'cstmrType') {
                                for(element of res.data) {
                                    that.cstmrTypes.push(element.value)
                                    that.cstmrTypeList.push(element)
                                }
                                return
                            }
                            if (type == 'user') {
                                for(element of res.data) {
                                    that.directors.push(element.value)
                                    that.directorList.push(element)
                                }
                                return
                            }
                            if (type == 'company') {
                                for (element of res.data) {
                                    that.companies.push(element.name)
                                }
                                return
                            }
                            if (type == 'cstmr') {
                                for (element of res.data) {
                                    that.cstmrs.push(element.value)
                                }
                                return
                            }
                        }
                    }
                })
            },
            // 添加用户
            addCstmr() {
                let that = this
                var element;
                for (element of that.directorList) {
                    if(element.value == that.baseFormData.director) {
                        that.baseFormData.director = element.id
                    }
                }
                for (element of that.cstmrTypeList) {
                    if(element.value == that.baseFormData.cstmrType) {
                        that.baseFormData.cstmrType = element.id
                    }
                }
                this.$refs.baseForm.validate().then(res=>{
                    if (res.rela == undefined) {
                        res.rela = ''
                    }
                    if(res.remarks == undefined) {
                        res.remarks = ''
                    }
                    res.pcd = this.citysDataTemp
                    uni.request({
                        url: that.baseUrl + '/cstmr/add/auth',
                        header:{
                            'token':uni.getStorageSync('token'),
                            'content-type':'application/x-www-form-urlencoded',
                            },
                        data: res,
                        method: 'POST',
                        success(result) {
                            var res = result.data
                            if (res.code === 200) {
                                uni.navigateBack()
                            } else if (res.code === 403) {
                                uni.showToast({title: res.msg, icon: "none", position: 'top'})
                                setTimeout(() => {
                                    uni.reLaunch({
                                        url: '../../login/login'
                                    });
                                }, 1000);
                            } else {
                                uni.showToast({title: res.msg, icon: "none",position: 'top'})
                            }
                        }
                    })
                }).catch(err =>{
                })
            }
        }
    }
</script>
<style>
    .container {
        min-height: 50rpx;
        padding: 15px;
        background-color: #fff;
        /* background-color: aqua; */
    }
</style>
pages/business/saleManage/saleManage.vue
New file
@@ -0,0 +1,199 @@
<template>
    <view>
        <!-- 搜索框 -->
        <view class="search-bg">
            <uni-search-bar placeholder="客户代号/名称" bgColor="#f4f4f4"  @confirm="search" />
        </view>
        <view>
            <!-- 客户列表 -->
            <view class="c-list" @click="getDetails(item.id)" v-for="(item,index) in csmtrList" :key="index">
                <view class="titles">
                    <y-title :title="item.name"></y-title>
                </view>
                <view style="display: grid;grid-template-columns: 1fr 3fr;">
                    <view class="list-item1">客户代号</view><view class="list-item2">{{item.uuid}}</view>
                    <view class="list-item1">详细地址</view><view class="list-item2">{{item.addr}}</view>
                    <view class="list-item1">电话</view><view class="list-item2">{{item.tel}}</view>
                    <view class="list-item1">备注</view><view class="list-item2">{{item.remarks  ? item.remarks : '--'}}</view>
                    <view class="list-item1">客户类别</view><view class="list-item2">{{item.cstmrType$}}</view>
                    <view class="list-item1">创建人</view><view class="list-item2">{{item.createBy$}}</view>
                    <view class="list-item1">创建时间</view><view class="list-item2">{{item.createTime$}}</view>
                </view>
            </view>
        </view>
        <uni-load-more :status="status" :icon-size="16" :content-text="contentText" />
    </view>
</template>
<script>
    export default {
        data() {
            return {
                csmtrList: [],
                last_id: '',
                reload: false,
                status: 'more',
                curr:2,
                contentText: {
                    contentdown: '上拉加载更多',
                    contentrefresh: '加载中',
                    contentnomore: '没有更多'
                },
            }
        },
        // 新建按钮事件
        onNavigationBarButtonTap(e) {
            uni.navigateTo({
                url:'/pages/business/saleManage/addSaleManage',
            })
        },
        onLoad() {
        },
        onShow() {
            setTimeout(()=> {
                this.getCsmtr1()
            },500)
        },
        onReachBottom() {
            this.status = 'more';
            this.getCsmtr()
        },
        methods: {
            getCsmtr1(e) {
                let that = this
                that.csmtrList = []
                uni.request({
                    url: that.baseUrl + '/cstmr/page/auth',
                    header: {'token' : uni.getStorageSync('token'),},
                    data: {curr:1,limit:4},
                    method:'GET',
                    success(result) {
                        if (result.statusCode ===  404) {
                            uni.showToast({title: '请重新登录', icon: "none", position: 'top'})
                            return
                        }
                        var res = result.data
                        if (res.code === 200) {
                            let list = res.data.records
                            that.csmtrList = that.reload ? list : that.csmtrList.concat(list);
                            if (res.data.records.length == 0) {
                                that.status = 'noMore'
                            }
                        } else if (res.code === 403) {
                            uni.showToast({title: res.msg, icon: "none", position: 'top'})
                            setTimeout(() => {
                                uni.reLaunch({
                                    url: '../../login/login'
                                });
                            }, 1000);
                        } else {
                            uni.showToast({title: res.msg, icon: "none",position: 'top'})
                        }
                    },
                    fail(result) {
                        uni.showToast({title: '请求失败'})
                        setTimeout(() => {
                            uni.reLaunch({
                                url: '../../login/login'
                            });
                        }, 1000);
                    },
                })
            },
            getCsmtr() {
                let that = this
                uni.request({
                    url: that.baseUrl + '/cstmr/page/auth',
                    header: {'token' : uni.getStorageSync('token'),},
                    data: {curr:that.curr,limit:4},
                    method:'GET',
                    success(result) {
                        if (result.statusCode ===  404) {
                            uni.showToast({title: '请重新登录', icon: "none", position: 'top'})
                            return
                        }
                        var res = result.data
                        if (res.code === 200) {
                            let list = res.data.records
                            that.csmtrList = that.reload ? list : that.csmtrList.concat(list);
                            that.curr = that.curr + 1
                            if (res.data.records.length == 0) {
                                that.status = 'noMore'
                            }
                        } else if (res.code === 403) {
                            uni.showToast({title: res.msg, icon: "none", position: 'top'})
                            setTimeout(() => {
                                uni.reLaunch({
                                    url: '../../login/login'
                                });
                            }, 1000);
                        } else {
                            uni.showToast({title: res.msg, icon: "none",position: 'top'})
                        }
                    },
                    fail(result) {
                        uni.showToast({title: '请求失败'})
                        setTimeout(() => {
                            uni.reLaunch({
                                url: '../../login/login'
                            });
                        }, 1000);
                    },
                })
            },
            getDetails(id) {
                uni.navigateTo({
                    url: '/pages/business/cstmr/cstmrDetails?id=' + id
                })
            },
            // ---
            search() {
            }
        }
    }
</script>
<style>
    .c-list {
        width: 96%;
        min-height: 100rpx;
        background-color: #fff;
        border-radius: 10rpx;
        margin: 20rpx 2% 0 2%;
        display: flex;
        flex-direction: column;
        font-size: 24rpx;
    }
    /* 父view 换 scroll-view */
    .c-list:last-child {
        margin-bottom: 20px;
    }
    .list-item1 {
        height: 45rpx;
        line-height: 45rpx;
        color: #909399;
        text-indent: 30rpx;
    }
    .list-item2 {
        height: 45rpx;
        line-height: 45rpx;
        color: black;
    }
    .titles {
        padding-left: 10rpx;
        text-indent: 5rpx;
        margin-top: 10rpx;
    }
    /* .title {
        height: 60rpx;
        line-height: 70rpx;
        font-size: 28rpx;
        font-weight: 900;
        color: #303133;
    } */
</style>