Bladeren bron

feature/产线gantt图

dengrui 1 jaar geleden
bovenliggende
commit
6dcc91ef68
3 gewijzigde bestanden met toevoegingen van 42 en 33 verwijderingen
  1. 1 1
      .env.development
  2. 3 0
      src/hooks/userCrud.ts
  3. 38 32
      src/views/report/productionScheduling/line/index.vue

+ 1 - 1
.env.development

@@ -11,7 +11,7 @@ VITE_APP_BASE_API = '/dev-api'
 VITE_APP_UPLOAD_URL = 'http://192.168.101.4:9000'
 # 开发接口地址
 # VITE_APP_API_URL = 'http://192.168.101.4:8078'
-VITE_APP_API_URL = 'http://127.0.0.1:8078'
+VITE_APP_API_URL = 'http://192.168.101.4:8078'
 #  VITE_APP_API_URL = 'http://121.41.179.41:8078'  #lup
 #VITE_APP_API_URL = 'http://192.168.101.64:8078'  #hetao
 

+ 3 - 0
src/hooks/userCrud.ts

@@ -45,6 +45,7 @@ export const useCrud = (config?: UseCrudConfig) => {
     tip: false, //选中的提示
   });
   const data = ref<any>([]); //表格数据
+  const lines = ref<any>([]); //产线
   const form = ref({}); //新增或者编辑弹出的表单绑定值
   /** 表格顶部搜索的表单的变量 v-model */
   const search = ref({});
@@ -123,6 +124,7 @@ export const useCrud = (config?: UseCrudConfig) => {
             page.value.total = res?.data?.length || 0;
           } else {
             data.value = res?.data?.records || [];
+            lines.value = res?.data?.productLines || [];
             page.value.total = res?.data?.totalCount || 0;
           }
         }
@@ -391,6 +393,7 @@ export const useCrud = (config?: UseCrudConfig) => {
     url,
     option,
     data,
+    lines,
     form,
     search,
     page,

+ 38 - 32
src/views/report/productionScheduling/line/index.vue

@@ -25,12 +25,22 @@ import "dhtmlx-gantt/codebase/dhtmlxgantt.css";
 import html2canvas from "html2canvas";
 import { htmlPdf } from "@/utils/htmlPDF.js";
 import { useCrud } from "@/hooks/userCrud";
+import { v4 as uuidv4 } from "uuid";
 const ganttRef = ref(null);
-const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
-  useCrud({
-    src: "/api/v1/process/census/productLineApsResultGant",
-    pageStr: "no",
-  });
+const {
+  form,
+  data,
+  option,
+  search,
+  page,
+  toDeleteIds,
+  Methords,
+  Utils,
+  lines,
+} = useCrud({
+  src: "/api/v1/process/census/productLineApsResultGant",
+  pageStr: "no",
+});
 const exportToPDF = () => {
   var fileName = "甘特图pdf";
   const fileList = document.getElementsByClassName("gantt_here");
@@ -217,27 +227,9 @@ const initGantt = (type) => {
     {
       tree: true,
       name: "text",
-      label: "订单名称",
+      label: "产线名称",
       width: "240",
     },
-    {
-      name: "startTime",
-      label: "开始时间",
-      align: "center",
-      width: "160",
-      template(task) {
-        return task.startTime;
-      },
-    },
-    {
-      name: "endTime",
-      label: "结束时间",
-      align: "center",
-      width: "160",
-      template(task) {
-        return task.endTime;
-      },
-    },
   ];
   gantt.config.autofit = true;
   gantt.config.resize_rows = true;
@@ -248,10 +240,10 @@ const initGantt = (type) => {
   gantt.config.readonly = true; //是否只读
   gantt.i18n.setLocale("cn"); //设置语言
   gantt.templates.tooltip_text = function (start, end, task) {
-    const text = `名称: ${task.text}<br/>总数: ${task.num}<br/>完成进度: ${task.progress * 100}%`;
-    return !task.parent
-      ? `${text}<br/>交期时间: ${task.deliverWhen}`
-      : `${text}<br/>计划开始时间: ${task.startTime}<br/>计划结束时间: ${task.endTime}`; // eslint-disable-line
+    const text = `产线名称: ${task.name}`;
+    return task.parent
+      ? `名称: ${task.text}<br/>完成进度: ${task.progress * 100}%<br/>计划开始时间: ${task.startTime}<br/>计划结束时间: ${task.endTime}`
+      : `${text}<br/>`;
   };
   const dateToStr = gantt.date.date_to_str(gantt.config.task_date);
   const today = new Date(new Date().setHours(0, 0, 0, 0));
@@ -412,9 +404,11 @@ const setGantt = () => {
   }
 };
 const useData = ref([]);
-const setUseData = (data) => {
+const setUseData = (data, lines) => {
   useData.value = [];
-  const data1 = [...data];
+  const reslinedata = ref([]);
+  const data1 = JSON.parse(JSON.stringify(data));
+  const line1 = JSON.parse(JSON.stringify(lines));
   data1.forEach((element) => {
     element.start_date = element.startTime;
     if (element.progress != 1) {
@@ -422,9 +416,21 @@ const setUseData = (data) => {
     } else {
       element.color = "green";
     }
+    element.id = uuidv4();
+    element.parent = element.productLineId;
   });
   const data2 = JSON.parse(JSON.stringify(data1));
-  useData.value = data2;
+  line1.forEach((element) => {
+    let obj = {};
+    obj.id = element.productLineId;
+    obj.name = element.productLineName;
+    obj.text = element.productLineName;
+    obj.render = "split";
+    reslinedata.value.push(obj);
+  });
+  const data3 = JSON.parse(JSON.stringify(reslinedata.value));
+  const data4 = [...data3, ...data2];
+  useData.value = data4;
 };
 onMounted(() => {
   setTime();
@@ -435,7 +441,7 @@ watch(
   () => data.value,
   () => {
     if (data.value) {
-      setUseData(data.value);
+      setUseData(data.value, lines.value);
       setGantt();
     }
   },