From aa0bc81d06736cc1a1bd210dde61f57736585d43 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期五, 07 六月 2024 10:37:05 +0800 Subject: [PATCH] 很多更新 --- src/views/tigerprojects/mes/prod/biz_mes_wo/WoModal.vue | 382 ++++++++++++++++++++++++++++-------------------------- 1 files changed, 197 insertions(+), 185 deletions(-) diff --git a/src/views/tigerprojects/mes/prod/biz_mes_wo/WoModal.vue b/src/views/tigerprojects/mes/prod/biz_mes_wo/WoModal.vue index cb1855b..b9d82c1 100644 --- a/src/views/tigerprojects/mes/prod/biz_mes_wo/WoModal.vue +++ b/src/views/tigerprojects/mes/prod/biz_mes_wo/WoModal.vue @@ -5,204 +5,216 @@ v-bind="$attrs" ok-text="淇濆瓨" @register="register" - :title="t('瀵煎叆宸ュ崟鏂欑珯琛�')" + :title="t(props.title)" @ok="handleSubmit" > - <a-button style="position: relative; left: 100px" @click="aoaToExcel" class="m-3"> - 妯℃澘 - </a-button> - <ImpExcel - style="width: 100px; position: relative; top: -56px" - @success="loadDataSuccess" - dateFormat="YYYY-MM-DD" - > - <a-button class="m-3"> 瀵煎叆Excel </a-button> - </ImpExcel> - - <p style="color: red" v-text="err"></p> - <a-card style="position: relative; top: -55px" :title="t('鍒楄〃')" :bordered="false"> - <!-- :columns="dtlColumns" - :dataSource="data" --> - <PageWrapper dense contentClass="flex"> - <BasicTable - :maxHeight="500" - v-for="(table, index) in tableListRef" - :key="index" - :title="table.title" - :columns="table.columns" - :dataSource="table.dataSource" - /> - </PageWrapper> - </a-card> + <div class="high-form"> + <p style="color: red" v-text="err"></p> + <BasicTable + v-for="(table, index) in tableListRef" + :key="index" + :title="table.title" + :columns="table.columns" + :dataSource="table.dataSource" + > + <template #toolbar> + <a-button @click="aoaToExcel" color="primary" preIcon="tmpDownload-white|svg"> + 妯℃澘 + </a-button> + <ImpExcel @success="loadDataSuccess" dateFormat="YYYY-MM-DD"> + <a-button class="m-3" preIcon="excel-import|svg"> 瀵煎叆Excel </a-button> + </ImpExcel> + </template> + </BasicTable> + </div> </BasicModal> </template> -<script lang="ts"> - import { defineComponent, ref, nextTick, unref, h } from 'vue'; - import { Tag, Tooltip } from 'ant-design-vue'; +<script lang="ts" setup> + import { ref, nextTick, unref, h } from 'vue'; + import { Tag, Tooltip, Card } from 'ant-design-vue'; import { BasicModal, useModalInner } from '/@/components/Modal'; - import { BasicForm, FormSchema, useForm } from '/@/components/Form/index'; import { SaveSmttable, ExportTable, SaveExportTable } from '/@/api/tigerapi/mes/smt/smttable'; import { useI18n } from '/@/hooks/web/useI18n'; import { aoaToSheetXlsx, ImpExcel, ExcelData } from '/@/components/Excel'; import { useMessage } from '/@/hooks/web/useMessage'; import { useLocale } from '/@/locales/useLocale'; - import { PageWrapper } from '/@/components/Page'; import { BasicTable, BasicColumn } from '/@/components/Table'; - const { getLocale } = useLocale(); - - const { t } = useI18n(''); - const { createMessage, createConfirm } = useMessage(); - export default defineComponent({ - components: { BasicModal, BasicForm, PageWrapper, ImpExcel, BasicTable }, - props: { - userData: { type: Object }, + const emit = defineEmits(['success', 'register', 'toExcel']); + const props = defineProps({ + title: { + type: String, + default: '', }, - emit: ['success', 'register'], - setup(_, { emit }) { - const modelRef = ref({}); - const tableListRef = ref< - { - title: string; - columns?: any[]; - dataSource?: any[]; - }[] - >([]); - - const tableListRef2 = ref< - { - title: string; - columns?: any[]; - dataSource?: any[]; - }[] - >([]); - - const [register, { setModalProps, closeModal }] = useModalInner((data) => { - setModalProps({ confirmLoading: false }); - tableListRef.value = []; - }); - var err = ref(''); - async function loadDataSuccess(excelDataList: ExcelData[]) { - tableListRef.value = []; - - for (const excelData of excelDataList) { - const { - header, - results, - meta: { sheetName }, - } = excelData; - const columns: BasicColumn[] = []; - columns.push({ - title: '澶勭悊鏂瑰紡', - dataIndex: '澶勭悊鏂瑰紡', - customRender: ({ record }) => { - const status = record.澶勭悊鏂瑰紡; - var text = ''; - var color = ''; - if (status == '鏁版嵁寮傚父') { - color = 'red'; - text = status; - } else if (status == '淇敼') { - color = 'yellow'; - text = status; - } else { - text = status; - } - return h(Tooltip, { title: 'xxxxxx' }, () => h(Tag, { color: color }, () => text)); - }, - }); - columns.push({ title: '鍘熷洜', dataIndex: '鍘熷洜', width: 300, resizable: true }); - for (const title of header) { - columns.push({ title, dataIndex: title }); - } - tableListRef.value.push({ title: sheetName, dataSource: results, columns }); - } - console.log('console.log(tableListRef.value);', tableListRef.value); - var res = await ExportTable(tableListRef.value); - if (res.IsSuccessed) { - tableListRef.value[0].dataSource = res.Data; - err.value = ''; - } else { - tableListRef.value = []; - createMessage.error('瀵煎叆澶辫触' + res.Message); - err.value = res.Message; - } - } - - // function handleVisibleChange(v) { - // v && props.userData && nextTick(() => onDataReceive(props.userData)); - // } - //瀵煎嚭 - function aoaToExcel() { - const arrHeader = [ - '鍏宠仈宸ュ崟鍙�', - '浜у搧缂栫爜', - '鐗╂枡缂栫爜', - '鏇夸唬鏂�', - '鍗曚綅', - '鍗曚綅鐢ㄩ噺', - '浜х嚎缂栫爜', - '璐寸墖鏈虹紪鐮�', - '璐寸墖鏈虹紪鐮�', - '閽㈢綉缂栫爜', - '绔欎綅鍙�', - '璐寸墖浣嶇疆', - '椋炶揪缂栫爜', - '椋炶揪绫诲瀷', - '鍔犲伐闈�', - '涓婃枡椤哄簭', - '鍒涘缓浜�', - '鍒涘缓鏃堕棿', - ]; - aoaToSheetXlsx({ - data: '', - header: arrHeader, - filename: '宸ュ崟鏂欑珯琛ㄤ俊鎭�.xlsx', - }); - } - async function handleSubmit() { - try { - const values = tableListRef.value; - setModalProps({ confirmLoading: true }); - // TODO custom api - //娣诲姞閿¤啅鑳舵按璁板綍 - createConfirm({ - iconType: 'warning', - title: () => h('span', t('瀵煎叆鏂欑珯琛ㄤ俊鎭�')), - content: () => h('span', t('纭鏈変慨鏀圭殑鏁版嵁鏄惁姝g‘锛屾湁寮傚父鐨勬暟鎹棤娉曞鍏�')), - onOk: async () => { - const apiAction = SaveExportTable(tableListRef.value); - apiAction.then((action) => { - if (action) { - if (action.IsSuccessed) { - closeModal(); - createMessage.success(t('瀵煎叆鎴愬姛')); - emit('success', { - isUpdate: unref(false), - values: { ...values, id: 0 }, - }); - } - } else { - createMessage.error(t('瀵煎叆澶辫触,浠g爜宸蹭娇鐢�')); - } - }); - }, - }); - } finally { - setModalProps({ confirmLoading: false }); - } - } - - return { - register, - model: modelRef, - handleSubmit, - loadDataSuccess, - tableListRef, - err, - t, - aoaToExcel, - }; + mtitle: { + type: String, + default: '', + }, + arr: { + type: Array, + default: () => [1, 2, 3, 4], }, }); + const ACard = Card; + const { getLocale } = useLocale(); + const { t } = useI18n(''); + const { createMessage, createConfirm } = useMessage(); + const modelRef = ref({}); + const tableListRef = ref< + { + title: string; + columns?: any[]; + dataSource?: any[]; + }[] + >([]); + + const tableListRef2 = ref< + { + title: string; + columns?: any[]; + dataSource?: any[]; + }[] + >([]); + const [register, { setModalProps, closeModal }] = useModalInner((data) => { + setModalProps({ confirmLoading: false }); + tableListRef.value = [ + { + title: '鍒楄〃淇℃伅', + columns: [ + { + title: '瀛楁1', + dataIndex: 'field1', + width: 200, + sorter: true, + resizable: true, + }, + { + title: '瀛楁2', + dataIndex: 'field2', + width: 200, + sorter: true, + resizable: true, + }, + ], + dataSource: [], + }, + ]; + }); + var err = ref(''); + async function loadDataSuccess(excelDataList: ExcelData[]) { + tableListRef.value = []; + + for (const excelData of excelDataList) { + const { + header, + results, + meta: { sheetName }, + } = excelData; + const columns: BasicColumn[] = []; + columns.push({ + title: '澶勭悊鏂瑰紡', + dataIndex: '澶勭悊鏂瑰紡', + customRender: ({ record }) => { + const status = record.澶勭悊鏂瑰紡; + var text = ''; + var color = ''; + if (status == '鏁版嵁寮傚父') { + color = 'red'; + text = status; + } else if (status == '淇敼') { + color = 'yellow'; + text = status; + } else { + text = status; + } + return h(Tooltip, { title: 'xxxxxx' }, () => h(Tag, { color: color }, () => text)); + }, + }); + columns.push({ title: '鍘熷洜', dataIndex: '鍘熷洜', width: 300, resizable: true }); + for (const title of header) { + columns.push({ title, dataIndex: title }); + } + tableListRef.value.push({ title: sheetName, dataSource: results, columns }); + } + console.log('console.log(tableListRef.value);', tableListRef.value); + var res = await ExportTable(tableListRef.value); + if (res.IsSuccessed) { + tableListRef.value[0].dataSource = res.Data; + err.value = ''; + } else { + tableListRef.value = []; + createMessage.error('瀵煎叆澶辫触' + res.Message); + err.value = res.Message; + } + } + + // function handleVisibleChange(v) { + // v && props.userData && nextTick(() => onDataReceive(props.userData)); + // } + //瀵煎嚭 + function aoaToExcel() { + const arrHeader = [ + '鍏宠仈宸ュ崟鍙�', + '浜у搧缂栫爜', + '鐗╂枡缂栫爜', + '鏇夸唬鏂�', + '鍗曚綅', + '鍗曚綅鐢ㄩ噺', + '浜х嚎缂栫爜', + '璐寸墖鏈虹紪鐮�', + '璐寸墖鏈虹紪鐮�', + '閽㈢綉缂栫爜', + '绔欎綅鍙�', + '璐寸墖浣嶇疆', + '椋炶揪缂栫爜', + '椋炶揪绫诲瀷', + '鍔犲伐闈�', + '涓婃枡椤哄簭', + '鍒涘缓浜�', + '鍒涘缓鏃堕棿', + ]; + aoaToSheetXlsx({ + data: '', + header: arrHeader, + filename: '宸ュ崟鏂欑珯琛ㄤ俊鎭�.xlsx', + }); + } + async function handleSubmit() { + try { + const values = tableListRef.value; + setModalProps({ confirmLoading: true }); + // TODO custom api + //娣诲姞閿¤啅鑳舵按璁板綍 + createConfirm({ + iconType: 'warning', + title: () => h('span', t('瀵煎叆鏂欑珯琛ㄤ俊鎭�')), + content: () => h('span', t('纭鏈変慨鏀圭殑鏁版嵁鏄惁姝g‘锛屾湁寮傚父鐨勬暟鎹棤娉曞鍏�')), + onOk: async () => { + const apiAction = SaveExportTable(tableListRef.value); + apiAction.then((action) => { + if (action) { + if (action.IsSuccessed) { + closeModal(); + createMessage.success(t('瀵煎叆鎴愬姛')); + emit('success', { + isUpdate: unref(false), + values: { ...values, id: 0 }, + }); + } + } else { + createMessage.error(t('瀵煎叆澶辫触,浠g爜宸蹭娇鐢�')); + } + }); + }, + }); + } finally { + setModalProps({ confirmLoading: false }); + } + } </script> +<style lang="less" scoped> + .high-form { + padding: 5px 10px 10px 10px; + background: #f5f9fe; + } +</style> -- Gitblit v1.9.3