Bladeren bron

订单信息-生产计划完成情况,全局字典和用户数据。

jiaxiaoqiang 10 maanden geleden
bovenliggende
commit
df8576f7bd

+ 20 - 0
src/api/auth/index.ts

@@ -50,3 +50,23 @@ export function getOrgListApi(): AxiosPromise<any[]> {
     method: "get",
   });
 }
+
+/**
+ * 登录成功后获取用户字典
+ */
+export function getUserDicts(data: string[]): AxiosPromise {
+  return request({
+    url: "/api/v1/sys/dictData/queryByTypes",
+    method: "post",
+    data: data,
+  });
+}
+
+// 用户信息列表查询
+export function getUserList(): AxiosPromise {
+  return request({
+    url: "/api/v1/sys/user/list",
+    method: "post",
+    data: {},
+  });
+}

+ 8 - 0
src/api/screens/index.ts

@@ -34,3 +34,11 @@ export function defectDistribution() {
     method: "POST",
   });
 }
+
+//订单信息-生产计划完成情况
+export function productionPlan() {
+  return request({
+    url: "/data/order",
+    method: "POST",
+  });
+}

+ 14 - 0
src/plugins/permission.ts

@@ -1,6 +1,9 @@
 import router from "@/router";
 import NProgress from "@/utils/nprogress";
 import { isNewVersion } from "@/utils/version.js";
