zhaoke 2 лет назад
Родитель
Сommit
89c450bdb5

+ 1 - 0
.env.serve-dev

@@ -1,6 +1,7 @@
 #The defined variable must start with VITE_APP_
 VITE_APP_ENV = 'dev'
 VITE_APP_BASE_URL = 'https://github.jzfai.top/micro-service-api'
+VITE_WEB_BASE_URL = 'http://120.26.64.82:8093'
 
 #image or oss address
 VITE_APP_IMAGE_URL = 'https://github.jzfai.top/gofast-image'

+ 168 - 1
package-lock.json

@@ -14,6 +14,7 @@
         "echarts": "5.3.2",
         "el-table-infinite-scroll": "^3.0.1",
         "element-plus": "^2.2.9",
+        "file-saver": "^2.0.5",
         "js-error-collection": "^1.0.7",
         "mitt": "^3.0.0",
         "moment-mini": "2.22.1",
@@ -23,7 +24,8 @@
         "pinia": "^2.0.16",
         "tinymce": "4.9.11",
         "vue": "^3.2.37",
-        "vue-router": "4.0.14"
+        "vue-router": "4.0.14",
+        "xlsx": "^0.18.5"
       },
       "devDependencies": {
         "@babel/eslint-parser": "7.16.3",
@@ -3279,6 +3281,14 @@
         "node": ">= 10.0.0"
       }
     },
+    "node_modules/adler-32": {
+      "version": "1.3.1",
+      "resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.3.1.tgz",
+      "integrity": "sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==",
+      "engines": {
+        "node": ">=0.8"
+      }
+    },
     "node_modules/ajv": {
       "version": "6.12.6",
       "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
@@ -4459,6 +4469,18 @@
       "integrity": "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==",
       "dev": true
     },
+    "node_modules/cfb": {
+      "version": "1.2.2",
+      "resolved": "https://registry.npmjs.org/cfb/-/cfb-1.2.2.tgz",
+      "integrity": "sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==",
+      "dependencies": {
+        "adler-32": "~1.3.0",
+        "crc-32": "~1.2.0"
+      },
+      "engines": {
+        "node": ">=0.8"
+      }
+    },
     "node_modules/chai": {
       "version": "4.3.6",
       "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.6.tgz",
@@ -4911,6 +4933,14 @@
         "node": ">= 4.0"
       }
     },
+    "node_modules/codepage": {
+      "version": "1.15.0",
+      "resolved": "https://registry.npmjs.org/codepage/-/codepage-1.15.0.tgz",
+      "integrity": "sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA==",
+      "engines": {
+        "node": ">=0.8"
+      }
+    },
     "node_modules/collection-visit": {
       "version": "1.0.0",
       "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz",
@@ -5546,6 +5576,17 @@
         "node": ">=4"
       }
     },
+    "node_modules/crc-32": {
+      "version": "1.2.2",
+      "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz",
+      "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==",
+      "bin": {
+        "crc32": "bin/crc32.njs"
+      },
+      "engines": {
+        "node": ">=0.8"
+      }
+    },
     "node_modules/create-ecdh": {
       "version": "4.0.4",
       "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.4.tgz",
@@ -8577,6 +8618,11 @@
         "webpack": "^4.0.0"
       }
     },
+    "node_modules/file-saver": {
+      "version": "2.0.5",
+      "resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.5.tgz",
+      "integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA=="
+    },
     "node_modules/file-uri-to-path": {
       "version": "1.0.0",
       "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
@@ -8803,6 +8849,14 @@
         "node": ">= 0.6"
       }
     },
+    "node_modules/frac": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmjs.org/frac/-/frac-1.1.2.tgz",
+      "integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==",
+      "engines": {
+        "node": ">=0.8"
+      }
+    },
     "node_modules/fragment-cache": {
       "version": "0.2.1",
       "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz",
@@ -15375,6 +15429,17 @@
       "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==",
       "dev": true
     },
