n20-common-lib 1.3.10 → 1.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/nstc-g6/assets/svg/404.svg +1 -0
- package/nstc-g6/assets/svg/addFile.svg +32 -0
- package/nstc-g6/assets/svg/bug.svg +1 -0
- package/nstc-g6/assets/svg/chart.svg +1 -0
- package/nstc-g6/assets/svg/clipboard.svg +1 -0
- package/nstc-g6/assets/svg/component.svg +1 -0
- package/nstc-g6/assets/svg/dashboard.svg +1 -0
- package/nstc-g6/assets/svg/deleteFile.svg +28 -0
- package/nstc-g6/assets/svg/documentation.svg +1 -0
- package/nstc-g6/assets/svg/drag.svg +1 -0
- package/nstc-g6/assets/svg/edit.svg +1 -0
- package/nstc-g6/assets/svg/education.svg +1 -0
- package/nstc-g6/assets/svg/email.svg +1 -0
- package/nstc-g6/assets/svg/example.svg +1 -0
- package/nstc-g6/assets/svg/excel.svg +1 -0
- package/nstc-g6/assets/svg/exit-fullscreen.svg +1 -0
- package/nstc-g6/assets/svg/eye-open.svg +1 -0
- package/nstc-g6/assets/svg/eye.svg +1 -0
- package/nstc-g6/assets/svg/favorite.svg +1 -0
- package/nstc-g6/assets/svg/favorite_active.svg +1 -0
- package/nstc-g6/assets/svg/favorite_x400.svg +1 -0
- package/nstc-g6/assets/svg/favorite_x400_active.svg +1 -0
- package/nstc-g6/assets/svg/favorite_x400_blank.svg +1 -0
- package/nstc-g6/assets/svg/filter.svg +16 -0
- package/nstc-g6/assets/svg/filter@2x.png +0 -0
- package/nstc-g6/assets/svg/filterActive.svg +16 -0
- package/nstc-g6/assets/svg/filterClose@2x.png +0 -0
- package/nstc-g6/assets/svg/form.svg +1 -0
- package/nstc-g6/assets/svg/fullscreen.svg +1 -0
- package/nstc-g6/assets/svg/guide.svg +1 -0
- package/nstc-g6/assets/svg/hourglass.svg +19 -0
- package/nstc-g6/assets/svg/icon.svg +1 -0
- package/nstc-g6/assets/svg/international.svg +1 -0
- package/nstc-g6/assets/svg/language.svg +1 -0
- package/nstc-g6/assets/svg/left-dis.svg +1 -0
- package/nstc-g6/assets/svg/left.svg +1 -0
- package/nstc-g6/assets/svg/link.svg +1 -0
- package/nstc-g6/assets/svg/list.svg +1 -0
- package/nstc-g6/assets/svg/lock.svg +1 -0
- package/nstc-g6/assets/svg/message-t.svg +1 -0
- package/nstc-g6/assets/svg/money.svg +1 -0
- package/nstc-g6/assets/svg/money3.svg +1 -0
- package/nstc-g6/assets/svg/money4.svg +1 -0
- package/nstc-g6/assets/svg/moneyTwo.svg +1 -0
- package/nstc-g6/assets/svg/msg_white.svg +1 -0
- package/nstc-g6/assets/svg/nested.svg +1 -0
- package/nstc-g6/assets/svg/newsearch.svg +19 -0
- package/nstc-g6/assets/svg/password.svg +1 -0
- package/nstc-g6/assets/svg/pdf.svg +1 -0
- package/nstc-g6/assets/svg/people.svg +1 -0
- package/nstc-g6/assets/svg/peoples.svg +1 -0
- package/nstc-g6/assets/svg/phone.svg +1 -0
- package/nstc-g6/assets/svg/phone_msg.svg +1 -0
- package/nstc-g6/assets/svg/qq.svg +1 -0
- package/nstc-g6/assets/svg/right-dis.svg +1 -0
- package/nstc-g6/assets/svg/right.svg +1 -0
- package/nstc-g6/assets/svg/search.svg +1 -0
- package/nstc-g6/assets/svg/searchActive.svg +19 -0
- package/nstc-g6/assets/svg/shopping.svg +1 -0
- package/nstc-g6/assets/svg/size.svg +1 -0
- package/nstc-g6/assets/svg/skill.svg +1 -0
- package/nstc-g6/assets/svg/star.svg +1 -0
- package/nstc-g6/assets/svg/steam.svg +1 -0
- package/nstc-g6/assets/svg/tab.svg +1 -0
- package/nstc-g6/assets/svg/table.svg +1 -0
- package/nstc-g6/assets/svg/theme.svg +1 -0
- package/nstc-g6/assets/svg/tree-table.svg +1 -0
- package/nstc-g6/assets/svg/tree.svg +1 -0
- package/nstc-g6/assets/svg/user.svg +1 -0
- package/nstc-g6/assets/svg/wechat.svg +1 -0
- package/nstc-g6/assets/svg/z-left-2-dis.svg +1 -0
- package/nstc-g6/assets/svg/z-left-2.svg +1 -0
- package/nstc-g6/assets/svg/z-right-2-dis.svg +1 -0
- package/nstc-g6/assets/svg/z-right-2.svg +1 -0
- package/nstc-g6/assets/svg/z-right.svg +1 -0
- package/nstc-g6/assets/svg/zip.svg +1 -0
- package/nstc-g6/components/Calendar/index.js +8 -0
- package/nstc-g6/components/Calendar/src/basic/month-table.vue +129 -0
- package/nstc-g6/components/Calendar/src/basic/year-table.vue +126 -0
- package/nstc-g6/components/Calendar/src/main.vue +442 -0
- package/nstc-g6/components/DialogForm/index.js +8 -0
- package/nstc-g6/components/DialogForm/src/demo/index.vue +56 -0
- package/nstc-g6/components/DialogForm/src/main.vue +189 -0
- package/nstc-g6/components/Form/A_DEMO/component/originalForm.vue +281 -0
- package/nstc-g6/components/Form/A_DEMO/config/config_3.js +1222 -0
- package/nstc-g6/components/Form/A_DEMO/index.vue +803 -0
- package/nstc-g6/components/Form/AutocompleteCustom/index.vue +72 -0
- package/nstc-g6/components/Form/BusinessSpecific/InputMultiple.vue +191 -0
- package/nstc-g6/components/Form/BusinessSpecific/InputWithUnit.vue +128 -0
- package/nstc-g6/components/Form/BusinessSpecific/SelectTreeDialog.vue +233 -0
- package/nstc-g6/components/Form/BusinessSpecific/readme.md +7 -0
- package/nstc-g6/components/Form/CascaderCustom/index.vue +101 -0
- package/nstc-g6/components/Form/CheckboxCustom/index.vue +84 -0
- package/nstc-g6/components/Form/Component.vue +661 -0
- package/nstc-g6/components/Form/ComponentSecond.vue +650 -0
- package/nstc-g6/components/Form/DatepickerCustom/index.vue +130 -0
- package/nstc-g6/components/Form/InputAndDialog/index.js +15 -0
- package/nstc-g6/components/Form/InputAndDialog/src/main.vue +395 -0
- package/nstc-g6/components/Form/InputCustom/demo/index.vue +65 -0
- package/nstc-g6/components/Form/InputCustom/index.vue +307 -0
- package/nstc-g6/components/Form/IntervalinputCustom/demo/index.vue +31 -0
- package/nstc-g6/components/Form/IntervalinputCustom/index.vue +118 -0
- package/nstc-g6/components/Form/Item.vue +330 -0
- package/nstc-g6/components/Form/ItemSecond.vue +269 -0
- package/nstc-g6/components/Form/List.vue +146 -0
- package/nstc-g6/components/Form/ListSecond.vue +130 -0
- package/nstc-g6/components/Form/RadioCustom/index.vue +73 -0
- package/nstc-g6/components/Form/SelectAccount/index.js +15 -0
- package/nstc-g6/components/Form/SelectAccount/src/demo/index.vue +58 -0
- package/nstc-g6/components/Form/SelectAccount/src/main.vue +283 -0
- package/nstc-g6/components/Form/SelectAndDialog/index.js +15 -0
- package/nstc-g6/components/Form/SelectAndDialog/src/main.vue +384 -0
- package/nstc-g6/components/Form/SelectCashFlow/index.js +15 -0
- package/nstc-g6/components/Form/SelectCashFlow/src/demo/index.vue +42 -0
- package/nstc-g6/components/Form/SelectCashFlow/src/main.vue +126 -0
- package/nstc-g6/components/Form/SelectCustom/demo/index.vue +82 -0
- package/nstc-g6/components/Form/SelectCustom/index.vue +488 -0
- package/nstc-g6/components/Form/SelectSubject/index.js +15 -0
- package/nstc-g6/components/Form/SelectSubject/src/demo/index.vue +85 -0
- package/nstc-g6/components/Form/SelectSubject/src/main.vue +182 -0
- package/nstc-g6/components/Form/SelectindialogCustom/demo/index.vue +188 -0
- package/nstc-g6/components/Form/SelectindialogCustom/index.vue +650 -0
- package/nstc-g6/components/Form/SelectindialogCustom/install.js +7 -0
- package/nstc-g6/components/Form/TableRadioCustom/demo/index.vue +53 -0
- package/nstc-g6/components/Form/TableRadioCustom/index.vue +183 -0
- package/nstc-g6/components/Form/TextCustom/index.vue +38 -0
- package/nstc-g6/components/Form/UploadCustom/demo/index.vue +31 -0
- package/nstc-g6/components/Form/UploadCustom/iconxitongshezhi-yichu.png +0 -0
- package/nstc-g6/components/Form/UploadCustom/index.vue +506 -0
- package/nstc-g6/components/Form/configs.js +191 -0
- package/nstc-g6/components/Form/configsSecond.js +161 -0
- package/nstc-g6/components/Form/index.js +8 -0
- package/nstc-g6/components/Form/index.scss +29 -0
- package/nstc-g6/components/Form/payeePersonSelect/index.js +15 -0
- package/nstc-g6/components/Form/payeePersonSelect/src/demo/index.vue +164 -0
- package/nstc-g6/components/Form/payeePersonSelect/src/main.vue +185 -0
- package/nstc-g6/components/Form/readme.txt +4 -0
- package/nstc-g6/components/FormGroup/index.js +8 -0
- package/nstc-g6/components/FormGroup/src/demo/config.js +23 -0
- package/nstc-g6/components/FormGroup/src/demo/index.vue +85 -0
- package/nstc-g6/components/FormGroup/src/main.vue +639 -0
- package/nstc-g6/components/FormGroup/src/validate.js +23 -0
- package/nstc-g6/components/InputTag/InputTag.vue +270 -0
- package/nstc-g6/components/NstcApprovel/NstcApprovel.vue +24 -0
- package/nstc-g6/components/NstcBackToTop/NstcBackToTop.vue +150 -0
- package/nstc-g6/components/NstcBranchLazyLoad/NstcBranchLazyLoad.vue +123 -0
- package/nstc-g6/components/NstcCharts/NstcCharts.vue +162 -0
- package/nstc-g6/components/NstcCharts/define.js +74 -0
- package/nstc-g6/components/NstcCharts/mixins/resize.js +56 -0
- package/nstc-g6/components/NstcConfirm/NstcConfirm.vue +152 -0
- package/nstc-g6/components/NstcConfirm/index.js +25 -0
- package/nstc-g6/components/NstcDialog/NstcDialog.vue +185 -0
- package/nstc-g6/components/NstcDialogForm/NstcDialogForm.vue +176 -0
- package/nstc-g6/components/NstcDialogTable/NstcDialogTable.vue +280 -0
- package/nstc-g6/components/NstcDropdown/NstcDropdown.vue +52 -0
- package/nstc-g6/components/NstcDropdownTree/NstcDropdownTree.vue +396 -0
- package/nstc-g6/components/NstcElectronicFile/NstcElectronicFile.vue +591 -0
- package/nstc-g6/components/NstcExcelCustomImport/NstcExcelCustomImport.vue +475 -0
- package/nstc-g6/components/NstcExcelCustomImport/img/upload@2x.png +0 -0
- package/nstc-g6/components/NstcExcelExport/NstcExcelExport.vue +145 -0
- package/nstc-g6/components/NstcExcelImport/NstcExcelImport.vue +1074 -0
- package/nstc-g6/components/NstcExcelImport/img/upload@2x.png +0 -0
- package/nstc-g6/components/NstcExcelImportN/NstcExcelImportN.vue +1166 -0
- package/nstc-g6/components/NstcExpandCollapse/NstcExpandCollapse.vue +130 -0
- package/nstc-g6/components/NstcExpandCollapse/index.scss +77 -0
- package/nstc-g6/components/NstcFileUpload/NstcFileUpload.vue +989 -0
- package/nstc-g6/components/NstcFileUpload/img/addFile.svg +32 -0
- package/nstc-g6/components/NstcFileUpload/img/delete.svg +24 -0
- package/nstc-g6/components/NstcFileUpload/img/deleteFile.svg +28 -0
- package/nstc-g6/components/NstcFileUpload/img/download.svg +24 -0
- package/nstc-g6/components/NstcFileUpload/img/inputUpload.svg +30 -0
- package/nstc-g6/components/NstcFileUpload/img/look-diabled.svg +24 -0
- package/nstc-g6/components/NstcFileUpload/img/look.svg +24 -0
- package/nstc-g6/components/NstcForm/A_DEMO/component/originalForm.vue +281 -0
- package/nstc-g6/components/NstcForm/A_DEMO/config/config_3.js +1222 -0
- package/nstc-g6/components/NstcForm/A_DEMO/index.vue +796 -0
- package/nstc-g6/components/NstcForm/AutocompleteCustom/index.vue +68 -0
- package/nstc-g6/components/NstcForm/BusinessSpecific/InputMultiple.vue +189 -0
- package/nstc-g6/components/NstcForm/BusinessSpecific/InputWithUnit.vue +128 -0
- package/nstc-g6/components/NstcForm/BusinessSpecific/SelectTreeDialog.vue +233 -0
- package/nstc-g6/components/NstcForm/BusinessSpecific/readme.md +7 -0
- package/nstc-g6/components/NstcForm/CascaderCustom/index.vue +101 -0
- package/nstc-g6/components/NstcForm/CheckboxCustom/index.vue +84 -0
- package/nstc-g6/components/NstcForm/Component.vue +684 -0
- package/nstc-g6/components/NstcForm/ComponentSecond.vue +650 -0
- package/nstc-g6/components/NstcForm/DatepickerCustom/index.vue +130 -0
- package/nstc-g6/components/NstcForm/InputAndDialog/NstcInputAndDialog.vue +389 -0
- package/nstc-g6/components/NstcForm/InputCustom/index.vue +314 -0
- package/nstc-g6/components/NstcForm/IntervalInputCustom/index.vue +116 -0
- package/nstc-g6/components/NstcForm/Item.vue +327 -0
- package/nstc-g6/components/NstcForm/ItemSecond.vue +269 -0
- package/nstc-g6/components/NstcForm/List.vue +146 -0
- package/nstc-g6/components/NstcForm/ListSecond.vue +130 -0
- package/nstc-g6/components/NstcForm/RadioCustom/index.vue +73 -0
- package/nstc-g6/components/NstcForm/SelectAccount/NstcSelectAccount.vue +334 -0
- package/nstc-g6/components/NstcForm/SelectAndDialog/NstcSelectAndDialog.vue +377 -0
- package/nstc-g6/components/NstcForm/SelectCashFlow/NstcSelectCashFlow.vue +123 -0
- package/nstc-g6/components/NstcForm/SelectCustom/index.vue +460 -0
- package/nstc-g6/components/NstcForm/SelectSubject/NstcSelectSubject.vue +185 -0
- package/nstc-g6/components/NstcForm/SelectindialogCustom/index.vue +648 -0
- package/nstc-g6/components/NstcForm/TableRadioCustom/index.vue +183 -0
- package/nstc-g6/components/NstcForm/TextCustom/index.vue +38 -0
- package/nstc-g6/components/NstcForm/UploadCustom/iconxitongshezhi-yichu.png +0 -0
- package/nstc-g6/components/NstcForm/UploadCustom/index.vue +500 -0
- package/nstc-g6/components/NstcForm/configs.js +191 -0
- package/nstc-g6/components/NstcForm/configsSecond.js +161 -0
- package/nstc-g6/components/NstcForm/index.js +8 -0
- package/nstc-g6/components/NstcForm/index.scss +29 -0
- package/nstc-g6/components/NstcForm/payeePersonSelect/NstcPayeePerson.vue +188 -0
- package/nstc-g6/components/NstcForm/readme.txt +4 -0
- package/nstc-g6/components/NstcPagination/NstcPagination.vue +428 -0
- package/nstc-g6/components/NstcPagination/setPageNum.png +0 -0
- package/nstc-g6/components/NstcPagination/setpagedefault.png +0 -0
- package/nstc-g6/components/NstcScreenFull/NstcScreenFull.vue +70 -0
- package/nstc-g6/components/NstcSelectTree/NstcSelectTree.vue +729 -0
- package/nstc-g6/components/NstcSelectTreeList/NstcSelectTreeList.vue +676 -0
- package/nstc-g6/components/NstcSticky/NstcSticky.vue +97 -0
- package/nstc-g6/components/NstcSvgIcon/NstcSvgIcon.vue +72 -0
- package/nstc-g6/components/NstcTab/NstcTab.vue +80 -0
- package/nstc-g6/components/NstcTabWithBadge/NstcTabWithBadge.vue +45 -0
- package/nstc-g6/components/NstcTabWithBadge/index.scss +31 -0
- package/nstc-g6/components/NstcTable/ElTableColumnCustom/index.vue +292 -0
- package/nstc-g6/components/NstcTable/NstcTable.vue +460 -0
- package/nstc-g6/components/NstcTableSet/NstcTableSet.vue +801 -0
- package/nstc-g6/components/NstcThemePicker/NstcThemePicker.vue +186 -0
- package/nstc-g6/components/NstcUploadCustomExcel/NstcUploadCustomExcel.vue +330 -0
- package/nstc-g6/components/NstcUploadExcel/NstcUploadExcel.vue +145 -0
- package/nstc-g6/components/NstcWorkBench/NstcWorkBench.vue +176 -0
- package/nstc-g6/components/Search/NstcSearch.vue +583 -0
- package/nstc-g6/components/Search/src/demo/index copy.vue +101 -0
- package/nstc-g6/components/Search/src/demo/index.vue +103 -0
- package/nstc-g6/components/Search/src/main copy.vue +607 -0
- package/nstc-g6/components/approvelTwo/main.vue +220 -0
- package/nstc-g6/components/approvelTwo/progress.vue +154 -0
- package/nstc-g6/directives/VCopy/index.js +60 -0
- package/nstc-g6/directives/VNstcNumber/index.js +14 -0
- package/nstc-g6/directives/VNstcNumber/temp.js +446 -0
- package/nstc-g6/index.js +193 -0
- package/nstc-g6/utils/auth.js +2 -0
- package/nstc-g6/utils/axios.js +2 -0
- package/nstc-g6/utils/dateAndValidator.js +649 -0
- package/nstc-g6/utils/debounce.js +40 -0
- package/nstc-g6/utils/parseTime.js +48 -0
- package/nstc-g6/utils/validate/index.js +7 -0
- package/nstc-g6/utils/vendor/Export2Excel.js +229 -0
- package/nstc-g6/utils/vendor/Export2Zip.js +24 -0
- package/nstc-g6/utils/vue-bus.js +5 -0
- package/package.json +8 -2
- package/src/assets/css/_coreLib.scss +9 -1
- package/src/components/ChildRange/index.vue +2 -37
- package/src/components/ChildRange/style.scss +34 -0
- package/src/components/PageHeader/index.vue +2 -44
- package/src/components/PageHeader/style.scss +39 -0
- package/src/components/Search/index.vue +1 -97
- package/src/components/Search/style.scss +93 -0
- package/src/components/Table/ThSelectHeader.vue +2 -11
- package/src/components/Table/index.vue +4 -2
- package/src/directives/VTitle/index.js +14 -17
- package/style/css/normalize.scss +6 -6
- package/style/index.css +3 -3
- package/style/index.css.map +1 -1
- package/style/server-config.jsonc +527 -410
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
功能: 主题切换
|
|
3
|
+
作者: nstc
|
|
4
|
+
创建时间: 2021-02-05
|
|
5
|
+
-->
|
|
6
|
+
<template>
|
|
7
|
+
<el-color-picker
|
|
8
|
+
v-model="theme"
|
|
9
|
+
:predefine="['#4E94A8', '#409EFF', '#1890ff', '#304156','#212121','#11a983', '#13c2c2', '#6959CD', '#f5222d', ]"
|
|
10
|
+
class="theme-picker"
|
|
11
|
+
popper-class="theme-picker-dropdown"
|
|
12
|
+
/>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script>
|
|
16
|
+
const version = require('element-ui/package.json').version // element-ui version from node_modules
|
|
17
|
+
const ORIGINAL_THEME = '#409EFF' // default color
|
|
18
|
+
|
|
19
|
+
export default {
|
|
20
|
+
name: 'NstcThemePicker',
|
|
21
|
+
data() {
|
|
22
|
+
return {
|
|
23
|
+
chalk: '', // theme-chalk css 文件内容
|
|
24
|
+
theme: ''
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
computed: {
|
|
28
|
+
defaultTheme() {
|
|
29
|
+
return this.$store.state.settings.theme
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
watch: {
|
|
33
|
+
defaultTheme: {
|
|
34
|
+
handler: function(val) {
|
|
35
|
+
this.theme = val
|
|
36
|
+
},
|
|
37
|
+
immediate: true
|
|
38
|
+
},
|
|
39
|
+
async theme(val) {
|
|
40
|
+
// 如果项目为开始状态
|
|
41
|
+
const oldVal = this.chalk ? this.theme : ORIGINAL_THEME
|
|
42
|
+
if (typeof val !== 'string') return
|
|
43
|
+
// 获取主题色的编码 []
|
|
44
|
+
const themeCluster = this.getThemeCluster(val.replace('#', ''))
|
|
45
|
+
const originalCluster = this.getThemeCluster(oldVal.replace('#', ''))
|
|
46
|
+
console.log('主题设置', themeCluster, originalCluster)
|
|
47
|
+
|
|
48
|
+
const $message = this.$message({
|
|
49
|
+
message: ' 主题编译中...',
|
|
50
|
+
customClass: 'theme-message',
|
|
51
|
+
type: 'success',
|
|
52
|
+
duration: 0,
|
|
53
|
+
iconClass: 'el-icon-loading'
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
const getHandler = (variable, id) => {
|
|
57
|
+
return () => {
|
|
58
|
+
const originalCluster = this.getThemeCluster(ORIGINAL_THEME.replace('#', ''))
|
|
59
|
+
const newStyle = this.updateStyle(this[variable], originalCluster, themeCluster)
|
|
60
|
+
|
|
61
|
+
let styleTag = document.getElementById(id)
|
|
62
|
+
if (!styleTag) {
|
|
63
|
+
styleTag = document.createElement('style')
|
|
64
|
+
styleTag.setAttribute('id', id)
|
|
65
|
+
document.head.appendChild(styleTag)
|
|
66
|
+
}
|
|
67
|
+
styleTag.setAttribute('load_time', new Date().getTime())
|
|
68
|
+
styleTag.innerText = newStyle
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// 加载css样式
|
|
72
|
+
if (!this.chalk) {
|
|
73
|
+
const url = `https://unpkg.com/element-ui@${version}/lib/theme-chalk/index.css`
|
|
74
|
+
await this.getCSSString(url, 'chalk')
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const chalkHandler = getHandler('chalk', 'chalk-style')
|
|
78
|
+
|
|
79
|
+
chalkHandler()
|
|
80
|
+
|
|
81
|
+
const styles = [].slice.call(document.querySelectorAll('style'))
|
|
82
|
+
.filter(style => {
|
|
83
|
+
const text = style.innerText
|
|
84
|
+
return new RegExp(oldVal, 'i').test(text) && !/Chalk Variables/.test(text)
|
|
85
|
+
})
|
|
86
|
+
styles.forEach(style => {
|
|
87
|
+
const { innerText } = style
|
|
88
|
+
if (typeof innerText !== 'string') return
|
|
89
|
+
style.innerText = this.updateStyle(innerText, originalCluster, themeCluster)
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
this.$emit('change', val)
|
|
93
|
+
|
|
94
|
+
$message.close()
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
methods: {
|
|
99
|
+
updateStyle(style, oldCluster, newCluster) {
|
|
100
|
+
let newStyle = style
|
|
101
|
+
oldCluster.forEach((color, index) => {
|
|
102
|
+
newStyle = newStyle.replace(new RegExp(color, 'ig'), newCluster[index])
|
|
103
|
+
})
|
|
104
|
+
return newStyle
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
getCSSString(url, variable) {
|
|
108
|
+
return new Promise(resolve => {
|
|
109
|
+
const xhr = new XMLHttpRequest()
|
|
110
|
+
xhr.onreadystatechange = () => {
|
|
111
|
+
if (xhr.readyState === 4 && xhr.status === 200) {
|
|
112
|
+
this[variable] = xhr.responseText.replace(/@font-face{[^}]+}/, '')
|
|
113
|
+
console.log('chalk', this.chalk)
|
|
114
|
+
resolve()
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
xhr.open('GET', url)
|
|
118
|
+
xhr.send()
|
|
119
|
+
})
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
getThemeCluster(theme) {
|
|
123
|
+
const tintColor = (color, tint) => {
|
|
124
|
+
let red = parseInt(color.slice(0, 2), 16)
|
|
125
|
+
let green = parseInt(color.slice(2, 4), 16)
|
|
126
|
+
let blue = parseInt(color.slice(4, 6), 16)
|
|
127
|
+
|
|
128
|
+
if (tint === 0) { // when primary color is in its rgb space
|
|
129
|
+
return [red, green, blue].join(',')
|
|
130
|
+
} else {
|
|
131
|
+
red += Math.round(tint * (255 - red))
|
|
132
|
+
green += Math.round(tint * (255 - green))
|
|
133
|
+
blue += Math.round(tint * (255 - blue))
|
|
134
|
+
|
|
135
|
+
red = red.toString(16)
|
|
136
|
+
green = green.toString(16)
|
|
137
|
+
blue = blue.toString(16)
|
|
138
|
+
|
|
139
|
+
return `#${red}${green}${blue}`
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const shadeColor = (color, shade) => {
|
|
144
|
+
let red = parseInt(color.slice(0, 2), 16)
|
|
145
|
+
let green = parseInt(color.slice(2, 4), 16)
|
|
146
|
+
let blue = parseInt(color.slice(4, 6), 16)
|
|
147
|
+
|
|
148
|
+
red = Math.round((1 - shade) * red)
|
|
149
|
+
green = Math.round((1 - shade) * green)
|
|
150
|
+
blue = Math.round((1 - shade) * blue)
|
|
151
|
+
|
|
152
|
+
red = red.toString(16)
|
|
153
|
+
green = green.toString(16)
|
|
154
|
+
blue = blue.toString(16)
|
|
155
|
+
|
|
156
|
+
return `#${red}${green}${blue}`
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const clusters = [theme]
|
|
160
|
+
for (let i = 0; i <= 9; i++) {
|
|
161
|
+
clusters.push(tintColor(theme, Number((i / 10).toFixed(2))))
|
|
162
|
+
}
|
|
163
|
+
clusters.push(shadeColor(theme, 0.1))
|
|
164
|
+
return clusters
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
</script>
|
|
169
|
+
|
|
170
|
+
<style>
|
|
171
|
+
.theme-message,
|
|
172
|
+
.theme-picker-dropdown {
|
|
173
|
+
z-index: 99999 !important;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.theme-picker .el-color-picker__trigger {
|
|
177
|
+
height: 26px !important;
|
|
178
|
+
width: 26px !important;
|
|
179
|
+
padding: 2px;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.theme-picker-dropdown .el-color-dropdown__link-btn {
|
|
183
|
+
display: none;
|
|
184
|
+
}
|
|
185
|
+
</style>
|
|
186
|
+
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
功能: 导入excel自定义解析
|
|
3
|
+
作者: nstc
|
|
4
|
+
创建时间: 2021-02-05
|
|
5
|
+
-->
|
|
6
|
+
<template>
|
|
7
|
+
<div
|
|
8
|
+
v-loading="loading"
|
|
9
|
+
class="excel-import-box"
|
|
10
|
+
:element-loading-text="analysisText"
|
|
11
|
+
element-loading-spinner="el-icon-loading"
|
|
12
|
+
element-loading-background="rgba(0, 0, 0, 0.8)"
|
|
13
|
+
@drop="handleDrop"
|
|
14
|
+
@dragover="handleDragover"
|
|
15
|
+
@dragenter="handleDragover"
|
|
16
|
+
>
|
|
17
|
+
<input
|
|
18
|
+
ref="excel-upload-input"
|
|
19
|
+
class="excel-upload-input"
|
|
20
|
+
type="file"
|
|
21
|
+
accept=".xlsx, .xls, .csv"
|
|
22
|
+
@change="handleClick"
|
|
23
|
+
/>
|
|
24
|
+
<i class="el-icon-upload" />
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script>
|
|
29
|
+
import XLSX from "xlsx";
|
|
30
|
+
import { mapperData } from "@/utils/mapper_aims.js";
|
|
31
|
+
export default {
|
|
32
|
+
name: "NstcUploadCustomExcel",
|
|
33
|
+
props: {
|
|
34
|
+
beforeUpload: Function, // eslint-disable-line
|
|
35
|
+
onSuccess: Function, // eslint-disable-line
|
|
36
|
+
},
|
|
37
|
+
data() {
|
|
38
|
+
return {
|
|
39
|
+
loading: false,
|
|
40
|
+
excelData: {
|
|
41
|
+
header: null,
|
|
42
|
+
results: null,
|
|
43
|
+
},
|
|
44
|
+
excelDataAll: {},
|
|
45
|
+
analysisText: "analysis",
|
|
46
|
+
columnsList: [],
|
|
47
|
+
columnsListNew: [],
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
methods: {
|
|
51
|
+
generateData(datas, list) {
|
|
52
|
+
// this.excelData.header = header
|
|
53
|
+
// this.excelData.results = results
|
|
54
|
+
this.onSuccess && this.onSuccess(datas, list);
|
|
55
|
+
},
|
|
56
|
+
handleDrop(e) {
|
|
57
|
+
e.stopPropagation();
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
if (this.loading) return;
|
|
60
|
+
const files = e.dataTransfer.files;
|
|
61
|
+
if (files.length !== 1) {
|
|
62
|
+
this.$message.error("Only support uploading one file!");
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const rawFile = files[0]; // only use files[0]
|
|
66
|
+
|
|
67
|
+
if (!this.isExcel(rawFile)) {
|
|
68
|
+
this.$message.error(
|
|
69
|
+
"Only supports upload .xlsx, .xls, .csv suffix files"
|
|
70
|
+
);
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
this.upload(rawFile);
|
|
74
|
+
e.stopPropagation();
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
},
|
|
77
|
+
handleDragover(e) {
|
|
78
|
+
e.stopPropagation();
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
e.dataTransfer.dropEffect = "copy";
|
|
81
|
+
},
|
|
82
|
+
handleUpload() {
|
|
83
|
+
this.$refs["excel-upload-input"].click();
|
|
84
|
+
},
|
|
85
|
+
handleClick(e) {
|
|
86
|
+
const files = e.target.files;
|
|
87
|
+
const rawFile = files[0]; // only use files[0]
|
|
88
|
+
if (!rawFile) return;
|
|
89
|
+
this.upload(rawFile);
|
|
90
|
+
},
|
|
91
|
+
upload(rawFile) {
|
|
92
|
+
this.$refs["excel-upload-input"].value = null; // fix can't select the same excel
|
|
93
|
+
|
|
94
|
+
if (!this.beforeUpload) {
|
|
95
|
+
this.readerData(rawFile);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const before = this.beforeUpload(rawFile);
|
|
99
|
+
if (before) {
|
|
100
|
+
this.readerData(rawFile);
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
readerData(rawFile) {
|
|
105
|
+
this.loading = true;
|
|
106
|
+
//清空表头
|
|
107
|
+
this.columnsList = [];
|
|
108
|
+
this.columnsListNew = [];
|
|
109
|
+
return new Promise((resolve) => {
|
|
110
|
+
const reader = new FileReader();
|
|
111
|
+
|
|
112
|
+
// 重写FileReader上的readAsBinaryString方法
|
|
113
|
+
FileReader.prototype.readAsBinaryString = (rawFile) => {
|
|
114
|
+
var binary = "";
|
|
115
|
+
var wb; // 读取完成的数据
|
|
116
|
+
var reader = new FileReader();
|
|
117
|
+
reader.onload = () => {
|
|
118
|
+
// 读取成Uint8Array,再转换为Unicode编码(Unicode占两个字节)
|
|
119
|
+
var bytes = new Uint8Array(reader.result);
|
|
120
|
+
var length = bytes.byteLength;
|
|
121
|
+
for (var i = 0; i < length; i++) {
|
|
122
|
+
binary += String.fromCharCode(bytes[i]);
|
|
123
|
+
}
|
|
124
|
+
// 接下来就是xlsx了,具体可看api
|
|
125
|
+
wb = XLSX.read(binary, {
|
|
126
|
+
type: "binary",
|
|
127
|
+
});
|
|
128
|
+
let datas = [];
|
|
129
|
+
for (let st = 0; st < wb.SheetNames.length; st++) {
|
|
130
|
+
var sheet = wb.Sheets[wb.SheetNames[st]];
|
|
131
|
+
let ref = sheet["!ref"];
|
|
132
|
+
if (ref == undefined || ref == "undefined") {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
var result0 = [];
|
|
136
|
+
var result1 = [];
|
|
137
|
+
var result2 = [];
|
|
138
|
+
var row;
|
|
139
|
+
var rowNum;
|
|
140
|
+
var colNum;
|
|
141
|
+
var range = XLSX.utils.decode_range(ref);
|
|
142
|
+
for (rowNum = range.s.r; rowNum <= range.e.r; rowNum++) {
|
|
143
|
+
row = [];
|
|
144
|
+
for (colNum = range.s.c; colNum <= range.e.c; colNum++) {
|
|
145
|
+
var nextCell =
|
|
146
|
+
sheet[
|
|
147
|
+
XLSX.utils.encode_cell({
|
|
148
|
+
r: rowNum,
|
|
149
|
+
c: colNum,
|
|
150
|
+
})
|
|
151
|
+
];
|
|
152
|
+
|
|
153
|
+
if (typeof nextCell === "undefined") {
|
|
154
|
+
row.push(void 0);
|
|
155
|
+
} else {
|
|
156
|
+
let cellw = nextCell.v;
|
|
157
|
+
if (cellw == "" || cellw == null || cellw === "undefined") {
|
|
158
|
+
row.push(cellw);
|
|
159
|
+
} else {
|
|
160
|
+
let val = cellw.toString().trim();
|
|
161
|
+
row.push(val);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
result0.push(row);
|
|
166
|
+
}
|
|
167
|
+
console.log("处理的数据", result0);
|
|
168
|
+
let lastIndex = 0; //最长数组位置
|
|
169
|
+
let lastLength = 0; //最长数组长度
|
|
170
|
+
for (let i = 0; i < result0.length; i++) {
|
|
171
|
+
let rows = result0[i];
|
|
172
|
+
let temp = [];
|
|
173
|
+
for (let item of rows) {
|
|
174
|
+
if (item) {
|
|
175
|
+
temp.push(item);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (lastLength < temp.length) {
|
|
179
|
+
lastIndex = i;
|
|
180
|
+
lastLength = temp.length;
|
|
181
|
+
}
|
|
182
|
+
temp.splice(0, temp.length); //清空
|
|
183
|
+
}
|
|
184
|
+
result1 = result0.slice(0, lastIndex);
|
|
185
|
+
result2 = result0.slice(lastIndex, result0.length);
|
|
186
|
+
// outdata = XLSX.utils.sheet_to_json(sheet);
|
|
187
|
+
// 自定义方法向父组件传递数据
|
|
188
|
+
// that.$emit("getResult", outdata);
|
|
189
|
+
|
|
190
|
+
// window.console.log(JSON.stringify(result1))
|
|
191
|
+
// window.console.log(JSON.stringify(result2))
|
|
192
|
+
var json = {};
|
|
193
|
+
var jsons = [];
|
|
194
|
+
for (let i = 0; i < result1.length; i++) {
|
|
195
|
+
let content = result1[i];
|
|
196
|
+
for (let j = 0; j < content.length; j++) {
|
|
197
|
+
let key = content[j];
|
|
198
|
+
if (Object.prototype.hasOwnProperty.call(mapperData, key)) {
|
|
199
|
+
this.columnsList.push({
|
|
200
|
+
prop: mapperData[key],
|
|
201
|
+
label: key,
|
|
202
|
+
});
|
|
203
|
+
json[mapperData[key]] = content[++j];
|
|
204
|
+
} else {
|
|
205
|
+
json[content[j]] = content[++j];
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
var title = result2[0];
|
|
210
|
+
//过滤result2全为空的行
|
|
211
|
+
result2 = result2.filter((item) => {
|
|
212
|
+
let flag = 0;
|
|
213
|
+
item.forEach((cloum) => {
|
|
214
|
+
if (!cloum) {
|
|
215
|
+
flag++;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
return flag < item.length;
|
|
219
|
+
});
|
|
220
|
+
console.log("---------", result2);
|
|
221
|
+
for (let k = 1; k < result2.length; k++) {
|
|
222
|
+
let content = result2[k];
|
|
223
|
+
let tempJson = {};
|
|
224
|
+
Object.assign(tempJson, json);
|
|
225
|
+
for (let l = 0; l < title.length; l++) {
|
|
226
|
+
let key = title[l];
|
|
227
|
+
if (Object.prototype.hasOwnProperty.call(mapperData, key)) {
|
|
228
|
+
this.columnsList.push({
|
|
229
|
+
prop: mapperData[key],
|
|
230
|
+
label: key,
|
|
231
|
+
});
|
|
232
|
+
key = mapperData[key];
|
|
233
|
+
} else {
|
|
234
|
+
key = title[l];
|
|
235
|
+
}
|
|
236
|
+
let val = content[l];
|
|
237
|
+
|
|
238
|
+
if (!tempJson[key]) {
|
|
239
|
+
tempJson[key] = val;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
jsons.push(tempJson);
|
|
243
|
+
}
|
|
244
|
+
// window.console.log("jsons:" + JSON.stringify(jsons))
|
|
245
|
+
window.console.log("jsons:", jsons);
|
|
246
|
+
|
|
247
|
+
datas.push(jsons);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
//处理数据
|
|
251
|
+
|
|
252
|
+
// this.excelDataAll = datas
|
|
253
|
+
|
|
254
|
+
let datasAll = [].concat(...datas);
|
|
255
|
+
console.log("datasAll", datasAll);
|
|
256
|
+
let reg = /.*[\u4e00-\u9fa5]+.*$/;
|
|
257
|
+
|
|
258
|
+
datasAll.forEach((item) => {
|
|
259
|
+
for (const key in item) {
|
|
260
|
+
if (
|
|
261
|
+
key === "recAmount" ||
|
|
262
|
+
key === "payAmount" ||
|
|
263
|
+
key === "amount" ||
|
|
264
|
+
key === "balance"
|
|
265
|
+
) {
|
|
266
|
+
item[key] && (item[key] = Number(item[key].replace(/,/g, "")));
|
|
267
|
+
}
|
|
268
|
+
if (reg.test(key) || key === "undefined" || key === "") {
|
|
269
|
+
delete item[key];
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
datasAll = datasAll.filter((item) => {
|
|
275
|
+
let num = Object.keys(item).length;
|
|
276
|
+
let flag = num;
|
|
277
|
+
for (var key in item) {
|
|
278
|
+
if (!item[key]) {
|
|
279
|
+
flag--;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return flag > 0;
|
|
283
|
+
});
|
|
284
|
+
console.log("datas", datasAll);
|
|
285
|
+
let obj = {};
|
|
286
|
+
for (let i = 0; i < this.columnsList.length; i++) {
|
|
287
|
+
if (
|
|
288
|
+
!obj[this.columnsList[i].label] &&
|
|
289
|
+
!obj[this.columnsList[i].prop]
|
|
290
|
+
) {
|
|
291
|
+
this.columnsListNew.push(this.columnsList[i]);
|
|
292
|
+
obj[this.columnsList[i].label] = true;
|
|
293
|
+
obj[this.columnsList[i].prop] = true;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
// console.log("表头", this.columnsListNew);
|
|
297
|
+
this.generateData(datasAll, this.columnsListNew);
|
|
298
|
+
|
|
299
|
+
resolve();
|
|
300
|
+
};
|
|
301
|
+
reader.readAsArrayBuffer(rawFile);
|
|
302
|
+
};
|
|
303
|
+
reader.readAsBinaryString(rawFile);
|
|
304
|
+
});
|
|
305
|
+
},
|
|
306
|
+
getHeaderRow(sheet) {
|
|
307
|
+
console.log(sheet);
|
|
308
|
+
const headers = [];
|
|
309
|
+
const range = XLSX.utils.decode_range(sheet["!ref"]);
|
|
310
|
+
let C;
|
|
311
|
+
const R = range.s.r;
|
|
312
|
+
/* start in the first row */
|
|
313
|
+
for (C = range.s.c; C <= range.e.c; ++C) {
|
|
314
|
+
/* walk every column in the range */
|
|
315
|
+
const cell = sheet[XLSX.utils.encode_cell({ c: C, r: R })];
|
|
316
|
+
/* find the cell in the first row */
|
|
317
|
+
let hdr = "UNKNOWN " + C; // <-- replace with your desired default
|
|
318
|
+
if (cell && cell.t) hdr = XLSX.utils.format_cell(cell);
|
|
319
|
+
headers.push(hdr);
|
|
320
|
+
}
|
|
321
|
+
return headers;
|
|
322
|
+
},
|
|
323
|
+
isExcel(file) {
|
|
324
|
+
return /\.(xlsx|xls|csv)$/.test(file.name);
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
|
+
};
|
|
328
|
+
</script>
|
|
329
|
+
|
|
330
|
+
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
功能: 导入excel
|
|
3
|
+
作者: nstc
|
|
4
|
+
创建时间: 2021-02-05
|
|
5
|
+
-->
|
|
6
|
+
<template>
|
|
7
|
+
<div
|
|
8
|
+
v-loading="loading"
|
|
9
|
+
class="excel-import-box"
|
|
10
|
+
:element-loading-text="analysisText"
|
|
11
|
+
element-loading-spinner="el-icon-loading"
|
|
12
|
+
element-loading-background="rgba(0, 0, 0, 0.8)"
|
|
13
|
+
@drop="handleDrop"
|
|
14
|
+
@dragover="handleDragover"
|
|
15
|
+
@dragenter="handleDragover"
|
|
16
|
+
>
|
|
17
|
+
<input
|
|
18
|
+
ref="excel-upload-input"
|
|
19
|
+
class="excel-upload-input"
|
|
20
|
+
type="file"
|
|
21
|
+
accept=".xlsx, .xls, .csv"
|
|
22
|
+
@change="handleClick"
|
|
23
|
+
>
|
|
24
|
+
<i class="el-icon-upload" />
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script>
|
|
29
|
+
import XLSX from 'xlsx'
|
|
30
|
+
|
|
31
|
+
export default {
|
|
32
|
+
name: 'NstcUploadExcel',
|
|
33
|
+
props: {
|
|
34
|
+
beforeUpload: Function, // eslint-disable-line
|
|
35
|
+
onSuccess: Function// eslint-disable-line
|
|
36
|
+
},
|
|
37
|
+
data() {
|
|
38
|
+
return {
|
|
39
|
+
loading: false,
|
|
40
|
+
excelData: {
|
|
41
|
+
header: null,
|
|
42
|
+
results: null
|
|
43
|
+
},
|
|
44
|
+
analysisText: 'analysis'
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
methods: {
|
|
48
|
+
generateData({ header, results }) {
|
|
49
|
+
this.excelData.header = header
|
|
50
|
+
this.excelData.results = results
|
|
51
|
+
this.onSuccess && this.onSuccess(this.excelData)
|
|
52
|
+
},
|
|
53
|
+
handleDrop(e) {
|
|
54
|
+
e.stopPropagation()
|
|
55
|
+
e.preventDefault()
|
|
56
|
+
if (this.loading) return
|
|
57
|
+
const files = e.dataTransfer.files
|
|
58
|
+
if (files.length !== 1) {
|
|
59
|
+
this.$message.error('Only support uploading one file!')
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
const rawFile = files[0] // only use files[0]
|
|
63
|
+
|
|
64
|
+
if (!this.isExcel(rawFile)) {
|
|
65
|
+
this.$message.error('Only supports upload .xlsx, .xls, .csv suffix files')
|
|
66
|
+
return false
|
|
67
|
+
}
|
|
68
|
+
this.upload(rawFile)
|
|
69
|
+
e.stopPropagation()
|
|
70
|
+
e.preventDefault()
|
|
71
|
+
},
|
|
72
|
+
handleDragover(e) {
|
|
73
|
+
e.stopPropagation()
|
|
74
|
+
e.preventDefault()
|
|
75
|
+
e.dataTransfer.dropEffect = 'copy'
|
|
76
|
+
},
|
|
77
|
+
handleUpload() {
|
|
78
|
+
this.$refs['excel-upload-input'].click()
|
|
79
|
+
},
|
|
80
|
+
handleClick(e) {
|
|
81
|
+
const files = e.target.files
|
|
82
|
+
const rawFile = files[0] // only use files[0]
|
|
83
|
+
if (!rawFile) return
|
|
84
|
+
this.upload(rawFile)
|
|
85
|
+
},
|
|
86
|
+
upload(rawFile) {
|
|
87
|
+
this.$refs['excel-upload-input'].value = null // fix can't select the same excel
|
|
88
|
+
|
|
89
|
+
if (!this.beforeUpload) {
|
|
90
|
+
this.readerData(rawFile)
|
|
91
|
+
return
|
|
92
|
+
}
|
|
93
|
+
const before = this.beforeUpload(rawFile)
|
|
94
|
+
if (before) {
|
|
95
|
+
this.readerData(rawFile)
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
readerData(rawFile) {
|
|
99
|
+
this.loading = true
|
|
100
|
+
return new Promise((resolve) => {
|
|
101
|
+
const reader = new FileReader()
|
|
102
|
+
reader.onload = e => {
|
|
103
|
+
const data = e.target.result
|
|
104
|
+
const workbook = XLSX.read(data,{
|
|
105
|
+
type: 'array',
|
|
106
|
+
cellDates: true,
|
|
107
|
+
})
|
|
108
|
+
const firstSheetName = workbook.SheetNames[0]
|
|
109
|
+
const worksheet = workbook.Sheets[firstSheetName]
|
|
110
|
+
const header = this.getHeaderRow(worksheet)
|
|
111
|
+
const results = XLSX.utils.sheet_to_json(worksheet)
|
|
112
|
+
|
|
113
|
+
this.generateData({ header, results })
|
|
114
|
+
this.loading = false
|
|
115
|
+
resolve()
|
|
116
|
+
}
|
|
117
|
+
reader.readAsArrayBuffer(rawFile)
|
|
118
|
+
})
|
|
119
|
+
},
|
|
120
|
+
getHeaderRow(sheet) {
|
|
121
|
+
console.log(sheet)
|
|
122
|
+
const headers = []
|
|
123
|
+
const range = XLSX.utils.decode_range(sheet['!ref'])
|
|
124
|
+
let C
|
|
125
|
+
const R = range.s.r
|
|
126
|
+
/* start in the first row */
|
|
127
|
+
for (C = range.s.c; C <= range.e.c; ++C) { /* walk every column in the range */
|
|
128
|
+
const cell = sheet[XLSX.utils.encode_cell({ c: C, r: R })]
|
|
129
|
+
/* find the cell in the first row */
|
|
130
|
+
let hdr = 'UNKNOWN ' + C // <-- replace with your desired default
|
|
131
|
+
if (cell && cell.t) hdr = XLSX.utils.format_cell(cell)
|
|
132
|
+
headers.push(hdr)
|
|
133
|
+
}
|
|
134
|
+
return headers
|
|
135
|
+
},
|
|
136
|
+
isExcel(file) {
|
|
137
|
+
return /\.(xlsx|xls|csv)$/.test(file.name)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
</script>
|
|
142
|
+
|
|
143
|
+
<style scoped lang="scss">
|
|
144
|
+
</style>
|
|
145
|
+
|