From 7cf58a4d2fff6b9cba9029d4d43ba9744dbef864 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期四, 18 七月 2024 15:49:03 +0800 Subject: [PATCH] 工单更新 --- src/views/tigerprojects/mes/smt/smttable/index.vue | 437 ++++++++++++++++++++---------------------------------- 1 files changed, 163 insertions(+), 274 deletions(-) diff --git a/src/views/tigerprojects/mes/smt/smttable/index.vue b/src/views/tigerprojects/mes/smt/smttable/index.vue index 2d3b0c3..4f611ee 100644 --- a/src/views/tigerprojects/mes/smt/smttable/index.vue +++ b/src/views/tigerprojects/mes/smt/smttable/index.vue @@ -1,285 +1,174 @@ <template> - <PageWrapper title="鏂欑珯琛ㄥ鍏�" contentFullHeight> - <CollapseContainer title="鏂欑珯琛ㄤ俊鎭�"> - <BasicForm - autoFocusFirstItem - :labelWidth="200" - :schemas="schemas" - :actionColOptions="{ span: 24 }" - :submitButtonOptions="{ text: '瀵煎叆' }" - @submit="handleSubmit" - @reset="handleReset" - /> - </CollapseContainer> - <BasicTable @register="registerTable" /> - </PageWrapper> + <div> + <BasicTable @register="registerTable"> + <template #toolbar> + <a-button color="primary" @click="addTool" preIcon="add_02|svg"> 鏂板 </a-button> + <a-button ghost color="success" @click="aoaToExcel" preIcon="excel-export|svg"> + 瀵煎嚭 + </a-button> + <a-button ghost color="success" @click="ExcelToaoa" preIcon="excel-import|svg"> + 瀵煎叆 + </a-button> + </template> + <template #action="{ record }"> + <TableAction + :actions="[ + { + icon: 'clarity:note-edit-line', + tooltip: '淇敼', + onClick: handleEdit.bind(null, record), + }, + { + icon: 'ant-design:delete-outlined', + tooltip: '鍒犻櫎', + color: 'error', + popConfirm: { + title: '鏄惁纭鍒犻櫎?', + placement: 'left', + confirm: handleDelete.bind(null, record), + }, + }, + ]" + /> + </template> + </BasicTable> + <Loading :loading="compState.loading" :tip="compState.tip" /> + <!-- <WmsItemDrawer @register="registerDrawer" @success="handleSuccess" /> --> + <SmttableDrawer @register="registerDrawer" @success="handleSuccess" /> + <SmttableModal @register="registerSmttable" @success="handleSuccess" /> + </div> </template> -<script lang="ts"> - import { computed, defineComponent, unref, ref } from 'vue'; - import { BasicColumn, BasicTable, useTable } from '/@/components/Table'; - import { BasicForm, FormSchema } from '/@/components/Form/index'; - import { CollapseContainer } from '/@/components/Container'; +<script lang="ts" setup> + import { reactive, unref } from 'vue'; + import { aoaToSheetXlsx } from '/@/components/Excel'; + import { BasicTable, useTable, TableAction } from '/@/components/Table'; + import SmttableDrawer from './SmttableDrawer.vue'; + import SmttableModal from './SmttableModal.vue'; + import { useDrawer } from '/@/components/Drawer'; + import { columns, searchFormSchema } from './smttbale.data'; + import { getSmttableListByPage, DeleteSmttable } from '/@/api/tigerapi/mes/smt/smttable'; + import { useGo } from '/@/hooks/web/usePage'; + import { Loading } from '/@/components/Loading'; import { useMessage } from '/@/hooks/web/useMessage'; - import { PageWrapper } from '/@/components/Page'; + import { useI18n } from '/@/hooks/web/useI18n'; + import { useModal } from '/@/components/Modal'; - import { optionsListApi } from '/@/api/demo/select'; - import { useDebounceFn } from '@vueuse/core'; - import { cloneDeep } from 'lodash-es'; - import { uploadApi } from '/@/api/sys/upload'; + const { t } = useI18n(); + const { createMessage } = useMessage(); + const [registerDrawer, { openDrawer }] = useDrawer(); + const go = useGo(); - const valueSelectA = ref<string[]>([]); - const valueSelectB = ref<string[]>([]); - const options = ref<Recordable[]>([]); - for (let i = 1; i < 10; i++) options.value.push({ label: '閫夐」' + i, value: `${i}` }); - - const optionsA = computed(() => { - return cloneDeep(unref(options)).map((op) => { - op.disabled = unref(valueSelectB).indexOf(op.value) !== -1; - return op; - }); + const compState = reactive({ + absolute: false, + loading: false, + tip: '鍔犺浇涓�...', }); - const optionsB = computed(() => { - return cloneDeep(unref(options)).map((op) => { - op.disabled = unref(valueSelectA).indexOf(op.value) !== -1; - return op; - }); + const [registerSmttable, { openModal: openSmttableModal }] = useModal(); + const [registerTable, { getForm, getPaginationRef, reload }] = useTable({ + title: '宸ュ崟鏂欑珯琛�', + api: getSmttableListByPage, + columns, + formConfig: { + labelWidth: 120, + schemas: searchFormSchema, + }, + actionColumn: { + width: 120, + title: '鎿嶄綔', + dataIndex: 'action', + slots: { customRender: 'action' }, + fixed: 'right', //undefined, + }, + ellipsis: true, + useSearchForm: true, + showTableSetting: true, + bordered: true, + showIndexColumn: false, }); + let arr: any[] = []; + //瀵煎嚭 + function aoaToExcel() { + const totals = getPaginationRef().total; + if (totals < 30000) { + arr = []; + compState.loading = true; + const col = getForm().getFieldsValue(); + getSmttableListByPage(col).then((res) => { + res.items.forEach((element) => { + arr.push({ + 鍏宠仈宸ュ崟鍙�: element.WORK_ORDER, + 浜у搧缂栫爜: element.PROD_CODE, + 鐗╂枡缂栫爜: element.ITEM_CODE, + 鏇夸唬鏂�: element.SUBITEM_CODE, + 鍗曚綅: element.UNIT, + 鍗曚綅鐢ㄩ噺: element.UNIT_QTY, + 浜х嚎缂栫爜: element.LINE_CODE, + 璐寸墖鏈虹紪鐮�: element.SMT_CODE, + 閽㈢綉缂栫爜: element.SMT_STENCIL, + 绔欎綅鍙�: element.SLOT_NO, + 璐寸墖浣嶇疆: element.LOCATION, + 椋炶揪缂栫爜: element.FEEDER_CODE, + 椋炶揪绫诲瀷: element.FEEDER_TYPE, + 鍔犲伐闈�: element.PCB_SURFACE, + 涓婃枡椤哄簭: element.LOAD_SEQ, + 鍒涘缓浜�: element.CREATE_USER, + 鍒涘缓鏃堕棿: element.CREATE_TIME, + }); + }); + const arrHeader = columns.map((column) => column.title); + const arrData = arr.map((item) => { + return Object.keys(item).map((key) => item[key]); + }); + // 淇濊瘉data椤哄簭涓巋eader涓�鑷� + if (arr.length < 30000) { + aoaToSheetXlsx({ + data: arrData, + header: arrHeader, + filename: '宸ュ崟鏂欑珯琛ㄤ俊鎭�.xlsx', + }); + } else { + createMessage.error(t('瀵煎嚭鏁版嵁涓嶈兘瓒呰繃涓変竾鏉★紝濡傞渶瑕佹洿澶氱殑璇疯仈绯荤鐞嗗憳')); + } - const schemas: FormSchema[] = [ - { - field: 'field1', - component: 'Select', - label: '绾垮埆', - colProps: { - span: 8, - }, - componentProps: { - options: [ - { - label: 'L8', - value: '1', - key: '1', - }, - { - label: 'L9', - value: '2', - key: '2', - }, - ], - }, - }, - { - field: 'field2', - component: 'Select', - label: '鏈哄彴', - colProps: { - span: 8, - }, - componentProps: { - options: [ - { - label: 'L8-1', - value: '1', - key: '1', - }, - { - label: 'L9-1', - value: '2', - key: '2', - }, - ], - }, - }, - { - field: 'field5', - component: 'Input', - label: '鏈虹鍚嶇О', - colProps: { - span: 8, - }, - }, - { - field: 'field6', - component: 'Upload', - label: '鏂欑珯琛ㄦ枃浠朵笂浼�', - colProps: { - span: 8, - }, - rules: [{ required: true, message: '璇烽�夋嫨涓婁紶鏂囦欢' }], - componentProps: { - api: uploadApi, - }, - }, - { - field: 'field9', - component: 'Switch', - label: '姝e弽闈�', - colProps: { - span: 8, - }, - }, - ]; - - const columns: BasicColumn[] = [ - { - title: 'SMT_CODE', - dataIndex: 'SMT_CODE', - }, - { - title: 'MACHINCE_SN', - dataIndex: 'MACHINCE_SN', - }, - { - title: 'SLOT_NO', - dataIndex: 'SLOT_NO', - }, - { - title: 'FEEDER', - dataIndex: 'FEEDER', - }, - { - title: 'MATERIAL_NO', - dataIndex: 'MATERIAL_NO', - }, - { - title: 'QTY', - dataIndex: 'QTY', - }, - { - title: '鍒涘缓鏃堕棿', - dataIndex: 'CREATE_TIME', - width: 180, - }, - { - title: '澶囨敞', - dataIndex: 'REMARK', - }, - ]; - - const data = [ - { - ID: '1', - SMT_CODE: 'Y18121001', - MACHINCE_SN: 'L8-1', - SLOT_NO: '11', - FEEDER: '8MM', - MATERIAL_NO: '32083241', - QTY: 1, - LOCATION: '', - UPDATE_TIME: '2023-02-06', - CREATE_TIME: '2023-02-06', - REMARK: '', - }, - { - ID: '2', - SMT_CODE: 'Y18121001', - MACHINCE_SN: 'L8-1', - SLOT_NO: '11', - FEEDER: '8MM', - MATERIAL_NO: '32080000', - QTY: 1, - LOCATION: '', - UPDATE_TIME: '2023-02-06', - CREATE_TIME: '2023-02-06', - REMARK: '', - }, - { - ID: '3', - SMT_CODE: 'Y18121001', - MACHINCE_SN: 'L8-1', - SLOT_NO: '11', - FEEDER: '8MM', - MATERIAL_NO: '32083242', - QTY: 1, - LOCATION: '', - UPDATE_TIME: '2023-02-06', - CREATE_TIME: '2023-02-06', - REMARK: '', - }, - { - ID: '4', - SMT_CODE: 'Y18121001', - MACHINCE_SN: 'L8-1', - SLOT_NO: '13', - FEEDER: '8MM', - MATERIAL_NO: '32083251', - QTY: 1, - LOCATION: '', - UPDATE_TIME: '2023-02-06', - CREATE_TIME: '2023-02-06', - REMARK: '', - }, - { - ID: '5', - SMT_CODE: 'Y18121001', - MACHINCE_SN: 'L8-1', - SLOT_NO: '12', - FEEDER: '8MM', - MATERIAL_NO: '32083202', - QTY: 1, - LOCATION: '', - UPDATE_TIME: '2023-02-06', - CREATE_TIME: '2023-02-06', - REMARK: '', - }, - ]; - - export default defineComponent({ - components: { - BasicForm, - CollapseContainer, - PageWrapper, - BasicTable, - }, - setup() { - const check = ref(null); - const { createMessage } = useMessage(); - const keyword = ref<string>(''); - const searchParams = computed<Recordable>(() => { - return { keyword: unref(keyword) }; + compState.loading = false; }); - - function onSearch(value: string) { - keyword.value = value; + } else { + createMessage.error(t('瀵煎嚭鏁版嵁涓嶈兘瓒呰繃涓変竾鏉★紝濡傞渶瑕佹洿澶氱殑璇疯仈绯荤鐞嗗憳')); + } + } + //瀵煎叆 + function ExcelToaoa() { + openSmttableModal(true, { + data: 'content', + info: 'Info', + }); + } + //娣诲姞 + function addTool() { + openDrawer(true, { + isUpdate: false, + }); + } + //缂栬緫 + function handleEdit(record: any) { + openDrawer(true, { + isUpdate: true, + record, + }); + } + function handleSuccess() { + reload(); + } + //鍒犻櫎 + function handleDelete(record: any) { + const apiAction = DeleteSmttable(record.ID); + apiAction.then((action) => { + if (action.IsSuccessed) { + createMessage.success(t('宸插垹闄�')); + reload(); + } else { + createMessage.success(t('鍒犻櫎鎿嶄綔澶辫触')); } - const [registerTable, { reload }] = useTable({ - columns, - dataSource: data, - useSearchForm: false, - bordered: true, - showIndexColumn: false, - actionColumn: { - width: 80, - title: '鎿嶄綔', - dataIndex: 'action', - slots: { customRender: 'action' }, - fixed: undefined, - }, - }); - - return { - schemas, - optionsListApi, - optionsA, - optionsB, - valueSelectA, - valueSelectB, - onSearch: useDebounceFn(onSearch, 300), - searchParams, - handleReset: () => { - keyword.value = ''; - }, - handleSubmit: (values: any) => { - createMessage.success('click search,values:' + JSON.stringify(values)); - }, - handleChange: (list: string[]) => { - createMessage.info(`宸蹭笂浼犳枃浠�${JSON.stringify(list)}`); - }, - check, - uploadApi, - registerTable, - reload, - }; - }, - }); + }); + } </script> -- Gitblit v1.9.3