+    "node_modules/ssf": {
+      "version": "0.11.2",
+      "resolved": "https://registry.npmjs.org/ssf/-/ssf-0.11.2.tgz",
+      "integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==",
+      "dependencies": {
+        "frac": "~1.1.2"
+      },
+      "engines": {
+        "node": ">=0.8"
+      }
+    },
     "node_modules/sshpk": {
       "version": "1.17.0",
       "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.17.0.tgz",
@@ -20665,6 +20730,22 @@
       "integrity": "sha512-B+enWhmw6cjfVC7kS8Pj9pCrKSc5txArRyaYGe088shv/FGWH+0Rjx/xPgtsWfsUtS27FkP697E4DDhgrgoc0Q==",
       "dev": true
     },
+    "node_modules/wmf": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/wmf/-/wmf-1.0.2.tgz",
+      "integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==",
+      "engines": {
+        "node": ">=0.8"
+      }
+    },
+    "node_modules/word": {
+      "version": "0.3.0",
+      "resolved": "https://registry.npmjs.org/word/-/word-0.3.0.tgz",
+      "integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA==",
+      "engines": {
+        "node": ">=0.8"
+      }
+    },
     "node_modules/word-wrap": {
       "version": "1.2.3",
       "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
@@ -20757,6 +20838,26 @@
         }
       }
     },
+    "node_modules/xlsx": {
+      "version": "0.18.5",
+      "resolved": "https://registry.npmjs.org/xlsx/-/xlsx-0.18.5.tgz",
+      "integrity": "sha512-dmg3LCjBPHZnQp5/F/+nnTa+miPJxUXB6vtk42YjBBKayDNagxGEeIdWApkYPOf3Z3pm3k62Knjzp7lMeTEtFQ==",
+      "dependencies": {
+        "adler-32": "~1.3.0",
+        "cfb": "~1.2.1",
+        "codepage": "~1.15.0",
+        "crc-32": "~1.2.1",
+        "ssf": "~0.11.2",
+        "wmf": "~1.0.1",
+        "word": "~0.3.0"
+      },
+      "bin": {
+        "xlsx": "bin/xlsx.njs"
+      },
+      "engines": {
+        "node": ">=0.8"
+      }
+    },
     "node_modules/xml-name-validator": {
       "version": "3.0.0",
       "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz",
@@ -23421,6 +23522,11 @@
       "integrity": "sha512-B+6bi5D34+fDYENiH5qOlA0cV2rAGKuWZ9LeyUUehbXy8e0VS9e498yO0Jeeh+iM+6KbfudHTFjXw2MmJD4QRA==",
       "dev": true
     },
+    "adler-32": {
+      "version": "1.3.1",
+      "resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.3.1.tgz",
+      "integrity": "sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A=="
+    },
     "ajv": {
       "version": "6.12.6",
       "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
@@ -24367,6 +24473,15 @@
       "integrity": "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==",
       "dev": true
     },
+    "cfb": {
+      "version": "1.2.2",
+      "resolved": "https://registry.npmjs.org/cfb/-/cfb-1.2.2.tgz",
+      "integrity": "sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==",
+      "requires": {
+        "adler-32": "~1.3.0",
+        "crc-32": "~1.2.0"
+      }
+    },
     "chai": {
       "version": "4.3.6",
       "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.6.tgz",
@@ -24729,6 +24844,11 @@
         "q": "^1.1.2"
       }
     },
+    "codepage": {
+      "version": "1.15.0",
+      "resolved": "https://registry.npmjs.org/codepage/-/codepage-1.15.0.tgz",
+      "integrity": "sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA=="
+    },
     "collection-visit": {
       "version": "1.0.0",
       "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz",
@@ -25255,6 +25375,11 @@
         "parse-json": "^4.0.0"
       }
     },
+    "crc-32": {
+      "version": "1.2.2",
+      "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz",
+      "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ=="
+    },
     "create-ecdh": {
       "version": "4.0.4",
       "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.4.tgz",
@@ -27541,6 +27666,11 @@
         "schema-utils": "^2.5.0"
       }
     },
+    "file-saver": {
+      "version": "2.0.5",
+      "resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.5.tgz",
+      "integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA=="
+    },
     "file-uri-to-path": {
       "version": "1.0.0",
       "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
@@ -27715,6 +27845,11 @@
       "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
       "dev": true
     },
+    "frac": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmjs.org/frac/-/frac-1.1.2.tgz",
+      "integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA=="
+    },
     "fragment-cache": {
       "version": "0.2.1",
       "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz",
@@ -33000,6 +33135,14 @@
       "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==",
       "dev": true
     },
