فهرست منبع

1.commonTale增加方法,用于重置字典值。

jiaxiaoqiang 1 سال پیش
والد
کامیت
d9656f76db
1فایلهای تغییر یافته به همراه15 افزوده شده و 29 حذف شده
  1. 15 29
      src/components/CommonTable/index.vue

+ 15 - 29
src/components/CommonTable/index.vue

@@ -34,7 +34,6 @@
 <script setup>
 import { ref, getCurrentInstance } from "vue";
 import { useCrud } from "@/hooks/userCrud";
-import { getBomVersion } from "@/api/craft/process/index";
 import { tableConfig } from "./configs/tableConfig";
 
 const props = defineProps({
@@ -49,40 +48,27 @@ const props = defineProps({
 });
 
 const isShowTable = ref(false);
-const startSelect = async (param, comObj) => {
+const startSelect = async (param) => {
   if (param) {
     commonConfig.value.params = param;
   }
-  if (comObj && comObj.tableName == "wuliaocaiji") {
-    //说明时物料采集的添加框 进行物料采集的下拉框数据获取
-    let bomParam = {
-      materialCode: param.materialCode,
-    };
-    await getBomVersion(bomParam).then((res) => {
-      let resListMap = [];
-      res?.data.forEach((versions) => {
-        resListMap.push({
-          label: versions.bomVersion,
-          value: versions.bomVersion,
-        });
-      });
-      option?.value?.column?.forEach((col) => {
-        if (col.label == "物料版本") {
-          col.dicData = resListMap;
-          if (resListMap.length > 0) {
-            commonConfig.value.params.bomVersion = resListMap[0].value;
-            col.value = resListMap[0].value;
-            console.log("col", col);
-          }
-          return;
-        }
-      });
-    });
-  }
   dataList();
   isShowTable.value = true;
 };
 
+/**
+ * propName 要跟字典配置的key一致
+ * dictData 字典数据, 注意props的value和label
+ * */
+const refreshDictData = (propName, dictData, keyName = "value") => {
+  nextTick(() => {
+    if (dictData && dictData.length > 0 && crudRef.value) {
+      crudRef.value.updateDic(propName, dictData);
+      search.value[propName] = dictData[0][keyName];
+    }
+  });
+};
+
 // 传入一个url,后面不带/
 const {
   url,
@@ -179,5 +165,5 @@ const onSelected = () => {
   isShowTable.value = false;
 };
 
-defineExpose({ startSelect });
+defineExpose({ startSelect, refreshDictData });
 </script>