From 8cf9dfa2bcdda707455250a4bfaec1beab7cbe2d Mon Sep 17 00:00:00 2001 From: dragon <3013557874@qq.com> Date: Mon, 26 Aug 2024 15:01:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=96=B0=E5=85=AC=E4=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.js | 1 + package-lock.json | 84 +- package.json | 3 + src/api/noblemanNew/noblemanNew.js | 94 ++ src/api/relAgency/relAgency.js | 138 +++ .../relUserBelongings/relUserBelongings.js | 104 +++ src/components/common/TablePagination.vue | 98 +++ src/main.js | 12 +- src/mixin/mixRegion.js | 81 ++ src/utils/copy.js | 11 + src/utils/excel/Blob.js | 684 +++++++++++++++ src/utils/excel/Export2Excel.js | 141 +++ src/utils/exportExcel.js | 11 + src/utils/relDate.js | 107 +++ .../GoldCoinGiftingHistory.vue | 413 +++++++++ .../agencyDiamondFlow.vue | 314 +++++++ .../agentSendSalary.vue | 281 ++++++ .../anchorSalaryOperate.vue | 570 ++++++++++++ .../guildOperationManagement/guildInfo.vue | 821 ++++++++++++++++++ .../guildOperationManagement/guildMove.vue | 181 ++++ .../officialWithdrawRecord.vue | 414 +++++++++ 21 files changed, 4557 insertions(+), 6 deletions(-) create mode 100644 src/api/noblemanNew/noblemanNew.js create mode 100644 src/api/relAgency/relAgency.js create mode 100644 src/api/relUserBelongings/relUserBelongings.js create mode 100644 src/components/common/TablePagination.vue create mode 100644 src/mixin/mixRegion.js create mode 100644 src/utils/copy.js create mode 100644 src/utils/excel/Blob.js create mode 100644 src/utils/excel/Export2Excel.js create mode 100644 src/utils/exportExcel.js create mode 100644 src/utils/relDate.js create mode 100644 src/views/goldCoinGiftingHistory/GoldCoinGiftingHistory.vue create mode 100644 src/views/guildOperationManagement/agencyDiamondFlow.vue create mode 100644 src/views/guildOperationManagement/agentSendSalary.vue create mode 100644 src/views/guildOperationManagement/anchorSalaryOperate.vue create mode 100644 src/views/guildOperationManagement/guildInfo.vue create mode 100644 src/views/guildOperationManagement/guildMove.vue create mode 100644 src/views/guildOperationManagement/officialWithdrawRecord.vue diff --git a/.eslintrc.js b/.eslintrc.js index b06c640..e7ccf4d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -17,5 +17,6 @@ module.exports = { 'no-unused-vars': 'off', 'no-useless-escape': 'off', 'no-control-regex': 'off', + 'no-extra-semi': 'off', } } diff --git a/package-lock.json b/package-lock.json index 60ea7e6..5494a24 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "bootstrap": "^3.3.5", "core-js": "^3.8.3", "element-plus": "^2.3.14", + "file-saver": "^2.0.5", "font-awesome": "^4.6.3", "ionicons": "^2.0.1", "jquery": "^2.2.0", @@ -26,6 +27,7 @@ "sass": "^1.67.0", "sass-loader": "^13.3.2", "unplugin-element-plus": "^0.8.0", + "vue-clipboard2": "^0.3.3", "vue-router": "^4.0.3", "vuex": "^4.0.0", "xlsx": "^0.18.5" @@ -40,6 +42,7 @@ "@vue/cli-service": "~5.0.0", "eslint": "^7.32.0", "eslint-plugin-vue": "^8.0.3", + "script-loader": "^0.7.2", "unplugin-auto-import": "^0.16.7", "unplugin-vue-components": "^0.25.2", "vue": "^3.2.13", @@ -4435,9 +4438,23 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001546", - "resolved": "https://registry.npmmirror.com/caniuse-lite/-/caniuse-lite-1.0.30001546.tgz", - "integrity": "sha512-zvtSJwuQFpewSyRrI3AsftF6rM0X80mZkChIt1spBGEvRglCrjTniXvinc8JKRoqTwXAgvqTImaN9igfSMtUBw==" + "version": "1.0.30001651", + "resolved": "https://registry.npmmirror.com/caniuse-lite/-/caniuse-lite-1.0.30001651.tgz", + "integrity": "sha512-9Cf+Xv1jJNe1xPZLGuUXLNkE1BoDkqRqYyFJ9TDYSqhduqA4hu4oR9HluGoWYQC/aj8WHjsGVV+bwkh0+tegRg==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ] }, "node_modules/case-sensitive-paths-webpack-plugin": { "version": "2.4.0", @@ -4652,6 +4669,16 @@ "node": ">=6" } }, + "node_modules/clipboard": { + "version": "2.0.11", + "resolved": "https://registry.npmmirror.com/clipboard/-/clipboard-2.0.11.tgz", + "integrity": "sha512-C+0bbOqkezLIsmWSvlsXS0Q0bmkugu7jcfMIACB+RDEntIzQIkdr148we28AfSloQLRdZlYL/QYyrq05j/3Faw==", + "dependencies": { + "good-listener": "^1.2.2", + "select": "^1.1.2", + "tiny-emitter": "^2.0.0" + } + }, "node_modules/clipboardy": { "version": "2.3.0", "resolved": "https://registry.npmmirror.com/clipboardy/-/clipboardy-2.3.0.tgz", @@ -5547,6 +5574,11 @@ "node": ">=0.4.0" } }, + "node_modules/delegate": { + "version": "3.2.0", + "resolved": "https://registry.npmmirror.com/delegate/-/delegate-3.2.0.tgz", + "integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==" + }, "node_modules/delegates": { "version": "1.0.0", "resolved": "https://registry.npmmirror.com/delegates/-/delegates-1.0.0.tgz", @@ -6685,6 +6717,11 @@ "node": "^10.12.0 || >=12.0.0" } }, + "node_modules/file-saver": { + "version": "2.0.5", + "resolved": "https://registry.npmmirror.com/file-saver/-/file-saver-2.0.5.tgz", + "integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA==" + }, "node_modules/fill-range": { "version": "7.0.1", "resolved": "https://registry.npmmirror.com/fill-range/-/fill-range-7.0.1.tgz", @@ -7082,6 +7119,14 @@ "node": "*" } }, + "node_modules/good-listener": { + "version": "1.2.2", + "resolved": "https://registry.npmmirror.com/good-listener/-/good-listener-1.2.2.tgz", + "integrity": "sha512-goW1b+d9q/HIwbVYZzZ6SsTr4IgE+WA44A0GmPIQstuOrgsFcT7VEJ48nmr9GaRtNu0XTKacFLGnBPAM6Afouw==", + "dependencies": { + "delegate": "^3.1.2" + } + }, "node_modules/gopd": { "version": "1.0.1", "resolved": "https://registry.npmmirror.com/gopd/-/gopd-1.0.1.tgz", @@ -10790,6 +10835,12 @@ "node": ">= 0.8" } }, + "node_modules/raw-loader": { + "version": "0.5.1", + "resolved": "https://registry.npmmirror.com/raw-loader/-/raw-loader-0.5.1.tgz", + "integrity": "sha512-sf7oGoLuaYAScB4VGr0tzetsYlS8EJH6qnTCfQ/WVEa89hALQ4RQfCKt5xCyPQKPDUbVUAIP1QsxAwfAjlDp7Q==", + "dev": true + }, "node_modules/read-pkg": { "version": "5.2.0", "resolved": "https://registry.npmmirror.com/read-pkg/-/read-pkg-5.2.0.tgz", @@ -11238,6 +11289,15 @@ "node": ">= 8.9.0" } }, + "node_modules/script-loader": { + "version": "0.7.2", + "resolved": "https://registry.npmmirror.com/script-loader/-/script-loader-0.7.2.tgz", + "integrity": "sha512-UMNLEvgOAQuzK8ji8qIscM3GIrRCWN6MmMXGD4SD5l6cSycgGsCo0tX5xRnfQcoghqct0tjHjcykgI1PyBE2aA==", + "dev": true, + "dependencies": { + "raw-loader": "~0.5.1" + } + }, "node_modules/scss-tokenizer": { "version": "0.4.3", "resolved": "https://registry.npmmirror.com/scss-tokenizer/-/scss-tokenizer-0.4.3.tgz", @@ -11261,6 +11321,11 @@ "integrity": "sha512-4AsO/FrViE/iDNEPaAQlb77tf0csuq27EsVpy6ett584EcRTp6pTDLoGWVxCD77y5iU5FauOvhsI4o1APwPoSQ==", "dev": true }, + "node_modules/select": { + "version": "1.1.2", + "resolved": "https://registry.npmmirror.com/select/-/select-1.1.2.tgz", + "integrity": "sha512-OwpTSOfy6xSs1+pwcNrv0RBMOzI39Lp3qQKUTPVVPRjCdNa5JH/oPRiqsesIskK8TVgmRiHwO4KXlV2Li9dANA==" + }, "node_modules/select-hose": { "version": "2.0.0", "resolved": "https://registry.npmmirror.com/select-hose/-/select-hose-2.0.0.tgz", @@ -12142,6 +12207,11 @@ "integrity": "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==", "dev": true }, + "node_modules/tiny-emitter": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/tiny-emitter/-/tiny-emitter-2.1.0.tgz", + "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==" + }, "node_modules/to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmmirror.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz", @@ -12638,6 +12708,14 @@ "@vue/shared": "3.2.13" } }, + "node_modules/vue-clipboard2": { + "version": "0.3.3", + "resolved": "https://registry.npmmirror.com/vue-clipboard2/-/vue-clipboard2-0.3.3.tgz", + "integrity": "sha512-aNWXIL2DKgJyY/1OOeITwAQz1fHaCIGvUFHf9h8UcoQBG5a74MkdhS/xqoYe7DNZdQmZRL+TAdIbtUs9OyVjbw==", + "dependencies": { + "clipboard": "^2.0.0" + } + }, "node_modules/vue-eslint-parser": { "version": "8.3.0", "resolved": "https://registry.npmmirror.com/vue-eslint-parser/-/vue-eslint-parser-8.3.0.tgz", diff --git a/package.json b/package.json index b6e43d1..50bf759 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "bootstrap": "^3.3.5", "core-js": "^3.8.3", "element-plus": "^2.3.14", + "file-saver": "^2.0.5", "font-awesome": "^4.6.3", "ionicons": "^2.0.1", "jquery": "^2.2.0", @@ -26,6 +27,7 @@ "sass": "^1.67.0", "sass-loader": "^13.3.2", "unplugin-element-plus": "^0.8.0", + "vue-clipboard2": "^0.3.3", "vue-router": "^4.0.3", "vuex": "^4.0.0", "xlsx": "^0.18.5" @@ -40,6 +42,7 @@ "@vue/cli-service": "~5.0.0", "eslint": "^7.32.0", "eslint-plugin-vue": "^8.0.3", + "script-loader": "^0.7.2", "unplugin-auto-import": "^0.16.7", "unplugin-vue-components": "^0.25.2", "vue": "^3.2.13", diff --git a/src/api/noblemanNew/noblemanNew.js b/src/api/noblemanNew/noblemanNew.js new file mode 100644 index 0000000..9cfcc3a --- /dev/null +++ b/src/api/noblemanNew/noblemanNew.js @@ -0,0 +1,94 @@ +import request from '@/utils/request'; +import { genQueryParam } from '@/utils/maintainer'; + +// 邀请移除记录 +export const pageOperateRecord = query => { + return request({ + url: '/admin/guild/manage/pageOperateRecord', + method: 'get', + params: query + }); +}; +// 查询公会信息 +export const pageFamily = query => { + return request({ + url: '/admin/guild/manage/pageGuild', + method: 'get', + params: query + }); +}; +// 公会成员信息 +export const pageFamilyMember = query => { + return request({ + url: '/admin/family/manage/pageFamilyMember', + method: 'get', + params: query + }); +}; +// 创建公会信息 +export const create = query => { + return request({ + url: '/admin/guild/manage/create', + method: 'post', + params: query + }); +}; +// 删除公会信息 +export const dismiss = query => { + return request({ + url: '/admin/guild/manage/dismiss', + method: 'post', + params: query + }); +}; +// 幸运礼物详情导出 +export const luckyGiftRewardRecordExport = query => { + window.location.href = `/admin/luckyGiftRewardRecord/export?${genQueryParam(query)}`; + return; +}; +// 公会信息编辑接口 +export const update = query => { + return request({ + url: '/admin/guild/manage/update', + method: 'post', + params: query + }); +}; +// 导出-公会信息 +export const exportInfo = query => { + window.location.href = `/admin/guild/manage/exportGuild?${genQueryParam(query)}`; + return; +}; +// 成员信息-弹窗详情 +export const manageListFamilyMember = query => { + return request({ + url: '/admin/guild/manage/listGuildMember', + method: 'get', + params: query + }); +}; + +// 成员信息-新增成员 +export const addMember = query => { + return request({ + url: '/admin/guild/manage/addMember', + method: 'post', + params: query + }); +}; +// 成员信息-设置管理员 +export const setManager = query => { + return request({ + url: '/admin/guild/manage/setManager', + method: 'post', + params: query + }); +}; +// 成员信息-删除管理员 +export const removeMember = query => { + return request({ + url: '/admin/guild/manage/removeMember', + method: 'post', + params: query + }); +}; \ No newline at end of file diff --git a/src/api/relAgency/relAgency.js b/src/api/relAgency/relAgency.js new file mode 100644 index 0000000..cf5d00c --- /dev/null +++ b/src/api/relAgency/relAgency.js @@ -0,0 +1,138 @@ + +import request from '@/utils/request'; +import qs from 'qs'; +import { genQueryParam } from '@/utils/maintainer'; +// 活动配置 相关接口(一级菜单:活动配置) + +// 获取 周期列表 +export const getDateCycleList = query => { + return request({ + url: '/anchorSalaryBill/dateCycle/list', + method: 'get', + params: query + }); +}; + +// 获取 公会钻石薪资流水统计 列表 +export const getAgencyDiamondFlow = query => { + return request({ + url: '/agency/diamond/flow/list', + method: 'get', + params: query + }); +}; + +// 公会钻石薪资流水统计 导出 +// export const agencyDiamondFlowExport = query => { +// return request({ +// url: `/agency/diamond/flow/export`, +// method: 'post', +// params: query, +// responseType: 'blob' +// }); +// }; +export const agencyDiamondFlowExport = query => { + window.location.href = `/agency/diamond/flow/export?${genQueryParam(query)}`; + return; +}; +// 主播薪资操作(不用分区) +export const getAnchorSalaryBill = query => { + return request({ + url: '/anchorSalaryBill/anchorSummary/list', + method: 'get', + params: query + }); +}; + +// salaryType 1钻石兑换薪资明细 2 薪资转赠充值代理 明细 3薪资转增公会长明细 4官方提现 6 薪资兑换金币明细 +export const anchorSalaryBillDetail = query => { + return request({ + url: '/anchorSalaryBill/detail/list', + method: 'get', + params: query + }); +}; + +// 充值代理转增薪资 +export const chargeAgentList = query => { + return request({ + url: '/anchorSalaryBill/chargeAgent/list', + method: 'get', + params: query + }); +}; +// 充值代理转增薪资 总值 +export const chargeAgentSum = query => { + return request({ + url: '/anchorSalaryBill/chargeAgent/sum', + method: 'get', + params: query + }); +}; + +// 官方提现记录 列表 +export const agencyWithdrawList = query => { + return request({ + url: '/agencyWithdrawExamine/list', + method: 'get', + params: query + }); +}; +// 官方提现记录 导出 +export const agencyWithdrawExamineExport = query => { + return request({ + url: `/agencyWithdrawExamine/export`, + method: 'post', + params: query, + responseType: 'blob' + }); +}; +// 官方提现记录 结算 +export const agencyWithdrawSet = query => { + return request({ + url: '/agencyWithdrawExamine/settle', + method: 'post', + params: query + }); +}; +// 官方提现记录 批量结算 +export const agencyWithdrawBatchSet = query => { + return request({ + url: '/agencyWithdrawExamine/batchSettle', + method: 'post', + params: query + }); +}; + +// 公会开业数据统计 +export const agencyOpenList = query => { + return request({ + url: '/agency/open/list', + method: 'get', + params: query + }); +}; +// 公会开业数据 详情 +export const agencyOpenDetail = query => { + return request({ + url: '/agency/open/detail/list', + method: 'get', + params: query + }); +}; +// 公会优秀主播数据统计 +export const excellentAnchorList = query => { + return request({ + url: '/agency/open/excellentAnchor/list', + method: 'get', + params: query + }); +}; +// 公会优秀主播数据统计 +export const excellentAnchorDetail = query => { + return request({ + url: '/agency/open/excellentAnchor/detail/list', + method: 'get', + params: query + }); +}; \ No newline at end of file diff --git a/src/api/relUserBelongings/relUserBelongings.js b/src/api/relUserBelongings/relUserBelongings.js new file mode 100644 index 0000000..36f3a91 --- /dev/null +++ b/src/api/relUserBelongings/relUserBelongings.js @@ -0,0 +1,104 @@ +import request from '@/utils/request'; +import qs from 'qs'; + +// 用户财产 相关接口(一级菜单:用户财产管理) + +// 获取 金币转赠历史列表 +export const getGoldCoinTransferList = query => { + return request({ + url: '/gold/give/history', + method: 'get', + params: query + }); +}; + +// 获取 金币转赠历史 金币汇总 +export const getGoldCoinSumGold = query => { + return request({ + url: '/gold/give/history/sumGold', + method: 'get', + params: query + }); +}; + + +// 用户资产排行 列表 +export const getUserAssetsList = query => { + return request({ + url: '/userAssets/list', + method: 'get', + params: query + }); +}; + +// 用户资产排行 导出 +export const userAssetsExport = query => { + return request({ + url: '/userAssets/export', + method: 'get', + params: query, + responseType: 'blob' + }); +}; +// 金币钻石操作记录 列表 +export const officalGoldSearch = query => { + return request({ + url: '/offical/gold/search', + method: 'get', + params: query + }); +}; + +// 金币钻石操作记录 导出 +export const officalGoldExport = query => { + return request({ + url: '/offical/gold/export', + method: 'get', + params: query, + responseType: 'blob' + }); +}; + +// 操作货币增加/减少 列表 +export const officalGoldGive= query => { + return request({ + url: '/offical/gold/give', + method: 'post', + params: query + // data: qs.stringify(query) + }); +}; + +// 操作货币增加/减少 查看用户 +export const getofficalGoldUserInfo = query => { + return request({ + url: '/offical/gold/userInfo', + method: 'get', + params: query + }); +}; + +// 冻结用户资产管理 列表 +export const getFrozenRecordList = query => { + return request({ + url: '/frozenRecord/list', + method: 'get', + params: query + }); +}; +// 冻结用户资产管理 冻结 +export const userRecordFrozen= query => { + return request({ + url: '/frozenRecord/frozen', + method: 'post', + params: query + }); +}; +// 冻结用户资产管理 解冻 +export const frozenRecordFree= query => { + return request({ + url: '/frozenRecord/free', + method: 'post', + params: query + }); +}; \ No newline at end of file diff --git a/src/components/common/TablePagination.vue b/src/components/common/TablePagination.vue new file mode 100644 index 0000000..632e30f --- /dev/null +++ b/src/components/common/TablePagination.vue @@ -0,0 +1,98 @@ + + + diff --git a/src/main.js b/src/main.js index 15b58d5..855c467 100644 --- a/src/main.js +++ b/src/main.js @@ -49,11 +49,17 @@ import '@/assets/plugins/bootstrap-treeview/js/bootstrap-treeview.min.js' // @ts-ignore import components from '@/utils/components.js' - +import Vue from 'vue'; // import ElementPlus from 'element-plus' // import 'element-plus/dist/index.css' import '@/css/public.css' - +import VueClipboard from 'vue-clipboard2' +// import 'vue-clipboard2/dist/vue-clipboard.min.css' +import { copy } from './utils/copy.js'; const app = createApp(App) +app.config.globalProperties.$copy = function (text) { + copy(text, this); +}; + app.config.warnHandler = () => null; -app.use(store).use(router).use(components).mount('#app') +app.use(store).use(router).use(components).use(VueClipboard).mount('#app') diff --git a/src/mixin/mixRegion.js b/src/mixin/mixRegion.js new file mode 100644 index 0000000..56f7a9a --- /dev/null +++ b/src/mixin/mixRegion.js @@ -0,0 +1,81 @@ + +// 公共混入 用户区服处理 +/** + * 注意: 使用混入,在选择区服切换的时候会添加搜索的区服, + * 所以页面data如果没有searchForm: { region: null }, 需要加上,否则查询searchForm为空 + */ +export default { + data() { + return { + userRegion: JSON.parse(localStorage.getItem('user_region')), + regionEnum: [ + { value: 1, name: 'A区' }, + { value: 2, name: 'B区' }, + { value: 3, name: 'C区' }, + { value: 4, name: 'D区' }, + { value: 5, name: 'E区' }, + { value: 6, name: 'F区' } + ], + userAreaRegion: [], //拥有权限的区域列表 + region: null, //展示的区域 + } + }, + created() { + this.handleUserRegion() + }, + methods: { + handleUserRegion() { + if (this.userRegion.length == 0) { + this.$message.error({ + message: '请先联系管理员设置你的区服权限!', + duration: 5000 + }); + return + } + this.userAreaRegion = this.regionEnum.filter(item => this.userRegion.includes(item.value)); + this.region = this.userAreaRegion[0].value; + this.searchForm.region = this.region; + console.log('当前查看区服:', this.region); + }, + handSearchRegion() { + if (this.$refs['searchForm']) { // 检查 this.$refs['searchForm'] 是否存在 + this.$refs['searchForm'].validate((valid) => { + if (valid) { + this.pageParams.pageNo = 1; + this.getData(); + } + }); + } else { + this.pageParams.pageNo = 1; + this.getData(); + } + }, + }, + computed: { + regionType() { + const { regionEnum } = this; + return function (value) { + for (let item of regionEnum) { + if (item.value === value) { + return item.name; + } + } + return ''; + }; + } + }, + watch: { + region: { + handler(newVal, oldVal) { + this.searchForm.region = newVal; + // 防止初始化重复调用查询表单接口 + if (oldVal != null) { + this.handSearchRegion() + } + }, + // immediate: true, //立即监听 + }, + + } + +} diff --git a/src/utils/copy.js b/src/utils/copy.js new file mode 100644 index 0000000..76d4a4e --- /dev/null +++ b/src/utils/copy.js @@ -0,0 +1,11 @@ + +// copy.js +export function copy(text, vueInstance) { + vueInstance.$copyText(text) + .then(() => { + vueInstance.$message.success('已复制'); + }) + .catch(() => { + vueInstance.$message.warning('复制失败'); + }); +} diff --git a/src/utils/excel/Blob.js b/src/utils/excel/Blob.js new file mode 100644 index 0000000..6178564 --- /dev/null +++ b/src/utils/excel/Blob.js @@ -0,0 +1,684 @@ +// /* Blob.js +// * A Blob, File, FileReader & URL implementation. +// * 2019-04-19 +// * +// * By Eli Grey, http://eligrey.com +// * By Jimmy Wärting, https://github.com/jimmywarting +// * License: MIT +// * See https://github.com/eligrey/Blob.js/blob/master/LICENSE.md +// */ + +// ; (function () { +// var global = typeof window === 'object' +// ? window : typeof self === 'object' +// ? self : this + +// var BlobBuilder = global.BlobBuilder +// || global.WebKitBlobBuilder +// || global.MSBlobBuilder +// || global.MozBlobBuilder + +// global.URL = global.URL || global.webkitURL || function (href, a) { +// a = document.createElement('a') +// a.href = href +// return a +// } + +// var origBlob = global.Blob +// var createObjectURL = URL.createObjectURL +// var revokeObjectURL = URL.revokeObjectURL +// var strTag = global.Symbol && global.Symbol.toStringTag +// var blobSupported = false +// var blobSupportsArrayBufferView = false +// var arrayBufferSupported = !!global.ArrayBuffer +// var blobBuilderSupported = BlobBuilder +// && BlobBuilder.prototype.append +// && BlobBuilder.prototype.getBlob + +// try { +// // Check if Blob constructor is supported +// blobSupported = new Blob(['ä']).size === 2 + +// // Check if Blob constructor supports ArrayBufferViews +// // Fails in Safari 6, so we need to map to ArrayBuffers there. +// blobSupportsArrayBufferView = new Blob([new Uint8Array([1, 2])]).size === 2 +// } catch (e) { } + +// /** +// * Helper function that maps ArrayBufferViews to ArrayBuffers +// * Used by BlobBuilder constructor and old browsers that didn't +// * support it in the Blob constructor. +// */ +// function mapArrayBufferViews(ary) { +// return ary.map(function (chunk) { +// if (chunk.buffer instanceof ArrayBuffer) { +// var buf = chunk.buffer + +// // if this is a subarray, make a copy so we only +// // include the subarray region from the underlying buffer +// if (chunk.byteLength !== buf.byteLength) { +// var copy = new Uint8Array(chunk.byteLength) +// copy.set(new Uint8Array(buf, chunk.byteOffset, chunk.byteLength)) +// buf = copy.buffer +// } + +// return buf +// } + +// return chunk +// }) +// } + +// function BlobBuilderConstructor(ary, options) { +// options = options || {} + +// var bb = new BlobBuilder() +// mapArrayBufferViews(ary).forEach(function (part) { +// bb.append(part) +// }) + +// return options.type ? bb.getBlob(options.type) : bb.getBlob() +// } + +// function BlobConstructor(ary, options) { +// return new origBlob(mapArrayBufferViews(ary), options || {}) +// } + +// if (global.Blob) { +// BlobBuilderConstructor.prototype = Blob.prototype +// BlobConstructor.prototype = Blob.prototype +// } + + + +// /********************************************************/ +// /* String Encoder fallback */ +// /********************************************************/ +// function stringEncode(string) { +// var pos = 0 +// var len = string.length +// var Arr = global.Uint8Array || Array // Use byte array when possible + +// var at = 0 // output position +// var tlen = Math.max(32, len + (len >> 1) + 7) // 1.5x size +// var target = new Arr((tlen >> 3) << 3) // ... but at 8 byte offset + +// while (pos < len) { +// var value = string.charCodeAt(pos++) +// if (value >= 0xd800 && value <= 0xdbff) { +// // high surrogate +// if (pos < len) { +// var extra = string.charCodeAt(pos) +// if ((extra & 0xfc00) === 0xdc00) { +// ++pos +// value = ((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000 +// } +// } +// if (value >= 0xd800 && value <= 0xdbff) { +// continue // drop lone surrogate +// } +// } + +// // expand the buffer if we couldn't write 4 bytes +// if (at + 4 > target.length) { +// tlen += 8 // minimum extra +// tlen *= (1.0 + (pos / string.length) * 2) // take 2x the remaining +// tlen = (tlen >> 3) << 3 // 8 byte offset + +// var update = new Uint8Array(tlen) +// update.set(target) +// target = update +// } + +// if ((value & 0xffffff80) === 0) { // 1-byte +// target[at++] = value // ASCII +// continue +// } else if ((value & 0xfffff800) === 0) { // 2-byte +// target[at++] = ((value >> 6) & 0x1f) | 0xc0 +// } else if ((value & 0xffff0000) === 0) { // 3-byte +// target[at++] = ((value >> 12) & 0x0f) | 0xe0 +// target[at++] = ((value >> 6) & 0x3f) | 0x80 +// } else if ((value & 0xffe00000) === 0) { // 4-byte +// target[at++] = ((value >> 18) & 0x07) | 0xf0 +// target[at++] = ((value >> 12) & 0x3f) | 0x80 +// target[at++] = ((value >> 6) & 0x3f) | 0x80 +// } else { +// // FIXME: do we care +// continue +// } + +// target[at++] = (value & 0x3f) | 0x80 +// } + +// return target.slice(0, at) +// } + +// /********************************************************/ +// /* String Decoder fallback */ +// /********************************************************/ +// function stringDecode(buf) { +// var end = buf.length +// var res = [] + +// var i = 0 +// while (i < end) { +// var firstByte = buf[i] +// var codePoint = null +// var bytesPerSequence = (firstByte > 0xEF) ? 4 +// : (firstByte > 0xDF) ? 3 +// : (firstByte > 0xBF) ? 2 +// : 1 + +// if (i + bytesPerSequence <= end) { +// var secondByte, thirdByte, fourthByte, tempCodePoint + +// switch (bytesPerSequence) { +// case 1: +// if (firstByte < 0x80) { +// codePoint = firstByte +// } +// break +// case 2: +// secondByte = buf[i + 1] +// if ((secondByte & 0xC0) === 0x80) { +// tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) +// if (tempCodePoint > 0x7F) { +// codePoint = tempCodePoint +// } +// } +// break +// case 3: +// secondByte = buf[i + 1] +// thirdByte = buf[i + 2] +// if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { +// tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) +// if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { +// codePoint = tempCodePoint +// } +// } +// break +// case 4: +// secondByte = buf[i + 1] +// thirdByte = buf[i + 2] +// fourthByte = buf[i + 3] +// if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { +// tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) +// if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { +// codePoint = tempCodePoint +// } +// } +// } +// } + +// if (codePoint === null) { +// // we did not generate a valid codePoint so insert a +// // replacement char (U+FFFD) and advance only 1 byte +// codePoint = 0xFFFD +// bytesPerSequence = 1 +// } else if (codePoint > 0xFFFF) { +// // encode to utf16 (surrogate pair dance) +// codePoint -= 0x10000 +// res.push(codePoint >>> 10 & 0x3FF | 0xD800) +// codePoint = 0xDC00 | codePoint & 0x3FF +// } + +// res.push(codePoint) +// i += bytesPerSequence +// } + +// var len = res.length +// var str = '' +// var i = 0 + +// while (i < len) { +// str += String.fromCharCode.apply(String, res.slice(i, i += 0x1000)) +// } + +// return str +// } + +// // string -> buffer +// var textEncode = typeof TextEncoder === 'function' +// ? TextEncoder.prototype.encode.bind(new TextEncoder()) +// : stringEncode + +// // buffer -> string +// var textDecode = typeof TextDecoder === 'function' +// ? TextDecoder.prototype.decode.bind(new TextDecoder()) +// : stringDecode + +// function FakeBlobBuilder() { +// function isDataView(obj) { +// return obj && DataView.prototype.isPrototypeOf(obj) +// } +// function bufferClone(buf) { +// var view = new Array(buf.byteLength) +// var array = new Uint8Array(buf) +// var i = view.length +// while (i--) { +// view[i] = array[i] +// } +// return view +// } +// function array2base64(input) { +// var byteToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=' + +// var output = [] + +// for (var i = 0; i < input.length; i += 3) { +// var byte1 = input[i] +// var haveByte2 = i + 1 < input.length +// var byte2 = haveByte2 ? input[i + 1] : 0 +// var haveByte3 = i + 2 < input.length +// var byte3 = haveByte3 ? input[i + 2] : 0 + +// var outByte1 = byte1 >> 2 +// var outByte2 = ((byte1 & 0x03) << 4) | (byte2 >> 4) +// var outByte3 = ((byte2 & 0x0F) << 2) | (byte3 >> 6) +// var outByte4 = byte3 & 0x3F + +// if (!haveByte3) { +// outByte4 = 64 + +// if (!haveByte2) { +// outByte3 = 64 +// } +// } + +// output.push( +// byteToCharMap[outByte1], byteToCharMap[outByte2], +// byteToCharMap[outByte3], byteToCharMap[outByte4] +// ) +// } + +// return output.join('') +// } + +// var create = Object.create || function (a) { +// function c() { } +// c.prototype = a +// return new c() +// } + +// if (arrayBufferSupported) { +// var viewClasses = [ +// '[object Int8Array]', +// '[object Uint8Array]', +// '[object Uint8ClampedArray]', +// '[object Int16Array]', +// '[object Uint16Array]', +// '[object Int32Array]', +// '[object Uint32Array]', +// '[object Float32Array]', +// '[object Float64Array]' +// ] + +// var isArrayBufferView = ArrayBuffer.isView || function (obj) { +// return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1 +// } +// } + +// function concatTypedarrays(chunks) { +// var size = 0 +// var i = chunks.length +// while (i--) { size += chunks[i].length } +// var b = new Uint8Array(size) +// var offset = 0 +// for (i = 0, l = chunks.length; i < l; i++) { +// var chunk = chunks[i] +// b.set(chunk, offset) +// offset += chunk.byteLength || chunk.length +// } + +// return b +// } + +// /********************************************************/ +// /* Blob constructor */ +// /********************************************************/ +// function Blob(chunks, opts) { +// chunks = chunks || [] +// opts = opts == null ? {} : opts +// for (var i = 0, len = chunks.length; i < len; i++) { +// var chunk = chunks[i] +// if (chunk instanceof Blob) { +// chunks[i] = chunk._buffer +// } else if (typeof chunk === 'string') { +// chunks[i] = textEncode(chunk) +// } else if (arrayBufferSupported && (ArrayBuffer.prototype.isPrototypeOf(chunk) || isArrayBufferView(chunk))) { +// chunks[i] = bufferClone(chunk) +// } else if (arrayBufferSupported && isDataView(chunk)) { +// chunks[i] = bufferClone(chunk.buffer) +// } else { +// chunks[i] = textEncode(String(chunk)) +// } +// } + +// this._buffer = global.Uint8Array +// ? concatTypedarrays(chunks) +// : [].concat.apply([], chunks) +// this.size = this._buffer.length + +// this.type = opts.type || '' +// if (/[^\u0020-\u007E]/.test(this.type)) { +// this.type = '' +// } else { +// this.type = this.type.toLowerCase() +// } +// } + +// Blob.prototype.arrayBuffer = function () { +// return Promise.resolve(this._buffer) +// } + +// Blob.prototype.text = function () { +// return Promise.resolve(textDecode(this._buffer)) +// } + +// Blob.prototype.slice = function (start, end, type) { +// var slice = this._buffer.slice(start || 0, end || this._buffer.length) +// return new Blob([slice], { type: type }) +// } + +// Blob.prototype.toString = function () { +// return '[object Blob]' +// } + +// /********************************************************/ +// /* File constructor */ +// /********************************************************/ +// function File(chunks, name, opts) { +// opts = opts || {} +// var a = Blob.call(this, chunks, opts) || this +// a.name = name.replace(/\//g, ':') +// a.lastModifiedDate = opts.lastModified ? new Date(opts.lastModified) : new Date() +// a.lastModified = +a.lastModifiedDate + +// return a +// } + +// File.prototype = create(Blob.prototype) +// File.prototype.constructor = File + +// if (Object.setPrototypeOf) { +// Object.setPrototypeOf(File, Blob) +// } else { +// try { File.__proto__ = Blob } catch (e) { } +// } + +// File.prototype.toString = function () { +// return '[object File]' +// } + +// /********************************************************/ +// /* FileReader constructor */ +// /********************************************************/ +// function FileReader() { +// if (!(this instanceof FileReader)) { +// throw new TypeError("Failed to construct 'FileReader': Please use the 'new' operator, this DOM object constructor cannot be called as a function.") +// } + +// var delegate = document.createDocumentFragment() +// this.addEventListener = delegate.addEventListener +// this.dispatchEvent = function (evt) { +// var local = this['on' + evt.type] +// if (typeof local === 'function') local(evt) +// delegate.dispatchEvent(evt) +// } +// this.removeEventListener = delegate.removeEventListener +// } + +// function _read(fr, blob, kind) { +// if (!(blob instanceof Blob)) { +// throw new TypeError("Failed to execute '" + kind + "' on 'FileReader': parameter 1 is not of type 'Blob'.") +// } + +// fr.result = '' + +// setTimeout(function () { +// this.readyState = FileReader.LOADING +// fr.dispatchEvent(new Event('load')) +// fr.dispatchEvent(new Event('loadend')) +// }) +// } + +// FileReader.EMPTY = 0 +// FileReader.LOADING = 1 +// FileReader.DONE = 2 +// FileReader.prototype.error = null +// FileReader.prototype.onabort = null +// FileReader.prototype.onerror = null +// FileReader.prototype.onload = null +// FileReader.prototype.onloadend = null +// FileReader.prototype.onloadstart = null +// FileReader.prototype.onprogress = null + +// FileReader.prototype.readAsDataURL = function (blob) { +// _read(this, blob, 'readAsDataURL') +// this.result = 'data:' + blob.type + ';base64,' + array2base64(blob._buffer) +// } + +// FileReader.prototype.readAsText = function (blob) { +// _read(this, blob, 'readAsText') +// this.result = textDecode(blob._buffer) +// } + +// FileReader.prototype.readAsArrayBuffer = function (blob) { +// _read(this, blob, 'readAsText') +// // return ArrayBuffer when possible +// this.result = (blob._buffer.buffer || blob._buffer).slice() +// } + +// FileReader.prototype.abort = function () { } + +// /********************************************************/ +// /* URL */ +// /********************************************************/ +// URL.createObjectURL = function (blob) { +// return blob instanceof Blob +// ? 'data:' + blob.type + ';base64,' + array2base64(blob._buffer) +// : createObjectURL.call(URL, blob) +// } + +// URL.revokeObjectURL = function (url) { +// revokeObjectURL && revokeObjectURL.call(URL, url) +// } + +// /********************************************************/ +// /* XHR */ +// /********************************************************/ +// var _send = global.XMLHttpRequest && global.XMLHttpRequest.prototype.send +// if (_send) { +// XMLHttpRequest.prototype.send = function (data) { +// if (data instanceof Blob) { +// this.setRequestHeader('Content-Type', data.type) +// _send.call(this, textDecode(data._buffer)) +// } else { +// _send.call(this, data) +// } +// } +// } + +// global.FileReader = FileReader +// global.File = File +// global.Blob = Blob +// } + +// function fixFileAndXHR() { +// var isIE = !!global.ActiveXObject || ( +// '-ms-scroll-limit' in document.documentElement.style && +// '-ms-ime-align' in document.documentElement.style +// ) + +// // Monkey patched +// // IE don't set Content-Type header on XHR whose body is a typed Blob +// // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/6047383 +// var _send = global.XMLHttpRequest && global.XMLHttpRequest.prototype.send +// if (isIE && _send) { +// XMLHttpRequest.prototype.send = function (data) { +// if (data instanceof Blob) { +// this.setRequestHeader('Content-Type', data.type) +// _send.call(this, data) +// } else { +// _send.call(this, data) +// } +// } +// } + +// try { +// new File([], '') +// } catch (e) { +// try { +// var klass = new Function('class File extends Blob {' + +// 'constructor(chunks, name, opts) {' + +// 'opts = opts || {};' + +// 'super(chunks, opts || {});' + +// 'this.name = name.replace(/\//g, ":");' + +// 'this.lastModifiedDate = opts.lastModified ? new Date(opts.lastModified) : new Date();' + +// 'this.lastModified = +this.lastModifiedDate;' + +// '}};' + +// 'return new File([], ""), File' +// )() +// global.File = klass +// } catch (e) { +// var klass = function (b, d, c) { +// var blob = new Blob(b, c) +// var t = c && void 0 !== c.lastModified ? new Date(c.lastModified) : new Date() + +// blob.name = d.replace(/\//g, ':') +// blob.lastModifiedDate = t +// blob.lastModified = +t +// blob.toString = function () { +// return '[object File]' +// } + +// if (strTag) { +// blob[strTag] = 'File' +// } + +// return blob +// } +// global.File = klass +// } +// } +// } + +// if (blobSupported) { +// fixFileAndXHR() +// global.Blob = blobSupportsArrayBufferView ? global.Blob : BlobConstructor +// } else if (blobBuilderSupported) { +// fixFileAndXHR() +// global.Blob = BlobBuilderConstructor +// } else { +// FakeBlobBuilder() +// } + +// if (strTag) { +// File.prototype[strTag] = 'File' +// Blob.prototype[strTag] = 'Blob' +// FileReader.prototype[strTag] = 'FileReader' +// } + +// var blob = global.Blob.prototype +// var stream + +// function promisify(obj) { +// return new Promise(function (resolve, reject) { +// obj.onload = +// obj.onerror = function (evt) { +// obj.onload = +// obj.onerror = null + +// evt.type === 'load' +// ? resolve(obj.result || obj) +// : reject(new Error('Failed to read the blob/file')) +// } +// }) +// } + + +// try { +// new ReadableStream({ type: 'bytes' }) +// stream = function stream() { +// var position = 0 +// var blob = this + +// return new ReadableStream({ +// type: 'bytes', +// autoAllocateChunkSize: 524288, + +// pull: function (controller) { +// var v = controller.byobRequest.view +// var chunk = blob.slice(position, position + v.byteLength) +// return chunk.arrayBuffer() +// .then(function (buffer) { +// var uint8array = new Uint8Array(buffer) +// var bytesRead = uint8array.byteLength + +// position += bytesRead +// v.set(uint8array) +// controller.byobRequest.respond(bytesRead) + +// if (position >= blob.size) +// controller.close() +// }) +// } +// }) +// } +// } catch (e) { +// try { +// new ReadableStream({}) +// stream = function stream(blob) { +// var position = 0 +// var blob = this + +// return new ReadableStream({ +// pull: function (controller) { +// var chunk = blob.slice(position, position + 524288) + +// return chunk.arrayBuffer().then(function (buffer) { +// position += buffer.byteLength +// var uint8array = new Uint8Array(buffer) +// controller.enqueue(uint8array) + +// if (position == blob.size) +// controller.close() +// }) +// } +// }) +// } +// } catch (e) { +// try { +// new Response('').body.getReader().read() +// stream = function stream() { +// return (new Response(this)).body +// } +// } catch (e) { +// stream = function stream() { +// throw new Error('Include https://github.com/MattiasBuelens/web-streams-polyfill') +// } +// } +// } +// } + + +// if (!blob.arrayBuffer) { +// blob.arrayBuffer = function arrayBuffer() { +// var fr = new FileReader() +// fr.readAsArrayBuffer(this) +// return promisify(fr) +// } +// } + +// if (!blob.text) { +// blob.text = function text() { +// var fr = new FileReader() +// fr.readAsText(this) +// return promisify(fr) +// } +// } + +// if (!blob.stream) { +// blob.stream = stream +// } +// })() \ No newline at end of file diff --git a/src/utils/excel/Export2Excel.js b/src/utils/excel/Export2Excel.js new file mode 100644 index 0000000..65e9e53 --- /dev/null +++ b/src/utils/excel/Export2Excel.js @@ -0,0 +1,141 @@ +/* eslint-disable */ +require('script-loader!file-saver'); +// require('script-loader!./Blob.js'); +require('script-loader!xlsx/dist/xlsx.core.min'); +function generateArray(table) { + var out = []; + var rows = table.querySelectorAll('tr'); + var ranges = []; + for (var R = 0; R < rows.length; ++R) { + var outRow = []; + var row = rows[R]; + var columns = row.querySelectorAll('td'); + for (var C = 0; C < columns.length; ++C) { + var cell = columns[C]; + var colspan = cell.getAttribute('colspan'); + var rowspan = cell.getAttribute('rowspan'); + var cellValue = cell.innerText; + if (cellValue !== "" && cellValue == +cellValue) cellValue = +cellValue; + + //Skip ranges + ranges.forEach(function (range) { + if (R >= range.s.r && R <= range.e.r && outRow.length >= range.s.c && outRow.length <= range.e.c) { + for (var i = 0; i <= range.e.c - range.s.c; ++i) outRow.push(null); + } + }); + + //Handle Row Span + if (rowspan || colspan) { + rowspan = rowspan || 1; + colspan = colspan || 1; + ranges.push({s: {r: R, c: outRow.length}, e: {r: R + rowspan - 1, c: outRow.length + colspan - 1}}); + } + ; + + //Handle Value + outRow.push(cellValue !== "" ? cellValue : null); + + //Handle Colspan + if (colspan) for (var k = 0; k < colspan - 1; ++k) outRow.push(null); + } + out.push(outRow); + } + return [out, ranges]; +}; + +function datenum(v, date1904) { + if (date1904) v += 1462; + var epoch = Date.parse(v); + return (epoch - new Date(Date.UTC(1899, 11, 30))) / (24 * 60 * 60 * 1000); +} + +function sheet_from_array_of_arrays(data, opts) { + var ws = {}; + var range = {s: {c: 10000000, r: 10000000}, e: {c: 0, r: 0}}; + for (var R = 0; R != data.length; ++R) { + for (var C = 0; C != data[R].length; ++C) { + if (range.s.r > R) range.s.r = R; + if (range.s.c > C) range.s.c = C; + if (range.e.r < R) range.e.r = R; + if (range.e.c < C) range.e.c = C; + var cell = {v: data[R][C]}; + if (cell.v == null) continue; + var cell_ref = XLSX.utils.encode_cell({c: C, r: R}); + + if (typeof cell.v === 'number') cell.t = 'n'; + else if (typeof cell.v === 'boolean') cell.t = 'b'; + else if (cell.v instanceof Date) { + cell.t = 'n'; + cell.z = XLSX.SSF._table[14]; + cell.v = datenum(cell.v); + } + else cell.t = 's'; + + ws[cell_ref] = cell; + } + } + if (range.s.c < 10000000) ws['!ref'] = XLSX.utils.encode_range(range); + return ws; +} + +function Workbook() { + if (!(this instanceof Workbook)) return new Workbook(); + this.SheetNames = []; + this.Sheets = {}; +} + +function s2ab(s) { + var buf = new ArrayBuffer(s.length); + var view = new Uint8Array(buf); + for (var i = 0; i != s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF; + return buf; +} + +export function export_table_to_excel(id) { + var theTable = document.getElementById(id); + console.log('a') + var oo = generateArray(theTable); + var ranges = oo[1]; + + /* original data */ + var data = oo[0]; + var ws_name = "SheetJS"; + console.log(data); + + var wb = new Workbook(), ws = sheet_from_array_of_arrays(data); + + /* add ranges to worksheet */ + // ws['!cols'] = ['apple', 'banan']; + ws['!merges'] = ranges; + + /* add worksheet to workbook */ + wb.SheetNames.push(ws_name); + wb.Sheets[ws_name] = ws; + + var wbout = XLSX.write(wb, {bookType: 'xlsx', bookSST: false, type: 'binary'}); + + saveAs(new Blob([s2ab(wbout)], {type: "application/octet-stream"}), "test.xlsx") +} + +function formatJson(jsonData) { + console.log(jsonData) +} +export function export_json_to_excel(th, jsonData, defaultTitle) { + + /* original data */ + + var data = jsonData; + data.unshift(th); + var ws_name = "SheetJS"; + + var wb = new Workbook(), ws = sheet_from_array_of_arrays(data); + + + /* add worksheet to workbook */ + wb.SheetNames.push(ws_name); + wb.Sheets[ws_name] = ws; + + var wbout = XLSX.write(wb, {bookType: 'xlsx', bookSST: false, type: 'binary'}); + var title = defaultTitle || '列表' + saveAs(new Blob([s2ab(wbout)], {type: "application/octet-stream"}), title + ".xlsx") +} \ No newline at end of file diff --git a/src/utils/exportExcel.js b/src/utils/exportExcel.js new file mode 100644 index 0000000..504f5f0 --- /dev/null +++ b/src/utils/exportExcel.js @@ -0,0 +1,11 @@ +function formatJson(filterVal, jsonData) { + return jsonData.map(v => filterVal.map(j => v[j])); +} + +export const exportExcel = (tHeader, filterVal, data, excelName) => { + require.ensure([], () => { + const { export_json_to_excel } = require('./excel/Export2Excel.js'); + const combineData = formatJson(filterVal, data); + export_json_to_excel(tHeader, combineData, excelName); + }); +} \ No newline at end of file diff --git a/src/utils/relDate.js b/src/utils/relDate.js new file mode 100644 index 0000000..c99d409 --- /dev/null +++ b/src/utils/relDate.js @@ -0,0 +1,107 @@ +export const formatDate = (value) => { + let timezone = 3; //目标时区时间,东3区(东时区正数 西时区负数) + let offset_GMT = new Date(value).getTimezoneOffset(); // 本地时间和格林威治的时间差,单位为分钟 + let nowDate = new Date(value).getTime(); // 本地时间距 1970 年 1 月 1 日午夜(GMT 时间)之间的毫秒数 + let date = new Date(nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000); + + // 提取年、月、日、小时、分钟和秒 + let y = date.getFullYear(); + let MM = date.getMonth() + 1; + MM = MM < 10 ? ('0' + MM) : MM; + let d = date.getDate(); + d = d < 10 ? ('0' + d) : d; + let h = date.getHours(); + h = h < 10 ? ('0' + h) : h; + let m = date.getMinutes(); + m = m < 10 ? ('0' + m) : m; + let s = date.getSeconds(); + s = s < 10 ? ('0' + s) : s; + return `${y}-${MM}-${d} ${h}:${m}:${s}`; +} + +export const formatDate2 = (value) => { + let timezone = 3; //目标时区时间,东3区(东时区正数 西时区负数) + let offset_GMT = new Date(value).getTimezoneOffset(); // 本地时间和格林威治的时间差,单位为分钟 + let nowDate = new Date(value).getTime(); // 本地时间距 1970 年 1 月 1 日午夜(GMT 时间)之间的毫秒数 + let date = new Date(nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000); + + let y = date.getFullYear(); + let MM = date.getMonth() + 1; + MM = MM < 10 ? ('0' + MM) : MM; + let d = date.getDate(); + d = d < 10 ? ('0' + d) : d; + let h = date.getHours(); + h = h < 10 ? ('0' + h) : h; + let m = date.getMinutes(); + m = m < 10 ? ('0' + m) : m; + let s = date.getSeconds(); + s = s < 10 ? ('0' + s) : s; + return `${y}/${MM}/${d} ${h}:${m}:${s}`; +} + +export const formatDateYMD = (value) => { + let timezone = 3; //目标时区时间,东3区(东时区正数 西时区负数) + let offset_GMT = new Date(value).getTimezoneOffset(); // 本地时间和格林威治的时间差,单位为分钟 + let nowDate = new Date(value).getTime(); // 本地时间距 1970 年 1 月 1 日午夜(GMT 时间)之间的毫秒数 + let date = new Date(nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000); + + let y = date.getFullYear(); + let MM = date.getMonth() + 1; + MM = MM < 10 ? ('0' + MM) : MM; + let d = date.getDate(); + d = d < 10 ? ('0' + d) : d; + let h = date.getHours(); + h = h < 10 ? ('0' + h) : h; + let m = date.getMinutes(); + m = m < 10 ? ('0' + m) : m; + let s = date.getSeconds(); + s = s < 10 ? ('0' + s) : s; + return `${y}/${MM}/${d}`; +} + +export const formatDateYYYYMMDD = (value) => { + let date = new Date(value); + // 将时区设置为GMT+3 + let gmtOffset = 3; // GMT+3时区偏移量为3小时 + let localOffset = date.getTimezoneOffset() / 60; // 获取本地时区偏移量(以小时为单位) + let targetOffset = gmtOffset - localOffset; // 计算目标时区偏移量 + date.setHours(date.getHours() + targetOffset); // 根据偏移量调整小时 + + const y = date.getFullYear(); + let MM = date.getMonth() + 1; + MM = MM < 10 ? ('0' + MM) : MM; + let d = date.getDate(); + d = d < 10 ? ('0' + d) : d; + let h = date.getHours(); + h = h < 10 ? ('0' + h) : h; + let m = date.getMinutes(); + m = m < 10 ? ('0' + m) : m; + let s = date.getSeconds(); + s = s < 10 ? ('0' + s) : s; + + return `${y}-${MM}-${d}`; +} + + +export const formatDateYYYYMM = (value) => { + let date = new Date(value); + // 将时区设置为GMT+3 + let gmtOffset = 3; // GMT+3时区偏移量为3小时 + let localOffset = date.getTimezoneOffset() / 60; // 获取本地时区偏移量(以小时为单位) + let targetOffset = gmtOffset - localOffset; // 计算目标时区偏移量 + date.setHours(date.getHours() + targetOffset); // 根据偏移量调整小时 + + let y = date.getFullYear(); + let MM = date.getMonth() + 1; + MM = MM < 10 ? ('0' + MM) : MM; + let d = date.getDate(); + d = d < 10 ? ('0' + d) : d; + let h = date.getHours(); + h = h < 10 ? ('0' + h) : h; + let m = date.getMinutes(); + m = m < 10 ? ('0' + m) : m; + let s = date.getSeconds(); + s = s < 10 ? ('0' + s) : s; + console.log(y, MM, d, h, s); + return `${y}-${MM}`; +} diff --git a/src/views/goldCoinGiftingHistory/GoldCoinGiftingHistory.vue b/src/views/goldCoinGiftingHistory/GoldCoinGiftingHistory.vue new file mode 100644 index 0000000..ae8d229 --- /dev/null +++ b/src/views/goldCoinGiftingHistory/GoldCoinGiftingHistory.vue @@ -0,0 +1,413 @@ + + + + + \ No newline at end of file diff --git a/src/views/guildOperationManagement/agencyDiamondFlow.vue b/src/views/guildOperationManagement/agencyDiamondFlow.vue new file mode 100644 index 0000000..8513f65 --- /dev/null +++ b/src/views/guildOperationManagement/agencyDiamondFlow.vue @@ -0,0 +1,314 @@ + + + + + diff --git a/src/views/guildOperationManagement/agentSendSalary.vue b/src/views/guildOperationManagement/agentSendSalary.vue new file mode 100644 index 0000000..87c30d5 --- /dev/null +++ b/src/views/guildOperationManagement/agentSendSalary.vue @@ -0,0 +1,281 @@ + + + + + diff --git a/src/views/guildOperationManagement/anchorSalaryOperate.vue b/src/views/guildOperationManagement/anchorSalaryOperate.vue new file mode 100644 index 0000000..e8b7201 --- /dev/null +++ b/src/views/guildOperationManagement/anchorSalaryOperate.vue @@ -0,0 +1,570 @@ + + + + + diff --git a/src/views/guildOperationManagement/guildInfo.vue b/src/views/guildOperationManagement/guildInfo.vue new file mode 100644 index 0000000..409f303 --- /dev/null +++ b/src/views/guildOperationManagement/guildInfo.vue @@ -0,0 +1,821 @@ + + + diff --git a/src/views/guildOperationManagement/guildMove.vue b/src/views/guildOperationManagement/guildMove.vue new file mode 100644 index 0000000..fb72371 --- /dev/null +++ b/src/views/guildOperationManagement/guildMove.vue @@ -0,0 +1,181 @@ + + + diff --git a/src/views/guildOperationManagement/officialWithdrawRecord.vue b/src/views/guildOperationManagement/officialWithdrawRecord.vue new file mode 100644 index 0000000..6936b75 --- /dev/null +++ b/src/views/guildOperationManagement/officialWithdrawRecord.vue @@ -0,0 +1,414 @@ + + + + +