From 87561787df0785e6d03fc2fcd3be6574aea90adf Mon Sep 17 00:00:00 2001 From: qb <1191961160@qq.com> Date: Thu, 20 Jun 2024 18:15:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=A1=A8=E5=A4=B4=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/edittablehead/index.vue | 29 ++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/components/edittablehead/index.vue b/src/components/edittablehead/index.vue index f4cb16ae..e3f78146 100644 --- a/src/components/edittablehead/index.vue +++ b/src/components/edittablehead/index.vue @@ -148,10 +148,31 @@ const initTable = async () => { const _arr = JSON.parse(data); if (getObjType(_arr) !== 'array') return; - console.log('_arr :>> ', _arr); - columnRef.value = [..._arr]; - handleClearTableQuery(_arr); - emit('update:modelValue', _arr); + + // 设置的表格数据 + const _setArr = []; + + // 本地设置的表格数据 + const _oldArr = [...columnRef.value]; + + for (let j = 0; j < _arr.length; j++) { + const item = _arr[j]; + for (let i = 0; i < _oldArr.length; i++) { + const value = _oldArr[i]; + + if (item.prop !== value.prop) continue; + _setArr.push(item); + _oldArr.splice(i, 1); + break; + } + } + + _setArr.push(..._oldArr); + + console.log('_setArr :>> ', _setArr); + columnRef.value = _setArr; + handleClearTableQuery(_setArr); + emit('update:modelValue', _setArr); } catch (error) { console.log('error :>> ', error); }