|
|
|
|
@ -1,26 +1,7 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<xy-dialog ref="dialog" :form="{...this.form,...this.form1}" :is-show.sync="isShow" :rules="flag === 1 ? rules : rules1" title="编辑客户"
|
|
|
|
|
:width="74" type="form">
|
|
|
|
|
<template v-if="type === 'add'" v-slot:headerContent>
|
|
|
|
|
<el-steps :active="flag" simple style="width: 72%;margin: auto;">
|
|
|
|
|
<el-step title="客户录入" icon="el-icon-user-solid"></el-step>
|
|
|
|
|
<el-step title="订单录入" icon="el-icon-document-add"></el-step>
|
|
|
|
|
</el-steps>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-slot:footerContent>
|
|
|
|
|
<Button @click="$refs['dialog'].reset()">重置</Button>
|
|
|
|
|
<template v-if="flag === 1">
|
|
|
|
|
<Button type="primary" @click="submit">{{type === 'add' ? '保存客户,退出' : '修改'}}</Button>
|
|
|
|
|
<template v-if="type === 'add'">
|
|
|
|
|
<Button type="primary" @click="submit1">保存客户,继续录入订单</Button>
|
|
|
|
|
</template>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else>
|
|
|
|
|
<Button type="primary" @click="submitOrder">保存订单</Button>
|
|
|
|
|
</template>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<xy-dialog ref="dialog" :form="formFormat" :is-show.sync="isShow" :rules="rulesFormat" :title="type === 'add' ? '新增客户' : '编辑客户'"
|
|
|
|
|
:width="74" type="form" @submit="submit">
|
|
|
|
|
<template v-slot:name>
|
|
|
|
|
<div class="xy-table-item">
|
|
|
|
|
<div class="xy-table-item-label">
|
|
|
|
|
@ -678,82 +659,63 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
submit() {
|
|
|
|
|
this.$refs['dialog'].validate().then(res => {
|
|
|
|
|
this.form.sex = getSex(this.form.idcard)
|
|
|
|
|
this.form.birthday = getBirth(this.form.idcard)
|
|
|
|
|
Object.defineProperty(this.form,'city_id',{
|
|
|
|
|
value:this.form.area[0] || '',
|
|
|
|
|
enumerable: true,
|
|
|
|
|
writable: true,
|
|
|
|
|
configurable: true
|
|
|
|
|
})
|
|
|
|
|
Object.defineProperty(this.form,'area_id',{
|
|
|
|
|
value:this.form.area[1] || '',
|
|
|
|
|
enumerable: true,
|
|
|
|
|
writable: true,
|
|
|
|
|
configurable: true
|
|
|
|
|
})
|
|
|
|
|
Object.defineProperty(this.form,'street_id',{
|
|
|
|
|
value:this.form.area[2] || '',
|
|
|
|
|
enumerable: true,
|
|
|
|
|
writable: true,
|
|
|
|
|
configurable: true
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if (this.type === 'editor') {
|
|
|
|
|
Object.defineProperty(this.form, 'id', {
|
|
|
|
|
value: this.id,
|
|
|
|
|
enumerable: true,
|
|
|
|
|
writable: true,
|
|
|
|
|
configurable: true
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
console.log(this.form)
|
|
|
|
|
save(this.form).then(res => {
|
|
|
|
|
this.$successMessage(this.type, '客户')
|
|
|
|
|
this.isShow = false
|
|
|
|
|
this.$emit('refresh')
|
|
|
|
|
})
|
|
|
|
|
this.form.sex = getSex(this.form.idcard)
|
|
|
|
|
this.form.birthday = getBirth(this.form.idcard)
|
|
|
|
|
Object.defineProperty(this.form,'city_id',{
|
|
|
|
|
value:this.form.area[0] || '',
|
|
|
|
|
enumerable: true,
|
|
|
|
|
writable: true,
|
|
|
|
|
configurable: true
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
submit1(){
|
|
|
|
|
this.$refs['dialog'].validate().then(res => {
|
|
|
|
|
this.form.sex = getSex(this.form.idcard)
|
|
|
|
|
this.form.birthday = getBirth(this.form.idcard)
|
|
|
|
|
Object.defineProperty(this.form,'city_id',{
|
|
|
|
|
value:this.form.area[0] || '',
|
|
|
|
|
enumerable: true,
|
|
|
|
|
writable: true,
|
|
|
|
|
configurable: true
|
|
|
|
|
})
|
|
|
|
|
Object.defineProperty(this.form,'area_id',{
|
|
|
|
|
value:this.form.area[1] || '',
|
|
|
|
|
enumerable: true,
|
|
|
|
|
writable: true,
|
|
|
|
|
configurable: true
|
|
|
|
|
})
|
|
|
|
|
Object.defineProperty(this.form,'street_id',{
|
|
|
|
|
value:this.form.area[2] || '',
|
|
|
|
|
Object.defineProperty(this.form,'area_id',{
|
|
|
|
|
value:this.form.area[1] || '',
|
|
|
|
|
enumerable: true,
|
|
|
|
|
writable: true,
|
|
|
|
|
configurable: true
|
|
|
|
|
})
|
|
|
|
|
Object.defineProperty(this.form,'street_id',{
|
|
|
|
|
value:this.form.area[2] || '',
|
|
|
|
|
enumerable: true,
|
|
|
|
|
writable: true,
|
|
|
|
|
configurable: true
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if (this.type === 'editor') {
|
|
|
|
|
Object.defineProperty(this.form, 'id', {
|
|
|
|
|
value: this.id,
|
|
|
|
|
enumerable: true,
|
|
|
|
|
writable: true,
|
|
|
|
|
configurable: true
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
console.log(this.form)
|
|
|
|
|
save(this.form).then(res => {
|
|
|
|
|
if(this.type === 'add'){
|
|
|
|
|
this.form1.customer_id = res.id
|
|
|
|
|
|
|
|
|
|
if (this.type === 'editor') {
|
|
|
|
|
Object.defineProperty(this.form, 'id', {
|
|
|
|
|
value: this.id,
|
|
|
|
|
enumerable: true,
|
|
|
|
|
writable: true,
|
|
|
|
|
configurable: true
|
|
|
|
|
Object.defineProperty(this.form1,'start_date',{
|
|
|
|
|
value:this.form1.date[0],
|
|
|
|
|
enumerable:true,
|
|
|
|
|
writable:true,
|
|
|
|
|
configurable:true
|
|
|
|
|
})
|
|
|
|
|
Object.defineProperty(this.form1,'end_date',{
|
|
|
|
|
value:this.form1.date[1],
|
|
|
|
|
enumerable:true,
|
|
|
|
|
writable:true,
|
|
|
|
|
configurable:true
|
|
|
|
|
})
|
|
|
|
|
delete this.form1.date
|
|
|
|
|
orderSave(this.form1).then(res => {
|
|
|
|
|
this.$successMessage(this.type, '客户')
|
|
|
|
|
this.$emit('refresh')
|
|
|
|
|
this.isShow = false
|
|
|
|
|
})
|
|
|
|
|
}else{
|
|
|
|
|
this.$emit('refresh')
|
|
|
|
|
this.$successMessage(this.type,'客户')
|
|
|
|
|
this.isShow = false
|
|
|
|
|
}
|
|
|
|
|
console.log(this.form)
|
|
|
|
|
save(this.form).then(res => {
|
|
|
|
|
this.$successMessage(this.type, '客户')
|
|
|
|
|
this.flag = 2
|
|
|
|
|
this.form1.customer_id = res.id
|
|
|
|
|
this.customerIdcard = res.idcard
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
@ -761,7 +723,7 @@ export default {
|
|
|
|
|
productPick(e){
|
|
|
|
|
this.pickedProduct = e
|
|
|
|
|
//判断年龄
|
|
|
|
|
let age = getAgeByIdcard(this.customerIdcard)
|
|
|
|
|
let age = getAgeByIdcard(this.form.idcard)
|
|
|
|
|
if(age > this.pickedProduct.product_type.max_age || age < this.pickedProduct.product_type.min_age){
|
|
|
|
|
this.ageTemp = true
|
|
|
|
|
this.$message({
|
|
|
|
|
@ -855,6 +817,28 @@ export default {
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
computed:{
|
|
|
|
|
formFormat(){
|
|
|
|
|
if(this.type === 'add'){
|
|
|
|
|
return {
|
|
|
|
|
...this.form,
|
|
|
|
|
...this.form1
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
return this.form
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
rulesFormat(){
|
|
|
|
|
if(this.type === 'add'){
|
|
|
|
|
return {
|
|
|
|
|
...this.rules,
|
|
|
|
|
...this.rules1
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
return this.rules
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
isShow(val) {
|
|
|
|
|
if (val) {
|
|
|
|
|
|