Parcourir la source

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

lupeng il y a 10 mois
Parent
commit
7d8520f8b7

+ 2 - 4
src/api/station/types.ts

@@ -5,7 +5,7 @@
  */
 
 export interface Station {
-  id?:number;
+  id?: number;
   //工位编码
   code?: string;
   //上级产线编码
@@ -13,10 +13,8 @@ export interface Station {
 
   //是否启用
   enable?: string;
-
 }
 
-
 /**
  *
  * 工位绑定设备参数
@@ -27,5 +25,5 @@ export interface StationDevice {
   //工位id
   stationId?: number;
   //设备编号
-  deviceNo?: string;
+  deviceNos?: string[];
 }

+ 6 - 0
src/components/CommonTable/index.vue

@@ -49,6 +49,11 @@ const props = defineProps({
     default: false,
     type: Boolean,
   },
+  // 用于多选的返回值
+  multipleKey: {
+    default: "id",
+    type: String,
+  },
 });
 
 const isShowTable = ref(false);
@@ -96,6 +101,7 @@ const {
   commonConfig,
 } = useCrud({
   src: tableConfig[props.tableType].url,
+  multipleSelectKey: props.multipleKey,
 });
 const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
   Methords; //增删改查

+ 20 - 13
src/hooks/userCrud.ts

@@ -23,6 +23,8 @@ interface UseCrudConfig {
   params?: object;
   // 是否是编辑,如果是编辑调用更新,否则调用新增
   isEdit?: boolean;
+  //   用于多选选中后添加进入,toDeleteIds中的key值。
+  multipleSelectKey?: string;
 }
 
 export const useCrud = (config?: UseCrudConfig) => {
@@ -54,7 +56,7 @@ export const useCrud = (config?: UseCrudConfig) => {
   });
   /** 配置项结构 v-model */
   // defaults ?: AvueCrudDefaults;
-
+  // 多选返回的数组,命名是因为后来增加了很多功能,现在这个数组里面的值是根据multipleSelectKey来决定
   const toDeleteIds = ref<Array<string>>([]);
 
   const save = async (config?: UseCrudConfig) => {
@@ -102,7 +104,7 @@ export const useCrud = (config?: UseCrudConfig) => {
       handleSearchData();
       try {
         const res = await request({
-          url: commonConfig.value.dataListUrl ?? `${url.value}/page`,
+          url: commonConfig.value?.dataListUrl ?? `${url.value}/page`,
           method: "post",
           data: {
             pageNo: page.value.currentPage,
@@ -141,22 +143,25 @@ export const useCrud = (config?: UseCrudConfig) => {
           },
         });
         if (res?.data) {
-          if(res?.data instanceof Array){
-            data.value = res?.data || []
-            page.value.total = res?.data?.length || 0
-          }else{
+          if (res?.data instanceof Array) {
+            data.value = res?.data || [];
+            page.value.total = res?.data?.length || 0;
+          } else {
             data.value = res?.data?.records || [];
             for (let i = 0; i < data.value.length; i++) {
               data.value[i].$cellEdit = true;
-              if(data.value[i].children!=undefined&&data.value[i].children!=null&&data.value[i].children.length > 0 ){
-                for(let j=0;j < data.value[i].children.length; j++){
+              if (
+                data.value[i].children != undefined &&
+                data.value[i].children != null &&
+                data.value[i].children.length > 0
+              ) {
+                for (let j = 0; j < data.value[i].children.length; j++) {
                   data.value[i].children[j].$cellEdit = true;
                 }
               }
             }
             page.value.total = res?.data?.totalCount || 0;
           }
-
         }
         config?.done && config?.done();
       } catch (err) {
@@ -211,9 +216,9 @@ export const useCrud = (config?: UseCrudConfig) => {
         cancelButtonText: "取消",
         type: "warning",
       }).then(async () => {
-        if(row.children && row.children.length > 0 ){
-          ElMessage.error("请先解绑下级关系")
-          return
+        if (row.children && row.children.length > 0) {
+          ElMessage.error("请先解绑下级关系");
+          return;
         }
         try {
           const res = await request({
@@ -235,7 +240,9 @@ export const useCrud = (config?: UseCrudConfig) => {
     selectionChange: (rows?: any[]) => {
       toDeleteIds.value = [];
       rows?.forEach((element) => {
-        toDeleteIds.value.push(element.id);
+        toDeleteIds.value.push(
+          element[commonConfig.value?.multipleSelectKey ?? "id"]
+        );
       });
     },
 

+ 5 - 5
src/layout/components/TagsView/index.vue

@@ -14,7 +14,7 @@
         @click.middle="!isAffix(tag) ? closeSelectedTag(tag) : ''"
         @contextmenu.prevent="openContentMenu(tag, $event)"
       >
-        {{ setTitle(translateRouteTitle(tag.title)) }}
+        {{ translateRouteTitle(setTitle(tag)) }}
         <i-ep-close
           class="close-icon"
           size="12px"
@@ -79,12 +79,12 @@ const tagsViewStore = useTagsViewStore();
 const appStore = useAppStore();
 const { visitedViews } = storeToRefs(tagsViewStore);
 //针对动态路由形成的新tags增加区别提示
-const setTitle = (title: any) => {
-  if (route.name == "processCom/:id/:prodtCode/:operationId") {
-    let newStr = title + ":工序ID" + route.fullPath.split("/")[4];
+const setTitle = (tag: any) => {
+  if (tag.name == "processCom/:id/:prodtCode/:operationId") {
+    let newStr = tag.title + ":工序ID" + tag.fullPath.split("/")[4];
     return newStr;
   } else {
-    return title;
+    return tag.title;
   }
 };
 

+ 17 - 17
src/views/base/craftManagement/route/components/setExcel/index.vue

@@ -29,7 +29,7 @@
           type="primary"
           @click="editDialog.visible = true"
           style="margin-bottom: 15px"
-          >新增 / 编辑</el-button
+          >编辑</el-button
         >
       </template>
       <template #menu="{ row, index, type }">
@@ -110,12 +110,12 @@ const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
   useCrud({
     src: "/api/v1/opExcelForm",
   });
-// const setValue1 = () => {
-//   value1.value = [];
-//   data.value.forEach((el) => {
-//     value1.value.push(el.id);
-//   });
-// };
+const setValue1 = () => {
+  value1.value = [];
+  data.value.forEach((el) => {
+    value1.value.push(el.formCode);
+  });
+};
 search.value = { ...search.value, operationId: route.fullPath.split("/")[4] };
 const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
   Methords; //增删改查
@@ -129,7 +129,7 @@ const getTemplate = async () => {
     pageNo: 1,
     pageSize: 9999999,
     formType: 0,
-    state: 2
+    state: 2,
   });
   options.value = [];
   data.records.forEach((element) => {
@@ -143,15 +143,15 @@ onMounted(() => {
   getTemplate();
   dataList();
 });
-// watch(
-//   () => data.value,
-//   (val) => {
-//     setValue1();
-//   },
-//   {
-//     immediately: true,
-//   }
-// );
+watch(
+  () => data.value,
+  (val) => {
+    setValue1();
+  },
+  {
+    immediately: true,
+  }
+);
 
 option.value = Object.assign(option.value, {
   selection: false,

+ 3 - 0
src/views/base/craftManagement/route/index.vue

@@ -308,6 +308,9 @@ option.value = Object.assign(option.value, {
         },
       ],
       readOnly: true,
+      click: () => {
+        startChooseProduct();
+      },
     },
     {
       label: "产品编号",

+ 3 - 4
src/views/base/modeling/station/components/station-page.vue

@@ -35,6 +35,7 @@
       tableTitle="设备列表"
       tableType="DEVICE"
       :multiple="true"
+      multipleKey="deviceNo"
       @select-multiple-sure="onSelectedFinish"
     />
   </div>
@@ -99,10 +100,8 @@ option.value = Object.assign(option.value, {
 });
 const props = defineProps({
   stationId: {
-    type: Number,
-    default: () => {
-      return 0;
-    },
+    type: String,
+    default: "",
   },
 });
 

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

@@ -65,11 +65,19 @@ 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 = () => {

+ 89 - 40
src/views/pro/traceability/components/traceabilityCom.vue

@@ -11,10 +11,10 @@
       v-model:page="page"
     />
     <CommonTable
-        ref="userRef"
-        tableTitle="操作人选择"
-        tableType="USERS"
-        @selected-sure="onUserSelectedFinish"
+      ref="userRef"
+      tableTitle="操作人选择"
+      tableType="USERS"
+      @selected-sure="onUserSelectedFinish"
     />
   </div>
 </template>
@@ -23,7 +23,11 @@ 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 {
+  useCommonStoreHook,
+  useDictionaryStore,
+  useUserStoreHook,
+} from "@/store";
 
 // 数据字典相关
 const { dicts } = useDictionaryStore();
@@ -43,26 +47,25 @@ const {
 } = useCrud({
   src: "/api/v1/process/info",
 });
-const { dataList,createRow, updateRow, deleteRow, searchChange, resetChange } =
+const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
   Methords; //增删改查
 const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
 const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
-const onUserSelectedFinish = (selectedValue)=>{
+const onUserSelectedFinish = (selectedValue) => {
   form.value.operator = selectedValue.userName;
-}
+};
 const crudRef = ref(null); //crudRef.value 获取avue-crud对象
 const userRef = ref(null);
 const refreshTra = (row) => {
   commonConfig.value.params = { seqNo: row.seqNo };
-    dataList();
+  dataList();
 };
 defineExpose({ refreshTra });
 onMounted(() => {
-    if(userStore.user.userId===10000){
-        option.value.menu=true;
-        option.value.editBtn=true;
-
-    }
+  if (userStore.user.userId === 10000) {
+    option.value.menu = true;
+    option.value.editBtn = true;
+  }
 });
 
 option.value = Object.assign(option.value, {
@@ -74,30 +77,30 @@ option.value = Object.assign(option.value, {
   align: "center",
   labelWidth: 100,
   addBtn: false,
-    delBtn:false,
-    menuWidth:100,
-    editBtn: false,
-    viewBtn:false,
-    menu:false,
+  delBtn: false,
+  menuWidth: 100,
+  editBtn: false,
+  viewBtn: false,
+  menu: false,
   header: false,
   column: [
     {
       label: "生产过程id",
       prop: "id",
-      display : false,
-      hide:true,
-      width:120,
+      display: false,
+      hide: true,
+      width: 120,
     },
     {
       label: "工序名称",
       prop: "operationName",
-        editDisplay : false,
-        width:120,
+      editDisplay: false,
+      width: 120,
     },
     {
       label: "工段",
       prop: "workSection",
-        editDisplay : false,
+      editDisplay: false,
       type: "select",
       dicData: dicts.workshop_section,
       props: {
@@ -107,7 +110,7 @@ option.value = Object.assign(option.value, {
     },
     {
       label: "状态",
-        editDisplay : false,
+      editDisplay: false,
       prop: "currentState",
       search: false,
       dicData: dicts.process_state,
@@ -120,43 +123,89 @@ option.value = Object.assign(option.value, {
       label: "开始时间",
       prop: "realStartWhen",
       search: false,
-        format: 'YYYY-MM-DD HH:mm:ss',
-        valueFormat: 'YYYY-MM-DD HH:mm:ss',
-        width:160,
-        type:"datetime",
+      format: "YYYY-MM-DD HH:mm:ss",
+      valueFormat: "YYYY-MM-DD HH:mm:ss",
+      width: 160,
+      type: "datetime",
+      rules: [
+        {
+          validator: (rule, value, callback) => {
+            if (value == null || form.value.realEndWhen == null) {
+              callback();
+            } else if (
+              new Date(value).getTime() <=
+              new Date(form.value.realEndWhen).getTime()
+            ) {
+              callback();
+            } else {
+              callback(new Error("开始时间应小于等于结束时间"));
+            }
+          },
+          message: "开始时间应小于等于结束时间",
+          required: true,
+          trigger: "change",
+        },
+      ],
     },
     {
       label: "结束时间",
       prop: "realEndWhen",
-      search: false,
-        format: 'YYYY-MM-DD HH:mm:ss',
-        valueFormat: 'YYYY-MM-DD HH:mm:ss',
-        width:160,
-        type:"datetime",
+      format: "YYYY-MM-DD HH:mm:ss",
+      valueFormat: "YYYY-MM-DD HH:mm:ss",
+      width: 160,
+      type: "datetime",
+      rules: [
+        {
+          validator: (rule, value, callback) => {
+            if (value == null || form.value.realStartWhen == null) {
+              callback();
+            } else if (
+              new Date(value).getTime() >=
+              new Date(form.value.realStartWhen).getTime()
+            ) {
+              callback();
+            } else {
+              callback(new Error("\结束时间应大于等于结束时间"));
+            }
+          },
+          required: true,
+          message: "结束时间应大于等于开始时间",
+          trigger: "change",
+        },
+      ],
     },
     {
       label: "操作人",
       prop: "operator",
       search: false,
-      width:100,
-      overHidden:true,
+      width: 100,
+      overHidden: true,
       click: ({ value, column }) => {
         userRef.value.startSelect();
       },
-
     },
     {
       label: "工时(秒)",
       prop: "totalTime",
-        editDisplay : false,
+      editDisplay: false,
       search: false,
     },
     {
       label: "工步",
       prop: "operationSort",
-        editDisplay : false,
+      editDisplay: false,
       search: false,
     },
   ],
 });
+
+// const validateTimeEnd = (rule, value, callback) => {
+//   if (value === "") {
+//     callback(new Error("Please input the password again"));
+//   } else if (value !== ruleForm.pass) {
+//     callback(new Error("Two inputs don't match!"));
+//   } else {
+//     callback();
+//   }
+// };
 </script>

+ 1 - 2
src/views/pro/traceability/components/updateExcel.vue

@@ -70,7 +70,7 @@ const useAddTemplateHook = () => {
     //导入按钮展示
     in: true,
     //导出按钮展示
-    out: false,
+    out: true,
     print: true,
     //编辑状态 false:为查看状态
     edit: true,
@@ -320,7 +320,6 @@ watch(
   () => {
     //@ts-ignore
     rowData.value = props.data;
-   
     exceldata.value = JSON.parse(rowData.value.writeData);
     excelKey1.value = !excelKey1.value;
     if (rowData.value.lookStatus == true) {