Selaa lähdekoodia

fix: BsUi-组件修改

hanxiaohui 5 kuukautta sitten
vanhempi
commit
d553cb2841

+ 1 - 1
src/components/BsUi/ModalTable/index.vue

@@ -1,6 +1,6 @@
 <template>
   <bs-modal :width="modalOptions.width" :visible="modalOptions.visible" :title="modalOptions.title" :modal-extra-props="modalOptions.modalExtraProps">
-    <bs-table v-bind="tableOptions" class="bs-table-modal" ref="bsTableRef" />
+    <bs-table v-if="modalOptions.visible" v-bind="tableOptions" class="bs-table-modal" ref="bsTableRef" />
   </bs-modal>
 </template>
 

+ 5 - 4
src/components/BsUi/ModalTableSelector/index.vue

@@ -39,23 +39,20 @@
     {
       type: 'checkbox',
       width: 60,
-      align: 'center',
       visible: props.multiple === SELECT_MULTIPLE.MORE,
     },
     {
       type: 'radio',
       width: 60,
-      align: 'center',
       visible: props.multiple !== SELECT_MULTIPLE.MORE,
     },
     {
       type: 'seq',
       width: 70,
-      align: 'center',
     },
   ];
 
-  const { tableOptions, setTablePropsValue: setValue, getTablePropsValue: getValue, getGridRef } = props.bsTable;
+  const { tableOptions, setTablePropsValue: setValue, getTablePropsValue: getValue, getGridRef, fetchTableData } = props.bsTable;
   const { modalOptions, setModalPropsValue, getModalPropsValue } = props.bsModal;
 
   const initGridOptions = () => {
@@ -109,6 +106,7 @@
         });
       },
       onCancel() {
+        setModalPropsValue('visible', false)
         emits('close', { close: setModalPropsValue('visible', false) });
       },
       okButtonProps: {
@@ -131,6 +129,9 @@
     () => props.bsModal.modalOptions.visible,
     (newValue, oldValue) => {
       if (newValue) {
+        selectedData.value = [];
+        setValue("gridOptions.data", [])
+        fetchTableData();
         // 界面每次进来重新初始化
         setModalPropsValue('modalExtraProps.okButtonProps.disabled', selectedData.value.length === 0);
       }

+ 20 - 7
src/components/BsUi/Table/index.js

@@ -127,17 +127,28 @@ export const useBsTable = (options, tableRef) => {
       } else {
         console.log('入参为 =====>', { pageNum, pageSize, ...newSearchParams });
         const resData = await getTableDataApi(tableOptions?.url, { pageNum, pageSize, ...newSearchParams });
-        // const resData = {
-        //   data:  {
-        //     list: [{ name: "韩晓辉" }],
-        //     total: 1
-        //   }
-        // }
         const { data } = resData;
         setLoading(false);
         setTableData(data.list);
         setPageTotal(data.total);
         resolve(data);
+        // setTimeout(() => {
+        //   const resData = {
+        //     data:  {
+        //       list: Array.from({ length: 10 }, (_, i) => {
+        //         return {
+        //           name: `hanxiaohui${i}`
+        //         };
+        //       }),
+        //       total: 1
+        //     }
+        //   }
+        //   const { data } = resData;
+        //   setLoading(false);
+        //   setTableData(data.list);
+        //   setPageTotal(data.total);
+        //   resolve(data);
+        // }, 2000)
       }
     });
   };
@@ -188,7 +199,9 @@ export const useBsTable = (options, tableRef) => {
     initPagerConfig();
     initSearchConfig();
     tableOptions.beforeMount && tableOptions.beforeMount();
-    await getTableData();
+    if(get(tableOptions, 'isLoadRequest', true)) {
+      await getTableData();
+    }
   });
 
   const setToolBarVisible = (visible) => {