init: 导入项目到 meswork Gitea
38
.gitignore
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
# Dependencies
|
||||
node_modules/
|
||||
|
||||
# Build output
|
||||
dist/
|
||||
|
||||
# Logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# Editor / IDE
|
||||
.idea/
|
||||
.vscode/
|
||||
.vs/
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw*
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Local env
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# Archives / binaries not part of source
|
||||
*.zip
|
||||
*.7z
|
||||
*.rar
|
||||
*.tar
|
||||
*.tar.gz
|
||||
*.tgz
|
||||
*.exe
|
||||
29
README.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# MES
|
||||
|
||||
## Project setup
|
||||
```
|
||||
npm install
|
||||
```
|
||||
|
||||
### Compiles and hot-reloads for development
|
||||
```
|
||||
npm run serve
|
||||
```
|
||||
|
||||
### Compiles and minifies for production
|
||||
```
|
||||
npm run build
|
||||
```
|
||||
|
||||
### Run your tests
|
||||
```
|
||||
npm run test
|
||||
```
|
||||
|
||||
### Lints and fixes files
|
||||
```
|
||||
npm run lint
|
||||
```
|
||||
|
||||
### Customize configuration
|
||||
See [Configuration Reference](https://cli.vuejs.org/config/).
|
||||
5
babel.config.js
Normal file
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
presets: [
|
||||
'@vue/app'
|
||||
]
|
||||
}
|
||||
45
build/build.js
Normal file
@@ -0,0 +1,45 @@
|
||||
'use strict'
|
||||
require('./check-versions')()
|
||||
|
||||
process.env.NODE_ENV = 'production'
|
||||
|
||||
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')
|
||||
|
||||
const spinner = ora('building for production...')
|
||||
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"
|
||||
)
|
||||
)
|
||||
})
|
||||
})
|
||||
64
build/check-versions.js
Normal file
@@ -0,0 +1,64 @@
|
||||
'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)
|
||||
}
|
||||
}
|
||||
BIN
build/logo.png
Normal file
|
After Width: | Height: | Size: 6.7 KiB |
108
build/utils.js
Normal file
@@ -0,0 +1,108 @@
|
||||
'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')
|
||||
})
|
||||
}
|
||||
}
|
||||
5
build/vue-loader.conf.js
Normal file
@@ -0,0 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
// You can set the vue-loader configuration by yourself.
|
||||
}
|
||||
110
build/webpack.base.conf.js
Normal file
@@ -0,0 +1,110 @@
|
||||
'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: {
|
||||
'vue$': 'vue/dist/vue.esm.js',
|
||||
'@': resolve('src'),
|
||||
'scss_vars': '@/styles/vars.scss',
|
||||
'excel': path.resolve(__dirname, '../src/excel')// 新增加一行
|
||||
}
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
...(config.dev.useEslint ? [createLintingRule()] : []),
|
||||
{
|
||||
test: /\.vue$/,
|
||||
loader: 'vue-loader',
|
||||
options: vueLoaderConfig
|
||||
},
|
||||
{
|
||||
test: /\.js$/,
|
||||
loader: 'babel-loader',
|
||||
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'
|
||||
}
|
||||
}
|
||||
98
build/webpack.dev.conf.js
Normal file
@@ -0,0 +1,98 @@
|
||||
'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: 'EquipmentConditionAnalysis.vue.html',
|
||||
template: 'EquipmentConditionAnalysis.vue.html',
|
||||
inject: true,
|
||||
favicon: resolve('MES.png'),
|
||||
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)
|
||||
}
|
||||
})
|
||||
})
|
||||
181
build/webpack.prod.conf.js
Normal file
@@ -0,0 +1,181 @@
|
||||
'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')
|
||||
|
||||
function resolve(dir) {
|
||||
return path.join(__dirname, '..', dir)
|
||||
}
|
||||
|
||||
const env = require('../config/prod.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: 'EquipmentConditionAnalysis.vue.html',
|
||||
inject: true,
|
||||
favicon: resolve('MES.png'),
|
||||
title: 'vue-admin-template',
|
||||
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[\\/]/
|
||||
}
|
||||
}
|
||||
},
|
||||
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()
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
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
|
||||
8
config/dev.env.js
Normal file
@@ -0,0 +1,8 @@
|
||||
'use strict'
|
||||
const merge = require('webpack-merge')
|
||||
const prodEnv = require('./prod.env')
|
||||
|
||||
module.exports = merge(prodEnv, {
|
||||
NODE_ENV: '"development"',
|
||||
BASE_API: '"https://easy-mock.com/mock/5950a2419adc231f356a6636/vue-admin"',
|
||||
})
|
||||
90
config/index.js
Normal file
@@ -0,0 +1,90 @@
|
||||
'use strict'
|
||||
// Template version: 1.2.6
|
||||
// see http://vuejs-templates.github.io/webpack for documentation.
|
||||
|
||||
const path = require('path')
|
||||
const os = require('os')
|
||||
|
||||
const networkInterfaces = os.networkInterfaces()
|
||||
|
||||
const ip = networkInterfaces['WLAN'][1] ? networkInterfaces['WLAN'][1].address : networkInterfaces['WLAN'][0].address
|
||||
|
||||
module.exports = {
|
||||
dev: {
|
||||
// Paths
|
||||
assetsSubDirectory: 'static',
|
||||
// assetsPublicPath: '/GQMobile/',
|
||||
assetsPublicPath: '/',
|
||||
proxyTable: {},
|
||||
// Various Dev Server settings
|
||||
host: ip, // can be overwritten by process.env.HOST
|
||||
port: 9528, // 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: '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 --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
|
||||
}
|
||||
}
|
||||
5
config/prod.env.js
Normal file
@@ -0,0 +1,5 @@
|
||||
'use strict'
|
||||
module.exports = {
|
||||
NODE_ENV: '"production"',
|
||||
BASE_API: '"https://easy-mock.com/mock/5950a2419adc231f356a6636/vue-admin"',
|
||||
}
|
||||
15381
package-lock.json
generated
Normal file
386
package.json
Normal file
@@ -0,0 +1,386 @@
|
||||
{
|
||||
"name": "mes",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build",
|
||||
"lint": "vue-cli-service lint",
|
||||
"svgo": "svgo -f src/icons/svg --config=src/icons/svgo.yml"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.21.4",
|
||||
"echarts": "^5.2.0",
|
||||
"element-ui": "^2.8.2",
|
||||
"file-saver": "^2.0.2",
|
||||
"js-cookie": "^2.2.1",
|
||||
"js-export-excel": "^1.1.2",
|
||||
"mint-ui": "^2.2.13",
|
||||
"mqtt": "^4.3.7",
|
||||
"node-sass": "^4.14.1",
|
||||
"qrcode": "^1.4.4",
|
||||
"qs": "^6.9.0",
|
||||
"sass-loader": "^7.3.1",
|
||||
"uuid": "^8.3.2",
|
||||
"vue": "^2.6.6",
|
||||
"vue-jsonp": "^0.1.8",
|
||||
"vue-router": "^3.0.1",
|
||||
"vue-seamless-scroll": "^1.1.21",
|
||||
"vuex": "^3.0.1",
|
||||
"xlsx": "^0.17.1",
|
||||
"xlsx-style": "^0.8.13"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vue/cli-plugin-babel": "^3.5.0",
|
||||
"@vue/cli-plugin-eslint": "^3.5.0",
|
||||
"@vue/cli-service": "^3.5.0",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"eslint": "^5.8.0",
|
||||
"eslint-plugin-vue": "^5.0.0",
|
||||
"jquery": "^2.2.4",
|
||||
"node-sass": "^4.14.1",
|
||||
"script-loader": "^0.7.2",
|
||||
"svg-sprite-loader": "^5.1.1",
|
||||
"vue-particles": "^1.0.9",
|
||||
"vue-template-compiler": "^2.5.21"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
"env": {
|
||||
"node": true
|
||||
},
|
||||
"extends": [
|
||||
"plugin:vue/essential",
|
||||
"eslint:recommended"
|
||||
],
|
||||
"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": 2,
|
||||
"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,
|
||||
"object-curly-spacing": [
|
||||
2,
|
||||
"always",
|
||||
{
|
||||
"objectsInObjects": false
|
||||
}
|
||||
],
|
||||
"array-bracket-spacing": [
|
||||
2,
|
||||
"never"
|
||||
]
|
||||
},
|
||||
"parserOptions": {
|
||||
"parser": "babel-eslint"
|
||||
}
|
||||
},
|
||||
"browserslist": [
|
||||
"> 1%",
|
||||
"last 2 versions",
|
||||
"not ie <= 8"
|
||||
]
|
||||
}
|
||||
BIN
public/MES.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
12
public/config.js
Normal file
@@ -0,0 +1,12 @@
|
||||
window.g = {
|
||||
mqttClient: null,
|
||||
mqttSubscriptionTopic: 'MES/InstantMessaging/SY/',
|
||||
mqttPublishTopic: 'WEB/InstantMessaging/SY/MisServer',
|
||||
// mqttIP: '192.168.0.1',
|
||||
// mqttIP: '10.10.22.229',
|
||||
mqttIP: '127.0.0.1',
|
||||
mqttPortNumber: '8083',
|
||||
// baseURL: 'http://192.168.0.1:8001/submit/MESCommonBase.ashx'
|
||||
// baseURL: 'http://10.10.22.229:8001/submit/MESCommonBase.ashx'
|
||||
baseURL: 'http://127.0.0.1:8001/submit/MESCommonBase.ashx'
|
||||
}
|
||||
BIN
public/heli.png
Normal file
|
After Width: | Height: | Size: 5.5 KiB |
26
public/index.html
Normal file
@@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="icon" href="<%= BASE_URL %>MES.png">
|
||||
<title>MES</title>
|
||||
<script type="text/javascript">
|
||||
document.write("<script src='./config.js?v=" + new Date().getTime() + "'><\/script>");
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>
|
||||
<strong>We're sorry but MES doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
||||
</noscript>
|
||||
<div id="app"></div>
|
||||
<!-- built files will be auto injected -->
|
||||
</body>
|
||||
</html>
|
||||
<style>
|
||||
body{
|
||||
margin: 0;
|
||||
background:white;
|
||||
}
|
||||
</style>
|
||||
BIN
public/leftPic.png
Normal file
|
After Width: | Height: | Size: 9.0 KiB |
BIN
public/login.png
Normal file
|
After Width: | Height: | Size: 625 KiB |
BIN
public/rightPic.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
34
src/App.vue
Normal file
@@ -0,0 +1,34 @@
|
||||
<template>
|
||||
<div id="app">
|
||||
<router-view />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
#app {
|
||||
font-family: MiSans Bold, serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
color: #2c3e50;
|
||||
}
|
||||
.el-table{
|
||||
font-size: 16px;
|
||||
border-color: #a6a6a6;
|
||||
}
|
||||
|
||||
.el-table td, .el-table th.is-leaf,.el-table--border, .el-table--group{
|
||||
border-color: #a6a6a6!important;
|
||||
}
|
||||
|
||||
.el-table--border::after, .el-table--group::after, .el-table::before{
|
||||
background-color: #a6a6a6!important;
|
||||
}
|
||||
|
||||
.el-table--border th.el-table__cell, .el-table__fixed-right-patch{
|
||||
border-bottom: 1px solid #a6a6a6;
|
||||
}
|
||||
|
||||
.el-table--border .el-table__cell, .el-table__body-wrapper .el-table--border.is-scrolling-left~.el-table__fixed{
|
||||
border-right: 1px solid #a6a6a6;
|
||||
}
|
||||
</style>
|
||||
44
src/api/login.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import request from '@/utils/request'
|
||||
import state from '@/store'
|
||||
import router from '@/router'
|
||||
export function login(username, password) {
|
||||
return request({
|
||||
url: '',
|
||||
method: 'post',
|
||||
data: {
|
||||
UserID: state.state.user.id,
|
||||
ModularID: router.currentRoute.path,
|
||||
type: '1',
|
||||
name: '菜单模块系统_用户名密码_查询数据_改造新增',
|
||||
param: `用户名=${username}&密码=${password}`
|
||||
}
|
||||
})
|
||||
}
|
||||
//
|
||||
export function getInfo(token) {
|
||||
return request({
|
||||
url: '',
|
||||
method: 'post',
|
||||
data: {
|
||||
UserID: state.state.user.id,
|
||||
ModularID: router.currentRoute.path,
|
||||
type: '1',
|
||||
name: '菜单模块系统_项目角色模块列表_二级_查询数据',
|
||||
param: `角色编号=${token}`
|
||||
}
|
||||
})
|
||||
}
|
||||
// 修改密码
|
||||
export function editPassword(num1, num2, num3, num4) {
|
||||
return request({
|
||||
url: '',
|
||||
method: 'post',
|
||||
data: {
|
||||
UserID: state.state.user.id,
|
||||
ModularID: router.currentRoute.path,
|
||||
type: '2',
|
||||
name: '账号信息_修改密码_MESWORK',
|
||||
param: '考勤编号=' + num1 + '=string&原始密码=' + num2 + '=string&新密码=' + num3 + '=string&返回=' + num4 + '=string=output'
|
||||
}
|
||||
})
|
||||
}
|
||||
BIN
src/assets/font/MiSans-Bold.ttf
Normal file
BIN
src/assets/font/MiSans-Demibold.ttf
Normal file
BIN
src/assets/font/MiSans-ExtraLight.ttf
Normal file
BIN
src/assets/font/MiSans-Heavy.ttf
Normal file
BIN
src/assets/font/MiSans-Light.ttf
Normal file
BIN
src/assets/font/MiSans-Medium.ttf
Normal file
BIN
src/assets/font/MiSans-Normal.ttf
Normal file
BIN
src/assets/font/MiSans-Regular.ttf
Normal file
BIN
src/assets/font/MiSans-Semibold.ttf
Normal file
BIN
src/assets/font/MiSans-Thin.ttf
Normal file
70
src/assets/font/Misans.css
Normal file
@@ -0,0 +1,70 @@
|
||||
@font-face {
|
||||
font-family: MiSans Demibold;
|
||||
src: url("MiSans-Demibold.ttf");
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-display: block;
|
||||
}
|
||||
@font-face {
|
||||
font-family: MiSans Bold;
|
||||
src: url("MiSans-Bold.ttf");
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-display: block;
|
||||
}
|
||||
@font-face {
|
||||
font-family: MiSans ExtraLight;
|
||||
src: url("MiSans-ExtraLight.ttf");
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-display: block;
|
||||
}
|
||||
@font-face {
|
||||
font-family: MiSans Heavy;
|
||||
src: url("MiSans-Heavy.ttf");
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-display: block;
|
||||
}
|
||||
@font-face {
|
||||
font-family: MiSans Light;
|
||||
src: url("MiSans-Light.ttf");
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-display: block;
|
||||
}
|
||||
@font-face {
|
||||
font-family: MiSans Medium;
|
||||
src: url("MiSans-Medium.ttf");
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-display: block;
|
||||
}
|
||||
@font-face {
|
||||
font-family: MiSans Normal;
|
||||
src: url("MiSans-Normal.ttf");
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-display: block;
|
||||
}
|
||||
@font-face {
|
||||
font-family: MiSans Regular;
|
||||
src: url("MiSans-Regular.ttf");
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-display: block;
|
||||
}
|
||||
@font-face {
|
||||
font-family: MiSans Semibold;
|
||||
src: url("MiSans-Semibold.ttf");
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-display: block;
|
||||
}
|
||||
@font-face {
|
||||
font-family: MiSans Thin;
|
||||
src: url("MiSans-Thin.ttf");
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-display: block;
|
||||
}
|
||||
BIN
src/assets/image/Andon.png
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
BIN
src/assets/image/DeviceManagement.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
src/assets/image/Init.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
src/assets/image/MESlogo.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
src/assets/image/MatchFail.png
Normal file
|
After Width: | Height: | Size: 55 KiB |
BIN
src/assets/image/MatchSuccess.png
Normal file
|
After Width: | Height: | Size: 56 KiB |
BIN
src/assets/image/MaterialPull.png
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
src/assets/image/OperationGuide.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
src/assets/image/OrderCompletion.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
src/assets/image/QualityInquiry.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
src/assets/image/RepairManagement.png
Normal file
|
After Width: | Height: | Size: 6.8 KiB |
BIN
src/assets/image/StartWorkCircle.gif
Normal file
|
After Width: | Height: | Size: 38 KiB |
BIN
src/assets/image/blinkrectangle.gif
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
src/assets/image/bluerectangle.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
src/assets/image/boltnew.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
src/assets/image/bule.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
src/assets/image/call.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
src/assets/image/caozuo.png
Normal file
|
After Width: | Height: | Size: 752 KiB |
BIN
src/assets/image/green.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
src/assets/image/greenFace.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
src/assets/image/greenFace1.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
src/assets/image/green_bolt.gif
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
src/assets/image/greenrectangle.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
src/assets/image/grey.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
src/assets/image/logo.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
src/assets/image/nothing.png
Normal file
|
After Width: | Height: | Size: 152 B |
BIN
src/assets/image/red.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
src/assets/image/redFace.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
src/assets/image/redFace1.png
Normal file
|
After Width: | Height: | Size: 9.2 KiB |
BIN
src/assets/image/redrectangle.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
src/assets/image/reset.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
src/assets/image/sy.png
Normal file
|
After Width: | Height: | Size: 9.9 KiB |
BIN
src/assets/logo.png
Normal file
|
After Width: | Height: | Size: 6.7 KiB |
63
src/main.js
Normal file
@@ -0,0 +1,63 @@
|
||||
import Vue from 'vue'
|
||||
import 'element-ui/lib/theme-chalk/index.css'
|
||||
import App from './App.vue'
|
||||
import store from './store/index'
|
||||
import ElementUI from 'element-ui'
|
||||
import router from './router'
|
||||
import * as echarts from 'echarts'
|
||||
import curd from '@/utils/curd'
|
||||
// import '@/styles/index.scss' // global css
|
||||
import VueParticles from 'vue-particles'
|
||||
import jsonp from 'vue-jsonp'
|
||||
|
||||
// 新通讯11/12---<
|
||||
import service from '@/utils/request'
|
||||
import scroll from 'vue-seamless-scroll'
|
||||
import mqtt from 'mqtt'
|
||||
|
||||
// 关闭点弹窗周围关闭功能 -- 20200218
|
||||
ElementUI.Dialog.props.closeOnClickModal.default = false
|
||||
Vue.prototype.ExecDatabase = function(num) {
|
||||
return service({
|
||||
url: '',
|
||||
method: 'post',
|
||||
data: num
|
||||
})
|
||||
}
|
||||
Vue.use(scroll)
|
||||
Vue.use(VueParticles)
|
||||
Vue.use(curd)
|
||||
Vue.use(jsonp)
|
||||
Vue.use(ElementUI)
|
||||
Vue.prototype.echarts = echarts
|
||||
Vue.prototype.mqtt = mqtt
|
||||
Vue.config.productionTip = true
|
||||
Vue.directive('loadmore', {
|
||||
bind(el, binding) {
|
||||
var p = 0
|
||||
var t = 0
|
||||
var down = true
|
||||
var selectWrap = el.querySelector('.el-table__body-wrapper')
|
||||
selectWrap.addEventListener('scroll', function() {
|
||||
// 判断是否向下滚动
|
||||
p = this.scrollTop
|
||||
// if ( t < p){down=true}else{down=false}
|
||||
if (t < p) {
|
||||
down = true
|
||||
} else {
|
||||
down = false
|
||||
}
|
||||
t = p
|
||||
// 判断是否到底
|
||||
const sign = 10
|
||||
const scrollDistance = this.scrollHeight - this.scrollTop - this.clientHeight
|
||||
if (scrollDistance <= sign && down) {
|
||||
binding.value()
|
||||
}
|
||||
})
|
||||
} })
|
||||
new Vue({
|
||||
store,
|
||||
router,
|
||||
render: h => h(App)
|
||||
}).$mount('#app')
|
||||
77
src/router/index.js
Normal file
@@ -0,0 +1,77 @@
|
||||
import Vue from 'vue'
|
||||
import Router from 'vue-router'
|
||||
import layout from '@/views/layout/index.vue'
|
||||
import Login from '@/views/Login/index.vue'
|
||||
import OperationGuide from '@/views/OperationGuide/index.vue'
|
||||
import OrderCompletion from '@/views/OrderCompletion/index.vue'
|
||||
import QualityInquiry from '@/views/QualityInquiry/index.vue'
|
||||
import Andon from '@/views/Andon/index.vue'
|
||||
import DeviceManagement from '@/views/EquipmentMaintenance/index.vue'
|
||||
import MaterialPull from '@/views/MaterialPull/index.vue'
|
||||
import RepairManagement from '@/views/RepairManagement/index.vue'
|
||||
import CheckTodayPlan from '@/views/CheckTodayPlan/index.vue'
|
||||
|
||||
Vue.use(Router)
|
||||
export const constantRouterMap = [
|
||||
{
|
||||
path: '/',
|
||||
name: 'Login',
|
||||
component: Login
|
||||
},
|
||||
{
|
||||
path: '/layout',
|
||||
name: 'layout',
|
||||
component: layout,
|
||||
children: [
|
||||
{
|
||||
path: '/OperationGuide',
|
||||
name: 'OperationGuide',
|
||||
component: OperationGuide
|
||||
// meta: {
|
||||
// keepAlive: true
|
||||
// }
|
||||
},
|
||||
{
|
||||
path: '/OrderCompletion',
|
||||
name: 'OrderCompletion',
|
||||
component: OrderCompletion
|
||||
},
|
||||
{
|
||||
path: '/QualityInquiry',
|
||||
name: 'QualityInquiry',
|
||||
component: QualityInquiry
|
||||
},
|
||||
{
|
||||
path: '/Andon',
|
||||
name: 'Andon',
|
||||
component: Andon
|
||||
},
|
||||
{
|
||||
path: '/DeviceManagement',
|
||||
name: 'DeviceManagement',
|
||||
component: DeviceManagement
|
||||
},
|
||||
{
|
||||
path: '/MaterialPull',
|
||||
name: 'MaterialPull',
|
||||
component: MaterialPull
|
||||
},
|
||||
{
|
||||
path: '/RepairManagement',
|
||||
name: 'RepairManagement',
|
||||
component: RepairManagement
|
||||
}
|
||||
,
|
||||
{
|
||||
path: '/CheckTodayPlan',
|
||||
name: 'CheckTodayPlan',
|
||||
component: CheckTodayPlan
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
export default new Router({
|
||||
scrollBehavior: () => ({ y: 0 }),
|
||||
routes: constantRouterMap
|
||||
})
|
||||
|
||||
24
src/store/getters.js
Normal file
@@ -0,0 +1,24 @@
|
||||
const getters = {
|
||||
sidebar: state => state.app.sidebar,
|
||||
device: state => state.app.device,
|
||||
token: state => state.user.token,
|
||||
avatar: state => state.user.avatar,
|
||||
name: state => state.user.name,
|
||||
roles: state => state.user.roles,
|
||||
visitedViews: state => state.tagsView.visitedViews,
|
||||
cachedViews: state => state.tagsView.cachedViews,
|
||||
permission_routers: state => state.permission.routers,
|
||||
addRouters: state => state.permission.addRouters,
|
||||
id: state => state.user.id,
|
||||
processList_table: state => state.operationGuide.processList_table,
|
||||
materialList_table: state => state.operationGuide.materialList_table,
|
||||
pic: state => state.operationGuide.pic,
|
||||
partAssemblyInformation: state => state.operationGuide.partAssemblyInformation,
|
||||
engineValue: state => state.station.engineValue,
|
||||
tighteningPosition: state => state.operationGuide.tighteningPosition,
|
||||
smile: state => state.operationGuide.smile,
|
||||
greenBoltInformation: state => state.operationGuide.greenBoltInformation,
|
||||
account: state => state.user.account,
|
||||
orderCompletion_table: state => state.orderCompletion.orderCompletion_table
|
||||
}
|
||||
export default getters
|
||||
29
src/store/index.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import app from './modules/app'
|
||||
import tagsView from './modules/tagsView'
|
||||
import user from './modules/user'
|
||||
import orderCompletion from './modules/orderCompletion'
|
||||
import permission from './modules/permission'
|
||||
import station from './modules/station'
|
||||
import operationGuide from './modules/operationGuide'
|
||||
import mqttServer from './modules/mqttServer'
|
||||
import getters from './getters'
|
||||
|
||||
Vue.use(Vuex)
|
||||
|
||||
const store = new Vuex.Store({
|
||||
modules: {
|
||||
app,
|
||||
user,
|
||||
tagsView,
|
||||
permission,
|
||||
station,
|
||||
operationGuide,
|
||||
mqttServer,
|
||||
orderCompletion
|
||||
},
|
||||
getters
|
||||
})
|
||||
|
||||
export default store
|
||||
43
src/store/modules/app.js
Normal file
@@ -0,0 +1,43 @@
|
||||
import Cookies from 'js-cookie'
|
||||
|
||||
const app = {
|
||||
state: {
|
||||
sidebar: {
|
||||
opened: !+Cookies.get('sidebarStatus'),
|
||||
withoutAnimation: false
|
||||
},
|
||||
device: 'desktop'
|
||||
},
|
||||
mutations: {
|
||||
TOGGLE_SIDEBAR: state => {
|
||||
if (state.sidebar.opened) {
|
||||
Cookies.set('sidebarStatus', 1)
|
||||
} else {
|
||||
Cookies.set('sidebarStatus', 0)
|
||||
}
|
||||
state.sidebar.opened = !state.sidebar.opened
|
||||
state.sidebar.withoutAnimation = false
|
||||
},
|
||||
CLOSE_SIDEBAR: (state, withoutAnimation) => {
|
||||
Cookies.set('sidebarStatus', 1)
|
||||
state.sidebar.opened = false
|
||||
state.sidebar.withoutAnimation = withoutAnimation
|
||||
},
|
||||
TOGGLE_DEVICE: (state, device) => {
|
||||
state.device = device
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
ToggleSideBar: ({ commit }) => {
|
||||
commit('TOGGLE_SIDEBAR')
|
||||
},
|
||||
CloseSideBar({ commit }, { withoutAnimation }) {
|
||||
commit('CLOSE_SIDEBAR', withoutAnimation)
|
||||
},
|
||||
ToggleDevice({ commit }, device) {
|
||||
commit('TOGGLE_DEVICE', device)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default app
|
||||
87
src/store/modules/mesUser.js
Normal file
@@ -0,0 +1,87 @@
|
||||
import { getToken, setToken, removeToken } from '@/utils/auth'
|
||||
import Cookies from 'js-cookie'
|
||||
import { Message } from 'element-ui'
|
||||
import axios from 'axios'
|
||||
import { getPayToken } from '@/utils/request'
|
||||
const user = {
|
||||
state: {
|
||||
token: getToken(),
|
||||
name: Cookies.get('name'),
|
||||
roles: [],
|
||||
id: Cookies.get('id')
|
||||
},
|
||||
|
||||
mutations: {
|
||||
SET_TOKEN: (state, token) => {
|
||||
state.token = token
|
||||
},
|
||||
SET_NAME: (state, name) => {
|
||||
state.name = name
|
||||
},
|
||||
SET_ROLES: (state, roles) => {
|
||||
state.roles = roles
|
||||
},
|
||||
SET_ID: (state, id) => {
|
||||
state.id = id
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
// 登录
|
||||
Login({ commit }, userInfo) {
|
||||
console.log(userInfo.username)
|
||||
const username = userInfo.username.trim()
|
||||
const password = userInfo.password.trim()
|
||||
return new Promise((resolve, reject) => {
|
||||
var url = getPayToken + '?userName=' + username + '&passWord=' + password
|
||||
axios.get(url).then(response => {
|
||||
console.log(response)
|
||||
const data = response.data
|
||||
if (data.IsSuccess === false) {
|
||||
// const h = this.$createElement
|
||||
// this.$message({
|
||||
// message: h('p', null, [
|
||||
// h('span', null, '错误代码: '),
|
||||
// h('i', { style: 'color: teal' }, `${{ data.ErrorCode }}`)
|
||||
// ])
|
||||
// })
|
||||
// Message.error(`错误代码`+`${{ data.ErrorCode }}`+`,`+`${{ data.ErrorDesc }}`)
|
||||
var a = '错误' + response.data.ErrorCode + ',' + data.ErrorDesc
|
||||
Message({
|
||||
showClose: true,
|
||||
message: a,
|
||||
type: 'error'
|
||||
})
|
||||
this.$router.push({ path: '/login' })
|
||||
}
|
||||
if (data.token === '' || data.$id === '' || data === '') {
|
||||
Message.error('账号或密码错误,请重新登录')
|
||||
this.$router.push({ path: '/login' })
|
||||
} else { // 只有一个角色
|
||||
setToken(data.token)
|
||||
Cookies.set('id', data.$id, { expires: 1 })
|
||||
Cookies.set('name', username, { expires: 1 })
|
||||
commit('SET_TOKEN', data.token)
|
||||
commit('SET_NAME', username)
|
||||
commit('SET_ID', data.$id)
|
||||
resolve({ data, commit })
|
||||
}
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
},
|
||||
// 登出
|
||||
FedLogOut({ commit }) {
|
||||
return new Promise(resolve => {
|
||||
commit('SET_TOKEN', '')
|
||||
Cookies.remove('name')
|
||||
Cookies.remove('id')
|
||||
removeToken()
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default user
|
||||
18
src/store/modules/mqttServer.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const mqttServer = {
|
||||
state: {
|
||||
serverIP: sessionStorage.getItem('serverIP') ? sessionStorage.getItem('serverIP') : '',
|
||||
serverPort: sessionStorage.getItem('serverPort') ? sessionStorage.getItem('serverPort') : ''
|
||||
},
|
||||
mutations: {
|
||||
set_serverIP(state, serverIP) {
|
||||
sessionStorage.setItem('serverIP', serverIP)
|
||||
state.serverIP = serverIP
|
||||
},
|
||||
set_serverPort(state, serverPort) {
|
||||
sessionStorage.setItem('serverPort', serverPort)
|
||||
state.serverPort = serverPort
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default mqttServer
|
||||
47
src/store/modules/operationGuide.js
Normal file
@@ -0,0 +1,47 @@
|
||||
const operationGuide = {
|
||||
state: {
|
||||
processList_table: JSON.parse(sessionStorage.getItem('processList_table')) ? JSON.parse(sessionStorage.getItem('processList_table')) : [],
|
||||
materialList_table: JSON.parse(sessionStorage.getItem('materialList_table')) ? JSON.parse(sessionStorage.getItem('materialList_table')) : [],
|
||||
pic: sessionStorage.getItem('pic') ? sessionStorage.getItem('pic') : '',
|
||||
smile: sessionStorage.getItem('smile') ? sessionStorage.getItem('smile') : 0,
|
||||
tighteningPosition: sessionStorage.getItem('tighteningPosition') ? sessionStorage.getItem('tighteningPosition') : [],
|
||||
greenBoltInformation: sessionStorage.getItem('greenBoltInformation') ? sessionStorage.getItem('greenBoltInformation') : [],
|
||||
partAssemblyInformation: {}
|
||||
},
|
||||
mutations: {
|
||||
set_processList_table(state, processList_table) {
|
||||
sessionStorage.setItem('processList_table', JSON.stringify(processList_table))
|
||||
state.processList_table = processList_table
|
||||
},
|
||||
set_materialList_table(state, materialList_table) {
|
||||
sessionStorage.setItem('materialList_table', JSON.stringify(materialList_table))
|
||||
state.materialList_table = materialList_table
|
||||
},
|
||||
set_pic(state, pic) {
|
||||
sessionStorage.setItem('pic', pic)
|
||||
state.pic = pic
|
||||
},
|
||||
set_checkPic(state, checkPic) {
|
||||
sessionStorage.setItem('checkPic', checkPic)
|
||||
state.checkPic = checkPic
|
||||
},
|
||||
set_smile(state, smile) {
|
||||
sessionStorage.setItem('smile', smile)
|
||||
state.smile = smile
|
||||
},
|
||||
set_tighteningPosition(state, tighteningPosition) {
|
||||
sessionStorage.setItem('tighteningPosition', tighteningPosition)
|
||||
state.tighteningPosition = tighteningPosition
|
||||
},
|
||||
set_greenBoltInformation(state, greenBoltInformation) {
|
||||
sessionStorage.setItem('greenBoltInformation', greenBoltInformation)
|
||||
state.greenBoltInformation = greenBoltInformation
|
||||
},
|
||||
set_partAssemblyInformation(state, partAssemblyInformation) {
|
||||
// sessionStorage.setItem('greenBoltInformation', greenBoltInformation)
|
||||
state.partAssemblyInformation = partAssemblyInformation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default operationGuide
|
||||
13
src/store/modules/orderCompletion.js
Normal file
@@ -0,0 +1,13 @@
|
||||
const orderCompletion = {
|
||||
state: {
|
||||
orderCompletion_table: JSON.parse(sessionStorage.getItem('orderCompletion_table')) ? JSON.parse(sessionStorage.getItem('orderCompletion_table')) : []
|
||||
},
|
||||
mutations: {
|
||||
set_orderCompletion_table(state, orderCompletion_table) {
|
||||
sessionStorage.setItem('orderCompletion_table', JSON.stringify(orderCompletion_table))
|
||||
state.orderCompletion_table = orderCompletion_table
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default orderCompletion
|
||||
23
src/store/modules/permission.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import { constantRouterMap } from '@/router'
|
||||
const permission = {
|
||||
state: {
|
||||
routers: constantRouterMap,
|
||||
addRouters: []
|
||||
},
|
||||
mutations: {
|
||||
SET_ROUTERS: (state, routers) => {
|
||||
state.addRouters = routers
|
||||
state.routers = constantRouterMap.concat(routers)
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
GenerateRoutes({ commit }, data) {
|
||||
return new Promise(resolve => {
|
||||
const accessedRouters = data
|
||||
commit('SET_ROUTERS', accessedRouters)
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
export default permission
|
||||
46
src/store/modules/station.js
Normal file
@@ -0,0 +1,46 @@
|
||||
const station = {
|
||||
state: {
|
||||
stationIp: sessionStorage.getItem('stationIp') ? sessionStorage.getItem('stationIp') : '',
|
||||
stationNumber: sessionStorage.getItem('stationNumber') ? sessionStorage.getItem('stationNumber') : '',
|
||||
stationName: sessionStorage.getItem('stationName') ? sessionStorage.getItem('stationName') : '',
|
||||
classesID: sessionStorage.getItem('classesID') ? sessionStorage.getItem('classesID') : '',
|
||||
MesWebCode: sessionStorage.getItem('MesWebCode') ? sessionStorage.getItem('MesWebCode') : '',
|
||||
classes: sessionStorage.getItem('classes') ? sessionStorage.getItem('classes') : '',
|
||||
engineValue: JSON.parse(sessionStorage.getItem('engineValue')) ? JSON.parse(sessionStorage.getItem('engineValue')) : {},
|
||||
clearMaterial : false, // 清料信号
|
||||
},
|
||||
mutations: {
|
||||
set_stationIp(state, stationIp) {
|
||||
sessionStorage.setItem('stationIp', stationIp)
|
||||
state.stationIp = stationIp
|
||||
},
|
||||
set_stationNumber(state, stationNumber) {
|
||||
sessionStorage.setItem('stationNumber', stationNumber)
|
||||
state.stationNumber = stationNumber
|
||||
},
|
||||
set_stationName(state, stationName) {
|
||||
sessionStorage.setItem('stationName', stationName)
|
||||
state.stationName = stationName
|
||||
},
|
||||
set_classesID(state, classesID) {
|
||||
sessionStorage.setItem('classesID', classesID)
|
||||
state.classesID = classesID
|
||||
},
|
||||
set_classes(state, classes) {
|
||||
sessionStorage.setItem('classes', classes)
|
||||
state.classes = classes
|
||||
},
|
||||
set_MesWebCode(state, MesWebCode) {
|
||||
sessionStorage.setItem('MesWebCode', MesWebCode)
|
||||
state.MesWebCode = MesWebCode
|
||||
},
|
||||
set_engineValue(state, engineValue) {
|
||||
sessionStorage.setItem('engineValue', JSON.stringify(engineValue))
|
||||
state.engineValue = engineValue
|
||||
},
|
||||
set_clearMaterial(state, clearMaterial) {
|
||||
state.clearMaterial = clearMaterial
|
||||
},
|
||||
}
|
||||
}
|
||||
export default station
|
||||
78
src/store/modules/tagsView.js
Normal file
@@ -0,0 +1,78 @@
|
||||
const tagsView = {
|
||||
state: {
|
||||
visitedViews: [],
|
||||
cachedViews: []
|
||||
},
|
||||
mutations: {
|
||||
ADD_VISITED_VIEWS: (state, view) => {
|
||||
if (state.visitedViews.some(v => v.path === view.path)) return
|
||||
state.visitedViews.push({
|
||||
name: view.name,
|
||||
path: view.path,
|
||||
title: view.meta.title || 'no-name'
|
||||
})
|
||||
if (!view.meta.noCache) {
|
||||
state.cachedViews.push(view.name)
|
||||
}
|
||||
},
|
||||
DEL_VISITED_VIEWS: (state, view) => {
|
||||
for (const [i, v] of state.visitedViews.entries()) {
|
||||
if (v.path === view.path) {
|
||||
state.visitedViews.splice(i, 1)
|
||||
break
|
||||
}
|
||||
}
|
||||
for (const i of state.cachedViews) {
|
||||
if (i === view.name) {
|
||||
const index = state.cachedViews.indexOf(i)
|
||||
state.cachedViews.splice(index, 1)
|
||||
break
|
||||
}
|
||||
}
|
||||
},
|
||||
DEL_OTHERS_VIEWS: (state, view) => {
|
||||
for (const [i, v] of state.visitedViews.entries()) {
|
||||
if (v.path === view.path) {
|
||||
state.visitedViews = state.visitedViews.slice(i, i + 1)
|
||||
break
|
||||
}
|
||||
}
|
||||
for (const i of state.cachedViews) {
|
||||
if (i === view.name) {
|
||||
const index = state.cachedViews.indexOf(i)
|
||||
state.cachedViews = state.cachedViews.slice(index, i + 1)
|
||||
break
|
||||
}
|
||||
}
|
||||
},
|
||||
DEL_ALL_VIEWS: (state) => {
|
||||
state.visitedViews = []
|
||||
state.cachedViews = []
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
addVisitedViews({ commit }, view) {
|
||||
commit('ADD_VISITED_VIEWS', view)
|
||||
},
|
||||
delVisitedViews({ commit, state }, view) {
|
||||
return new Promise((resolve) => {
|
||||
commit('DEL_VISITED_VIEWS', view)
|
||||
resolve([...state.visitedViews])
|
||||
})
|
||||
},
|
||||
delOthersViews({ commit, state }, view) {
|
||||
return new Promise((resolve) => {
|
||||
commit('DEL_OTHERS_VIEWS', view)
|
||||
resolve([...state.visitedViews])
|
||||
})
|
||||
},
|
||||
delAllViews({ commit, state }) {
|
||||
return new Promise((resolve) => {
|
||||
commit('DEL_ALL_VIEWS')
|
||||
resolve([...state.visitedViews])
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default tagsView
|
||||
100
src/store/modules/user.js
Normal file
@@ -0,0 +1,100 @@
|
||||
import { login, getInfo } from '@/api/login'
|
||||
import { getToken, setToken, removeToken } from '@/utils/auth'
|
||||
import Cookies from 'js-cookie'
|
||||
import { Message } from 'element-ui'
|
||||
const user = {
|
||||
state: {
|
||||
token: getToken(),
|
||||
name: Cookies.get('name'),
|
||||
roles: [],
|
||||
id: Cookies.get('id'),
|
||||
account: ''
|
||||
},
|
||||
|
||||
mutations: {
|
||||
SET_TOKEN: (state, token) => {
|
||||
state.token = token
|
||||
},
|
||||
SET_NAME: (state, name) => {
|
||||
state.name = name
|
||||
},
|
||||
SET_ROLES: (state, roles) => {
|
||||
state.roles = roles
|
||||
},
|
||||
SET_ID: (state, id) => {
|
||||
state.id = id
|
||||
},
|
||||
SET_account: (state, account) => {
|
||||
state.account = account
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
// 登录
|
||||
Login({ commit }, userInfo) {
|
||||
const username = userInfo.username.trim()
|
||||
return new Promise((resolve, reject) => {
|
||||
login(username, userInfo.password).then(response => {
|
||||
let data = response.data
|
||||
if (data.length === 0 || data.result === '0') {
|
||||
Message.error('账号或密码错误,请重新登录')
|
||||
this.$router.push({ path: '/login' })
|
||||
} else if (data.length === 1) { // 只有一个角色
|
||||
setToken(data[0].角色代码)
|
||||
Cookies.set('id', data[0].人员编号, { expires: 1 })
|
||||
Cookies.set('name', data[0].姓名, { expires: 1 })
|
||||
// commit('SET_TOKEN', data[0].角色代码)
|
||||
commit('SET_NAME', data[0].姓名)
|
||||
commit('SET_ID', data[0].人员编号)
|
||||
commit('SET_account', data[0].考勤编号, { expires: 1 })
|
||||
resolve({ data, commit })
|
||||
} else { // 多个角色
|
||||
var res = []
|
||||
var resRole = []
|
||||
data.forEach(item => {
|
||||
resRole.includes(item.Roles_Function) ? '' : (res.push(item), resRole.push(item.Roles_Function))
|
||||
})
|
||||
if (res.length === 1) {
|
||||
setToken(data[0].角色代码)
|
||||
Cookies.set('id', data[0].人员编号, { expires: 1 })
|
||||
Cookies.set('name', data[0].姓名, { expires: 1 })
|
||||
// commit('SET_TOKEN', data[0].角色代码)
|
||||
commit('SET_NAME', data[0].姓名)
|
||||
commit('SET_ID', data[0].人员编号)
|
||||
commit('SET_account', data[0].考勤编号, { expires: 1 })
|
||||
resolve({ data, commit })
|
||||
}
|
||||
data = res
|
||||
resolve({ data, commit })
|
||||
}
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
},
|
||||
// 获取用户信息
|
||||
GetInfo({ commit, state }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getInfo(state.token).then(response => {
|
||||
commit('SET_ROLES', 'admin')
|
||||
resolve(response)
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
},
|
||||
// 登出
|
||||
FedLogOut({ commit }) {
|
||||
return new Promise(resolve => {
|
||||
commit('SET_TOKEN', '')
|
||||
Cookies.remove('name')
|
||||
Cookies.remove('id')
|
||||
Cookies.remove('account')
|
||||
removeToken()
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default user
|
||||
29
src/styles/element-ui.scss
Normal file
@@ -0,0 +1,29 @@
|
||||
//to reset element-ui default css
|
||||
.el-upload {
|
||||
input[type="file"] {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
.el-upload__input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
//暂时性解决diolag 问题 https://github.com/ElemeFE/element/issues/2461
|
||||
.el-dialog {
|
||||
transform: none;
|
||||
left: 0;
|
||||
position: relative;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
//element ui upload
|
||||
.upload-container {
|
||||
.el-upload {
|
||||
width: 100%;
|
||||
.el-upload-dragger {
|
||||
width: 100%;
|
||||
height: 200px;
|
||||
}
|
||||
}
|
||||
}
|
||||
140
src/styles/index.scss
Normal file
@@ -0,0 +1,140 @@
|
||||
@import './variables.scss';
|
||||
@import './mixin.scss';
|
||||
@import './transition.scss';
|
||||
@import './element-ui.scss';
|
||||
@import './sidebar.scss';
|
||||
@import '../assets/font/Misans.css';
|
||||
|
||||
HTML{
|
||||
overflow: auto;
|
||||
}
|
||||
body {
|
||||
height: 100%;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
text-rendering: optimizeLegibility;
|
||||
font-family: MiSans Demibold, serif;
|
||||
}
|
||||
|
||||
label {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
html {
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
#app{
|
||||
height: 100%;
|
||||
.sidebar-container{
|
||||
background-color: #2e296a;
|
||||
}
|
||||
}
|
||||
|
||||
*,
|
||||
*:before,
|
||||
*:after {
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
a,
|
||||
a:focus,
|
||||
a:hover {
|
||||
cursor: pointer;
|
||||
color: inherit;
|
||||
outline: none;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
div:focus{
|
||||
outline: none;
|
||||
}
|
||||
|
||||
a:focus,
|
||||
a:active {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
a,
|
||||
a:focus,
|
||||
a:hover {
|
||||
cursor: pointer;
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.clearfix {
|
||||
&:after {
|
||||
visibility: hidden;
|
||||
display: block;
|
||||
font-size: 0;
|
||||
content: " ";
|
||||
clear: both;
|
||||
height: 0;
|
||||
}
|
||||
}
|
||||
|
||||
//main-container全局样式
|
||||
.app-main{
|
||||
min-height: 100%;
|
||||
min-width: 1220px;
|
||||
max-height: 1800px;
|
||||
}
|
||||
|
||||
.app-container {
|
||||
padding: 20px;
|
||||
//background-color: #ebf1ee;
|
||||
}
|
||||
|
||||
.navbar{
|
||||
background-color: #2D3C67!important;
|
||||
}
|
||||
.submenu-title-noDropdown{
|
||||
background-color: black!important;
|
||||
color: #00893D!important;
|
||||
}
|
||||
.el-menu-item.is-active{
|
||||
color:#2456E6!important;
|
||||
}
|
||||
el-form-item__content{
|
||||
background-color: #00893D!important;
|
||||
}
|
||||
.el-menu-item:hover{
|
||||
background-color: #00893D !important;
|
||||
color: #fff!important;
|
||||
}
|
||||
.el-menu-item, .el-submenu__title{
|
||||
line-height: 42px;
|
||||
height: 42px;
|
||||
background-color: #F5F5F5!important;
|
||||
color: #000000!important;
|
||||
}
|
||||
.el-scrollbar{
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.el-submenu__title{
|
||||
color: #000000!important;
|
||||
background-color: #F5F5F5!important;
|
||||
}
|
||||
.el-button--success {
|
||||
color: #fff;
|
||||
background-color: #67c23a ;
|
||||
border-color: #67c23a ;
|
||||
}
|
||||
.el-button--success.is-plain {
|
||||
color: #67c23a!important;
|
||||
background: #FAFAFA!important;
|
||||
border-color: #67c23a!important;
|
||||
}
|
||||
.el-button--success:hover{
|
||||
color: #FAFAFA!important;
|
||||
background-color: #67c23a!important;
|
||||
border-color: #67c23a!important;
|
||||
}
|
||||
.el-button--success:focus{
|
||||
color: #FAFAFA!important;
|
||||
background-color: #67c23a!important;
|
||||
border-color: #67c23a!important;
|
||||
}
|
||||
27
src/styles/mixin.scss
Normal file
@@ -0,0 +1,27 @@
|
||||
@mixin clearfix {
|
||||
&:after {
|
||||
content: "";
|
||||
display: table;
|
||||
clear: both;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin scrollBar {
|
||||
&::-webkit-scrollbar-track-piece {
|
||||
background: #d3dce6;
|
||||
}
|
||||
&::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: #99a9bf;
|
||||
border-radius: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin relative {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
123
src/styles/sidebar.scss
Normal file
@@ -0,0 +1,123 @@
|
||||
#app {
|
||||
// 主体区域
|
||||
.main-container {
|
||||
min-height: 100%;
|
||||
transition: margin-left .28s;
|
||||
margin-left: 200px;
|
||||
position: relative;
|
||||
}
|
||||
// 侧边栏
|
||||
.sidebar-container {
|
||||
transition: width 0.28s;
|
||||
width: 200px !important;
|
||||
height: 100%;
|
||||
position: fixed;
|
||||
font-size: 0px;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 1001;
|
||||
overflow: hidden;
|
||||
//reset element-ui css
|
||||
.horizontal-collapse-transition {
|
||||
transition: 0s width ease-in-out, 0s padding-left ease-in-out, 0s padding-right ease-in-out;
|
||||
}
|
||||
.el-scrollbar__bar.is-vertical{
|
||||
right: 0px;
|
||||
}
|
||||
.scrollbar-wrapper {
|
||||
overflow-x: hidden!important;
|
||||
.el-scrollbar__view {
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
.is-horizontal {
|
||||
display: none;
|
||||
}
|
||||
a {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
.svg-icon {
|
||||
margin-right: 16px;
|
||||
}
|
||||
.el-menu {
|
||||
border: none;
|
||||
height: 100%;
|
||||
background: #F5F5F5!important;
|
||||
width: 100% !important;
|
||||
}
|
||||
}
|
||||
.hideSidebar {
|
||||
.sidebar-container {
|
||||
width: 36px !important;
|
||||
}
|
||||
.main-container {
|
||||
margin-left: 36px;
|
||||
}
|
||||
.submenu-title-noDropdown {
|
||||
padding-left: 10px !important;
|
||||
position: relative;
|
||||
.el-tooltip {
|
||||
padding: 0 10px !important;
|
||||
}
|
||||
}
|
||||
.el-submenu {
|
||||
overflow: hidden;
|
||||
&>.el-submenu__title {
|
||||
padding-left: 10px !important;
|
||||
.el-submenu__icon-arrow {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
.el-menu--collapse {
|
||||
.el-submenu {
|
||||
&>.el-submenu__title {
|
||||
&>span {
|
||||
height: 0;
|
||||
width: 0;
|
||||
overflow: hidden;
|
||||
visibility: hidden;
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.sidebar-container .nest-menu .el-submenu>.el-submenu__title,
|
||||
.sidebar-container .el-submenu .el-menu-item {
|
||||
min-width: 200px !important;
|
||||
background-color: $subMenuBg !important;
|
||||
&:hover {
|
||||
background-color: $menuHover !important;
|
||||
}
|
||||
}
|
||||
.el-menu--collapse .el-menu .el-submenu {
|
||||
min-width: 180px !important;
|
||||
}
|
||||
|
||||
//适配移动端
|
||||
.mobile {
|
||||
.main-container {
|
||||
margin-left: 0px;
|
||||
}
|
||||
.sidebar-container {
|
||||
transition: transform .28s;
|
||||
width: 180px !important;
|
||||
}
|
||||
&.hideSidebar {
|
||||
.sidebar-container {
|
||||
transition-duration: 0.3s;
|
||||
transform: translate3d(-180px, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
.withoutAnimation {
|
||||
.main-container,
|
||||
.sidebar-container {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
46
src/styles/transition.scss
Normal file
@@ -0,0 +1,46 @@
|
||||
//globl transition css
|
||||
|
||||
/*fade*/
|
||||
.fade-enter-active,
|
||||
.fade-leave-active {
|
||||
transition: opacity 0.28s;
|
||||
}
|
||||
|
||||
.fade-enter,
|
||||
.fade-leave-active {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
/*fade-transform*/
|
||||
.fade-transform-leave-active,
|
||||
.fade-transform-enter-active {
|
||||
transition: all .5s;
|
||||
}
|
||||
.fade-transform-enter {
|
||||
opacity: 0;
|
||||
transform: translateX(-30px);
|
||||
}
|
||||
.fade-transform-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateX(30px);
|
||||
}
|
||||
|
||||
/*fade*/
|
||||
.breadcrumb-enter-active,
|
||||
.breadcrumb-leave-active {
|
||||
transition: all .5s;
|
||||
}
|
||||
|
||||
.breadcrumb-enter,
|
||||
.breadcrumb-leave-active {
|
||||
opacity: 0;
|
||||
transform: translateX(20px);
|
||||
}
|
||||
|
||||
.breadcrumb-move {
|
||||
transition: all .5s;
|
||||
}
|
||||
|
||||
.breadcrumb-leave-active {
|
||||
position: absolute;
|
||||
}
|
||||
4
src/styles/variables.scss
Normal file
@@ -0,0 +1,4 @@
|
||||
//sidebar
|
||||
$menuBg:#2D3C67;
|
||||
$subMenuBg:#F8F8FF;
|
||||
$menuHover:#2D3C67;
|
||||
15
src/utils/auth.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import Cookies from 'js-cookie'
|
||||
|
||||
const TokenKey = 'Admin-Token'
|
||||
|
||||
export function getToken() {
|
||||
return Cookies.get(TokenKey)
|
||||
}
|
||||
|
||||
export function setToken(token) {
|
||||
return Cookies.set(TokenKey, token)
|
||||
}
|
||||
|
||||
export function removeToken() {
|
||||
return Cookies.remove(TokenKey)
|
||||
}
|
||||
380
src/utils/curd.js
Normal file
@@ -0,0 +1,380 @@
|
||||
import { type } from './tool' // type判断传入值的类型,比typeof更详细
|
||||
// import axios from 'axios'
|
||||
// import { url } from '../main'
|
||||
import { ExcelDownLoad } from '@/utils/request'
|
||||
export default {
|
||||
install(Vue) {
|
||||
Vue.prototype.exportExcel_NPOI = function(param, blob) {
|
||||
download(`${ExcelDownLoad}?param=${param}`, blob)
|
||||
}
|
||||
// 用于生成传通讯服务器参数。
|
||||
// 传入参数
|
||||
// 1)type:11查询;12增删改,必须
|
||||
// 2)name:存储过程名,必须
|
||||
// 3)data:存储过程参数名和对应值,例如:
|
||||
// this.param[0] = ['设备类型编码', '3', 'string', '0']
|
||||
// this.param[1] = ['output', '3', 'int', '1'],必须
|
||||
// 数组里四个分别对应:存储过程参数名(必须);存储过程参数值(必须);参数类型(若是output必须);参数是否为output(0否1是)
|
||||
// 4)pageSize,pageCurrent:分页使用,可选
|
||||
|
||||
Vue.prototype.CreateData = function(type, name, data, pageSize, pageList) {
|
||||
var param_Str = ''
|
||||
var param_array = []
|
||||
if (type === '7') {
|
||||
data.map(v => {
|
||||
pageSize.map(h => {
|
||||
const val = h.toString()
|
||||
if (!v[val]) {
|
||||
this.$set(v, val, '')
|
||||
}
|
||||
})
|
||||
})
|
||||
param_Str = data
|
||||
} else {
|
||||
if (data !== undefined) {
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
param_array.push({
|
||||
name: data[i][0],
|
||||
value: data[i][1],
|
||||
type: data[i][2],
|
||||
output: data[i][3]
|
||||
})
|
||||
}
|
||||
param_Str = JSON.stringify(param_array)
|
||||
}
|
||||
}
|
||||
var obj = []
|
||||
obj[0] = {}
|
||||
obj[0].type = type
|
||||
obj[0].name = name
|
||||
obj[0].param = param_Str
|
||||
obj[0].pageSize = pageSize
|
||||
obj[0].pageList = pageList
|
||||
obj[0].pageList = pageList
|
||||
obj[0].UserID = this.id
|
||||
obj[0].ModularID = this.$router.currentRoute.path
|
||||
var numn = JSON.stringify(obj[0])
|
||||
return numn
|
||||
}
|
||||
Vue.prototype.CreateData1 = function(type, name, data, pageSize, pageList) {
|
||||
var param_Str = ''
|
||||
var param_array = []
|
||||
if (data !== undefined) {
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
param_array.push({
|
||||
name: data[i][0],
|
||||
value: data[i][1],
|
||||
type: data[i][2],
|
||||
output: data[i][3]
|
||||
})
|
||||
}
|
||||
param_Str = JSON.stringify(param_array)
|
||||
}
|
||||
var obj = []
|
||||
obj[0] = {}
|
||||
obj[0].type = type
|
||||
obj[0].name = name
|
||||
obj[0].param = param_Str
|
||||
obj[0].pageSize = pageSize
|
||||
obj[0].pageList = pageList
|
||||
var numn = JSON.stringify(obj[0])
|
||||
return numn
|
||||
}
|
||||
// 生成
|
||||
Vue.prototype.CreatePost = function(data) {
|
||||
var param_Str = ''
|
||||
var param_array = []
|
||||
if (data !== undefined) {
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
param_array.push({
|
||||
name: data[i][0],
|
||||
value: data[i][1]
|
||||
})
|
||||
}
|
||||
param_Str = JSON.stringify(param_array)
|
||||
}
|
||||
var obj = []
|
||||
obj[0] = {}
|
||||
obj[0].param = param_Str
|
||||
var numn = JSON.stringify(obj[0])
|
||||
return numn
|
||||
}
|
||||
// 用于打开增加框,方法能重置表单,并使表单内容回到初始化状态。
|
||||
// 传入参数
|
||||
// 1)表单名称,字符串形式如'form',必须
|
||||
// 2) 打开表单后需要做什么,可以传数组[this.dialogvisiale = false, fetchData],也可以传回调函数function() { this.dialogvisiale = false } 可选
|
||||
Vue.prototype.addForm = function(form, callback) {
|
||||
if (type(form) === 'string') {
|
||||
if (this.$refs[form]) { // 判断是否需要重置表单,如果需要重置表单
|
||||
this.$refs[form].resetFields()
|
||||
}
|
||||
if (type(callback) === 'array') { // 判断传入是否为数组,如果是遍历数组,遇到函数将函数体变成函数执行,其余正常执行
|
||||
if (callback && callback.length !== 0) {
|
||||
for (let i = 0, len = callback.length; i < len; i++) {
|
||||
typeof callback[i] === 'function' ? callback[i]() : callback[i]
|
||||
}
|
||||
}
|
||||
} else if (type(callback) === 'function') { // 判断传入是否为回调函数
|
||||
callback.call(this) // 回调函数执行,需将this改为该组件
|
||||
}
|
||||
this[form] = Object.assign(this.$data[form], this.$options.data()[form]) // 将表单中的数据变为初始状态。其中,this.$options.data是所有初始化的数据,this.$data是目前的数据
|
||||
} else {
|
||||
console.error('传入参数错误')
|
||||
}
|
||||
}
|
||||
// 用于打开编辑框,方法能自动传入行的数据到对应的表单中,并将表单中所有纯数字转成int。前提是行的名称需跟表单名称一样。
|
||||
// 传入参数
|
||||
// 1) 编辑这一行的row
|
||||
// 2)表单名称,字符串形式如'form'
|
||||
// 3) 打开编辑需要做什么,同样是[] 和 function
|
||||
Vue.prototype.editForm = function(row, form, callback) {
|
||||
if (type(row) === 'object' && type(form) === 'string') {
|
||||
if (this.$refs[form]) { // 判断是否需要重置表单
|
||||
this.$refs[form].resetFields()
|
||||
}
|
||||
const isNum = /^[0-9]+$/ // 正则表达式,是否全都为纯数字
|
||||
for (const prop in this[form]) { // 遍历表单,当表单和row中属性名一样时,表单row中的属性赋值给form
|
||||
isNum.lastIndex = 0 // 正则每一次匹配后的索引归0,否则循环会造成问题
|
||||
isNum.exec(row[prop]) ? this[form][prop] = parseInt(row[prop]) : this[form][prop] = row[prop] // 通过正则匹配数字,当匹配成功后,将字符串转为int。当然你也不用担心空转成NaN,因为''匹配通不过!
|
||||
}
|
||||
if (type(callback) === 'array') { // 这部分处理与打开表单相同
|
||||
if (callback && callback.length !== 0) {
|
||||
for (let i = 0, len = callback.length; i < len; i++) {
|
||||
typeof callback[i] === 'function' ? callback[i]() : callback[i]
|
||||
}
|
||||
}
|
||||
} else if (type(callback) === 'function') {
|
||||
callback.call(this)
|
||||
}
|
||||
} else {
|
||||
console.error('传入参数错误')
|
||||
}
|
||||
}
|
||||
// 用于获取下拉框中的数据
|
||||
// 传入参数
|
||||
// 1)请求数据函数引用如getXXX,必须
|
||||
// 2)数组的实行名称['XXXX名称', 'XXXX代码'],必须
|
||||
// 3)需要用哪个数组接收这个结果,字符串形式。如在组件也需要用this.select,传入值就为'select',必须
|
||||
// 4) 请求函数传入的参数,可选
|
||||
Vue.prototype.getSelect = function(requestData, select, carrier, param) {
|
||||
if (type(requestData) === 'function' && type(select) === 'array' && type(carrier) === 'string') {
|
||||
if (type(param) === 'array') {
|
||||
requestData(...param).then(response => { // 这个方法没什么难度,不注释了
|
||||
this[carrier] = []
|
||||
for (let i = 0, len = response.data.length; i < len; i++) {
|
||||
if (select.length === 2) {
|
||||
this[carrier].push({
|
||||
label: response.data[i][select[0]],
|
||||
value: response.data[i][select[1]]
|
||||
})
|
||||
} else {
|
||||
this[carrier].push({
|
||||
value: response.data[i][select[0]]
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
requestData(param).then(response => { // 这个方法没什么难度,不注释了
|
||||
this[carrier] = []
|
||||
for (let i = 0, len = response.data.length; i < len; i++) {
|
||||
if (select.length === 2) {
|
||||
this[carrier].push({
|
||||
label: response.data[i][select[0]],
|
||||
value: response.data[i][select[1]]
|
||||
})
|
||||
} else {
|
||||
this[carrier].push({
|
||||
value: response.data[i][select[0]]
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
console.error('参数传递错误')
|
||||
}
|
||||
}
|
||||
// 普通获取数据
|
||||
// 传入参数
|
||||
// 1) 请求数据函数引用如getXXX,必须
|
||||
// 2) 需要用哪个数组接收这个结果,字符串形式。如在组件也需要用this.select,传入值就为'select',必须
|
||||
// 3) 请求函数传入的参数,可选
|
||||
Vue.prototype.getData = function(requestData, carrier, param) {
|
||||
if (type(requestData) === 'function' && type(carrier) === 'string') {
|
||||
if (type(param) === 'undefined') {
|
||||
requestData(param).then(response => {
|
||||
const data = response.data
|
||||
this[carrier] = data
|
||||
})
|
||||
} else {
|
||||
let Param = []
|
||||
if (type(param) !== 'array') {
|
||||
Param.push(param)
|
||||
} else {
|
||||
Param = param
|
||||
}
|
||||
requestData(...Param).then(response => {
|
||||
const data = response.data
|
||||
this[carrier] = data
|
||||
})
|
||||
}
|
||||
} else {
|
||||
console.error('传入参数错误')
|
||||
}
|
||||
}
|
||||
// 获取表格数据,将表格中的年月日时分秒,转换成年月日
|
||||
// 传入参数
|
||||
// 1)请求数据函数引用如getXXX,必须
|
||||
// 2)请求的参数,可选
|
||||
// 3)接受值,数组,一般是['table','total','loading']顺序不能变
|
||||
Vue.prototype.getTable = function(requestData, param, e) {
|
||||
requestData(...param).then(response => {
|
||||
const data = response.data.rows
|
||||
this[e[0]] = []
|
||||
this[e[1]] = 0
|
||||
if (data && data.length > 0) {
|
||||
const isTime = /^\d{4}([-\/.])\d{1,2}\1\d{1,2}/ // 判断是否是时间的正则表达式
|
||||
for (let i = 0, len = data.length; i < len; i++) { // 循环得到每一条数据
|
||||
for (const prop in data[i]) { // 循环每一条的每一项
|
||||
isTime.lastIndex = 0 // 正则每一次指针复位
|
||||
if (isTime.test(data[i][prop])) { // 判断是否是时间,如果是切割
|
||||
data[i][prop] = data[i][prop].split(' ')[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
this[e[0]] = data
|
||||
this[e[1]] = parseInt(response.data.total)
|
||||
} else {
|
||||
this[e[0]] = []
|
||||
// console.log('暂无数据')
|
||||
}
|
||||
}).then(() => {
|
||||
this[e[2]] = false
|
||||
})
|
||||
}
|
||||
// 添加表格数据
|
||||
// 传入参数
|
||||
// 1) 请求数据函数引用如getXXX,必须
|
||||
// 2) 请求的参数,可选
|
||||
// 3) 验证的表单名称,必须
|
||||
// 4) 回调函数,必须
|
||||
Vue.prototype.addTable = function(requestData, param, form, callback) {
|
||||
if (type(callback) === 'function' && type(requestData) === 'function' && type(form) === 'string') {
|
||||
console.log(this.$refs[form])
|
||||
this.$refs[form].validate((valid) => {
|
||||
console.log(valid)
|
||||
if (valid) {
|
||||
requestData(...param).then(response => {
|
||||
if (response.data[0].result === '1') {
|
||||
this.$message.success('增加成功')
|
||||
callback.call(this)
|
||||
} else { this.$message.error('增加失败') }
|
||||
})
|
||||
} else {
|
||||
console.error('error submit!!')
|
||||
return false
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.error('参数传递错误')
|
||||
}
|
||||
}
|
||||
// 编辑表格数据
|
||||
// 传入参数
|
||||
// 1) 请求数据函数引用如getXXX,必须
|
||||
// 2) 请求的参数,可选
|
||||
// 3) 验证的表单名称,必须
|
||||
// 4) 回调函数,必须
|
||||
Vue.prototype.editTable = function(requestData, param, form, callback) {
|
||||
if (type(callback) === 'function' && type(requestData) === 'function' && type(form) === 'string') {
|
||||
this.$refs[form].validate((valid) => {
|
||||
if (valid) {
|
||||
requestData(...param).then(response => {
|
||||
if (response.data[0].result === '1') {
|
||||
this.$message.success('修改成功')
|
||||
callback.call(this) // 回调函数修正this指向组件本身
|
||||
} else { this.$message.error('修改失败') }
|
||||
})
|
||||
} else {
|
||||
console.error('error submit!!')
|
||||
return false
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.error('参数传递错误')
|
||||
}
|
||||
}
|
||||
// 删除表格数据
|
||||
// 传入参数
|
||||
// 1) 请求数据函数引用如getXXX,必须
|
||||
// 2) id传入删除条件,必须
|
||||
// 3) 回调函数,必须
|
||||
Vue.prototype.deleteRow = function(requestData, id, callback) {
|
||||
if (type(callback) === 'function' && type(requestData) === 'function') {
|
||||
if (this.tableData && this.tableData.length === 1 && this.pageCurrent > 1) { // 判断删除的是否是最后一页最后一行,如果是且不是第一页,页数减一
|
||||
this.pageCurrent--
|
||||
}
|
||||
this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
requestData(id).then(response => {
|
||||
if (response.data[0].result === '1') {
|
||||
this.$message.success('删除成功')
|
||||
callback.call(this) // 回调函数修正this指向组件本身
|
||||
} else { this.$message.error('数据占用') }
|
||||
})
|
||||
}).catch(() => {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: '已取消删除'
|
||||
})
|
||||
})
|
||||
} else {
|
||||
console.error('参数传递错误')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function download(url, imgblob) {
|
||||
getBlob(url, function(blob, filename) {
|
||||
saveAs(blob, filename)
|
||||
}, imgblob)
|
||||
}
|
||||
|
||||
function getBlob(url, cb, imgblob) {
|
||||
var xhr = new XMLHttpRequest()
|
||||
var fromData = new FormData()
|
||||
fromData.append('base64', imgblob)
|
||||
xhr.open('POST', url, true)
|
||||
xhr.responseType = 'blob'
|
||||
xhr.onload = function() {
|
||||
if (xhr.status === 200) {
|
||||
const name = xhr.getResponseHeader('content-disposition').split('=')[1]
|
||||
var filename = decodeURIComponent(name)
|
||||
cb(xhr.response, filename)
|
||||
}
|
||||
}
|
||||
// xhr.send()
|
||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
|
||||
xhr.send(fromData)
|
||||
}
|
||||
|
||||
function saveAs(blob, filename) {
|
||||
if (window.navigator.msSaveOrOpenBlob) {
|
||||
navigator.msSaveBlob(blob, filename)
|
||||
} else {
|
||||
var link = document.createElement('a')
|
||||
var body = document.querySelector('body')
|
||||
link.href = window.URL.createObjectURL(blob)
|
||||
link.download = filename
|
||||
// fix Firefox
|
||||
link.style.display = 'none'
|
||||
body.appendChild(link)
|
||||
link.click()
|
||||
body.removeChild(link)
|
||||
window.URL.revokeObjectURL(link.href)
|
||||
}
|
||||
}
|
||||
104
src/utils/mqtt.js
Normal file
@@ -0,0 +1,104 @@
|
||||
import { v4 as uuid } from 'uuid'
|
||||
import mqtt from 'mqtt'
|
||||
export { Mqtt }
|
||||
class Mqtt {
|
||||
constructor(config) {
|
||||
this.connection = {
|
||||
host: config.host,
|
||||
port: config.port,
|
||||
endpoint: config.endpoint || '/mqtt',
|
||||
clean: config.clean || true,
|
||||
connectTimeout: config.connectTimeout || 4000,
|
||||
reconnectPeriod: config.reconnectPeriod || 4000,
|
||||
clientId: config.clientId || uuid(),
|
||||
username: config.username || '',
|
||||
password: config.password || ''
|
||||
}
|
||||
this.client = {
|
||||
connected: false
|
||||
}
|
||||
}
|
||||
// 创建连接
|
||||
createConnection() {
|
||||
// 连接字符串, 通过协议指定使用的连接方式
|
||||
// ws 未加密 WebSocket 连接
|
||||
// wss 加密 WebSocket 连接
|
||||
// mqtt 未加密 TCP 连接
|
||||
// mqtts 加密 TCP 连接
|
||||
// wxs 微信小程序连接
|
||||
// alis 支付宝小程序连接
|
||||
const { host, port, endpoint, ...options } = this.connection
|
||||
const connectUrl = `ws://${host}:${port}${endpoint}`
|
||||
try {
|
||||
this.client = mqtt.connect(connectUrl, options)
|
||||
} catch (error) {
|
||||
// 连接错位、
|
||||
this.connectError(error)
|
||||
}
|
||||
}
|
||||
connectError(error) {
|
||||
console.log('mqtt.connect error', error)
|
||||
}
|
||||
// 订阅主题
|
||||
doSubscribe(subscription) {
|
||||
const { topic, qos } = subscription
|
||||
let subscribeSuccess = false
|
||||
this.client.subscribe(topic, { qos }, (error, res) => {
|
||||
if (error) {
|
||||
subscribeSuccess = false
|
||||
console.log('Subscribe to topics error', error)
|
||||
} else {
|
||||
subscribeSuccess = true
|
||||
console.log('Subscribe to topics res', res)
|
||||
}
|
||||
})
|
||||
return subscribeSuccess
|
||||
}
|
||||
// 取消订阅
|
||||
doUnSubscribe(subscription) {
|
||||
const { topic } = subscription
|
||||
let unSubscribeSuccess = false
|
||||
this.client.unsubscribe(topic, error => {
|
||||
if (error) {
|
||||
unSubscribeSuccess = false
|
||||
console.log('Unsubscribe error', error)
|
||||
} else {
|
||||
unSubscribeSuccess = true
|
||||
}
|
||||
})
|
||||
return unSubscribeSuccess
|
||||
}
|
||||
// 发送消息
|
||||
doPublish(publish) {
|
||||
const { topic, qos, payload } = publish
|
||||
let doPublishSuccess = false
|
||||
this.client.publish(topic, payload, qos, error => {
|
||||
if (error) {
|
||||
doPublishSuccess = false
|
||||
console.log('Publish error', error)
|
||||
} else {
|
||||
doPublishSuccess = true
|
||||
}
|
||||
})
|
||||
return doPublishSuccess
|
||||
}
|
||||
// 断开连接
|
||||
destroyConnection() {
|
||||
let destroyConnectionSuccess = false
|
||||
if (this.client.connected) {
|
||||
try {
|
||||
this.client.end()
|
||||
this.client = {
|
||||
connected: false
|
||||
}
|
||||
destroyConnectionSuccess = true
|
||||
console.log('Successfully disconnected!')
|
||||
} catch (error) {
|
||||
destroyConnectionSuccess = false
|
||||
console.log('Disconnect failed', error.toString())
|
||||
}
|
||||
}
|
||||
return destroyConnectionSuccess
|
||||
}
|
||||
}
|
||||
|
||||
11
src/utils/request.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import axios from 'axios'
|
||||
|
||||
export const getPayToken = 'http://124.220.15.242:8100/submit/MESgetToken.ashx' // token地址
|
||||
const service = axios.create({
|
||||
baseURL: window.g.baseURL,
|
||||
timeout: 15000 // 请求超时时间
|
||||
})
|
||||
export default service
|
||||
window.service = service
|
||||
axios.defaults.headers.post['Content-Type'] = 'application/json'
|
||||
export const ExcelDownLoad = 'http://124.220.15.242:8100/submit/MESCommonBase.ashx' // 导出excel
|
||||
126
src/utils/tool.js
Normal file
@@ -0,0 +1,126 @@
|
||||
// 数组去重
|
||||
export function arrayUnique(arr) {
|
||||
arr.filter((element, index, arr) => {
|
||||
return arr.indexOf(element) === index
|
||||
})
|
||||
}
|
||||
|
||||
// 数组去重,数组中值是对象
|
||||
export function arrayUnique2(arr, name) {
|
||||
const hash = {}
|
||||
return arr.reduce(function(item, next) {
|
||||
hash[next[name]] ? '' : hash[next[name]] = true && item.push(next)
|
||||
return item
|
||||
}, [])
|
||||
}
|
||||
|
||||
// 时间转时间戳
|
||||
export function timeToStamp(time) {
|
||||
const date = new Date(time)
|
||||
return date.getTime()
|
||||
}
|
||||
|
||||
// 数组的深度拷贝
|
||||
export function arrDeepCopy(arr) {
|
||||
const newArr = []
|
||||
for (const prop in arr) newArr[prop] = typeof arr[prop] === 'object' ? arrDeepCopy(arr[prop]) : arr[prop]
|
||||
return newArr
|
||||
}
|
||||
|
||||
// 对象的深度拷贝
|
||||
export function objDeepCopy(obj) {
|
||||
const newObj = {}
|
||||
for (const prop in obj) newObj[prop] = typeof obj[prop] === 'object' ? objDeepCopy(obj[prop]) : obj[prop]
|
||||
return newObj
|
||||
}
|
||||
|
||||
function zeroFill(i) {
|
||||
if (i >= 0 && i <= 9) {
|
||||
return '0' + i
|
||||
} else {
|
||||
return i
|
||||
}
|
||||
}
|
||||
// 获取当前时间
|
||||
export function getNowTime() {
|
||||
const date = new Date()
|
||||
const month = zeroFill(date.getMonth() + 1)
|
||||
const day = zeroFill(date.getDate())
|
||||
const hour = zeroFill(date.getHours())
|
||||
const minute = zeroFill(date.getMinutes())
|
||||
const second = zeroFill(date.getSeconds())
|
||||
const time = date.getFullYear() + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second
|
||||
return time
|
||||
}
|
||||
export function getNowTime2() {
|
||||
const date = new Date()
|
||||
const month = zeroFill2(date.getMonth())
|
||||
const day = zeroFill(date.getDate())
|
||||
const time = date.getFullYear() + '-' + month + '-' + day
|
||||
return time
|
||||
}
|
||||
function zeroFill2(i) {
|
||||
if (i >= 0 && i <= 9) {
|
||||
if (i === 0) {
|
||||
return '01'
|
||||
} else {
|
||||
return '0' + i
|
||||
}
|
||||
} else {
|
||||
return i
|
||||
}
|
||||
}
|
||||
|
||||
// 判断类型
|
||||
export function type(target) {
|
||||
const ret = typeof (target)
|
||||
const template = {
|
||||
'[object Array]': 'array',
|
||||
'[object Object]': 'object',
|
||||
'[object String]': 'string - object',
|
||||
'[object Number]': 'Number - object',
|
||||
'[object Boolean]': 'Boolean - object'
|
||||
}
|
||||
if (target === null) {
|
||||
return 'null'
|
||||
}
|
||||
if (ret === 'object') {
|
||||
const str = Object.prototype.toString.call(target)
|
||||
return template[str]
|
||||
} else {
|
||||
return ret
|
||||
}
|
||||
}
|
||||
|
||||
export function SectionToChinese(section) {
|
||||
const chnNumChar = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九']
|
||||
const chnUnitChar = ['', '十', '百', '千']
|
||||
let strIns = ''
|
||||
let chnStr = ''
|
||||
let unitPos = 0
|
||||
let zero = true
|
||||
while (section > 0) {
|
||||
const v = section % 10
|
||||
if (v === 0) {
|
||||
if (!zero) {
|
||||
zero = true
|
||||
chnStr = chnNumChar[v] + chnStr
|
||||
}
|
||||
} else {
|
||||
zero = false
|
||||
strIns = chnNumChar[v]
|
||||
strIns += chnUnitChar[unitPos]
|
||||
chnStr = strIns + chnStr
|
||||
}
|
||||
unitPos++
|
||||
section = Math.floor(section / 10)
|
||||
}
|
||||
return chnStr
|
||||
}
|
||||
|
||||
export function sleep(time) {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(resolve, time)
|
||||
})
|
||||
}
|
||||
|
||||
32
src/utils/validate.js
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Created by jiachenpan on 16/11/18.
|
||||
*/
|
||||
|
||||
export function isvalidUsername(str) {
|
||||
const user = /^[0-9]{4,5}$/
|
||||
return user.test(str)
|
||||
}
|
||||
|
||||
/* 合法uri*/
|
||||
export function validateURL(textval) {
|
||||
const urlregex = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/
|
||||
return urlregex.test(textval)
|
||||
}
|
||||
|
||||
/* 小写字母*/
|
||||
export function validateLowerCase(str) {
|
||||
const reg = /^[a-z]+$/
|
||||
return reg.test(str)
|
||||
}
|
||||
|
||||
/* 大写字母*/
|
||||
export function validateUpperCase(str) {
|
||||
const reg = /^[A-Z]+$/
|
||||
return reg.test(str)
|
||||
}
|
||||
|
||||
/* 大小写字母*/
|
||||
export function validatAlphabets(str) {
|
||||
const reg = /^[A-Za-z]+$/
|
||||
return reg.test(str)
|
||||
}
|
||||
179
src/vendor/Blob.js
vendored
Normal file
@@ -0,0 +1,179 @@
|
||||
/* eslint-disable */
|
||||
/* Blob.js
|
||||
* A Blob implementation.
|
||||
* 2014-05-27
|
||||
*
|
||||
* By Eli Grey, http://eligrey.com
|
||||
* By Devin Samarin, https://github.com/eboyjr
|
||||
* License: X11/MIT
|
||||
* See LICENSE.md
|
||||
*/
|
||||
|
||||
/*global self, unescape */
|
||||
/*jslint bitwise: true, regexp: true, confusion: true, es5: true, vars: true, white: true,
|
||||
plusplus: true */
|
||||
|
||||
/*! @source http://purl.eligrey.com/github/Blob.js/blob/master/Blob.js */
|
||||
|
||||
(function (view) {
|
||||
"use strict";
|
||||
|
||||
view.URL = view.URL || view.webkitURL;
|
||||
|
||||
if (view.Blob && view.URL) {
|
||||
try {
|
||||
new Blob;
|
||||
return;
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
// Internally we use a BlobBuilder implementation to base Blob off of
|
||||
// in order to support older browsers that only have BlobBuilder
|
||||
var BlobBuilder = view.BlobBuilder || view.WebKitBlobBuilder || view.MozBlobBuilder || (function(view) {
|
||||
var
|
||||
get_class = function(object) {
|
||||
return Object.prototype.toString.call(object).match(/^\[object\s(.*)\]$/)[1];
|
||||
}
|
||||
, FakeBlobBuilder = function BlobBuilder() {
|
||||
this.data = [];
|
||||
}
|
||||
, FakeBlob = function Blob(data, type, encoding) {
|
||||
this.data = data;
|
||||
this.size = data.length;
|
||||
this.type = type;
|
||||
this.encoding = encoding;
|
||||
}
|
||||
, FBB_proto = FakeBlobBuilder.prototype
|
||||
, FB_proto = FakeBlob.prototype
|
||||
, FileReaderSync = view.FileReaderSync
|
||||
, FileException = function(type) {
|
||||
this.code = this[this.name = type];
|
||||
}
|
||||
, file_ex_codes = (
|
||||
"NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR "
|
||||
+ "NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR"
|
||||
).split(" ")
|
||||
, file_ex_code = file_ex_codes.length
|
||||
, real_URL = view.URL || view.webkitURL || view
|
||||
, real_create_object_URL = real_URL.createObjectURL
|
||||
, real_revoke_object_URL = real_URL.revokeObjectURL
|
||||
, URL = real_URL
|
||||
, btoa = view.btoa
|
||||
, atob = view.atob
|
||||
|
||||
, ArrayBuffer = view.ArrayBuffer
|
||||
, Uint8Array = view.Uint8Array
|
||||
;
|
||||
FakeBlob.fake = FB_proto.fake = true;
|
||||
while (file_ex_code--) {
|
||||
FileException.prototype[file_ex_codes[file_ex_code]] = file_ex_code + 1;
|
||||
}
|
||||
if (!real_URL.createObjectURL) {
|
||||
URL = view.URL = {};
|
||||
}
|
||||
URL.createObjectURL = function(blob) {
|
||||
var
|
||||
type = blob.type
|
||||
, data_URI_header
|
||||
;
|
||||
if (type === null) {
|
||||
type = "application/octet-stream";
|
||||
}
|
||||
if (blob instanceof FakeBlob) {
|
||||
data_URI_header = "data:" + type;
|
||||
if (blob.encoding === "base64") {
|
||||
return data_URI_header + ";base64," + blob.data;
|
||||
} else if (blob.encoding === "URI") {
|
||||
return data_URI_header + "," + decodeURIComponent(blob.data);
|
||||
} if (btoa) {
|
||||
return data_URI_header + ";base64," + btoa(blob.data);
|
||||
} else {
|
||||
return data_URI_header + "," + encodeURIComponent(blob.data);
|
||||
}
|
||||
} else if (real_create_object_URL) {
|
||||
return real_create_object_URL.call(real_URL, blob);
|
||||
}
|
||||
};
|
||||
URL.revokeObjectURL = function(object_URL) {
|
||||
if (object_URL.substring(0, 5) !== "data:" && real_revoke_object_URL) {
|
||||
real_revoke_object_URL.call(real_URL, object_URL);
|
||||
}
|
||||
};
|
||||
FBB_proto.append = function(data/*, endings*/) {
|
||||
var bb = this.data;
|
||||
// decode data to a binary string
|
||||
if (Uint8Array && (data instanceof ArrayBuffer || data instanceof Uint8Array)) {
|
||||
var
|
||||
str = ""
|
||||
, buf = new Uint8Array(data)
|
||||
, i = 0
|
||||
, buf_len = buf.length
|
||||
;
|
||||
for (; i < buf_len; i++) {
|
||||
str += String.fromCharCode(buf[i]);
|
||||
}
|
||||
bb.push(str);
|
||||
} else if (get_class(data) === "Blob" || get_class(data) === "File") {
|
||||
if (FileReaderSync) {
|
||||
var fr = new FileReaderSync;
|
||||
bb.push(fr.readAsBinaryString(data));
|
||||
} else {
|
||||
// async FileReader won't work as BlobBuilder is sync
|
||||
throw new FileException("NOT_READABLE_ERR");
|
||||
}
|
||||
} else if (data instanceof FakeBlob) {
|
||||
if (data.encoding === "base64" && atob) {
|
||||
bb.push(atob(data.data));
|
||||
} else if (data.encoding === "URI") {
|
||||
bb.push(decodeURIComponent(data.data));
|
||||
} else if (data.encoding === "raw") {
|
||||
bb.push(data.data);
|
||||
}
|
||||
} else {
|
||||
if (typeof data !== "string") {
|
||||
data += ""; // convert unsupported types to strings
|
||||
}
|
||||
// decode UTF-16 to binary string
|
||||
bb.push(unescape(encodeURIComponent(data)));
|
||||
}
|
||||
};
|
||||
FBB_proto.getBlob = function(type) {
|
||||
if (!arguments.length) {
|
||||
type = null;
|
||||
}
|
||||
return new FakeBlob(this.data.join(""), type, "raw");
|
||||
};
|
||||
FBB_proto.toString = function() {
|
||||
return "[object BlobBuilder]";
|
||||
};
|
||||
FB_proto.slice = function(start, end, type) {
|
||||
var args = arguments.length;
|
||||
if (args < 3) {
|
||||
type = null;
|
||||
}
|
||||
return new FakeBlob(
|
||||
this.data.slice(start, args > 1 ? end : this.data.length)
|
||||
, type
|
||||
, this.encoding
|
||||
);
|
||||
};
|
||||
FB_proto.toString = function() {
|
||||
return "[object Blob]";
|
||||
};
|
||||
FB_proto.close = function() {
|
||||
this.size = this.data.length = 0;
|
||||
};
|
||||
return FakeBlobBuilder;
|
||||
}(view));
|
||||
|
||||
view.Blob = function Blob(blobParts, options) {
|
||||
var type = options ? (options.type || "") : "";
|
||||
var builder = new BlobBuilder();
|
||||
if (blobParts) {
|
||||
for (var i = 0, len = blobParts.length; i < len; i++) {
|
||||
builder.append(blobParts[i]);
|
||||
}
|
||||
}
|
||||
return builder.getBlob(type);
|
||||
};
|
||||
}(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this.content || this));
|
||||
224
src/vendor/Export2Excel.js
vendored
Normal file
@@ -0,0 +1,224 @@
|
||||
/* eslint-disable */
|
||||
require('script-loader!file-saver');
|
||||
// import XLSX from 'xlsx'
|
||||
import XLSX from 'xlsx-style'
|
||||
function generateArray(table) {
|
||||
var out = [];
|
||||
var rows = table.querySelectorAll('tr');
|
||||
var ranges = [];
|
||||
for (var R = 0; R < rows.length; ++R) {
|
||||
var outRow = [];
|
||||
var row = rows[R];
|
||||
var columns = row.querySelectorAll('td');
|
||||
for (var C = 0; C < columns.length; ++C) {
|
||||
var cell = columns[C];
|
||||
var colspan = cell.getAttribute('colspan');
|
||||
var rowspan = cell.getAttribute('rowspan');
|
||||
var cellValue = cell.innerText;
|
||||
if (cellValue !== "" && cellValue == +cellValue) cellValue = +cellValue;
|
||||
|
||||
//Skip ranges
|
||||
ranges.forEach(function (range) {
|
||||
if (R >= range.s.r && R <= range.e.r && outRow.length >= range.s.c && outRow.length <= range.e.c) {
|
||||
for (var i = 0; i <= range.e.c - range.s.c; ++i) outRow.push(null);
|
||||
}
|
||||
});
|
||||
|
||||
//Handle Row Span
|
||||
if (rowspan || colspan) {
|
||||
rowspan = rowspan || 1;
|
||||
colspan = colspan || 1;
|
||||
ranges.push({
|
||||
s: {
|
||||
r: R,
|
||||
c: outRow.length
|
||||
},
|
||||
e: {
|
||||
r: R + rowspan - 1,
|
||||
c: outRow.length + colspan - 1
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//Handle Value
|
||||
outRow.push(cellValue !== "" ? cellValue : null);
|
||||
|
||||
//Handle Colspan
|
||||
if (colspan)
|
||||
for (var k = 0; k < colspan - 1; ++k) outRow.push(null);
|
||||
}
|
||||
out.push(outRow);
|
||||
}
|
||||
return [out, ranges];
|
||||
};
|
||||
|
||||
function datenum(v, date1904) {
|
||||
if (date1904) v += 1462;
|
||||
var epoch = Date.parse(v);
|
||||
return (epoch - new Date(Date.UTC(1899, 11, 30))) / (24 * 60 * 60 * 1000);
|
||||
}
|
||||
|
||||
function sheet_from_array_of_arrays(data, opts) {
|
||||
var ws = {};
|
||||
var range = {
|
||||
s: {
|
||||
c: 10000000,
|
||||
r: 10000000
|
||||
},
|
||||
e: {
|
||||
c: 0,
|
||||
r: 0
|
||||
}
|
||||
};
|
||||
for (var R = 0; R != data.length; ++R) {
|
||||
for (var C = 0; C != data[R].length; ++C) {
|
||||
if (range.s.r > R) range.s.r = R;
|
||||
if (range.s.c > C) range.s.c = C;
|
||||
if (range.e.r < R) range.e.r = R;
|
||||
if (range.e.c < C) range.e.c = C;
|
||||
var cell = {
|
||||
v: data[R][C]
|
||||
};
|
||||
if (cell.v == null) continue;
|
||||
var cell_ref = XLSX.utils.encode_cell({
|
||||
c: C,
|
||||
r: R
|
||||
});
|
||||
|
||||
if (typeof cell.v === 'number') cell.t = 'n';
|
||||
else if (typeof cell.v === 'boolean') cell.t = 'b';
|
||||
else if (cell.v instanceof Date) {
|
||||
cell.t = 'n';
|
||||
cell.z = XLSX.SSF._table[14];
|
||||
cell.v = datenum(cell.v);
|
||||
} else cell.t = 's';
|
||||
|
||||
ws[cell_ref] = cell;
|
||||
}
|
||||
}
|
||||
if (range.s.c < 10000000) ws['!ref'] = XLSX.utils.encode_range(range);
|
||||
return ws;
|
||||
}
|
||||
|
||||
function Workbook() {
|
||||
if (!(this instanceof Workbook)) return new Workbook();
|
||||
this.SheetNames = [];
|
||||
this.Sheets = {};
|
||||
}
|
||||
|
||||
function s2ab(s) {
|
||||
var buf = new ArrayBuffer(s.length);
|
||||
var view = new Uint8Array(buf);
|
||||
for (var i = 0; i != s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
|
||||
return buf;
|
||||
}
|
||||
|
||||
export function export_table_to_excel(id) {
|
||||
var theTable = document.getElementById(id);
|
||||
var oo = generateArray(theTable);
|
||||
var ranges = oo[1];
|
||||
|
||||
/* original data */
|
||||
var data = oo[0];
|
||||
var ws_name = "SheetJS";
|
||||
|
||||
var wb = new Workbook(),
|
||||
ws = sheet_from_array_of_arrays(data);
|
||||
|
||||
/* add ranges to worksheet */
|
||||
// ws['!cols'] = ['apple', 'banan'];
|
||||
ws['!merges'] = ranges;
|
||||
|
||||
/* add worksheet to workbook */
|
||||
wb.SheetNames.push(ws_name);
|
||||
wb.Sheets[ws_name] = ws;
|
||||
|
||||
var wbout = XLSX.write(wb, {
|
||||
bookType: 'xlsx',
|
||||
bookSST: false,
|
||||
type: 'binary'
|
||||
});
|
||||
|
||||
saveAs(new Blob([s2ab(wbout)], {
|
||||
type: "application/octet-stream"
|
||||
}), "test.xlsx")
|
||||
}
|
||||
|
||||
export function export_json_to_excel({
|
||||
headerGroup,
|
||||
dataGroup,
|
||||
sheetGroup,
|
||||
filename,
|
||||
autoWidth = true,
|
||||
bookType= 'xlsx'
|
||||
} = {}) {
|
||||
var wb = new Workbook()
|
||||
for (let i = 0; i < dataGroup.length; i++) {
|
||||
/* original data */
|
||||
let data = dataGroup[i]
|
||||
filename = filename || 'excel-list'
|
||||
data = [...data]
|
||||
data.unshift(headerGroup[i]);
|
||||
var ws_name = sheetGroup[i];
|
||||
var ws = sheet_from_array_of_arrays(data);
|
||||
|
||||
if (autoWidth) {
|
||||
/*设置worksheet每列的最大宽度*/
|
||||
const colWidth = data.map(row => row.map(val => {
|
||||
/*先判断是否为null/undefined*/
|
||||
if (val == null) {
|
||||
return {
|
||||
'wch': 10
|
||||
};
|
||||
}
|
||||
/*再判断是否为中文*/
|
||||
else if (val.toString().charCodeAt(0) > 255) {
|
||||
return {
|
||||
'wch': val.toString().length * 2
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
'wch': val.toString().length
|
||||
};
|
||||
}
|
||||
}))
|
||||
/*以第一行为初始值*/
|
||||
let result = colWidth[0];
|
||||
for (let i = 1; i < colWidth.length; i++) {
|
||||
for (let j = 0; j < colWidth[i].length; j++) {
|
||||
if (result[j]['wch'] < colWidth[i][j]['wch']) {
|
||||
result[j]['wch'] = colWidth[i][j]['wch'];
|
||||
}
|
||||
}
|
||||
}
|
||||
ws['!cols'] = result;
|
||||
}
|
||||
let R = 0;
|
||||
data.map(item => {
|
||||
let C = 0;
|
||||
item.map(itm => {
|
||||
var cell_ref = XLSX.utils.encode_cell({c:C,r:R});
|
||||
var cell = {v: itm }
|
||||
cell.s= {
|
||||
alignment: {
|
||||
horizontal: "center"
|
||||
}
|
||||
}
|
||||
ws[cell_ref] = cell;
|
||||
C++;
|
||||
})
|
||||
R++;
|
||||
})
|
||||
/* add worksheet to workbook */
|
||||
wb.SheetNames.push(ws_name);
|
||||
wb.Sheets[ws_name] = ws;
|
||||
}
|
||||
var wbout = XLSX.write(wb, {
|
||||
bookType: bookType,
|
||||
bookSST: false,
|
||||
type: 'binary'
|
||||
});
|
||||
saveAs(new Blob([s2ab(wbout)], {
|
||||
type: "application/octet-stream"
|
||||
}), `${filename}.${bookType}`);
|
||||
}
|
||||
1443
src/vendor/Export2Excel1.js
vendored
Normal file
1445
src/vendor/Export2Excel2.js
vendored
Normal file
206
src/vendor/Export2Excelcjn.js
vendored
Normal file
@@ -0,0 +1,206 @@
|
||||
/* eslint-disable */
|
||||
require('script-loader!file-saver');
|
||||
import XLSX from 'xlsx'
|
||||
|
||||
function generateArray(table) {
|
||||
var out = [];
|
||||
var rows = table.querySelectorAll('tr');
|
||||
var ranges = [];
|
||||
for (var R = 0; R < rows.length; ++R) {
|
||||
var outRow = [];
|
||||
var row = rows[R];
|
||||
var columns = row.querySelectorAll('td');
|
||||
for (var C = 0; C < columns.length; ++C) {
|
||||
var cell = columns[C];
|
||||
var colspan = cell.getAttribute('colspan');
|
||||
var rowspan = cell.getAttribute('rowspan');
|
||||
var cellValue = cell.innerText;
|
||||
if (cellValue !== "" && cellValue == +cellValue) cellValue = +cellValue;
|
||||
|
||||
//Skip ranges
|
||||
ranges.forEach(function (range) {
|
||||
if (R >= range.s.r && R <= range.e.r && outRow.length >= range.s.c && outRow.length <= range.e.c) {
|
||||
for (var i = 0; i <= range.e.c - range.s.c; ++i) outRow.push(null);
|
||||
}
|
||||
});
|
||||
|
||||
//Handle Row Span
|
||||
if (rowspan || colspan) {
|
||||
rowspan = rowspan || 1;
|
||||
colspan = colspan || 1;
|
||||
ranges.push({
|
||||
s: {
|
||||
r: R,
|
||||
c: outRow.length
|
||||
},
|
||||
e: {
|
||||
r: R + rowspan - 1,
|
||||
c: outRow.length + colspan - 1
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//Handle Value
|
||||
outRow.push(cellValue !== "" ? cellValue : null);
|
||||
|
||||
//Handle Colspan
|
||||
if (colspan)
|
||||
for (var k = 0; k < colspan - 1; ++k) outRow.push(null);
|
||||
}
|
||||
out.push(outRow);
|
||||
}
|
||||
return [out, ranges];
|
||||
};
|
||||
|
||||
function datenum(v, date1904) {
|
||||
if (date1904) v += 1462;
|
||||
var epoch = Date.parse(v);
|
||||
return (epoch - new Date(Date.UTC(1899, 11, 30))) / (24 * 60 * 60 * 1000);
|
||||
}
|
||||
|
||||
function sheet_from_array_of_arrays(data, opts) {
|
||||
var ws = {};
|
||||
var range = {
|
||||
s: {
|
||||
c: 10000000,
|
||||
r: 10000000
|
||||
},
|
||||
e: {
|
||||
c: 0,
|
||||
r: 0
|
||||
}
|
||||
};
|
||||
for (var R = 0; R != data.length; ++R) {
|
||||
for (var C = 0; C != data[R].length; ++C) {
|
||||
if (range.s.r > R) range.s.r = R;
|
||||
if (range.s.c > C) range.s.c = C;
|
||||
if (range.e.r < R) range.e.r = R;
|
||||
if (range.e.c < C) range.e.c = C;
|
||||
var cell = {
|
||||
v: data[R][C]
|
||||
};
|
||||
if (cell.v == null) continue;
|
||||
var cell_ref = XLSX.utils.encode_cell({
|
||||
c: C,
|
||||
r: R
|
||||
});
|
||||
|
||||
if (typeof cell.v === 'number') cell.t = 'n';
|
||||
else if (typeof cell.v === 'boolean') cell.t = 'b';
|
||||
else if (cell.v instanceof Date) {
|
||||
cell.t = 'n';
|
||||
cell.z = XLSX.SSF._table[14];
|
||||
cell.v = datenum(cell.v);
|
||||
} else cell.t = 's';
|
||||
|
||||
ws[cell_ref] = cell;
|
||||
}
|
||||
}
|
||||
if (range.s.c < 10000000) ws['!ref'] = XLSX.utils.encode_range(range);
|
||||
return ws;
|
||||
}
|
||||
|
||||
function Workbook() {
|
||||
if (!(this instanceof Workbook)) return new Workbook();
|
||||
this.SheetNames = [];
|
||||
this.Sheets = {};
|
||||
}
|
||||
|
||||
function s2ab(s) {
|
||||
var buf = new ArrayBuffer(s.length);
|
||||
var view = new Uint8Array(buf);
|
||||
for (var i = 0; i != s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
|
||||
return buf;
|
||||
}
|
||||
|
||||
export function export_table_to_excel(id) {
|
||||
var theTable = document.getElementById(id);
|
||||
var oo = generateArray(theTable);
|
||||
var ranges = oo[1];
|
||||
|
||||
/* original data */
|
||||
var data = oo[0];
|
||||
var ws_name = "SheetJS";
|
||||
|
||||
var wb = new Workbook(),
|
||||
ws = sheet_from_array_of_arrays(data);
|
||||
|
||||
/* add ranges to worksheet */
|
||||
// ws['!cols'] = ['apple', 'banan'];
|
||||
ws['!merges'] = ranges;
|
||||
|
||||
/* add worksheet to workbook */
|
||||
wb.SheetNames.push(ws_name);
|
||||
wb.Sheets[ws_name] = ws;
|
||||
|
||||
var wbout = XLSX.write(wb, {
|
||||
bookType: 'xlsx',
|
||||
bookSST: false,
|
||||
type: 'binary'
|
||||
});
|
||||
|
||||
saveAs(new Blob([s2ab(wbout)], {
|
||||
type: "application/octet-stream"
|
||||
}), "test.xlsx")
|
||||
}
|
||||
|
||||
export function export_json_to_excel({
|
||||
header,
|
||||
data,
|
||||
filename,
|
||||
autoWidth = true,
|
||||
bookType= 'xlsx'
|
||||
} = {}) {
|
||||
/* original data */
|
||||
filename = filename || 'excel-list'
|
||||
data = [...data]
|
||||
data.unshift(header);
|
||||
var ws_name = filename || 'excel-list';
|
||||
var wb = new Workbook(),
|
||||
ws = sheet_from_array_of_arrays(data);
|
||||
|
||||
if (autoWidth) {
|
||||
/*设置worksheet每列的最大宽度*/
|
||||
const colWidth = data.map(row => row.map(val => {
|
||||
/*先判断是否为null/undefined*/
|
||||
if (val == null) {
|
||||
return {
|
||||
'wch': 10
|
||||
};
|
||||
}
|
||||
/*再判断是否为中文*/
|
||||
else if (val.toString().charCodeAt(0) > 255) {
|
||||
return {
|
||||
'wch': val.toString().length * 2
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
'wch': val.toString().length
|
||||
};
|
||||
}
|
||||
}))
|
||||
/*以第一行为初始值*/
|
||||
let result = colWidth[0];
|
||||
for (let i = 1; i < colWidth.length; i++) {
|
||||
for (let j = 0; j < colWidth[i].length; j++) {
|
||||
if (result[j]['wch'] < colWidth[i][j]['wch']) {
|
||||
result[j]['wch'] = colWidth[i][j]['wch'];
|
||||
}
|
||||
}
|
||||
}
|
||||
ws['!cols'] = result;
|
||||
}
|
||||
|
||||
/* add worksheet to workbook */
|
||||
wb.SheetNames.push(ws_name);
|
||||
wb.Sheets[ws_name] = ws;
|
||||
|
||||
var wbout = XLSX.write(wb, {
|
||||
bookType: bookType,
|
||||
bookSST: false,
|
||||
type: 'binary'
|
||||
});
|
||||
saveAs(new Blob([s2ab(wbout)], {
|
||||
type: "application/octet-stream"
|
||||
}), `${filename}.${bookType}`);
|
||||
}
|
||||