From 81b8089d94e7f9537b8f5a00b68c95a9e858e2bf Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期一, 13 十一月 2023 12:48:41 +0800
Subject: [PATCH] #
---
pages/business/cstmr/addCsmtr.vue | 237 ++++++++++++++++++++++++++++++++++++++---------------------
1 files changed, 153 insertions(+), 84 deletions(-)
diff --git a/pages/business/cstmr/addCsmtr.vue b/pages/business/cstmr/addCsmtr.vue
index 4e3133e..09dcad1 100644
--- a/pages/business/cstmr/addCsmtr.vue
+++ b/pages/business/cstmr/addCsmtr.vue
@@ -2,59 +2,62 @@
<view>
<view class="container">
<uni-forms ref="baseForm" :modelValue="baseFormData">
- <uni-forms-item label="瀹㈡埛鍚嶇О" required name="name">
+ <!-- <uni-forms-item label="瀹㈡埛鍚嶇О" required name="name">
<uni-easyinput v-model="baseFormData.name" placeholder="璇疯緭鍏ュ鎴峰悕绉�" />
- </uni-forms-item>
- <uni-forms-item label="瀹㈡埛鍏崇郴" >
- <uni-easyinput v-model="baseFormData.rela" placeholder="璇疯緭鍏ュ鎴峰叧绯�" />
- </uni-forms-item>
- <uni-forms-item label="瀹㈡埛绫诲埆" required name="cstmrType">
- <view class="uni-list">
- <view class="uni-list-cell">
- <view class="uni-list-cell-db" >
- <picker style="border: 1px solid #e5e5e5;height: 80rpx;border-radius: 4px;line-height: 80rpx;padding-left: 10px;font-size: 14px;" @change="bindPickerChange" :value="cstmrTypeIndex" :range="cstmrTypes" range-key="value">
- <view class="uni-input">{{cstmrTypes[cstmrTypeIndex].value}}</view>
- </picker>
- </view>
- </view>
+ </uni-forms-item> -->
+
+ <uni-forms-item label="瀹㈡埛鍚嶇О" required name="name">
+ <view>
+ <uni-combox :candidates="names" placeholder="璇疯緭鍏ュ鎴峰悕绉�"
+ v-model="baseFormData.name" @input="cstmrSearch()"></uni-combox>
</view>
-
-
-
-
-
-
-
-
-
-
-
- <!-- <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="cstmrType">
+ <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="industry">
+ <view >
+ <uni-combox :candidates="industrys" placeholder="璇烽�夋嫨瀹㈡埛琛屼笟"
+ v-model="baseFormData.industry"></uni-combox>
+ </view>
+ </uni-forms-item>
+
+ <uni-forms-item label="浜у搧绫诲埆" required name="productCategory">
+ <view>
+ <uni-combox :candidates="productCategorys" placeholder="璇烽�夋嫨浜у搧绫诲埆"
+ v-model="baseFormData.productCategory"></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">
- <uni-easyinput v-model="baseFormData.tel" placeholder="璇疯緭鍏ュ鎴风數璇�" />
</uni-forms-item>
<uni-forms-item label="璇︾粏鍦板潃" required name="addr">
<uni-easyinput v-model="baseFormData.addr" placeholder="璇疯緭鍏ヨ缁嗗湴鍧�" />
</uni-forms-item>
- <uni-forms-item label="璐熻矗浜�" required name="director">
- <uni-combox :candidates="directors" placeholder="璇烽�夋嫨璐熻矗浜�"
- v-model="baseFormData.director" @input="autoLoad('user',baseFormData.director)"></uni-combox>
- <!-- <uni-easyinput v-model="baseFormData.director" placeholder="璇疯緭鍏ヨ礋璐d汉" /> -->
- </uni-forms-item>
+
+
+ <!-- <uni-forms-item label="璐熻矗浜�" required 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="瀹㈡埛鑱旂郴浜�" required name="contacts">
<uni-easyinput v-model="baseFormData.contacts" placeholder="璇疯緭鍏ュ鎴疯仈绯讳汉" />
</uni-forms-item>
- <uni-forms-item label="澶囨敞">
+ <uni-forms-item label="鐢佃瘽" required name="tel">
+ <uni-easyinput v-model="baseFormData.tel" placeholder="璇疯緭鍏ュ鎴风數璇�" />
+ </uni-forms-item>
+ <uni-forms-item label="澶囨敞" name="remarks">
<uni-easyinput type="textarea" v-model="baseFormData.remarks" placeholder="璇疯緭鍏ュ娉�" />
</uni-forms-item>
</uni-forms>
@@ -68,16 +71,24 @@
export default {
data() {
return {
- baseUrl: '',
cstmrTypes: [],
cstmrType: '',
- cstmrTypeIndex: 0,
directors: [],
director: '',
+ cstmrTypeList: [],
+ directorList: [],
+ names: [],
+ nameList: [],
+ industrys: ['鍖昏嵂涓�','鍒堕�犱笟','绾虹粐涓�'],
+ productCategorys: ['绔嬩綋搴擄紙璐ф灦锛�','绔嬩綋搴擄紙闆嗘垚锛�','鍥涘悜绌挎搴�/涓ゅ悜绌挎搴�','闃佹ゼ璐ф灦/閽㈠钩鍙�','鍛ㄨ浆瀹瑰櫒','骞冲簱'],
baseFormData: {
+ name: '',
citysData: [],
cstmrType: '',
director: '',
+ rela: '',
+ remarks: '',
+ industry: ''
},
rules: {
name: {
@@ -86,10 +97,28 @@
errorMessage: '璇峰~鍐欏鎴峰悕绉�',
}]
},
+ rela: {
+ rules: [{
+ required: false,
+ errorMessage: '璇峰~鍐欏鎴峰悕绉�',
+ }]
+ },
cstmrType: {
rules: [{
required: true,
errorMessage: '璇烽�夋嫨瀹㈡埛绫诲埆',
+ }]
+ },
+ industry: {
+ rules: [{
+ required: true,
+ errorMessage: '璇烽�夋嫨瀹㈡埛琛屼笟'
+ }]
+ },
+ productCategory: {
+ rules: [{
+ required: true,
+ errorMessage: '璇烽�夋嫨浜у搧绫诲埆'
}]
},
type: {
@@ -127,6 +156,12 @@
required: true,
errorMessage: '璇疯緭鍏ュ鎴疯仈绯讳汉',
}]
+ },
+ remarks: {
+ rules: [{
+ required: false,
+ errorMessage: '璇疯緭鍏ュ鎴疯仈绯讳汉',
+ }]
}
},
// 鍗曢�夋暟鎹簮
@@ -138,33 +173,56 @@
value: 2
}],
citysData: [],
- userArea: '',
- cstmrList: [],
+ citysDataTemp: ''
+
}
},
onReady() {
// 闇�瑕佸湪onReady涓缃鍒�
this.$refs.baseForm.setRules(this.rules)
-
- },
- mounted() {
+ },
+ onShow() {
// 鑾峰彇鐪佸競鍖�
this.citysData = test.citysData
- this.baseUrl = uni.getStorageSync('baseUrl')
this.autoLoad('cstmrType','')
this.autoLoad('user','')
- // this.getCstmrType()
- // this.getUser()
},
methods: {
+ cstmrSearch() {
+ this.names = []
+ let _this = this
+ if(_this.baseFormData.name.length < 4) {
+ return
+ }
+ uni.request({
+ url: `${_this.baseUrl}/cstmrSearch/auth`,
+ header:{'token':uni.getStorageSync('token'),'content-type':'application/x-www-form-urlencoded',},
+ data: {condition: _this.baseFormData.name},
+ method: 'POST',
+ success(res) {
+ res = res.data
+ if (res.code === 200 && res.data.length > 0) {
+ for(let element of res.data) {
+ _this.names.push(element.name)
+ _this.nameList.push(element)
+ }
+ }
+ }
+ })
+
+ },
bindPickerChange: function(e) {
- console.log(e);
- console.log('picker鍙戦�侀�夋嫨鏀瑰彉锛屾惡甯﹀�间负锛�' + e.detail.value)
- console.log(this.cstmrTypes[e.detail.value].id);
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.directors = []
+ that.directorList = []
var a = that.baseUrl + '/' + type + 'Query/auth'
uni.request({
url: that.baseUrl + '/' + type + 'Query' +'/auth',
@@ -173,18 +231,19 @@
method: 'GET',
success(result) {
var res = result.data
- console.log(res);
if (res.code === 200) {
var element;
if (type == 'cstmrType') {
for(element of res.data) {
- that.cstmrTypes.push(element)
+ 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
}
@@ -195,40 +254,50 @@
},
// 娣诲姞鐢ㄦ埛
addCstmr() {
-
let that = this
- uni.request({
- // url: that.baseUrl + '/cstmr/add/auth',
- url: "http://localhost:9528" + '/cstmr/add/auth',
- header:{
- 'token':uni.getStorageSync('token'),
- // 'content-type':'application/json',
- },
- data: {
- addr: "婊ㄦ睙璺�35鍙�",
- contacts: "绋嬬嚂",
- cstmrType: 1,
- cstmrType$: "绗竴绫�",
- director: "19",
- director$: "瓒呯骇绠$悊鍛�",
- id: "",
- name: "娴嬭瘯2",
- pcd:"14000,140100,140105",
- rela: "",
- remarks: "",
- tel: "15987462587",
- type: "1"
- },
- method: 'POST',
- success(result) {
- var res = result.data
- console.log(res);
+ var element;
+ for (element of that.directorList) {
+ if(element.value == that.baseFormData.director) {
+ that.baseFormData.director = element.id
}
- })
- return
+ }
+ 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',
+ },
+ 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 =>{
})
}
--
Gitblit v1.9.1