+import { useDictionaryStore } from "@/store";
+import { getUserDicts } from "@/api/auth";
+
 export function setupPermission() {
   // 白名单路由
   const whiteList = ["/login"];
@@ -16,6 +19,17 @@ export function setupPermission() {
         next();
         NProgress.done();
       } else {
+        const dictStore = useDictionaryStore();
+        dictStore.checkAllData();
+        if (
+          !dictStore.dicts.value ||
+          JSON.stringify(dictStore.dicts.value) === "{}"
+        ) {
+          const res = await getUserDicts(dictStore.types);
+          if (res.data) {
+            dictStore.dicts = res?.data ?? [];
+          }
+        }
         next();
         NProgress.done();
       }

+ 1 - 0
src/store/index.ts

@@ -16,4 +16,5 @@ export * from "./modules/settings";
 export * from "./modules/tagsView";
 export * from "./modules/user";
 export * from "./modules/common";
+export * from "./modules/dictionary";
 export { store };

+ 55 - 0
src/store/modules/dictionary.ts

@@ -0,0 +1,55 @@
+import { store } from "@/store";
+import { defineStore } from "pinia";
+// import { getUserList } from "@/api/auth";
+
+export const useDictionaryStore = defineStore("dictionaryStore", () => {
+  const types = [
+    "defect_mana",
+    "stage",
+    "process_state",
+    "outsource_state",
+    "work_order_seq_state",
+    "accessories_type",
+    "danwei_type",
+    "system_message_type",
+    "plan_work_order_state",
+    "disposal_measures_type",
+    "escalation_fault_state",
+    "excel_type",
+    "plan_order_state",
+  ];
+  const dicts = ref<{ [key: string]: any[] }>({});
+
+  // 所有的用户列表
+  const allUsers = ref<any[]>([]);
+
+  function checkAllData() {
+    // if (allUsers.value.length === 0) {
+    //   getUserList().then((res) => {
+    //     allUsers.value = res.data || [];
+    //   });
+    // }
+  }
+
+  function getLableByValue(type: string, value: string) {
+    const dict = dicts.value[type];
+    if (dict) {
+      const lable = dict.find((item: any) => item.dictValue === value);
+      return lable?.dictLabel;
+    }
+    return "";
+  }
+
+  return {
+    types,
+    dicts,
+    allUsers,
+    checkAllData,
+    getLableByValue,
+  };
+});
+
+export function useDictionaryStoreHook() {
+  // console.log('dicts:',useDictionaryStore(store))
+  return useDictionaryStore(store);
+}

+ 35 - 20
src/views/screens/screen-components/CompletionProductionPlan.vue

@@ -14,8 +14,11 @@
 
 <script lang="ts" setup>
 import ScreenComHeader from "@/views/screens/configs/screenComHeader.vue";
+import { productionPlan } from "@/api/screens";
+import { useDictionaryStore } from "@/store";
 
 const config = ref({});
+const dictS = useDictionaryStore();
 
 const props = defineProps({
   moduleId: {
@@ -24,25 +27,37 @@ const props = defineProps({
   },
 });
 
-onMounted(() => {
-  config.value = {
-    header: ["列1", "列2", "列3"],
-    data: [
-      ["行1列1", "行1列2", "行1列3"],
-      ["行2列1", "行2列2", "行2列3"],
-      ["行3列1", "行3列2", "行3列3"],
-      ["行4列1", "行4列2", "行4列3"],
-      ["行5列1", "行5列2", "行5列3"],
-      ["行6列1", "行6列2", "行6列3"],
-      ["行7列1", "行7列2", "行7列3"],
-      ["行8列1", "行8列2", "行8列3"],
-      ["行9列1", "行9列2", "行9列3"],
-      ["行10列1", "行10列2", "行10列3"],
-    ],
-    index: true,
-    columnWidth: [50],
-    align: ["center"],
-    carousel: "page",
-  };
+onMounted(async () => {
+  let res = await productionPlan();
+  if (res.data.length > 0) {
+    let dicts = {
+      orderName: "订单名称",
+      orderNum: "订单数量",
+      orderState: "订单状态",
+      materialName: "物料名称",
+      projectCode: "项目编号",
+    };
+
+    let bigData: any[] = [];
+    res.data.forEach((item: any) => {
+      let row = [
+        item.orderName,
+        item.orderNum,
+        dictS.getLableByValue("plan_order_state", item.orderState),
+        item.materialName,
+        item.projectCode,
+      ];
+      bigData.push(row);
+    });
+
+    config.value = {
+      header: Object.values(dicts),
+      data: bigData,
+      index: true,
+      // columnWidth: [50],
+      align: ["left"],
+      carousel: "page",
+    };
+  }
 });
 </script>

+ 39 - 20
src/views/screens/screen-components/OrderInformation.vue

@@ -4,12 +4,14 @@
     <dv-scroll-board
       :config="config"
       style="width: 100%; height: calc(100% - 32px)"
+      @mouseover="tableHover"
     />
   </div>
 </template>
 
 <script lang="ts" setup>
 import ScreenComHeader from "@/views/screens/configs/screenComHeader.vue";
+import { productionPlan } from "@/api/screens";
 
 const config = ref({});
 
@@ -20,25 +22,42 @@ const props = defineProps({
   },
 });
 
-onMounted(() => {
-  config.value = {
-    header: ["订单编号", "产品名称", "数量", "单位", "交期时间"],
-    data: [
-      ["行1列1", "行1列2", "行1列3", "行1列2", "行1列3"],
-      ["行2列1", "行2列2", "行2列3"],
-      ["行3列1", "行3列2", "行3列3"],
-      ["行4列1", "行4列2", "行4列3"],
-      ["行5列1", "行5列2", "行5列3"],
-      ["行6列1", "行6列2", "行6列3"],
-      ["行7列1", "行7列2", "行7列3"],
-      ["行8列1", "行8列2", "行8列3"],
-      ["行9列1", "行9列2", "行9列3"],
-      ["行10列1", "行10列2", "行10列3"],
-    ],
-    index: false,
-    // columnWidth: [50],
-    align: ["left"],
-    carousel: "page",
-  };
+onMounted(async () => {
+  let res = await productionPlan();
+  if (res.data.length > 0) {
+    let dicts = {
+      orderName: "名称",
+      // orderCode: "编码",
+      orderNum: "数量",
+      deliverTime: "交期",
+    };
+
+    let bigData: any[] = [];
+    res.data.forEach((item: any) => {
+      let row = [
+        item.orderName,
+        // item.orderCode,
+        item.orderNum,
+        item.deliverTime,
+      ];
+      bigData.push(row);
+    });
+
+    config.value = {
+      header: Object.values(dicts),
+      data: bigData,
+      // index: true,
+      // columnWidth: [50],
+      align: ["left"],
+      carousel: "page",
+      click: (row: any, index: number) => {
+        console.log("mouseover", row, index);
+      },
+    };
+  }
 });
+
+const tableHover = (data: any) => {
+  // console.log("mouseover", data.row[data.columnIndex]);
+};
 </script>