diff --git a/.gitignore b/.gitignore index 11f5d71..f3ccf24 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ pnpm-debug.log* *.njsproj *.sln *.sw? +/.vs diff --git a/package.json b/package.json index b5f998f..2953b09 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,12 @@ }, "dependencies": { "core-js": "^3.6.5", + "element-ui": "^2.13.2", + "moment": "^2.27.0", "vue": "^2.6.11", "vue-router": "^3.2.0", - "vuex": "^3.4.0" + "vuex": "^3.4.0", + "xlsx": "^0.16.5" }, "devDependencies": { "@vue/cli-plugin-babel": "~4.4.0", diff --git a/src/App.vue b/src/App.vue index 6c26aa6..4f662bb 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,9 +1,9 @@ @@ -29,4 +29,8 @@ #nav a.router-link-exact-active { color: #42b983; } +body,html{ + margin:0; + padding:0; +} diff --git a/src/components/HelloWorld.vue b/src/components/HelloWorld.vue deleted file mode 100644 index b9f3c7d..0000000 --- a/src/components/HelloWorld.vue +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - diff --git a/src/components/Layout.vue b/src/components/Layout.vue new file mode 100644 index 0000000..7c7b8d5 --- /dev/null +++ b/src/components/Layout.vue @@ -0,0 +1,113 @@ + + + + + + + \ No newline at end of file diff --git a/src/main.js b/src/main.js index f253456..07987db 100644 --- a/src/main.js +++ b/src/main.js @@ -1,7 +1,12 @@ -import Vue from 'vue' -import App from './App.vue' -import router from './router' -import store from './store' +import Vue from 'vue'; +import App from './App.vue'; +import router from './router'; +import store from './store'; + +import ElementUI from "element-ui"; +import "element-ui/lib/theme-chalk/index.css"; + +Vue.use(ElementUI); Vue.config.productionTip = false diff --git a/src/router/index.js b/src/router/index.js index 711f9d9..721cc43 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,29 +1,48 @@ -import Vue from 'vue' -import VueRouter from 'vue-router' -import Home from '../views/Home.vue' +import Vue from 'vue'; +import VueRouter from 'vue-router'; + +import Layout from "@/components/Layout.vue"; Vue.use(VueRouter) - const routes = [ - { - path: '/', - name: 'Home', - component: Home - }, - { - path: '/about', - name: 'About', - // route level code-splitting - // this generates a separate chunk (about.[hash].js) for this route - // which is lazy-loaded when the route is visited. - component: () => import(/* webpackChunkName: "about" */ '../views/About.vue') - } +const routes = [ + { + path: '/', + component: Layout, + redirect: '/userauto', + meta: { + title: "生成学生信息", + icon:"el-icon-s-open" + }, + children: [ + { + path: 'userauto', + name: 'UserAuto', + component: () => import('@/views/UserAuto.vue'), + } + ] + }, + { + path: '/about', + component: Layout, + meta: { + title: "关于", + icon: "el-icon-info" + }, + children: [ + { + path: 'index', + name: 'Abuout', + component: () => import('@/views/About.vue'), + } + ] + } ] const router = new VueRouter({ - mode: 'history', - base: process.env.BASE_URL, - routes + mode: 'history', + base: process.env.BASE_URL, + routes }) export default router diff --git a/src/utils/excelExport.js b/src/utils/excelExport.js new file mode 100644 index 0000000..0893730 --- /dev/null +++ b/src/utils/excelExport.js @@ -0,0 +1,96 @@ +/** + * Created by admin on 2018/02/08. + * author maw + */ +import XLSX from "xlsx"; +//import xlsxStyle from 'xlsx-style' + +/* eslint-disable */ +export default function (_headers, _data, _file) { + if (!Array.isArray(_headers) || _headers.length === 0) { + console.log("failure in excel export, reason: wrong parameter of header!"); + return ""; + } + if (!Array.isArray(_data)) { + console.log("failure in excel export, reason: wrong parameter of data!"); + return ""; + } + + let str = JSON.stringify(_data); + for (let i = 0; i < _headers.length; i++) { + let reg = new RegExp("(['|\"])" + _headers[i].prop + "['|\"]", "g"); + str = str.replace(reg, "$1" + _headers[i].label + "$1"); + } + let arr = JSON.parse(str); + + let wb = XLSX.utils.book_new(); + let ws = XLSX.utils.json_to_sheet(arr); + + let objectMaxLength = []; + console.log('arr', arr) + for (let i = 0; i < arr.length; i++) { + let temp = arr[i]; + for (var j in temp) { + let index = Object.keys(temp).indexOf(j); + if (!temp[j]) { + continue; + } + if (!isNaN(parseInt(temp[j].toString()))) { + objectMaxLength[index] = objectMaxLength[index] >= temp[j].length*1.5 ? objectMaxLength[index] : temp[j].length*1.5; + } else { + objectMaxLength[index] = objectMaxLength[index] >= temp[j].length * 3 ? objectMaxLength[index] : temp[j].length * 3; + } + } + } + + console.log('objectMaxLength', objectMaxLength) + + ws["!cols"] = []; + for (let item of objectMaxLength) { + ws["!cols"].push({ + wch: item < 10 ? 10 : item + }) + } + console.log('cols', ws["!cols"]) + // console.log(start) + XLSX.utils.book_append_sheet(wb, ws, "SheetJS"); + // 导出 Excel + let fileName = "output"; + if (_file) { + fileName = _file; + } + fileName += ".xlsx"; + XLSX.writeFile(wb, fileName, { compression: true, bookType: "xlsx" }); +}; + +/* + * 参数示例: + * let _headers = [ +* {prop: "id", label: "ID"}, +* {prop: "name", label: "姓名"}, +* {prop: "age", label: "年龄"}, +* {prop: "country", label: "国籍"}, +* {prop: "remark", label: "备注"} + * ]; + * let _data = [ +* { +* id: "1", + * name: "test1", + * age: "30", + * country: "China", + * remark: "hello" +* }, { +* id: "2", + * name: "test2", + * age: "20", + * country: "America", + * remark: "world" +* }, { +* id: "3", + * name: "test3", + * age: "18", + * country: "Unkonw", + * remark: "呵呵哈哈!" + * } + * ]; + */ diff --git a/src/views/About.vue b/src/views/About.vue index 3fa2807..ae30e38 100644 --- a/src/views/About.vue +++ b/src/views/About.vue @@ -1,5 +1,57 @@ + + + + + + \ No newline at end of file diff --git a/src/views/Home.vue b/src/views/Home.vue deleted file mode 100644 index 8bd6c57..0000000 --- a/src/views/Home.vue +++ /dev/null @@ -1,18 +0,0 @@ - - - diff --git a/src/views/UserAuto.vue b/src/views/UserAuto.vue new file mode 100644 index 0000000..d6a9f7c --- /dev/null +++ b/src/views/UserAuto.vue @@ -0,0 +1,157 @@ + + + + + + diff --git a/vue.config.js b/vue.config.js new file mode 100644 index 0000000..a1755e6 --- /dev/null +++ b/vue.config.js @@ -0,0 +1,57 @@ +'use strict' +const path = require('path') + +function resolve(dir) { + return path.join(__dirname, dir) +} + +const name = 'YzxTool' // page title +// If your port is set to 80, +// use administrator privileges to execute the command line. +// For example, Mac: sudo npm run +const port = 9999 // dev port + +// All configuration item explanations can be find in https://cli.vuejs.org/config/ +module.exports = { + /**a + * You will need to set publicPath if you plan to deploy your site under a sub path, + * for example GitHub Pages. If you plan to deploy your site to https://foo.github.io/bar/, + * then publicPath should be set to "/bar/". + * In most cases please use '/' !!! + * Detail: https://cli.vuejs.org/config/#publicpath + */ + publicPath: '/', + outputDir: 'dist', + assetsDir: 'static', + lintOnSave: false, + productionSourceMap: false, + devServer: { + port: port, + open: true, + overlay: { + warnings: false, + errors: true + }, + proxy: { + '/api': { + //target: process.env.VUE_APP_BASE_API_TARGET, + target: "/apppp", + changeOrigin: true, + ws: true, + pathRewrite: { + '^/api': '' + } + }, + }, + }, + configureWebpack: { + // provide the app's title in webpack's name field, so that + // it can be accessed in index.html to inject the correct title. + name: name, + resolve: { + alias: { + '@': resolve('src') + } + }, + }, +}