From 155f2b80f2a9b6f900c73f6e4461e9cebb7cd028 Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期二, 10 十月 2023 17:12:20 +0800
Subject: [PATCH] #
---
pages/business/cstmr/addCsmtr.vue | 153 +++++++++++++++++++++++++++++++-------------------
1 files changed, 95 insertions(+), 58 deletions(-)
diff --git a/pages/business/cstmr/addCsmtr.vue b/pages/business/cstmr/addCsmtr.vue
index 1ec9ad0..569908b 100644
--- a/pages/business/cstmr/addCsmtr.vue
+++ b/pages/business/cstmr/addCsmtr.vue
@@ -5,18 +5,20 @@
<uni-forms-item label="瀹㈡埛鍚嶇О" required name="name">
<uni-easyinput v-model="baseFormData.name" placeholder="璇疯緭鍏ュ鎴峰悕绉�" />
</uni-forms-item>
- <uni-forms-item label="瀹㈡埛鍏崇郴" >
+ <uni-forms-item label="瀹㈡埛鍏崇郴" name="rela" >
<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)"></uni-combox>
- <!-- <uni-easyinput v-model="baseFormData.cstmrType" placeholder="璇疯緭鍏ュ鎴风被鍒�" /> -->
+ <view @click="autoLoad('cstmrType','')">
+ <uni-combox :candidates="cstmrTypes" placeholder="璇烽�夋嫨瀹㈡埛绫诲埆"
+ v-model="baseFormData.cstmrType" @input="autoLoad('cstmrType',baseFormData.cstmrType)"></uni-combox>
+ </view>
</uni-forms-item>
<uni-forms-item label="鍖哄垎" required name="type">
<uni-data-checkbox v-model="baseFormData.type" :localdata="type$" />
</uni-forms-item>
<uni-forms-item label="鐪佸競鍖�" required name="citysData">
- <uni-data-picker placeholder="璇烽�夋嫨鐪佸競鍖�" popup-title="璇烽�夋嫨鎵�鍦ㄥ湴鍖�" :localdata="citysData" v-model="baseFormData.userArea">
+ <uni-data-picker @change="areaChange" placeholder="璇烽�夋嫨鐪佸競鍖�" popup-title="璇烽�夋嫨鎵�鍦ㄥ湴鍖�" :localdata="citysData" v-model="baseFormData.pcd">
</uni-data-picker>
</uni-forms-item>
<uni-forms-item label="鐢佃瘽" required name="tel">
@@ -26,17 +28,19 @@
<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-easyinput v-model="baseFormData.director" placeholder="璇疯緭鍏ヨ礋璐d汉" /> -->
+ <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="瀹㈡埛鑱旂郴浜�" required name="contacts">
<uni-easyinput v-model="baseFormData.contacts" placeholder="璇疯緭鍏ュ鎴疯仈绯讳汉" />
</uni-forms-item>
- <uni-forms-item label="澶囨敞">
+ <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>
+ <button type="primary" @click="addCstmr()">娣诲姞</button>
</view>
</view>
</template>
@@ -46,18 +50,30 @@
export default {
data() {
return {
- baseUrl: '',
cstmrTypes: [],
cstmrType: '',
directors: [],
director: '',
+ cstmrTypeList: [],
+ directorList: [],
baseFormData: {
citysData: [],
+ cstmrType: '',
+ director: '',
+ rela: '',
+ remarks: '',
+
},
rules: {
name: {
rules: [{
required: true,
+ errorMessage: '璇峰~鍐欏鎴峰悕绉�',
+ }]
+ },
+ rela: {
+ rules: [{
+ required: false,
errorMessage: '璇峰~鍐欏鎴峰悕绉�',
}]
},
@@ -102,6 +118,12 @@
required: true,
errorMessage: '璇疯緭鍏ュ鎴疯仈绯讳汉',
}]
+ },
+ remarks: {
+ rules: [{
+ required: false,
+ errorMessage: '璇疯緭鍏ュ鎴疯仈绯讳汉',
+ }]
}
},
// 鍗曢�夋暟鎹簮
@@ -113,71 +135,58 @@
value: 2
}],
citysData: [],
- userArea: ''
+ citysDataTemp: ''
+
}
},
onReady() {
// 闇�瑕佸湪onReady涓缃鍒�
this.$refs.baseForm.setRules(this.rules)
-
- },
- mounted() {
+ },
+ onShow() {
// 鑾峰彇鐪佸競鍖�
this.citysData = test.citysData
- this.baseUrl = uni.getStorageSync('baseUrl')
- this.getCstmrType()
- this.getUser()
+ this.autoLoad('cstmrType','')
+ this.autoLoad('user','')
},
methods: {
- autoLoad(condition) {
- let that = this
- uni.request({
- url: that.baseUrl + '/' + condition +'/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)
- }
- }
- }
- })
+ bindPickerChange: function(e) {
+ this.cstmrTypeIndex = e.detail.value
+ this.baseFormData.cstmrType = this.cstmrTypes[e.detail.value].id
},
- // 鑾峰彇瀹㈡埛绫诲埆
- 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)
- }
- }
- }
- })
+ areaChange(e) {
+ this.citysDataTemp = e.detail.value[0].value + ',' + e.detail.value[1].value + ',' + e.detail.value[2].value
},
- // 鑾峰彇鐢ㄦ埛
- getUser() {
+ autoLoad(type,condition) {
let that = this
+ that.cstmrTypes = []
+ that.directors = []
+ that.directorList = []
+ var a = that.baseUrl + '/' + type + 'Query/auth'
uni.request({
- url: that.baseUrl + '/userQuery/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) {
- that.directors.push(element.value)
+ 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
+ }
+
}
}
})
@@ -185,22 +194,50 @@
// 娣诲姞鐢ㄦ埛
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=>{
- console.log(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'},
+ 'content-type':'application/x-www-form-urlencoded',
+ },
data: res,
method: 'POST',
success(result) {
var res = result.data
- console.log(res);
+ 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 =>{
-
})
}
}
--
Gitblit v1.9.1