From 16257dd099d9811fb5caf78047ffc2425c401e0e Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期一, 05 八月 2024 03:11:20 +0800 Subject: [PATCH] 工单工艺路线更新 --- src/views/tigerprojects/mes/eng/route/components/PostProps.vue | 226 +++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 182 insertions(+), 44 deletions(-) diff --git a/src/views/tigerprojects/mes/eng/route/components/PostProps.vue b/src/views/tigerprojects/mes/eng/route/components/PostProps.vue index 8eeaafc..b9c0b19 100644 --- a/src/views/tigerprojects/mes/eng/route/components/PostProps.vue +++ b/src/views/tigerprojects/mes/eng/route/components/PostProps.vue @@ -1,63 +1,201 @@ <!-- * @Description: file content - * @Author: your name + * @Author: Ben Lin * @version: * @Date: 2024-06-11 21:07:04 - * @LastEditors: your name - * @LastEditTime: 2024-06-12 10:11:05 + * @LastEditors: Ben Lin + * @LastEditTime: 2024-08-04 18:34:26 --> <!-- * @Description: 鍙充晶灞炴�ч潰鏉挎帶浠� 琛ㄥ崟灞炴�ч潰鏉� --> <template> - <div class="mt-3"> - <Button type="primary" @click="handleCreate" preIcon="add_02|svg" :size="size"> 鏂板 </Button> - <a-table :columns="columns" :data-source="data" bordered> - <template #name="{ text }"> - <a>{{ text }}</a> - </template> - </a-table> + <div class="m-1"> + <BasicTable @register="registerTable"> + <template #toolbar> + <a-button type="primary" @click="handleCreate" preIcon="add_02|svg" :size="size"> + 鏂板 + </a-button> + </template> + <template #action="{ record }"> + <TableAction + :actions="[ + { + icon: 'ant-design:delete-outlined', + color: 'error', + popConfirm: { + title: '鏄惁纭鍒犻櫎?', + placement: 'left', + confirm: handleDelete.bind(null, record), + }, + name: '', + }, + ]" + /> + </template> + </BasicTable> </div> + + <GeneralModal @register="register" @success="handleSuccess"></GeneralModal> </template> <script lang="ts" setup> -import { Table, notification } from 'ant-design-vue'; -import { Button } from '/@/components/Button'; -import { SizeType } from 'ant-design-vue/es/config-provider'; -import { ref } from 'vue'; + import { notification } from 'ant-design-vue'; + import { BasicTable, TableAction, useTable } from '/@/components/Table'; + import { SizeType } from 'ant-design-vue/es/config-provider'; + import { nextTick, onMounted, ref, unref, watch } from 'vue'; + import { useModal } from '/@/components/Modal'; + import GeneralModal from '/@/views/components/GeneralModal.vue'; + import { useI18n } from '/@/hooks/web/useI18n'; + import { DeleteWhere, getListByPage } from '/@/api/tigerapi/system'; + import { useRouteDesignState } from '../hooks/useRouteDesignState'; + import { SaveRouteNodePost, SaveWoRouteNodePost } from '/@/api/tigerapi/mes/router'; -const ATable = Table; -const size = ref<SizeType>('small'); -const columns = [ - { - title: 'Name', - dataIndex: 'name', - key: 'name', - slots: { customRender: 'name' }, - }, - { - title: 'Age', - dataIndex: 'age', - key: 'age', - }, -]; + const { t } = useI18n(); + const { routeConfig, mesRoute } = useRouteDesignState(); + const size = ref<SizeType>('small'); + const columns = [ + { + title: '宀椾綅鍚嶇О', + dataIndex: 'POST_NAME', + key: 'POST_NAME', + slots: { customRender: 'POST_NAME' }, + }, + { + title: '宀椾綅缂栫爜', + dataIndex: 'POST_CODE', + key: 'POST_CODE', + }, + { + title: t('浜х嚎缂栫爜'), + dataIndex: 'LINE_CODE', + key: 'LINE_CODE', + }, + ]; -const data: DataItem[] = []; -for (let i = 0; i < 100; i++) { - data.push({ - key: i, - name: `Edrward ${i}`, - age: 32, - address: `London Park no. ${i}`, + const [register, { openModal }] = useModal(); + const [registerTable, { reload }] = useTable({ + title: '鍒楄〃', + api: getListByPage, + searchInfo: routeConfig['isWorkOrder'] + ? { TABLE_NAME: 'V_MES_WO_NODE_POST', NODE_ID: routeConfig['currentItem'].ID } + : { TABLE_NAME: 'V_MES_ROUTE_NODE_POST', NODE_ID: routeConfig['currentItem'].ID }, + columns, + useSearchForm: false, + showTableSetting: false, + bordered: true, + showIndexColumn: false, + pagination: { pageSize: 10 }, + actionColumn: { + width: 80, + title: '鎿嶄綔', + dataIndex: 'action', + slots: { customRender: 'action' }, + }, }); -} + defineExpose({ + reload, + }); + // watch( + // () => routeConfig.currentItem.ID, + // (newVal, oldVal) => { + // if (newVal != oldVal) { + // nextTick(() => { + // reload(); + // }); + // } + // }, + // { deep: true, immediate: true }, + // ); -interface DataItem { - key: number; - name: string; - age: number; - address: string; -} + onMounted(() => {}); -function handleCreate() {} + /** + * @description: 鏂板鏂规硶 + * @return {*} + */ + function handleCreate() { + openModal(true, { + title: '宀椾綅璧勬簮鍒楄〃', + schemas: [ + { + field: 'POST_CODE', + component: 'Input', + label: '宀椾綅璧勬簮缂栫爜', + colProps: { + span: 12, + }, + }, + ], + ItemColumns: [ + { + title: t('宀椾綅璧勬簮缂栫爜'), + dataIndex: 'POST_CODE', + resizable: true, + sorter: true, + width: 200, + }, + { + title: t('宀椾綅璧勬簮鍚嶇О'), + dataIndex: 'POST_NAME', + resizable: true, + sorter: true, + width: 180, + }, + { + title: t('浜х嚎缂栫爜'), + dataIndex: 'LINE_CODE', + resizable: true, + sorter: true, + width: 180, + }, + ], + tableName: 'MES_POSITION', + rowKey: 'POST_CODE', + searchInfo: { TABLE_NAME: 'MES_POSITION' }, + }); + } + /** + * @description: 鍒犻櫎 + * @param {*} record + * @return {*} + */ + function handleDelete(record: Recordable) { + let entityName = routeConfig['isWorkOrder'] ? 'MES_WO_NODE_POST' : 'MES_ROUTE_NODE_POST'; + DeleteWhere( + `POST_CODE = '${record.POST_CODE}' And NODE_ID = '${record.NODE_ID}'`, + entityName, + ).then((res) => { + reload(); + }); + } + + /** + * @description: 閫夋嫨宀椾綅璧勬簮鎴愬姛杩斿洖鏂规硶 + * @param {*} d + * @param {*} u + * @return {*} + */ + function handleSuccess(d, u) { + let codes = d.values.val.split(','); + let eintity: any[] = []; + var i; + for (i = 0; i < codes.length; i++) { + eintity.push({ + NODE_ID: routeConfig['currentItem'].ID, + POST_CODE: codes[i], + REMARK: '', + WORK_ORDER: routeConfig['currentItem'].WORK_ORDER, + }); + } + if (routeConfig['isWorkOrder']) { + SaveWoRouteNodePost(eintity).then((res) => { + reload(); + }); + } else { + SaveRouteNodePost(eintity).then((res) => { + reload(); + }); + } + } </script> -- Gitblit v1.9.3