瀏覽代碼

修改bug

huangxw 4 月之前
父節點
當前提交
83609431ff
共有 3 個文件被更改,包括 86 次插入80 次删除
  1. 54 54
      src/assets/styles/variables.module.scss
  2. 3 2
      src/views/cdt/menus/form/index.vue
  3. 29 24
      src/views/cdt/models/transferItems.vue

+ 54 - 54
src/assets/styles/variables.module.scss

@@ -22,60 +22,60 @@
   --tags-view-active-border-color: var(--el-color-primary);
 }
 
-html.dark {
-  --menuBg: #1d1e1f;
-  --menuColor: #bfcbd9;
-  --menuActiveText: #f4f4f5;
-  --menuHover: #171819;
-
-  --subMenuBg: #1d1e1f;
-  --subMenuActiveText: #1d1e1f;
-  --subMenuHover: #171819;
-  --subMenuTitleHover: #171819;
-
-  --fixedHeaderBg: #171819;
-  --tableHeaderBg: var(--el-bg-color);
-  --tableHeaderTextColor: var(--el-text-color);
-
-  // 覆盖ele 高亮当前行的标准暗色
-  .el-tree-node__content {
-    --el-color-primary-light-9: #262727;
-  }
-
-  .el-button--primary {
-    --el-button-bg-color: var(--el-color-primary-dark-6);
-    --el-button-border-color: var(--el-color-primary-light-2);
-  }
-
-  .el-switch {
-    --el-switch-on-color: var(--el-color-primary-dark-6);
-    --el-switch-border-color: var(--el-color-primary-light-2);
-  }
-
-  .el-tag--primary {
-    --el-tag-bg-color: var(--el-color-primary-dark-6);
-    --el-tag-border-color: var(--el-color-primary-light-2);
-  }
-
-  // 在深色模式下使用更深的颜色
-  --tags-view-active-bg: var(--el-color-primary-dark-6);
-  --tags-view-active-border-color: var(--el-color-primary-light-2);
-  // vxe-table 主题
-  --vxe-font-color: #98989e;
-  --vxe-primary-color: #2c9049;
-  --vxe-icon-background-color: #98989e;
-  --vxe-table-font-color: #98989e;
-  --vxe-table-resizable-color: #95969a;
-  --vxe-table-header-background-color: #28282a;
-  --vxe-table-body-background-color: #151518;
-  --vxe-table-background-color: #4a5663;
-  --vxe-table-border-width: 1px;
-  --vxe-table-border-color: #37373a;
-  --vxe-toolbar-background-color: #37373a;
-
-  // ele
-  --brder-color: #37373a;
-}
+// html.dark {
+//   --menuBg: #1d1e1f;
+//   --menuColor: #bfcbd9;
+//   --menuActiveText: #f4f4f5;
+//   --menuHover: #171819;
+
+//   --subMenuBg: #1d1e1f;
+//   --subMenuActiveText: #1d1e1f;
+//   --subMenuHover: #171819;
+//   --subMenuTitleHover: #171819;
+
+//   --fixedHeaderBg: #171819;
+//   --tableHeaderBg: var(--el-bg-color);
+//   --tableHeaderTextColor: var(--el-text-color);
+
+//   // 覆盖ele 高亮当前行的标准暗色
+//   .el-tree-node__content {
+//     --el-color-primary-light-9: #262727;
+//   }
+
+//   .el-button--primary {
+//     --el-button-bg-color: var(--el-color-primary-dark-6);
+//     --el-button-border-color: var(--el-color-primary-light-2);
+//   }
+
+//   .el-switch {
+//     --el-switch-on-color: var(--el-color-primary-dark-6);
+//     --el-switch-border-color: var(--el-color-primary-light-2);
+//   }
+
+//   .el-tag--primary {
+//     --el-tag-bg-color: var(--el-color-primary-dark-6);
+//     --el-tag-border-color: var(--el-color-primary-light-2);
+//   }
+
+//   // 在深色模式下使用更深的颜色
+//   --tags-view-active-bg: var(--el-color-primary-dark-6);
+//   --tags-view-active-border-color: var(--el-color-primary-light-2);
+//   // vxe-table 主题
+//   --vxe-font-color: #98989e;
+//   --vxe-primary-color: #2c9049;
+//   --vxe-icon-background-color: #98989e;
+//   --vxe-table-font-color: #98989e;
+//   --vxe-table-resizable-color: #95969a;
+//   --vxe-table-header-background-color: #28282a;
+//   --vxe-table-body-background-color: #151518;
+//   --vxe-table-background-color: #4a5663;
+//   --vxe-table-border-width: 1px;
+//   --vxe-table-border-color: #37373a;
+//   --vxe-toolbar-background-color: #37373a;
+
+//   // ele
+//   --brder-color: #37373a;
+// }
 
 // base color
 $blue: #324157;

+ 3 - 2
src/views/cdt/menus/form/index.vue

@@ -173,7 +173,7 @@
             </div>
         </div>
     </div>
