From 5f625667370ced031da721bc4dd14ec51509a4a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=96=87=E5=8F=AF?= <1041367524@qq.com> Date: Thu, 9 Jun 2022 14:48:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B9=BF=E5=91=8A=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/extra/ElTable.vue | 17 +++++- .../modules/operation/advertise/advertise.js | 9 ++++ src/views/operation/advertise/form.vue | 2 +- src/views/operation/advertise/index.vue | 52 ++++++++++++++----- 4 files changed, 64 insertions(+), 16 deletions(-) diff --git a/src/components/extra/ElTable.vue b/src/components/extra/ElTable.vue index 9040e83..f9d2890 100644 --- a/src/components/extra/ElTable.vue +++ b/src/components/extra/ElTable.vue @@ -226,8 +226,21 @@ console.error('可拖拽表格ID不存在'); } }; - // 元素实例化后初始化sortablejs - onMounted(handleInit); + if (props.sortable) { + // 元素实例化后初始化sortablejs + onMounted(handleInit); + } else { + watch( + () => props.sortable, + (value, old) => { + if (!old && value) { + handleInit(); + } else if (old && !value) { + sortable.value.destroy(); + } + } + ); + } // 代理原生函数 const handleProxy = (fnName, args) => { return unref(refsTable)[fnName]?.apply(unref(refsTable), args); diff --git a/src/store/modules/operation/advertise/advertise.js b/src/store/modules/operation/advertise/advertise.js index 7b9294b..b90dc3f 100644 --- a/src/store/modules/operation/advertise/advertise.js +++ b/src/store/modules/operation/advertise/advertise.js @@ -165,6 +165,15 @@ const actions = { ElMessage.error((data.isEnable ? '启用' : '禁用') + '失败'); } }, + sort: async ({ dispatch }, data) => { + let res = await api.sort(data); + if (res) { + ElMessage.success('排序成功'); + dispatch('search'); + } else { + ElMessage.error('排序失败'); + } + }, }; export default { state, diff --git a/src/views/operation/advertise/form.vue b/src/views/operation/advertise/form.vue index 329c009..07f76fd 100644 --- a/src/views/operation/advertise/form.vue +++ b/src/views/operation/advertise/form.vue @@ -79,9 +79,9 @@ 继续为该位置添加广告 取消 +