| @@ -1721,16 +1721,6 @@ | |||
| "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", | |||
| "dev": true | |||
| }, | |||
| "ansi-styles": { | |||
| "version": "4.3.0", | |||
| "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", | |||
| "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", | |||
| "dev": true, | |||
| "optional": true, | |||
| "requires": { | |||
| "color-convert": "^2.0.1" | |||
| } | |||
| }, | |||
| "cacache": { | |||
| "version": "13.0.1", | |||
| "resolved": "https://registry.npmjs.org/cacache/-/cacache-13.0.1.tgz", | |||
| @@ -1763,34 +1753,6 @@ | |||
| "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", | |||
| "dev": true | |||
| }, | |||
| "chalk": { | |||
| "version": "4.1.0", | |||
| "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", | |||
| "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", | |||
| "dev": true, | |||
| "optional": true, | |||
| "requires": { | |||
| "ansi-styles": "^4.1.0", | |||
| "supports-color": "^7.1.0" | |||
| } | |||
| }, | |||
| "color-convert": { | |||
| "version": "2.0.1", | |||
| "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", | |||
| "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", | |||
| "dev": true, | |||
| "optional": true, | |||
| "requires": { | |||
| "color-name": "~1.1.4" | |||
| } | |||
| }, | |||
| "color-name": { | |||
| "version": "1.1.4", | |||
| "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", | |||
| "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", | |||
| "dev": true, | |||
| "optional": true | |||
| }, | |||
| "css-loader": { | |||
| "version": "3.6.0", | |||
| "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-3.6.0.tgz", | |||
| @@ -1834,13 +1796,6 @@ | |||
| } | |||
| } | |||
| }, | |||
| "has-flag": { | |||
| "version": "4.0.0", | |||
| "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", | |||
| "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", | |||
| "dev": true, | |||
| "optional": true | |||
| }, | |||
| "icss-utils": { | |||
| "version": "4.1.1", | |||
| "resolved": "https://registry.npmjs.org/icss-utils/-/icss-utils-4.1.1.tgz", | |||
| @@ -1850,18 +1805,6 @@ | |||
| "postcss": "^7.0.14" | |||
| } | |||
| }, | |||
| "loader-utils": { | |||
| "version": "2.0.0", | |||
| "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz", | |||
| "integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==", | |||
| "dev": true, | |||
| "optional": true, | |||
| "requires": { | |||
| "big.js": "^5.2.2", | |||
| "emojis-list": "^3.0.0", | |||
| "json5": "^2.1.2" | |||
| } | |||
| }, | |||
| "postcss-modules-extract-imports": { | |||
| "version": "2.0.0", | |||
| "resolved": "https://registry.npmjs.org/postcss-modules-extract-imports/-/postcss-modules-extract-imports-2.0.0.tgz", | |||
| @@ -1925,16 +1868,6 @@ | |||
| "minipass": "^3.1.1" | |||
| } | |||
| }, | |||
| "supports-color": { | |||
| "version": "7.2.0", | |||
| "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", | |||
| "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", | |||
| "dev": true, | |||
| "optional": true, | |||
| "requires": { | |||
| "has-flag": "^4.0.0" | |||
| } | |||
| }, | |||
| "terser-webpack-plugin": { | |||
| "version": "2.3.8", | |||
| "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-2.3.8.tgz", | |||
| @@ -1951,18 +1884,6 @@ | |||
| "terser": "^4.6.12", | |||
| "webpack-sources": "^1.4.3" | |||
| } | |||
| }, | |||
| "vue-loader-v16": { | |||
| "version": "npm:vue-loader@16.1.2", | |||
| "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.1.2.tgz", | |||
| "integrity": "sha512-8QTxh+Fd+HB6fiL52iEVLKqE9N1JSlMXLR92Ijm6g8PZrwIxckgpqjPDWRP5TWxdiPaHR+alUWsnu1ShQOwt+Q==", | |||
| "dev": true, | |||
| "optional": true, | |||
| "requires": { | |||
| "chalk": "^4.1.0", | |||
| "hash-sum": "^2.0.0", | |||
| "loader-utils": "^2.0.0" | |||
| } | |||
| } | |||
| } | |||
| }, | |||
| @@ -11219,6 +11140,87 @@ | |||
| } | |||
| } | |||
| }, | |||
| "vue-loader-v16": { | |||
| "version": "npm:vue-loader@16.2.0", | |||
| "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.2.0.tgz", | |||
| "integrity": "sha512-TitGhqSQ61RJljMmhIGvfWzJ2zk9m1Qug049Ugml6QP3t0e95o0XJjk29roNEiPKJQBEi8Ord5hFuSuELzSp8Q==", | |||
| "dev": true, | |||
| "optional": true, | |||
| "requires": { | |||
| "chalk": "^4.1.0", | |||
| "hash-sum": "^2.0.0", | |||
| "loader-utils": "^2.0.0" | |||
| }, | |||
| "dependencies": { | |||
| "ansi-styles": { | |||
| "version": "4.3.0", | |||
| "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", | |||
| "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", | |||
| "dev": true, | |||
| "optional": true, | |||
| "requires": { | |||
| "color-convert": "^2.0.1" | |||
| } | |||
| }, | |||
| "chalk": { | |||
| "version": "4.1.0", | |||
| "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", | |||
| "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", | |||
| "dev": true, | |||
| "optional": true, | |||
| "requires": { | |||
| "ansi-styles": "^4.1.0", | |||
| "supports-color": "^7.1.0" | |||
| } | |||
| }, | |||
| "color-convert": { | |||
| "version": "2.0.1", | |||
| "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", | |||
| "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", | |||
| "dev": true, | |||
| "optional": true, | |||
| "requires": { | |||
| "color-name": "~1.1.4" | |||
| } | |||
| }, | |||
| "color-name": { | |||
| "version": "1.1.4", | |||
| "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", | |||
| "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", | |||
| "dev": true, | |||
| "optional": true | |||
| }, | |||
| "has-flag": { | |||
| "version": "4.0.0", | |||
| "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", | |||
| "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", | |||
| "dev": true, | |||
| "optional": true | |||
| }, | |||
| "loader-utils": { | |||
| "version": "2.0.0", | |||
| "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz", | |||
| "integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==", | |||
| "dev": true, | |||
| "optional": true, | |||
| "requires": { | |||
| "big.js": "^5.2.2", | |||
| "emojis-list": "^3.0.0", | |||
| "json5": "^2.1.2" | |||
| } | |||
| }, | |||
| "supports-color": { | |||
| "version": "7.2.0", | |||
| "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", | |||
| "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", | |||
| "dev": true, | |||
| "optional": true, | |||
| "requires": { | |||
| "has-flag": "^4.0.0" | |||
| } | |||
| } | |||
| } | |||
| }, | |||
| "vue-router": { | |||
| "version": "3.5.1", | |||
| "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.5.1.tgz", | |||
| @@ -63,6 +63,7 @@ | |||
| <v-select v-model="insertItem.department" outlined rounded :items="departments" label="部門"/> | |||
| <v-text-field v-model="insertItem.account" outlined rounded label="帳號" /> | |||
| <v-text-field v-model="insertItem.pwd" outlined rounded label="密碼" /> | |||
| <v-select v-model="insertItem.level" outlined rounded label="權限" :items="levelSelectItem" /> | |||
| </v-container> | |||
| </v-card-text> | |||
| <v-card-actions> | |||
| @@ -86,6 +87,11 @@ | |||
| </v-dialog> | |||
| </v-toolbar> | |||
| </template> | |||
| <template v-slot:item.level="{ item }"> | |||
| <p>{{item.level === '0' ? '超級管理員' : ''}}</p> | |||
| <p>{{item.level === '1' ? '一般管理員' : ''}}</p> | |||
| <p>{{item.level === '2' ? '一般使用者' : ''}}</p> | |||
| </template> | |||
| <template v-slot:item.actions="{ item }"> | |||
| <div class="d-flex"> | |||
| <v-btn | |||
| @@ -121,6 +127,7 @@ | |||
| <v-select v-model="modifyItem.department" outlined rounded :items="departments" label="部門"/> | |||
| <v-text-field v-model="modifyItem.account" outlined rounded label="帳號" /> | |||
| <v-text-field v-model="modifyItem.pwd" outlined rounded label="密碼" /> | |||
| <v-select v-model="modifyItem.level" outlined rounded label="權限" :items="levelSelectItem" /> | |||
| </v-container> | |||
| </v-card-text> | |||
| <v-card-actions> | |||
| @@ -158,7 +165,8 @@ | |||
| {'text': '部門', 'value': 'department'}, | |||
| // {'text': '型態', 'value': 'type'}, | |||
| {'text': '帳號', 'value': 'account'}, | |||
| {'text': '密碼', 'value': 'pwd'}], | |||
| {'text': '密碼', 'value': 'pwd'}, | |||
| {'text': '權限', 'value': 'level'}], | |||
| items: [], | |||
| departments: [], | |||
| insertItem: { | |||
| @@ -178,6 +186,9 @@ | |||
| id: "", | |||
| }, | |||
| progress: false, | |||
| levelSelectItem: [{'text': '超級管理員', 'value': '0'}, | |||
| {'text': '一般管理員', 'value': '1'}, | |||
| {'text': '一般使用者', 'value': '2'}], | |||
| } | |||
| }, | |||
| async mounted() { | |||
| @@ -247,13 +247,15 @@ | |||
| md='4' | |||
| class='d-flex' | |||
| > | |||
| <!--文字型欄位--> | |||
| <v-text-field | |||
| v-if="header.text !== '' && header.value !== 'isselect' && isBooleanCol.indexOf(header.value) < 0" | |||
| v-if="header.text !== '' && header.value !== 'isselect' && isBooleanCol.indexOf(header.value) < 0 && header.value !== 'descript2'" | |||
| :label='header.text' | |||
| :value="insertColItem[header.value]" | |||
| hint='必填' | |||
| v-on:input='oninput(insertColItem, header.value, $event)' | |||
| /> | |||
| <!--選項型欄位--> | |||
| <v-select | |||
| v-if="header.value === 'isselect' && isBooleanCol.indexOf(header.value) < 0" | |||
| :label='header.text' hint='必填' | |||
| @@ -262,6 +264,7 @@ | |||
| :item-text="selectColItem.isselect.text" | |||
| :item-value="selectColItem.isselect.value" | |||
| /> | |||
| <!--資產類別細項欄位--> | |||
| <v-select | |||
| v-if="header.value && isBooleanCol.indexOf(header.value) >= 0" | |||
| :label='header.text' hint='必填' | |||
| @@ -276,6 +279,12 @@ | |||
| > | |||
| 編輯選項 | |||
| </v-btn> | |||
| <!--欄位說明欄位--> | |||
| <v-textarea v-if="header.text === '欄位說明'" | |||
| :label='header.text' hint='必填' | |||
| v-on:input='oninput(insertColItem, header.value, $event)' | |||
| auto-grow | |||
| rows="1" /> | |||
| </v-col> | |||
| </v-row> | |||
| </v-container> | |||
| @@ -374,13 +383,15 @@ | |||
| md='4' | |||
| class='d-flex' | |||
| > | |||
| <!--文字型欄位--> | |||
| <v-text-field | |||
| v-if="header.text !== '' && header.value !== 'isselect' && isBooleanCol.indexOf(header.value) < 0" | |||
| v-if="header.text !== '' && header.value !== 'isselect' && isBooleanCol.indexOf(header.value) < 0 && header.value !== 'descript2'" | |||
| :label='header.text' | |||
| :value="modifyColItem[header.value]" | |||
| hint='必填' | |||
| v-on:input='oninput(modifyColItem, header.value, $event)' | |||
| /> | |||
| <!--選項型欄位--> | |||
| <v-select | |||
| v-if="header.value === 'isselect' && isBooleanCol.indexOf(header.value) < 0" | |||
| :label='header.text' hint='必填' | |||
| @@ -390,6 +401,7 @@ | |||
| :item-text="selectColItem.isselect.text" | |||
| :item-value="selectColItem.isselect.value" | |||
| /> | |||
| <!--資產類別細項欄位--> | |||
| <v-select | |||
| v-if="header.value && isBooleanCol.indexOf(header.value) >= 0" | |||
| :label='header.text' hint='必填' | |||
| @@ -405,6 +417,13 @@ | |||
| > | |||
| 編輯選項 | |||
| </v-btn> | |||
| <!--欄位說明欄位--> | |||
| <v-textarea v-if="header.text === '欄位說明'" | |||
| :label='header.text' hint='必填' | |||
| :value="modifyColItem[header.value]" | |||
| v-on:input='oninput(modifyColItem, header.value, $event)' | |||
| auto-grow | |||
| rows="1" /> | |||
| </v-col> | |||
| </v-row> | |||
| </v-container> | |||
| @@ -514,6 +533,7 @@ | |||
| {'text': '文字框或選項', 'value': 'isselect'}, | |||
| {'text': '順序', 'value': 'index'}, | |||
| {'text': '必填', 'value': 'isrequire'}, | |||
| {'text': '欄位說明', 'value': 'descript2'}, | |||
| // {'text': '可匯出', 'value': 'isexport'}, | |||
| // {'text': '可搜尋', 'value': 'issearch'}, | |||
| ], | |||
| @@ -165,7 +165,7 @@ | |||
| drawer: null, | |||
| error: false, | |||
| message: "", | |||
| items: [{'text': '全域搜尋', 'route': '/search'}, {text: '資訊資產群組', route: '/asset_group'}], | |||
| items: [{'text': '全域搜尋', 'route': '/search'}], | |||
| username: localStorage.getItem('username'), | |||
| this1: this, | |||
| menuitems: [ | |||
| @@ -200,6 +200,7 @@ | |||
| this.$emit("authenticated", null); | |||
| }, | |||
| async getRoutes() { | |||
| this.addFeatureByLevel(localStorage.getItem('level')); | |||
| this.$axios.get('/routes').then((resp) => { | |||
| resp.data.data.forEach((item) => { | |||
| let route = {'text': '', 'route': ''}; | |||
| @@ -208,12 +209,19 @@ | |||
| this.items.push(route); | |||
| }); | |||
| if (localStorage.getItem('level') === '0') { | |||
| this.items.push({'text': '帳號管理', 'route': '/account'}); | |||
| } | |||
| console.log(this.items); | |||
| }); | |||
| }, | |||
| addFeatureByLevel(level) { | |||
| //超級管理員 | |||
| if (level === '0') { | |||
| this.items.push({'text': '資訊資產群組', 'route': '/asset_group'}); | |||
| this.items.push({'text': '帳號與權限管理', 'route': '/account'}); | |||
| } | |||
| //一般管理員 | |||
| if (level === '1') { | |||
| this.items.push({text: '資訊資產群組', route: '/asset_group'}); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| </script> | |||
| @@ -1,201 +0,0 @@ | |||
| <template> | |||
| <div class="dashboard"> | |||
| <h1>歷史報表檢視</h1> | |||
| <v-card> | |||
| <v-card-title> | |||
| 歷史報表 -- 共 {{reports.length}} 筆 | |||
| <v-spacer></v-spacer> | |||
| <v-select | |||
| v-model="select" | |||
| :items="reportconfs" | |||
| :rules="[v => !!v || '必須要選擇一個報表']" | |||
| label="選擇報表" | |||
| required | |||
| item-text="nameId" | |||
| item-value="id" | |||
| @change="loadReport()" | |||
| ></v-select> | |||
| <div class="px-1"></div> | |||
| <v-menu | |||
| v-model="menu2" | |||
| :close-on-content-click="false" | |||
| :nudge-right="40" | |||
| transition="scale-transition" | |||
| offset-y | |||
| min-width="100px" | |||
| class="mr-3" | |||
| > | |||
| <template v-slot:activator="{ on }"> | |||
| <v-text-field | |||
| v-model="date" | |||
| label="選擇報表日期" | |||
| prepend-icon="mdi-calendar" | |||
| readonly | |||
| v-on="on" | |||
| @change="loadReport()" | |||
| ></v-text-field> | |||
| </template> | |||
| <v-date-picker v-model="date" @input="menu2 = false;loadReport()"></v-date-picker> | |||
| </v-menu> | |||
| <div v-if="isAdmin" class="pl-4 mb-3"> | |||
| <v-tooltip bottom> | |||
| <template v-slot:activator="{ on, attrs }"> | |||
| <v-btn | |||
| color="primary" | |||
| dark | |||
| v-bind="attrs" | |||
| v-on="on" | |||
| @click="generateReport()" | |||
| > | |||
| 重新產生報表 | |||
| </v-btn> | |||
| </template> | |||
| <span>以選定日期重新產生報表, 不會發送 Email 及 FTP</span> | |||
| </v-tooltip> | |||
| </div> | |||
| </v-card-title> | |||
| <v-data-table | |||
| :headers="headers" | |||
| :items="reports" | |||
| :search="search" | |||
| > | |||
| <template v-slot:item.fileName="{ item }"> | |||
| <a href="javascript:void(0)" @click="download(item.filePath)">{{item.fileName}}</a> | |||
| </template> | |||
| </v-data-table> | |||
| </v-card> | |||
| <v-snackbar | |||
| v-model="snackbar" | |||
| :color="snackbarColor" | |||
| :timeout="snackbarTimeout" | |||
| absolute | |||
| right | |||
| rounded="pill" | |||
| top | |||
| > | |||
| {{snackbarMessage}}. | |||
| </v-snackbar> | |||
| </div> | |||
| </template> | |||
| <script> | |||
| import axios from 'axios'; | |||
| export default { | |||
| name: 'AssetGroup', | |||
| data () { | |||
| return { | |||
| search: '', | |||
| select: null, | |||
| reportconfs: [], | |||
| date: new Date().toISOString().substr(0, 10), | |||
| menu2: false, | |||
| headers: [ | |||
| { text: '檔案名稱', value: 'fileName',}, | |||
| { text: '產生時間', value: 'fileDate' }, | |||
| // { text: '產生狀態', value: 'genstate' }, | |||
| // { text: 'FTP 狀態', value: 'ftpstate' }, | |||
| // { text: 'Email 狀態', value: 'emailstate' }, | |||
| ], | |||
| reports: [], | |||
| snackbar: false, | |||
| snackbarMessage: "", | |||
| snackbarColor: "blue-grey", | |||
| snackbarTimeout: 1000, | |||
| } | |||
| }, | |||
| created() { | |||
| this.initialize(); | |||
| }, | |||
| computed: { | |||
| isAdmin() { | |||
| let roles = localStorage.getItem( 'roles'); | |||
| let admin = (roles != null && roles.indexOf('ADMIN') >= 0 ); | |||
| console.log("isAdmin", admin); | |||
| return admin; | |||
| } | |||
| }, | |||
| methods: { | |||
| initialize() { | |||
| // axios.get("/api/access/reportview/listconf", this.editedItem) | |||
| // .then((result) => { | |||
| // let json = result.data; | |||
| // this.reportconfs = json.data | |||
| // if (this.reportconfs && this.reportconfs.length > 0) { | |||
| // this.select = this.reportconfs[0].id; | |||
| // this.loadReport(); | |||
| // } | |||
| // }); | |||
| }, | |||
| loadReport() { | |||
| axios.get("/api/access/reportview/listreport/"+ this.select + "/" + this.date) | |||
| .then((result) => { | |||
| let json = result.data; | |||
| if (json.status === "OK") | |||
| this.reports = json.data; | |||
| else { | |||
| this.reports = []; | |||
| this.$root.$emit('showError', json.message); | |||
| } | |||
| }); | |||
| }, | |||
| download(file) { | |||
| axios({ | |||
| url: '/api/access/reportview/download?file=' + file, //your url | |||
| method: 'GET', | |||
| responseType: 'blob', // important | |||
| }).then((response) => { | |||
| const url = window.URL.createObjectURL(new Blob([response.data])); | |||
| const link = document.createElement('a'); | |||
| console.log(response); | |||
| console.log(file); | |||
| file = file.replace("\\", "/"); | |||
| const fileName = file.substr(file.lastIndexOf("/")+1); | |||
| link.href = url; | |||
| link.setAttribute('download', fileName); //or any other extension | |||
| document.body.appendChild(link); | |||
| link.click(); | |||
| }); | |||
| }, | |||
| generateReport() { | |||
| let reportId = this.select; | |||
| let date = this.date; | |||
| axios({ | |||
| url: '/api/access/reportview/genreport/' + reportId + "/" + date, //your url | |||
| method: 'GET', | |||
| }).then((response) => { | |||
| let json = response.data; | |||
| if (json.status === "OK") { | |||
| this.snackbarMessage = "報表在背景執行,請稍候…"; | |||
| this.snackbarColor = "blue-grey"; | |||
| this.snackbarTimeout = 1000, | |||
| this.snackbar = true; | |||
| setTimeout(this.checkReportStatus, 1000); | |||
| } | |||
| else { | |||
| this.snackbarMessage = "報表無法執行:" + json.message; | |||
| this.snackbarColor = "deep-orange"; | |||
| this.snackbar = true; | |||
| } | |||
| }); | |||
| }, | |||
| checkReportStatus() { | |||
| axios({ | |||
| url: '/api/access/reportview/genreport/status', //your url | |||
| method: 'GET', | |||
| }).then((response) => { | |||
| let json = response.data; | |||
| if (json.status === "OK" && json.data === true) { | |||
| this.snackbarMessage = "報表仍在背景執行,請稍候…"; | |||
| this.snackbar = true; | |||
| setTimeout(this.checkReportStatus, 1000); | |||
| } | |||
| else{ | |||
| this.snackbarMessage = "報表執行完畢!"; | |||
| this.snackbarTimeout = 3000, | |||
| this.snackbar = true; | |||
| this.loadReport(); | |||
| } | |||
| }); | |||
| }, | |||
| }, | |||
| } | |||
| </script> | |||
| @@ -150,6 +150,12 @@ | |||
| </excludes> | |||
| </configuration> | |||
| </plugin> | |||
| <plugin> | |||
| <artifactId>maven-war-plugin</artifactId> | |||
| <configuration> | |||
| <failOnMissingWebXml>false</failOnMissingWebXml> | |||
| </configuration> | |||
| </plugin> | |||
| </plugins> | |||
| </build> | |||
| @@ -112,11 +112,11 @@ public class InventoryController { | |||
| ExcelImporter excelImporter = new ExcelImporter(f); | |||
| List<Map<String, String>> data = excelImporter.readAll().get("工作表1"); | |||
| List<MappingCol> mappingCols = mappingColDAO.findByTable(tablename); | |||
| inventoryDAO.importInventories(tablename, mappingCols, data, searchDAO); | |||
| f.deleteOnExit(); | |||
| data.remove(data.get(0)); | |||
| // List<MappingCol> mappingCols = mappingColDAO.findByTable(tablename); | |||
| // | |||
| // inventoryDAO.importInventories(tablename, mappingCols, data, searchDAO); | |||
| // f.deleteOnExit(); | |||
| return new JsonResult(StatusCode.SUCCESS, null); | |||
| } | |||
| @@ -131,12 +131,14 @@ public class InventoryController { | |||
| ArrayList<String> titleKeyList= new ArrayList<>(); | |||
| Map<String, String> titleMap = new ManagedMap<>(); | |||
| Map<String, String> descriptMap = new ManagedMap<>(); | |||
| for(MappingCol m: mappingCols) { | |||
| titleKeyList.add(m.getColname()); | |||
| titleMap.put(m.getColname(), m.getDescript()); | |||
| descriptMap.put(m.getColname(), m.getDescript2()); | |||
| } | |||
| ExcelExpoter excelExpoter = new ExcelExpoter(""); | |||
| excelExpoter.expoerDataExcel(resp, titleKeyList, titleMap, items, info.get("tablename")); | |||
| excelExpoter.expoerDataExcel(resp, titleKeyList, titleMap, descriptMap, items, info.get("tablename")); | |||
| } | |||
| @GetMapping("/allHeaders") | |||
| @@ -60,22 +60,25 @@ public class SearchController { | |||
| Map<String, ArrayList<String>>titleKeyLists = new ManagedMap<>(); | |||
| Map<String, Map<String, String>> titleMaps = new ManagedMap<>(); | |||
| Map<String, Map<String, String>> descriptMaps = new ManagedMap<>(); | |||
| while (iterator.hasNext()) { | |||
| Map.Entry<String, List<Map<String, Object>>> next = iterator.next(); | |||
| String key = next.getKey(); | |||
| List<MappingCol> mappingCols = mappingColDAO.findByTable(key); | |||
| ArrayList<String> titleKeyList= new ArrayList<>(); | |||
| Map<String, String> titleMap = new ManagedMap<>(); | |||
| Map<String, String> descriptMap = new ManagedMap<>(); | |||
| for(MappingCol m: mappingCols) { | |||
| titleKeyList.add(m.getColname()); | |||
| titleMap.put(m.getColname(), m.getDescript()); | |||
| descriptMap.put(m.getColname(), m.getDescript2()); | |||
| } | |||
| titleKeyLists.put(key, titleKeyList); | |||
| titleMaps.put(key, titleMap); | |||
| descriptMaps.put(key, descriptMap); | |||
| } | |||
| ExcelExpoter excelExpoter = new ExcelExpoter(""); | |||
| excelExpoter.expoerDataExcelMultiSheet(resp, titleKeyLists, titleMaps, data, ""); | |||
| excelExpoter.expoerDataExcelMultiSheet(resp, titleKeyLists, titleMaps, descriptMaps, data, ""); | |||
| } | |||
| } | |||
| @@ -35,7 +35,7 @@ public interface AssertDAO extends SqlObject { | |||
| } | |||
| @RegisterBeanMapper(MappingCol.class) | |||
| @SqlQuery("select * from mapping.mapping_col order by [index];") | |||
| @SqlQuery("select * from mapping.mapping_col order by convert(int, [index]);") | |||
| List<MappingCol> findAllCols(); | |||
| @@ -13,6 +13,7 @@ public class MappingCol { | |||
| private String colname; | |||
| private String level; | |||
| private String descript; | |||
| private String descript2; | |||
| private String type; | |||
| private String index; | |||
| private String isselect; | |||
| @@ -3,6 +3,10 @@ package com.moze.rms.utils; | |||
| import java.io.*; | |||
| import java.util.*; | |||
| import org.apache.poi.hssf.usermodel.HSSFCellStyle; | |||
| import org.apache.poi.hssf.usermodel.HSSFFont; | |||
| import org.apache.poi.hssf.usermodel.HSSFWorkbook; | |||
| import org.apache.poi.hssf.util.HSSFColor; | |||
| import org.apache.poi.ss.usermodel.*; | |||
| import org.apache.poi.xssf.streaming.SXSSFWorkbook; | |||
| import org.apache.poi.xssf.usermodel.XSSFSheet; | |||
| @@ -173,11 +177,11 @@ public class ExcelExpoter { | |||
| } | |||
| public void expoerDataExcel(HttpServletResponse response, ArrayList<String> titleKeyList, Map<String, String> titleMap, List<Map<String, Object>> src_list, String filename) throws IOException { | |||
| public void expoerDataExcel(HttpServletResponse response, ArrayList<String> titleKeyList, Map<String, String> titleMap, Map<String, String> descriptMap, List<Map<String, Object>> src_list, String filename) throws IOException { | |||
| String xlsFile_name = filename + ".xls"; //輸出xls檔名稱 | |||
| //記憶體中只建立100個物件 | |||
| Workbook wb = new SXSSFWorkbook(100); //關鍵語句 | |||
| Workbook wb = new HSSFWorkbook(); //關鍵語句 | |||
| Sheet sheet = null; //工作表物件 | |||
| Row nRow = null; //行物件 | |||
| Cell nCell = null; //列物件 | |||
| @@ -185,6 +189,11 @@ public class ExcelExpoter { | |||
| int rowNo = 0; //總行號 | |||
| int pageRowNo = 0; //頁行號 | |||
| HSSFCellStyle dataStyle = (HSSFCellStyle) wb.createCellStyle(); | |||
| dataStyle.setBorderBottom(BorderStyle.THIN); | |||
| dataStyle.setBorderLeft(BorderStyle.THIN); | |||
| dataStyle.setBorderTop(BorderStyle.THIN); | |||
| dataStyle.setBorderRight(BorderStyle.THIN); | |||
| for (int k = 0; k < src_list.size(); k++) { | |||
| Map<String, Object> srcMap = src_list.get(k); | |||
| //寫入300000條後切換到下個工作表 | |||
| @@ -195,20 +204,48 @@ public class ExcelExpoter { | |||
| pageRowNo = 0; //新建了工作表,重置工作表的行號為0 | |||
| // -----------定義表頭----------- | |||
| nRow = sheet.createRow(pageRowNo++); | |||
| HSSFCellStyle headerStyle = (HSSFCellStyle) wb.createCellStyle(); | |||
| headerStyle.setFillForegroundColor(HSSFColor.HSSFColorPredefined.DARK_BLUE.getIndex()); | |||
| headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); | |||
| HSSFFont headerFont= (HSSFFont) wb.createFont(); | |||
| headerFont.setColor(HSSFColor.HSSFColorPredefined.WHITE.getIndex()); | |||
| headerStyle.setFont(headerFont); | |||
| headerStyle.setBorderBottom(BorderStyle.THIN); | |||
| headerStyle.setBorderLeft(BorderStyle.THIN); | |||
| headerStyle.setBorderTop(BorderStyle.THIN); | |||
| headerStyle.setBorderRight(BorderStyle.THIN); | |||
| // 列數 titleKeyList.size() | |||
| for (int i = 0; i < titleKeyList.size(); i++) { | |||
| Cell cell_tem = nRow.createCell(i); | |||
| cell_tem.setCellValue(titleMap.get(titleKeyList.get(i))); | |||
| cell_tem.setCellStyle(headerStyle); | |||
| } | |||
| rowNo++; | |||
| nRow = sheet.createRow(pageRowNo++); | |||
| HSSFCellStyle descriptStyle = (HSSFCellStyle) wb.createCellStyle(); | |||
| descriptStyle.setFillForegroundColor(HSSFColor.HSSFColorPredefined.LIGHT_CORNFLOWER_BLUE.getIndex()); | |||
| descriptStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); | |||
| HSSFFont descriptFont= (HSSFFont) wb.createFont(); | |||
| descriptFont.setColor(HSSFColor.HSSFColorPredefined.RED.getIndex()); | |||
| descriptStyle.setFont(descriptFont); | |||
| descriptStyle.setBorderBottom(BorderStyle.THIN); | |||
| descriptStyle.setBorderLeft(BorderStyle.THIN); | |||
| descriptStyle.setBorderTop(BorderStyle.THIN); | |||
| descriptStyle.setBorderRight(BorderStyle.THIN); | |||
| for (int i = 0; i < descriptMap.size(); i++) { | |||
| Cell cell_tem = nRow.createCell(i); | |||
| cell_tem.setCellValue(descriptMap.get(titleKeyList.get(i))); | |||
| cell_tem.setCellStyle(descriptStyle); | |||
| } | |||
| rowNo++; | |||
| // --------------------------- | |||
| } | |||
| rowNo++; | |||
| nRow = sheet.createRow(pageRowNo++); //新建行物件 | |||
| // 行,獲取cell值 | |||
| for (int j = 0; j < titleKeyList.size(); j++) { | |||
| nCell = nRow.createCell(j); | |||
| nCell.setCellStyle(dataStyle); | |||
| if (srcMap.get(titleKeyList.get(j)) != null) { | |||
| nCell.setCellValue(srcMap.get(titleKeyList.get(j)).toString()); | |||
| } else { | |||
| @@ -216,7 +253,6 @@ public class ExcelExpoter { | |||
| } | |||
| } | |||
| } | |||
| System.out.println(wb.getSheet("工作簿0").getRow(1)); | |||
| response.setContentType("application/vnd.ms-excel;charset=utf-8"); | |||
| response.setHeader("filename" , xlsFile_name); | |||
| response.setHeader("Content-disposition" , "attachment;filename=" + xlsFile_name); | |||
| @@ -229,11 +265,11 @@ public class ExcelExpoter { | |||
| } | |||
| public void expoerDataExcelMultiSheet(HttpServletResponse response, Map<String, ArrayList<String>> titleKeyLists, Map<String, Map<String, String>> titleMaps, Map<String, List<Map<String, Object>>> src_lists, String filename) throws IOException { | |||
| public void expoerDataExcelMultiSheet(HttpServletResponse response, Map<String, ArrayList<String>> titleKeyLists, Map<String, Map<String, String>> titleMaps, Map<String, Map<String, String>> descriptMaps, Map<String, List<Map<String, Object>>> src_lists, String filename) throws IOException { | |||
| String xlsFile_name = "SeverList.xls"; //輸出xls檔名稱 | |||
| //記憶體中只建立100個物件 | |||
| Workbook wb = new SXSSFWorkbook(100); //關鍵語句 | |||
| Workbook wb = new HSSFWorkbook(); //關鍵語句 | |||
| Iterator<Map.Entry<String, List<Map<String, Object>>>> iterator = src_lists.entrySet().iterator(); | |||
| while (iterator.hasNext()) { | |||
| Sheet sheet = null; //工作表物件 | |||
| @@ -248,6 +284,12 @@ public class ExcelExpoter { | |||
| String key = next.getKey(); | |||
| List<Map<String, Object>> src_list = next.getValue(); | |||
| HSSFCellStyle dataStyle = (HSSFCellStyle) wb.createCellStyle(); | |||
| dataStyle.setBorderBottom(BorderStyle.THIN); | |||
| dataStyle.setBorderLeft(BorderStyle.THIN); | |||
| dataStyle.setBorderTop(BorderStyle.THIN); | |||
| dataStyle.setBorderRight(BorderStyle.THIN); | |||
| for (int k = 0; k < src_list.size(); k++) { | |||
| Map<String, Object> srcMap = src_list.get(k); | |||
| //寫入300000條後切換到下個工作表 | |||
| @@ -258,10 +300,38 @@ public class ExcelExpoter { | |||
| pageRowNo = 0; //新建了工作表,重置工作表的行號為0 | |||
| // -----------定義表頭----------- | |||
| nRow = sheet.createRow(pageRowNo++); | |||
| HSSFCellStyle headerStyle = (HSSFCellStyle) wb.createCellStyle(); | |||
| headerStyle.setFillForegroundColor(HSSFColor.HSSFColorPredefined.DARK_BLUE.getIndex()); | |||
| headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); | |||
| HSSFFont headerFont= (HSSFFont) wb.createFont(); | |||
| headerFont.setColor(HSSFColor.HSSFColorPredefined.WHITE.getIndex()); | |||
| headerStyle.setFont(headerFont); | |||
| headerStyle.setBorderBottom(BorderStyle.THIN); | |||
| headerStyle.setBorderLeft(BorderStyle.THIN); | |||
| headerStyle.setBorderTop(BorderStyle.THIN); | |||
| headerStyle.setBorderRight(BorderStyle.THIN); | |||
| // 列數 titleKeyList.size() | |||
| for (int i = 0; i < titleKeyLists.get(key).size(); i++) { | |||
| Cell cell_tem = nRow.createCell(i); | |||
| cell_tem.setCellValue(titleMaps.get(key).get(titleKeyLists.get(key).get(i))); | |||
| cell_tem.setCellStyle(headerStyle); | |||
| } | |||
| rowNo++; | |||
| nRow = sheet.createRow(pageRowNo++); | |||
| HSSFCellStyle descriptStyle = (HSSFCellStyle) wb.createCellStyle(); | |||
| descriptStyle.setFillForegroundColor(HSSFColor.HSSFColorPredefined.LIGHT_CORNFLOWER_BLUE.getIndex()); | |||
| descriptStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); | |||
| HSSFFont descriptFont= (HSSFFont) wb.createFont(); | |||
| descriptFont.setColor(HSSFColor.HSSFColorPredefined.RED.getIndex()); | |||
| descriptStyle.setFont(descriptFont); | |||
| descriptStyle.setBorderBottom(BorderStyle.THIN); | |||
| descriptStyle.setBorderLeft(BorderStyle.THIN); | |||
| descriptStyle.setBorderTop(BorderStyle.THIN); | |||
| descriptStyle.setBorderRight(BorderStyle.THIN); | |||
| for (int i = 0; i < descriptMaps.get(key).size(); i++) { | |||
| Cell cell_tem = nRow.createCell(i); | |||
| cell_tem.setCellValue(descriptMaps.get(key).get(titleKeyLists.get(key).get(i))); | |||
| cell_tem.setCellStyle(descriptStyle); | |||
| } | |||
| rowNo++; | |||
| // --------------------------- | |||
| @@ -269,9 +339,11 @@ public class ExcelExpoter { | |||
| rowNo++; | |||
| nRow = sheet.createRow(pageRowNo++); //新建行物件 | |||
| // 行,獲取cell值 | |||
| for (int j = 0; j < titleKeyLists.get(key).size(); j++) { | |||
| nCell = nRow.createCell(j); | |||
| nCell.setCellStyle(dataStyle); | |||
| if (srcMap.get(titleKeyLists.get(key).get(j)) != null) { | |||
| nCell.setCellValue(srcMap.get(titleKeyLists.get(key).get(j)).toString()); | |||
| } else { | |||
| @@ -1,4 +1,3 @@ | |||
| server.servlet.context-path=/ | |||
| spring.datasource.url=jdbc:sqlserver://172.105.222.191:1433;databaseName=rms; | |||
| spring.datasource.username=sa | |||
| @@ -1,4 +1,4 @@ | |||
| spring.datasource.url=jdbc:postgresql://172.105.222.191:54132/rms | |||
| spring.datasource.url=jdbc:sqlserver://localhost:1433;databaseName=rms; | |||
| spring.datasource.username=moze | |||
| spring.datasource.password=moze794064,! | |||
| spring.datasource.password=6yhn&UJM | |||
| server.port=8080 | |||
| @@ -1,6 +1,6 @@ | |||
| spring.profiles.active=dev | |||
| #spring.profiles.active=pro | |||
| server.servlet.context-path=/rms | |||
| spring.servlet.multipart.max-file-size=100MB | |||
| spring.servlet.multipart.max-request-size=1000MB | |||