+    "ssf": {
+      "version": "0.11.2",
+      "resolved": "https://registry.npmjs.org/ssf/-/ssf-0.11.2.tgz",
+      "integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==",
+      "requires": {
+        "frac": "~1.1.2"
+      }
+    },
     "sshpk": {
       "version": "1.17.0",
       "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.17.0.tgz",
@@ -36856,6 +36999,16 @@
       "integrity": "sha512-B+enWhmw6cjfVC7kS8Pj9pCrKSc5txArRyaYGe088shv/FGWH+0Rjx/xPgtsWfsUtS27FkP697E4DDhgrgoc0Q==",
       "dev": true
     },
+    "wmf": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/wmf/-/wmf-1.0.2.tgz",
+      "integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw=="
+    },
+    "word": {
+      "version": "0.3.0",
+      "resolved": "https://registry.npmjs.org/word/-/word-0.3.0.tgz",
+      "integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA=="
+    },
     "word-wrap": {
       "version": "1.2.3",
       "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
@@ -36921,6 +37074,20 @@
       "dev": true,
       "requires": {}
     },
+    "xlsx": {
+      "version": "0.18.5",
+      "resolved": "https://registry.npmjs.org/xlsx/-/xlsx-0.18.5.tgz",
+      "integrity": "sha512-dmg3LCjBPHZnQp5/F/+nnTa+miPJxUXB6vtk42YjBBKayDNagxGEeIdWApkYPOf3Z3pm3k62Knjzp7lMeTEtFQ==",
+      "requires": {
+        "adler-32": "~1.3.0",
+        "cfb": "~1.2.1",
+        "codepage": "~1.15.0",
+        "crc-32": "~1.2.1",
+        "ssf": "~0.11.2",
+        "wmf": "~1.0.1",
+        "word": "~0.3.0"
+      }
+    },
     "xml-name-validator": {
       "version": "3.0.0",
       "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz",

+ 3 - 2
package.json

@@ -27,7 +27,7 @@
     "echarts": "5.3.2",
     "el-table-infinite-scroll": "^3.0.1",
     "element-plus": "^2.2.9",
-    "js-cookie": "^3.0.1",
+    "file-saver": "^2.0.5",
     "js-error-collection": "^1.0.7",
     "mitt": "^3.0.0",
     "moment-mini": "2.22.1",
@@ -37,7 +37,8 @@
     "pinia": "^2.0.16",
     "tinymce": "4.9.11",
     "vue": "^3.2.37",
-    "vue-router": "4.0.14"
+    "vue-router": "4.0.14",
+    "xlsx": "^0.18.5"
   },
   "devDependencies": {
     "@babel/eslint-parser": "7.16.3",

+ 1 - 1
src/api/dataIntegration.ts

@@ -72,4 +72,4 @@ export async function myQuery(id, ...dataContent) {
   } catch (error) {
     return Promise.reject(error)
   }
-}
+}

+ 8 - 0
src/api/user.ts

@@ -27,3 +27,11 @@ export function logoutReq() {
     method: 'post'
   })
 }
+
+export function Query(params) {
+  return request({
+    url: '/openApi/query',
+    method: 'post',
+    data: params
+  })
+}

+ 27 - 0
src/api/webApi.ts

@@ -0,0 +1,27 @@
+import request from "@/utils/axiosReq2";
+import { ObjTy } from "~/common";
+
+export function Query(params) {
+  return request({
+    url: "/openApi/query",
+    method: "post",
+    data: params,
+  });
+}
+
+export async function myQuery(id, ...dataContent) {
+  const params = {
+    id,
+    dataContent,
+  };
+  try {
+    const result = await Query(params);
+    if (Number(result.code) === 0) {
+      return result.returnData.listValues;
+    } else {
+      return Promise.reject(result.message);
+    }
+  } catch (error) {
+    return Promise.reject(error);
+  }
+}

+ 4 - 1
src/components/tableTemp/index.vue

@@ -1,5 +1,5 @@
 <template>
-  <el-table v-el-table-infinite-scroll="load" :row-key="
+  <el-table ref="table" v-el-table-infinite-scroll="load" :row-key="
       props.tableProperty.rowKey
         ? props.tableProperty.rowKey
         : tablePropertyDefault.rowKey
@@ -223,8 +223,11 @@ const load = () => {
   emit("load", true);
 };
 
+const table = ref(null)
+
 defineExpose({
   cellClass,
+  table
 });
 </script>
 

+ 4 - 4
src/utils/axiosReq.ts

@@ -20,7 +20,7 @@ service.interceptors.request.use(
     }
     /* upload file*/
     if (request.isUploadFile) {
-      request.headers['Content-Type'] = 'multipart/form-data'
+      request.headers['Content-Type'] = 'application/json'
     }
     reqConfig = request
     if (request.bfLoading) {
@@ -56,9 +56,9 @@ service.interceptors.response.use(
     }
     const { flag, msg, isNeedUpdateToken, updateToken, code } = res.data
     //更新token保持登录状态
-    if (isNeedUpdateToken) {
-      setToken(updateToken)
-    }
+    // if (isNeedUpdateToken) {
+    //   setToken(updateToken)
+    // }
     const successCode = '0,200,20000'
     if (successCode.includes(code)) {
       return res.data

+ 140 - 0
src/utils/axiosReq2.ts

@@ -0,0 +1,140 @@
+import axios from 'axios'
+import router from '@/router'
+import { ElLoading, ElMessage, ElMessageBox } from 'element-plus'
+import { getToken, setToken } from '@/utils/auth'
+import { AxiosConfigTy, AxiosReqTy, ObjTy } from '~/common'
+import { useUserStore } from '@/store/user'
+let reqConfig: any
+let loadingE: any
+
+const service: any = axios.create()
+
+// 请求拦截
+service.interceptors.request.use(
+  (request: AxiosReqTy) => {
+    // token setting
+    request.headers['AUTHORIZE_TOKEN'] = getToken()
+    request.headers['token'] = "4cdc82f3d9374abc9cd2c940170a770b"
+    request.data["OperatorId"] ="1656481036138";
+    /* download file*/
+    if (request.isDownLoadFile) {
+      request.responseType = 'blob'
+    }
+    /* upload file*/
+    if (request.isUploadFile) {
+      request.headers['Content-Type'] = 'application/json'
+    }
+    reqConfig = request
+    if (request.bfLoading) {
+      loadingE = ElLoading.service({
+        lock: true,
+        text: '数据载入中',
+        // spinner: 'el-icon-ElLoading',
+        background: 'rgba(0, 0, 0, 0.1)'
+      })
+    }
+    /*
+     *params会拼接到url上
+     * */
+    if (request.isParams) {
+      request.params = request.data
+      request.data = {}
+    }
+    return request
+  },
+  (err: any) => {
+    Promise.reject(err)
+  }
+)
+// 响应拦截
+service.interceptors.response.use(
+  (res: any) => {
+    if (reqConfig.afHLoading && loadingE) {
+      loadingE.close()
+    }
+    // 如果是下载文件直接返回
+    if (reqConfig.isDownLoadFile) {
+      return res
+    }
+    const { flag, msg, isNeedUpdateToken, updateToken, code } = res.data
+    //更新token保持登录状态
+    if (isNeedUpdateToken) {
+      setToken(updateToken)
+    }
+    const successCode = '0,200,20000'
+    if (successCode.includes(code)) {
+      return res.data
+    } else {
+      if (code === 403) {
+        ElMessageBox.confirm('请重新登录', {
+          confirmButtonText: '重新登录',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          const userStore = useUserStore()
+          userStore.resetState().then(() => {
+            router.push({ path: '/login' })
+          })
+        })
+      }
+      if (reqConfig.isAlertErrorMsg) {
+        ElMessage({
+          message: msg,
+          type: 'error',
+          duration: 2 * 1000
+        })
+      }
+      //返回错误信息
+      //如果未catch 走unhandledrejection进行收集
+      //注:如果没有return 则,会放回到请求方法中.then ,返回的res为 undefined
+      return Promise.reject(res.data)
+    }
+  },
+  (err: any) => {
+    /*http错误处理,处理跨域,404,401,500*/
+    if (loadingE) loadingE.close()
+    ElMessage({
+      message: err,
+      type: 'error',
+      duration: 2 * 1000
+    })
+    //如果是跨域
+    //Network Error,cross origin
+    const errObj: ObjTy = {
+      msg: err.toString(),
+      reqUrl: reqConfig.baseURL + reqConfig.url,
+      params: reqConfig.isParams ? reqConfig.params : reqConfig.data
+    }
+    return Promise.reject(JSON.stringify(errObj))
+  }
+)
+
+export function axiosReq({
+  url,
+  data,
+  method,
+  isParams,
+  bfLoading,
+  afHLoading,
+  isUploadFile,
+  isDownLoadFile,
+  baseURL,
+  timeout,
+  isAlertErrorMsg = true
+}: AxiosConfigTy): any {
+  return service({
+    url: url,
+    method: method ?? 'get',
+    data: data ?? {},
+    isParams: isParams ?? false,
+    bfLoading: bfLoading ?? false,
+    afHLoading: afHLoading ?? true,
+    isUploadFile: isUploadFile ?? false,
+    isDownLoadFile: isDownLoadFile ?? false,
+    isAlertErrorMsg: isAlertErrorMsg,
+    baseURL: baseURL ?? import.meta.env.VITE_WEB_BASE_URL,
+    timeout: timeout ?? 15000
+  })
+}
+
+export default axiosReq

+ 22 - 0
src/views/baggageManagement/arrival/flight/index.vue

@@ -66,6 +66,7 @@ import tableColumnSet from "@/components/tableColumnSet/index.vue";
 import Search from "@/components/search/index.vue";
 import {CaretRight} from "@element-plus/icons-vue"
 import { ref, onMounted } from 'vue';
+import { Query } from '@/api/webApi'
 
 const state = reactive({
   tableHeader: [
@@ -188,6 +189,7 @@ const test = (row) => {
 
 const loadMore=(data)=>{
   setError()
+  queryData()
   console.log(data);
 
 }
@@ -227,6 +229,26 @@ const closeDialog = (data) => {
   state.dialogVisible = false;
 }
 
+const queryData = async() => {
+      return new Promise((resolve, reject) => {
+        let data = {
+          dataContent: [],
+          id: 16
+        }
+        Query(data)
+          .then((res) => {
+            if (res.code === 200 ) {
+              //commit('SET_Token', res.data?.jwtToken)
+              console.log(res)
+            } else {
+              reject(res)
+            }
+          })
+          .catch((error: any) => {
+            reject(error)
+          })
+      })
+    }
 
 </script>
 <style lang="scss" scoped>

+ 1 - 1
src/views/baggageManagement/components/CountBox/index.vue

@@ -29,7 +29,7 @@ const props = defineProps({
     default: '总数',
   },
 })
-const numberBoxes = ref<HTMLInputElement[] | undefined[]>([])
+const numberBoxes = ref<HTMLElement[] | undefined[]>([])
 const numberItems = computed(() => {
   let numberString = props.countNumber.toString()
   if (numberString.length > props.length) {

+ 7 - 1
src/views/baggageManagement/departure/flight/index.vue

@@ -66,6 +66,7 @@ import Search from "@/components/search/index.vue";
 import tableColumnSet from "@/components/tableColumnSet/index.vue";
 import {CaretRight} from "@element-plus/icons-vue"
 import { ref } from 'vue';
+import useTableExport from "../../hooks/useTableExport";
 
 const state = reactive({
   tableHeader: [
@@ -205,9 +206,14 @@ const refresh=(data) =>{
   console.log(data)
 }
 
+const domeTable = ref(null)
+const { exportToExcel } = useTableExport()
 //点击下载按钮
 const downLoad=(data) =>{
-  console.log(data)
+  const table = ref(domeTable.value.table)
+  exportToExcel({
+    table
+  })
 }
 
 //点击列设置按钮

+ 62 - 0
src/views/baggageManagement/hooks/useTableExport.ts

@@ -0,0 +1,62 @@
+import { Ref } from 'vue'
+import { ElMessage, ElTable } from 'element-plus'
+import * as XLSX from 'xlsx'
+import FileSaver from 'file-saver'
+
+type ElTableType = InstanceType<typeof ElTable>
+interface ExportOptions {
+  table: ElTableType | Ref<ElTableType>
+  sheetName?: string
+  fileName?: string
+  headerRowNumber?: number
+}
+type ExportHandler = (option: ExportOptions) => void
+
+export default function useTableExport() {
+  const exportToExcel: ExportHandler = ({
+    table,
+    sheetName = 'sheet1',
+    fileName = '导出表格.xlsx',
+    headerRowNumber = 1,
+  }) => {
+    try {
+      const tableNode = (('$el' in table
+        ? table.$el
+        : table.value.$el) as HTMLElement).cloneNode(true) as HTMLElement
+      // 设置了列的fixed属性后会有两个table元素,导出数据会重复,需要去掉一个table
+      const fixedTable = tableNode.querySelector('.el-table__fixed')
+      fixedTable && tableNode.removeChild(fixedTable)
+      // 自定义的表头里包含筛选,直接导出会把筛选的下拉数据也写到表头单元格里,需要先去掉筛选弹出框
+      const tableHeaderCellPopovers = tableNode.querySelectorAll(
+        '.table-header-cell-popover'
+      )
+      tableHeaderCellPopovers.forEach(node => {
+        const childNode = node.querySelector('.el-popover')
+        if (childNode) {
+          node.removeChild(childNode)
+        }
+      })
+      // 生成要导出的xlsx数据对象,raw: true表示不使用excel的格式解析,输出为纯文本,sheet设置xlsx这一页的标题
+      const tableBook = XLSX.utils.table_to_book(tableNode, {
+        raw: true,
+        sheet: sheetName,
+      })
+      const tableBuffer = XLSX.write(tableBook, {
+        bookType: 'xlsx',
+        bookSST: true,
+        type: 'buffer',
+        cellStyles: true,
+      })
+      FileSaver.saveAs(
+        new Blob([tableBuffer], { type: 'application/octet-stream' }),
+        fileName
+      )
+    } catch (error: any) {
+      ElMessage.error(error.message)
+    }
+  }
+
+  return {
+    exportToExcel,
+  }
+}

+ 49 - 18
src/views/systemSettings/queryTemplate/index.vue

@@ -10,7 +10,7 @@
       >
       <div class="app-containers">
         <DataTable
-          :tableHeader="state.list"
+          :tableHeader="tableCols"
           :tableData="tableData"
           :tableBtnGroup="tableBtnGroup"
           :tableProperty="{ rowKey: 'ID' }"
@@ -24,7 +24,15 @@
 import DataTable from "@/components/tableTemp/index.vue";
 import Minheader from "@/components/minheader/index.vue";
 import Dialog from "@/components/dialog/index.vue";
+import { Query } from "@/api/webApi";
 const router = useRouter();
+const dataId = ref<String>("4"); //请求id
+const page = ref<number>(0); //分页参数
+const dataContent = ref<object>({});
+const noMore = ref<Boolean>(false);
+const rowTitle = ref<String>("");
+const tableCols = ref([]); //表头数据
+const serviceId = ref<String>("");
 const flag = ref<Boolean>(false); //弹窗开关
 const type = ref<String>(""); //判断是否删除
 const msgTitle = ref<String>("新增查询模板"); //弹窗标题
@@ -39,23 +47,7 @@ const tableForm = reactive({
   text: "",
 }); //弹窗内容
 //列表
-const tableData = ref([
-  {
-    name: "测试",
-    china: "测试",
-    englin: "测试",
-  },
-  {
-    name: "测试",
-    china: "测试",
-    englin: "测试",
-  },
-  {
-    name: "测试",
-    china: "测试",
-    englin: "测试",
-  },
-]);
+const tableData = ref([]);
 //表头
 const state = reactive({
   list: [
@@ -127,6 +119,45 @@ const eleDialog = () => {
 const delRest = () => {
   flag.value = false;
 };
+//获取表格数据
+const getQuery = async () => {
+  try {
+    const { code, returnData } = await Query({
+      id: dataId.value,
+      needPage: ++page.value,
+      dataContent: Object.values(dataContent.value),
+    });
+    if (code === "0") {
+      if (returnData.listValues.length === 0) {
+        page.value--;
+        noMore.value = true;
+      }
+      const titleColumn = returnData.columnSet.find(
+        (item) => item.needShow === 1
+      );
+      if (titleColumn) {
+        rowTitle.value = titleColumn.columnName;
+      }
+      tableData.value.push(...returnData.listValues);
+      tableCols.value = returnData.columnSet;
+      tableCols.value.forEach((element) => {
+        element.label = element.columnLabel;
+        element.key = element.columnName;
+        // if (element.columnName === "queryTemplate") {
+        //   element.width = "300px";
+        // }
+      });
+      serviceId.value = returnData.submitID;
+    } else {
+      page.value--;
+    }
+  } catch (error) {
+    page.value--;
+  }
+};
+onMounted(() => {
+  getQuery();
+});
 </script>
 <style lang="scss" scoped>
 ::v-deep .el-form-item__label {

+ 69 - 13
src/views/systemSettings/queryTemplate/queryTemplateAdd.vue

@@ -18,13 +18,27 @@
           <el-col :span="5">
             <el-form-item label="查询模板名称" size="default">
               <el-input
-                v-model="tableForm.name"
+                v-model="tableForm.queryTemplateName"
                 placeholder="请输入查询模板名称"
               />
             </el-form-item>
           </el-col>
           <el-col :span="5">
-            <el-form-item label="查询协议" size="default">
+            <el-form-item label="数据源" prop="dataSourceID" size="default">
+              <el-select
+                v-model="tableForm.dataSourceID"
+                placeholder="请选择"
+                clearable
+              >
+                <el-option
+                  v-for="item in tableOptionser"
+                  :key="item.v"
+                  :label="item.k"
+                  :value="item.v"
+                />
+              </el-select>
+            </el-form-item>
+            <!-- <el-form-item label="查询协议" size="default">
               <el-select
                 style="width: 100%"
                 v-model="tableForm.china"
@@ -42,12 +56,12 @@
                 >
                 </el-option>
               </el-select>
-            </el-form-item>
+            </el-form-item> -->
           </el-col>
           <el-col :span="14">
             <el-form-item label="查询模板描述" size="default">
               <el-input
-                v-model="tableForm.englin"
+                v-model="tableForm.queryTemplateDescribe"
                 placeholder="请输入查询模板描述"
               />
             </el-form-item>
@@ -67,7 +81,7 @@
               <el-input
                 :autosize="{ minRows: 24, maxRows: 24 }"
                 type="textarea"
-                v-model="tableForm.three"
+                v-model="tableForm.serviceName"
                 placeholder="请输入查询语句"
               />
             </el-form-item>
@@ -80,20 +94,62 @@
 
 <script setup lang="ts">
 import Minheader from "@/components/minheader/index.vue";
+import { Query, myQuery } from "@/api/webApi";
 const router = useRouter();
 const tableOptionser = ref<Array>([]); //下拉
 const tableForm = reactive({
-  name: "",
-  china: "",
-  englin: "",
-  two: "",
-  three: "",
-  text: "",
+  queryTemplateName: "",
+  queryTemplateDescribe: "",
+  submitID: null,
+  queryTemplate: "",
+  pageRows: null,
+  serviceName: "",
+  dataSourceID: "",
 }); //内容
 //保存
-const preserForm = () => {
-  router.push({ path: "/systemSettings/queryTemplate" });
+const preserForm = async () => {
+  const params = {
+    ...tableForm,
+    submitID: tableForm.serviceID,
+  };
+  delete params.serviceID;
+  try {
+    const res = await Query({
+      serviceId: "5",
+      dataContent: JSON.stringify(params),
+    });
+    if (Number(res.code) === 0) {
+      // this.$message.success(res.message ?? "成功");
+      // this.$router.push("/systemSettings/queryTemplate");
+    } else {
+      // this.$message.error(res.message ?? "失败");
+    }
+  } catch (error) {
+    // this.$message.error("失败");
+  }
+  // router.push({ path: "/systemSettings/queryTemplate" });
+};
+const getDataSourceList = async () => {
+  const tableOptionser = await getSelectOption(13);
+  tableOptionser.value = tableOptionser.map((item) => {
+    item[item.setlabel] = item.k;
+    item[item.setvalue] = item.v;
+    return item;
+  });
 };
+const getSelectOption = async (ID) => {
+  try {
+    const listValues = await myQuery(ID);
+    return listValues;
+  } catch (error) {
+    // this.$message.error(error)
+    return [];
+  }
+};
+
+onMounted(() => {
+  getDataSourceList();
+});
 </script>
 
 <style lang="scss" scoped>