-    <TransferItems ref="TransferItemsRef" v-model:show="showSelectItems" @change="changeItems"></TransferItems>
+    <TransferItems v-if="showSelectItems" ref="TransferItemsRef" v-model:show="showSelectItems" @change="changeItems" :items="form.items"></TransferItems>
 </template>
 
 <script setup name="Menus-form" lang="ts">
@@ -305,7 +305,8 @@ const changeItemCpy = (val: any[]) => {
 // 继续添加方法
 const addItems = () => {
     // 保留之前选中
-    TransferItemsRef.value?.setSelectItems(form.value.items);
+    console.log(form.value.items);
+    
     showSelectItems.value = true;
 };
 // 清空重选方法

+ 29 - 24
src/views/cdt/models/transferItems.vue

@@ -41,7 +41,7 @@
                     </div>
                     <div class="flex1 ov-hd d-flex flex-cln">
                         <div class="flex1 ov-hd">
-                            <vxe-table ref="tableLeftRef" :loading="loading" border :data="list" height="100%" :column-config="{ resizable: true }" :row-config="{keyField: 'id',isCurrent: true, isHover: true}" :checkbox-config="{ checkRowKeys: checkRowKeys,  highlight: true, range: true, trigger: 'row', reserve: true }">
+                            <vxe-table ref="tableLeftRef" :loading="loading" border :data="list" height="100%" :column-config="{ resizable: true }" :row-config="{keyField: 'id',isCurrent: true, isHover: true}" :checkbox-config="{ highlight: true, range: true, trigger: 'row', reserve: true }">
                                 <vxe-column type="checkbox" width="60"></vxe-column>
                                 <!-- 序号 -->
                                 <vxe-column type="seq" width="60" title="序号" align="center" />
@@ -97,7 +97,8 @@ const props = defineProps({
     show: propTypes.bool.def(false),
     title: propTypes.string.def('选择检测项目'),
     width: propTypes.string.def('80vw'),
-    info: propTypes.any.def(null)
+    info: propTypes.any.def(null),
+    items: propTypes.array.def([]) // 已选检测项目
 });
 const treeItemsRef = ref<any>();
 const treeStandardsRef = ref<any>();
@@ -114,18 +115,19 @@ const total = ref(0);
 const list = ref<any>([]);
 const targetList = ref<any>([]);
 const itemsData = ref<any>([]);
+// 是否打开过刚才id
+const mapIdsOpened = ref<any>({});
 const getList = async () => {
     loading.value = true;
     const res = await itemsList(queryParams.value);
     if (!res || res.code !== 200) return;
-    list.value = res.rows;
-    res.rows.forEach((item: any) => {
-        if (targetList.value.some((target: any) => target.id === item.id)) {
-            tableLeftRef.value?.setCheckboxRow([item], true);
-        }
+    res.rows.forEach(element => {
+        mapIdsOpened.value[element.id] = true;
     });
+    list.value = res.rows
     total.value = res.total;
     loading.value = false;
+    tableLeftRef.value?.setCheckboxRow(targetList.value, true);
 };
 const handleQuery = () => {
     queryParams.value.pageNum = 1;
@@ -190,26 +192,20 @@ const submitForm = async () => {
 const tableLeftRef = ref<any>();
 const tableRightRef = ref<any>();
 const transferRight = () => {
-    targetList.value = tableLeftRef.value?.getCheckboxReserveRecords(true).concat(tableLeftRef.value?.getCheckboxRecords());
+    // 去重
+    const newsList = tableLeftRef.value?.getCheckboxReserveRecords(true).concat(tableLeftRef.value?.getCheckboxRecords());
+    // 过滤没打开过的
+    const noOpenList = targetList.value.filter((item: any) => !mapIdsOpened.value[item.id]);
+    // 合并newsList和noOpenList
+    targetList.value = newsList
 };
 const transferLeft = () => {
     targetList.value = targetList.value.filter((item: any) => !tableRightRef.value?.getCheckboxRecords().includes(item));
     tableLeftRef.value?.setCheckboxRow(tableRightRef.value?.getCheckboxRecords(), false);
     tableRightRef.value.setCheckboxRow(tableRightRef.value?.getCheckboxRecords(), false);
 };
-// 清空全部已选
-const clearAll = () => {
-    tableLeftRef.value?.clearCheckboxRow();
-    tableRightRef.value?.clearCheckboxRow();
-    targetList.value = [];
-};
+
 const checkRowKeys = ref<any>([]);
-// const c
-// 设置已选
-const setSelectItems = (val: any) => {
-    targetList.value = val;
-    checkRowKeys.value = val.map((item: any) => item.id);
-};
 watch(
     () => props.show,
     (val) => {
@@ -221,10 +217,19 @@ watch(
     },
     { immediate: true }
 );
-defineExpose({
-    clearAll,
-    setSelectItems
-});
+watch(
+    () => props.items,
+    (val) => {
+        console.log(val);
+        if (val && val.length) {
+            targetList.value = val;
+        } else {
+            targetList.value = [];
+            checkRowKeys.value = [];
+        }
+    },
+    { immediate: true }
+);
 </script>
 <style lang="scss" scoped>
 .tree-wrap {