| | |
| | | <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"> |
| | |
| | | <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"> |
| | |
| | | <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> |
| | |
| | | director: '', |
| | | baseFormData: { |
| | | citysData: [], |
| | | cstmrType: '', |
| | | director: '', |
| | | }, |
| | | rules: { |
| | | name: { |
| | |
| | | // 获取省市区 |
| | | 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) |
| | | } |
| | | |
| | | } |
| | | } |
| | | }) |
| | |
| | | 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 |
| | |
| | | } |
| | | }) |
| | | }).catch(err =>{ |
| | | |
| | | }) |
| | | } |
| | | } |