Kaynağa Gözat

Merge branch 'qingban' of http://192.168.101.4:3000/jiaxiaoqiang/JG-ADMIN-TEMP into qingban

dengrui 6 ay önce
ebeveyn
işleme
4cf744cfaf

+ 5 - 0
src/hooks/userCrud.ts

@@ -11,6 +11,8 @@ interface UseCrudConfig {
 
   dataListUrl?: string;
 
+  afterDataList?: Function;
+
   // 需要操作的数据
   row?: any;
   // done用于结束操作
@@ -122,6 +124,9 @@ export const useCrud = (config?: UseCrudConfig) => {
             data.value = res?.data?.records || [];
             page.value.total = res?.data?.totalCount || 0;
           }
+          if (commonConfig.value?.afterDataList) {
+            commonConfig.value?.afterDataList();
+          }
         }
         config?.done && config?.done();
       } catch (err) {

+ 16 - 20
src/views/base/craftManagement/route/components/bottomTable.vue

@@ -104,11 +104,14 @@ const props = defineProps({
 
 const route = useRoute();
 const tableConfig = getTableConfig(route.fullPath.split("/")[4]);
-
+const afterDataListToGetBomVersion = () => {
+  toGetBomVersion();
+};
 // 传入一个url,后面不带/
 const { url, form, data, option, search, page, toDeleteIds, Methords, Utils } =
   useCrud({
     src: tableConfig[props.tableType].url,
+    afterDataList: afterDataListToGetBomVersion,
   });
 
 const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
@@ -150,9 +153,8 @@ const goToSelectMaterial = () => {
 
 const startCreat = () => {
   if (props.tableType === "wuliaocaiji") {
-    if (data.value && data.value.length > 0) {
-      bomVersion.value = data.value[0].recordVersion;
-      selectedVersion.value = data.value[0].recordVersion;
+    if (bomVersion.value) {
+      selectedVersion.value = bomVersion.value;
       goToSelectMaterial();
     } else {
       getBomVersion({ materialCode: route.fullPath.split("/")[5] }).then(
@@ -381,13 +383,7 @@ onMounted(() => {
     column: tableConfig[props.tableType].column,
   });
   dataList();
-  getRouteMaxVersion(
-    route.fullPath.split("/")[6] ? route.fullPath.split("/")[6] : routeId.value
-  ).then(({ data }) => {
-    if (data) {
-      bomVersion.value = data;
-    }
-  });
+  toGetBomVersion();
 });
 
 watch(
@@ -403,15 +399,15 @@ watch(
       column: tableConfig[props.tableType].column,
     });
     dataList();
-    getRouteMaxVersion(
-      route.fullPath.split("/")[6]
-        ? route.fullPath.split("/")[6]
-        : routeId.value
-    ).then(({ data }) => {
-      if (data) {
-        bomVersion.value = data;
-      }
-    });
+    toGetBomVersion();
   }
 );
+
+const toGetBomVersion = () => {
+  getRouteMaxVersion(
+    route.fullPath.split("/")[6] ? route.fullPath.split("/")[6] : routeId.value
+  ).then(({ data }) => {
+    bomVersion.value = data;
+  });
+};
 </script>