#
whycq
2022-12-14 719146bf3020d1aee5fe92e446b1f65c7ee89cb4
#
1个文件已修改
78 ■■■■■ 已修改文件
pages/business/cstmr/addCsmtr.vue 78 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/business/cstmr/addCsmtr.vue
@@ -9,7 +9,8 @@
                    <uni-easyinput v-model="baseFormData.rela" placeholder="请输入客户关系" />
                </uni-forms-item>
                <uni-forms-item label="客户类别" required name="cstmrType">
                    <uni-combox :candidates="cstmrTypes" placeholder="请选择客户类别" v-model="cstmrType" @input="autoLoad('cstmrType',cstmrTypeQuery)"></uni-combox>
                    <uni-combox :candidates="cstmrTypes" placeholder="请选择客户类别"
                    v-model="baseFormData.cstmrType" @input="autoLoad('cstmrType',baseFormData.cstmrType)"></uni-combox>
                    <!-- <uni-easyinput v-model="baseFormData.cstmrType" placeholder="请输入客户类别" /> -->
                </uni-forms-item>
                <uni-forms-item label="区分" required name="type">
@@ -26,7 +27,8 @@
                    <uni-easyinput v-model="baseFormData.addr" placeholder="请输入详细地址" />
                </uni-forms-item>
                <uni-forms-item label="负责人" required name="director">
                    <uni-combox :candidates="directors" placeholder="请选择客户类别" v-model="director"></uni-combox>
                    <uni-combox :candidates="directors" placeholder="请选择负责人"
                    v-model="baseFormData.director" @input="autoLoad('user',baseFormData.director)"></uni-combox>
                    <!-- <uni-easyinput v-model="baseFormData.director" placeholder="请输入负责人" /> -->
                </uni-forms-item>
                <uni-forms-item label="客户联系人" required name="contacts">
@@ -36,7 +38,7 @@
                    <uni-easyinput type="textarea" v-model="baseFormData.remarks" placeholder="请输入备注" />
                </uni-forms-item>
            </uni-forms>
            <button type="primary" @click="addCstmr()">保存</button>
            <button type="primary" @click="addCstmr()">添加</button>
        </view>
    </view>
</template>
@@ -53,6 +55,8 @@
                director: '',
                baseFormData: {
                    citysData: [],
                    cstmrType: '',
                    director: '',
                },
                rules: {
                    name: {
@@ -125,69 +129,37 @@
            // 获取省市区
            this.citysData = test.citysData
            this.baseUrl = uni.getStorageSync('baseUrl')
            this.autoLoad('cstmrType',cstmrType)
            this.autoLoad('contacts',user)
            this.autoLoad('cstmrType','')
            this.autoLoad('user','')
            // this.getCstmrType()
            // this.getUser()
        },
        methods: {
            autoLoad(type,condition) {
                let that = this
                var a = that.baseUrl + '/' + type + 'Query/auth'
                uni.request({
                    url: that.baseUrl + '/' + condition +'/auth',
                    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;
                            for(element of res.data) {
                                if (type == cstmrType) {
                            if (type == 'cstmrType') {
                                for(element of res.data) {
                                    that.cstmrTypes.push(element.value)
                                    return
                                }
                                if (type == contacts) {
                                    that.contacts.push(element.value)
                                    return
                                return
                            }
                            if (type == 'user') {
                                for(element of res.data) {
                                    that.directors.push(element.value)
                                }
                                return
                            }
                        }
                    }
                })
            },
            // 获取客户类别
            getCstmrType() {
                let that = this
                uni.request({
                    url: that.baseUrl + '/cstmrTypeQuery/auth',
                    header:{'token':uni.getStorageSync('token')},
                    method: 'GET',
                    success(result) {
                        var res = result.data
                        if (res.code === 200) {
                            var element;
                            for(element of res.data) {
                                that.cstmrTypes.push(element.value)
                            }
                        }
                    }
                })
            },
            // 获取用户
            getUser() {
                let that = this
                uni.request({
                    url: that.baseUrl + '/userQuery/auth',
                    header:{'token':uni.getStorageSync('token')},
                    method: 'GET',
                    success(result) {
                        var res = result.data
                        if (res.code === 200) {
                            var element;
                            for(element of res.data) {
                                that.directors.push(element.value)
                            }
                        }
                    }
                })
@@ -197,12 +169,15 @@
                let that = this
                this.$refs.baseForm.validate().then(res=>{
                    console.log(res);
                    var a = JSON.stringify(res)
                    console.log(a);
                    uni.request({
                        url: that.baseUrl + '/cstmr/add/auth',
                        header:{
                            'token':uni.getStorageSync('token'),
                            'content-type':'application/x-www-form-urlencoded'},
                        data: res,
                            // 'content-type':'application/json',
                            },
                        data: a,
                        method: 'POST',
                        success(result) {
                            var res = result.data
@@ -210,7 +185,6 @@
                        }
                    })
                }).catch(err =>{
                })
            }
        }