Commit 32353a17 authored by zhengyi's avatar zhengyi

Merge branch 'pre-release'

parents c329fcba 369ce4bf
......@@ -213,19 +213,27 @@
</el-col>
<el-col :span="12">
<el-form-item :label="$t('主营类别')" prop="productTypes">
<el-form-item :label="$t('主营类别')" prop="products">
<div style="overflow: hidden">
<div style="margin-bottom: 10px" v-for="(ITEM, INDEX) in form.products" :key="INDEX">
<el-row :gutter="10">
<el-col :span="11">
<el-select @change="change" v-model="form.productTypes" filterable multiple :placeholder="$t('请选择产品类别')">
<el-col :span="9">
<el-select @change="change(INDEX, $event)" v-model="form.products[INDEX].typeId" filterable :placeholder="$t('请选择产品类别')">
<el-option :label="isChinese ? item.titleZh : item.titleEn" :value="item.id" v-for="item in productTypeList" :key="item.id" />
</el-select>
</el-col>
<el-col :span="11">
<el-select @change="productIdsChange" multiple filterable clearable v-model="form.productIds" :placeholder="$t('请选择')">
<el-option :label="`${isChinese ? item.typeTitleZh : item.typeTitleEn}: ${item.titleZh}`" :value="parseInt(item.id)" v-for="item in productList" :key="item.id" />
<el-col :span="9">
<el-select @change="productIdsChange(INDEX, $event)" multiple filterable clearable v-model="form.products[INDEX].productIds" :placeholder="$t('请选择')">
<el-option :label="`${item.titleZh}`" :value="parseInt(item.id)" v-for="item in form.products[INDEX].productList" :key="item.id" />
</el-select>
</el-col>
<el-col :span="6">
<el-button type="danger" @click="form.products.splice(INDEX, 1)" style="padding: 10px" :disabled="!INDEX"><i class="el-icon-minus"></i></el-button>
<el-button type="primary" @click="handleAddProduct" style="padding: 10px" v-if="INDEX === form.products.length - 1"><i class="el-icon-plus"></i></el-button>
</el-col>
</el-row>
</div>
</div>
</el-form-item>
</el-col>
......@@ -695,8 +703,8 @@ export default {
}
// 掉入公海时间
this.enterOpenSeaTime = this.form.estimateEnterOpenSeaTime || this.form.enterOpenSeaTime || undefined
if (!this.form.customerService || (this.form.customerService !== user.state.id)){
console.log(!this.form.customerService? "当前客户没有客户经理" : "与当前登录用户的客户经理不同")
if (!this.form.customerService || this.form.customerService !== user.state.id) {
console.log(!this.form.customerService ? "当前客户没有客户经理" : "与当前登录用户的客户经理不同")
// 当前客户没有客户经理,或者与当前登录用户的客户经理不同, 可以不校验部分必填字段
// 2024-12-03 客户-编辑,当客户所属客户经理非当前用户,保存必填校验去掉客户类别,常用提货网点,业务国家,主营类别
// 2024-12-05 客户-编辑,当客户所属客户经理非当前用户,保存必填校验去补充掉竞争对手
......@@ -760,7 +768,7 @@ export default {
}
})
// 判断当前客登录用户是否为当前客户的客户经理
this.getProductListFn([])
this.getProductListFn(0, [undefined])
} else {
this.getZhongPao()
// 新建客户
......@@ -768,7 +776,8 @@ export default {
if (this.isCustomerServiceConfirmed) {
this.form.customerService = this.userId
}
this.getProductListFn([])
this.form.products.push({ typeId: undefined, productIds: [], productList: [] })
this.getProductListFn(0, [undefined])
}
getNodeList().then((r) => {
......@@ -806,6 +815,13 @@ export default {
form: {},
// 表单校验
rules: {
products: [
{
required: true,
trigger: "blur",
validator: this.productsValidator
}
],
name: [
{
required: true,
......@@ -906,7 +922,7 @@ export default {
// 网点
nodeList: [],
productTypeList: [],
productList: [],
productList: {},
showZhong: false,
showZhong1: false,
showPao: false,
......@@ -941,25 +957,31 @@ export default {
deleteEmail(row, index) {
row.splice(index, 1)
},
change(val) {
this.form.productIds = []
this.getProductListFn(val)
change(INDEX, val) {
this.form.products[INDEX].productIds = []
this.getProductListFn(INDEX, [val])
this.$refs["form"].validateField("products")
},
getProductListFn(val) {
getProductList({ typeIds: val }).then((r) => {
this.productList = r.data
getProductListFn(INDEX, val) {
getProductList({ typeIds: !val[0] ? [] : val }).then((r) => {
this.form.products[INDEX].productList = r.data
})
},
productIdsChange(val) {
console.log(val)
let typeIds = this.productList.filter((item) => val.indexOf(item.id) > -1).map((item) => item.typeId)
handleAddProduct() {
this.form.products.push({ typeId: undefined, productIds: [], productList: [] })
this.getProductListFn(this.form.products.length - 1, [undefined])
},
productIdsChange(INDEX, val) {
let typeIds = this.form.products[INDEX].productList.filter((item) => val.indexOf(item.id) > -1).map((item) => item.typeId)
typeIds = [...new Set(typeIds)]
console.log(typeIds)
typeIds.forEach((item) => {
if (this.form.productTypes.indexOf(item) < 0) {
this.form.productTypes.push(item)
let typeId = undefined
if (typeIds.length) {
typeId = typeIds[0]
}
if (typeId !== this.form.products[INDEX].typeId) {
this.form.products[INDEX].typeId = typeId
this.getProductListFn(INDEX, [typeId])
}
})
},
deleteBankData(index) {
this.form.customerBanks.splice(index, 1)
......@@ -992,6 +1014,22 @@ export default {
this.customerSelect = res.data.list
})
},
productsValidator(rule, value, callback) {
let r = this.form.products.some((item) => {
if (!item.typeId) {
callback(new Error(this.$t("主营类别不能为空")))
return true
}
})
let typeIds = this.form.products.map(item=>item.typeId)
if(new Set(typeIds).size !== typeIds.length) {
callback(new Error(this.$t("主营类别不能重复")))
return
}
if (!r) {
callback()
}
},
phoneValidator(rule, value, callback) {
if (!value) {
return callback(new Error(this.$t("请输入联系方式")))
......@@ -1105,6 +1143,9 @@ export default {
this.$modal.msgError(this.$t("请重新选择主要竞争对手"))
return
}
if (this.form.competitorIds == 0 && !this.potential) {
return
}
// 重货标准和泡货标准,未打开就不传,提交前清空一下
if (!this.showZhong) {
......@@ -1212,6 +1253,7 @@ export default {
productTypes: [],
pickupPoints: [],
productIds: [],
products: [],
memberId: undefined,
birthday: undefined,
balance: undefined,
......@@ -1279,9 +1321,12 @@ export default {
competitorIds: Number(response.data.competitorIds),
productTypes: this.stringArrToNumberArr(response.data.productTypes)
}
if (this.form.productTypes.length) {
this.getProductListFn(this.form.productTypes)
if (!this.form.products.length) {
this.form.products.push({ typeId: undefined, productIds: [], productList: [] })
}
this.form.products.forEach((ITEM, INDEX) => {
this.getProductListFn(INDEX, [ITEM.typeId])
})
console.log(this.form)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment