Browse Source

feature/生产履历

dengrui 9 months ago
parent
commit
55a13cd905

+ 21 - 2
src/views/base/craftManagement/route/bindProcess.vue

@@ -54,13 +54,18 @@
         </el-scrollbar>
       </div>
       <div class="flowBox">
-        <el-scrollbar style="padding-bottom: 20px">
+        <el-scrollbar style="padding-bottom: 20px; position: relative">
           <VueDraggable
             v-model="list2"
             :animation="150"
             group="people"
             @update="onUpdate"
-            style="min-width: 400px"
+            style="
+              min-width: 400px;
+              min-height: 80px;
+              position: relative;
+              z-index: 1;
+            "
             @add="onClone"
             :disabled="!editStauts"
           >
@@ -84,6 +89,9 @@
               <Bottom class="arrow" v-show="index < list2.length - 1" />
             </div>
           </VueDraggable>
+          <div class="notice" id="notice" v-if="list2.length < 1">
+            请拖拽置此处
+          </div>
         </el-scrollbar>
       </div>
       <div class="detailInfo">
@@ -325,6 +333,17 @@ const getNameByDictType = (dictValue) => {
   overflow-y: auto;
   padding-top: 47px;
   padding-bottom: 47px;
+  .notice {
+    position: absolute;
+    width: 100%;
+    height: 80px;
+    border: 1px dashed rgba(0, 0, 0, 0.5);
+    top: 0;
+    text-align: center;
+    font-size: 20px;
+    line-height: 80px;
+    z-index: 0;
+  }
   .flowContain {
     width: 400px;
 

+ 175 - 0
src/views/pro/traceability/components/excelCom.vue

@@ -0,0 +1,175 @@
+<!-- 表格数据 -->
+<template>
+  <div class="mainContentBox">
+    <avue-crud
+      ref="crudRef2"
+      v-model:search="search"
+      v-model="form"
+      @row-update="createRow"
+      :data="data"
+      :option="option"
+      v-model:page="page"
+    >
+      <template #menu="{ size, row, index }">
+        <el-button
+          v-if="row.excelData != '' && row.excelData != null"
+          link
+          size="small"
+          type="primary"
+          @click="opView(row)"
+          style="margin: 0"
+          ><i-ep-view />查看
+        </el-button>
+        <el-button
+          v-if="row.excelData != '' && row.excelData != null"
+          type="warning"
+          link
+          size="small"
+          @click="opUpdate(row)"
+          style="margin: 0"
+          ><i-ep-edit />修改表格数据
+        </el-button>
+      </template>
+    </avue-crud>
+    <el-dialog
+      v-model="updataShow"
+      :title="updateTitle"
+      @close="updataShow = false"
+      width="1600"
+    >
+      <updateExcel
+        @refresh="refreshDatalist"
+        :data="ExData"
+        @close="closeShow"
+      />
+    </el-dialog>
+  </div>
+</template>
+<script setup>
+import { ref, getCurrentInstance } from "vue";
+import { useCrud } from "@/hooks/userCrud";
+import dictDataUtil from "@/common/configs/dictDataUtil";
+import ButtonPermKeys from "@/common/configs/buttonPermission";
+import {
+  useCommonStoreHook,
+  useDictionaryStore,
+  useUserStoreHook,
+} from "@/store";
+import updateExcel from "./updateExcel.vue";
+// 数据字典相关
+const { dicts } = useDictionaryStore();
+const updataShow = ref(false);
+const updateTitle = ref("修改表格数据");
+const crudRef2 = ref({});
+const lookStatus = ref(false);
+const opUpdate = (row) => {
+  ExData.value = row;
+  ExData.value.lookStatus = false;
+  if (row.writeData == "" || row.writeData == null) {
+    ElMessage.error("数据有误请联系管理员");
+    return;
+  }
+  updataShow.value = true;
+};
+const opView = (row) => {
+  ExData.value = row;
+  ExData.value.lookStatus = true;
+  if (row.writeData == "" || row.writeData == null) {
+    ElMessage.error("数据有误请联系管理员");
+    return;
+  }
+  updataShow.value = true;
+};
+const closeShow = () => {
+  updataShow.value = false;
+};
+const ExData = ref("");
+// 传入一个url,后面不带/
+const {
+  form,
+  data,
+  option,
+  search,
+  page,
+  toDeleteIds,
+  Methords,
+  Utils,
+  commonConfig,
+} = useCrud({
+  src: "/api/v1/ProcessFormData",
+});
+const ctableRef = ref(null);
+const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
+  Methords; //增删改查
+const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
+const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
+const userStore = useUserStoreHook();
+const crudRef = ref(null); //crudRef.value 获取avue-crud对象
+const doEdit = (row, index) => {
+  crudRef2.value && crudRef2.value.rowEdit(row, index);
+};
+const refreshTra = (row) => {
+  commonConfig.value.params = { seqNo: row.seqNo,workOrderCode: row.workOrderCode}
+  dataList();
+};
+const refreshDatalist = () => {
+  dataList();
+};
+defineExpose({ refreshTra });
+onMounted(() => {
+  if (userStore.user.userId === 10000) {
+    option.value.menu = true;
+  }
+});
+
+option.value = Object.assign(option.value, {
+  selection: false,
+  border: true,
+  index: false,
+  expandLevel: 3,
+  headerAlign: "center",
+  align: "center",
+  labelWidth: 100,
+  addBtn: false,
+  delBtn: false,
+  viewBtn: false,
+  menu: false,
+  header: false,
+  editBtn: false,
+  rowKey: "operationId",
+  column: [
+    {
+      label: "工序Id",
+      prop: "operationId",
+      display: false,
+      hide: true,
+    },
+    {
+      label: "工序名称",
+      prop: "operationName",
+      disabled: true,
+      search: false,
+      display: false,
+    },
+
+    {
+      label: "表格名称",
+      disabled: true,
+      prop: "formName",
+      search: false,
+    },
+    {
+      label: "表格类型",
+      prop: "formType",
+      type: "select",
+      disabled: true,
+      search: false,
+      dicData: dicts.excel_type,
+      props: {
+        label: "dictLabel",
+        value: "dictValue",
+      },
+    },
+  ],
+});
+</script>

+ 366 - 0
src/views/pro/traceability/components/updateExcel.vue

@@ -0,0 +1,366 @@
+<template>
+  <div class="dialogBody">
+    <div class="exView" :key="excelKey1">
+      <ExcelView
+        ref="excelViewRef"
+        :option="options"
+        @confirm="confirm"
+        v-model:data="exceldata"
+        :checkStatus="true"
+        :verifications="setting"
+      />
+    </div>
+    <div class="btns" v-if="options.edit !== false">
+      <el-button class="btn" type="success" @click="submit">确 定 </el-button>
+      <el-button class="btn" @click="reset">重 置 </el-button>
+      <el-button class="btn" type="info" @click="cancel">取 消 </el-button>
+    </div>
+    <div class="btns" v-else>
+      <el-button class="btn" type="info" @click="cancel">返 回 </el-button>
+    </div>
+  </div>
+</template>
+<script setup lang="ts">
+import { ref } from "vue";
+import { useCrud } from "@/hooks/userCrud";
+import { setExcelData } from "@/api/excel/index.ts";
+import ExcelView from "@/components/ExcelView/index.vue";
+import { useDictionaryStore } from "@/store";
+const setting = ref([]);
+const props = defineProps({
+  data: {
+    type: Object,
+  },
+});
+const rowData = ref({});
+const emits = defineEmits(["update:modelValue", "close", "refresh"]);
+const excelKey1 = ref(false);
+const submit = async () => {
+  excelViewRef.value.confirm();
+  const { data, code } = await setExcelData({
+    excelData: JSON.stringify(exceldata.value),
+    excelFormId: rowData.value.excelFormId,
+    processId: rowData.value.processId,
+    formType: rowData.value.formType,
+    formName: rowData.value.formName,
+  });
+  if (code == "200") {
+    ElMessage.success("修改成功!");
+    cancel();
+    emits("refresh");
+  }
+};
+const reset = () => {
+  exceldata.value = JSON.parse(rowData.value.excelData);
+  excelKey1.value = !excelKey1.value;
+};
+const cancel = () => {
+  excelKey1.value = !excelKey1.value;
+  options.value.edit = true;
+  emits("close");
+};
+// 存放操作表格相关业务代码
+const useAddTemplateHook = () => {
+  //excelView 组件实例
+  const excelViewRef = ref(null);
+  //表格配置项
+  const options = ref({
+    //头部操作区域
+    opreaState: true,
+    //导入按钮展示
+    in: true,
+    //导出按钮展示
+    out: true,
+    print: true,
+    //编辑状态 false:为查看状态
+    edit: true,
+    //当前操作表格名称
+    inName: "",
+    opreaTitle: false,
+  });
+  //双向绑定表格data变量
+  const exceldata = ref(null);
+  //控制表格组件展示界面变量(包括表格展示页面和操作页面)
+  const excelStatus = ref(true);
+
+  //获取组件内实时数据赋值到外层
+  const confirm = (data: any) => {
+    exceldata.value = data;
+  };
+  return {
+    excelStatus,
+    options,
+    confirm,
+    exceldata,
+    excelViewRef,
+  };
+};
+const { options, confirm, exceldata, excelViewRef } = useAddTemplateHook();
+const useFormHook = () => {
+  //KEY告知组件刷新
+  const excelKey = ref(1);
+  //表单data
+  const formVlaue = reactive({ formType: null, formName: null, state: null });
+  //表单是否为编辑状态变量
+  const operaEditStatus = ref(false);
+  //选中的行id
+  const selectId = ref(null);
+  //表单ref实例
+  const formRef = ref(null);
+  //表单校验规则
+  const rules = reactive({
+    formName: [
+      {
+        required: true,
+        trigger: "blur",
+      },
+    ],
+    formType: [
+      {
+        required: true,
+        trigger: "blur",
+      },
+    ],
+    state: [
+      {
+        required: true,
+        trigger: "blur",
+      },
+    ],
+  });
+  //新增模版
+  const submitForm = async (formEl: any) => {
+    //@ts-ignore;
+    excelViewRef.value.confirm();
+    if (exceldata.value == null) return ElMessage.error("请提供表格数据!");
+    if (!formEl) return;
+    await formEl.validate(async (valid: any, fields: any) => {
+      if (valid) {
+        const { data, code } = await addExcel({
+          ...formVlaue,
+          excelData: exceldata.value,
+        });
+        if (code == "200") {
+          ElMessage.success("添加成功!");
+          resetData();
+          dataEditList();
+          editTep(data);
+        }
+      }
+    });
+  };
+  //更新行内信息
+  const updateExForm = async (formEl: any) => {
+    //@ts-ignore;
+    excelViewRef.value.saveCellData();
+    //@ts-ignore;
+    excelViewRef.value.confirm();
+    if (exceldata.value == null) return ElMessage.error("请提供表格数据!");
+    if (!formEl) return;
+    await formEl.validate(async (valid: any, fields: any) => {
+      if (valid) {
+        const { data, code } = await updateExcel({
+          ...formVlaue,
+          excelData: exceldata.value,
+          id: selectId.value,
+          settings: settings.value,
+        });
+        if (code == "200") {
+          ElMessage.success("修改成功!");
+          resetData();
+          dataEditList();
+        }
+      }
+    });
+  };
+  //表达数据重置
+  const resetForm = (formEl: any) => {
+    if (!formEl) return;
+    formEl.resetFields();
+  };
+  return {
+    formVlaue,
+    formRef,
+    rules,
+    selectId,
+    excelKey,
+    operaEditStatus,
+    submitForm,
+    resetForm,
+    updateExForm,
+  };
+};
+
+const {
+  formVlaue,
+  formRef,
+  rules,
+  selectId,
+  excelKey,
+  operaEditStatus,
+  submitForm,
+  resetForm,
+  updateExForm,
+} = useFormHook();
+//表格新增 分页
+const useAddFormHook = () => {
+  const formRef1 = ref(null);
+  const settings = ref([]);
+  const searchForm = ref({
+    pageNo: 1,
+    pageSize: 5,
+    totalPages: 0,
+  });
+  const addForm = ref({
+    paramName: "",
+    position: "",
+  });
+  const addPage = () => {
+    searchForm.value.pageNo = searchForm.value.pageNo + 1;
+    getSettingData();
+  };
+  const deletePage = () => {
+    searchForm.value.pageNo = searchForm.value.pageNo - 1;
+    getSettingData();
+  };
+  const getSettingData = async () => {
+    const { data } = await getSettingsData({
+      excelFormId: selectId.value,
+      ...searchForm.value,
+    });
+    settings.value = data.records;
+    if (settings.value.length == 0 && searchForm.value.pageNo > 1) {
+      deletePage();
+    }
+    searchForm.value.totalPages = data.totalPages;
+  };
+  const addSettings = async () => {
+    const { data, code } = await addSettingsData({
+      excelFormId: selectId.value,
+      ...addForm.value,
+    });
+    if (code == "200") {
+      ElMessage.success("添加成功");
+      resetAddForm();
+      getSettingData();
+    }
+  };
+  const deleteSettings = async (id: any) => {
+    const { data, code } = await deleteSettingsData({ id: id });
+    if (code == "200") {
+      ElMessage.success("删除成功");
+      getSettingData();
+    }
+  };
+
+  const resetAddForm = () => {
+    addForm.value = {
+      paramName: "",
+      position: "",
+    };
+    searchForm.value = {
+      pageNo: 1,
+      pageSize: 5,
+      totalPages: 0,
+    };
+    settings.value = [];
+  };
+  const creatAddForm = async () => {
+    await formRef1.value.validate(async (valid: any, fields: any) => {
+      if (valid) {
+        addSettings();
+      }
+    });
+  };
+  const addRules = reactive({
+    paramName: [
+      {
+        required: true,
+        trigger: "blur",
+      },
+    ],
+    position: [
+      {
+        required: true,
+        trigger: "blur",
+      },
+    ],
+  });
+  return {
+    formRef1,
+    addForm,
+    searchForm,
+    settings,
+    addRules,
+    creatAddForm,
+    resetAddForm,
+    getSettingData,
+    addSettings,
+    addPage,
+    deleteSettings,
+    deletePage,
+  };
+};
+
+const {
+  formRef1,
+  addForm,
+  searchForm,
+  settings,
+  addRules,
+  creatAddForm,
+  deletePage,
+  addPage,
+  resetAddForm,
+  getSettingData,
+  deleteSettings,
+} = useAddFormHook();
+watch(
+  () => props.data,
+  () => {
+    //@ts-ignore
+    rowData.value = props.data;
+    exceldata.value = JSON.parse(rowData.value.writeData);
+    excelKey1.value = !excelKey1.value;
+    if (rowData.value.lookStatus == true) {
+      options.value.edit = false;
+    }
+    setting.value = rowData.value.settings;
+  },
+  { immediate: true }
+);
+watch(
+  () => rowData.value,
+  () => {
+    if (rowData.value.lookStatus == true) {
+      options.value.edit = false;
+    }
+  },
+  { immediate: true, deep: true }
+);
+</script>
+<style lang="scss" scoped>
+.dialogBody {
+  width: 1560px;
+  height: 560px;
+  display: flex;
+  .exView {
+    width: 1330px;
+    height: 560px;
+    display: flex;
+    position: relative;
+  }
+  .btns {
+    width: 200px;
+    height: 560px;
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    padding: 40px 0 0 20px;
+    .btn {
+      width: 100%;
+      margin: 10px;
+    }
+  }
+}
+</style>

+ 49 - 28
src/views/pro/traceability/index.vue

@@ -1,7 +1,10 @@
 <template>
   <div class="mainContentBox common-layout">
     <el-container>
-      <el-aside width="600px" style="height: 800px">
+      <el-aside
+        width="600px"
+        style="min-height: 800px; max-height: calc(100vh - 200px)"
+      >
         <avue-crud
           ref="crudRef"
           v-model:search="search"
@@ -12,8 +15,9 @@
           @cell-click="handleCellClick"
           @search-change="searchChange"
           @size-change="dataList"
+          @search-reset="resetChange"
           @current-change="dataList"
-
+          @selection-change="selectionChange"
         >
           <template #seqNo="{ row }">
             <el-tag :type="chooseTagType(row.level, 'css')">{{
@@ -38,9 +42,9 @@
             <el-descriptions-item label="产品规格">{{
               productReviewInfo.materialModel
             }}</el-descriptions-item>
-            <el-descriptions-item label="计划编号">{{productReviewInfo.orderCode}}</el-descriptions-item>
+            <el-descriptions-item label="铭牌号">-</el-descriptions-item>
             <el-descriptions-item label="是否返工">
-              <el-tag size="small">{{productReviewInfo.rework}}</el-tag>
+              <el-tag size="small">{{ productReviewInfo.rework }}</el-tag>
             </el-descriptions-item>
             <el-descriptions-item label="工单出站">{{
               productReviewInfo.outNum
@@ -48,9 +52,11 @@
             <el-descriptions-item label="交付日期">{{
               productReviewInfo.planStartEnd
             }}</el-descriptions-item>
-            <el-descriptions-item label="工单报故">
-              <el-tag size="small">{{productReviewInfo.bug}}</el-tag>
-            </el-descriptions-item>
+            <el-descriptions-item label="工单报故"
+              ><el-tag size="small">{{
+                productReviewInfo.bug
+              }}</el-tag></el-descriptions-item
+            >
           </el-descriptions>
         </el-header>
         <el-main>
@@ -151,6 +157,19 @@
               </template>
               <media-com ref="mediaComRef"
             /></el-tab-pane>
+            <el-tab-pane name="excelComRef" label="表格数据"
+              ><template #label>
+                <span
+                  >表格数据
+                  <el-badge
+                    :value="tabCount.excel"
+                    class="item"
+                    type="primary"
+                  />
+                </span>
+              </template>
+              <ExcelCom ref="excelComRef"
+            /></el-tab-pane>
           </el-tabs>
         </el-main>
       </el-container>
@@ -169,6 +188,7 @@ import CheckCom from "@/views/pro/traceability/components/checkCom.vue";
 import EquitCom from "@/views/pro/traceability/components/equitCom.vue";
 import FaultCom from "@/views/pro/traceability/components/faultCom.vue";
 import MediaCom from "./components/mediaCom.vue";
+import ExcelCom from "./components/excelCom.vue";
 
 // 传入一个url,后面不带/
 const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
@@ -176,7 +196,8 @@ const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
     src: "/api/v1/process/web/traceability",
   });
 
-const { dataList, createRow, updateRow, deleteRow, searchChange } = Methords; //增删改查
+const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
+  Methords; //增删改查
 const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
 const { checkBtnPerm } = Utils; //按钮权限等工具
 
@@ -189,6 +210,7 @@ const checkComRef = ref(null);
 const equitComRef = ref(null);
 const faultComRef = ref(null);
 const mediaComRef = ref(null);
+const excelComRef = ref(null);
 let defaultTabName = ref("traceabilityComRef");
 //tab页组件
 const tabNameComRef = new Map([
@@ -199,10 +221,12 @@ const tabNameComRef = new Map([
   ["equitComRef", equitComRef],
   ["faultComRef", faultComRef],
   ["mediaComRef", mediaComRef],
+  ["excelComRef", excelComRef],
 ]);
 let temRow = ref({});
 const tabsEvent = (pane, ev) => {
   defaultTabName.value = pane.props.name;
+  //console.log(pane.props.name, temRow.value.seqNo);
   if (temRow.value.seqNo) {
     tabNameComRef.get(pane.props.name)?.value.refreshTra(temRow.value);
   }
@@ -211,17 +235,11 @@ const tabsEvent = (pane, ev) => {
 const chooseTagType = (row, type) => {
   let daynamicType = "";
   if (type == "text") {
-    daynamicType = row === 'order'
-      ? "订单"
-      : row === 'workOrder'
-        ? "工单"
-        : "流转卡号";
+    daynamicType =
+      row === "order" ? "订单" : row === "workOrder" ? "工单" : "流转卡号";
   } else {
-    daynamicType = row === 'order'
-      ? "success"
-      : row === 'workOrder'
-        ? "warning"
-        : "primary";
+    daynamicType =
+      row === "order" ? "success" : row === "workOrder" ? "warning" : "primary";
   }
   return daynamicType;
 };
@@ -235,7 +253,7 @@ let productReviewInfo = reactive({
   workOrderCode: "",
   outNum: "",
   rework: "-",
-  bug: "-"
+  bug: "-",
 });
 
 let tabCount = reactive({
@@ -246,15 +264,15 @@ let tabCount = reactive({
   equit: "",
   fault: "",
   medias: "",
+  excel: "",
 });
 
 const handleCellClick = (row, column, event) => {
-  productReviewInfo.orderCode = row.orderCode
-  if(row.level === 'order'){
-    productReviewInfo.bug = '-'
+  if (row.level === "order") {
+    productReviewInfo.bug = "-";
   }
-  if(row.orderType){
-    productReviewInfo.rework = row.orderType === '2' ? '是' : '否'
+  if (row.orderType) {
+    productReviewInfo.rework = row.orderType === "2" ? "是" : "否";
   }
   //获取出单的数量
   if (data.value) {
@@ -262,9 +280,9 @@ const handleCellClick = (row, column, event) => {
       if (topTree) {
         for (let secondTree of topTree.children) {
           if (row.workOrderCode == secondTree.workOrderCode) {
-            productReviewInfo.rework = topTree.orderType === '2' ? '是' : '否'
+            productReviewInfo.rework = topTree.orderType === "2" ? "是" : "否";
+            productReviewInfo.bug = secondTree.bugNum === 0 ? "否" : "是";
             productReviewInfo.outNum = secondTree.children.length;
-            productReviewInfo.bug = secondTree.bugNum === 0 ? '否' : '是'
           }
         }
       }
@@ -279,7 +297,10 @@ const handleCellClick = (row, column, event) => {
       tabNameComRef.get(defaultTabName.value)?.value.refreshTra(temRow.value);
     }
     //每次点击都要获取tab页面的数量
-    traceabilityTabCount({workOrderCode: row.workOrderCode, seqNo: row.seqNo }).then(({ data }) => {
+    traceabilityTabCount({
+      seqNo: row.seqNo,
+      workOrderCode: row.workOrderCode,
+    }).then(({ data }) => {
       tabCount = Object.assign(tabCount, data);
     });
     if (row.workOrderCode == productReviewInfo.workOrderCode) {
@@ -287,7 +308,7 @@ const handleCellClick = (row, column, event) => {
       return;
     }
     //产品信息
-    getMaterialDetailsByseqNo(row.workOrderCode,row.seqNo).then(({ data }) => {
+    getMaterialDetailsByseqNo(row.workOrderCode, row.seqNo).then(({ data }) => {
       productReviewInfo = Object.assign(productReviewInfo, data);
       productReviewInfo.workOrderCode = row.workOrderCode;
       // productReviewInfo.outNum =