From 6f6207ef6eb81d2abb3805bc2cba889ea2abd135 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期日, 02 六月 2024 01:12:32 +0800
Subject: [PATCH] 低代码更新

---
 src/views/tigerprojects/mes/smt/smttable/SmttableModal.vue |  323 +++++++++++++++++++++++++++++++----------------------
 1 files changed, 189 insertions(+), 134 deletions(-)

diff --git a/src/views/tigerprojects/mes/smt/smttable/SmttableModal.vue b/src/views/tigerprojects/mes/smt/smttable/SmttableModal.vue
index 90a7102..cb1855b 100644
--- a/src/views/tigerprojects/mes/smt/smttable/SmttableModal.vue
+++ b/src/views/tigerprojects/mes/smt/smttable/SmttableModal.vue
@@ -1,153 +1,208 @@
 <template>
-  <BasicModal width="1200px" :height=400 v-bind="$attrs" ok-text="淇濆瓨" @register="register" :title="t('瀵煎叆宸ュ崟鏂欑珯琛�')"
-    @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"
+  <BasicModal
+    width="1200px"
+    :height="600"
+    v-bind="$attrs"
+    ok-text="淇濆瓨"
+    @register="register"
+    :title="t('瀵煎叆宸ュ崟鏂欑珯琛�')"
+    @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 :minHeight="300" dense contentFullHeight contentClass="flex">
-          <BasicTable :maxHeight="200" v-for="(table, index) in tableListRef" :key="index" :title="table.title" :columns="table.columns"
-            :dataSource="table.dataSource" />
-        </PageWrapper>
-    </a-card> 
+      <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>
   </BasicModal>
 </template>
 <script lang="ts">
-import { defineComponent, ref, nextTick, unref,h } from 'vue';
-import { Tag ,Tooltip} 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 } from '/@/components/Excel';
-import { useMessage } from '/@/hooks/web/useMessage';
-import { useLocale } from '/@/locales/useLocale';
-import { PageWrapper } from '/@/components/Page';
-import { ImpExcel, ExcelData } from '/@/components/Excel';
-import { BasicTable, BasicColumn } from '/@/components/Table';
+  import { defineComponent, ref, nextTick, unref, h } from 'vue';
+  import { Tag, Tooltip } 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 { getLocale } = useLocale();
 
-const { t } = useI18n('');
-const { createMessage } = useMessage();
-export default defineComponent({
-  components: { BasicModal, BasicForm, PageWrapper, ImpExcel,BasicTable },
-  props: {
-    userData: { type: Object },
-  },
-  emit: ['success', 'register'],
-  setup(_, { emit }) {
-    const modelRef = ref({});
-    const tableListRef = ref<
-      {
-        title: string;
-        columns?: any[];
-        dataSource?: any[];
-      }[]
-    >([]);
+  const { t } = useI18n('');
+  const { createMessage, createConfirm } = useMessage();
+  export default defineComponent({
+    components: { BasicModal, BasicForm, PageWrapper, ImpExcel, BasicTable },
+    props: {
+      userData: { type: Object },
+    },
+    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 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{
-        text=status
-      }
-      return h(Tooltip, { title: 'xxxxxx' }, () => h(Tag, { color: color }, () => text));
-    },});
-        columns.push({title:'鍘熷洜',dataIndex:'鍘熷洜'})
-        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{
+      const [register, { setModalProps, closeModal }] = useModalInner((data) => {
+        setModalProps({ confirmLoading: false });
         tableListRef.value = [];
-        createMessage.error('瀵煎叆澶辫触'+res.Message);
-        err.value=res.Message;
-      }
-      
-    }
+      });
+      var err = ref('');
+      async function loadDataSuccess(excelDataList: ExcelData[]) {
+        tableListRef.value = [];
 
-    // function handleVisibleChange(v) {
-    //   v && props.userData && nextTick(() => onDataReceive(props.userData));
-    // }
-//瀵煎嚭
-function aoaToExcel() {
-      const arrHeader = ["鍏宠仈宸ュ崟鍙�","浜у搧缂栫爜","鐗╂枡缂栫爜","鏇夸唬鏂�","鍗曚綅","鍗曚綅鐢ㄩ噺","浜х嚎缂栫爜",
-      "璐寸墖鏈虹紪鐮�","璐寸墖鏈虹紪鐮�","閽㈢綉缂栫爜","绔欎綅鍙�","璐寸墖浣嶇疆","椋炶揪缂栫爜","椋炶揪绫诲瀷","鍔犲伐闈�","涓婃枡椤哄簭",
-      "鍒涘缓浜�","鍒涘缓鏃堕棿"];
+        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
-        //娣诲姞閿¤啅鑳舵按璁板綍
-        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 });
       }
-    }
+      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 };
-  },
-});
+      return {
+        register,
+        model: modelRef,
+        handleSubmit,
+        loadDataSuccess,
+        tableListRef,
+        err,
+        t,
+        aoaToExcel,
+      };
+    },
+  });
 </script>

--
Gitblit v1.9.3