From 6e7acd5062824d5aae2ed345898d761a93879de0 Mon Sep 17 00:00:00 2001 From: heimawl <1785969728@qq.com> Date: 星期五, 02 六月 2023 17:16:31 +0800 Subject: [PATCH] 组件库整理,依赖安装、excel导入导入方法整理 --- src/components/index.js | 11 src/components/Screenfull/index.vue | 1 src/components/Editor/index.vue | 1 src/store/modules/settings.js | 2 src/components/UploadExcel/index.vue | 169 +++++++ src/views/import/index.vue | 55 ++ src/components/HeaderSearch/index.vue | 1 src/components/ImageUpload/index.vue | 61 +- src/components/PanThumb/index.vue | 1 src/components/UploadImg/index.vue | 116 +++++ src/assets/styles/variables.scss | 2 src/components/DictTag/index.vue | 4 src/components/SvgIcon/index.vue | 38 + src/components/RightToolbar/index.vue | 40 + src/components/SizeSelect/index.vue | 53 +- src/components/Breadcrumb/index.vue | 55 +- src/components/Pagination/index.vue | 2 src/filters/index.js | 5 src/components/IconSelect/index.vue | 88 ++- src/components/Hamburger/index.vue | 1 src/main.js | 9 src/components/iFrame/index.vue | 1 package.json | 8 src/components/TopNav/index.vue | 63 +- src/components/ThemePicker/index.vue | 1 src/components/FileUpload/index.vue | 57 + src/components/ImagePreview/index.vue | 1 src/constant/employees.js | 429 +++++++++++++++++++ src/components/PageTools/index.vue | 42 + 29 files changed, 1,136 insertions(+), 181 deletions(-) diff --git a/package.json b/package.json index a76db05..0d1291b 100644 --- a/package.json +++ b/package.json @@ -40,9 +40,11 @@ "axios": "0.24.0", "clipboard": "2.0.8", "core-js": "3.25.3", + "cos-js-sdk-v5": "^1.4.18", + "dayjs": "^1.11.7", "echarts": "5.4.0", "element-ui": "2.15.12", - "file-saver": "2.0.5", + "file-saver": "^2.0.5", "fuse.js": "6.4.3", "highlight.js": "9.18.5", "js-beautify": "1.13.0", @@ -59,7 +61,8 @@ "vue-meta": "2.4.0", "vue-router": "3.4.9", "vuedraggable": "2.24.3", - "vuex": "3.6.0" + "vuex": "3.6.0", + "xlsx": "^0.18.5" }, "devDependencies": { "@vue/cli-plugin-babel": "4.4.6", @@ -77,6 +80,7 @@ "sass": "1.32.13", "sass-loader": "10.1.1", "script-ext-html-webpack-plugin": "2.1.5", + "script-loader": "^0.7.2", "svg-sprite-loader": "5.1.1", "vue-template-compiler": "2.6.12" }, diff --git a/src/assets/styles/variables.scss b/src/assets/styles/variables.scss index 12360a4..6e2ed23 100644 --- a/src/assets/styles/variables.scss +++ b/src/assets/styles/variables.scss @@ -3,7 +3,7 @@ $light-blue:#3A71A8; $red:#C03639; $pink: #E65D6E; -$green: #30B08F; +$green: #2ef0bf; $tiffany: #4AB7BD; $yellow:#FEC171; $panGreen: #30B08F; diff --git a/src/components/Breadcrumb/index.vue b/src/components/Breadcrumb/index.vue index 1696f54..8e6be4c 100644 --- a/src/components/Breadcrumb/index.vue +++ b/src/components/Breadcrumb/index.vue @@ -1,8 +1,13 @@ +<!-- 椤堕儴璺緞 --> <template> <el-breadcrumb class="app-breadcrumb" separator="/"> <transition-group name="breadcrumb"> - <el-breadcrumb-item v-for="(item,index) in levelList" :key="item.path"> - <span v-if="item.redirect === 'noRedirect' || index == levelList.length - 1" class="no-redirect">{{ item.meta.title }}</span> + <el-breadcrumb-item v-for="(item, index) in levelList" :key="item.path"> + <span + v-if="item.redirect === 'noRedirect' || index == levelList.length - 1" + class="no-redirect" + >{{ item.meta.title }}</span + > <a v-else @click.prevent="handleLink(item)">{{ item.meta.title }}</a> </el-breadcrumb-item> </transition-group> @@ -13,50 +18,54 @@ export default { data() { return { - levelList: null - } + levelList: null, + }; }, watch: { $route(route) { // if you go to the redirect page, do not update the breadcrumbs - if (route.path.startsWith('/redirect/')) { - return + if (route.path.startsWith("/redirect/")) { + return; } - this.getBreadcrumb() - } + this.getBreadcrumb(); + }, }, created() { - this.getBreadcrumb() + this.getBreadcrumb(); }, methods: { getBreadcrumb() { // only show routes with meta.title - let matched = this.$route.matched.filter(item => item.meta && item.meta.title) - const first = matched[0] + let matched = this.$route.matched.filter( + (item) => item.meta && item.meta.title + ); + const first = matched[0]; if (!this.isDashboard(first)) { - matched = [{ path: '/index', meta: { title: '棣栭〉' }}].concat(matched) + matched = [{ path: "/index", meta: { title: "棣栭〉" } }].concat(matched); } - this.levelList = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false) + this.levelList = matched.filter( + (item) => item.meta && item.meta.title && item.meta.breadcrumb !== false + ); }, isDashboard(route) { - const name = route && route.name + const name = route && route.name; if (!name) { - return false + return false; } - return name.trim() === 'Index' + return name.trim() === "Index"; }, handleLink(item) { - const { redirect, path } = item + const { redirect, path } = item; if (redirect) { - this.$router.push(redirect) - return + this.$router.push(redirect); + return; } - this.$router.push(path) - } - } -} + this.$router.push(path); + }, + }, +}; </script> <style lang="scss" scoped> diff --git a/src/components/DictTag/index.vue b/src/components/DictTag/index.vue index 4c196c4..1c71696 100644 --- a/src/components/DictTag/index.vue +++ b/src/components/DictTag/index.vue @@ -36,7 +36,7 @@ }, computed: { values() { - if (this.value !== null && typeof this.value !== 'undefined') { + if (this.value !== null && typeof this.value !== "undefined") { return Array.isArray(this.value) ? this.value : [String(this.value)]; } else { return []; @@ -49,4 +49,4 @@ .el-tag + .el-tag { margin-left: 10px; } -</style> \ No newline at end of file +</style> diff --git a/src/components/Editor/index.vue b/src/components/Editor/index.vue index 6bb5a18..fccd83d 100644 --- a/src/components/Editor/index.vue +++ b/src/components/Editor/index.vue @@ -1,3 +1,4 @@ +<!-- 涓婁紶鍥剧墖s --> <template> <div> <el-upload diff --git a/src/components/FileUpload/index.vue b/src/components/FileUpload/index.vue index 6c583cf..cfc8070 100644 --- a/src/components/FileUpload/index.vue +++ b/src/components/FileUpload/index.vue @@ -1,3 +1,4 @@ +<!-- 涓婁紶鏂囦欢 --> <template> <div class="upload-file"> <el-upload @@ -19,20 +20,38 @@ <!-- 涓婁紶鎻愮ず --> <div class="el-upload__tip" slot="tip" v-if="showTip"> 璇蜂笂浼� - <template v-if="fileSize"> 澶у皬涓嶈秴杩� <b style="color: #f56c6c">{{ fileSize }}MB</b> </template> - <template v-if="fileType"> 鏍煎紡涓� <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template> + <template v-if="fileSize"> + 澶у皬涓嶈秴杩� <b style="color: #f56c6c">{{ fileSize }}MB</b> + </template> + <template v-if="fileType"> + 鏍煎紡涓� <b style="color: #f56c6c">{{ fileType.join("/") }}</b> + </template> 鐨勬枃浠� </div> </el-upload> <!-- 鏂囦欢鍒楄〃 --> - <transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul"> - <li :key="file.url" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in fileList"> - <el-link :href="`${baseUrl}${file.url}`" :underline="false" target="_blank"> + <transition-group + class="upload-file-list el-upload-list el-upload-list--text" + name="el-fade-in-linear" + tag="ul" + > + <li + :key="file.url" + class="el-upload-list__item ele-upload-list__item-content" + v-for="(file, index) in fileList" + > + <el-link + :href="`${baseUrl}${file.url}`" + :underline="false" + target="_blank" + > <span class="el-icon-document"> {{ getFileName(file.name) }} </span> </el-link> <div class="ele-upload-list__item-content-action"> - <el-link :underline="false" @click="handleDelete(index)" type="danger">鍒犻櫎</el-link> + <el-link :underline="false" @click="handleDelete(index)" type="danger" + >鍒犻櫎</el-link + > </div> </li> </transition-group> @@ -65,8 +84,8 @@ // 鏄惁鏄剧ず鎻愮ず isShowTip: { type: Boolean, - default: true - } + default: true, + }, }, data() { return { @@ -86,9 +105,9 @@ if (val) { let temp = 1; // 棣栧厛灏嗗�艰浆涓烘暟缁� - const list = Array.isArray(val) ? val : this.value.split(','); + const list = Array.isArray(val) ? val : this.value.split(","); // 鐒跺悗灏嗘暟缁勮浆涓哄璞℃暟缁� - this.fileList = list.map(item => { + this.fileList = list.map((item) => { if (typeof item === "string") { item = { name: item, url: item }; } @@ -101,8 +120,8 @@ } }, deep: true, - immediate: true - } + immediate: true, + }, }, computed: { // 鏄惁鏄剧ず鎻愮ず @@ -115,11 +134,13 @@ handleBeforeUpload(file) { // 鏍℃鏂囦欢绫诲瀷 if (this.fileType) { - const fileName = file.name.split('.'); + const fileName = file.name.split("."); const fileExt = fileName[fileName.length - 1]; const isTypeOk = this.fileType.indexOf(fileExt) >= 0; if (!isTypeOk) { - this.$modal.msgError(`鏂囦欢鏍煎紡涓嶆纭�, 璇蜂笂浼�${this.fileType.join("/")}鏍煎紡鏂囦欢!`); + this.$modal.msgError( + `鏂囦欢鏍煎紡涓嶆纭�, 璇蜂笂浼�${this.fileType.join("/")}鏍煎紡鏂囦欢!` + ); return false; } } @@ -142,7 +163,7 @@ // 涓婁紶澶辫触 handleUploadError(err) { this.$modal.msgError("涓婁紶鏂囦欢澶辫触锛岃閲嶈瘯"); - this.$modal.closeLoading() + this.$modal.closeLoading(); }, // 涓婁紶鎴愬姛鍥炶皟 handleUploadSuccess(res, file) { @@ -187,9 +208,9 @@ for (let i in list) { strs += list[i].url + separator; } - return strs != '' ? strs.substr(0, strs.length - 1) : ''; - } - } + return strs != "" ? strs.substr(0, strs.length - 1) : ""; + }, + }, }; </script> diff --git a/src/components/Hamburger/index.vue b/src/components/Hamburger/index.vue index 368b002..11e9435 100644 --- a/src/components/Hamburger/index.vue +++ b/src/components/Hamburger/index.vue @@ -1,3 +1,4 @@ +<!-- svg鍥炬爣灏佽 --> <template> <div style="padding: 0 15px;" @click="toggleClick"> <svg diff --git a/src/components/HeaderSearch/index.vue b/src/components/HeaderSearch/index.vue index c4d76bb..78fe2c0 100644 --- a/src/components/HeaderSearch/index.vue +++ b/src/components/HeaderSearch/index.vue @@ -1,3 +1,4 @@ +<!-- 浣跨敤鍏ㄥ眬svgicon鍥炬爣 --> <template> <div :class="{'show':show}" class="header-search"> <svg-icon class-name="search-icon" icon-class="search" @click.stop="click" /> diff --git a/src/components/IconSelect/index.vue b/src/components/IconSelect/index.vue index b0ec9fa..aa8d5a6 100644 --- a/src/components/IconSelect/index.vue +++ b/src/components/IconSelect/index.vue @@ -1,12 +1,24 @@ <!-- @author zhengjie --> +<!-- 鑷畾涔夊浘鏍囧悕绉板皝瑁� --> <template> <div class="icon-body"> - <el-input v-model="name" style="position: relative;" clearable placeholder="璇疯緭鍏ュ浘鏍囧悕绉�" @clear="filterIcons" @input.native="filterIcons"> + <el-input + v-model="name" + style="position: relative" + clearable + placeholder="璇疯緭鍏ュ浘鏍囧悕绉�" + @clear="filterIcons" + @input.native="filterIcons" + > <i slot="suffix" class="el-icon-search el-input__icon" /> </el-input> <div class="icon-list"> - <div v-for="(item, index) in iconList" :key="index" @click="selectedIcon(item)"> - <svg-icon :icon-class="item" style="height: 30px;width: 16px;" /> + <div + v-for="(item, index) in iconList" + :key="index" + @click="selectedIcon(item)" + > + <svg-icon :icon-class="item" style="height: 30px; width: 16px" /> <span>{{ item }}</span> </div> </div> @@ -14,55 +26,57 @@ </template> <script> -import icons from './requireIcons' +import icons from "./requireIcons"; export default { - name: 'IconSelect', + name: "IconSelect", data() { return { - name: '', - iconList: icons - } + name: "", + iconList: icons, + }; }, methods: { filterIcons() { - this.iconList = icons + this.iconList = icons; if (this.name) { - this.iconList = this.iconList.filter(item => item.includes(this.name)) + this.iconList = this.iconList.filter((item) => + item.includes(this.name) + ); } }, selectedIcon(name) { - this.$emit('selected', name) - document.body.click() + this.$emit("selected", name); + document.body.click(); }, reset() { - this.name = '' - this.iconList = icons - } - } -} + this.name = ""; + this.iconList = icons; + }, + }, +}; </script> <style rel="stylesheet/scss" lang="scss" scoped> - .icon-body { - width: 100%; - padding: 10px; - .icon-list { - height: 200px; - overflow-y: scroll; - div { - height: 30px; - line-height: 30px; - margin-bottom: -5px; - cursor: pointer; - width: 33%; - float: left; - } - span { - display: inline-block; - vertical-align: -0.15em; - fill: currentColor; - overflow: hidden; - } +.icon-body { + width: 100%; + padding: 10px; + .icon-list { + height: 200px; + overflow-y: scroll; + div { + height: 30px; + line-height: 30px; + margin-bottom: -5px; + cursor: pointer; + width: 33%; + float: left; + } + span { + display: inline-block; + vertical-align: -0.15em; + fill: currentColor; + overflow: hidden; } } +} </style> diff --git a/src/components/ImagePreview/index.vue b/src/components/ImagePreview/index.vue index 3c770c7..1423d80 100644 --- a/src/components/ImagePreview/index.vue +++ b/src/components/ImagePreview/index.vue @@ -1,3 +1,4 @@ +<!-- image鍥剧墖瀹瑰櫒灏佽 --> <template> <el-image :src="`${realSrc}`" diff --git a/src/components/ImageUpload/index.vue b/src/components/ImageUpload/index.vue index b57a15e..f70e1fc 100644 --- a/src/components/ImageUpload/index.vue +++ b/src/components/ImageUpload/index.vue @@ -1,3 +1,4 @@ +<!-- 涓婁紶鏂囦欢灏佽 --> <template> <div class="component-upload-image"> <el-upload @@ -15,16 +16,20 @@ :headers="headers" :file-list="fileList" :on-preview="handlePictureCardPreview" - :class="{hide: this.fileList.length >= this.limit}" + :class="{ hide: this.fileList.length >= this.limit }" > <i class="el-icon-plus"></i> </el-upload> - + <!-- 涓婁紶鎻愮ず --> <div class="el-upload__tip" slot="tip" v-if="showTip"> 璇蜂笂浼� - <template v-if="fileSize"> 澶у皬涓嶈秴杩� <b style="color: #f56c6c">{{ fileSize }}MB</b> </template> - <template v-if="fileType"> 鏍煎紡涓� <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template> + <template v-if="fileSize"> + 澶у皬涓嶈秴杩� <b style="color: #f56c6c">{{ fileSize }}MB</b> + </template> + <template v-if="fileType"> + 鏍煎紡涓� <b style="color: #f56c6c">{{ fileType.join("/") }}</b> + </template> 鐨勬枃浠� </div> @@ -55,7 +60,7 @@ }, // 澶у皬闄愬埗(MB) fileSize: { - type: Number, + type: Number, default: 5, }, // 鏂囦欢绫诲瀷, 渚嬪['png', 'jpg', 'jpeg'] @@ -66,8 +71,8 @@ // 鏄惁鏄剧ず鎻愮ず isShowTip: { type: Boolean, - default: true - } + default: true, + }, }, data() { return { @@ -81,7 +86,7 @@ headers: { Authorization: "Bearer " + getToken(), }, - fileList: [] + fileList: [], }; }, watch: { @@ -89,14 +94,14 @@ handler(val) { if (val) { // 棣栧厛灏嗗�艰浆涓烘暟缁� - const list = Array.isArray(val) ? val : this.value.split(','); + const list = Array.isArray(val) ? val : this.value.split(","); // 鐒跺悗灏嗘暟缁勮浆涓哄璞℃暟缁� - this.fileList = list.map(item => { + this.fileList = list.map((item) => { if (typeof item === "string") { if (item.indexOf(this.baseUrl) === -1) { - item = { name: this.baseUrl + item, url: this.baseUrl + item }; + item = { name: this.baseUrl + item, url: this.baseUrl + item }; } else { - item = { name: item, url: item }; + item = { name: item, url: item }; } } return item; @@ -107,8 +112,8 @@ } }, deep: true, - immediate: true - } + immediate: true, + }, }, computed: { // 鏄惁鏄剧ず鎻愮ず @@ -125,7 +130,7 @@ if (file.name.lastIndexOf(".") > -1) { fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1); } - isImg = this.fileType.some(type => { + isImg = this.fileType.some((type) => { if (file.type.indexOf(type) > -1) return true; if (fileExtension && fileExtension.indexOf(type) > -1) return true; return false; @@ -135,7 +140,9 @@ } if (!isImg) { - this.$modal.msgError(`鏂囦欢鏍煎紡涓嶆纭�, 璇蜂笂浼�${this.fileType.join("/")}鍥剧墖鏍煎紡鏂囦欢!`); + this.$modal.msgError( + `鏂囦欢鏍煎紡涓嶆纭�, 璇蜂笂浼�${this.fileType.join("/")}鍥剧墖鏍煎紡鏂囦欢!` + ); return false; } if (this.fileSize) { @@ -167,8 +174,8 @@ }, // 鍒犻櫎鍥剧墖 handleDelete(file) { - const findex = this.fileList.map(f => f.name).indexOf(file.name); - if(findex > -1) { + const findex = this.fileList.map((f) => f.name).indexOf(file.name); + if (findex > -1) { this.fileList.splice(findex, 1); this.$emit("input", this.listToString(this.fileList)); } @@ -202,25 +209,25 @@ strs += list[i].url.replace(this.baseUrl, "") + separator; } } - return strs != '' ? strs.substr(0, strs.length - 1) : ''; - } - } + return strs != "" ? strs.substr(0, strs.length - 1) : ""; + }, + }, }; </script> <style scoped lang="scss"> // .el-upload--picture-card 鎺у埗鍔犲彿閮ㄥ垎 ::v-deep.hide .el-upload--picture-card { - display: none; + display: none; } // 鍘绘帀鍔ㄧ敾鏁堟灉 ::v-deep .el-list-enter-active, ::v-deep .el-list-leave-active { - transition: all 0s; + transition: all 0s; } -::v-deep .el-list-enter, .el-list-leave-active { - opacity: 0; - transform: translateY(0); +::v-deep .el-list-enter, +.el-list-leave-active { + opacity: 0; + transform: translateY(0); } </style> - diff --git a/src/components/PageTools/index.vue b/src/components/PageTools/index.vue new file mode 100644 index 0000000..5861bf4 --- /dev/null +++ b/src/components/PageTools/index.vue @@ -0,0 +1,42 @@ +<!-- tag鏍囩灏佽 --> +<template> + <el-card class="box-card"> + <el-row type="flex"> + <el-col> + <el-tag v-if="isShowLeft"> + <i :class="leftIon"></i> + <slot name="left-tag" /> + </el-tag> + </el-col> + <el-col> + <el-row type="flex" justify="end"> + <slot name="right" /> + </el-row> + </el-col> + </el-row> + </el-card> +</template> + +<script> +export default { + name: "PageTools", + data() { + return {}; + }, + props: { + leftIon: { + type: String, + default: "el-icon-info", + }, + isShowLeft: { + type: Boolean, + default: true, + }, + }, + created() {}, + + methods: {}, +}; +</script> + +<style lang="less" scoped></style> diff --git a/src/components/Pagination/index.vue b/src/components/Pagination/index.vue index 56f5a6b..f16425c 100644 --- a/src/components/Pagination/index.vue +++ b/src/components/Pagination/index.vue @@ -1,3 +1,5 @@ + +<!-- 搴曢儴鍒嗛〉缁勪欢灏佽 --> <template> <div :class="{'hidden':hidden}" class="pagination-container"> <el-pagination diff --git a/src/components/PanThumb/index.vue b/src/components/PanThumb/index.vue index 1bcf417..ee796e7 100644 --- a/src/components/PanThumb/index.vue +++ b/src/components/PanThumb/index.vue @@ -1,3 +1,4 @@ +<!-- 鍥剧墖灞曠ず椤甸潰 --> <template> <div :style="{zIndex:zIndex,height:height,width:width}" class="pan-item"> <div class="pan-info"> diff --git a/src/components/RightToolbar/index.vue b/src/components/RightToolbar/index.vue index 527e07c..d682090 100644 --- a/src/components/RightToolbar/index.vue +++ b/src/components/RightToolbar/index.vue @@ -1,14 +1,42 @@ +<!-- 榧犳爣瑙﹀彂寮瑰嚭鎴� --> <template> <div class="top-right-btn" :style="style"> <el-row> - <el-tooltip class="item" effect="dark" :content="showSearch ? '闅愯棌鎼滅储' : '鏄剧ず鎼滅储'" placement="top" v-if="search"> - <el-button size="mini" circle icon="el-icon-search" @click="toggleSearch()" /> + <el-tooltip + class="item" + effect="dark" + :content="showSearch ? '闅愯棌鎼滅储' : '鏄剧ず鎼滅储'" + placement="top" + v-if="search" + > + <el-button + size="mini" + circle + icon="el-icon-search" + @click="toggleSearch()" + /> </el-tooltip> <el-tooltip class="item" effect="dark" content="鍒锋柊" placement="top"> - <el-button size="mini" circle icon="el-icon-refresh" @click="refresh()" /> + <el-button + size="mini" + circle + icon="el-icon-refresh" + @click="refresh()" + /> </el-tooltip> - <el-tooltip class="item" effect="dark" content="鏄鹃殣鍒�" placement="top" v-if="columns"> - <el-button size="mini" circle icon="el-icon-menu" @click="showColumn()" /> + <el-tooltip + class="item" + effect="dark" + content="鏄鹃殣鍒�" + placement="top" + v-if="columns" + > + <el-button + size="mini" + circle + icon="el-icon-menu" + @click="showColumn()" + /> </el-tooltip> </el-row> <el-dialog :title="title" :visible.sync="open" append-to-body> @@ -58,7 +86,7 @@ ret.marginRight = `${this.gutter / 2}px`; } return ret; - } + }, }, created() { // 鏄鹃殣鍒楀垵濮嬮粯璁ら殣钘忓垪 diff --git a/src/components/Screenfull/index.vue b/src/components/Screenfull/index.vue index d4e539c..1a81a5c 100644 --- a/src/components/Screenfull/index.vue +++ b/src/components/Screenfull/index.vue @@ -1,3 +1,4 @@ +<!-- 鍥炬爣鐐瑰嚮鏀惧ぇ --> <template> <div> <svg-icon :icon-class="isFullscreen?'exit-fullscreen':'fullscreen'" @click="click" /> diff --git a/src/components/SizeSelect/index.vue b/src/components/SizeSelect/index.vue index 069b5de..3cd013a 100644 --- a/src/components/SizeSelect/index.vue +++ b/src/components/SizeSelect/index.vue @@ -1,10 +1,16 @@ +<!-- 涓嬫媺鑿滃崟灏佽 --> <template> <el-dropdown trigger="click" @command="handleSetSize"> <div> <svg-icon class-name="size-icon" icon-class="size" /> </div> <el-dropdown-menu slot="dropdown"> - <el-dropdown-item v-for="item of sizeOptions" :key="item.value" :disabled="size===item.value" :command="item.value"> + <el-dropdown-item + v-for="item of sizeOptions" + :key="item.value" + :disabled="size === item.value" + :command="item.value" + > {{ item.label }} </el-dropdown-item> </el-dropdown-menu> @@ -16,41 +22,40 @@ data() { return { sizeOptions: [ - { label: 'Default', value: 'default' }, - { label: 'Medium', value: 'medium' }, - { label: 'Small', value: 'small' }, - { label: 'Mini', value: 'mini' } - ] - } + { label: "Default", value: "default" }, + { label: "Medium", value: "medium" }, + { label: "Small", value: "small" }, + { label: "Mini", value: "mini" }, + ], + }; }, computed: { size() { - return this.$store.getters.size - } + return this.$store.getters.size; + }, }, methods: { handleSetSize(size) { - this.$ELEMENT.size = size - this.$store.dispatch('app/setSize', size) - this.refreshView() + this.$ELEMENT.size = size; + this.$store.dispatch("app/setSize", size); + this.refreshView(); this.$message({ - message: 'Switch Size Success', - type: 'success' - }) + message: "Switch Size Success", + type: "success", + }); }, refreshView() { // In order to make the cached page re-rendered - this.$store.dispatch('tagsView/delAllCachedViews', this.$route) + this.$store.dispatch("tagsView/delAllCachedViews", this.$route); - const { fullPath } = this.$route + const { fullPath } = this.$route; this.$nextTick(() => { this.$router.replace({ - path: '/redirect' + fullPath - }) - }) - } - } - -} + path: "/redirect" + fullPath, + }); + }); + }, + }, +}; </script> diff --git a/src/components/SvgIcon/index.vue b/src/components/SvgIcon/index.vue index e4bf5ad..97456a4 100644 --- a/src/components/SvgIcon/index.vue +++ b/src/components/SvgIcon/index.vue @@ -1,47 +1,53 @@ +<!-- svg灏佽 --> <template> - <div v-if="isExternal" :style="styleExternalIcon" class="svg-external-icon svg-icon" v-on="$listeners" /> + <div + v-if="isExternal" + :style="styleExternalIcon" + class="svg-external-icon svg-icon" + v-on="$listeners" + /> <svg v-else :class="svgClass" aria-hidden="true" v-on="$listeners"> <use :xlink:href="iconName" /> </svg> </template> <script> -import { isExternal } from '@/utils/validate' +import { isExternal } from "@/utils/validate"; export default { - name: 'SvgIcon', + name: "SvgIcon", props: { iconClass: { type: String, - required: true + required: true, }, className: { type: String, - default: '' - } + default: "", + }, }, computed: { isExternal() { - return isExternal(this.iconClass) + return isExternal(this.iconClass); }, iconName() { - return `#icon-${this.iconClass}` + return `#icon-${this.iconClass}`; }, svgClass() { if (this.className) { - return 'svg-icon ' + this.className + return "svg-icon " + this.className; } else { - return 'svg-icon' + return "svg-icon"; } }, styleExternalIcon() { return { mask: `url(${this.iconClass}) no-repeat 50% 50%`, - '-webkit-mask': `url(${this.iconClass}) no-repeat 50% 50%` - } - } - } -} + "-webkit-mask": `url(${this.iconClass}) no-repeat 50% 50%`, + }; + }, + }, +}; </script> <style scoped> @@ -55,7 +61,7 @@ .svg-external-icon { background-color: currentColor; - mask-size: cover!important; + mask-size: cover !important; display: inline-block; } </style> diff --git a/src/components/ThemePicker/index.vue b/src/components/ThemePicker/index.vue index 1714e1f..aac3187 100644 --- a/src/components/ThemePicker/index.vue +++ b/src/components/ThemePicker/index.vue @@ -1,3 +1,4 @@ +<!-- 棰滆壊閫夋嫨鍣� --> <template> <el-color-picker v-model="theme" diff --git a/src/components/TopNav/index.vue b/src/components/TopNav/index.vue index 5f0edbe..aec393d 100644 --- a/src/components/TopNav/index.vue +++ b/src/components/TopNav/index.vue @@ -1,3 +1,4 @@ +<!-- 椤堕儴瀵艰埅灏佽 --> <template> <el-menu :default-active="activeMenu" @@ -5,14 +6,22 @@ @select="handleSelect" > <template v-for="(item, index) in topMenus"> - <el-menu-item :style="{'--theme': theme}" :index="item.path" :key="index" v-if="index < visibleNumber" + <el-menu-item + :style="{ '--theme': theme }" + :index="item.path" + :key="index" + v-if="index < visibleNumber" ><svg-icon :icon-class="item.meta.icon" /> {{ item.meta.title }}</el-menu-item > </template> <!-- 椤堕儴鑿滃崟瓒呭嚭鏁伴噺鎶樺彔 --> - <el-submenu :style="{'--theme': theme}" index="more" v-if="topMenus.length > visibleNumber"> + <el-submenu + :style="{ '--theme': theme }" + index="more" + v-if="topMenus.length > visibleNumber" + > <template slot="title">鏇村鑿滃崟</template> <template v-for="(item, index) in topMenus"> <el-menu-item @@ -31,7 +40,7 @@ import { constantRoutes } from "@/router"; // 闅愯棌渚ц竟鏍忚矾鐢� -const hideList = ['/index', '/user/profile']; +const hideList = ["/index", "/user/profile"]; export default { data() { @@ -39,7 +48,7 @@ // 椤堕儴鏍忓垵濮嬫暟 visibleNumber: 5, // 褰撳墠婵�娲昏彍鍗曠殑 index - currentIndex: undefined + currentIndex: undefined, }; }, computed: { @@ -53,9 +62,9 @@ if (menu.hidden !== true) { // 鍏煎椤堕儴鏍忎竴绾ц彍鍗曞唴閮ㄨ烦杞� if (menu.path === "/") { - topMenus.push(menu.children[0]); + topMenus.push(menu.children[0]); } else { - topMenus.push(menu); + topMenus.push(menu); } } }); @@ -71,11 +80,12 @@ this.routers.map((router) => { for (var item in router.children) { if (router.children[item].parentPath === undefined) { - if(router.path === "/") { + if (router.path === "/") { router.children[item].path = "/" + router.children[item].path; } else { - if(!this.ishttp(router.children[item].path)) { - router.children[item].path = router.path + "/" + router.children[item].path; + if (!this.ishttp(router.children[item].path)) { + router.children[item].path = + router.path + "/" + router.children[item].path; } } router.children[item].parentPath = router.path; @@ -89,25 +99,29 @@ activeMenu() { const path = this.$route.path; let activePath = path; - if (path !== undefined && path.lastIndexOf("/") > 0 && hideList.indexOf(path) === -1) { + if ( + path !== undefined && + path.lastIndexOf("/") > 0 && + hideList.indexOf(path) === -1 + ) { const tmpPath = path.substring(1, path.length); activePath = "/" + tmpPath.substring(0, tmpPath.indexOf("/")); if (!this.$route.meta.link) { - this.$store.dispatch('app/toggleSideBarHide', false); + this.$store.dispatch("app/toggleSideBarHide", false); } - } else if(!this.$route.children) { + } else if (!this.$route.children) { activePath = path; - this.$store.dispatch('app/toggleSideBarHide', true); + this.$store.dispatch("app/toggleSideBarHide", true); } this.activeRoutes(activePath); return activePath; }, }, beforeMount() { - window.addEventListener('resize', this.setVisibleNumber) + window.addEventListener("resize", this.setVisibleNumber); }, beforeDestroy() { - window.removeEventListener('resize', this.setVisibleNumber) + window.removeEventListener("resize", this.setVisibleNumber); }, mounted() { this.setVisibleNumber(); @@ -121,18 +135,18 @@ // 鑿滃崟閫夋嫨浜嬩欢 handleSelect(key, keyPath) { this.currentIndex = key; - const route = this.routers.find(item => item.path === key); + const route = this.routers.find((item) => item.path === key); if (this.ishttp(key)) { // http(s):// 璺緞鏂扮獥鍙f墦寮� window.open(key, "_blank"); } else if (!route || !route.children) { // 娌℃湁瀛愯矾鐢辫矾寰勫唴閮ㄦ墦寮� this.$router.push({ path: key }); - this.$store.dispatch('app/toggleSideBarHide', true); + this.$store.dispatch("app/toggleSideBarHide", true); } else { // 鏄剧ず宸︿晶鑱斿姩鑿滃崟 this.activeRoutes(key); - this.$store.dispatch('app/toggleSideBarHide', false); + this.$store.dispatch("app/toggleSideBarHide", false); } }, // 褰撳墠婵�娲荤殑璺敱 @@ -145,15 +159,15 @@ } }); } - if(routes.length > 0) { + if (routes.length > 0) { this.$store.commit("SET_SIDEBAR_ROUTERS", routes); } else { - this.$store.dispatch('app/toggleSideBarHide', true); + this.$store.dispatch("app/toggleSideBarHide", true); } }, ishttp(url) { - return url.indexOf('http://') !== -1 || url.indexOf('https://') !== -1 - } + return url.indexOf("http://") !== -1 || url.indexOf("https://") !== -1; + }, }, }; </script> @@ -168,8 +182,9 @@ margin: 0 10px !important; } -.topmenu-container.el-menu--horizontal > .el-menu-item.is-active, .el-menu--horizontal > .el-submenu.is-active .el-submenu__title { - border-bottom: 2px solid #{'var(--theme)'} !important; +.topmenu-container.el-menu--horizontal > .el-menu-item.is-active, +.el-menu--horizontal > .el-submenu.is-active .el-submenu__title { + border-bottom: 2px solid #{"var(--theme)"} !important; color: #303133; } diff --git a/src/components/UploadExcel/index.vue b/src/components/UploadExcel/index.vue new file mode 100644 index 0000000..bf6d7a9 --- /dev/null +++ b/src/components/UploadExcel/index.vue @@ -0,0 +1,169 @@ +<!-- excel鏂囦欢涓婁紶 --> +<template> + <div class="upload-excel"> + <div class="btn-upload"> + <el-button + :loading="loading" + size="mini" + type="primary" + @click="handleUpload" + > + 鐐瑰嚮涓婁紶 + </el-button> + </div> + + <input + ref="excel-upload-input" + class="excel-upload-input" + type="file" + accept=".xlsx, .xls" + @change="handleClick" + /> + <div + class="drop" + @drop="handleDrop" + @dragover="handleDragover" + @dragenter="handleDragover" + > + <i class="el-icon-upload" /> + <span>灏嗘枃浠舵嫋鍒版澶�</span> + </div> + </div> +</template> + +<script> +import XLSX from "xlsx"; +export default { + name: "UploadExcel", + props: { + beforeUpload: Function, // eslint-disable-line + onSuccess: Function, // eslint-disable-line + }, + data() { + return { + loading: false, + excelData: { + header: null, + results: null, + }, + }; + }, + methods: { + generateData({ header, results }) { + this.excelData.header = header; + this.excelData.results = results; + this.onSuccess && this.onSuccess(this.excelData); + }, + handleDrop(e) { + e.stopPropagation(); + e.preventDefault(); + if (this.loading) return; + const files = e.dataTransfer.files; + if (files.length !== 1) { + this.$message.error("Only support uploading one file!"); + return; + } + const rawFile = files[0]; // only use files[0] + if (!this.isExcel(rawFile)) { + this.$message.error( + "Only supports upload .xlsx, .xls, .csv suffix files" + ); + return false; + } + this.upload(rawFile); + e.stopPropagation(); + e.preventDefault(); + }, + handleDragover(e) { + e.stopPropagation(); + e.preventDefault(); + e.dataTransfer.dropEffect = "copy"; + }, + handleUpload() { + this.$refs["excel-upload-input"].click(); + }, + handleClick(e) { + const files = e.target.files; + const rawFile = files[0]; // only use files[0] + if (!rawFile) return; + this.upload(rawFile); + }, + upload(rawFile) { + this.$refs["excel-upload-input"].value = null; // fix can't select the same excel + if (!this.beforeUpload) { + this.readerData(rawFile); + return; + } + const before = this.beforeUpload(rawFile); + if (before) { + this.readerData(rawFile); + } + }, + readerData(rawFile) { + this.loading = true; + return new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.onload = (e) => { + const data = e.target.result; + const workbook = XLSX.read(data, { type: "array" }); + const firstSheetName = workbook.SheetNames[0]; + const worksheet = workbook.Sheets[firstSheetName]; + const header = this.getHeaderRow(worksheet); + const results = XLSX.utils.sheet_to_json(worksheet); + this.generateData({ header, results }); + this.loading = false; + resolve(); + }; + reader.readAsArrayBuffer(rawFile); + }); + }, + getHeaderRow(sheet) { + const headers = []; + const range = XLSX.utils.decode_range(sheet["!ref"]); + let C; + const R = range.s.r; + /* start in the first row */ + for (C = range.s.c; C <= range.e.c; ++C) { + /* walk every column in the range */ + const cell = sheet[XLSX.utils.encode_cell({ c: C, r: R })]; + /* find the cell in the first row */ + let hdr = "UNKNOWN " + C; // <-- replace with your desired default + if (cell && cell.t) hdr = XLSX.utils.format_cell(cell); + headers.push(hdr); + } + return headers; + }, + isExcel(file) { + return /\.(xlsx|xls|csv)$/.test(file.name); + }, + }, +}; +</script> + +<style scoped lang="scss"> +.upload-excel { + display: flex; + justify-content: center; + margin-top: 100px; + .excel-upload-input { + display: none; + z-index: -9999; + } + .btn-upload, + .drop { + border: 1px dashed #bbb; + width: 350px; + height: 160px; + text-align: center; + line-height: 160px; + } + .drop { + line-height: 80px; + color: #bbb; + i { + font-size: 60px; + display: block; + } + } +} +</style> diff --git a/src/components/UploadImg/index.vue b/src/components/UploadImg/index.vue new file mode 100644 index 0000000..c294ed7 --- /dev/null +++ b/src/components/UploadImg/index.vue @@ -0,0 +1,116 @@ +<!-- 鍥剧墖涓婁紶灏佽 --> +<template> + <div> + <el-upload + :file-list="filelist" + v-loading="loading" + element-loading-text="鎷煎懡鍔犺浇涓�" + element-loading-spinner="el-icon-loading" + element-loading-background="rgba(0, 0, 0, 0.8)" + action="https://jsonplaceholder.typicode.com/posts/" + :http-request="uoloadimg" + :on-change="onChange" + :on-remove="onRemove" + :on-preview="onPreview" + :before-upload="onBeforeUpload" + list-type="picture-card" + :limit="1" + :class="filelist.length === 1 ? 'father' : ''" + class="custom-upload" + > + <i class="el-icon-plus"></i> + </el-upload> + <el-dialog :visible.sync="fileonPreview"> + <img :src="fileimg" alt="" /> + </el-dialog> + </div> +</template> + +<script> +import COS from "cos-js-sdk-v5"; +var cos = new COS({ + SecretId: "AKIDxlNmyua2FDwSjmeHGVVHxNYVghSyFhus", + SecretKey: "nPp8D5mKgomaBawHPI1avzuhJhqombCZ", +}); +console.log(cos); +export default { + name: "UploadImg", + data() { + return { + filelist: [], + fileimg: "", + fileonPreview: false, + loading: false, + }; + }, + + created() {}, + + methods: { + // 鍙戦�佸浘鐗囦笂浼� + uoloadimg({ file }) { + this.loading = true; + cos.putObject( + { + Bucket: "hmhr-31-1313341522" /* 蹇呴』 */, + Region: "ap-shanghai" /* 瀛樺偍妗舵墍鍦ㄥ湴鍩燂紝蹇呴』瀛楁 */, + Key: file.name /* 蹇呴』 */, + StorageClass: "STANDARD", + Body: file, // 涓婁紶鏂囦欢瀵硅薄 + onProgress: function (progressData) { + console.log(JSON.stringify(progressData)); + }, + }, + (err, data) => { + this.loading = false; + if (err || data.statusCode != 200) { + return this.$$message.error(""); + } + this.$emit("onSuccess", { + url: "https://" + data.Location, + }); + } + ); + }, + // 瀛樺偍鍥剧墖鍒楄〃 + onChange(file, filelist) { + this.filelist = filelist; + }, + //鍒犻櫎 + onRemove(file, filelist) { + this.filelist = filelist; + }, + // 棰勮 + onPreview(file) { + console.log(file); + this.fileonPreview = true; + this.fileimg = file.url; + }, + // 涓婁紶鍓嶅垽鏂� + onBeforeUpload(file) { + console.log(file); + const types = ["image/jpeg", "image/png", "image/gif"]; + if (!types.includes(file.type)) { + this.$message.error("璇烽�夋嫨" + types.join(", ") + "鏍煎紡鍥剧墖"); + return false; + } + const maxSize = 1024 * 1024 * 2; + if (file.size > maxSize) { + this.$message.error("閫夋嫨鍥剧墖涓嶈秴杩�2mb"); + return false; + } + }, + }, +}; +</script> + +<style lang="scss" scoped> +.father .el-upload--picture-card { + display: none; +} +.custom-upload { + width: 148px; + height: 148px; + overflow: hidden; +} +</style> diff --git a/src/components/iFrame/index.vue b/src/components/iFrame/index.vue index 426857f..24a8ed5 100644 --- a/src/components/iFrame/index.vue +++ b/src/components/iFrame/index.vue @@ -1,3 +1,4 @@ +<!-- 椤甸潰鍐呭祵鍏ュ皝瑁� --> <template> <div v-loading="loading" :style="'height:' + height"> <iframe diff --git a/src/components/index.js b/src/components/index.js new file mode 100644 index 0000000..07d5b01 --- /dev/null +++ b/src/components/index.js @@ -0,0 +1,11 @@ +import PageTools from "@/components/PageTools" +import UploadExcel from "@/components/UploadExcel" +import UploadImg from "@/components/UploadImg" +const component=[PageTools,UploadExcel,UploadImg] +export default{ + install(Vue){ + component.forEach((component)=>{ + Vue.component(component.name,component) + }) + } +} \ No newline at end of file diff --git a/src/constant/employees.js b/src/constant/employees.js new file mode 100644 index 0000000..88bdd9d --- /dev/null +++ b/src/constant/employees.js @@ -0,0 +1,429 @@ +// 鍛樺伐 +export default { + // 鑱樼敤褰㈠紡 + hireType: [ + { + id: 1, + value: '姝e紡' + }, + { + id: 2, + value: '闈炴寮�' + } + ], + // 绠$悊褰㈠紡 + subjection: [ + { + id: '1', + value: '鎬婚儴' + }, + { + id: '2', + value: '鍒嗗煄甯�' + } + ], + // 鍦ㄨ亴鐘舵�� + workingState: [ + { + id: '1', + value: '鍦ㄨ亴' + }, + { + id: '2', + value: '绂昏亴' + } + ], + // 绂昏亴绫诲瀷 + leaveType: [ + { + id: '1', + value: '涓诲姩绂昏亴' + }, + { + id: '2', + value: '琚姩绂昏亴' + }, + { + id: '3', + value: '閫�浼�' + } + ], + // 鍑忓憳鏈� + attritionMonth: [ + { + id: '1', + value: '绂昏亴鏃ユ湰鏈�' + }, + { + id: '2', + value: '绂昏亴鏃ユ鏈�' + } + ], + // 鑱樼敤褰㈠紡 + informaltype: [ + { + id: '2', + value: '瀹炰範' + }, + { + id: '3', + value: '鍔冲姟' + }, + { + id: '4', + value: '椤鹃棶' + }, + { + id: '5', + value: '杩旇仒' + }, + { + id: '6', + value: '澶栧寘' + } + ], + // 鏈�楂樺鍘� + highestDegree: [ + { + id: '1', + value: '鍒濅腑' + }, + { + id: '2', + value: '楂樹腑' + }, + { + id: '3', + value: '涓笓' + }, + { + id: '4', + value: '澶т笓' + }, + { + id: '5', + value: '鏈' + }, + { + id: '6', + value: '纭曞+' + }, + { + id: '7', + value: '鍗氬+' + }, + { + id: '8', + value: '鍏朵粬' + } + ], + // 鍥藉/鍦板尯 + isOverseas: [ + { + id: '1', + value: '涓浗澶ч檰' + }, + { + id: '2', + value: '娓境鍙板浗澶�' + } + ], + // 鎬у埆 + gender: [ + { + id: '1', + value: '鐢�' + }, + { + id: '2', + value: '濂�' + } + ], + // 濠氬Щ鐘跺喌 + maritaStatus: [ + { + id: '1', + value: '鏈' + }, + { + id: '2', + value: '宸插' + }, + { + id: '3', + value: '绂诲紓' + } + ], + // 鐢熻倴 + animalSymbol: [ + { + id: '1', + value: '榧�' + }, + { + id: '2', + value: '鐗�' + }, + { + id: '3', + value: '铏�' + }, + { + id: '4', + value: '鍏�' + }, + { + id: '5', + value: '榫�' + }, + { + id: '6', + value: '铔�' + }, + { + id: '7', + value: '椹�' + }, + { + id: '8', + value: '缇�' + }, + { + id: '9', + value: '鐚�' + }, + { + id: '10', + value: '楦�' + }, + { + id: '11', + value: '鐙�' + }, + { + id: '12', + value: '鐚�' + } + ], + // 鏄熷骇 + constellation: [ + { + code: 1, + value: '姘寸摱搴�' + }, + { + code: 2, + value: '鍙岄奔搴�' + }, + { + code: 3, + value: '鐧界緤搴�' + }, + { + code: 4, + value: '閲戠墰搴�' + }, + { + code: 5, + value: '鍙屽瓙搴�' + }, + { + code: 6, + value: '宸ㄨ煿搴�' + }, + { + code: 7, + value: '鐙瓙搴�' + }, + { + code: 8, + value: '澶勫コ搴�' + }, + { + code: 9, + value: '澶╃Г搴�' + }, + { + code: 10, + value: '澶╄潕搴�' + }, + { + code: 11, + value: '灏勬墜搴�' + }, + { + code: 12, + value: '鎽╃警搴�' + } + ], + // 琛�鍨� + bloodType: [ + { + id: '1', + value: 'A鍨�' + }, + { + id: '2', + value: 'B鍨�' + }, + { + id: '3', + value: 'O鍨�' + }, + { + id: '4', + value: 'AB鍨�' + } + ], + // 瀛﹀巻 + educationType: [ + { + id: '1', + value: '缁熸嫑' + }, + { + id: '2', + value: '鑷��' + }, + { + id: '3', + value: '鎴愯��' + } + ], + // 杞 + positiveType: [ + { + id: '1', + value: '宸茶浆姝�' + }, + { + id: '2', + value: '鏈浆姝�' + } + ], + // 鍚堝悓鏈熼檺 + contractPeriod: [ + { + id: '1', + value: '6鏈�' + }, + { + id: '2', + value: '12鏈�' + }, + { + id: '3', + value: '24鏈�' + }, + { + id: '4', + value: '36鏈�' + }, + { + id: '5', + value: '鍏朵粬' + } + ], + // 绛剧害娆℃暟 + renewalCount: [ + { + id: 1, + value: '0娆�' + }, + { + id: 2, + value: '1娆�' + }, + { + id: 3, + value: '2娆�' + }, + { + id: 4, + value: '3娆�' + }, + { + id: 5, + value: '4娆℃垨浠ヤ笂' + } + ], + // 绠�鍘嗘潵婧� + resumeSource: [ + { + id: '1', + value: '鏅鸿仈鎷涜仒' + }, + { + id: '2', + value: '鎷夊嬀缃�' + }, + { + id: '3', + value: '鍓嶇▼鏃犲咖' + }, + { + id: '4', + value: '鐚庤仒缃�' + }, + { + id: '5', + value: '鏍″洯瀹h' + }, + { + id: '6', + value: '鐚庡ご' + }, + { + id: '7', + value: '鍐呴儴鎺ㄨ崘' + } + ], + // 绀炬嫑/鏍℃嫑 + hireSourceType: [ + { + id: '1', + value: '绀炬嫑' + }, + { + id: '2', + value: '鏍℃嫑' + } + ], + // 鏂板姞 + // 閮ㄩ棬 + departments: [ + { + id: '1', + value: '鎬昏鍔�' + }, + { + id: '2', + value: '鐮旂┒闄�' + } + ], + // 鑱屼綅鐘舵�� + stausInfos: [ + { + id: '1', + value: '鍦ㄨ亴' + }, + { + id: '2', + value: '鍏ヨ亴' + }, + { + id: '3', + value: '绂昏亴' + } + ], + // 涓婁紶鏁版嵁琛ㄥご + importMapKeyPath: { + 鍏ヨ亴鏃ユ湡: 'timeOfEntry', + 濮撳悕: "username", + 宸ュ彿: "workNumber", + 鎵嬫満鍙�: "mobile", + 杞鏃ユ湡: "correctionTime" +} +} + + diff --git a/src/filters/index.js b/src/filters/index.js new file mode 100644 index 0000000..c16223a --- /dev/null +++ b/src/filters/index.js @@ -0,0 +1,5 @@ +import dayjs from 'dayjs'; +// 杩囨护鍣� +export const formatTime=(val)=>{ + return dayjs(val).format('YYYY-MM-DD') + } \ No newline at end of file diff --git a/src/main.js b/src/main.js index 13c6cf2..861cfc1 100644 --- a/src/main.js +++ b/src/main.js @@ -37,6 +37,14 @@ import VueMeta from 'vue-meta' // 瀛楀吀鏁版嵁缁勪欢 import DictData from '@/components/DictData' +// 缁勪欢灏佽闆嗘垚 +import components from './components' +// 娉ㄥ唽杩囨护鍣� +import * as filters from './filters' +for(let key in filters){ +Vue.filter(key, filters[key]) +} + // 鍏ㄥ眬鏂规硶鎸傝浇 Vue.prototype.getDicts = getDicts @@ -62,6 +70,7 @@ Vue.use(plugins) Vue.use(VueMeta) DictData.install() +Vue.use(components) /** * If you don't want to use mock-server diff --git a/src/store/modules/settings.js b/src/store/modules/settings.js index 2455a1e..16b58d4 100644 --- a/src/store/modules/settings.js +++ b/src/store/modules/settings.js @@ -5,7 +5,7 @@ const storageSetting = JSON.parse(localStorage.getItem('layout-setting')) || '' const state = { title: '', - theme: storageSetting.theme || '#409EFF', + theme: storageSetting.theme || '#2ef0bf', sideTheme: storageSetting.sideTheme || sideTheme, showSettings: showSettings, topNav: storageSetting.topNav === undefined ? topNav : storageSetting.topNav, diff --git a/src/views/import/index.vue b/src/views/import/index.vue new file mode 100644 index 0000000..2ff68b3 --- /dev/null +++ b/src/views/import/index.vue @@ -0,0 +1,55 @@ +<template> + <div> + <UploadExcel :deforeUpload="excelSuccess" :onSuccess="onSuccess" /> + </div> +</template> + +<script> +//绛夊緟api鎺ュ彛 +// import { importEmployee } from "@/api/index"; +import employees from "@/constant/employees"; +import formatTime from "@/filters/index"; +const { importMapKeyPath } = employees; +export default { + data() { + return {}; + }, + + created() {}, + + methods: { + // 涓婁紶鍓嶈Е鍙� + excelSuccess({ name }) { + if (!name.endsWith(".xlsx")) { + return this.$message("璇烽�夋嫨xlsx鏂囦欢"); + } + return true; + }, + // 瑙f瀽鎴愬姛鍚庤Е鍙� + async onSuccess({ results, header }) { + const neWArr = results.map((item) => { + const obj = {}; + for (let key in importMapKeyPath) { + if (key === "鍏ヨ亴鏃堕棿" || key === "杞鏃堕棿") { + // excel鏃堕棿鎴� + const timestamp = item[key]; + // 杞牸寮忥紝骞跺姣旀晥楠屽樊鏃堕棿 + const date = new Date((timestamp - 1) * 24 * 3600000); + date.setFullYear(data.setFullYear() - 70); + obj[importMapKeyPath[key]] = formatTime(date); + } else { + obj[importMapKeyPath[key]] = item[key]; + } + } + return obj; + }); + // await importEmployee(neWArr); + this.$message.success("瀵煎叆鎴愬姛"); + this.$router.go(-1); + console.log(neWArr); + }, + }, +}; +</script> + +<style lang="less" scoped></style> -- Gitblit v1.9.3