Commit f040f186 authored by zhangdy's avatar zhangdy

first

parents
.DS_Store
node_modules/
dist/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.idea
{
"git.ignoreLimitWarning": true
}
\ No newline at end of file
MIT License
Copyright (c) 2016-present taylorchen709
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
\ No newline at end of file
# To start
``` bash
# install dependencies
npm install
# serve with hot reload at localhost:8081
npm run dev
# build for production with minification
npm run buildDev(开发环境打包)
npm run build(线上环境打包)
```
# Folder structure
* build - webpack config files
* config - webpack config files
* dist - build
* src -your app
* assets
* common
* components - your vue components
* views - your pages
* vuex
* App.vue
* main.js - main file
* router
#所有文件夹命名规范(驼峰法)
* 例如 .operationCenter
#每个路由下index.js里面内容命名规范(驼峰法)
* path - 一级菜单斜杠二级菜单 例如 one/two
* name - 不能与其它路由的name重复
#class命名规范
* 例如 .route-wrapper
#编码规范
* 搜索条件比较多的时候,注意每个搜索框上下左右对齐
* 代码整洁美观上注意层级关系需要缩进两行
* 页面内公用方法需要封装调用,减少赘余代码
* 每个方法需要写注释,便于协调开发
* 有组件化意识,复用功能模块可写到components目录下
require('./check-versions')()
process.env.NODE_ENV = 'production'
var ora = require('ora')
var rm = require('rimraf')
var path = require('path')
var chalk = require('chalk')
var webpack = require('webpack')
var config = require('../config')
var webpackConfig = require('./webpack.prod.conf')
var spinner = ora('building for production...')
spinner.start()
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
if (err) throw err
webpack(webpackConfig, function (err, stats) {
spinner.stop()
if (err) throw err
process.stdout.write(stats.toString({
colors: true,
modules: false,
children: false,
chunks: false,
chunkModules: false
}) + '\n\n')
console.log(chalk.cyan(' Build complete.\n'))
console.log(chalk.yellow(
' Tip: built files are meant to be served over an HTTP server.\n' +
' Opening index.html over file:// won\'t work.\n'
))
})
})
var chalk = require('chalk')
var semver = require('semver')
var packageConfig = require('../package.json')
var shell = require('shelljs')
function exec (cmd) {
return require('child_process').execSync(cmd).toString().trim()
}
var versionRequirements = [
{
name: 'node',
currentVersion: semver.clean(process.version),
versionRequirement: packageConfig.engines.node
},
]
if (shell.which('npm')) {
versionRequirements.push({
name: 'npm',
currentVersion: exec('npm --version'),
versionRequirement: packageConfig.engines.npm
})
}
module.exports = function () {
var warnings = []
for (var i = 0; i < versionRequirements.length; i++) {
var mod = versionRequirements[i]
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
warnings.push(mod.name + ': ' +
chalk.red(mod.currentVersion) + ' should be ' +
chalk.green(mod.versionRequirement)
)
}
}
if (warnings.length) {
console.log('')
console.log(chalk.yellow('To use this template, you must update following to modules:'))
console.log()
for (var i = 0; i < warnings.length; i++) {
var warning = warnings[i]
console.log(' ' + warning)
}
console.log()
process.exit(1)
}
}
/* eslint-disable */
require('eventsource-polyfill')
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
hotClient.subscribe(function (event) {
if (event.action === 'reload') {
window.location.reload()
}
})
require('./check-versions')()
var config = require('../config')
if (!process.env.NODE_ENV) {
process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV)
}
var opn = require('opn')
var path = require('path')
var express = require('express')
var webpack = require('webpack')
var proxyMiddleware = require('http-proxy-middleware')
var webpackConfig = require('./webpack.dev.conf')
// default port where dev server listens for incoming traffic
var port = process.env.PORT || config.dev.port
// automatically open browser, if not set will be false
var autoOpenBrowser = !!config.dev.autoOpenBrowser
// Define HTTP proxies to your custom API backend
// https://github.com/chimurai/http-proxy-middleware
var proxyTable = config.dev.proxyTable
var app = express()
var compiler = webpack(webpackConfig)
var devMiddleware = require('webpack-dev-middleware')(compiler, {
publicPath: webpackConfig.output.publicPath,
quiet: true
})
var hotMiddleware = require('webpack-hot-middleware')(compiler, {
log: () => {}
})
// force page reload when html-webpack-plugin template changes
compiler.plugin('compilation', function (compilation) {
compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
hotMiddleware.publish({ action: 'reload' })
cb()
})
})
// proxy api requests
Object.keys(proxyTable).forEach(function (context) {
var options = proxyTable[context]
if (typeof options === 'string') {
options = { target: options }
}
app.use(proxyMiddleware(options.filter || context, options))
})
// handle fallback for HTML5 history API
app.use(require('connect-history-api-fallback')())
// serve webpack bundle output
app.use(devMiddleware)
// enable hot-reload and state-preserving
// compilation error display
app.use(hotMiddleware)
// serve pure static assets
var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
app.use(staticPath, express.static('./static'))
var uri = 'http://localhost:' + port
var _resolve
var readyPromise = new Promise(resolve => {
_resolve = resolve
})
console.log('> Starting dev server...')
devMiddleware.waitUntilValid(() => {
console.log('> Listening at ' + uri + '\n')
// when env is testing, don't need open it
if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
// opn(uri)
}
_resolve()
})
var server = app.listen(port)
module.exports = {
ready: readyPromise,
close: () => {
server.close()
}
}
var path = require('path')
var config = require('../config')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
exports.assetsPath = function (_path) {
var assetsSubDirectory = process.env.NODE_ENV === 'production'
? config.build.assetsSubDirectory
: config.dev.assetsSubDirectory
return path.posix.join(assetsSubDirectory, _path)
}
exports.cssLoaders = function (options) {
options = options || {}
var cssLoader = {
loader: 'css-loader',
options: {
minimize: process.env.NODE_ENV === 'production',
sourceMap: options.sourceMap
}
}
// generate loader string to be used with extract text plugin
function generateLoaders (loader, loaderOptions) {
var loaders = [cssLoader]
if (loader) {
loaders.push({
loader: loader + '-loader',
options: Object.assign({}, loaderOptions, {
sourceMap: options.sourceMap
})
})
}
// Extract CSS when that option is specified
// (which is the case during production build)
if (options.extract) {
return ExtractTextPlugin.extract({
use: loaders,
fallback: 'vue-style-loader'
})
} else {
return ['vue-style-loader'].concat(loaders)
}
}
// https://vue-loader.vuejs.org/en/configurations/extract-css.html
return {
css: generateLoaders(),
postcss: generateLoaders(),
less: generateLoaders('less'),
sass: generateLoaders('sass', { indentedSyntax: true }),
scss: generateLoaders('sass'),
stylus: generateLoaders('stylus'),
styl: generateLoaders('stylus')
}
}
// Generate loaders for standalone style files (outside of .vue)
exports.styleLoaders = function (options) {
var output = []
var loaders = exports.cssLoaders(options)
for (var extension in loaders) {
var loader = loaders[extension]
output.push({
test: new RegExp('\\.' + extension + '$'),
use: loader
})
}
return output
}
var utils = require('./utils')
var config = require('../config')
var isProduction = process.env.NODE_ENV === 'production'
module.exports = {
loaders: utils.cssLoaders({
sourceMap: isProduction
? config.build.productionSourceMap
: config.dev.cssSourceMap,
extract: isProduction
})
}
var path = require('path')
var utils = require('./utils')
var config = require('../config')
var vueLoaderConfig = require('./vue-loader.conf')
function resolve(dir) {
return path.join(__dirname, '..', dir)
}
module.exports = {
entry: {
app: './src/main.js'
},
externals: {
'vue': 'Vue',
'vue-router': 'VueRouter',
'element-ui': 'ELEMENT',
'vuex': 'Vuex',
'axios': 'axios',
'echarts': 'echarts'
},
output: {
path: config.build.assetsRoot,
filename: '[name].js',
publicPath: process.env.NODE_ENV === 'production'
? config.build.assetsPublicPath
: config.dev.assetsPublicPath
},
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': resolve('src'),
'assets': resolve('src/assets'),
'scss_vars': '@/styles/vars.scss'
}
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: vueLoaderConfig
},
{
test: /\.js$/,
loader: 'babel-loader',
include: [resolve('src'), resolve('test')]
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('img/[name].[hash:7].[ext]')
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
}
]
}
}
var utils = require('./utils')
var webpack = require('webpack')
var config = require('../config')
var merge = require('webpack-merge')
var baseWebpackConfig = require('./webpack.base.conf')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
// add hot-reload related code to entry chunks
Object.keys(baseWebpackConfig.entry).forEach(function (name) {
baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name])
})
module.exports = merge(baseWebpackConfig, {
module: {
rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
},
// cheap-module-eval-source-map is faster for development
devtool: '#cheap-module-eval-source-map',
plugins: [
new webpack.DefinePlugin({
'process.env': require('../config/dev.env')
}),
// https://github.com/glenjamin/webpack-hot-middleware#installation--usage
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
// https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true
}),
new FriendlyErrorsPlugin()
]
})
var path = require('path')
var utils = require('./utils')
var webpack = require('webpack')
var config = require('../config')
var merge = require('webpack-merge')
var baseWebpackConfig = require('./webpack.base.conf')
var CopyWebpackPlugin = require('copy-webpack-plugin')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
// var env = config.build.env
var env = require('../config/prod.env')
var webpackConfig = merge(baseWebpackConfig, {
module: {
rules: utils.styleLoaders({
sourceMap: config.build.productionSourceMap,
extract: true
})
},
devtool: config.build.productionSourceMap ? '#source-map' : false,
output: {
path: config.build.assetsRoot,
filename: utils.assetsPath('js/[name].[chunkhash].js'),
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
},
plugins: [
// http://vuejs.github.io/vue-loader/en/workflow/production.html
new webpack.DefinePlugin({
'process.env': env
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
},
sourceMap: true
}),
// extract css into its own file
new ExtractTextPlugin({
filename: utils.assetsPath('css/[name].[contenthash].css')
}),
// Compress extracted CSS. We are using this plugin so that possible
// duplicated CSS from different components can be deduped.
new OptimizeCSSPlugin({
cssProcessorOptions: {
safe: true
}
}),
// generate dist index.html with correct asset hash for caching.
// you can customize output by editing /index.html
// see https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: config.build.index,
template: 'index.html',
inject: true,
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
// more options:
// https://github.com/kangax/html-minifier#options-quick-reference
},
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
chunksSortMode: 'dependency'
}),
// split vendor js into its own file
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: function (module, count) {
// any required modules inside node_modules are extracted to vendor
return (
module.resource &&
/\.js$/.test(module.resource) &&
module.resource.indexOf(
path.join(__dirname, '../node_modules')
) === 0
)
}
}),
// extract webpack runtime and module manifest to its own file in order to
// prevent vendor hash from being updated whenever app bundle is updated
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
chunks: ['vendor']
}),
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.build.assetsSubDirectory,
ignore: ['.*']
}
])
]
})
if (config.build.productionGzip) {
var CompressionWebpackPlugin = require('compression-webpack-plugin')
webpackConfig.plugins.push(
new CompressionWebpackPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: new RegExp(
'\\.(' +
config.build.productionGzipExtensions.join('|') +
')$'
),
threshold: 10240,
minRatio: 0.8
})
)
}
if (config.build.bundleAnalyzerReport) {
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
}
module.exports = webpackConfig
var merge = require('webpack-merge')
var prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {
NODE_ENV: '"development"'
})
// see http://vuejs-templates.github.io/webpack for documentation.
var path = require('path')
var argv = require('minimist')(process.argv.slice(2));
module.exports = {
build: {
env: require('./prod.env'),
index: path.resolve(__dirname, '../dist/index.html'),
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: '/',
productionSourceMap: false,
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
// Before setting to `true`, make sure to:
// npm install --save-dev compression-webpack-plugin
productionGzip: false,
productionGzipExtensions: ['js', 'css'],
// Run the build command with an extra argument to
// View the bundle analyzer report after build finishes:
// `npm run build --report`
// Set to `true` or `false` to always turn it on or off
bundleAnalyzerReport: process.env.npm_config_report
},
dev: {
env: require('./dev.env'),
host: 'jieziman.com',
port: 8097,
autoOpenBrowser: true,
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: { //转发:本地请求资源的时候:localhost转发到这个路径下请求资源 防止跨域
// '/api': {
// target: 'http://devihappy.yl9158.com/',
// changeOrigin: true,
// pathRewrite: {
// '^/api': ''
// }
// }
},
// CSS Sourcemaps off by default because relative paths are "buggy"
// with this option, according to the CSS-Loader README
// (https://github.com/webpack/css-loader#sourcemaps)
// In our experience, they generally work as expected,
// just be aware of this issue when enabling this option.
cssSourceMap: false
}
}
\ No newline at end of file
'use strict'
let argv = require('minimist')(process.argv.slice(2));
let env = '"'+argv.env+'"';
module.exports = {
NODE_ENV: '"production"',
env: env
}
This diff is collapsed.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" name="viewport" content="width=device-width,initial-scale=1.0">
<title>财务系统</title>
<link rel="icon" type="image/x-icon" href="/static/logo.ico">
<link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<!-- <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css"> -->
<!-- <link rel="stylesheet" href="/static/element-ui/element-ui.css"></link> -->
<link rel="stylesheet" href="/static/theme/index.css"></link>
<!-- <link rel="stylesheet" href="https://jzm-oss.oss-cn-hangzhou.aliyuncs.com/static/element-ui.css"> -->
</head>
<body>
<div id="app">
</div>
<script src="https://cdn.staticfile.org/vue/2.5.16/vue.min.js"></script>
<script src="https://cdn.staticfile.org/vue-router/3.0.1/vue-router.min.js"></script>
<script src="https://cdn.staticfile.org/vuex/3.0.1/vuex.min.js"></script>
<script src="https://cdn.staticfile.org/axios/0.18.0/axios.min.js"></script>
<script src="http://gosspublic.alicdn.com/aliyun-oss-sdk-6.5.0.min.js"></script>
<!-- <script src="https://unpkg.com/element-ui/lib/index.js"></script> -->
<!-- <script src="/static/element-ui/element-ui.js"></script> -->
<script src="https://jzm-oss.oss-cn-hangzhou.aliyuncs.com/static/element-ui.js"></script>
<script src="https://cdn.staticfile.org/echarts/4.0.3/echarts.min.js"></script>
</body>
</html>
This diff is collapsed.
{
"name": "vueadmin",
"version": "1.0.1",
"description": "vue+element",
"author": "zdy",
"license": "MIT",
"scripts": {
"dev": "node build/dev-server.js",
"start": "node build/dev-server.js",
"build": "node build/build.js --env=www",
"buildUat": "node build/build.js --env=uat",
"buildSit": "node build/build.js --env=sit",
"buildDev": "node build/build.js --env=dev"
},
"dependencies": {
"af-table-column": "^1.0.3",
"ali-oss": "^6.11.2",
"axios": "^0.19.0",
"echarts": "^4.0.3",
"element-theme": "^2.0.1",
"element-ui": "^2.11.0",
"font-awesome": "^4.7.0",
"moment": "^2.24.0",
"nprogress": "^0.2.0",
"qs": "6.5.2",
"screenfull": "^5.0.2",
"v-clipboard": "^2.2.3",
"vue": "^2.2.2",
"vue-clipboard2": "^0.3.1",
"vue-router": "^2.3.0",
"vuex": "^2.0.0-rc.6"
},
"devDependencies": {
"autoprefixer": "^6.7.2",
"axios-mock-adapter": "^1.7.1",
"babel-core": "^6.22.1",
"babel-loader": "^6.2.10",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-polyfill": "^6.16.0",
"babel-preset-env": "^1.2.1",
"babel-preset-es2015": "^6.0.0",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.22.0",
"chalk": "^1.1.3",
"connect-history-api-fallback": "^1.3.0",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.26.1",
"element-theme-chalk": "^2.15.2",
"eventsource-polyfill": "^0.9.6",
"express": "^4.11.0",
"extract-text-webpack-plugin": "^2.0.0",
"file-loader": "^0.10.0",
"friendly-errors-webpack-plugin": "^1.1.3",
"function-bind": "^1.0.2",
"html-webpack-plugin": "^2.28.0",
"http-proxy-middleware": "^0.19.1",
"json-loader": "^0.5.4",
"less": "3.8.0",
"less-loader": "4.1.0",
"minimist": "1.2.0",
"mockjs": "^1.0.1-beta3",
"node-sass": "^4.11.0",
"opn": "^4.0.2",
"optimize-css-assets-webpack-plugin": "^1.3.0",
"ora": "^1.0.0",
"rimraf": "^2.6.0",
"sass-loader": "^7.0.0",
"semver": "^5.3.0",
"shelljs": "^0.7.6",
"url-loader": "^0.5.8",
"vue-loader": "^11.1.4",
"vue-style-loader": "^2.0.0",
"vue-template-compiler": "^2.2.4",
"webpack": "^2.2.1",
"webpack-bundle-analyzer": "^2.2.1",
"webpack-dev-middleware": "^1.10.0",
"webpack-hot-middleware": "^2.16.1",
"webpack-merge": "^2.6.1"
},
"engines": {
"node": ">= 4.0.0",
"npm": ">= 3.0.0"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}
<template>
<div id="app">
<transition name="fade"
mode="out-in">
<router-view></router-view>
</transition>
</div>
</template>
<script>
export default {
name: 'app',
components: {
},
// data () {
// return {
// isRouteAlive: true
// }
// },
// provide () {
// return {
// reload: this.reload
// }
// },
// methods: {
// reload () {
// this.isRouteAlive = false
// this.$nextTick (() => {
// this.isRouteAlive = true
// })
// }
// }
}
</script>
<style lang="scss">
body {
margin: 0px;
padding: 0px;
/*background: url(assets/bg1.jpg) center !important;
background-size: cover;*/
// background: #1F2D3D;
font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, SimSun, sans-serif;
font-size: 12px;
-webkit-font-smoothing: antialiased;
}
#app {
position: absolute;
top: 0px;
bottom: 0px;
width: 100%;
}
.el-submenu [class^=fa] {
vertical-align: baseline;
margin-right: 10px;
}
.el-menu{
border-right: none
}
.el-menu-item [class^=fa] {
vertical-align: baseline;
margin-right: 10px;
}
.toolbar {
background: #f2f2f2;
padding: 10px;
//border:1px solid #dfe6ec;
margin: 10px 0px;
.el-form-item {
margin-bottom: 10px;
}
}
.fade-enter-active,
.fade-leave-active {
transition: all .2s ease;
}
.fade-enter,
.fade-leave-active {
opacity: 0;
}
.el-form-item__label{
font-size: 12px!important;
}
.el-form--inline .el-form-item{
margin-bottom: -5px!important;
}
.el-table{
font-size: 12px!important
}
.el-input.is-disabled .el-input__inner {
background-color: #FFF!important;
}
.el-radio__input.is-disabled+span.el-radio__label{
color: #606266!important
}
.el-checkbox__input.is-disabled+span.el-checkbox__label{
color: #606266!important
}
body .el-table th.gutter{
display: table-cell!important;
}
</style>
\ No newline at end of file
This diff is collapsed.
@color-primary: #4E74FC;
\ No newline at end of file
// import Vue from 'vue'
// import ELEMENT from 'element-ui';
// import axios from 'axios'
import localStorage from '../vuex/localStorage'
import { router } from '../router'
import qs from 'qs';
import {rootUrl} from '@/config'
let apiPrefix = process.env.NODE_ENV === 'production' ? '/' : '/api';
let AxiosIns = axios.create({
baseURL: rootUrl,
timeout: 50000,
transformRequest: [data => {
if(data instanceof FormData){
return data
}else{
return qs.stringify(data)
}
}],
headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8' },
withCredentials: true
})
let timer = [];
let delay = 300;
let loading = null;
let options = {
lock: true,
text: '拼命加载中',
background: 'rgba(0, 0, 0, 0.2)',
target: "#app",
}
AxiosIns.interceptors.request.use((config) => {
if (loading == null) {
loading = ELEMENT.Loading.service(options);
}
timer.push(setTimeout(() => {
}, delay))
return config;
})
AxiosIns.interceptors.response.use((response) => {
for (let t of timer) {
clearTimeout(t);
}
if (loading != null) {
loading.close();
loading = null;
}
try {//使用try catch是因为:后台服务器挂掉返回的并不是一个object并不能正确捕捉到错误信息
if (response.data && response.data.success !== true) {
let msg = Array.isArray(response.data.errMsg) ? response.data.errMsg[0] : response.data.errMsg;
let code = Array.isArray(response.data.errCode) ? response.data.errCode[0] : response.data.errCode;
ELEMENT.Message({
message: msg ? msg : code || '操作失败',
type: 'warning',
showClose: true,
});
// if (msg == "REQUEST_TOKEN") { // cookie验证验权失败
// localStorage.$setLocalStorageByName('user', {}); //清空用户缓存
// setTimeout(() => {
// router.push({path: '/login'})
// }, 1000)
// }
}
} catch (e) {
}
return response.data;
}, (error) => {
for (let t of timer) {
clearTimeout(t);
}
// loading.close();
try {
// console.log(error.response.status)
// if (error.response.data.Code !== 0) {
// let msg = typeof error.response.data === "string" ? error.response.data : error.response.data.Message
// if (msg !== '对不起,您没有配置权限菜单!') {
// ELEMENT.Message({
// message: msg || '操作失败',
// type: 'warning',
// showClose: true
// });
// }
// }
// 请求授权失败则重新跳转到登陆页
// if (error.response.data.Code === 401) {
// setTimeout(() => {
// router.push({
// path: '/login'
// })
// }, 1000)
// }
let message=''
if(error&&error.response){
loading.close();
loading = null;
switch(error.response.status){
case 400:
message='错误请求'
break;
case 404:
message='请求错误,未找到该资源'
break;
case 500:
message='服务器出错'
break;
default:
message='网络错误'
}
ELEMENT.Message({
message: message,
type: 'warning',
showClose: true,
});
}else{
loading.close();
loading = null;
ELEMENT.Message({
message: '后端接口出现异常',
type: 'warning'
});
// router.push({
// path: '/login'
// })
}
} catch (e) {
console.log(e);
// loading.close();
loading = null;
}
return Promise.reject(error);
})
Vue.prototype.axios = AxiosIns;
var SIGN_REGEXP = /([yMdhsm])(\1*)/g;
var DEFAULT_PATTERN = 'yyyy-MM-dd';
function padding(s, len) {
var len = len - (s + '').length;
for (var i = 0; i < len; i++) { s = '0' + s; }
return s;
};
import OSS from 'ali-oss';
export default {
getQueryStringByName: function (name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
var context = "";
if (r != null)
context = r[2];
reg = null;
r = null;
return context == null || context == "" || context == "undefined" ? "" : context;
},
formatDate: {
format: function (date, pattern) {
pattern = pattern || DEFAULT_PATTERN;
return pattern.replace(SIGN_REGEXP, function ($0) {
switch ($0.charAt(0)) {
case 'y': return padding(date.getFullYear(), $0.length);
case 'M': return padding(date.getMonth() + 1, $0.length);
case 'd': return padding(date.getDate(), $0.length);
case 'w': return date.getDay() + 1;
case 'h': return padding(date.getHours(), $0.length);
case 'm': return padding(date.getMinutes(), $0.length);
case 's': return padding(date.getSeconds(), $0.length);
}
});
},
parse: function (dateString, pattern) {
var matchs1 = pattern.match(SIGN_REGEXP);
var matchs2 = dateString.match(/(\d)+/g);
if (matchs1.length == matchs2.length) {
var _date = new Date(1970, 0, 1);
for (var i = 0; i < matchs1.length; i++) {
var _int = parseInt(matchs2[i]);
var sign = matchs1[i];
switch (sign.charAt(0)) {
case 'y': _date.setFullYear(_int); break;
case 'M': _date.setMonth(_int - 1); break;
case 'd': _date.setDate(_int); break;
case 'h': _date.setHours(_int); break;
case 'm': _date.setMinutes(_int); break;
case 's': _date.setSeconds(_int); break;
}
}
return _date;
}
return null;
}
},
getTime: function (n,callback) {
console.log(typeof callback)
var now = new Date();
var year = now.getFullYear();
//因为月份是从0开始的,所以获取这个月的月份数要加1才行
var month = now.getMonth() + 1;
var date = now.getDate();
var day = now.getDay();
//判断是否为周日,如果不是的话,就让今天的day-1(例如星期二就是2-1)
if (day !== 0) {
n = n + (day - 1);
} else {
n = n + day;
}
if (day) {
//这个判断是为了解决跨年的问题
if (month > 1) {
month = month;
}
//这个判断是为了解决跨年的问题,月份是从0开始的
else {
year = year - 1;
month = 12;
}
}
now.setDate(now.getDate() - n);
year = now.getFullYear();
month = now.getMonth() + 1;
date = now.getDate();
let s =
year +
"-" +
(month < 10 ? "0" + month : month) +
"-" +
(date < 10 ? "0" + date : date);
this.value1 = s;
callback(s);
},
handleselect(key,_this,type,name) {
let getCurSide=_this.getCurSide?_this.getCurSide:JSON.parse(localStorage.getItem('menuTree'))
let isHas = _this.dynamicTags.some((item) => {
return item.path == key
})
if(type==1){
getCurSide.map((item) => {
item.children.map((v) => {
if (v.path === key && !isHas) {
_this.dynamicTags.map((m) => {
return m.type = 'info'
})
_this.dynamicTags.push(v)
}
})
})
}else{
if(!isHas){
_this.dynamicTags.push({name,path:key,type:'info'})
}
}
if (_this.dynamicTags.length > 1) {
_this.dynamicTags.map((m) => {
if (key == m.path) {
_this.$set(m, 'type', '')
} else {
_this.$set(m, 'type', 'info')
}
})
}
_this.$store.commit('getTopMenu', _this.dynamicTags);
},
export(url, param, _this){
let obj = _this.$el;
obj.setAttribute("class", "el-loading-parent--relative");
let loadDiv = document.createElement('div');
let loadDivContent = '<div class="el-loading-mask" style=""><div class="el-loading-spinner"><svg viewBox="25 25 50 50" class="circular"><circle cx="50" cy="50" r="20" fill="none" class="path"></circle></svg><!----></div></div>';
loadDiv.innerHTML = loadDivContent;
obj.appendChild(loadDiv);
let notify = _this.$notify({
title: '下载中',
dangerouslyUseHTMLString: true,
message: '',
type: 'info',
duration: 0
});
_this.axios({
url: url,
data: param,
method: 'post'
}).then(res => {
if (res.success){
notify.title = "下载完成";
notify.type = 'success';
notify.message = '<strong><a style="text-decoration: none;" href="'+res.module+'">点击获取</a></strong>';
} else {
notify.title = "下载失败";
notify.type = 'error';
}
obj.removeAttribute("class");
obj.removeChild(loadDiv);
})
},
client(data) {
console.log(JSON.stringify(data));
return new OSS({
region: data.region,
accessKeyId: data.accessKeyId,
accessKeySecret: data.accessKeySecret,
bucket: data.bucket
});
},
};
<template>
<aside :class="collapsed?'menu-collapsed':'menu-expanded'" id="leftAside">
<!--导航菜单-->
<el-menu :default-active="$route.path" class="el-menu-vertical-demo" @open="handleopen" @close="handleclose"
@select="handleselect"
unique-opened router :collapse="collapsed">
<template v-for="(item,index) in getCurSide" v-if="!item.hidden">
<el-submenu :index="index+''" v-if="!item.leaf" :key="index">
<template slot="title"><i :class="item.iconCls"></i><span>{{ item.name }}</span></template>
<el-menu-item v-for="child in item.children" :index="child.path" :key="child.path"
v-if="!child.hidden">{{ child.name }}
</el-menu-item>
</el-submenu>
<el-menu-item v-if="item.leaf&&item.children.length>0" :index="item.children[0].path" :key="index"><i
:class="item.iconCls"></i><span>{{ item.children[0].name }}</span></el-menu-item>
</template>
</el-menu>
</aside>
</template>
<script>
import util from "@/common/js/util";
export default {
data() {
return {
getCurSide: this.$store.state.global.menuTree,
path: '',
}
},
mounted() {
let treeData = localStorage.getItem('menuTree') || [];
let currentTreeData = JSON.parse(treeData);
// this.getCurSide = this.recursionMenu(currentTreeData);
},
computed: {
collapsed() {
return this.$store.state.global.collapsed
},
dynamicTags() {
return this.$store.state.global.dynamicTags
}
},
methods: {
getMenu() {
return {
path: '',
name: '',
iconCls: '',
leaf: true,
children: []
};
},
getChildren(childrenData) {
let children = [];
childrenData.forEach(item => {
children.push({path: item.path, name: item.name});
});
return children;
},
recursionMenu(treeData) {
let that = this;
let menumData = [];
treeData.forEach(item => {
let menum = that.getMenu();
menum.path = item.path;
menum.name = item.name;
menum.iconCls = item.icon;
let children = item.children;
if (children != null && children.length > 0 && item.type <= 2) {
menum.leaf = false;
menum.children = that.getChildren(children);
}
if (menum.leaf) {
menum.children = [{path: item.path, name: item.name}];
}
menumData.push(menum);
});
return menumData;
},
handleselect(key) {
util.handleselect(key,this,1)
// let isHas = this.dynamicTags.some((item) => {
// return item.path == key
// })
// this.getCurSide.map((item) => {
// item.children.map((v) => {
// if (v.path === key && !isHas) {
// this.dynamicTags.map((m) => {
// return m.type = 'info'
// })
// this.dynamicTags.push(v)
// }
// })
// })
// if (this.dynamicTags.length > 1) {
// this.dynamicTags.map((m) => {
// if (key == m.path) {
// this.$set(m, 'type', '')
// } else {
// this.$set(m, 'type', 'info')
// }
// })
// }
// this.$store.commit('getTopMenu', this.dynamicTags);
},
}
}
</script>
<style scoped lang="less">
aside {
// position: absolute;
// top: 0px;
// bottom: 0px;
.el-menu-vertical-demo:not(.el-menu--collapse) {
width: 180px;
min-height: 400px;
}
.el-menu {
height: 100%;
}
.collapsed {
width: 60px;
.item {
position: relative;
}
.submenu {
position: absolute;
top: 0px;
left: 60px;
z-index: 99999;
height: auto;
display: none;
}
}
}
.menu-collapsed {
flex: 0 0 60px;
width: 60px;
z-index: 2000;
}
.menu-expanded {
flex: 0 0 180px;
width: 180px;
z-index: 2000;
}
</style>
\ No newline at end of file
<template>
<section>
<el-col :span="24" class="tags-center" v-if="dynamicTags.length>0">
<i class="fa fa-backward pl10 pr10 tab-text zx1 bgwh" aria-hidden="true" @click="leftmove"/>
<div class="dis-flex ac calcw" style="overflow-x:auto">
<div class="dis-flex" :style="{width: dynamicTags.length * 120 + 'px','margin-left': xxx * 110 + 'px',flex:'none'}">
<div :class="tag.type?'tab-text':'tab-text g30'" v-for="tag in dynamicTags" :key="tag.name" @click="changePage(tag)">{{tag.name}}<i class="el-icon-close pl2" @click.stop="handleCloseTag(tag)"/></div>
</div>
</div>
<div style="width:196px">
<i class="fa fa-forward tab-text border-l" aria-hidden="true" @click="rightmove"/>
<el-dropdown trigger="hover" class="tab-text f12">
<span class="el-dropdown-link userinfo-inner">
<span>页面标签</span>
<i class="el-icon-caret-bottom el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item @click.native="closeAllTag"><i class="el-icon-circle-close"/>关闭全部标签</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<span class="p10 tag-color" @click="refresh">刷新<i class="el-icon-refresh pl5"/></span>
</div>
</el-col>
<div class="cl">
</div>
</section>
</template>
<script>
export default {
data() {
return {
activeMenu:'',
getCurSide:[],
path:'',
xxx:0
}
},
inject: ['reload'],
computed:{
dynamicTags(){
return this.$store.state.global.dynamicTags
}
},
methods: {
leftmove() {
if (this.xxx < 0) {
this.xxx += 1;
}
},
rightmove() {
if (this.xxx > -(this.dynamicTags.length + this.xxx)) {
this.xxx -= 1;
}
},
refresh () {
this.reload()
},
changePage(tag){
this.dynamicTags.map((v)=>{
this.$set(v,'type','info')
if(tag.name===v.name){
this.$set(v,'type','')
}
})
this.$router.push(tag.path)
},
handleCloseTag(tag) {
this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1);
},
closeAllTag(){
this.$store.commit('getTopMenu', []);
this.$store.commit('getTopMenu', [{name: '首页',path: '/index/index',type:''}]);
this.$router.push({name:'index'})
}
}
}
</script>
<style scoped lang="less">
.tags-center{
min-width: 1200px;
text-align: center;
cursor: pointer;
height:32px;
background:rgba(255,255,255,1);
// box-shadow:0px 1px 4px 0px rgba(0,21,41,0.12);
display: flex;
align-items: center;
justify-content: space-between;
// padding-left: 15px;
.el-tag + .el-tag {
margin-left: 10px;
cursor: pointer;
}
.border-l{
border-left: 1px solid #E5E5E5;
}
}
.tab-text{
border-right: 1px solid #E5E5E5;
height: 30px;
line-height: 32px;
padding: 0 10px;
color: #909399
}
.calcw{
// width:calc(100%-193px)
width: calc(100% - 223px);
}
.pl2{padding-left: 2px}
</style>
\ No newline at end of file
let host = window.location.protocol + '//' + window.location.host + '/';
if (window.location.host === 'localhost:8097') host = 'http://finance.winwchain.com/finance-web';
// http://sitpurchasing.rubansh.com/
// http://localhost:8192/
export const devtools = true;
export const productionTip = true;
if (process.env.env == 'dev') {
host = 'http://devfinance.rubansh.com/finance-web';
} else if (process.env.env == 'sit') {
host = 'http://sitfinance.rubansh.com/finance-web';
} else if (process.env.env == 'www') {
host = host+'finance-web';
}
export const rootUrl = host;
export const domain = process.env.env;
\ No newline at end of file
import babelpolyfill from 'babel-polyfill'
// import Vue from 'vue'
import App from './App'
// import ElementUI from 'element-ui'
// import 'element-ui/lib/theme-chalk/index.css'
import '@/assets/css/common.less'
// import '../theme/index.css'
import store from './vuex'
import Vuex from 'vuex'
import {router} from './router'
import './common/axiosSetting'
// import echarts from 'echarts'
// import 'font-awesome/css/font-awesome.min.css'
// Vue.use(ElementUI)
// Vue.use(VueRouter)
Vue.use(Vuex)
// const router = new VueRouter({
// routes
// })
// router.beforeEach((to, from, next) => {
// //NProgress.start();
// console.log(to)
// if (to.path == '/login') {
// sessionStorage.removeItem('user');
// }
// let user = JSON.parse(sessionStorage.getItem('user'));
// if (!user && to.path != '/login') {
// next({ path: '/login' })
// } else {
// next()
// }
// })
window.log = message => console.log(message)
new Vue({
el: '#app',
template: '<App/>',
router,
store,
components: { App },
// render: h => h(App)
})
// import Vue from 'vue'
// import VueRouter from 'vue-router'
// import 'vueConfig'
import warehouseConfiguration from './warehouseConfiguration'
const login = resolve => require(['@/views/Login'], resolve);
import index from './index/index'
// const parent = resolve => require(['@/components/parent'], resolve);//子页面
const Home = resolve => require(['@/views/Home'], resolve); //子页面
Vue.use(VueRouter);
const routes = [{ // 404
path: '*',
component: login
},
{
path: '/login',
component: login,
name: 'login',
hidden: true
},
// 主页面
{
path: '/home',
// redirect: '/',
name: 'home',
component: Home,
children: [].concat(index,warehouseConfiguration)
},
].reverse();
export const router = new VueRouter({
routes,
mode: 'history',
})
router.beforeEach((to, from, next) => {
if (to.path == '/login') {
localStorage.removeItem('user');
}
let user = JSON.parse(localStorage.getItem('user'));
if (!user && to.path != '/login') {
// next({ path: '/login' })
next()
} else {
if(from.meta.isChildren&&!to.meta.isChildren){
from.meta.keepAlive = false
to.meta.keepAlive = true
}else if(to.meta.isChildren&&!from.meta.isChildren){
to.meta.keepAlive = false
}
else{
to.meta.keepAlive = true
}
next()
}
})
\ No newline at end of file
const index = resolve => require(['@/views/index/index'], resolve);
export default [
{
path: '/index/index',
name: 'index',
component: index,
meta: {
title: '首页'
}
}
]
const login = resolve => require(['@/views/Login'], resolve);
export default [
{
path: '/login',
name: 'login',
component: login,
meta: {
title: '登录页面'
}
}
]
const deliveryWarehouse = resolve => require(['@/views/warehouseConfiguration/deliveryWarehouse'], resolve);
const shipperInformation = resolve => require(['@/views/warehouseConfiguration/shipperInformation'], resolve);
export default [
{
path: '/warehouseConfiguration/deliveryWarehouse',
name: 'deliveryWarehouse',
component: deliveryWarehouse,
meta: {
title: '发货仓库'
}
},
{
path: '/warehouseConfiguration/shipperInformation',
name: 'shipperInformation',
component: shipperInformation,
meta: {
title: '发件人信息'
}
}
]
<template>
<p class="page-container">404 page not found</p>
</template>
<style lang="scss" scoped>
.page-container {
font-size: 20px;
text-align: center;
color: rgb(192, 204, 218);
}
</style>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment