Ben Lin
2024-10-17 07895c65b99fa43f8e54f5054bd8351a71158143
工艺路线绑定优化
已修改7个文件
125 ■■■■■ 文件已修改
src/api/tigerapi/system.ts 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/modules/prodRoute.ts 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/components/GeneralCrudModal.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/components/GeneralModal.vue 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/tigerprojects/system/lowcode/composition/Config.vue 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/tigerprojects/system/lowcode/entityts/ProdRouteBinding.ts 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/tigerprojects/system/lowcode/entityts/WoRouteBinding.ts 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/tigerapi/system.ts
@@ -316,7 +316,7 @@
 * @param {string} childId
 * @return {*}
 */
export function findParent(tree: any[], nodeId: number): any | undefined {
export function findParent(tree: any[], nodeId: string): any | undefined {
  for (const node of tree) {
      if (node.children) {
          for (const child of node.children) {
src/store/modules/prodRoute.ts
@@ -4,7 +4,7 @@
 * @version:
 * @Date: 2024-06-18 15:09:47
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-10-16 00:41:53
 * @LastEditTime: 2024-10-17 14:43:28
 */
import { defineStore } from 'pinia';
import { store } from '@/store';
@@ -15,25 +15,27 @@
interface ProdRouteState {
  curProdRotTree: MesRotTree[];
  curPkgConfig: any;
  curConfig: any;
  curSelectedNodes: any;
  ItemCode: string;
  curDtl: any
}
export const useProdRouteStore = defineStore({
  id: 'app-prodrot',
  state: (): ProdRouteState => ({
    curProdRotTree: [],
    curPkgConfig: {},
    curConfig: {},
    curSelectedNodes: {},
    ItemCode: ''
    ItemCode: '',
    curDtl: {}
  }),
  getters: {
    getCurProdRotTree(state): MesRotTree[] {
      return state.curProdRotTree;
    },
    getCurPkgConfig(state): any {
      return state.curPkgConfig;
    getCurConfig(state): any {
      return state.curConfig;
    },
    getCurSelectedNodes(state): any {
      return state.curSelectedNodes;
@@ -41,10 +43,13 @@
    getItemCodes(state): string {
      return state.ItemCode;
    },
    getcurDtl(state): any {
      return state.curDtl;
    },
  },
  actions: {
    setCurPkgConfig(val: any) {
      this.curPkgConfig = val;
      this.curConfig = val;
    },
    setCurProdRotTree(info: MesRotTree[]) {
      this.curProdRotTree = info;
@@ -55,10 +60,14 @@
    setItemCode(val: string) {
      this.ItemCode = val;
    },
    setcurDtl(val: any) {
      this.curDtl = val;
    },
    resetState() {
      this.curProdRotTree = [];
      this.curPkgConfig = {};
      this.curConfig = {};
      this.curSelectedNodes = {};
      this.curDtl = {};
    },
    /**
     * @description: 设置默认工艺路线
@@ -99,7 +108,7 @@
     * @return {*}
     */    
    getParent(tid: string): MesRotTree{
      return findParent(this.getCurProdRotTree,tid) as unknown as MesRotTree;
      return findParent(this.getCurProdRotTree, tid) as unknown as MesRotTree;
    }
  },
});
src/views/components/GeneralCrudModal.vue
@@ -1,7 +1,7 @@
<template>
  <BasicModal
    :width="width"
    :height="650"
    :height="750"
    v-bind="$attrs"
    @register="register"
    :title="title"
src/views/components/GeneralModal.vue
@@ -1,7 +1,7 @@
<template>
  <BasicModal
    width="800px"
    :height="600"
    :height="450"
    v-bind="$attrs"
    @register="register"
    :title="title"
@@ -53,6 +53,8 @@
    },
    useSearchForm: true,
    showTableSetting: false,
    scroll: { y: 350 },
    canResize: false,
    rowKey: rowKey,
    rowSelection: {
      selectedRowKeys: checkedKeys.value,
@@ -70,13 +72,6 @@
    },
    bordered: true,
    showIndexColumn: false,
    // actionColumn: {
    //   width: 80,
    //   title: '操作',
    //   dataIndex: 'action',
    //   slots: { customRender: 'action' },
    //   fixed: 'right' //undefined,
    // },
  });
  const [register, { setModalProps, closeModal }] = useModalInner((data) => {
    setModalProps({ confirmLoading: false });
src/views/tigerprojects/system/lowcode/composition/Config.vue
@@ -4,7 +4,7 @@
 * @version: 
 * @Date: 2024-06-24 23:44:31
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-09-29 16:23:30
 * @LastEditTime: 2024-10-17 20:28:47
-->
<template>
  <Card :title="GetTitle(configType)['configTitle']">
@@ -34,16 +34,18 @@
  <Card
    :title="GetTitle(configType, item)['tableTitle']"
    :bordered="false"
    class="!mt-5"
    v-for="item in OtherTables"
    :key="item"
    v-show="showOtherTable[item]"
    class="mt-1"
  >
  <div :style="custTableStyle" >
    <BasicTable @register="useTables[item][0]" v-if="showOtherTable[item]">
      <template #action="{ record }">
        <TableAction :actions="createActions(record, item)" />
      </template>
    </BasicTable>
  </div>
    <normalDrawer @register="useDrawers[item][0]" @success="(d, u) => EditSuccess(d, u, item)" />
    <GeneralCrudModal @register="useModalsCrud[item][0]"></GeneralCrudModal>
  </Card>
@@ -62,6 +64,8 @@
  import { useDrawer } from '/@/components/Drawer';
  import normalDrawer from '../normalDrawer.vue';
  import { useModal } from '/@/components/Modal';
  import { useProdRouteStore } from '/@/store/modules/prodRoute';
  import { storeToRefs } from 'pinia';
  const { t } = useI18n();
  const emit = defineEmits(['success', 'register']);
@@ -113,10 +117,11 @@
  ] = isNullOrUnDef(custImport.value['default'])
    ? EntityCustFunction.value
    : custImport.value['default']();
  const useProdRoute = useProdRouteStore();
  const { curDtl } = storeToRefs(useProdRoute);
  const useModalData = ref(GetUseModals());
  const data = ref({});
  const useTables = ref(GetUseTables(data, emit));
  // const data = ref({});
  const useTables = ref(GetUseTables(curDtl, emit));
  const useForms = ref(GetUseForm());
  const useDrawers = ref({});
  const useModalsCrud = ref({});
@@ -127,6 +132,9 @@
    showOtherTable.value[x] = false;
    useDrawers.value[x] = useDrawer();
    useModalsCrud.value[x] = useModal();
  });
  const custTableStyle = ref({
    height: window.screen.width == 1366? '350px': '450px'
  });
  /* 注入选中节点数据 */
@@ -150,9 +158,9 @@
            const name = result['name'];
            if (showOtherTable.value[name]) {
              showOtherTable.value[name] = false;
              data.value[name] = result[name];
              data.value['Action'] = result['Action'];
              useTables.value = GetUseTables(data, emit);
              // data.value[name] = curDtl.value[name]; //result[name];
              // data.value['Action'] = curDtl.value['Action']; //result['Action'];
              useTables.value = GetUseTables(curDtl, emit);
              setTimeout(() => {
                showOtherTable.value[name] = true;
              }, 10);
@@ -180,10 +188,10 @@
    const nodes = selectedNodes.value;
    nodeChange({ useForms, objParams, selectedNodes: nodes }).then((result) => {
      showOtherTable.value = result.isShow;
      data.value[configType.value as string] = result[configType.value as string];
      useTables.value = GetUseTables(data, emit);
      if (showOtherTable.value[result['name']]) {
        data.value[result['name']] = result[result['name']];
      // data.value[configType.value as string] = curDtl.value[configType.value as string]; //result[configType.value as string];
      useTables.value = GetUseTables(curDtl, emit);
      if (showOtherTable.value[curDtl.value['name']]) {
        // curDtl.value[result['name']] = curDtl.value[result['name']];
        // useTables.value[result['name']][1].setProps({
        //   dataSource: [],
        // });
@@ -263,7 +271,7 @@
      CustFunc({
        ctype: item,
        values: d,
        data: data,
        data: curDtl,
      }).then(() => {
        /* 显示其他表格 */
        if (showOtherTable.value[item]) {
@@ -271,12 +279,12 @@
          setTimeout(() => {
            showOtherTable.value[item] = true;
          }, 10);
          useTables.value = GetUseTables(data, emit);
          useTables.value = GetUseTables(curDtl, emit);
          setTimeout(() => {
            useTables.value[item][1].reload();
            useForms.value[configType.value as string][1].resetFields();
            useForms.value[configType.value as string][1].setFieldsValue(
              data.value[configType.value as string][0],
              curDtl.value[configType.value as string][0],
            );
          }, 10);
        }
@@ -311,17 +319,17 @@
  function SelectInFormSuccess(d, u, item) {
    GetSelectSuccess(d, u, item).then((result) => {
      useForms.value[configType.value][1].setFieldsValue(result['value']);
      if (!isNullOrUnDef(data.value[configType.value as string])) {
        data.value[configType.value as string].map((x) => {
      if (!isNullOrUnDef(curDtl.value[configType.value as string])) {
        curDtl.value[configType.value as string].map((x) => {
          Object.getOwnPropertyNames(result['value']).forEach((key) => {
            x[key] = result['value'][key];
          });
        });
      }
      showOtherTable.value = result['isShow'];
      data.value[result.name] = result['data'];
      curDtl.value[result.name] = result['data'];
      /* 重新useTable,否则数据不刷新 */
      useTables.value = GetUseTables(data, emit);
      useTables.value = GetUseTables(curDtl, emit);
      if (showOtherTable.value[result.name]) {
        showOtherTable.value[result.name] = false;
        setTimeout(() => {
src/views/tigerprojects/system/lowcode/entityts/ProdRouteBinding.ts
@@ -4,7 +4,7 @@
 * @version:
 * @Date: 2024-06-19 20:34:27
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-10-16 00:10:37
 * @LastEditTime: 2024-10-17 20:56:33
 */
import { Ref, h, ref, render, unref } from 'vue';
@@ -274,6 +274,7 @@
              ItemCode: false,
            };
          }
          useProdRoute.setcurDtl(result);
          resolve(result);
        } catch (e) {
          reject(e);
@@ -296,6 +297,9 @@
        }
        values.AUTH_ORG = useUserStore().getUserInfo.orgCode;
        values.AUTH_PROD = useUserStore().getUserInfo.prodCode;
        if(type == 'Action'){
          values.OPTION_1 = JSON.stringify(useProdRoute.getcurDtl['BAS_PKG_DTL'])
        }
        SaveEntity(values, true, entityName).then((action) => {
          if (action.IsSuccessed) {
            emit('success');
@@ -512,11 +516,13 @@
          // searchInfo: { TABLE_NAME: 'V_BAS_PKG_DTL' },
          dataSource: data.value['BAS_PKG_DTL'],
          columns: GetBaseColumns('BAS_PKG_DTL', args[0], data),
          maxHeight: 520,
          // maxHeight: 520,
          // scroll: { y: window.screen.width == 1366? 400: 450 },
          isCanResizeParent: true,
          useSearchForm: false,
          showTableSetting: false,
          bordered: true,
          canResize: true,
          // canResize: false,
          showIndexColumn: false,
          // rowSelection: {
          //   type: 'radio', //'checkbox'
@@ -1847,8 +1853,8 @@
    {
      title: '默认值',
      dataIndex: 'DEFAULT_VALUE',
      editRow: true,
      editRule: true,
      // editRow: true,
      // editRule: true,
    },
  ] as BasicColumn[];
src/views/tigerprojects/system/lowcode/entityts/WoRouteBinding.ts
@@ -4,7 +4,7 @@
 * @version:
 * @Date: 2024-06-19 20:34:27
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-10-05 16:49:39
 * @LastEditTime: 2024-10-17 21:13:17
 */
import { Ref, h, ref, render, unref } from 'vue';
@@ -28,12 +28,14 @@
import { ContextMenuItem } from '/@/components/TigerTree';
import { AddOrEditLabelVarByWorkOrder, UpdateWoStatus } from '/@/api/tigerapi/mes/wo';
import { useForm } from '/@/components/Form';
import { BAS_LABEL_VAR_WO } from '/@/api/tigerapi/model/mesModel';
import { BAS_LABEL_VAR_WO, MesRotTree } from '/@/api/tigerapi/model/mesModel';
import { buildUUID } from '/@/utils/uuid';
import { mesApi } from '/@/api/tigerapi/mes/mesApi';
import { useProdRouteStore } from '/@/store/modules/prodRoute';
const { t } = useI18n();
const { createErrorModal } = useMessage();
const useProdRoute = useProdRouteStore();
const { getLocale } = useLocale();
function _default() {
  /* 定义变量 */
@@ -90,13 +92,7 @@
    fetchTreeData: async (type: string, wo: string) => {
      let data = { title: '', treeData: [] as any[], fieldNames: {} };
      let prodTreeData = await GetWoPTree({ wo: wo });
      // let uniqueArr = prodTreeData.reduce((acc, current) => {
      //   if (!acc.some((x) => x.pid == current.pid && x.id == current.id && x.seq == current.seq && x.type == current.type)) {
      //     acc.push(current);
      //   }
      //   return acc;
      // }, [] as V_MES_ROUTE_PTREE[]);
      data.treeData = convertToTree(prodTreeData, 'pid', 'tid', 'root');
      let _treeData = convertToTree(prodTreeData, 'pid', 'tid', 'root');
      if (data.treeData.length == 0) {
        data.treeData.push({
          pid: 'root',
@@ -110,6 +106,9 @@
      }
      data.title = '工单工艺路线';
      data.fieldNames = { key: 'tid', title: 'name' };
      /* 保存工艺树形数据到状态管理 */
      useProdRoute.setCurProdRotTree(_treeData as unknown as MesRotTree[]);
      data.treeData = useProdRoute.getCurProdRotTree;
      return data;
    },
    /**
@@ -356,6 +355,7 @@
              ItemCode: false,
            };
          }
          useProdRoute.setcurDtl(result);
          resolve(result);
        } catch (e) {
          reject(e);
@@ -377,6 +377,9 @@
      }
      values.AUTH_ORG = useUserStore().getUserInfo.orgCode;
      values.AUTH_PROD = useUserStore().getUserInfo.prodCode;
      if(type == 'Action'){
        values.OPTION_1 = JSON.stringify(useProdRoute.getcurDtl['BAS_PKG_DTL'])
      }
      SaveEntity(values, true, entityName).then((action) => {
        if (action.IsSuccessed) {
          emit('success');