Commit 32353a17 authored by zhengyi's avatar zhengyi

Merge branch 'pre-release'

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