From 3849be53f220bc63e7e05fb18357132f30ecd674 Mon Sep 17 00:00:00 2001
From: wuhui_zzw <1760308791@qq.com>
Date: Fri, 22 Mar 2024 11:16:52 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=EF=BC=9A=E7=83=9F=E9=85=92?=
=?UTF-8?q?=E9=A6=86=E4=BB=A3=E7=90=86=E7=BB=91=E5=AE=9A=E7=83=9F=E9=85=92?=
=?UTF-8?q?=E9=A6=86=E5=95=86=E6=88=B7=20=E4=BF=AE=E6=94=B9=EF=BC=9A?=
=?UTF-8?q?=E9=A4=90=E5=8E=85=E3=80=81=E9=85=92=E9=81=93=E9=A6=86=E3=80=81?=
=?UTF-8?q?=E7=83=9F=E9=85=92=E9=A6=86=E7=BB=91=E5=AE=9A=E5=AF=B9=E5=BA=94?=
=?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=95=86=E6=88=B7=E6=B5=81=E7=A8=8B=E3=80=82?=
=?UTF-8?q?=E5=B7=B2=E8=A2=AB=E7=BB=91=E5=AE=9A=E5=88=99=E4=B8=8D=E5=8F=AF?=
=?UTF-8?q?=E9=80=89=E6=8B=A9=EF=BC=8C=E9=9C=80=E8=A6=81=E5=85=88=E5=8F=96?=
=?UTF-8?q?=E6=B6=88=E6=89=8D=E8=83=BD=E9=80=89=E6=8B=A9=E7=BB=91=E5=AE=9A?=
=?UTF-8?q?=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../marketing/agent/agent/template/edit.vue | 129 ++++++++++++++++--
.../marketing/agent/agent/template/mer.vue | 103 ++++++++++----
2 files changed, 192 insertions(+), 40 deletions(-)
diff --git a/src/views/marketing/agent/agent/template/edit.vue b/src/views/marketing/agent/agent/template/edit.vue
index 9e917fd..5a89be1 100644
--- a/src/views/marketing/agent/agent/template/edit.vue
+++ b/src/views/marketing/agent/agent/template/edit.vue
@@ -107,16 +107,41 @@
-
+
-
+
+
+
+
+
+
+
+
@@ -135,7 +160,7 @@
添加餐厅
添加配送商
- 添加烟酒店代销商
+ 添加烟酒店代销商
提交编辑
取消编辑
@@ -257,14 +282,38 @@
-
+
-
+
+
+
+
+
+
+
@@ -460,6 +509,7 @@ export default {
// 商户选择
mer_loading: false,
mer_list: {},
+ selectedShop: {},// 已选择商户 mer=餐厅已选中,shop_mer=酒道馆已选中,wine=烟酒店已选中
};
},
watch: {
@@ -551,8 +601,12 @@ export default {
};
getEditInfo(params).then((res) => {
if(res.status == 200){
- _this.info = Object.assign({},res.data.info || {});
- _this.children_list = Object.assign({},res.data.children_list || {});
+ let data = Object.assign({},res.data || {});
+ _this.info = Object.assign({},data.info || {});
+ _this.children_list = Object.assign({},data.children_list || {});
+ _this.selectedShop.shop_mer = Object.assign({},data.shop_mer || {});
+ _this.selectedShop.wine = Object.assign({},data.wine || {});
+ _this.selectedShop.mer = Object.assign({},data.mer || {});
}
}).catch((res) => {
_this.$message.error(res.message)
@@ -751,23 +805,72 @@ export default {
// 选择商户 - 商户改变
changeMer(event,index){
let _this = this;
+ // 当前代理选中商户信息变更
if(index == -1){
let agent_type = _this.info.agent_type;
if(agent_type == 7) _this.info.mer_id = event.mer_id;
- else if(agent_type == 8) _this.info.mer_id_list = event.event || [];
+ else if(agent_type == 8 || agent_type == 11) _this.info.mer_id_list = event.event || [];
}else{
let agent_type = _this.children_list[index].agent_type;
if(agent_type == 7) _this.children_list[index].mer_id = event.mer_id;
- else if(agent_type == 8) _this.children_list[index].mer_id_list = event.event || [];
+ else if(agent_type == 8 || agent_type == 11) _this.children_list[index].mer_id_list = event.event || [];
}
-
-
-
-
+ _this.changeSelectedShop(index);
_this.$forceUpdate();
+ },
+ // 改变酒道馆已选择商户
+ changeSelectedShop(index){
+ let _this = this;
+ // 获取当前代理
+ let currentAgent = _this.info
+ if(index >= 0) currentAgent = _this.children_list[index] || {};
+ // 获取对应的键 及变更后已选中内容
+ let agentType = currentAgent.agent_type || 0;
+ let selectedMerIds = {};// 当前代理已选中商户ID列表
+ let keyName = '';
+ if(agentType == 7){
+ // 餐厅绑定商户变更
+ selectedMerIds = Number(currentAgent.mer_id) > 0 ? [currentAgent.mer_id] : {};
+ keyName = 'mer';
+ }else if(agentType == 8 || agentType == 11){
+ // 配送商 || 烟酒店代销商 绑定商户变更
+ selectedMerIds = currentAgent.mer_id_list || {};
+ keyName = agentType == 8 ? 'shop_mer' : 'wine';
+ }
+ // 执行删除 —— 循环对应已选中商户列表 进行对应的判断
+ let selectedShop = Object.assign({}, _this.selectedShop[keyName] || {});
+ let selectedShopMerIds = [];// 全部同类型代理已选中商户
+ Object.values(selectedShop).forEach(function (item, index) {
+ if(item.agent_id == currentAgent.id && !Object.values(selectedMerIds).includes(item.mer_id)){
+ // 是当前代理操作 判断是否存在 不存在直接删除
+ delete selectedShop[index];
+ }else{
+ selectedShopMerIds.push(item.mer_id);
+ }
+ })
+ // 执行添加 —— 循环当前代理已选中数据 和所有已选中对比,不存在则添加
+ selectedShop = Object.values(selectedShop);
+ Object.values(selectedMerIds).forEach(function (merId) {
+ if(!Object.values(selectedShopMerIds).includes(merId)){
+ // 不存在所有已选中列表中 添加数据
+ selectedShop.push({
+ agent_id: currentAgent.id,
+ contact_name: currentAgent.contact_name || '',
+ mer_id: merId
+ });
+ }
+ })
+ selectedShop = Object.values(selectedShop);
+
+ _this.$set(_this.selectedShop, keyName, Object.assign({}, selectedShop));
}
+
+
+
+
+
},
};
diff --git a/src/views/marketing/agent/agent/template/mer.vue b/src/views/marketing/agent/agent/template/mer.vue
index 2679992..99cd3f4 100644
--- a/src/views/marketing/agent/agent/template/mer.vue
+++ b/src/views/marketing/agent/agent/template/mer.vue
@@ -1,7 +1,24 @@
-
-
+
+
@@ -15,61 +32,82 @@ export default {
type: String|Number|Object|Array,
default: 0
},
+ merchant_type:{
+ type: String|Number,
+ default: 0
+ },
is_multiple: {
type: Boolean,
default: false
},
+ selected_shop:{
+ type: Object|Array,
+ default: function () {
+ return {};
+ },
+ },
+ agent_id:{
+ type: String|Number,
+ default: 0
+ },
},
data() {
return {
loading: false,
list: {},
+ // 商户已经选中处理
+ selected_shop_mer_ids: {},
+ current_agent_selected: {},
};
},
watch: {
+ // 当前角色已选中商户id列表变更
mer_id: {
handler: function () {
if(Object.values(this.list).length <= 0){
- this.getMer(this.mer_id);
+
+ this.searchMer('');
}
},
immediate: true
},
+ // 所有同类型角色已选中商品ID列表
+ selected_shop: {
+ handler: function () {
+ let agentId = this.agent_id || 0;
+ let merIds = {};
+ let currentAgentSelected = {};
+ Object.values(this.selected_shop).forEach(function (item,index) {
+ merIds[index] = Number(item.mer_id);
+ if (item.agent_id == agentId) currentAgentSelected[index] = Number(item.mer_id);
+ })
+ this.selected_shop_mer_ids = merIds;
+ this.current_agent_selected = Object.values(currentAgentSelected);
+ },
+ immediate: true
+ },
},
mounted() {},
methods: {
// 搜索商户
searchMer(event) {
let _this = this;
- this.loading = true;
let params = {
- keyword: event,
+ keyword: event
};
- merchantListApi(params).then((res) => {
- if(res.status == 200){
- this.list = res.data.list;
- }
- this.loading = false;
- }).catch((res) => {
- this.loading = false;
- this.$message.error(res.message);
- });
+
+ _this.getMerchantList(params);
},
- // 获取商户
- getMer(mer_id) {
+ // 获取商户列表
+ getMerchantList(params){
let _this = this;
- this.loading = true;
- let type = typeof mer_id;
- let params = {};
- if(type === 'object'){
- params.mer_id_list = mer_id;
- }else{
- params.mer_id = mer_id;
- }
+ _this.loading = true;
+ // 参数补充
+ params.merchant_type = _this.merchant_type || 0;
+ params.status = 1;
+ // 发起请求
merchantListApi(params).then((res) => {
- if(res.status == 200){
- _this.list = res.data.list;
- }
+ if(res.status == 200) _this.list = res.data.list;
_this.loading = false;
}).catch((res) => {
_this.loading = false;
@@ -90,7 +128,18 @@ export default {
info.event = event;
this.$emit('change', info);
+ },
+ // 当前角色是否允许选择当前商户
+ isDisabled(mer_id){
+ // 判断:当前商户是否已经被选中 未被选中可以进行操作
+ if(Object.values(this.selected_shop_mer_ids).includes(Number(mer_id))){
+ // 已被选中 判断是否被当前代理选中
+ return !Object.values(this.current_agent_selected).includes(Number(mer_id))
+ }
+
+ return false;
}
+
},
};