From b4496ad2462843c575a3902c94a87694426f29a3 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期四, 27 六月 2024 16:03:37 +0800 Subject: [PATCH] 产品工艺路线更新 --- src/api/tigerapi/model/router.ts | 1 src/views/components/Step1.vue | 150 +++++++++++ src/views/tigerprojects/system/lowcode/composition/CarGridNav.vue | 69 ++-- src/views/components/StepModal.vue | 122 +++++++++ src/views/tigerprojects/system/lowcode/entityts/ProdRouteBinding.ts | 144 ++++++++--- src/views/tigerprojects/system/lowcode/data.ts | 26 - src/views/components/data.ts | 70 +++++ src/api/tigerapi/model/basModel.ts | 4 src/views/components/Step2.vue | 128 +++++++++ src/views/components/Step3.vue | 31 ++ 10 files changed, 639 insertions(+), 106 deletions(-) diff --git a/src/api/tigerapi/model/basModel.ts b/src/api/tigerapi/model/basModel.ts index f2b418d..a1f5090 100644 --- a/src/api/tigerapi/model/basModel.ts +++ b/src/api/tigerapi/model/basModel.ts @@ -108,6 +108,7 @@ color: string; url: string; action: string; + isStep: boolean; } export type MaterialInfoPageListGetResultModel = BasicFetchResult<MaterialInfoListItem>; @@ -133,5 +134,6 @@ CreateIcon: (params: Recordable<any>) => string; SelectNode: (selectedNodes: Ref<any[]>) => {}; GetNavItems: () => NavItem[]; - naveChangeItem: (action: any, ...args) => void; + navChangeItem: (action: any, ...args) => void; + GetUseModals: () => {}; } diff --git a/src/api/tigerapi/model/router.ts b/src/api/tigerapi/model/router.ts index 72447db..dfb64bf 100644 --- a/src/api/tigerapi/model/router.ts +++ b/src/api/tigerapi/model/router.ts @@ -167,6 +167,7 @@ export interface V_MES_ROUTE_PTREE { pid: string; + tid: string; id: string; code: string; name: string; diff --git a/src/views/components/Step1.vue b/src/views/components/Step1.vue new file mode 100644 index 0000000..657c847 --- /dev/null +++ b/src/views/components/Step1.vue @@ -0,0 +1,150 @@ +<!-- + * @Description: file content + * @Author: Ben Lin + * @version: + * @Date: 2024-06-27 00:25:26 + * @LastEditors: Ben Lin + * @LastEditTime: 2024-06-27 10:58:04 +--> +<template> + <div class="step1"> + <div class="w-120 m-auto"> + <BasicForm @register="register"> + <template #add="{ field }"> + <a-button + v-if="field" + class="mt-1 ml-1" + size="small" + @click="handleSelectItem" + preIcon="search|svg" + /> + <GeneralModal @register="registerItemAdd" @success="handleItemSuccess" /> + </template> + </BasicForm> + <Divider /> + <h3>璇存槑</h3> + <h4>閫夋嫨瀹㈡埛</h4> + <p> 閫夋嫨璇ヤ骇鍝佺殑瀹㈡埛锛屼互渚挎坊鍔犻拡瀵瑰鎴风殑宸ヨ壓璺嚎銆� </p> + </div> + </div> +</template> +<script lang="ts" setup> + import { BasicForm, useForm } from '@/components/Form'; + import { step1Schemas } from './data'; + import GeneralModal from '/@/views/components/GeneralModal.vue'; + import { Select, Input, Divider } from 'ant-design-vue'; + import { useModal } from '/@/components/Modal'; + import { useI18n } from '/@/hooks/web/useI18n'; + + const emit = defineEmits(['next']); + const { t } = useI18n(); + const [registerItemAdd, { openModal: openItemModal }] = useModal(); + const [register, { setFieldsValue, validate }] = useForm({ + labelWidth: 100, + schemas: step1Schemas, + actionColOptions: { + span: 14, + }, + showResetButton: false, + submitButtonOptions: { + text: '涓嬩竴姝�', + }, + submitFunc: customSubmitFunc, + }); + + async function customSubmitFunc() { + try { + const values = await validate(); + emit('next', values); + } catch (error) { + // + } + } + + /** + * @description: 寮瑰嚭閫夋嫨妗� + * @param {*} item + * @return {*} + */ + function handleSelectItem(item) { + openItemModal(true, { + title: '瀹㈡埛鍒楄〃', + schemas: [ + { + field: 'CUST_CODE', + component: 'Input', + label: '瀹㈡埛缂栫爜', + colProps: { + span: 12, + }, + }, + ], + ItemColumns: [ + { + title: t('瀹㈡埛缂栫爜'), + dataIndex: 'CUST_CODE', + resizable: true, + sorter: true, + width: 200, + }, + { + title: t('瀹㈡埛鍚嶇О'), + dataIndex: 'CUST_NAME_CN', + resizable: true, + sorter: true, + width: 180, + }, + ], + tableName: 'BAS_CUSTOMER', + rowKey: 'CUST_CODE', + searchInfo: { TABLE_NAME: 'BAS_CUSTOMER' }, + }); + } + + /** + * @description: 寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庝簨浠� + * @param {*} d + * @param {*} u + * @return {*} + */ + function handleItemSuccess(d, u) { + setFieldsValue({ + CUST_CODE: d.values['val'], + CUST_ID: d.values['id'], + }); + } +</script> +<style lang="less" scoped> + .step1 { + &-form { + width: 450px; + margin: 0 auto; + } + + h3 { + margin: 0 0 12px; + color: @text-color-base; + font-size: 16px; + line-height: 32px; + } + + h4 { + margin: 0 0 4px; + color: @text-color-base; + font-size: 14px; + line-height: 22px; + } + + p { + color: @text-color-base; + } + } + + .pay-select { + width: 20%; + } + + .pay-input { + width: 70%; + } +</style> diff --git a/src/views/components/Step2.vue b/src/views/components/Step2.vue new file mode 100644 index 0000000..58cb3bd --- /dev/null +++ b/src/views/components/Step2.vue @@ -0,0 +1,128 @@ +<template> + <div class="w-120 m-auto"> + <Alert message="纭閫夋嫨浜嗘纭殑瀹㈡埛锛屽鏋滄湁璇彲浠ョ偣涓婁竴姝ラ噸鏂伴�夋嫨銆�" show-icon /> + <BasicForm @register="register"> + <template #add="{ field }"> + <a-button + v-if="field" + class="mt-1 ml-1" + size="small" + @click="handleSelectItem" + preIcon="search|svg" + /> + <GeneralModal @register="registerItemAdd" @success="handleItemSuccess" /> + </template> + </BasicForm> + <Divider /> + <h3>璇存槑</h3> + <h4>娣诲姞宸ヨ壓璺嚎</h4> + <p> 娣诲姞璇ヤ骇鍝佺殑瀹㈡埛鐨勫伐鑹鸿矾绾匡紝閽堝瀹㈡埛鐨勪笉鍚屽伐鑹烘湁鎵�涓嶅悓銆� </p> + </div> +</template> +<script lang="ts" setup> + import { BasicForm, useForm } from '@/components/Form'; + import { step2Schemas } from './data'; + import { Alert, Divider, Descriptions } from 'ant-design-vue'; + import GeneralModal from '/@/views/components/GeneralModal.vue'; + import { useModal } from '/@/components/Modal'; + import { useI18n } from '/@/hooks/web/useI18n'; + + const emit = defineEmits(['next', 'prev']); + const { t } = useI18n(); + const [registerItemAdd, { openModal: openItemModal }] = useModal(); + const [register, { validate, setProps, setFieldsValue }] = useForm({ + labelWidth: 80, + schemas: step2Schemas, + actionColOptions: { + span: 14, + }, + resetButtonOptions: { + text: '涓婁竴姝�', + }, + submitButtonOptions: { + text: '鎻愪氦', + }, + resetFunc: customResetFunc, + submitFunc: customSubmitFunc, + }); + + async function customResetFunc() { + emit('prev'); + } + + async function customSubmitFunc() { + try { + const values = await validate(); + setProps({ + submitButtonOptions: { + loading: true, + }, + }); + setTimeout(() => { + setProps({ + submitButtonOptions: { + loading: false, + }, + }); + emit('next', values); + }, 1500); + } catch (error) { + console.error(error); + } + } + + /** + * @description: 寮瑰嚭閫夋嫨妗� + * @param {*} item + * @return {*} + */ + function handleSelectItem(item) { + openItemModal(true, { + title: '宸ヨ壓璺嚎鍒楄〃', + schemas: [ + { + field: 'ROT_CODE', + component: 'Input', + label: '宸ヨ壓璺嚎缂栫爜', + colProps: { + span: 12, + }, + }, + ], + ItemColumns: [ + { + title: t('宸ヨ壓璺嚎缂栫爜'), + dataIndex: 'ROT_CODE', + resizable: true, + sorter: true, + width: 200, + }, + { + title: t('宸ヨ壓璺嚎鍚嶇О'), + dataIndex: 'ROT_NAME', + resizable: true, + sorter: true, + width: 180, + }, + ], + tableName: 'MES_ROUTE', + rowKey: 'ROT_CODE', + returnFieldName: 'ROUTE_CODE', //杩斿洖鍊艰璧嬪�肩殑瀛楁鍚嶇О + searchInfo: { TABLE_NAME: 'MES_ROUTE' }, + which: '', + }); + } + + /** + * @description: 寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庝簨浠� + * @param {*} d + * @param {*} u + * @return {*} + */ + function handleItemSuccess(d, u) { + setFieldsValue({ + ROT_CODE: d.values['val'], + ROT_ID: d.values['id'], + }); + } +</script> diff --git a/src/views/components/Step3.vue b/src/views/components/Step3.vue new file mode 100644 index 0000000..d737d02 --- /dev/null +++ b/src/views/components/Step3.vue @@ -0,0 +1,31 @@ +<!-- + * @Description: file content + * @Author: Ben Lin + * @version: + * @Date: 2024-06-27 00:25:26 + * @LastEditors: Ben Lin + * @LastEditTime: 2024-06-27 01:09:24 +--> +<template> + <div class="w-150 m-auto"> + <Result status="success" title="鎿嶄綔鎴愬姛" sub-title="宸茬粡缁欎骇鍝佹坊鍔犱簡瀹㈡埛鐨勫伐鑹鸿矾绾�"> + <template #extra> + <a-button type="primary" @click="emit('redo')"> 鍐嶆坊鍔� </a-button> + <a-button> 鏌ョ湅 </a-button> + </template> + </Result> + <!-- <div class="mt-6 px-6 py-8 bg-white"> + <Descriptions :column="1" class="mt-5"> + <Descriptions.Item label="浠樻璐︽埛"> ant-design@alipay.com </Descriptions.Item> + <Descriptions.Item label="鏀舵璐︽埛"> test@example.com </Descriptions.Item> + <Descriptions.Item label="鏀舵浜哄鍚�"> Vben </Descriptions.Item> + <Descriptions.Item label="杞处閲戦"> 500鍏� </Descriptions.Item> + </Descriptions> + </div> --> + </div> +</template> +<script lang="ts" setup> + import { Result, Descriptions } from 'ant-design-vue'; + + const emit = defineEmits(['redo']); +</script> diff --git a/src/views/components/StepModal.vue b/src/views/components/StepModal.vue new file mode 100644 index 0000000..477052d --- /dev/null +++ b/src/views/components/StepModal.vue @@ -0,0 +1,122 @@ +<!-- + * @Description: file content + * @Author: Ben Lin + * @version: + * @Date: 2024-06-26 22:54:42 + * @LastEditors: Ben Lin + * @LastEditTime: 2024-06-27 10:44:54 +--> +<template> + <BasicModal + width="800px" + :height="600" + v-bind="$attrs" + @register="register" + :title="title" + @ok="handleSubmit" + > + <div class="step-form-form"> + <Steps :current="current"> + <Steps.Step title="閫夋嫨瀹㈡埛" /> + <Steps.Step title="娣诲姞宸ヨ壓璺嚎" /> + <Steps.Step title="瀹屾垚" /> + </Steps> + </div> + <div class="mt-5"> + <Step1 @next="handleStep1Next" v-show="current === 0" /> + <Step2 + @prev="handleStepPrev" + @next="handleStep2Next" + v-show="current === 1" + v-if="state.initStep2" + /> + <Step3 v-show="current === 2" @redo="handleRedo" v-if="state.initStep3" /> + </div> + </BasicModal> +</template> +<script lang="ts" setup> + import { ref, reactive } from 'vue'; + import Step1 from './Step1.vue'; + import Step2 from './Step2.vue'; + import Step3 from './Step3.vue'; + import { BasicModal, useModalInner } from '/@/components/Modal'; + import { Steps } from 'ant-design-vue'; + import { useI18n } from '/@/hooks/web/useI18n'; + + defineOptions({ name: 'StepModal' }); + + const emit = defineEmits(['success']); + const { t } = useI18n(); + const title = ref(''); + const current = ref(0); + const step1Values = ref({}); + const step2Values = ref({}); + + const state = reactive({ + initStep2: false, + initStep3: false, + }); + + const [register, { setModalProps, closeModal }] = useModalInner((data) => { + setModalProps({ confirmLoading: false, okText: '淇濆瓨鎻愪氦' }); + data && onDataReceive(data); + }); + + /** + * @description: 鎵撳紑妯℃�佺獥鍙f椂鎺ユ敹鏁版嵁鏂规硶 + * @param {*} data + * @return {*} + */ + async function onDataReceive(data) { + console.log('Data Received', data); + title.value = data?.title; + } + + /** + * @description: 姝ラ瀹屾垚鍚庢彁浜ゆ柟娉� + * @return {*} + */ + async function handleSubmit() { + try { + closeModal(); + emit('success', { ...step1Values.value, ...step2Values.value }); + } finally { + setModalProps({ confirmLoading: false }); + } + } + + function handleStep1Next(Values: any) { + current.value++; + state.initStep2 = true; + console.log(Values); + step1Values.value = Values; + } + + function handleStepPrev() { + current.value--; + } + + function handleStep2Next(Values: any) { + current.value++; + state.initStep3 = true; + console.log(Values); + step2Values.value = Values; + } + + function handleRedo() { + current.value = 0; + state.initStep2 = false; + state.initStep3 = false; + } +</script> +<style lang="less" scoped> + .step-form-content { + padding: 24px; + background-color: @component-background; + } + + .step-form-form { + width: 750px; + margin: 0 auto; + } +</style> diff --git a/src/views/components/data.ts b/src/views/components/data.ts index 0240bc3..79852ad 100644 --- a/src/views/components/data.ts +++ b/src/views/components/data.ts @@ -1,10 +1,10 @@ /* * @Description: 鑷畾涔夊脊鍑烘璇锋暟鎹� * @Author: Ben Lin - * @version: + * @version: * @Date: 2024-06-05 15:50:59 - * @LastEditors: your name - * @LastEditTime: 2024-06-15 22:44:19 + * @LastEditors: Ben Lin + * @LastEditTime: 2024-06-27 10:54:27 */ import { getWoFns, @@ -138,8 +138,70 @@ ], tableName: 'BAS_ITEM', rowKey: 'ITEM_CODE', - searchInfo: {TABLE_NAME: 'BAS_ITEM'} //searchInfo: {TABLE_NAME: 'MES_CUSTOM_ACT', ACT_TYPE: routeConfig.currentAct.ACT_TYPE} + searchInfo: { TABLE_NAME: 'BAS_ITEM' }, //searchInfo: {TABLE_NAME: 'MES_CUSTOM_ACT', ACT_TYPE: routeConfig.currentAct.ACT_TYPE} }); break; } } + +export const step1Schemas: FormSchema[] = [ + { + field: 'CUST_CODE', + component: 'Input', + label: '瀹㈡埛缂栫爜', + required: true, + colProps: { + span: 20, + }, + }, + { + field: '0', + label: '', + defaultValue: '', + slot: 'add', + colProps: { + span: 4, + }, + }, + { + field: 'CUST_ID', + component: 'Input', + label: 'ID', + required: true, + colProps: { + span: 20, + }, + show: false, + }, +]; + +export const step2Schemas: FormSchema[] = [ + { + field: 'ROT_CODE', + component: 'Input', + label: '宸ヨ壓璺嚎', + required: true, + colProps: { + span: 20, + }, + }, + { + field: '0', + label: '', + defaultValue: '', + slot: 'add', + colProps: { + span: 4, + }, + }, + { + field: 'ROT_ID', + component: 'Input', + label: 'ID', + required: true, + colProps: { + span: 20, + }, + show: false, + }, +]; diff --git a/src/views/tigerprojects/system/lowcode/composition/CarGridNav.vue b/src/views/tigerprojects/system/lowcode/composition/CarGridNav.vue index 78c40a5..a4281d4 100644 --- a/src/views/tigerprojects/system/lowcode/composition/CarGridNav.vue +++ b/src/views/tigerprojects/system/lowcode/composition/CarGridNav.vue @@ -1,33 +1,43 @@ <!-- - * @Description: 宸ヨ壓璺嚎娣诲姞椤甸潰 + * @Description: 瀵艰埅椤甸潰 * @Author: Ben Lin * @version: * @Date: 2024-06-20 12:13:27 * @LastEditors: Ben Lin - * @LastEditTime: 2024-06-26 21:46:41 + * @LastEditTime: 2024-06-27 00:39:37 --> <template> <Card :title="GetTitle()['navTitle']"> - <CardGrid v-for="item in GetNavItems()" :key="item.title" @click="naveChangeItem(item.action, openModal)"> + <CardGrid + v-for="item in GetNavItems()" + :key="item.title" + @click="navChangeItem(item.action, useModalData[item.action][1].openModal)" + > <span class="flex flex-col items-center"> <Icon :icon="item.icon" :color="item.color" size="20" /> <span class="text-md mt-2 truncate">{{ item.title }}</span> </span> + <GeneralModal + v-if="!item.isStep" + @register="useModalData[item.action][0]" + @success="(d, u) => handleSuccess(d, u, item.action, objParams, refreshPage)" + ></GeneralModal> + <StepModal + v-if="item.isStep" + @register="useModalData[item.action][0]" + @success="(d, u) => handleSuccess(d, u, item.action, objParams, refreshPage)" + /> </CardGrid> </Card> - <GeneralModal @register="register" @success="handleSuccess"></GeneralModal> </template> <script lang="ts" setup> import { Card, CardGrid } from 'ant-design-vue'; import Icon from '@/components/Icon/Icon.vue'; - import { RouteToCust, RouteToProd } from '/@/api/tigerapi/mes/router'; import GeneralModal from '/@/views/components/GeneralModal.vue'; - import { useModal } from '/@/components/Modal'; - import { useI18n } from '/@/hooks/web/useI18n'; + import StepModal from '/@/views/components/StepModal.vue'; import { Ref, inject, ref, watch } from 'vue'; - import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is'; + import { isNullOrUnDef } from '/@/utils/is'; import { useTabs } from '/@/hooks/web/useTabs'; - import { useMessage } from '/@/hooks/web/useMessage'; import { EntityCustFunctionType } from '/@/api/tigerapi/model/basModel'; const objParams = inject('objParams') as Ref<any>; @@ -36,21 +46,23 @@ { GetTitle() {}, GetNavItems() {}, - naveChangeItem(action: any, ...args) {}, + navChangeItem(action: any, ...args) {}, + GetUseModals() {}, + GetSelectSuccess(d, u, ...args) {}, } as EntityCustFunctionType, ]); /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */ try { custImport.value = await import(`../entityts/${objParams.value['Name']}.ts`); } catch (e) {} - const [{ GetTitle, GetNavItems, naveChangeItem }] = - isNullOrUnDef(custImport.value['default']) - ? EntityCustFunction.value - : custImport.value['default'](); + const [{ GetTitle, GetNavItems, navChangeItem, GetUseModals, GetSelectSuccess }] = isNullOrUnDef( + custImport.value['default'], + ) + ? EntityCustFunction.value + : custImport.value['default'](); + + const useModalData = ref(GetUseModals()); const { refreshPage } = useTabs(); - const { createErrorModal } = useMessage(); - const { t } = useI18n(); - const [register, { openModal }] = useModal(); // watch( // () => Prod_Code, @@ -63,29 +75,12 @@ // ); /** - * @description: 閫夋嫨宸ヨ壓璺嚎鎴愬姛杩斿洖鏂规硶 + * @description: 寮瑰嚭閫夋嫨妗嗘垚鍔熻繑鍥炴柟娉� * @param {*} d * @param {*} u * @return {*} */ - async function handleSuccess(d, u) { - if (isNullOrEmpty(objParams.value['CODE'])) { - createErrorModal({ - title: t('sys.api.errorTip'), - content: '浜у搧涓虹┖锛屼笉鑳芥坊鍔犲伐鑹鸿矾绾匡紝璇风偣鍑诲乏渚ч�夋嫨浜у搧', - }); - return; - } - let codes = d.values.id.split(','); - var i; - for (i = 0; i < codes.length; i++) { - if (d.which == 'addRoute') { - await RouteToProd({ rotId: codes[i], prodCode: objParams.value['CODE'] }); - } else { - await RouteToCust({ rotId: codes[i], prodCode: objParams.value['CODE'], custCode: '' }); - } - } - - await refreshPage(); + async function handleSuccess(d, u, item, objParams, refreshPage) { + GetSelectSuccess(d, u, item, objParams, refreshPage); } </script> diff --git a/src/views/tigerprojects/system/lowcode/data.ts b/src/views/tigerprojects/system/lowcode/data.ts index 6ff1417..7b42f90 100644 --- a/src/views/tigerprojects/system/lowcode/data.ts +++ b/src/views/tigerprojects/system/lowcode/data.ts @@ -1,34 +1,10 @@ /* - * __----~~~~~~~~~~~------___ - * . . ~~//====...... __--~ ~~ - * -. \_|// |||\\ ~~~~~~::::... /~ - * ___-==_ _-~o~ \/ ||| \\ _/~~- - * __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ - * _-~~ .=~ | \\-_ '-~7 /- / || \ / - * .~ .~ | \\ -_ / /- / || \ / - * / ____ / | \\ ~-_/ /|- _/ .|| \ / - * |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ - * ' ~-| /| |-~\~~ __--~~ - * |-~~-_/ | | ~\_ _-~ /\ - * / \ \__ \/~ \__ - * _--~ _/ | .-~~____--~-/ ~~==. - * ((->/~ '.|||' -_| ~~-/ , . _|| - * -_ ~\ ~~---l__i__i__i--~~_/ - * _-~-__ ~) \--______________--~~ - * //.-~~~-~_--~- |-------~~~~~~~~ - * //.-~~~--\ - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * - * 绁炲吔淇濅綉 姘告棤BUG - */ - -/* * @Description: 閫氱敤浣庝唬鐮佸憟鐜伴〉闈富鏁版嵁 * @Author: Ben Lin * @version: * @Date: 2024-06-02 17:52:35 * @LastEditors: Ben Lin - * @LastEditTime: 2024-06-14 09:08:11 + * @LastEditTime: 2024-06-26 22:23:12 */ import { ActionItem, BasicColumn, FormSchema } from '/@/components/Table'; diff --git a/src/views/tigerprojects/system/lowcode/entityts/ProdRouteBinding.ts b/src/views/tigerprojects/system/lowcode/entityts/ProdRouteBinding.ts index d142b78..7119887 100644 --- a/src/views/tigerprojects/system/lowcode/entityts/ProdRouteBinding.ts +++ b/src/views/tigerprojects/system/lowcode/entityts/ProdRouteBinding.ts @@ -4,18 +4,22 @@ * @version: * @Date: 2024-06-19 20:34:27 * @LastEditors: Ben Lin - * @LastEditTime: 2024-06-26 21:49:44 + * @LastEditTime: 2024-06-27 15:49:17 */ import { Ref, ref, unref } from 'vue'; -import { GetRoutePTree } from '/@/api/tigerapi/mes/router'; +import { GetRoutePTree, RouteToCust, RouteToProd } from '/@/api/tigerapi/mes/router'; import { GetEnum, convertToTree, getEntity } from '/@/api/tigerapi/system'; import { useLocale } from '/@/locales/useLocale'; import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is'; import { useI18n } from '/@/hooks/web/useI18n'; import { NavItem } from '/@/api/tigerapi/model/basModel'; +import { useMessage } from '/@/hooks/web/useMessage'; +import { useModal } from '/@/components/Modal'; +import { V_MES_ROUTE_PTREE } from '/@/api/tigerapi/model/router'; const { t } = useI18n(); +const { createErrorModal } = useMessage(); const { getLocale } = useLocale(); function _default() { const isNormal = (type: number) => type === 0; @@ -67,9 +71,15 @@ fetchTreeData: async (type: string, itemCode: string) => { let data = { title: '', treeData: [] as any[], fieldNames: {} }; let prodTreeData = await GetRoutePTree(itemCode); - data.treeData = convertToTree(prodTreeData, 'pid', 'id', 'root'); + // 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'); data.title = '宸ヨ壓璺嚎'; - data.fieldNames = { key: 'id', title: 'name' }; + data.fieldNames = { key: 'tid', title: 'name' }; return data; }, GetCrudForm: () => { @@ -329,9 +339,54 @@ value = { pkgRULE_CODE: d.values['val'], }; + case 'addRoute': + if (isNullOrEmpty(args[1]['CODE'])) { + createErrorModal({ + title: t('sys.api.errorTip'), + content: '浜у搧涓虹┖锛屼笉鑳芥坊鍔犲伐鑹鸿矾绾匡紝璇风偣鍑诲乏渚ч�夋嫨浜у搧', + }); + return; + } + let codes = d.values.id.split(','); + var i; + for (i = 0; i < codes.length; i++) { + if (d.which == 'addRoute') { + RouteToProd({ rotId: codes[i], prodCode: args[1]['CODE'] }); + } else { + RouteToCust({ rotId: codes[i], prodCode: args[1]['CODE'], custCode: '' }); + } + } + + args[2](); break; + case 'addCustomer': + if (isNullOrEmpty(args[1]['CODE'])) { + createErrorModal({ + title: t('sys.api.errorTip'), + content: '浜у搧涓虹┖锛屼笉鑳芥坊鍔犲伐鑹鸿矾绾匡紝璇风偣鍑诲乏渚ч�夋嫨浜у搧', + }); + return; + } + let rotIds = d.ROT_ID.split(','); + var i; + for (i = 0; i < rotIds.length; i++) { + RouteToCust({ rotId: rotIds[i], prodCode: args[1]['CODE'], custCode: d.CUST_CODE }); + } + + args[2](); + break; } return value; + }, + /** + * @description: 鑾峰彇妯℃�佹搴旂敤鍒楄〃 + * @return {*} + */ + GetUseModals: () => { + return { + addRoute: useModal(), + addCustomer: useModal(), + }; }, /** * @description: 鑾峰彇鏍囬淇℃伅 @@ -376,6 +431,7 @@ color: '#1fdaca', url: '/addRoute', action: 'addRoute', + isStep: false, }, { title: '娣诲姞瀹㈡埛宸ヨ壓璺嚎', @@ -383,6 +439,7 @@ color: '#bf0c2c', url: '/addCustomer', action: 'addCustomer', + isStep: true, }, ] as NavItem[]; }, @@ -391,41 +448,50 @@ * @param {any} action * @return {*} */ - naveChangeItem: (action: any, ...args) => { - args[0](true, { - title: '宸ヨ壓璺嚎鍒楄〃', - schemas: [ - { - field: 'ROT_CODE', - component: 'Input', - label: '宸ヨ壓璺嚎缂栫爜', - colProps: { - span: 12, - }, - }, - ], - ItemColumns: [ - { - title: t('宸ヨ壓璺嚎缂栫爜'), - dataIndex: 'ROT_CODE', - resizable: true, - sorter: true, - width: 200, - }, - { - title: t('宸ヨ壓璺嚎鍚嶇О'), - dataIndex: 'ROT_NAME', - resizable: true, - sorter: true, - width: 180, - }, - ], - tableName: 'MES_ROUTE', - rowKey: 'ROT_CODE', - returnFieldName: 'ROUTE_CODE', //杩斿洖鍊艰璧嬪�肩殑瀛楁鍚嶇О - searchInfo: { TABLE_NAME: 'MES_ROUTE' }, - which: action, - }); + navChangeItem: (action: any, ...args) => { + switch (action) { + case 'addRoute': + args[0](true, { + title: '宸ヨ壓璺嚎鍒楄〃', + schemas: [ + { + field: 'ROT_CODE', + component: 'Input', + label: '宸ヨ壓璺嚎缂栫爜', + colProps: { + span: 12, + }, + }, + ], + ItemColumns: [ + { + title: t('宸ヨ壓璺嚎缂栫爜'), + dataIndex: 'ROT_CODE', + resizable: true, + sorter: true, + width: 200, + }, + { + title: t('宸ヨ壓璺嚎鍚嶇О'), + dataIndex: 'ROT_NAME', + resizable: true, + sorter: true, + width: 180, + }, + ], + tableName: 'MES_ROUTE', + rowKey: 'ROT_CODE', + returnFieldName: 'ROUTE_CODE', //杩斿洖鍊艰璧嬪�肩殑瀛楁鍚嶇О + searchInfo: { TABLE_NAME: 'MES_ROUTE' }, + which: action, + }); + break; + case 'addCustomer': + args[0](true, { + title: '璇峰畬鎴愪互涓嬫楠�', + }); + break; + } }, }; -- Gitblit v1.9.3