From 5ca02faa9277546e7a8bbe72e2b7e8b8b461ef34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=99=E7=A0=81=E7=94=9F=E8=8A=B1?= <18523774412@qq.com> Date: Thu, 10 Mar 2022 15:34:17 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=E4=BC=98=E5=8C=96=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E5=BC=80=E5=85=B3loading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/views/backend/auth/menu.vue | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/web/src/views/backend/auth/menu.vue b/web/src/views/backend/auth/menu.vue index 1c8e06d4..9f43d7ad 100644 --- a/web/src/views/backend/auth/menu.vue +++ b/web/src/views/backend/auth/menu.vue @@ -130,7 +130,6 @@ import Table from '/@/components/table/index.vue' import IconSelector from '/@/components/icon/selector.vue' import remoteSelect from '/@/components/remoteSelect/index.vue' import useCurrentInstance from '/@/utils/useCurrentInstance' -import { getArrayKey } from '/@/utils/common' import { useI18n } from 'vue-i18n' const { t } = useI18n() @@ -368,24 +367,15 @@ onMounted(() => { * @param field 被操作字段名 */ proxy.eventBus.on('onTableFieldChange', (data: { value: any; row: TableRow; field: keyof TableRow; render: string }) => { - // 开关-多维数据修改时无loading状态 if (data.render == 'switch') { - const editObj = { [table.pk]: data.row[table.pk], [data.field]: data.value } - const tableDataKey = getArrayKey(table.data, table.pk, data.row[table.pk]) - if (!tableDataKey) { - postData('edit', editObj).then(() => { + data.row.loading = true + postData('edit', { [table.pk]: data.row[table.pk], [data.field]: data.value }) + .then(() => { + data.row.loading = false data.row[data.field] = data.value }) - return - } - table.data[tableDataKey].loading = true - postData('edit', editObj) - .then(() => { - table.data[tableDataKey].loading = false - table.data[tableDataKey][data.field] = data.value - }) .catch(() => { - table.data[tableDataKey].loading = false + data.row.loading = false }) } })