From 410ab07f583fb7d72c2ee12ad4e9b3c1e7fb251f Mon Sep 17 00:00:00 2001 From: From-wh Date: Mon, 27 Mar 2023 19:39:51 +0800 Subject: [PATCH] =?UTF-8?q?improve:=20=E5=95=86=E5=93=81=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E4=BD=93=E9=AA=8C=E5=8F=8A=E9=87=8D=E5=A4=8D=E7=82=B9=E5=87=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/src/components/goodsList/index.vue | 42 +++++++++++++++++-- .../src/pages/marketing/live/add_goods.vue | 19 +++++++-- .../admin/src/pages/marketing/live/index.vue | 5 ++- template/admin/src/utils/modalForm.js | 11 ++--- 4 files changed, 65 insertions(+), 12 deletions(-) diff --git a/template/admin/src/components/goodsList/index.vue b/template/admin/src/components/goodsList/index.vue index 400ba4e10..c3b8119ac 100644 --- a/template/admin/src/components/goodsList/index.vue +++ b/template/admin/src/components/goodsList/index.vue @@ -95,6 +95,12 @@ export default { type: Boolean, default: false, }, + selectIds: { + type: Array, + default: () => { + return []; + }, + }, datas: { type: Object, default: function () { @@ -259,6 +265,7 @@ export default { } else { this.getList(); } + console.log(this.diy); }, methods: { productList() { @@ -324,7 +331,22 @@ export default { } changeListApi(this.formValidate) .then(async (res) => { + console.log(this.selectIds); + let data = res.data; + if (this.selectIds.length) { + let arr = [] + this.selectIds.map((item) => { + data.list.map((i) => { + if (i.id == item) { + console.log(i); + i._checked = true; + arr.push(i) + } + }); + }); + this.changeCheckbox(arr) + } this.tableList = data.list; this.total = res.data.count; this.loading = false; @@ -347,9 +369,23 @@ export default { data.list.forEach((el) => { el.image = el.cover_img; }); - this.tableList = data.list; - this.total = res.data.count; - this.loading = false; + + console.log(this.selectIds); + if (this.selectIds.length) { + this.selectIds.map((item) => { + data.list.map((i) => { + if (i.id == item) { + console.log(i); + i._checked = true; + } + }); + }); + } + this.$nextTick((e) => { + this.tableList = data.list; + this.total = res.data.count; + this.loading = false; + }); }) .catch((res) => { this.loading = false; diff --git a/template/admin/src/pages/marketing/live/add_goods.vue b/template/admin/src/pages/marketing/live/add_goods.vue index 98855fa28..604c530d0 100644 --- a/template/admin/src/pages/marketing/live/add_goods.vue +++ b/template/admin/src/pages/marketing/live/add_goods.vue @@ -26,7 +26,7 @@ -
+
@@ -66,7 +66,13 @@ - + @@ -143,6 +149,13 @@ export default { }; }, methods: { + selectGoods() { + this.modals = true; + this.selectIds = this.goodsList.map((i) => { + return i.product_id; + }); + console.log(this.selectIds,this.goodsList) + }, // 生成直播商品 liveGoods() { let array = []; @@ -161,7 +174,7 @@ export default { }); }, getProductId(data) { - this.goodsList = this.goodsList.concat(data); + this.goodsList = data; this.$nextTick((res) => { setTimeout(() => { this.modals = false; diff --git a/template/admin/src/pages/marketing/live/index.vue b/template/admin/src/pages/marketing/live/index.vue index 322a78f4b..f59fc0c1d 100644 --- a/template/admin/src/pages/marketing/live/index.vue +++ b/template/admin/src/pages/marketing/live/index.vue @@ -79,7 +79,7 @@ 详情 删除 - + 添加商品 @@ -105,6 +105,7 @@ ref="goodslist" @getProductId="getProductId" v-if="isShowBox" + :selectIds="selectIds" :ischeckbox="true" :liveStatus="true" > @@ -179,6 +180,7 @@ export default { tabList: [], loading: false, activeItem: {}, + selectIds: [], }; }, computed: { @@ -236,6 +238,7 @@ export default { }, // 直播间添加商品 addGoods(row) { + this.selectIds = row.product_ids; this.activeItem = row; this.isShowBox = true; }, diff --git a/template/admin/src/utils/modalForm.js b/template/admin/src/utils/modalForm.js index 313f45e40..9d027a95e 100644 --- a/template/admin/src/utils/modalForm.js +++ b/template/admin/src/utils/modalForm.js @@ -13,6 +13,7 @@ import Modal from './modal'; import Vue from 'vue'; import { Message, Spin, Notice } from 'iview'; let modalInstance; +let btnStop = false; function getModalInstance(render = undefined) { modalInstance = @@ -88,13 +89,9 @@ export default function (formRequestPromise, { width = '700' } = { width: '700' }, }, }; - let btnStop = false; data.config.onSubmit = (formData, $f) => { - console.log('add') $f.btn.loading(true); $f.btn.disabled(true); - if (btnStop) return; - btnStop = true; request[data.method.toLowerCase()](data.action, formData) .then((res) => { modalInstance.remove(); @@ -105,7 +102,6 @@ export default function (formRequestPromise, { width = '700' } = { width: '700' Message.error(err.msg || '提交失败'); }) .finally(() => { - btnStop = false; $f.btn.loading(false); $f.btn.disabled(false); }); @@ -144,7 +140,12 @@ export default function (formRequestPromise, { width = '700' } = { width: '700' }, on: { click: () => { + if (btnStop) return; + btnStop = true; fApi.submit(); + setTimeout(() => { + btnStop = false; + }, 1000); }, }, },