Commit 8e8bbb8e by 张杰

包活干源码

1 parent 4d24805a
Showing 301 changed files with 4864 additions and 0 deletions
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": ["transform-vue-jsx", "transform-runtime"],
"env": {
"development":{
"plugins": ["dynamic-import-node"]
}
}
}
# http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
build/*.js
config/*.js
src/assets
module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint',
sourceType: 'module'
},
env: {
browser: true,
node: true,
es6: true,
},
extends: ['plugin:vue/recommended', 'eslint:recommended'],
// add your custom rules here
//it is base on https://github.com/vuejs/eslint-config-vue
rules: {
"vue/max-attributes-per-line": [2, {
"singleline": 10,
"multiline": {
"max": 1,
"allowFirstLine": false
}
}],
"vue/name-property-casing": ["error", "PascalCase"],
'accessor-pairs': 2,
'arrow-spacing': [2, {
'before': true,
'after': true
}],
'block-spacing': [2, 'always'],
'brace-style': [2, '1tbs', {
'allowSingleLine': true
}],
'camelcase': [0, {
'properties': 'always'
}],
'comma-dangle': [2, 'never'],
'comma-spacing': [2, {
'before': false,
'after': true
}],
'comma-style': [2, 'last'],
'constructor-super': 2,
'curly': [2, 'multi-line'],
'dot-location': [2, 'property'],
'eol-last': 2,
'eqeqeq': [2, 'allow-null'],
'generator-star-spacing': [2, {
'before': true,
'after': true
}],
'handle-callback-err': [2, '^(err|error)$'],
'indent': [2, 2, {
'SwitchCase': 1
}],
'jsx-quotes': [2, 'prefer-single'],
'key-spacing': [2, {
'beforeColon': false,
'afterColon': true
}],
'keyword-spacing': [2, {
'before': true,
'after': true
}],
'new-cap': [2, {
'newIsCap': true,
'capIsNew': false
}],
'new-parens': 2,
'no-array-constructor': 2,
'no-caller': 2,
'no-console': 'off',
'no-class-assign': 2,
'no-cond-assign': 2,
'no-const-assign': 2,
'no-control-regex': 0,
'no-delete-var': 2,
'no-dupe-args': 2,
'no-dupe-class-members': 2,
'no-dupe-keys': 2,
'no-duplicate-case': 2,
'no-empty-character-class': 2,
'no-empty-pattern': 2,
'no-eval': 2,
'no-ex-assign': 2,
'no-extend-native': 2,
'no-extra-bind': 2,
'no-extra-boolean-cast': 2,
'no-extra-parens': [2, 'functions'],
'no-fallthrough': 2,
'no-floating-decimal': 2,
'no-func-assign': 2,
'no-implied-eval': 2,
'no-inner-declarations': [2, 'functions'],
'no-invalid-regexp': 2,
'no-irregular-whitespace': 2,
'no-iterator': 2,
'no-label-var': 2,
'no-labels': [2, {
'allowLoop': false,
'allowSwitch': false
}],
'no-lone-blocks': 2,
'no-mixed-spaces-and-tabs': 2,
'no-multi-spaces': 2,
'no-multi-str': 2,
'no-multiple-empty-lines': [2, {
'max': 1
}],
'no-native-reassign': 2,
'no-negated-in-lhs': 2,
'no-new-object': 2,
'no-new-require': 2,
'no-new-symbol': 2,
'no-new-wrappers': 2,
'no-obj-calls': 2,
'no-octal': 2,
'no-octal-escape': 2,
'no-path-concat': 2,
'no-proto': 2,
'no-redeclare': 2,
'no-regex-spaces': 2,
'no-return-assign': [2, 'except-parens'],
'no-self-assign': 2,
'no-self-compare': 2,
'no-sequences': 2,
'no-shadow-restricted-names': 2,
'no-spaced-func': 2,
'no-sparse-arrays': 2,
'no-this-before-super': 2,
'no-throw-literal': 2,
'no-trailing-spaces': 2,
'no-undef': 2,
'no-undef-init': 2,
'no-unexpected-multiline': 2,
'no-unmodified-loop-condition': 2,
'no-unneeded-ternary': [2, {
'defaultAssignment': false
}],
'no-unreachable': 2,
'no-unsafe-finally': 2,
'no-unused-vars': [2, {
'vars': 'all',
'args': 'none'
}],
'no-useless-call': 2,
'no-useless-computed-key': 2,
'no-useless-constructor': 2,
'no-useless-escape': 0,
'no-whitespace-before-property': 2,
'no-with': 2,
'one-var': [2, {
'initialized': 'never'
}],
'operator-linebreak': [2, 'after', {
'overrides': {
'?': 'before',
':': 'before'
}
}],
'padded-blocks': [2, 'never'],
'quotes': [2, 'single', {
'avoidEscape': true,
'allowTemplateLiterals': true
}],
'semi': [2, 'never'],
'semi-spacing': [2, {
'before': false,
'after': true
}],
'space-before-blocks': [2, 'always'],
'space-before-function-paren': [2, 'never'],
'space-in-parens': [2, 'never'],
'space-infix-ops': 2,
'space-unary-ops': [2, {
'words': true,
'nonwords': false
}],
'spaced-comment': [2, 'always', {
'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
}],
'template-curly-spacing': [2, 'never'],
'use-isnan': 2,
'valid-typeof': 2,
'wrap-iife': [2, 'any'],
'yield-star-spacing': [2, 'both'],
'yoda': [2, 'never'],
'prefer-const': 2,
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'object-curly-spacing': [2, 'always', {
objectsInObjects: false
}],
'array-bracket-spacing': [2, 'never']
}
}
.DS_Store
node_modules/
dist/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
**/*.log
test/unit/coverage
test/e2e/reports
selenium-debug.log
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
package-lock.json
.DS_Store
node_modules/
build/
npm-debug.log
yarn-error.log
# Editor directories and files
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
// https://github.com/michael-ciniawsky/postcss-load-config
module.exports = {
"plugins": {
"postcss-import": {},
"postcss-url": {},
// to edit target browsers: use "browserslist" field in package.json
"autoprefixer": {}
}
}
language: node_js
node_js: stable
script: npm run test
notifications:
email: false
MIT License
Copyright (c) 2017-present PanJiaChen
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.
'use strict'
require('./check-versions')()
const ora = require('ora')
const rm = require('rimraf')
const path = require('path')
const chalk = require('chalk')
const webpack = require('webpack')
const config = require('../config')
const webpackConfig = require('./webpack.prod.conf')
var connect = require('connect')
var serveStatic = require('serve-static')
const spinner = ora(
'building for ' + process.env.env_config + ' environment...'
)
spinner.start()
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
if (err) throw err
webpack(webpackConfig, (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'
)
if (stats.hasErrors()) {
console.log(chalk.red(' Build failed with errors.\n'))
process.exit(1)
}
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"
)
)
if (process.env.npm_config_preview) {
const port = 9526
const host = 'http://localhost:' + port
const basePath = config.build.assetsPublicPath
const app = connect()
app.use(
basePath,
serveStatic('./dist', {
index: ['index.html', '/']
})
)
app.listen(port, function() {
console.log(
chalk.green(`> Listening at http://localhost:${port}${basePath}`)
)
})
}
})
})
'use strict'
const chalk = require('chalk')
const semver = require('semver')
const packageConfig = require('../package.json')
const shell = require('shelljs')
function exec(cmd) {
return require('child_process')
.execSync(cmd)
.toString()
.trim()
}
const 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() {
const warnings = []
for (let i = 0; i < versionRequirements.length; i++) {
const 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 (let i = 0; i < warnings.length; i++) {
const warning = warnings[i]
console.log(' ' + warning)
}
console.log()
process.exit(1)
}
}
'use strict'
const path = require('path')
const config = require('../config')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const packageConfig = require('../package.json')
exports.assetsPath = function(_path) {
const assetsSubDirectory =
process.env.NODE_ENV === 'production'
? config.build.assetsSubDirectory
: config.dev.assetsSubDirectory
return path.posix.join(assetsSubDirectory, _path)
}
exports.cssLoaders = function(options) {
options = options || {}
const cssLoader = {
loader: 'css-loader',
options: {
sourceMap: options.sourceMap
}
}
const postcssLoader = {
loader: 'postcss-loader',
options: {
sourceMap: options.sourceMap
}
}
// generate loader string to be used with extract text plugin
function generateLoaders(loader, loaderOptions) {
const loaders = []
// Extract CSS when that option is specified
// (which is the case during production build)
if (options.extract) {
loaders.push(MiniCssExtractPlugin.loader)
} else {
loaders.push('vue-style-loader')
}
loaders.push(cssLoader)
if (options.usePostCSS) {
loaders.push(postcssLoader)
}
if (loader) {
loaders.push({
loader: loader + '-loader',
options: Object.assign({}, loaderOptions, {
sourceMap: options.sourceMap
})
})
}
return 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) {
const output = []
const loaders = exports.cssLoaders(options)
for (const extension in loaders) {
const loader = loaders[extension]
output.push({
test: new RegExp('\\.' + extension + '$'),
use: loader
})
}
return output
}
exports.createNotifierCallback = () => {
const notifier = require('node-notifier')
return (severity, errors) => {
if (severity !== 'error') return
const error = errors[0]
const filename = error.file && error.file.split('!').pop()
notifier.notify({
title: packageConfig.name,
message: severity + ': ' + error.name,
subtitle: filename || '',
icon: path.join(__dirname, 'logo.png')
})
}
}
'use strict'
module.exports = {
//You can set the vue-loader configuration by yourself.
}
'use strict'
const path = require('path')
const utils = require('./utils')
const config = require('../config')
const { VueLoaderPlugin } = require('vue-loader')
const vueLoaderConfig = require('./vue-loader.conf')
function resolve(dir) {
return path.join(__dirname, '..', dir)
}
const createLintingRule = () => ({
test: /\.(js|vue)$/,
loader: 'eslint-loader',
enforce: 'pre',
include: [resolve('src'), resolve('test')],
options: {
formatter: require('eslint-friendly-formatter'),
emitWarning: !config.dev.showEslintErrorsInOverlay
}
})
module.exports = {
context: path.resolve(__dirname, '../'),
entry: {
app: './src/main.js'
},
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: {
'@': resolve('src')
}
},
module: {
rules: [
// ...(config.dev.useEslint ? [createLintingRule()] : []),
{
test: /\.vue$/,
loader: 'vue-loader',
options: vueLoaderConfig
},
{
test: /\.js$/,
loader: 'babel-loader?cacheDirectory',
include: [
resolve('src'),
resolve('test'),
resolve('node_modules/webpack-dev-server/client')
]
},
{
test: /\.svg$/,
loader: 'svg-sprite-loader',
include: [resolve('src/icons')],
options: {
symbolId: 'icon-[name]'
}
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
exclude: [resolve('src/icons')],
options: {
limit: 10000,
name: utils.assetsPath('img/[name].[hash:7].[ext]')
}
},
{
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('media/[name].[hash:7].[ext]')
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
}
]
},
plugins: [new VueLoaderPlugin()],
node: {
// prevent webpack from injecting useless setImmediate polyfill because Vue
// source contains it (although only uses it if it's native).
setImmediate: false,
// prevent webpack from injecting mocks to Node native modules
// that does not make sense for the client
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty'
}
}
'use strict'
const path = require('path')
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const baseWebpackConfig = require('./webpack.base.conf')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
const portfinder = require('portfinder')
function resolve(dir) {
return path.join(__dirname, '..', dir)
}
const HOST = process.env.HOST
const PORT = process.env.PORT && Number(process.env.PORT)
const devWebpackConfig = merge(baseWebpackConfig, {
mode: 'development',
module: {
rules: utils.styleLoaders({
sourceMap: config.dev.cssSourceMap,
usePostCSS: true
})
},
// cheap-module-eval-source-map is faster for development
devtool: config.dev.devtool,
// these devServer options should be customized in /config/index.js
devServer: {
clientLogLevel: 'warning',
historyApiFallback: true,
hot: true,
compress: true,
host: HOST || config.dev.host,
port: PORT || config.dev.port,
open: config.dev.autoOpenBrowser,
overlay: config.dev.errorOverlay
? { warnings: false, errors: true }
: false,
publicPath: config.dev.assetsPublicPath,
proxy: config.dev.proxyTable,
quiet: true, // necessary for FriendlyErrorsPlugin
watchOptions: {
poll: config.dev.poll
}
},
plugins: [
new webpack.DefinePlugin({
'process.env': require('../config/dev.env')
}),
new webpack.HotModuleReplacementPlugin(),
// https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true,
favicon: resolve('favicon.ico'),
title: 'vue-element-admin',
templateParameters: {
BASE_URL: config.dev.assetsPublicPath + config.dev.assetsSubDirectory,
},
}),
]
})
module.exports = new Promise((resolve, reject) => {
portfinder.basePort = process.env.PORT || config.dev.port
portfinder.getPort((err, port) => {
if (err) {
reject(err)
} else {
// publish the new Port, necessary for e2e tests
process.env.PORT = port
// add port to devServer config
devWebpackConfig.devServer.port = port
// Add FriendlyErrorsPlugin
devWebpackConfig.plugins.push(
new FriendlyErrorsPlugin({
compilationSuccessInfo: {
messages: [
`Your application is running here: http://${
devWebpackConfig.devServer.host
}:${port}`
]
},
onErrors: config.dev.notifyOnErrors
? utils.createNotifierCallback()
: undefined
})
)
resolve(devWebpackConfig)
}
})
})
'use strict'
const path = require('path')
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const baseWebpackConfig = require('./webpack.base.conf')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
const portfinder = require('portfinder')
function resolve(dir) {
return path.join(__dirname, '..', dir)
}
const HOST = process.env.HOST
const PORT = process.env.PORT && Number(process.env.PORT)
const devWebpackConfig = merge(baseWebpackConfig, {
mode: 'development',
module: {
rules: utils.styleLoaders({
sourceMap: config.dev.cssSourceMap,
usePostCSS: true
})
},
// cheap-module-eval-source-map is faster for development
devtool: config.dev.devtool,
// these devServer options should be customized in /config/index.js
devServer: {
clientLogLevel: 'warning',
historyApiFallback: true,
hot: true,
compress: true,
host: HOST || config.dev.host,
port: PORT || config.dev.port,
open: config.dev.autoOpenBrowser,
overlay: config.dev.errorOverlay
? { warnings: false, errors: true }
: false,
publicPath: config.dev.assetsPublicPath,
proxy: config.dev.proxyTable,
quiet: true, // necessary for FriendlyErrorsPlugin
watchOptions: {
poll: config.dev.poll
}
},
plugins: [
new webpack.DefinePlugin({
'process.env': require('../config/devxz.env')
}),
new webpack.HotModuleReplacementPlugin(),
// https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true,
favicon: resolve('favicon.ico'),
title: 'vue-element-admin',
templateParameters: {
BASE_URL: config.dev.assetsPublicPath + config.dev.assetsSubDirectory,
},
}),
]
})
module.exports = new Promise((resolve, reject) => {
portfinder.basePort = process.env.PORT || config.dev.port
portfinder.getPort((err, port) => {
if (err) {
reject(err)
} else {
// publish the new Port, necessary for e2e tests
process.env.PORT = port
// add port to devServer config
devWebpackConfig.devServer.port = port
// Add FriendlyErrorsPlugin
devWebpackConfig.plugins.push(
new FriendlyErrorsPlugin({
compilationSuccessInfo: {
messages: [
`Your application is running here: http://${
devWebpackConfig.devServer.host
}:${port}`
]
},
onErrors: config.dev.notifyOnErrors
? utils.createNotifierCallback()
: undefined
})
)
resolve(devWebpackConfig)
}
})
})
'use strict'
const path = require('path')
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const baseWebpackConfig = require('./webpack.base.conf')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const TerserPlugin = require('terser-webpack-plugin')
function resolve(dir) {
return path.join(__dirname, '..', dir)
}
const env = require('../config/' + process.env.env_config + '.env')
// For NamedChunksPlugin
const seen = new Set()
const nameLength = 4
const webpackConfig = merge(baseWebpackConfig, {
mode: 'production',
module: {
rules: utils.styleLoaders({
sourceMap: config.build.productionSourceMap,
extract: true,
usePostCSS: true
})
},
devtool: config.build.productionSourceMap ? config.build.devtool : false,
output: {
path: config.build.assetsRoot,
filename: utils.assetsPath('js/[name].[chunkhash:8].js'),
chunkFilename: utils.assetsPath('js/[name].[chunkhash:8].js')
},
plugins: [
// http://vuejs.github.io/vue-loader/en/workflow/production.html
new webpack.DefinePlugin({
'process.env': env
}),
// extract css into its own file
new MiniCssExtractPlugin({
filename: utils.assetsPath('css/[name].[contenthash:8].css'),
chunkFilename: utils.assetsPath('css/[name].[contenthash:8].css')
}),
// 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,
favicon: resolve('favicon.ico'),
title: 'vue-element-admin',
templateParameters: {
BASE_URL: config.build.assetsPublicPath + config.build.assetsSubDirectory,
},
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
// more options:
// https://github.com/kangax/html-minifier#options-quick-reference
}
// default sort mode uses toposort which cannot handle cyclic deps
// in certain cases, and in webpack 4, chunk order in HTML doesn't
// matter anyway
}),
new ScriptExtHtmlWebpackPlugin({
//`runtime` must same as runtimeChunk name. default is `runtime`
inline: /runtime\..*\.js$/
}),
// keep chunk.id stable when chunk has no name
new webpack.NamedChunksPlugin(chunk => {
if (chunk.name) {
return chunk.name
}
const modules = Array.from(chunk.modulesIterable)
if (modules.length > 1) {
const hash = require('hash-sum')
const joinedHash = hash(modules.map(m => m.id).join('_'))
let len = nameLength
while (seen.has(joinedHash.substr(0, len))) len++
seen.add(joinedHash.substr(0, len))
return `chunk-${joinedHash.substr(0, len)}`
} else {
return modules[0].id
}
}),
// keep module.id stable when vender modules does not change
new webpack.HashedModuleIdsPlugin(),
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.build.assetsSubDirectory,
ignore: ['.*']
}
])
],
optimization: {
splitChunks: {
chunks: 'all',
cacheGroups: {
libs: {
name: 'chunk-libs',
test: /[\\/]node_modules[\\/]/,
priority: 10,
chunks: 'initial' // 只打包初始时依赖的第三方
},
elementUI: {
name: 'chunk-elementUI', // 单独将 elementUI 拆包
priority: 20, // 权重要大于 libs 和 app 不然会被打包进 libs 或者 app
test: /[\\/]node_modules[\\/]element-ui[\\/]/
},
commons: {
name: 'chunk-commons',
test: resolve('src/components'), // 可自定义拓展你的规则
minChunks: 3, // 最小公用次数
priority: 5,
reuseExistingChunk: true
}
}
},
runtimeChunk: 'single',
minimizer: [
new UglifyJsPlugin({
uglifyOptions: {
mangle: {
safari10: true
}
},
sourceMap: config.build.productionSourceMap,
cache: true,
parallel: true,
}),
// Compress extracted CSS. We are using this plugin so that possible
// duplicated CSS from different components can be deduped.
new OptimizeCSSAssetsPlugin(),
new TerserPlugin({
minify: (file, sourceMap) => {
// https://github.com/mishoo/UglifyJS2#minify-options
const uglifyJsOptions = {
/* your `uglify-js` package options */
compress:{
drop_console:true
}
};
if (sourceMap) {
uglifyJsOptions.sourceMap = {
content: sourceMap,
};
}
return require('uglify-js').minify(file, uglifyJsOptions);
},
}),
]
}
})
if (config.build.productionGzip) {
const 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.generateAnalyzerReport || config.build.bundleAnalyzerReport) {
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin
if (config.build.bundleAnalyzerReport) {
webpackConfig.plugins.push(
new BundleAnalyzerPlugin({
analyzerPort: 8080,
generateStatsFile: false
})
)
}
if (config.build.generateAnalyzerReport) {
webpackConfig.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: 'static',
reportFilename: 'bundle-report.html',
openAnalyzer: false
})
);
}
}
module.exports = webpackConfig
module.exports = {
NODE_ENV: '"development"',
ENV_CONFIG: '"dev"',
BASE_API: '"http://qcwx.glsx.com.cn"'//'"http://devwx.glsx.com.cn"'//开发
}
module.exports = {
NODE_ENV: '"development"',
ENV_CONFIG: '"dev"',
BASE_API: '"https://devwx.glsx.com.cn"',
// BASE_API: '"http://192.168.3.145:8088"'
// BASE_API: '"http://192.168.3.243:8088"' //海俊
// BASE_API: '"http://192.168.1.148:8088"' //海覃
// BASE_API: '"http://192.168.1.59:8088"' //霞军
}
\ No newline at end of file
'use strict'
// Template version: 1.2.6
// see http://vuejs-templates.github.io/webpack for documentation.
const path = require('path')
module.exports = {
dev: {
// Paths
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {
// '/list': {
// target: 'https://devwx.glsx.com.cn',
// changeOrigin: true,
// pathRewrite: {
// '^/list': '/list'
// }
// }
},
// Various Dev Server settings
// can be overwritten by process.env.HOST
// if you want dev by ip, please set host: '0.0.0.0'
// host: 'localhost',
host: '127.0.0.1',
port: 9527, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: true,
errorOverlay: true,
notifyOnErrors: false,
poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
// Use Eslint Loader?
// If true, your code will be linted during bundling and
// linting errors and warnings will be shown in the console.
useEslint: true,
// If true, eslint errors and warnings will also be shown in the error overlay
// in the browser.
showEslintErrorsInOverlay: false,
/**
* Source Maps
*/
// https://webpack.js.org/configuration/devtool/#development
devtool: 'eval-source-map',//'cheap-source-map',
// 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
},
build: {
// Template for index.html
index: path.resolve(__dirname, '../dist/index.html'),
// Paths
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
/**
* You can set by youself according to actual condition
* You will need to set this 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 assetsPublicPath should be set to "/bar/".
* In most cases please use '/' !!!
*/
assetsPublicPath: '/',
/**
* Source Maps
*/
productionSourceMap: false,
// https://webpack.js.org/configuration/devtool/#production
devtool: 'source-map',
// 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:prod --report`
// Set to `true` or `false` to always turn it on or off
bundleAnalyzerReport: process.env.npm_config_report || false,
// `npm run build:prod --generate_report`
generateAnalyzerReport: process.env.npm_config_generate_report || false
}
}
module.exports = {
NODE_ENV: '"production"',
ENV_CONFIG: '"prod"',
BASE_API: '"https://bhg.didihu.com.cn"'
}
module.exports = {
NODE_ENV: '"production"',
ENV_CONFIG: '"sit"',
BASE_API: '"https://devwx.glsx.com.cn"',
// BASE_API: '"http://192.168.1.156:8088"'
}
module.exports = {
NODE_ENV: '"production"',
ENV_CONFIG: '"prod"',
BASE_API: '"https://qcwx.glsx.com.cn"'
}
\ No newline at end of file
No preview for this file type
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>包活干</title>
</head>
<body style="min-width:1024px;">
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
{
"name": "vue-element-admin",
"version": "3.9.3",
"description": "A magical vue admin. Typical templates for enterprise applications. Newest development stack of vue. Lots of awesome features",
"author": "Pan <panfree23@gmail.com>",
"license": "MIT",
"scripts": {
"dev": "cross-env BABEL_ENV=development webpack-dev-server --open chrome --inline --progress --config build/webpack.dev.conf.js",
"dev:xz": "cross-env BABEL_ENV=development webpack-dev-server --open chrome --inline --progress --config build/webpack.devxz.conf.js",
"build:prod": "cross-env NODE_ENV=production env_config=prod node build/build.js",
"build:dev": "cross-env NODE_ENV=production env_config=sit node build/build.js",
"build:test": "cross-env NODE_ENV=production env_config=test node build/build.js",
"lint": "eslint --ext .js,.vue src",
"test": "npm run lint",
"precommit": "lint-staged",
"svgo": "svgo -f src/icons/svg --config=src/icons/svgo.yml"
},
"lint-staged": {
"src/**/*.{js,vue}": [
"eslint --fix",
"git add"
]
},
"keywords": [
"vue",
"element-ui",
"admin",
"management-system",
"admin-template"
],
"repository": {
"type": "git",
"url": "git+https://github.com/PanJiaChen/vue-element-admin.git"
},
"bugs": {
"url": "https://github.com/PanJiaChen/vue-element-admin/issues"
},
"dependencies": {
"axios": "0.18.0",
"babel-runtime": "^6.26.0",
"clipboard": "1.7.1",
"codemirror": "5.39.2",
"connect": "3.6.6",
"driver.js": "0.5.2",
"dropzone": "5.2.0",
"echarts": "4.1.0",
"element-china-area-data": "^4.1.1",
"element-ui": "2.11.0",
"file-saver": "1.3.8",
"font-awesome": "4.7.0",
"js-cookie": "2.2.0",
"jsonlint": "1.6.3",
"jszip": "3.1.5",
"mockjs": "1.0.1-beta3",
"moment": "^2.26.0",
"normalize.css": "7.0.0",
"nprogress": "0.2.0",
"screenfull": "3.3.3",
"showdown": "1.8.6",
"simplemde": "1.11.2",
"sortablejs": "1.7.0",
"svg-baker-runtime": "^1.4.0",
"vue": "2.5.17",
"vue-count-to": "1.0.13",
"vue-i18n": "7.3.2",
"vue-router": "3.0.1",
"vue-splitpane": "1.0.2",
"vuedraggable": "^2.16.0",
"vuex": "3.0.1",
"xlsx": "^0.11.16"
},
"devDependencies": {
"autoprefixer": "8.5.0",
"babel-core": "6.26.3",
"babel-eslint": "8.2.6",
"babel-helper-vue-jsx-merge-props": "2.0.3",
"babel-loader": "7.1.5",
"babel-plugin-dynamic-import-node": "2.0.0",
"babel-plugin-syntax-jsx": "6.18.0",
"babel-plugin-transform-runtime": "6.23.0",
"babel-plugin-transform-vue-jsx": "3.7.0",
"babel-preset-env": "1.7.0",
"babel-preset-stage-2": "6.24.1",
"chalk": "2.4.1",
"copy-webpack-plugin": "4.5.2",
"cross-env": "5.2.0",
"css-loader": "1.0.0",
"eslint": "4.19.1",
"eslint-friendly-formatter": "4.0.1",
"eslint-loader": "2.0.0",
"eslint-plugin-vue": "4.7.1",
"file-loader": "1.1.11",
"friendly-errors-webpack-plugin": "1.7.0",
"hash-sum": "1.0.2",
"html-webpack-plugin": "4.0.0-alpha",
"husky": "0.14.3",
"lint-staged": "7.2.2",
"mini-css-extract-plugin": "0.4.1",
"node-notifier": "5.2.1",
"node-sass": "^4.7.2",
"optimize-css-assets-webpack-plugin": "5.0.0",
"ora": "3.0.0",
"path-to-regexp": "2.4.0",
"portfinder": "1.0.13",
"postcss-import": "11.1.0",
"postcss-loader": "2.1.6",
"postcss-url": "7.3.2",
"rimraf": "2.6.2",
"sass-loader": "7.0.3",
"script-ext-html-webpack-plugin": "2.0.1",
"script-loader": "0.7.2",
"semver": "5.5.0",
"serve-static": "1.13.2",
"shelljs": "0.8.2",
"svg-sprite-loader": "3.8.0",
"svgo": "1.0.5",
"terser-webpack-plugin": "^1.2.3",
"uglifyjs-webpack-plugin": "1.2.7",
"url-loader": "1.0.1",
"vue-loader": "15.3.0",
"vue-style-loader": "4.1.2",
"vue-template-compiler": "2.5.17",
"webpack": "4.16.5",
"webpack-bundle-analyzer": "2.13.1",
"webpack-cli": "3.1.0",
"webpack-dev-server": "3.1.5",
"webpack-merge": "4.1.4"
},
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}
<template>
<div id="app">
<router-view/>
</div>
</template>
<script>
export default{
name: 'App'
}
</script>
import request from '@/utils/request'
// request.defaults.withCredentials=true;//当前实例request全局设置 让ajax携带cookie
export function loginByUsername(username, password) {
const data = {
username,
password,
'terminalType':0,
}
return request({
url: '/carservice/usercenter/user/login',
method: 'post',
// `params` 是即将与请求一起发送的 URL 参数。 必须是一个无格式对象(plain object)或 URLSearchParams 对象
params: data,
// data: qs.stringify(data), //完美方案,post请求,键值对提交,url不带参数
})
}
export function logout() {
return request({
url: '/carservice/usercenter/user/logout',
method: 'get'
})
}
export function getUserInfo() {
return request({
url: '/carservice/usercenter/user/isLogin',
method: 'get',
})
}
export function getUserInfoForOrder(data) {
return request({
url: '/carservice/usercenter/user/getCurrentUserInfo',
method: 'get',
params: data
})
}
import request from '@/utils/request'
export function getUserPermission(data) {
return request({
url: '/carservice/usercenter/sysMenu/getUserPermissionMenuList',
method: 'get',
params: data
})
}
\ No newline at end of file
const apiData = {
getCarOrderAboutCounts: '/carservice/ordercenter/carOrder/countByServiceItem',
/* 资料管理 */
getMaterialCounts: '/carservice/ordercenter/delivery/countByStatus',
getMaterialList: '/carservice/ordercenter/delivery/getList',
addLogistics: '/carservice/ordercenter/delivery/save',
sendLogistics: '/carservice/ordercenter/delivery/send',
receiveLogistics: '/carservice/ordercenter/delivery/receive',
cancelLogistics: '/carservice/ordercenter/delivery/cancel',
exportMaterialList: '/carservice/ordercenter/report/exportDelivery',
/* 车务单 */
getCarOrderList: '/carservice/ordercenter/carOrder/getList',
getCarOrderCounts: '/carservice/ordercenter/carOrder/countByStatus',
exportCarOrderList: '/carservice/ordercenter/report/exportCarOrder',
saveCarOrder: '/carservice/ordercenter/carOrder/save',
getCarOrderDetail: '/carservice/ordercenter/carOrder/getDetail',
cancelCarOrder: '/carservice/ordercenter/carOrder/cancel',
getCarOrderServiceItem: 'carservice/ordercenter/serviceItme/getListByUserAndType',//'/carservice/usercenter/user/getMerchantCarServiceItem',
/* 车务子单 */
getSubCarOrderList: '/carservice/ordercenter/carOrder/getSubOrderList',
getSubCarOrderCounts: '/carservice/ordercenter/carOrder/countSubOrderByStatus',
cancelSubCarOrder: '/carservice/ordercenter/carOrder/cancelSubOrder',
getSubCarOrderFile: '/carservice/ordercenter/carOrder/getSubOrderFile',
}
export default apiData
\ No newline at end of file
This diff could not be displayed because it is too large.
No preview for this file type
<template>
<div :class="center == 'editCenter'?'fix-dialog-height':''" class="app-add-dialog">
<div :class="heightClass" :style="heightStyle" v-if="noCache">
<el-dialog
v-dialogDrag
ref='dialog'
v-if="dialogVisible"
:title="title"
:visible.sync="dialogVisible"
:width="diaWidth"
:top="diaTop"
:showClose='isShowClose'
:before-close="handleClose"
>
<div ref='dialogTitle' v-if="title == 'editTitle'" slot="title">
<slot name="titleOut"/>
</div>
<div ref='dialogCenter' :class="center == 'editCenter'?'center-out':''" class="container">
<slot name="center"/>
</div>
<div ref='dialogFooter' v-if="footer == 'editFooter'" slot="footer" class="dialog-footer footer-out">
<slot name="footerOut"/>
</div>
<span ref='dialogFooter' v-else slot="footer" class="dialog-footer">
<el-button v-if="isShowCancel" @click="hideDialog">取 消</el-button>
<el-button v-if="isShowConfirm" :disabled="isDisable" type="primary" @click="handleComfrim">确 定</el-button>
</span>
</el-dialog>
</div>
<div :class="heightClass" v-else>
<el-dialog
v-dialogDrag
ref='dialog'
:title="title"
:visible.sync="dialogVisible"
:width="diaWidth"
:top="diaTop"
:showClose='isShowClose'
:before-close="handleClose"
>
<div ref='dialogTitle' v-if="title == 'editTitle'" slot="title">
<slot name="titleOut"/>
</div>
<div ref='dialogCenter' :class="center == 'editCenter'?'center-out':''" class="container">
<slot name="center"/>
</div>
<div ref='dialogFooter' v-if="footer == 'editFooter'" slot="footer" class="dialog-footer footer-out">
<slot name="footerOut"/>
</div>
<span ref='dialogFooter' v-else slot="footer" class="dialog-footer">
<el-button v-if="isShowCancel" @click="hideDialog">取 消</el-button>
<el-button v-if="isShowConfirm" :disabled="isDisable" type="primary" @click="handleComfrim">{{footerName}}</el-button>
<slot name="btnSlot"></slot>
</span>
</el-dialog>
</div>
</div>
</template>
<script>
import '@/directive/directives.js'
export default {
props: {
noCache: {
type: Boolean,
default: false
},
isDisable: {
type: Boolean,
default: false
},
isVisible: {
type: Boolean,
default: false
},
isCloseNoComfrimAgain: {
type: Boolean,
default: false
},
isShowClose: {
type: Boolean,
default: true
},
isShowCancel: {
type: Boolean,
default: true
},
isShowConfirm: {
type: Boolean,
default: true
},
diaWidth: {
type: String,
default: '40%'
},
diaTop: {
type: String,
default: '50px'
},
heightClass: {
type: String,
default: ''
},
heightStyle: {
type: Object,
default: ()=>{
return {}
}
},
title: {
type: String,
default: '提示'
},
center: {
type: String,
default: ''
},
footer: {
type: String,
default: ''
},
footerName:{
type: String,
default: '确 定'
}
},
data() {
return {
dialogVisible: false,
isDisableState:false,
}
},
// computed:{
// dialogVisible: {
// get(){
// console.log('get')
// return this.isVisible
// },
// set(){
// console.log('set')
// this.isVisible = false
// return false
// }
// }
// },
watch: {
isVisible(val) {
this.dialogVisible = val
}
},
created() {
},
methods: {
handleClose(done) {
// console.log("gua");
if (this.isCloseNoComfrimAgain) {
this.$emit('hideDialog')
done()
} else {
this.$confirm('确认关闭?')
.then(_ => {
this.$emit('hideDialog')
done()
})
.catch(_ => {})
}
},
handleComfrim() {
// this.dialogVisible = false;
// console.log("子点击了确认按钮");
// this.isDisableState = true;
// setTimeout(()=>{
// this.isDisableState = false;
// },2000)
this.$emit('comfrim-click')
},
hideDialog() {
this.$emit('hideDialog')
}
}
}
</script>
<style rel="stylesheet/scss" lang="scss" >
.app-add-dialog {
.el-dialog__header {
padding: 20px;
}
.el-dialog__footer {
padding: 10px;
background: #fff;
}
&.fix-dialog-height{
.el-dialog__body {
height: 400px !important;
}
}
.move-dialog-height{
.el-dialog__body {
height: 590px !important;
max-height: 800px !important;
}
}
.move-dialog-height-500{
.el-dialog__body {
height: 500px !important;
max-height: 800px !important;
}
}
.el-dialog__body {
padding: 0;
border-top: 1px solid #eaeefb;
border-bottom: 1px solid #eaeefb;
min-height: 250px;
max-height: 500px;
overflow-y: auto;
.container {
> span {
display: block;
}
overflow-y: auto;
padding: 20px 20px;
.el-radio {
height: 40px;
line-height: 40px;
}
}
.center-out{
&.container {
padding: 0;
}
}
}
.footer-out{
width: 100%;
.el-pagination__total{
float: left;
}
}
.hide-dialog-header{
.el-dialog__header{
// height: 2px;
display:none;
}
}
}
</style>
<template>
<el-breadcrumb class="app-breadcrumb" separator="/">
<transition-group name="breadcrumb">
<el-breadcrumb-item v-for="(item,index) in levelList" :key="index">
<!-- <div> -->
<template v-if="item.meta.title" >
<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>
</template>
<!-- </div> -->
</el-breadcrumb-item>
</transition-group>
</el-breadcrumb>
</template>
<script>
import pathToRegexp from 'path-to-regexp'
export default {
data() {
return {
levelList: null
}
},
watch: {
$route() {
this.getBreadcrumb()
}
},
created() {
this.getBreadcrumb()
},
methods: {
getBreadcrumb() {
//console.log(this.$route,'this.$route.matched');
let matched = this.$route.matched.filter(item => {
if (item.name) {
return true
}
})
const first = matched[0]
if (first && first.name.trim().toLocaleLowerCase() !== 'Dashboard'.toLocaleLowerCase()) {
matched = [{ path: '/dashboard', meta: { title: '首页' }}].concat(matched)
}
this.levelList = matched
},
pathCompile(path) {
// To solve this problem https://github.com/PanJiaChen/vue-element-admin/issues/561
const { params } = this.$route
var toPath = pathToRegexp.compile(path)
return toPath(params)
},
handleLink(item) {
//禁止点击
return
const { redirect, path } = item
if (redirect) {
this.$router.push(redirect)
return
}
this.$router.push(this.pathCompile(path))
}
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.app-breadcrumb.el-breadcrumb {
display: inline-block;
font-size: 14px;
line-height: 50px;
margin-left: 10px;
.no-redirect {
color: #97a8be;
cursor: text;
}
}
</style>
<template>
<div >
<div id="barChart" :style="styleInner"></div>
</div>
</template>
<script>
// 引入 ECharts 主模块
var echarts = require('echarts/lib/echarts');
// 引入柱状图
require('echarts/lib/chart/bar');
// 引入提示框和标题组件
require('echarts/lib/component/tooltip');
require('echarts/lib/component/title');
export default {
name: 'barChart',
data () {
return {
}
},
props:{
optionsInner: {
type: Object,
default:() => {
return {}
}
},
styleInner: {
type: Object,
default:() => {
return {width: '600px', height: '300px'}
}
},
},
watch:{
optionsInner:{
handler(newVal,oldVal){
console.log(newVal,'-------------------------------newval')
console.log(oldVal,'-------------------------------oldVal')
this.drawLine(newVal)
},
deep:true,
}
},
mounted(){
this.drawLine();
},
methods: {
drawLine(data){
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('barChart'));
// 绘制图表
// myChart.setOption(data);
// return
myChart.setOption(this.optionsFunc(data));
window.addEventListener('resize',function(){
myChart.resize()
})
},
optionsFunc(data){
if(data){
var serData = data&&data.series? data.series[0].data:[]
var serXaxis = data&&data.xAxis?data.xAxis[0].data:[]
var seriesData = serData
var nullLength = serXaxis.length - seriesData.length;
var nullArr = []
for(var i = 0 ;i<nullLength;i++){
nullArr.push('-')
}
var xAxisData = [...serXaxis].splice(0,seriesData.length).concat(nullArr)
// xAxisData = xAxisData.splice(0,seriesData.length)
}else{
var seriesData = []
var xAxisData = []
}
return {
color: ['#409EFF'],
// title: { text: '业务量趋势' ,
// textStyle:{
// fontSize:16,
// color:'#000',
// fontWeight:'normal',
// },},
tooltip : {
trigger: 'axis',
axisPointer : { // 坐标轴指示器,坐标轴触发有效
type : 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
grid: {
top:'10',
left: '0',
right: '80',
bottom: '3%',
containLabel: true
},
xAxis : [
{
type : 'category',
data : xAxisData,
axisTick: {
alignWithLabel: true
}
}
],
yAxis : [
{
type : 'value',
scale:true,
min:0,
// max:1000,
splitNumber:5,
}
],
series : [
{
name:'业务量',
type:'bar',
barWidth: '60%',
data:seriesData
}
]
}
}
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
</style>
<template>
<div >
<div :id="id" :style="styleInner"></div>
</div>
</template>
<script>
// 引入 ECharts 主模块
var echarts = require('echarts/lib/echarts');
// 引入柱状图
require('echarts/lib/chart/line');
// 引入提示框和标题组件
require('echarts/lib/component/tooltip');
require('echarts/lib/component/title');
export default {
name: 'lineChart',
data () {
return {
newVal:undefined,
}
},
props:{
id: {
type: String,
default:'lineChart'
},
optionsInner: {
type: Object,
default:() => {
return {}
}
},
styleInner: {
type: Object,
default:() => {
return {width: '200px', height: '100px'}
}
},
},
computed:{
isOpend(){
return this.$store.getters.sidebar.opened
}
},
watch:{
optionsInner:{
handler(newVal,oldVal){
console.log(newVal,'------------line-------------------newval')
console.log(oldVal,'-------------------------------oldVal')
this.drawLine(newVal);
this.$set(this,'newVal',newVal)
},
deep:true,
},
isOpend(nn,old){
console.log(this.newVal,'drawLine');
// this.drawLine(this.newVal);
}
},
mounted(){
this.drawLine();
},
methods: {
drawLine(data){
console.log(data,'drawLine');
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById(this.id),'light');
// 绘制图表
myChart.setOption(this.optionsFunc(data));
window.addEventListener('resize',function(){
myChart.resize()
})
},
optionsFunc(data){
let seriesData,xAxisData;
if(data){
var serData = data&&data.series? data.series[0].data:[]
var serXaxis = data&&data.xAxis?data.xAxis.data:[]
seriesData = serData
var nullLength = serXaxis.length - seriesData.length;
var nullArr = []
for(var i = 0 ;i<nullLength;i++){
nullArr.push('-')
}
xAxisData = [...serXaxis].splice(0,seriesData.length).concat(nullArr)
}else{
seriesData = [0];
xAxisData = [0];
}
return {
grid: {
right: '20',
top: '15',
},
tooltip: {
trigger: 'item',
formatter: "{c}",
backgroundColor:'#5E77FF',
borderColor: 'red',
borderWidth:0,
padding: [5,15],
},
xAxis: {
show: true,
type: 'category',
data: xAxisData,
axisLine:{
lineStyle:{
color: '#808285',
}
},
},
yAxis: {
type: 'value',
show: true,
axisLine:{
lineStyle:{
color: '#808285',
}
},
},
series: [{
data: seriesData,
type: 'line',
symbol:'circle', //这句就是去掉点的
symbolSize: 3,
itemStyle: {
borderColor: '#5E77FF',
color: '#5E77FF',
},
smooth: true,
lineStyle:{
color:'#5E77FF',
width:0,
},
areaStyle: {
color:'#5E77FF',
}
}]
};
},
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
</style>
<template>
<div>
<div id="pieChart" :style="styleInner"></div>
</div>
</template>
<script>
// 引入 ECharts 主模块
var echarts = require('echarts/lib/echarts');
// 引入柱状图
require('echarts/lib/chart/pie');
// 引入提示框和标题组件
require('echarts/lib/component/tooltip');
require('echarts/lib/component/title');
require("echarts/lib/component/legendScroll");
export default {
name: 'pieChart',
data () {
return {
}
},
props:{
optionsInner: {
type: Object,
default:() => {
return {}
}
},
styleInner: {
type: Object,
default:() => {
return {width: '1000px', height: '500px'}
}
},
},
watch:{
optionsInner:{
handler(newVal,oldVal){
console.log(newVal,'-------------------------------pie newval')
console.log(oldVal,'-------------------------------pie oldVal')
this.drawLine(newVal)
},
deep:true,
}
},
mounted(){
this.drawLine();
},
methods: {
drawLine(data){
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('pieChart'),'light');
// 绘制图表
myChart.setOption(this.optionsFunc(data));
window.addEventListener('resize',function(){
myChart.resize()
})
},
optionsFunc(data){
if(data&&data.series){
var seriesData = data.series[0].data
var amount = data.title.subtext
var legendData = data.legend.data
var legendFormat = data.legend.formatter
}else{
var seriesData = []
var amount = 0
var legendData = []
var legendFormat = ''
}
return {
title: {
text:'业务量',
textAlign: 'center',
textVerticalAlign: 'center',
subtext: amount,
itemGap:25,
textStyle:{
fontSize:16,
color:'#97a8be',
},
subtextStyle:{
fontSize:24,
color:'#000'
},
left: '29.5%',
top: '40%',
},
tooltip: {
trigger: 'item',
formatter: "{a} <br/>{b}: {c} ({d}%)",
},
legend: {
type: 'scroll',
orient: 'vertical',
right: 20,
top:30,
itemWidth:20,
itemHeight:10,
itemGap:15,
textStyle:{
fontSize:16,
},
data:legendData,
formatter: legendFormat
},
series: [
{
name:'业务量',
type:'pie',
radius: ['55%', '70%'],
center: ['30%', '50%'],
avoidLabelOverlap: false,
label: {
normal: {
show: false,
position: 'center'
},
emphasis: {
show: false,
textStyle: {
fontSize: '30',
fontWeight: 'bold'
}
}
},
labelLine: {
normal: {
show: false
}
},
data:seriesData
}
]
}
},
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
</style>
<template>
<div>
<svg
:class="{'is-active':isActive}"
t="1492500959545"
class="hamburger"
style=""
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="1691"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="64"
height="64"
@click="toggleClick">
<path
d="M966.8023 568.849776 57.196677 568.849776c-31.397081 0-56.850799-25.452695-56.850799-56.850799l0 0c0-31.397081 25.452695-56.849776 56.850799-56.849776l909.605623 0c31.397081 0 56.849776 25.452695 56.849776 56.849776l0 0C1023.653099 543.397081 998.200404 568.849776 966.8023 568.849776z"
p-id="1692"/>
<path
d="M966.8023 881.527125 57.196677 881.527125c-31.397081 0-56.850799-25.452695-56.850799-56.849776l0 0c0-31.397081 25.452695-56.849776 56.850799-56.849776l909.605623 0c31.397081 0 56.849776 25.452695 56.849776 56.849776l0 0C1023.653099 856.07443 998.200404 881.527125 966.8023 881.527125z"
p-id="1693"/>
<path
d="M966.8023 256.17345 57.196677 256.17345c-31.397081 0-56.850799-25.452695-56.850799-56.849776l0 0c0-31.397081 25.452695-56.850799 56.850799-56.850799l909.605623 0c31.397081 0 56.849776 25.452695 56.849776 56.850799l0 0C1023.653099 230.720755 998.200404 256.17345 966.8023 256.17345z"
p-id="1694"/>
</svg>
</div>
</template>
<script>
export default {
name: 'Hamburger',
props: {
isActive: {
type: Boolean,
default: false
},
toggleClick: {
type: Function,
default: null
}
}
}
</script>
<style scoped>
.hamburger {
display: inline-block;
cursor: pointer;
width: 20px;
height: 20px;
transform: rotate(90deg);
transition: .38s;
transform-origin: 50% 50%;
}
.hamburger.is-active {
transform: rotate(0deg);
}
</style>
<template>
<div :class="computedClasses" class="material-input__component">
<div :class="{iconClass:icon}">
<i v-if="icon" :class="['el-icon-' + icon]" class="el-input__icon material-input__icon"/>
<input
v-if="type === 'email'"
:name="name"
:placeholder="fillPlaceHolder"
v-model="currentValue"
:readonly="readonly"
:disabled="disabled"
:autoComplete="autoComplete"
:required="required"
type="email"
class="material-input"
@focus="handleMdFocus"
@blur="handleMdBlur"
@input="handleModelInput">
<input
v-if="type === 'url'"
:name="name"
:placeholder="fillPlaceHolder"
v-model="currentValue"
:readonly="readonly"
:disabled="disabled"
:autoComplete="autoComplete"
:required="required"
type="url"
class="material-input"
@focus="handleMdFocus"
@blur="handleMdBlur"
@input="handleModelInput">
<input
v-if="type === 'number'"
:name="name"
:placeholder="fillPlaceHolder"
v-model="currentValue"
:step="step"
:readonly="readonly"
:disabled="disabled"
:autoComplete="autoComplete"
:max="max"
:min="min"
:minlength="minlength"
:maxlength="maxlength"
:required="required"
type="number"
class="material-input"
@focus="handleMdFocus"
@blur="handleMdBlur"
@input="handleModelInput">
<input
v-if="type === 'password'"
:name="name"
:placeholder="fillPlaceHolder"
v-model="currentValue"
:readonly="readonly"
:disabled="disabled"
:autoComplete="autoComplete"
:max="max"
:min="min"
:required="required"
type="password"
class="material-input"
@focus="handleMdFocus"
@blur="handleMdBlur"
@input="handleModelInput">
<input
v-if="type === 'tel'"
:name="name"
:placeholder="fillPlaceHolder"
v-model="currentValue"
:readonly="readonly"
:disabled="disabled"
:autoComplete="autoComplete"
:required="required"
type="tel"
class="material-input"
@focus="handleMdFocus"
@blur="handleMdBlur"
@input="handleModelInput">
<input
v-if="type === 'text'"
:name="name"
:placeholder="fillPlaceHolder"
v-model="currentValue"
:readonly="readonly"
:disabled="disabled"
:autoComplete="autoComplete"
:minlength="minlength"
:maxlength="maxlength"
:required="required"
type="text"
class="material-input"
@focus="handleMdFocus"
@blur="handleMdBlur"
@input="handleModelInput">
<span class="material-input-bar"/>
<label class="material-label">
<slot/>
</label>
</div>
</div>
</template>
<script>
// source:https://github.com/wemake-services/vue-material-input/blob/master/src/components/MaterialInput.vue
export default {
name: 'MdInput',
props: {
/* eslint-disable */
icon: String,
name: String,
type: {
type: String,
default: 'text'
},
value: [String, Number],
placeholder: String,
readonly: Boolean,
disabled: Boolean,
min: String,
max: String,
step: String,
minlength: Number,
maxlength: Number,
required: {
type: Boolean,
default: true
},
autoComplete: {
type: String,
default: 'off'
},
validateEvent: {
type: Boolean,
default: true
}
},
data() {
return {
currentValue: this.value,
focus: false,
fillPlaceHolder: null
}
},
computed: {
computedClasses() {
return {
'material--active': this.focus,
'material--disabled': this.disabled,
'material--raised': Boolean(this.focus || this.currentValue) // has value
}
}
},
watch: {
value(newValue) {
this.currentValue = newValue
}
},
methods: {
handleModelInput(event) {
const value = event.target.value
this.$emit('input', value)
if (this.$parent.$options.componentName === 'ElFormItem') {
if (this.validateEvent) {
this.$parent.$emit('el.form.change', [value])
}
}
this.$emit('change', value)
},
handleMdFocus(event) {
this.focus = true
this.$emit('focus', event)
if (this.placeholder && this.placeholder !== '') {
this.fillPlaceHolder = this.placeholder
}
},
handleMdBlur(event) {
this.focus = false
this.$emit('blur', event)
this.fillPlaceHolder = null
if (this.$parent.$options.componentName === 'ElFormItem') {
if (this.validateEvent) {
this.$parent.$emit('el.form.blur', [this.currentValue])
}
}
}
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
// Fonts:
$font-size-base: 16px;
$font-size-small: 18px;
$font-size-smallest: 12px;
$font-weight-normal: normal;
$font-weight-bold: bold;
$apixel: 1px;
// Utils
$spacer: 12px;
$transition: 0.2s ease all;
$index: 0px;
$index-has-icon: 30px;
// Theme:
$color-white: white;
$color-grey: #9E9E9E;
$color-grey-light: #E0E0E0;
$color-blue: #2196F3;
$color-red: #F44336;
$color-black: black;
// Base clases:
%base-bar-pseudo {
content: '';
height: 1px;
width: 0;
bottom: 0;
position: absolute;
transition: $transition;
}
// Mixins:
@mixin slided-top() {
top: - ($font-size-base + $spacer);
left: 0;
font-size: $font-size-base;
font-weight: $font-weight-bold;
}
// Component:
.material-input__component {
margin-top: 36px;
position: relative;
* {
box-sizing: border-box;
}
.iconClass {
.material-input__icon {
position: absolute;
left: 0;
line-height: $font-size-base;
color: $color-blue;
top: $spacer;
width: $index-has-icon;
height: $font-size-base;
font-size: $font-size-base;
font-weight: $font-weight-normal;
pointer-events: none;
}
.material-label {
left: $index-has-icon;
}
.material-input {
text-indent: $index-has-icon;
}
}
.material-input {
font-size: $font-size-base;
padding: $spacer $spacer $spacer - $apixel * 10 $spacer / 2;
display: block;
width: 100%;
border: none;
line-height: 1;
border-radius: 0;
&:focus {
outline: none;
border: none;
border-bottom: 1px solid transparent; // fixes the height issue
}
}
.material-label {
font-weight: $font-weight-normal;
position: absolute;
pointer-events: none;
left: $index;
top: 0;
transition: $transition;
font-size: $font-size-small;
}
.material-input-bar {
position: relative;
display: block;
width: 100%;
&:before {
@extend %base-bar-pseudo;
left: 50%;
}
&:after {
@extend %base-bar-pseudo;
right: 50%;
}
}
// Disabled state:
&.material--disabled {
.material-input {
border-bottom-style: dashed;
}
}
// Raised state:
&.material--raised {
.material-label {
@include slided-top();
}
}
// Active state:
&.material--active {
.material-input-bar {
&:before,
&:after {
width: 50%;
}
}
}
}
.material-input__component {
background: $color-white;
.material-input {
background: none;
color: $color-black;
text-indent: $index;
border-bottom: 1px solid $color-grey-light;
}
.material-label {
color: $color-grey;
}
.material-input-bar {
&:before,
&:after {
background: $color-blue;
}
}
// Active state:
&.material--active {
.material-label {
color: $color-blue;
}
}
// Errors:
&.material--has-errors {
&.material--active .material-label {
color: $color-red;
}
.material-input-bar {
&:before,
&:after {
background: transparent;
}
}
}
}
</style>
<template>
<div :style="{height:height+'px',zIndex:zIndex}" class="simplemde-container">
<textarea :id="id"/>
</div>
</template>
<script>
import 'font-awesome/css/font-awesome.min.css'
import 'simplemde/dist/simplemde.min.css'
import SimpleMDE from 'simplemde'
export default {
name: 'SimplemdeMd',
props: {
value: {
type: String,
default: ''
},
id: {
type: String,
required: false,
default: 'markdown-editor-' + +new Date()
},
autofocus: {
type: Boolean,
default: false
},
placeholder: {
type: String,
default: ''
},
height: {
type: Number,
default: 150
},
zIndex: {
type: Number,
default: 10
},
toolbar: {
type: Array,
default: function() {
return []
}
}
},
data() {
return {
simplemde: null,
hasChange: false
}
},
watch: {
value(val) {
if (val === this.simplemde.value() && !this.hasChange) return
this.simplemde.value(val)
}
},
mounted() {
this.simplemde = new SimpleMDE({
element: document.getElementById(this.id),
autoDownloadFontAwesome: false,
autofocus: this.autofocus,
toolbar: this.toolbar.length > 0 ? this.toolbar : undefined,
spellChecker: false,
insertTexts: {
link: ['[', ']( )']
},
// hideIcons: ['guide', 'heading', 'quote', 'image', 'preview', 'side-by-side', 'fullscreen'],
placeholder: this.placeholder
})
if (this.value) {
this.simplemde.value(this.value)
}
this.simplemde.codemirror.on('change', () => {
if (this.hasChange) {
this.hasChange = true
}
this.$emit('input', this.simplemde.value())
})
},
destroyed() {
this.simplemde.toTextArea()
this.simplemde = null
}
}
</script>
<style scoped>
.simplemde-container>>>.CodeMirror {
min-height: 150px;
line-height: 20px;
}
.simplemde-container>>>.CodeMirror-scroll {
min-height: 150px;
}
.simplemde-container>>>.CodeMirror-code {
padding-bottom: 40px;
}
.simplemde-container>>>.editor-statusbar {
display: none;
}
.simplemde-container>>>.CodeMirror .CodeMirror-code .cm-link {
color: #1890ff;
}
.simplemde-container>>>.CodeMirror .CodeMirror-code .cm-string.cm-url {
color: #2d3b4d;
}
.simplemde-container>>>.CodeMirror .CodeMirror-code .cm-formatting-link-string.cm-url {
padding: 0 2px;
color: #E61E1E;
}
.simplemde-container >>> .editor-toolbar.fullscreen,
.simplemde-container >>> .CodeMirror-fullscreen {
z-index: 1003;
}
</style>
<template>
<div :class="{'hidden':hidden}" class="pagination-container">
<el-pagination
:background="background"
:current-page.sync="currentPage"
:page-size.sync="pageSize"
:layout="layout"
:total="total"
v-bind="$attrs"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"/>
</div>
</template>
<script>
import { scrollTo } from '@/utils/scrollTo'
export default {
name: 'Pagination',
props: {
total: {
required: true,
type: Number
},
page: {
type: Number,
default: 1
},
limit: {
type: Number,
default: 20
},
pageSizes: {
type: Array,
default() {
return [10, 20, 30, 50]
}
},
layout: {
type: String,
default: 'total, sizes, prev, pager, next, jumper'
},
background: {
type: Boolean,
default: true
},
autoScroll: {
type: Boolean,
default: true
},
hidden: {
type: Boolean,
default: false
}
},
computed: {
currentPage: {
get() {
return this.page
},
set(val) {
this.$emit('update:page', val)
}
},
pageSize: {
get() {
return this.limit
},
set(val) {
this.$emit('update:limit', val)
}
}
},
methods: {
handleSizeChange(val) {
this.$emit('pagination', { page: this.currentPage, limit: val })
if (this.autoScroll) {
scrollTo(0, 800)
}
},
handleCurrentChange(val) {
this.$emit('pagination', { page: val, limit: this.pageSize })
if (this.autoScroll) {
scrollTo(0, 800)
}
}
}
}
</script>
<style scoped>
.pagination-container {
background: #fff;
padding: 32px 16px;
}
.pagination-container.hidden {
display: none;
}
</style>
<template>
<div class="app-permission-button">
<el-button
v-for="(item,index) in btnData"
:key="index"
:type="item.type"
@click="btnClick(item.pType,rowIndex,btnType)"
:style="{'margin':item.type=='text'?'0 10px 0 0':'0px 10px 20px 0'}"
><span v-if="item.type!='text'">+&nbsp;</span>
<span mytype='btn'>{{item.name}}</span>
</el-button>
<!-- :style="{'margin':item.type=='text'?'0 10px 0 0':'0px 10px 20px 0','padding':item.type=='text'?'0':''}" -->
</div>
</template>
<script>
export default {
data() {
return {
};
},
props: {
btnData: {
type: Array,
default: {}
},
rowIndex: {
type: String,
default: ''
},
btnType : {
type: String,
default: ''
},
},
watch: {
},
created() {},
methods: {
btnClick(pType,rowIndex,btnType) {
// console.log(btnType,'permission')
this.$emit("btnClick",pType,rowIndex,btnType);
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" >
</style>
<template>
<div>
<svg
t="1508738709248"
class="screenfull-svg"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="2069"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="32"
height="32"
@click="click">
<path
d="M333.493443 428.647617 428.322206 333.832158 262.572184 168.045297 366.707916 64.444754 64.09683 64.444754 63.853283 366.570793 167.283957 262.460644Z"
p-id="2070"/>
<path
d="M854.845439 760.133334 688.61037 593.95864 593.805144 688.764889 759.554142 854.56096 655.44604 958.161503 958.055079 958.161503 958.274066 656.035464Z"
p-id="2071"/>
<path
d="M688.535669 428.550403 854.31025 262.801405 957.935352 366.921787 957.935352 64.34754 655.809313 64.081481 759.919463 167.535691 593.70793 333.731874Z"
p-id="2072"/>
<path
d="M333.590658 594.033341 167.8171 759.804852 64.218604 655.67219 64.218604 958.270996 366.342596 958.502263 262.234493 855.071589 428.421466 688.86108Z"
p-id="2073"/>
</svg>
</div>
</template>
<script>
import screenfull from 'screenfull'
export default {
name: 'Screenfull',
props: {
width: {
type: Number,
default: 22
},
height: {
type: Number,
default: 22
},
fill: {
type: String,
default: '#48576a'
}
},
data() {
return {
isFullscreen: false
}
},
methods: {
click() {
if (!screenfull.enabled) {
this.$message({
message: 'you browser can not work',
type: 'warning'
})
return false
}
screenfull.toggle()
}
}
}
</script>
<style scoped>
.screenfull-svg {
display: inline-block;
cursor: pointer;
fill: #5a5e66;;
width: 20px;
height: 20px;
vertical-align: 10px;
}
</style>
<template>
<el-scrollbar ref="scrollContainer" :vertical="false" class="scroll-container" @wheel.native.prevent="handleScroll">
<slot/>
</el-scrollbar>
</template>
<script>
const tagAndTagSpacing = 4 // tagAndTagSpacing
export default {
name: 'ScrollPane',
data() {
return {
left: 0
}
},
methods: {
handleScroll(e) {
const eventDelta = e.wheelDelta || -e.deltaY * 40
const $scrollWrapper = this.$refs.scrollContainer.$refs.wrap
$scrollWrapper.scrollLeft = $scrollWrapper.scrollLeft + eventDelta / 4
},
moveToTarget(currentTag) {
const $container = this.$refs.scrollContainer.$el
const $containerWidth = $container.offsetWidth
const $scrollWrapper = this.$refs.scrollContainer.$refs.wrap
const tagList = this.$parent.$refs.tag
let firstTag = null
let lastTag = null
let prevTag = null
let nextTag = null
// find first tag and last tag
if (tagList.length > 0) {
firstTag = tagList[0]
lastTag = tagList[tagList.length - 1]
}
// find preTag and nextTag
for (let i = 0; i < tagList.length; i++) {
if (tagList[i] === currentTag) {
if (i === 0) {
nextTag = tagList[i].length > 1 && tagList[i + 1]
} else if (i === tagList.length - 1) {
prevTag = tagList[i].length > 1 && tagList[i - 1]
} else {
prevTag = tagList[i - 1]
nextTag = tagList[i + 1]
}
break
}
}
if (firstTag === currentTag) {
$scrollWrapper.scrollLeft = 0
} else if (lastTag === currentTag) {
$scrollWrapper.scrollLeft = $scrollWrapper.scrollWidth - $containerWidth
} else {
// the tag's offsetLeft after of nextTag
const afterNextTagOffsetLeft = nextTag.$el.offsetLeft + nextTag.$el.offsetWidth + tagAndTagSpacing
// the tag's offsetLeft before of prevTag
const beforePrevTagOffsetLeft = prevTag.$el.offsetLeft - tagAndTagSpacing
if (afterNextTagOffsetLeft > $scrollWrapper.scrollLeft + $containerWidth) {
$scrollWrapper.scrollLeft = afterNextTagOffsetLeft - $containerWidth
} else if (beforePrevTagOffsetLeft < $scrollWrapper.scrollLeft) {
$scrollWrapper.scrollLeft = beforePrevTagOffsetLeft
}
}
}
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.scroll-container {
white-space: nowrap;
position: relative;
overflow: hidden;
width: 100%;
/deep/ {
.el-scrollbar__bar {
bottom: 0px;
}
.el-scrollbar__wrap {
height: 49px;
}
}
}
</style>
function format(formatStr) {
const date = this
var zeroize = function(value, length) {
let zeros = ''
if (!length) length = 2
value = value.toString()
for (let i = 0; i < (length - value.length); i++) {
zeros += '0'
}
return zeros + value
}
return formatStr.replace(/"[^"]*"|'[^']*'|\b(?:d{1,4}|M{1,4}|yy(?:yy)?|([hHmstT])\1?|[lLZ])\b/g, function($0) {
switch ($0) {
case 'd': return date.getDate()
case 'dd': return zeroize(date.getDate())
case 'ddd': return ['Sun', 'Mon', 'Tue', 'Wed', 'Thr', 'Fri', 'Sat'][date.getDay()]
case 'dddd': return ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][date.getDay()]
case 'M': return date.getMonth() + 1
case 'MM': return zeroize(date.getMonth() + 1)
case 'MMM': return ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][date.getMonth()]
case 'MMMM': return ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'][date.getMonth()]
case 'yy': return date.getFullYear().substr(2)
case 'yyyy': return date.getFullYear()
case 'h': return date.getHours() % 12 || 12
case 'hh': return zeroize(date.getHours() % 12 || 12)
case 'H': return date.getHours()
case 'HH': return zeroize(date.getHours())
case 'm': return date.getMinutes()
case 'mm': return zeroize(date.getMinutes())
case 's': return date.getSeconds()
case 'ss': return zeroize(date.getSeconds())
case 'l': return date.getMilliseconds()
case 'll': return zeroize(date.getMilliseconds())
case 'tt': return date.getHours() < 12 ? 'am' : 'pm'
case 'TT': return date.getHours() < 12 ? 'AM' : 'PM'
}
})
}
const time = Date
time.prototype.format = format
<!-- -->
<template>
<div class="searchTop" :class="[searchData.length > 4 ?'':'padding-left',searchTopClass]">
<div v-show="searchData.length > 4 || showType =='oneRow' ? true : false" :class="searchTopBtnStyle" class="searchTopBtn">
<template
v-for="(item, index) in searchBtn"
>
<el-badge
v-if="!item.nextToForm&&item.Badge"
:key="index"
:value="$store.getters[item.BadgeStoreString]" >
<el-button
size="small"
:class="item.class"
:style="item.style"
:type="item.type"
:disabled="item.isDisabled"
:loading="item.isDisabled"
@click="btnClick(item.pType, item)">{{item.name}}
</el-button>
</el-badge>
<el-button
v-else-if="!item.nextToForm"
:key="index"
size="small"
:class="item.class"
:style="item.style"
:type="item.type"
:disabled="item.isDisabled"
:loading="item.isDisabled"
@click="btnClick(item.pType, item)">{{item.name}}
</el-button>
</template>
</div>
<el-form
ref="form"
:model="searchForm"
:class="searchData.length > 4 || showType =='oneRow' ? 'threeCol clearfix' : 'clearfix'">
<el-form-item v-for="(item,index) in searchData"
style="height:36px"
:label-width="item.width?item.width:'85px'"
:key="index"
:prop='item.modelValue'
:rules="item.rules"
size="small"
:label="item.label">
<el-input
v-if="item.type === 'selectInput'"
placeholder="请输入对应条件值"
v-model="searchForm[item.modelValue]"
size="small"
class="input-with-select"
clearable>
<el-select v-model="searchForm[item.optionKey]" slot="prepend" :style="item.style" placeholder="请选择" size="small">
<el-option
v-for="(i,index) in item.optionValue"
:key="index"
:label="i.label"
:value="i.value">
</el-option>
</el-select>
</el-input>
<el-input
v-if="item.type === 'input'"
v-model.trim="searchForm[item.modelValue]"
:placeholder="item.placeholder"
:class="item.clickFunc?'input cursor':'input'"
@click.native="item.clickFunc ? handleInputClick(item.modelValue, item) :''"
:readonly="item.readonly"
:disabled="item.disabled"
clearable>
</el-input>
<el-date-picker
v-if="item.type === 'time'"
v-model="searchForm[item.modelValue]"
type="daterange"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
start-placeholder="开始日期"
end-placeholder="结束日期"
:picker-options="item.pickerOptions ? item.pickerOptions :pickerOption">
</el-date-picker>
<el-select
v-if="item.type === 'select'"
v-model="searchForm[item.modelValue]"
:placeholder="item.placeholder">
<el-option
v-for="(i,index) in item.optionValue"
:key="index"
:label="i.label"
:value="i.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item v-for="(item, index) in searchBtn" :key="item.name" class="next_form_item">
<el-badge
v-if="item.nextToForm&&item.Badge"
:key="index"
:value="$store.getters[item.BadgeStoreString]" >
<el-button
size="small"
:class="item.class"
:style="item.style"
:type="item.type"
:disabled="item.isDisabled"
:loading="item.isDisabled"
@click="btnClick(item.pType, item)">{{item.name}}
</el-button>
</el-badge>
<el-button
v-else-if="item.nextToForm"
:key="index"
size="small"
:class="item.class"
:style="item.style"
:type="item.type"
:disabled="item.isDisabled"
:loading="item.isDisabled"
@click="btnClick(item.pType, item)">{{item.name}}
</el-button>
</el-form-item>
</el-form>
<div v-show="searchData.length > 4 || showType =='oneRow' ? false : true" class="searchBtn">
<el-button size="small" type="primary" @click="handleSearch">查询</el-button>
<el-button size="small" @click="handleReset">重置</el-button>
</div>
</div>
</template>
<script>
// import './date.js'
const today = new Date()
const limitday = new Date('2017-12-31')
// const startDate = new Date(today.getTime() - 3600 * 1000 * 24 * 7).format('yyyy-MM-dd')
// const endDate = new Date(today.getTime()).format('yyyy-MM-dd')
export default {
name: 'SearchTop',
props: {
searchForm: Object,
searchData: Array,
searchBtn: Array,
searchTopBtnStyle: String,
searchTopClass: String,
showType:{
type:String,
default:''
},
noClearAttr:{
type:Boolean,
default:false
},
},
data () {
return {
pickerOption: {
disabledDate(time) {
return time > today || time < limitday
}
},
}
},
watch:{
searchData:{
handler(newVal,oldVal){
this.searchData = newVal;
},
deep:true,
}
},
created() {
for(var item in this.searchData) {
let temp = this.searchData[item]
switch(temp.type) {
case 'input':
this.searchData[item].placeholder = temp.placeholder ? temp.placeholder :'请输入' + temp.label.split(':')[0]
break
case 'select':
this.searchData[item].placeholder = temp.placeholder ? temp.placeholder :'请选择' + temp.label.split(':')[0]
break
}
}
},
methods: {
deleteEmptyAttribute(val) {
for (var i in val) {
!val[i] && (delete val[i])
}
return val
},
handleSearch() {
// for(var item in this.searchData) {
// if(this.searchData[item].type == 'time') {
// !this.searchForm.time ? this.searchForm.time = [startDate, endDate] : ''
// }
// }
this.$refs['form'].validate((valid) => {
if (valid) {
!this.noClearAttr&&this.deleteEmptyAttribute(this.searchForm)
this.$emit('search', this.searchForm)
}
})
},
handleReset() {
for(var item in this.searchForm) {
this.searchForm[item] = "";
}
this.$emit('reset', this.searchForm)
},
btnClick(pType, item) {
switch(pType) {
case 'search':
this.handleSearch()
break
case 'reset':
this.handleReset()
break
default:
item.callback()
break
}
},
handleInputClick(modelValue, item){
this.$emit('inputClick', modelValue,item)
},
}
}
</script>
<style rel="stylesheet/scss" lang="scss" >
.clearfix:after {
display:block;
clear:both;
content:"";
visibility:hidden;
height:0;
}
.clearfix {
zoom:1;
}
.searchTop {
padding: 20px 10px 0;
/* border: 2px solid #f0f2f5;
border-radius: 5px; */
margin-bottom: 30px;
border-width: 1px;
border-style: solid;
border-color: rgb(235, 235, 235);
border-image: initial;
border-radius: 3px;
transition: all 0.2s ease 0s;
&:hover {
box-shadow: rgba(232, 237, 250, 0.6) 0px 0px 8px 0px,
rgba(232, 237, 250, 0.5) 0px 2px 4px 0px;
}
.el-form-item {
float: left;
width: 50%;
max-width: 420px;
}
.input,.el-date-editor--daterange.el-input__inner,
.el-select {
width: 85%;
}
.threeCol .el-form-item{
float: left;
width: 33%;
// max-width: unset;
}
.threeCol .input,
.threeCol .el-date-editor--daterange.el-input__inner,
.threeCol .el-select {
width: 95%;
}
.searchTopBtn {
display: flex;
justify-content: flex-end;
margin: 0 2.2% 15px 0;
}
.searchBtn{
margin-left: 3px;
margin-bottom: 20px;
}
}
.padding-left{
padding-left: 35px;
margin-top: 5px;
}
.cursor .el-input--medium .el-input__inner{
cursor: pointer;
}
.noBorder{
border:none !important;
&:hover {
box-shadow:none !important;
}
}
</style>
<style rel="stylesheet/scss" lang="scss" scoped>
.searchTop .el-form-item.next_form_item{
width: auto;
margin-right: 10px;
.el-button{
vertical-align: top;
}
}
</style>
\ No newline at end of file
<template>
<div class="app-add-dialog"
:tabindex="1"
@blur="treeBlur"
>
<el-input
ref="searchTreeInput"
class="orgina-dialog-input"
placeholder="请输入"
@keyup.enter.native="searchClick"
v-model="inputValue">
<i slot="suffix" class="el-input__icon el-icon-search" @click="searchClick"></i>
</el-input>
<el-tree
v-show="isAsyc"
ref="searchLoadTree"
accordion
node-key="id"
:props="parentTreeProps"
:load="nodeLoad"
@node-click="nodeClick"
@check="checkChange"
lazy
v-bind="$attrs"
>
</el-tree>
<el-tree
ref="searchTree"
v-show="!isAsyc"
default-expand-all
node-key="id"
:props="parentTreeProps"
:data='parentNoAsycData'
@node-click="nodeClick"
@check="checkChange"
v-bind="$attrs"
>
</el-tree>
</div>
</template>
<script>
export default {
name:'SearchTree',
data() {
return {
inputValue:'',
isAsyc:this.parentIsAysc,
};
},
props: {
parentIsAysc: {
type: Boolean,
default: true
},
parentNoAsycData: {
type: Array,
default: () => {
return []
}
},
parentTreeProps: {
type: Object,
default:() => {
return {}
}
},
isShow: {
type: Boolean,
default: false
},
},
watch: {
parentIsAysc(val){
// console.log(val,'***********&&&&&&&&&&&&&&&&&&&^^^^^^^^^^^^^')
this.isAsyc = val;
this.isAsyc ? this.inputValue = '' : ''
},
isShow(val){
console.log(val,'****************!!!!!!!!!!!!!!!~~~~~~~~~~~~~~~~~')
this.isShow ? this.inputValue = '' : ''
}
},
created() {},
methods: {
nodeLoad(node, resolve) {
// this.orginaGetAsycData(node, resolve)
this.$emit('nodeLoad',node,resolve)
},
nodeClick(node, resolve) {
// console.log(node,'点击当前组织 数据')
this.$emit('nodeClick',node)
},
searchClick(){
// console.log('组件内 点击到了 搜索 按钮')
// this.$emit('orginaClickVal','')
this.inputValue ? this.isAsyc=false : this.isAsyc=true;
this.$emit('searchClick',this.inputValue)
},
checkChange(data){
// console.log(this.$refs.searchLoadTree.getCheckedKeys(),'组件内 选择changge ')
this.$emit('checkChange',this.$refs.searchLoadTree.getCheckedKeys())
},
treeBlur(){
console.log('treeBlur')
},
}
};
</script>
<style rel="stylesheet/scss" lang="scss" >
.app-add-dialog{
//tree 样式 start
.el-tree-node:focus>.el-tree-node__content {
background-color: #409eff;
color:#fff;
}
//tree 样式 end
//input 样式
.orgina-dialog-input{
margin-bottom: 10px;
}
}
</style>
<template>
<div class="app-add-dialog"
:tabindex="1"
@blur="treeBlur"
>
<el-input
ref="searchTreeNoAsycInput"
class="orgina-dialog-input"
placeholder="请输入"
@keyup.enter.native="searchClick"
v-model="inputValue">
<i slot="suffix" class="el-input__icon el-icon-search" @click="searchClick"></i>
</el-input>
<!-- {{isShow}} -->
<el-tree
ref="searchTreeNoAsyc"
v-show="!isAsyc"
default-expand-all
node-key="id"
:props="parentTreeProps"
:data='parentNoAsycData'
@node-click="nodeClick"
@check="checkChange"
:filter-node-method="filterNode"
v-bind="$attrs"
>
</el-tree>
</div>
</template>
<script>
export default {
name:'SearchTree',
data() {
return {
inputValue:'',
isAsyc:this.parentIsAysc,
};
},
props: {
isShow: {
type: Boolean,
default: false
},
parentIsAysc: {
type: Boolean,
default: true
},
parentNoAsycData: {
type: Array,
default: () => {
return []
}
},
parentTreeProps: {
type: Object,
default:() => {
return {
label: "id",
children: "children"
}
}
},
},
watch: {
//是否 清空 输入框值
isShow(val){
console.log(val,'****************!!!!!!!!!!!!!!!~~~~~~~~~~~~~~~~~')
this.isShow ? this.inputValue = '' : ''
}
},
created() {},
methods: {
nodeClick(node, resolve) {
// console.log(node,'点击当前组织 数据')
this.$emit('nodeClick',node)
},
searchClick(){
// console.log('组件内 点击到了 搜索 按钮')
this.$emit('searchClick',this.inputValue)
},
checkChange(data){
// console.log(this.$refs.searchLoadTree.getCheckedKeys(),'组件内 选择changge ')
this.$emit('checkChange',this.$refs.searchLoadTree.getCheckedKeys())
},
treeBlur(){
console.log('treeBlur')
},
filterNode(value, data) {
// this.$emit('filterNode',value,data)
if (!value) return true;
var isPhone = false ,isName = true;
if(data&&data.name){
isName = (data.name.indexOf(value) !== -1)
}
if(data&&data.phone){
isPhone = (data.phone.indexOf(value) !== -1)
}
console.log(isName,'xxxxxxxxxxxx222222222////////// ---true')
if( isName || isPhone ){
// console.log('xxxxxxxxxxxx222222222////////// ---true')
return true
}else{
// console.log('xxxxxxxxxxxx222222222////////// ---false')
return false
}
},
}
};
</script>
<style rel="stylesheet/scss" lang="scss" >
.app-add-dialog{
//tree 样式 start
.el-tree-node:focus>.el-tree-node__content {
background-color: #409eff;
color:#fff;
}
//tree 样式 end
//input 样式
.orgina-dialog-input{
margin-bottom: 10px;
}
}
</style>
<template>
<div :class="{active:isActive}" class="share-dropdown-menu">
<div class="share-dropdown-menu-wrapper">
<span class="share-dropdown-menu-title" @click.self="clickTitle">{{ title }}</span>
<div v-for="(item,index) of items" :key="index" class="share-dropdown-menu-item">
<a v-if="item.href" :href="item.href" target="_blank">{{ item.title }}</a>
<span v-else>{{ item.title }}</span>
</div>
</div>
</div>
</template>
<script>
export default {
props: {
items: {
type: Array,
default: function() {
return []
}
},
title: {
type: String,
default: 'vue'
}
},
data() {
return {
isActive: false
}
},
methods: {
clickTitle() {
this.isActive = !this.isActive
}
}
}
</script>
<style rel="stylesheet/scss" lang="scss" >
$n: 8; //和items.length 相同
$t: .1s;
.share-dropdown-menu {
width: 250px;
position: relative;
z-index: 1;
&-title {
width: 100%;
display: block;
cursor: pointer;
background: black;
color: white;
height: 60px;
line-height: 60px;
font-size: 20px;
text-align: center;
z-index: 2;
transform: translate3d(0,0,0);
}
&-wrapper {
position: relative;
}
&-item {
text-align: center;
position: absolute;
width: 100%;
background: #e0e0e0;
line-height: 60px;
height: 60px;
cursor: pointer;
font-size: 20px;
opacity: 1;
transition: transform 0.28s ease;
&:hover {
background: black;
color: white;
}
@for $i from 1 through $n {
&:nth-of-type(#{$i}) {
z-index: -1;
transition-delay: $i*$t;
transform: translate3d(0, -60px, 0);
}
}
}
&.active {
.share-dropdown-menu-wrapper {
z-index: 1;
}
.share-dropdown-menu-item {
@for $i from 1 through $n {
&:nth-of-type(#{$i}) {
transition-delay: ($n - $i)*$t;
transform: translate3d(0, ($i - 1)*60px, 0);
}
}
}
}
}
</style>
<template>
<svg :class="svgClass" aria-hidden="true">
<use :xlink:href="iconName"/>
</svg>
</template>
<script>
export default {
name: 'SvgIcon',
props: {
iconClass: {
type: String,
required: true
},
className: {
type: String,
default: ''
}
},
computed: {
iconName() {
return `#icon-${this.iconClass}`
},
svgClass() {
if (this.className) {
return 'svg-icon ' + this.className
} else {
return 'svg-icon'
}
}
}
}
</script>
<style scoped>
.svg-icon {
width: 1em;
height: 1em;
vertical-align: -0.15em;
fill: currentColor;
overflow: hidden;
}
</style>
<template>
<el-table-column :prop="prop" v-bind="$attrs">
<template slot-scope="scope">
<span @click.prevent="toggleHandle(scope.$index, scope.row)" :style="childStyles(scope.row)">
<i :class="iconClasses(scope.row)" :style="iconStyles(scope.row)"></i>
{{ scope.row[prop] }}
</span>
</template>
</el-table-column>
</template>
<script>
import isArray from 'lodash/isArray'
export default {
name: 'table-tree-column',
data(){
return {
arr:[]
}
},
props: {
prop: {
type: String
},
treeKey: {
type: String,
default: 'id'
},
parentKey: {
type: String,
default: 'parentId'
},
levelKey: {
type: String,
default: 'level'
},
childKey: {
type: String,
default: 'children'
}
},
methods: {
childStyles (row) {
return { 'padding-left': (row[this.levelKey] * 25) + 'px' }
},
iconClasses (row) {
return [ !row._expanded ? 'el-icon-caret-right' : 'el-icon-caret-bottom' ]
},
iconStyles (row) {
return { 'visibility': this.hasChild(row) ? 'visible' : 'hidden' }
},
hasChild (row) {
return (isArray(row[this.childKey]) && row[this.childKey].length >= 1) || false
},
// 切换处理
toggleHandle (index, row) {
// console.log(row,'this row ')
if (this.hasChild(row)) {
var data = this.$parent.store.states.data.slice(0)
data[index]._expanded = !data[index]._expanded
if (data[index]._expanded) {
data = data.splice(0, index + 1).concat(this.addChildNode(row[this.childKey])).concat(data)
// data = data.splice(0, index + 1).concat(row[this.childKey]).concat(data)
} else {
data = this.removeChildNode(data, row[this.treeKey])
}
// console.log(data,'show data')
this.$parent.store.commit('setData', data)
this.$nextTick(() => {
this.$parent.doLayout()
})
}
},
addChildNode (row) {
// console.log(row,'点击当前项的产生的下级数据 row ')
//遍历下一级项 如果下级数据中 存在展开项 继续操作
var arr = []
this.forE(row,arr);
return arr
},
forE(row,arr){
var _this = this;
row.forEach(item => {
if(item._expanded){
arr.push(item);
// item['children'].forEach(childitem => {
// if(childitem._expanded){
// arr.push(childitem)
// // arr.push(childitem['children'])
// //继续循环
// }else{
// arr.push(childitem)
// }
// });
_this.forE(item[_this.childKey],arr)
}else{
arr.push(item);
}
});
},
// 移除子节点
removeChildNode (data, parentId) {
var parentIds = isArray(parentId) ? parentId : [parentId]
if (parentId.length <= 0) {
return data
}
var ids = []
for (var i = 0; i < data.length; i++) {
if (parentIds.indexOf(data[i][this.parentKey]) !== -1 && parentIds.indexOf(data[i][this.treeKey]) === -1) {
ids.push(data.splice(i, 1)[0][this.treeKey])
i--
}
}
return this.removeChildNode(data, ids)
}
}
}
</script>
\ No newline at end of file
<template>
<el-table-column :prop="prop" v-bind="$attrs">
<template slot-scope="scope">
<span @click.prevent="toggleHandle(scope.$index, scope.row)" :style="childStyles(scope.row)">
<i :class="iconClasses(scope.row)" :style="iconStyles(scope.row)"></i>
{{ scope.row[prop] }}
</span>
</template>
</el-table-column>
</template>
<script>
import isArray from 'lodash/isArray'
export default {
name: 'table-tree-column',
props: {
prop: {
type: String
},
treeKey: {
type: String,
default: 'id'
},
parentKey: {
type: String,
default: 'parentId'
},
levelKey: {
type: String,
default: 'level'
},
childKey: {
type: String,
default: 'children'
}
},
methods: {
childStyles (row) {
return { 'padding-left': (row[this.levelKey] * 25) + 'px' }
},
iconClasses (row) {
return [ !row._expanded ? 'el-icon-caret-right' : 'el-icon-caret-bottom' ]
},
iconStyles (row) {
return { 'visibility': this.hasChild(row) ? 'visible' : 'hidden' }
},
hasChild (row) {
return (isArray(row[this.childKey]) && row[this.childKey].length >= 1) || false
},
// 切换处理
toggleHandle (index, row) {
if (this.hasChild(row)) {
var data = this.$parent.store.states.data.slice(0)
data[index]._expanded = !data[index]._expanded
if (data[index]._expanded) {
data = data.splice(0, index + 1).concat(row[this.childKey]).concat(data)
} else {
data = this.removeChildNode(data, row[this.treeKey])
}
this.$parent.store.commit('setData', data)
this.$nextTick(() => {
this.$parent.doLayout()
})
}
},
// 移除子节点
removeChildNode (data, parentId) {
var parentIds = isArray(parentId) ? parentId : [parentId]
if (parentId.length <= 0) {
return data
}
var ids = []
for (var i = 0; i < data.length; i++) {
if (parentIds.indexOf(data[i][this.parentKey]) !== -1 && parentIds.indexOf(data[i][this.treeKey]) === -1) {
ids.push(data.splice(i, 1)[0][this.treeKey])
i--
}
}
return this.removeChildNode(data, ids)
}
}
}
</script>
\ No newline at end of file
<template>
<el-table-column :prop="prop" v-bind="$attrs">
<template slot-scope="scope">
<span @click.prevent="toggleHandle(scope.$index, scope.row)" :style="childStyles(scope.row)">
<i v-if="hasChild(scope.row)" :class="iconClasses(scope.row)" :style="iconStyles(scope.row)"></i>
{{ scope.row[prop] }}
</span>
</template>
</el-table-column>
</template>
<script>
import isArray from 'lodash/isArray'
export default {
name: 'table-tree-column',
data(){
return {
flag : true
}
},
props: {
prop: {
type: String
},
treeKey: {
type: String,
default: 'id'
},
parentKey: {
type: String,
default: 'parentId'
},
levelKey: {
type: String,
default: 'level'
},
childKey: {
type: String,
default: 'children'
},
hasChildKey: {
type: String,
default: 'hasChild'
},
},
methods: {
childStyles (row) {
return { 'padding-left': (row[this.levelKey] * 25) + 'px' }
},
iconClasses (row) {
return [ !row._expanded ? 'el-icon-caret-right' : 'el-icon-caret-bottom' ]
},
iconStyles (row) {
return { 'visibility': this.hasChild(row) ? 'visible' : 'hidden' }
},
hasChild (row) {
// console.log(row[this.hasChildKey],'hasChildKey')
// return (isArray(row[this.childKey]) && row[this.childKey].length >= 1) || false
return row[this.hasChildKey]
},
// 切换处理
toggleHandle (index, row) {
// if (this.hasChild(row)) {
var data = this.$parent.store.states.data.slice(0)
console.log(row,'是否已经点击了')
if(!data[index].hasClick){ //判断是否已点击加载完成
data[index]._expanded = !data[index]._expanded
if (data[index]._expanded) {
// console.log('kai')
if(data[index].hasAsyc == 1){ //判断是否异步加载
// console.log(data,'展开 但不请求数据')
data = data.splice(0, index + 1).concat(this.addChildNode(row[this.childKey])).concat(data)
}else{
// console.log(data,'展开,请求数据data')
this.$emit('table-click',this,index,row,data);
}
} else {
// console.log(data[index].children,'guan')
// console.log(row[this.treeKey],'guan')
data = this.removeChildNode(data, row[this.treeKey])
}
this.$nextTick(() => {
this.$parent.store.commit('setData', data)
this.$parent.doLayout()
})
}
// }
},
addChildNode (row) {
var arr = []
this.forE(row,arr);
return arr
},
forE(row,arr){
var _this = this;
if(row){
row.forEach(item => {
if(item._expanded){
arr.push(item);
_this.forE(item[_this.childKey],arr)
}else{
arr.push(item);
}
});
}
},
// 移除子节点
removeChildNode (data, parentId) {
var parentIds = isArray(parentId) ? parentId : [parentId]
if (parentId.length <= 0) {
return data
}
var ids = []
for (var i = 0; i < data.length; i++) {
if (parentIds.indexOf(data[i][this.parentKey]) !== -1 && parentIds.indexOf(data[i][this.treeKey]) === -1) {
ids.push(data.splice(i, 1)[0][this.treeKey])
i--
}
}
return this.removeChildNode(data, ids)
}
}
}
</script>
\ No newline at end of file
<template>
<el-table-column :prop="prop" v-bind="$attrs">
<template slot-scope="scope">
<span @click.prevent="toggleHandle(scope.$index, scope.row)" :style="childStyles(scope.row)">
<i :class="iconClasses(scope.row)" :style="iconStyles(scope.row)"></i>
{{ scope.row[prop] }}
</span>
</template>
</el-table-column>
</template>
<script>
import isArray from 'lodash/isArray'
export default {
name: 'table-tree-column',
props: {
prop: {
type: String
},
treeKey: {
type: String,
default: 'id'
},
parentKey: {
type: String,
default: 'parentId'
},
levelKey: {
type: String,
default: 'level'
},
childKey: {
type: String,
default: 'children'
},
hasChildKey: {
type: String,
default: 'hasChild'
},
},
methods: {
childStyles (row) {
return { 'padding-left': (row[this.levelKey] * 25) + 'px' }
},
iconClasses (row) {
return [ !row._expanded ? 'el-icon-caret-right' : 'el-icon-caret-bottom' ]
},
iconStyles (row) {
return { 'visibility': this.hasChild(row) ? 'visible' : 'hidden' }
},
hasChild (row) {
// return (isArray(row[this.childKey]) && row[this.childKey].length >= 1) || false
return row[this.hasChildKey]
},
// 切换处理
toggleHandle (index, row) {
// if (this.hasChild(row)) {
var data = this.$parent.store.states.data.slice(0)
data[index]._expanded = !data[index]._expanded
if (data[index]._expanded) {
if(data[index].hasAsyc == 1){
data = data.splice(0, index + 1).concat(row[this.childKey]).concat(data)
console.log(data,'已经点击加载 后的data')
}else{
this.$emit('table-click',this,index,row,data);
}
} else {
data = this.removeChildNode(data, row[this.treeKey])
}
this.$parent.store.commit('setData', data)
this.$nextTick(() => {
this.$parent.doLayout()
})
// }
},
// 移除子节点
removeChildNode (data, parentId) {
var parentIds = isArray(parentId) ? parentId : [parentId]
if (parentId.length <= 0) {
console.log(data,'new data')
return data
}
var ids = []
for (var i = 0; i < data.length; i++) {
if (parentIds.indexOf(data[i][this.parentKey]) !== -1 && parentIds.indexOf(data[i][this.treeKey]) === -1) {
ids.push(data.splice(i, 1)[0][this.treeKey])
i--
}
}
return this.removeChildNode(data, ids)
}
}
}
</script>
\ No newline at end of file
<template>
<a :class="className" class="link--mallki" href="#">
{{ text }}
<span :data-letters="text"/>
<span :data-letters="text"/>
</a>
</template>
<script>
export default {
props: {
className: {
type: String,
default: ''
},
text: {
type: String,
default: 'vue-element-admin'
}
}
}
</script>
<style>
/* Mallki */
.link--mallki {
font-weight: 800;
color: #4dd9d5;
font-family: 'Dosis', sans-serif;
-webkit-transition: color 0.5s 0.25s;
transition: color 0.5s 0.25s;
overflow: hidden;
position: relative;
display: inline-block;
line-height: 1;
outline: none;
text-decoration: none;
}
.link--mallki:hover {
-webkit-transition: none;
transition: none;
color: transparent;
}
.link--mallki::before {
content: '';
width: 100%;
height: 6px;
margin: -3px 0 0 0;
background: #3888fa;
position: absolute;
left: 0;
top: 50%;
-webkit-transform: translate3d(-100%, 0, 0);
transform: translate3d(-100%, 0, 0);
-webkit-transition: -webkit-transform 0.4s;
transition: transform 0.4s;
-webkit-transition-timing-function: cubic-bezier(0.7, 0, 0.3, 1);
transition-timing-function: cubic-bezier(0.7, 0, 0.3, 1);
}
.link--mallki:hover::before {
-webkit-transform: translate3d(100%, 0, 0);
transform: translate3d(100%, 0, 0);
}
.link--mallki span {
position: absolute;
height: 50%;
width: 100%;
left: 0;
top: 0;
overflow: hidden;
}
.link--mallki span::before {
content: attr(data-letters);
color: red;
position: absolute;
left: 0;
width: 100%;
color: #3888fa;
-webkit-transition: -webkit-transform 0.5s;
transition: transform 0.5s;
}
.link--mallki span:nth-child(2) {
top: 50%;
}
.link--mallki span:first-child::before {
top: 0;
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0);
}
.link--mallki span:nth-child(2)::before {
bottom: 0;
-webkit-transform: translate3d(0, -100%, 0);
transform: translate3d(0, -100%, 0);
}
.link--mallki:hover span::before {
-webkit-transition-delay: 0.3s;
transition-delay: 0.3s;
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
-webkit-transition-timing-function: cubic-bezier(0.2, 1, 0.3, 1);
transition-timing-function: cubic-bezier(0.2, 1, 0.3, 1);
}
</style>
/**
* @Author: jianglei
* @Date: 2017-10-12 12:06:49
*/
'use strict'
import Vue from 'vue'
export default function treeToArray(data, expandAll, parent = null, level = null) {
let tmp = []
Array.from(data).forEach(function(record) {
if (record._expanded === undefined) {
Vue.set(record, '_expanded', expandAll)
}
let _level = 1
if (level !== undefined && level !== null) {
_level = level + 1
}
Vue.set(record, '_level', _level)
// 如果有父元素
if (parent) {
Vue.set(record, 'parent', parent)
}
tmp.push(record)
if (record.children && record.children.length > 0) {
const children = treeToArray(record.children, expandAll, record, _level)
tmp = tmp.concat(children)
}
})
return tmp
}
<template>
<el-table :data="formatData" :row-style="showRow" v-bind="$attrs">
<el-table-column v-if="columns.length===0" width="150">
<template slot-scope="scope">
<span v-for="space in scope.row._level" :key="space" class="ms-tree-space"/>
<span v-if="iconShow(0,scope.row)" class="tree-ctrl" @click="toggleExpanded(scope.$index)">
<i v-if="!scope.row._expanded" class="el-icon-plus"/>
<i v-else class="el-icon-minus"/>
</span>
{{ scope.$index }}
</template>
</el-table-column>
<el-table-column v-for="(column, index) in columns" v-else :key="column.value" :label="column.text" :width="column.width">
<template slot-scope="scope">
<!-- Todo -->
<!-- eslint-disable-next-line vue/no-confusing-v-for-v-if -->
<span v-for="space in scope.row._level" v-if="index === 0" :key="space" class="ms-tree-space"/>
<span v-if="iconShow(index,scope.row)" class="tree-ctrl" @click="toggleExpanded(scope.$index)">
<i v-if="!scope.row._expanded" class="el-icon-plus"/>
<i v-else class="el-icon-minus"/>
</span>
{{ scope.row[column.value] }}
</template>
</el-table-column>
<slot/>
</el-table>
</template>
<script>
/**
Auth: Lei.j1ang
Created: 2018/1/19-13:59
*/
import treeToArray from './eval'
export default {
name: 'TreeTable',
props: {
/* eslint-disable */
data: {
type: [Array, Object],
required: true
},
columns: {
type: Array,
default: () => []
},
evalFunc: Function,
evalArgs: Array,
expandAll: {
type: Boolean,
default: false
}
},
computed: {
// 格式化数据源
formatData: function() {
let tmp
if (!Array.isArray(this.data)) {
tmp = [this.data]
} else {
tmp = this.data
}
const func = this.evalFunc || treeToArray
const args = this.evalArgs ? Array.concat([tmp, this.expandAll], this.evalArgs) : [tmp, this.expandAll]
return func.apply(null, args)
}
},
methods: {
showRow: function(row) {
const show = (row.row.parent ? (row.row.parent._expanded && row.row.parent._show) : true)
row.row._show = show
return show ? 'animation:treeTableShow 1s;-webkit-animation:treeTableShow 1s;' : 'display:none;'
},
// 切换下级是否展开
toggleExpanded: function(trIndex) {
const record = this.formatData[trIndex]
record._expanded = !record._expanded
},
// 图标显示
iconShow(index, record) {
return (index === 0 && record.children && record.children.length > 0)
}
}
}
</script>
<style rel="stylesheet/css">
@keyframes treeTableShow {
from {opacity: 0;}
to {opacity: 1;}
}
@-webkit-keyframes treeTableShow {
from {opacity: 0;}
to {opacity: 1;}
}
</style>
<style lang="scss" rel="stylesheet/scss" scoped>
$color-blue: #2196F3;
$space-width: 18px;
.ms-tree-space {
position: relative;
top: 1px;
display: inline-block;
font-style: normal;
font-weight: 400;
line-height: 1;
width: $space-width;
height: 14px;
&::before {
content: ""
}
}
.processContainer{
width: 100%;
height: 100%;
}
table td {
line-height: 26px;
}
.tree-ctrl{
position: relative;
cursor: pointer;
color: $color-blue;
margin-left: -$space-width;
}
</style>
## 写在前面
此组件仅提供一个创建TreeTable的解决思路
## prop说明
#### *data*
**必填**
原始数据,要求是一个数组或者对象
```javascript
[{
key1: value1,
key2: value2,
children: [{
key1: value1
},
{
key1: value1
}]
},
{
key1: value1
}]
```
或者
```javascript
{
key1: value1,
key2: value2,
children: [{
key1: value1
},
{
key1: value1
}]
}
```
#### columns
列属性,要求是一个数组
1. text: 显示在表头的文字
2. value: 对应data的key。treeTable将显示相应的value
3. width: 每列的宽度,为一个数字(可选)
如果你想要每个字段都有自定义的样式或者嵌套其他组件,columns可不提供,直接像在el-table一样写即可,如果没有自定义内容,提供columns将更加的便捷方便
如果你有几个字段是需要自定义的,几个不需要,那么可以将不需要自定义的字段放入columns,将需要自定义的内容放入到slot中,详情见后文
```javascript
[{
value:string,
text:string,
width:number
},{
value:string,
text:string,
width:number
}]
```
#### expandAll
是否默认全部展开,boolean值,默认为false
#### evalFunc
解析函数,function,非必须
如果不提供,将使用默认的[evalFunc](./eval.js)
如果提供了evalFunc,那么会用提供的evalFunc去解析data,并返回treeTable渲染所需要的值。如何编写一个evalFunc,请参考[*eval.js*](https://github.com/PanJiaChen/vue-element-admin/blob/master/src/components/TreeTable/eval.js)或[*customEval.js*](https://github.com/PanJiaChen/vue-element-admin/blob/master/src/views/table/treeTable/customEval.js)
#### evalArgs
解析函数的参数,是一个数组
**请注意,自定义的解析函数参数第一个为this.data,第二个参数为, this.expandAll,你不需要在evalArgs填写。一定记住,这两个参数是强制性的,并且位置不可颠倒** *this.data为需要解析的数据,this.expandAll为是否默认展开*
如你的解析函数需要的参数为`(this.data, this.expandAll,1,2,3,4)`,那么你只需要将`[1,2,3,4]`赋值给`evalArgs`就可以了
如果你的解析函数参数只有`(this.data, this.expandAll)`,那么就可以不用填写evalArgs了
具体可参考[*customEval.js*](https://github.com/PanJiaChen/vue-element-admin/blob/master/src/views/table/treeTable/customEval.js)的函数参数和[customTreeTable](https://github.com/PanJiaChen/vue-element-admin/blob/master/src/views/table/treeTable/customTreeTable.vue)的`evalArgs`属性值
## slot
这是一个自定义列的插槽。
默认情况下,treeTable只有一行行展示数据的功能。但是一般情况下,我们会要给行加上一个操作按钮或者根据当行数据展示不同的样式,这时我们就需要自定义列了。请参考[customTreeTable](https://github.com/PanJiaChen/vue-element-admin/blob/master/src/views/table/treeTable/customTreeTable.vue),[实例效果](https://panjiachen.github.io/vue-element-admin/#/table/tree-table)
`slot`和`columns属性`可同时存在,columns里面的数据列会在slot自定义列的左边展示
## 其他
如果有其他的需求,请参考[el-table](http://element-cn.eleme.io/#/en-US/component/table)的api自行修改index.vue
<template>
<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">
Drop excel file here or
<el-button :loading="loading" style="margin-left:16px;" size="mini" type="primary" @click="handleUpload">Browse</el-button>
</div>
</div>
</template>
<script>
import XLSX from 'xlsx'
export default {
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 fixedData = this.fixData(data)
const workbook = XLSX.read(btoa(fixedData), { type: 'base64' })
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)
})
},
fixData(data) {
let o = ''
let l = 0
const w = 10240
for (; l < data.byteLength / w; ++l) o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w, l * w + w)))
o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w)))
return o
},
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>
.excel-upload-input{
display: none;
z-index: -9999;
}
.drop{
border: 2px dashed #bbb;
width: 600px;
height: 160px;
line-height: 160px;
margin: 0 auto;
font-size: 24px;
border-radius: 5px;
text-align: center;
color: #bbb;
position: relative;
}
</style>
<template>
<div class="upload_img_wrap">
<el-upload
ref="pictures"
v-if="pictures.length<maxNum"
list-type="picture-card"
class="image-upload image-header"
:action='WEBURL+"/carservice/publicservice/common/uploadFile"'
header='Access-Control-Allow-Origin'
:show-file-list="false"
:on-success="uploadHeaderImageSuccess"
:on-error=" (value) => uploadError(value,'附件')"
:before-upload=" (value) => uploadImageChange(value,'附件')"
>
<span>
<i class="el-icon-plus image-upload-icon"></i>
</span>
</el-upload>
<template v-for="(item,index) in pictures">
<span
style="position:relative;display: inline-block;"
:key="index">
<i class="el-icon-remove red-cl" style="position:absolute;top:1px;right:5px;cursor:pointer;" @click="deleteImage(index)"></i>
<el-image
class="image-header-item"
:src="item"
:preview-src-list="pictures"
fit="contain">
</el-image>
</span>
</template>
</div>
</template>
<script>
import {
getBussinessApi,
getDictDataListByKey,
} from '@/api/system'
export default {
props: {
maxNum: Number,
beforeUpload: Function, // eslint-disable-line
onSuccess: Function// eslint-disable-line
},
data() {
return {
WEBURL:process.env.BASE_API,
pictures: [],
}
},
methods: {
uploadError(file,imageName){
this.$message.error(imageName+'上传失败!');
},
uploadImageChange(file,imageName) {
const regx = ["image/png","image/jpeg"]
const isJPG = regx.includes(file.type);
const isLt2M = file.size / 1024 / 1024 < 2;
if (!isJPG) {
this.$message.error('上传的'+imageName+'只能是 JPG/PNG 格式!');
return false
}
if (!isLt2M) {
this.$message.error('上传的'+imageName+'大小不能超过 2MB!');
return false
}
return isJPG && isLt2M;
},
//业务
uploadHeaderImageSuccess(res, file) {
this.pictures.push(res.data);
this.$emit('update', this.pictures)
},
deleteImage(index){
getBussinessApi({'fileUrl':this.pictures[index]},'deleteFile','post').then(response => {
if(response&&response.code == 200){ //添加成功
this.pictures.splice(index,1)
this.$emit('update', this.pictures)
}else{
this.$message.error('照片删除失败,请稍后重试');
}
}).catch(error => {})
},
reset(){
this.pictures = []
}
}
}
</script>
<style lang="scss" scoped>
.upload_img_wrap{
.image-upload {
.el-upload {
border: 1px dashed #d9d9d9;
border-radius: 5px;
cursor: pointer;
position: relative;
overflow: hidden;
width: 100%;
height: 100%;
}
.el-upload:hover {
border-color: #409EFF;
}
.image-upload-icon {
font-size: 28px;
color: #8c939d;
width: 100%;
height: 100%;
text-align: center;
}
.image {
width: 100%;
height: 100%;
display: block;
}
p{
position: absolute;
top: 0px;
width: 100%;
color: #999;
margin: 0;
padding-top: 30px;
}
}
.image-header {
padding: 10px 0 0 0;
float: left;
margin-right: 10px;
.el-upload {
border-radius: 5px;
width: 100px;
height: 100px;
line-height: 100px;
}
}
.image-header-item{
border:1px dashed rgba(0,0,0,.1);
padding: 5px;
border-radius: 5px;
width: 100px;
height: 100px;
margin:10px 10px 0 0;
}
}
</style>
<style lang="scss" >
.upload_img_wrap{
.el-upload--picture-card{
width: 100px;
height: 100px;
line-height: 102px;
}
}
</style>
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!