Ben Lin
2024-08-21 ccebd227e4f3bfaab7a27c5b8dcc55b642a4006b
src/views/tigerprojects/mes/prod/biz_mes_wo/index.vue
@@ -4,7 +4,7 @@
 * @version: 
 * @Date: 2024-05-25 00:27:00
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-07-03 20:51:05
 * @LastEditTime: 2024-07-21 18:07:27
-->
<template>
  <div>
@@ -32,6 +32,7 @@
              icon: 'clarity:note-edit-line',
              tooltip: '修改',
              onClick: handleEdit.bind(null, record),
              name: undefined
            },
            {
              icon: 'ant-design:delete-outlined',
@@ -42,27 +43,30 @@
                placement: 'left',
                confirm: handleDelete.bind(null, record),
              },
              name: undefined
            },
            {
              icon: 'config|svg',
              tooltip: '配置工艺',
              onClick: handleConfig.bind(null, record),
              name: undefined
            },
            {
              icon: 'release|svg',
              tooltip: '下发',
              onClick: handleRelease.bind(null, record),
              name: undefined
            },
            {
              icon: 'unrelease|svg',
              tooltip: '取消下发',
              onClick: handleUnRelease.bind(null, record),
            },
            {
              icon: 'suspend-blue|svg',
              tooltip: '暂停',
              onClick: handlePause.bind(null, record),
            },
            // {
            //   icon: 'unrelease|svg',
            //   tooltip: '取消下发',
            //   onClick: handleUnRelease.bind(null, record),
            // },
            // {
            //   icon: 'suspend-blue|svg',
            //   tooltip: '暂停',
            //   onClick: handlePause.bind(null, record),
            // },
          ]"
        />
      </template>
@@ -70,37 +74,41 @@
    <Loading :loading="compState.loading" :tip="compState.tip" />
    <WoDrawer @register="registerDrawer" @success="handleSuccess" />
    <WoModal @register="registerWo" @success="handleSuccess" :title="title" :mtitle="mtitle" />
    <!-- 自定义模态框,可以自定义多表单 -->
    <CustModal
      @register="registerCust"
      @success="custSuccess"
      :type="cType"
      :detailSlots="dtlSlots"
    >
      <!-- 用插槽自定义多表单 -->
      <template #[item.name] v-for="item in dtlSlots" :key="item.name">
        <BasicForm @register="useFormData[item.name][0]" v-if="useFormData[item.name]">
          <!-- 用插槽自定义弹出选择框 -->
          <template #[name]="{ field }" v-for="name in item.slots" :key="name">
            <a-button
              class="mt-1 ml-1"
              size="small"
              @click="handleCustClick(field)"
              :preIcon="item.preIcons[name]"
            />
            <GeneralModal
              @register="useModalData[name][0]"
              @success="(d, u) => handleEntSuccess(d, u, item.name)"
            />
          </template>
        </BasicForm>
        <!-- 自定义内容 -->
        <!-- <div style="height: 200px" id="lfContainer" v-if="isCustEl[item.name]"></div> -->
        <div class="h-full" style="height: 380px" v-if="isCustEl[item.name]">
          <FlowChartView :data="routeData" @init="init" />
        </div>
      </template>
    </CustModal>
    <Suspense>
      <!-- 自定义模态框,可以自定义多表单 -->
      <CustModal
        @register="registerCust"
        @success="custSuccess"
        :type="cType"
        :detailSlots="dtlSlots"
        :entityName="entityName"
      >
        <!-- 用插槽自定义多表单 -->
        <template #[item.name] v-for="item in dtlSlots" :key="item.name">
          <BasicForm @register="useFormData[item.name][0]" v-if="useFormData[item.name]">
            <!-- 用插槽自定义弹出选择框 -->
            <template #[name]="{ field }" v-for="name in item.slots" :key="name">
              <a-button
                class="mt-1 ml-1"
                size="small"
                @click="handleCustClick(field)"
                :preIcon="item.preIcons[name]"
              />
              <GeneralModal
                @register="useModalData[name][0]"
                @success="(d, u) => handleEntSuccess(d, u, item.name)"
              />
            </template>
          </BasicForm>
          <!-- 自定义内容 -->
          <!-- <div style="height: 200px" id="lfContainer" v-if="isCustEl[item.name]"></div> -->
          <div class="h-full" style="height: 380px" v-if="isCustEl[item.name]">
            <FlowChartView :data="routeData" @init="init" />
          </div>
        </template>
      </CustModal>
      <!-- <template #fallback> Loading... </template> -->
    </Suspense>
    <RouteViewModal @register="registerRv" @success="RvItemSuccess" />
  </div>
</template>
@@ -126,6 +134,8 @@
  import { GetSelectSuccess, OpenSelectItem, getFormSchema } from '/@/views/components/data';
  import LogicFlow from '@logicflow/core';
  import { initRoute } from '../../../system/lowcode/data';
  import BIZ_MES_WO from '../../../system/lowcode/entityts/BIZ_MES_WO';
  import { useUserStore } from '/@/store/modules/user';
  const { t } = useI18n();
  const ASteps = Steps;
@@ -150,6 +160,15 @@
  const [registerTable, { getForm, reload }] = useTable({
    title: '工单信息',
    api: getListByPage,
    searchInfo: {
      TABLE_NAME: 'BIZ_MES_WO',
      option: {
        //根据据点查询,必需带这个参数
        UserId: useUserStore().getUserInfo.userId,
        ByOrg: true,
        CurOrg: useUserStore().getUserInfo.orgCode,
      },
    },
    columns,
    formConfig: {
      labelWidth: 120,
@@ -172,6 +191,7 @@
    nodes: [],
    edges: [],
  });
  const entityName = ref('BIZ_MES_WO');
  const formSchema = ref([] as FormSchema[]);
  const woSchema = ref<FormSchema[]>(getFormSchema('woinfo'));
  const prodSchema = ref<FormSchema[]>(getFormSchema('prodinfo'));
@@ -188,41 +208,10 @@
    addRot: useModal(),
    setRot: useModal(),
  });
  //自定义多表单实例
  const useFormData = ref({
    forminfo: useForm({
      labelWidth: 120,
      schemas: formSchema,
      actionColOptions: {
        span: 24,
      },
      showActionButtonGroup: false,
    }),
    woinfo: useForm({
      labelWidth: 120,
      schemas: woSchema,
      actionColOptions: {
        span: 24,
      },
      showActionButtonGroup: false,
    }),
    prodinfo: useForm({
      labelWidth: 120,
      schemas: prodSchema,
      actionColOptions: {
        span: 24,
      },
      showActionButtonGroup: false,
    }),
    // rotinfo: useForm({
    //   labelWidth: 120,
    //   schemas: rotSchema,
    //   actionColOptions: {
    //     span: 24,
    //   },
    //   showActionButtonGroup: false,
    // }),
  });
  /* 获取多表单实例 */
  const [{ GetUseForm }] = BIZ_MES_WO();
  const useFormData = ref<any>(GetUseForm());
  onMounted(async () => {});
@@ -287,9 +276,9 @@
      formEl: useFormData.value, //如果是多个表单,增加多个插槽
      formElName: ['woinfo', 'prodinfo', 'rotinfo'], //表单插槽名称,支持多个表单
      RowKey: '',
      fnName: { BIZ_MES_WO_Config: 'SaveCofig' }, //保存方法名
      initFnName: { BIZ_MES_WO_Config: 'initRoute' }, //初始化方法名
      isCustEl: isCustEl.value,
      fnName: 'SaveCofig', //保存方法名
      // initFnName: { BIZ_MES_WO_Config: 'initRoute' }, //初始化方法名
      // isCustEl: isCustEl.value,
      others: routeData.value,
      values: record, //表单记录
    });
@@ -301,14 +290,14 @@
   * @return {*}
   */
  function handleRelease(record: Recordable) {
    if (record.STATUS == 2) {
      createErrorModal({
        title: t('警告'),
        content: t('工单已经下发,不能再下发!'),
        getContainer: () => document.body,
      });
      return;
    }
    // if (record.STATUS == 2) {
    //   createErrorModal({
    //     title: t('警告'),
    //     content: t('工单已经下发,不能再下发!'),
    //     getContainer: () => document.body,
    //   });
    //   return;
    // }
    cType.value = 'BIZ_MES_WO';
    dtlSlots.value = [
      {
@@ -318,7 +307,7 @@
        title: '下发配置',
      },
    ];
    formSchema.value = getFormSchema(cType.value);
    // formSchema.value = getFormSchema(cType.value);
    openCustModal(true, {
      isUpdate: true, //是否更新操作
      ctype: cType, //是哪个页面
@@ -327,8 +316,8 @@
      formEl: useFormData.value,
      formElName: ['forminfo'], //表单插槽名称
      RowKeys: { add: 'ROUTE_CODE', set: 'ROUTE_CODE' }, //插槽的弹出框选择的code
      fnName: { BIZ_MES_WO: 'SaveWoBatch' }, //保存方法名
      initFnName: {}, //初始化方法名
      fnName: 'SaveWoBatch', //保存方法名
      initFnName: {}, //初始化方法名,没有就留空{}
      isCustEl: isCustEl.value,
      values: record, //表单记录
    });
@@ -474,7 +463,9 @@
    var values = GetSelectSuccess(d, u, cType.value);
    selectVals.value = values; //保存弹出框选择的结果
    let _val = {};
    _val[d.returnFieldName] = values[d.returnFieldName];
    d.returnFieldName.map((x) => {
          _val[x] = values[x];
        });
    useFormData.value[item][1].setFieldsValue(_val);
    if (d.returnFieldName == 'ROUTE_CODE' && cType.value == 'BIZ_MES_WO_Config') {
      routeData.value = {
@@ -503,8 +494,8 @@
      selectVals.value['ROUTE_CODE'],
    ); //[openRvModal], selectVals.value['ID']这是自定义参数,按实际需求
  }
  function RvItemSuccess(d, u) {
    closeModal();
    }
  }
</script>