基础开发

This commit is contained in:
2024-09-01 17:24:23 +08:00
commit 81b4328042
63 changed files with 13149 additions and 0 deletions

28
.babelrc Normal file
View File

@@ -0,0 +1,28 @@
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": [
"transform-vue-jsx",
"transform-runtime",
[
"component",
{
"libraryName": "element-ui",
"styleLibraryName": "theme-chalk"
}
]
],
"env": {
"test": {
"presets": ["env", "stage-2"],
"plugins": ["transform-vue-jsx", "transform-es2015-modules-commonjs", "dynamic-import-node"]
}
}
}

9
.editorconfig Normal file
View File

@@ -0,0 +1,9 @@
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

5
.eslintignore Normal file
View File

@@ -0,0 +1,5 @@
/build/
/config/
/dist/
/*.js
/test/unit/coverage/

29
.eslintrc.js Normal file
View File

@@ -0,0 +1,29 @@
// https://eslint.org/docs/user-guide/configuring
module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint'
},
env: {
browser: true,
},
extends: [
// https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
// consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
'plugin:vue/essential',
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
'standard'
],
// required to lint *.vue files
plugins: [
'vue'
],
// add your custom rules here
rules: {
// allow async-await
'generator-star-spacing': 'off',
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
}
}

17
.gitignore vendored Normal file
View File

@@ -0,0 +1,17 @@
.DS_Store
node_modules/
/dist/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
/test/unit/coverage/
/test/e2e/reports/
selenium-debug.log
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln

10
.postcssrc.js Normal file
View File

@@ -0,0 +1,10 @@
// https://github.com/michael-ciniawsky/postcss-load-config
module.exports = {
"plugins": {
"postcss-import": {},
"postcss-url": {},
// to edit target browsers: use "browserslist" field in package.json
"autoprefixer": {}
}
}

33
README.md Normal file
View File

@@ -0,0 +1,33 @@
# nl-aio-hl
> A Vue.js project
## Build Setup
``` bash
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build
# build for production and view the bundle analyzer report
npm run build --report
# run unit tests
npm run unit
# run e2e tests
npm run e2e
# run all tests
npm test
```
For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
# 注意事项
+ 屏幕分辨率800 * 600

41
build/build.js Normal file
View File

@@ -0,0 +1,41 @@
'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, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
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'
))
})
})

54
build/check-versions.js Normal file
View File

@@ -0,0 +1,54 @@
'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

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

102
build/utils.js Normal file
View File

@@ -0,0 +1,102 @@
'use strict'
const path = require('path')
const config = require('../config')
const ExtractTextPlugin = require('extract-text-webpack-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 = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader]
if (loader) {
loaders.push({
loader: loader + '-loader',
options: Object.assign({}, loaderOptions, {
sourceMap: options.sourceMap
})
})
}
// Extract CSS when that option is specified
// (which is the case during production build)
if (options.extract) {
return ExtractTextPlugin.extract({
use: loaders,
publicPath: '../../',
fallback: 'vue-style-loader'
})
} else {
return ['vue-style-loader'].concat(loaders)
}
}
// https://vue-loader.vuejs.org/en/configurations/extract-css.html
return {
css: generateLoaders(),
postcss: generateLoaders(),
less: generateLoaders('less'),
sass: generateLoaders('sass', { indentedSyntax: true }),
scss: generateLoaders('sass'),
stylus: generateLoaders('stylus'),
styl: generateLoaders('stylus')
}
}
// Generate loaders for standalone style files (outside of .vue)
exports.styleLoaders = function (options) {
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')
})
}
}

22
build/vue-loader.conf.js Normal file
View File

@@ -0,0 +1,22 @@
'use strict'
const utils = require('./utils')
const config = require('../config')
const isProduction = process.env.NODE_ENV === 'production'
const sourceMapEnabled = isProduction
? config.build.productionSourceMap
: config.dev.cssSourceMap
module.exports = {
loaders: utils.cssLoaders({
sourceMap: sourceMapEnabled,
extract: isProduction
}),
cssSourceMap: sourceMapEnabled,
cacheBusting: config.dev.cacheBusting,
transformToRequire: {
video: ['src', 'poster'],
source: 'src',
img: 'src',
image: 'xlink:href'
}
}

View File

@@ -0,0 +1,97 @@
'use strict'
const path = require('path')
const utils = require('./utils')
const config = require('../config')
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'),
'@page': resolve('src') + '/pages',
'@components': resolve('src') + '/components',
'@style': resolve('src') + '/style',
'@images': resolve('src') + '/images',
'@config': resolve('src') + '/config'
}
},
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: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
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]')
}
}
]
},
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'
}
}

95
build/webpack.dev.conf.js Executable file
View File

@@ -0,0 +1,95 @@
'use strict'
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const path = require('path')
const baseWebpackConfig = require('./webpack.base.conf')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
const portfinder = require('portfinder')
const HOST = process.env.HOST
const PORT = process.env.PORT && Number(process.env.PORT)
const devWebpackConfig = merge(baseWebpackConfig, {
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: {
rewrites: [
{ from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') },
],
},
hot: true,
contentBase: false, // since we use CopyWebpackPlugin.
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(),
new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update.
new webpack.NoEmitOnErrorsPlugin(),
// https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true
}),
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.dev.assetsSubDirectory,
ignore: ['.*']
}
])
]
})
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)
}
})
})

149
build/webpack.prod.conf.js Normal file
View File

@@ -0,0 +1,149 @@
'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 ExtractTextPlugin = require('extract-text-webpack-plugin')
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const env = process.env.NODE_ENV === 'testing'
? require('../config/test.env')
: require('../config/prod.env')
const webpackConfig = merge(baseWebpackConfig, {
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].js'),
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
},
plugins: [
// http://vuejs.github.io/vue-loader/en/workflow/production.html
new webpack.DefinePlugin({
'process.env': env
}),
new UglifyJsPlugin({
uglifyOptions: {
compress: {
warnings: false
}
},
sourceMap: config.build.productionSourceMap,
parallel: true
}),
// extract css into its own file
new ExtractTextPlugin({
filename: utils.assetsPath('css/[name].[contenthash].css'),
// Setting the following option to `false` will not extract CSS from codesplit chunks.
// Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack.
// It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`,
// increasing file size: https://github.com/vuejs-templates/webpack/issues/1110
allChunks: true,
}),
// Compress extracted CSS. We are using this plugin so that possible
// duplicated CSS from different components can be deduped.
new OptimizeCSSPlugin({
cssProcessorOptions: config.build.productionSourceMap
? { safe: true, map: { inline: false } }
: { safe: true }
}),
// generate dist index.html with correct asset hash for caching.
// you can customize output by editing /index.html
// see https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: process.env.NODE_ENV === 'testing'
? 'index.html'
: config.build.index,
template: 'index.html',
inject: true,
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
// more options:
// https://github.com/kangax/html-minifier#options-quick-reference
},
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
chunksSortMode: 'dependency'
}),
// keep module.id stable when vendor modules does not change
new webpack.HashedModuleIdsPlugin(),
// enable scope hoisting
new webpack.optimize.ModuleConcatenationPlugin(),
// split vendor js into its own file
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks (module) {
// any required modules inside node_modules are extracted to vendor
return (
module.resource &&
/\.js$/.test(module.resource) &&
module.resource.indexOf(
path.join(__dirname, '../node_modules')
) === 0
)
}
}),
// extract webpack runtime and module manifest to its own file in order to
// prevent vendor hash from being updated whenever app bundle is updated
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
minChunks: Infinity
}),
// This instance extracts shared chunks from code splitted chunks and bundles them
// in a separate chunk, similar to the vendor chunk
// see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk
new webpack.optimize.CommonsChunkPlugin({
name: 'app',
async: 'vendor-async',
children: true,
minChunks: 3
}),
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.build.assetsSubDirectory,
ignore: ['.*']
}
])
]
})
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.bundleAnalyzerReport) {
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
}
module.exports = webpackConfig

7
config/dev.env.js Normal file
View File

@@ -0,0 +1,7 @@
'use strict'
const merge = require('webpack-merge')
const prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {
NODE_ENV: '"development"'
})

76
config/index.js Normal file
View File

@@ -0,0 +1,76 @@
'use strict'
// Template version: 1.3.1
// see http://vuejs-templates.github.io/webpack for documentation.
const path = require('path')
module.exports = {
dev: {
// Paths
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {},
// Various Dev Server settings
host: '0.0.0.0', // can be overwritten by process.env.HOST
port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: false,
errorOverlay: true,
notifyOnErrors: true,
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: 'cheap-module-eval-source-map',
// If you have problems debugging vue-files in devtools,
// set this to false - it *may* help
// https://vue-loader.vuejs.org/en/options.html#cachebusting
cacheBusting: true,
cssSourceMap: true
},
build: {
// Template for index.html
index: path.resolve(__dirname, '../dist/index.html'),
// Paths
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: './',
/**
* Source Maps
*/
productionSourceMap: true,
// 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
}
}

4
config/prod.env.js Normal file
View File

@@ -0,0 +1,4 @@
'use strict'
module.exports = {
NODE_ENV: '"production"'
}

7
config/test.env.js Normal file
View File

@@ -0,0 +1,7 @@
'use strict'
const merge = require('webpack-merge')
const devEnv = require('./dev.env')
module.exports = merge(devEnv, {
NODE_ENV: '"testing"'
})

12
index.html Normal file
View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>山东金宝一体机</title>
</head>
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

97
package.json Normal file
View File

@@ -0,0 +1,97 @@
{
"name": "nl-aio-hl",
"version": "1.0.0",
"description": "A Vue.js project",
"author": "",
"private": true,
"scripts": {
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"start": "npm run dev",
"unit": "jest --config test/unit/jest.conf.js --coverage",
"e2e": "node test/e2e/runner.js",
"test": "npm run unit && npm run e2e",
"lint": "eslint --ext .js,.vue src test/unit test/e2e/specs",
"build": "node build/build.js"
},
"dependencies": {
"axios": "^0.18.0",
"babel-polyfill": "^6.26.0",
"element-ui": "^2.8.2",
"fastclick": "^1.0.6",
"jsencrypt": "^3.3.2",
"vue": "^2.5.2",
"vue-infinite-scroll": "^2.0.2",
"vue-router": "^3.0.1",
"vuex": "^3.0.1"
},
"devDependencies": {
"autoprefixer": "^7.1.2",
"babel-core": "^6.22.1",
"babel-eslint": "^8.2.1",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-jest": "^21.0.2",
"babel-loader": "^7.1.1",
"babel-plugin-component": "^1.1.1",
"babel-plugin-dynamic-import-node": "^1.2.0",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-plugin-transform-vue-jsx": "^3.5.0",
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.22.0",
"chalk": "^2.0.1",
"chromedriver": "^2.27.2",
"copy-webpack-plugin": "^4.0.1",
"cross-spawn": "^5.0.1",
"css-loader": "^0.28.0",
"eslint": "^4.15.0",
"eslint-config-standard": "^10.2.1",
"eslint-friendly-formatter": "^3.0.0",
"eslint-loader": "^1.7.1",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.2.0",
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^3.0.1",
"eslint-plugin-vue": "^4.0.0",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^1.1.4",
"friendly-errors-webpack-plugin": "^1.6.1",
"html-webpack-plugin": "^2.30.1",
"jest": "^22.0.4",
"jest-serializer-vue": "^0.3.0",
"nightwatch": "^0.9.12",
"node-notifier": "^5.1.2",
"optimize-css-assets-webpack-plugin": "^3.2.0",
"ora": "^1.2.0",
"portfinder": "^1.0.13",
"postcss-import": "^11.0.0",
"postcss-loader": "^2.0.8",
"postcss-url": "^7.2.1",
"rimraf": "^2.6.0",
"selenium-server": "^3.0.1",
"semver": "^5.3.0",
"shelljs": "^0.7.6",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.2",
"uglifyjs-webpack-plugin": "^1.1.1",
"url-loader": "^0.5.8",
"vue-jest": "^1.0.2",
"vue-loader": "^13.3.0",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.5.2",
"webpack": "^3.6.0",
"webpack-bundle-analyzer": "^2.9.0",
"webpack-dev-server": "^2.9.1",
"webpack-merge": "^4.1.0"
},
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}

11
src/App.vue Normal file
View File

@@ -0,0 +1,11 @@
<template>
<div id="app">
<router-view/>
</div>
</template>
<script>
export default {
name: 'App'
}
</script>

45
src/components/Back.vue Normal file
View File

@@ -0,0 +1,45 @@
<template>
<div></div>
</template>
<script>
export default {
name: 'Back',
data () {
return {
lockTime: this.$store.getters.lockTime,
timeOut: null,
actions: ['mouseup', 'mousemove', 'keyup', 'click', 'touchend']
}
},
mounted () {
if (Number(this.lockTime) !== 0) {
this.isTimeOut()
}
},
methods: {
startTimer () {
// console.log('8')
clearInterval(this.timeOut)
this.timeOut = setInterval(() => {
this.$router.push({path: '/'})
// console.log('time', 1000 * 6 * this.lockTime)
}, 1000 * 60 * this.lockTime)
},
isTimeOut () {
this.startTimer()
this.actions.forEach(item => {
document.body.addEventListener(item, this.startTimer)
})
}
},
beforeDestroy () {
this.actions.forEach(item => {
// console.log(item)
document.body.removeEventListener(item, this.startTimer)
})
clearInterval(this.timeOut)
this.timeOut = null
}
}
</script>

37
src/components/Modal.vue Normal file
View File

@@ -0,0 +1,37 @@
<template>
<div v-show="mdShow" class="message-box__wrapper">
<div class="message-box">
<div class="message-box__content">
<div class="message-box__message"><p>{{message}}</p></div>
<div class="message-box__input">
<slot></slot>
</div>
</div>
<div class="message-box__btns">
<div class="fr">
<button class="mgr5 button--primary button--defalut" @click="closeModal">&nbsp;&nbsp;</button>
<button class="button--primary" @click="comfirm" :disabled="disabled">&nbsp;&nbsp;</button>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'Modal',
props: {
mdShow: Boolean,
message: String,
disabled: Boolean
},
methods: {
closeModal () {
this.$emit('closeModalCallback')
},
comfirm () {
this.$emit('comfirmCallback', this.type)
}
}
}
</script>

View File

@@ -0,0 +1,67 @@
<template>
<div class="container">
<header>
<div class="header-tip">设备{{deviceCode}}</div>
<button class="button button--primary" @click="goBack">&nbsp;&nbsp;</button>
</header>
<!-- <ul v-if="tabShow" class="tabs">
<li v-for="i in menus" :key="i.index">
<router-link :to="i.router" :class="{'router-link-active': i.index === activeIndex}">{{i.label}}</router-link>
</li>
</ul> -->
<slot></slot>
</div>
</template>
<script>
export default {
name: 'Assignment',
props: {
deviceCode: String,
activeIndex: String,
tabShow: {
type: Boolean,
default: true
},
inner: {
type: Boolean,
default: false
}
},
data () {
return {
menus: [
{
label: '工单操作',
index: '1',
router: '/operation'
}
// {
// label: '残次品上报',
// index: '2',
// router: '/ungraded'
// },
// {
// label: '状态设置',
// index: '3',
// router: '/stateset'
// },
// {
// label: '工单查询',
// index: '4',
// router: '/opersearch'
// }
]
}
},
methods: {
goBack () {
if (this.inner) {
this.$emit('goIn')
} else {
this.$router.push('/home')
}
}
}
}
</script>

116
src/components/alert.vue Normal file
View File

@@ -0,0 +1,116 @@
<template>
<div>
<transition name="bounce">
<div class="alert-wrap">
<div class="text">{{alertMsg}}</div>
<div class="hairline--top">
<button class="button--large" @click="onClose"><span>确认</span></button>
</div>
</div>
</transition>
<transition name="fade">
<div class="overlay"></div>
</transition>
</div>
</template>
<script>
import { mapState } from 'vuex'
export default {
data () {
return {}
},
computed: mapState({
alertMsg: state => state.com.alertMsg
}),
methods: {
onClose () {
this.$store.dispatch('showAlert', false)
}
}
}
</script>
<style lang="stylus" scoped>
@keyframes fade-in {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes fade-out {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
.bounce-enter {
opacity 0
transform translate3d(-50%, -50%, 0) scale(0.7)
}
.bounce-leave-active {
opacity 0
transform translate3d(-50%, -50%, 0) scale(0.9)
}
.fade-enter-active
animation 0.3s fade-in
.fade-leave-active
animation 0.3s fade-out
.overlay
position fixed
top 0
left 0
width 100%
height 100%
background-color rgba(0, 0, 0, 0.7)
z-index 2012
.alert-wrap
position fixed
top 50%
left 50%
width 45%
transition .3s
transform translate3d(-50%, -50%, 0)
overflow hidden
border-radius 4px
border 1px solid #ebeef5
background-color #fff
box-shadow 0 2px 12px 0 rgba(0,0,0,.3)
font-size .28rem
line-height .42rem
color #929292
z-index 2018
.text
padding .1rem
max-height 60vh
overflow-y auto
text-align center
-webkit-overflow-scrolling touch
white-space pre-wrap
color #606266
[class*='hairline']
position relative
[class*='hairline']::after
content ' '
position absolute
pointer-events none
box-sizing border-box
top -50%
left -50%
right -50%
bottom -50%
transform scale(0.5)
border 0 solid #ebedf0
.hairline--top::after
border-top-width 1px
.button--large
width 100%
height .5rem
line-height .5rem
color #fff
background-color #2778f3
</style>

111
src/components/dialog.vue Normal file
View File

@@ -0,0 +1,111 @@
<template>
<div>
<div v-if="active" class="dialog_wrapper">
<div class="dialog">
<div class="dialog_header">
<span class="dialog_title">{{title}}</span>
<button class="dialog_headerbtn" @click="toCancle">
<i class="iconfont close_icon"></i>
</button>
</div>
<div class="dialog_body">
<slot></slot>
</div>
<div class="dialog_footer">
<button class="button button--primary" @click="toCancle">取消</button>
<button class="button button--primary" :class="{'button--info': unclick === true}" :disabled="disabled" @click="toSure">确定</button>
</div>
</div>
</div>
<div v-if="active" class="modal"></div>
</div>
</template>
<script>
export default {
name: 'jxDialog',
props: {
title: String,
type: String,
unclick: {
type: Boolean,
default: false
}
},
data () {
return {
active: false,
disabled: false
}
},
methods: {
toCancle () {
this.active = false
this.$emit('toCancle', this.type)
},
toSure () {
this.$emit('toSure', this.type)
}
}
}
</script>
<style lang="stylus" scoped>
.modal
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
opacity: .5;
background: #000;
z-index: 101;
.dialog_wrapper
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
overflow: auto;
z-index: 102;
.dialog
position: relative;
margin: 0 auto 50px;
background: #fff;
border-radius: 16px;
box-shadow: 0 1px 3px rgba(0,0,0,.3);
box-sizing: border-box;
width: 50%;
margin-top: 15vh;
.dialog_header
padding: 20px 20px 10px;
.dialog_title
line-height: 24px;
font-size: 18px;
color: #303133;
.dialog_headerbtn
position: absolute;
top: 20px;
right: 20px;
padding: 0;
background: transparent;
border: none;
outline: none;
cursor: pointer;
font-size: 16px;
.close_icon
width 24px
height 24px
font-size 15px
line-height 24px
top 0
.dialog_body
padding: 30px 20px;
color: #606266;
font-size: 14px;
word-break: break-all;
.dialog_footer
padding: 10px 20px 20px;
text-align: center;
box-sizing: border-box;
</style>

252
src/components/header.vue Normal file
View File

@@ -0,0 +1,252 @@
<template>
<div class="header">
<div class="header-time-wrap">
<div class="header-time">
<div class="date_week">
<div class="xj_date">{{date}}</div>
<div class="xj_week">{{week}}</div>
</div>
<div class="xj_time">{{time}}</div>
</div>
</div>
<div class="header-center">{{ title }}</div>
<div class="header_wrap_left">
<div class="header-user-content">
<div class="header-user-txt" @click="toSelect">
<div class="span2">{{userName}}</div>
<div class="span1"></div>
</div>
<div v-show="show" class="dropdown-wrap">
<ul class="dropdown-list drift">
<li class="dropdown-item__1" @click="exit">
<i class="icon_exit"></i>
<i class="exit_txt">退出</i>
</li>
</ul>
<div class="popper__arrow"></div>
</div>
</div>
<div class="drop-button-wraper">
<div class="colors_3_wrap" @click="toSelectColor">
<div class="color_item color_1"></div>
<div class="color_item color_2"></div>
<div class="color_item color_3"></div>
</div>
<div v-show="showColor" class="dropdown-wrap">
<ul class="dropdown-list drift">
<li class="dropdown-item color_button_wrap">
<div class="color_button overall_orange" @click="switchColor(1)"></div>
<div class="color_button overall_lightgreen" @click="switchColor(2)"></div>
<div class="color_button overall_blue" @click="switchColor(3)"></div>
</li>
</ul>
<div class="popper__arrow"></div>
</div>
</div>
<div class="home_tip_wrap" @click="backHome">
<div class="iconfont icon_home"></div>
</div>
</div>
</div>
</template>
<script>
export default {
data () {
return {
userName: this.$store.getters.userInfo !== '' ? JSON.parse(this.$store.getters.userInfo).person_name : '',
timer: null,
time: '',
date: '',
week: '',
show: false,
showColor: false
}
},
props: {
title: String
},
mounted () {
this.timer = window.setInterval(this.updateTime, 1000)
},
methods: {
updateTime () {
let cd = new Date()
let year = cd.getFullYear()
let month = cd.getMonth() + 1 < 10 ? '0' + (cd.getMonth() + 1) : cd.getMonth() + 1
let date = cd.getDate() < 10 ? '0' + cd.getDate() : cd.getDate()
let hh = cd.getHours() < 10 ? '0' + cd.getHours() : cd.getHours()
let mm = cd.getMinutes() < 10 ? '0' + cd.getMinutes() : cd.getMinutes()
let ss = cd.getSeconds() < 10 ? '0' + cd.getSeconds() : cd.getSeconds()
var weekday = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
let myddy = new Date().getDay()
let week = weekday[myddy]
this.time = `${hh}:${mm}:${ss}`
this.date = `${year}/${month}/${date}`
this.week = `${week}`
},
toSelect () {
this.show = !this.show
},
exit () {
this.$store.dispatch('delUserInfo')
this.$router.push('/login')
},
toSelectColor () {
this.showColor = !this.showColor
},
switchColor (type) {
this.$emit('switchColor', type)
},
backHome () {
this.$router.push('/home')
}
}
}
</script>
<style lang="stylus" scoped>
@import '~@style/mixin.styl'
.header
height 45px
_fj()
padding 0 15px
// border-bottom 1px solid #2aa6f9
// box-shadow 0 1px 2px 0 rgba(42,166,249,.4)
.header_wrap_left
_wh(35%,45px)
_fj(flex-end)
.header-center
_wh(30%, 45px)
_font(18px, 45px, #fff,,center)
.header-user-content
position relative
height 45px
_fj(flex-start)
cursor pointer
.header-user-txt
_fj()
.span1
_wh(18px, 18px)
background url(../images/user.png) center center / 100% 100% no-repeat
margin-left 10px
.span2
_font(16px, 20px, #fff,,)
margin-bottom -2px
.drop-button-wraper
position relative
height 100%
line-height 45px
font-size 14px
color #fff
margin-left 15px
vertical-align middle
_fj(center)
.dropdown-wrap
position absolute
min-width 75px
top 35px
right 0
z-index 1
transform-origin center top
transition transform .3s ease-in-out
border 1px solid #e4e7ed
border-radius 4px
background-color #fff
box-shadow 0 2px 12px 0 rgba(0,0,0,.1)
margin 5px 0
.dropdown-list
padding 0
.dropdown-item
height 34px
_font(14px, 34px, #606266,,center)
padding 0 10px
&:hover
background-color $gray2
.dropdown-item__1
height 34px
_font(14px, 34px, #606266,,center)
padding 0 10px
_fj(center)
&:hover
background-color $gray2
.icon_exit
_font(14px, 34px, #606266,,center)
.exit_txt
_font(14px, 34px, #606266,,center)
font-style normal
margin-left 5px
.popper__arrow
position absolute
display block
width 0
height 0
border-color transparent
border-style solid
border-width 6px
filter drop-shadow(0 2px 12px rgba(0,0,0,.03))
top -5px
right 2px
border-top-width 0
border-bottom-color #fff
.header-time-wrap
_wh(35%, 45px)
.header-time
height 45px
_fj(flex-start)
.xj_time
_font(16px, 18px, #fff,,right)
.date_week
_fj()
.xj_date
_font(15px, 18px, #fff,,)
.xj_week
_font(15px, 18px, #fff,,)
margin 0 5px 0 1px
.drop-button-wraper
.dropdown-list
padding 0 10px
.dropdown-item
float left
padding 0
&:nth-child(2)
padding 0 10px
.home_tip_wrap
_wh(18px, 45px)
_fj(center)
margin-left 15px
.icon_home
_font(18px, 45px, #fff,,center)
.colors_3_wrap
position relative
_wh(18px, 18px)
border 1px solid $gray3
border-radius 50%
overflow hidden
>.color_item
_wh(58%, 58%)
position absolute
top 50%
left 50%
transform-origin 0% 0%
.color_1
transform rotate(0deg) skewX(-30deg)
background-color #ffa530
.color_2
transform rotate(120deg) skewX(-30deg)
background-color #b7e15d
.color_3
transform rotate(240deg) skewX(-30deg)
background-color #484cce
.color_button_wrap
display block
_fj()
.color_button
_wh(30px, 30px)
line-height 30px
font-size 30px
border-radius 50%
overflow hidden
&:nth-child(2)
margin 0 5px
</style>

252
src/components/header2.vue Normal file
View File

@@ -0,0 +1,252 @@
<template>
<div class="header">
<div class="header-time-wrap">
<div class="header-time">
<div class="date_week">
<div class="xj_date">{{date}}</div>
<div class="xj_week">{{week}}</div>
</div>
<div class="xj_time">{{time}}</div>
</div>
</div>
<!-- <div class="header-center">{{ title }}</div> -->
<div class="header_wrap_left">
<div class="header-user-content">
<div class="header-user-txt" @click="toSelect">
<div class="span2">{{userName}}</div>
<div class="span1"></div>
</div>
<div v-show="show" class="dropdown-wrap">
<ul class="dropdown-list drift">
<li class="dropdown-item__1" @click="exit">
<i class="icon_exit"></i>
<i class="exit_txt">退出</i>
</li>
</ul>
<div class="popper__arrow"></div>
</div>
</div>
<!-- <div class="drop-button-wraper">
<div class="colors_3_wrap" @click="toSelectColor">
<div class="color_item color_1"></div>
<div class="color_item color_2"></div>
<div class="color_item color_3"></div>
</div>
<div v-show="showColor" class="dropdown-wrap">
<ul class="dropdown-list drift">
<li class="dropdown-item color_button_wrap">
<div class="color_button overall_orange" @click="switchColor(1)"></div>
<div class="color_button overall_lightgreen" @click="switchColor(2)"></div>
<div class="color_button overall_blue" @click="switchColor(3)"></div>
</li>
</ul>
<div class="popper__arrow"></div>
</div>
</div>
<div class="home_tip_wrap" @click="backHome">
<div class="iconfont icon_home"></div>
</div> -->
</div>
</div>
</template>
<script>
export default {
data () {
return {
userName: this.$store.getters.userInfo !== '' ? JSON.parse(this.$store.getters.userInfo).person_name : 'admin',
timer: null,
time: '',
date: '',
week: '',
show: false,
showColor: false
}
},
props: {
title: String
},
mounted () {
this.timer = window.setInterval(this.updateTime, 1000)
},
methods: {
updateTime () {
let cd = new Date()
let year = cd.getFullYear()
let month = cd.getMonth() + 1 < 10 ? '0' + (cd.getMonth() + 1) : cd.getMonth() + 1
let date = cd.getDate() < 10 ? '0' + cd.getDate() : cd.getDate()
let hh = cd.getHours() < 10 ? '0' + cd.getHours() : cd.getHours()
let mm = cd.getMinutes() < 10 ? '0' + cd.getMinutes() : cd.getMinutes()
let ss = cd.getSeconds() < 10 ? '0' + cd.getSeconds() : cd.getSeconds()
var weekday = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
let myddy = new Date().getDay()
let week = weekday[myddy]
this.time = `${hh}:${mm}:${ss}`
this.date = `${year}/${month}/${date}`
this.week = `${week}`
},
toSelect () {
this.show = !this.show
},
exit () {
this.$store.dispatch('delUserInfo')
this.$router.push('/login')
},
toSelectColor () {
this.showColor = !this.showColor
},
switchColor (type) {
this.$emit('switchColor', type)
},
backHome () {
this.$router.push('/home')
}
}
}
</script>
<style lang="stylus" scoped>
@import '~@style/mixin.styl'
.header
height 45px
_fj()
padding 0 15px
// border-bottom 1px solid #2aa6f9
// box-shadow 0 1px 2px 0 rgba(42,166,249,.4)
.header_wrap_left
_wh(35%,45px)
_fj(flex-end)
.header-center
_wh(30%, 45px)
_font(18px, 45px, #fff,,center)
.header-user-content
position relative
height 45px
_fj(flex-start)
cursor pointer
.header-user-txt
_fj()
.span1
_wh(18px, 18px)
background url(../images/user.png) center center / 100% 100% no-repeat
margin-left 10px
.span2
_font(16px, 20px, #fff,,)
margin-bottom -2px
.drop-button-wraper
position relative
height 100%
line-height 45px
font-size 14px
color #fff
margin-left 15px
vertical-align middle
_fj(center)
.dropdown-wrap
position absolute
min-width 75px
top 35px
right 0
z-index 1
transform-origin center top
transition transform .3s ease-in-out
border 1px solid #e4e7ed
border-radius 4px
background-color #fff
box-shadow 0 2px 12px 0 rgba(0,0,0,.1)
margin 5px 0
.dropdown-list
padding 0
.dropdown-item
height 34px
_font(14px, 34px, #606266,,center)
padding 0 10px
&:hover
background-color $gray2
.dropdown-item__1
height 34px
_font(14px, 34px, #606266,,center)
padding 0 10px
_fj(center)
&:hover
background-color $gray2
.icon_exit
_font(14px, 34px, #606266,,center)
.exit_txt
_font(14px, 34px, #606266,,center)
font-style normal
margin-left 5px
.popper__arrow
position absolute
display block
width 0
height 0
border-color transparent
border-style solid
border-width 6px
filter drop-shadow(0 2px 12px rgba(0,0,0,.03))
top -5px
right 2px
border-top-width 0
border-bottom-color #fff
.header-time-wrap
_wh(35%, 45px)
.header-time
height 45px
_fj(flex-start)
.xj_time
_font(16px, 18px, #fff,,right)
.date_week
_fj()
.xj_date
_font(15px, 18px, #fff,,)
.xj_week
_font(15px, 18px, #fff,,)
margin 0 5px 0 1px
.drop-button-wraper
.dropdown-list
padding 0 10px
.dropdown-item
float left
padding 0
&:nth-child(2)
padding 0 10px
.home_tip_wrap
_wh(18px, 45px)
_fj(center)
margin-left 15px
.icon_home
_font(18px, 45px, #fff,,center)
.colors_3_wrap
position relative
_wh(18px, 18px)
border 1px solid $gray3
border-radius 50%
overflow hidden
>.color_item
_wh(58%, 58%)
position absolute
top 50%
left 50%
transform-origin 0% 0%
.color_1
transform rotate(0deg) skewX(-30deg)
background-color #ffa530
.color_2
transform rotate(120deg) skewX(-30deg)
background-color #b7e15d
.color_3
transform rotate(240deg) skewX(-30deg)
background-color #484cce
.color_button_wrap
display block
_fj()
.color_button
_wh(30px, 30px)
line-height 30px
font-size 30px
border-radius 50%
overflow hidden
&:nth-child(2)
margin 0 5px
</style>

View File

@@ -0,0 +1,30 @@
<template>
<div class="loading">
<div class="loader-inner">
<img src="../images/oval-white.svg">
</div>
</div>
</template>
<style lang="stylus" scoped>
.loading
position fixed
width 100%
height 100%
z-index 100000
.loader-inner
position absolute
z-index 100000
height 50px
width 50px
padding 10px
transform translate(-25px, -25px)
left 50%
top 50%
overflow hidden
background-color rgba(0, 0, 0, .5)
border-radius 3px
img
width 100%
height 100%
</style>

44
src/components/toast.vue Normal file
View File

@@ -0,0 +1,44 @@
<template>
<div class="toast">
<div class="toast-wrap">
<div class="text">
{{toastMsg}}
</div>
</div>
</div>
</template>
<script>
import { mapState } from 'vuex'
export default {
data () {
return {}
},
computed: mapState({
toastMsg: state => state.com.toastMsg
})
}
</script>
<style lang="stylus" scoped>
.toast
.toast-wrap
position fixed
z-index 10000
width 100%
height .5rem
line-height .5rem
text-align center
left 50%
top 50%
transform translate(-50%, -50%)
.text
display inline-block
width auto
text-align center
padding 0 .1rem
border-radius 10px
background #a2a6ae
font-size .2rem
color #fff
</style>

16
src/config/filter.js Normal file
View File

@@ -0,0 +1,16 @@
import {accDiv} from '@config/utils.js'
const filter = {
numeric (value, bit) {
if (!value) return ''
return Number(value).toFixed(bit)
},
unitskg (value) {
if (!value) return ''
let res = accDiv(value, 1000)
res = Number(res).toFixed(3)
return res
}
}
export default filter

221
src/config/getData1.js Normal file
View File

@@ -0,0 +1,221 @@
import {post} from '@config/http.js'
// 菜单
export const authority = () => {
let res = {
sonTree: [
{menu_id: '1',
path: 'RF01',
name: '工单管理',
sonTree: [
{menu_id: '1', name: '工单作业', path: '/workorderassignment'}
]
},
{menu_id: '2',
path: 'RF02',
name: '半成品管理',
sonTree: [
{menu_id: '1', name: '半成品入库', path: '/semifinishedinstore'},
{menu_id: '2', name: '半成品出库', path: '/semifinishedoutstore'},
{menu_id: '3', name: '半成品盘点', path: '/semifinishedcheck'},
{menu_id: '4', name: '半成品拼盘', path: '/semifinishedcomposesearch'}
]
},
{menu_id: '3',
path: 'RF03',
name: '成品管理',
sonTree: [
{menu_id: '1', name: '批量入库', path: '/batchinstore'},
{menu_id: '2', name: '成品入库', path: '/finishedinstore'}
]
},
{menu_id: '4',
path: 'RF13',
name: '刻字管理',
sonTree: [
{menu_id: '1', name: '刻字工序', path: '/letteringprocess'},
{menu_id: '2', name: '人工刻字上料', path: '/letteringload'}
]
},
{menu_id: '5',
path: 'RF05',
name: '清洗管理',
sonTree: [
{menu_id: '1', name: '清洗管理', path: '/cleaningloading'},
{menu_id: '2', name: '人工倒料', path: '/manpour'}
]
},
{menu_id: '6',
path: 'RF07',
name: '专机管理',
sonTree: [
{menu_id: '1', name: '人工倒料', path: '/manpouring'}
]
},
{menu_id: '7',
path: 'RF06',
name: '暂存区管理',
sonTree: [
{menu_id: '1', name: '包装机选择', path: '/bzjselect'}
]
},
{menu_id: '8',
path: 'RF04',
name: '设备管理',
sonTree: [
{menu_id: '1', name: '维修单管理', path: '/repairorder'},
{menu_id: '2', name: '保养单管理', path: '/maintainorder'},
{menu_id: '3', name: '点检单管理', path: '/checkorder'},
{menu_id: '4', name: '润滑单管理', path: '/lubricorder'}
]
}
]
}
return res
}
// 成品入库
// 1.1仓库下拉框
export const getBcpStor = () => post('api/pda/cp/in/getBcpStor', {
})
// 1.2单据类型下拉框
export const getBillType = () => post('api/pda/cp/in/getBillType', {
})
// 1.3入库点下拉框
export const getPoint = () => post('api/pda/cp/in/getPoint', {
})
// 1.4添加单据物料按钮
// 1.5选择成品箱物料页面
export const getMaterial = (page, size, btime, etime, scode, mcode) => post('api/pda/cp/in/getMaterial', {
page: page,
size: size,
begin_time: btime,
end_time: etime,
sale_code: scode,
material_code: mcode
})
// 1.6删除一行(按钮)
// 1.7确认入库(按钮)-->点击后弹出框(“确认入库是否继续?”)
export const confirmIn = (from) => post('api/pda/cp/in/confirmIn', {
from: from
})
// 1.8作业查询(按钮)
// 2.1成品入库查询
export const outgetAll = (sid, btime, etime, btype, mcode, scode) => post('api/pda/cp/in/getAll', {
stor_id: sid,
begin_time: btime,
end_time: etime,
bill_type: btype,
material_code: mcode,
storagevehicle_code: scode
})
// 2.2强制确认(按钮)
export const inconfirm = (row) => post('api/pda/cp/in/confirm', {
row: row
})
// 刻字上料
// 1.1设备列表
export const devicelist = () => post('api/device/list', {
workprocedure_id: '1535144682756116480'
})
// 1.2车间列表
export const dictDetailByCode = (code) => post('api/dict/dictDetailByCode', {
code: code
})
// 1卸料
export const kzunload = (dcode, qty) => post('api/pda/kzunload', {
device_code: dcode,
qty: qty
})
// 2余料上完
export const kzresidue = (dcode) => post('api/pda/kzresidue', {
device_code: dcode
})
// 临时人工刻字上料
// 1刻字上料
export const tmpcallVechile = (dcode, qty) => post('api/pda/tmpcallVechile', {
device_code: dcode,
qty: qty
})
// 2空框回库
export const tmpsendVechile = (dcode) => post('api/pda/tmpsendVechile', {
device_code: dcode
})
// 公共接口
// 1.1车间列表
export const dictall = () => post('api/dict/all', {
})
// 人工倒料
// 1.1设备列表
export const washdevicelist = (wid) => post('api/device/list', {
workprocedure_id: wid
})
// 1.2根据设备列表获取物料信息
export const washquery = (parea, dcode) => post('api/pda/wash/query', {
product_area: parea,
device_code: dcode
})
// 1.3称重
export const washweighing = (list) => post('api/pda/wash/weighing', {
list: list
})
// 1.4确认
export const washweighingFinish = (dcode, dweight, mcode, mspec, mname) => post('api/pda/wash/weighingFinish', {
device_code: dcode,
deviceinstor_weight: dweight,
material_code: mcode,
material_spec: mspec,
material_name: mname
})
// 1.5查询物料列表
export const washmaterialList = (page, size, mcode) => post('api/pda/wash/materialList', {
page: page,
size: size,
material_code: mcode
})
// 暂存区管理
// 包装机管理1
// 1.2包装机选择列表
export const packageList = () => post('api/pda/package/packageList', {
})
// 1.3空框送回
export const sendVechile = (dcode) => post('api/pda/package/sendVechile', {
device_code: dcode
})
// 刻字暂存位选择2
// 1.2包装机选择列表
export const cachepoint = () => post('api/pda/package/cachepoint', {
})
// 1.3确认上料
export const sendMaterial = (dcode, pcode) => post('api/pda/package/sendMaterial', {
device_code: dcode,
point_code: pcode
})
// 1.3空框送回
export const sendVechile2 = (dcode, pcode) => post('api/pda/package/sendVechile2', {
device_code: dcode,
point_code: pcode
})

549
src/config/getData2.js Normal file

File diff suppressed because one or more lines are too long

80
src/config/http.js Normal file
View File

@@ -0,0 +1,80 @@
import axios from 'axios'
import { Dialog } from './utils.js'
import store from '../vuex/store'
import router from '@/router'
axios.defaults.timeout = 50000
axios.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8'
axios.interceptors.request.use(
config => {
let token = ''
if (store.getters.saveToken !== '') {
token = store.getters.saveToken
}
token && (config.headers.Authorization = token)
if (config.method === 'post') {
if (!config.data.flag) {
config.data = config.data
} else {
config.data = config.data.formData
}
}
return config
},
error => {
Dialog('错误的传参')
return Promise.reject(error)
}
)
axios.interceptors.response.use(
response => {
return Promise.resolve(response)
},
error => {
if (error && error.response) {
switch (error.response.status) {
case 400:
break
case 401:
store.dispatch('delUserInfo')
router.push('/login')
break
}
return Promise.reject(error.response.data)
} else {
return Promise.reject(error)
}
}
)
export const post = (sevmethod, params) => {
return new Promise((resolve, reject) => {
axios.post(`${store.getters.baseUrl}/` + sevmethod, params)
.then(response => {
resolve(response.data)
}, error => {
Dialog(error.message)
reject(error.message)
})
.catch((error) => {
reject(error)
})
})
}
export const get = (sevmethod, params) => {
return new Promise((resolve, reject) => {
axios.get(`${store.getters.baseUrl}/` + sevmethod + params)
.then(response => {
resolve(response.data)
}, error => {
Dialog(error.message)
reject(error.message)
})
.catch((error) => {
reject(error)
})
})
}

13
src/config/rem.js Normal file
View File

@@ -0,0 +1,13 @@
// 800 * 600
(function (doc, win) {
var docEl = doc.documentElement
var resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize'
var recalc = function () {
var clientWidth = docEl.clientWidth
if (!clientWidth) return
docEl.style.fontSize = 100 * (clientWidth / 800) + 'px'
}
if (!doc.addEventListener) return
win.addEventListener(resizeEvt, recalc, false)
doc.addEventListener('DOMContentLoaded', recalc, false)
})(document, window)

167
src/config/utils.js Normal file
View File

@@ -0,0 +1,167 @@
import store from '../vuex/store'
/**
* 弹出框
*/
export const Dialog = (str) => {
store.dispatch('showAlert', true)
store.dispatch('alertMsg', str)
setTimeout(() => {
store.dispatch('showAlert', false)
}, 30000)
}
/**
* 提示框
*/
export const toast = (str) => {
store.dispatch('showToast', true)
store.dispatch('toastMsg', str)
setTimeout(() => {
store.dispatch('showToast', false)
}, 3000)
}
/**
* 存储localStorage
*/
export const setStore = (name, content) => {
if (!name) return
if (typeof content !== 'string') {
content = JSON.stringify(content)
}
window.localStorage.setItem(name, content)
}
/**
* 获取localStorage
*/
export const getStore = name => {
if (!name) return
return window.localStorage.getItem(name)
}
/**
* yy-mm-dd
*/
export const dateFtt = date => {
if (date == null) {
return ''
}
let year = date.getFullYear()
let month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
let day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
return `${year}-${month}-${day}`
}
/**
* yy-mm-dd hh:mm:ss
*/
export const dateTimeFtt = date => {
if (date == null) {
return ''
}
let year = date.getFullYear()
let month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
let day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
let hh = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
let mm = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
let ss = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
return `${year}-${month}-${day} ${hh}:${mm}:${ss}`
}
/**
* 小数加法
*/
export const accAdd = (arg1, arg2) => {
var r1, r2, m, c
try {
r1 = arg1.toString().split('.')[1].length
} catch (e) {
r1 = 0
}
try {
r2 = arg2.toString().split('.')[1].length
} catch (e) {
r2 = 0
}
c = Math.abs(r1 - r2)
m = Math.pow(10, Math.max(r1, r2))
if (c > 0) {
var cm = Math.pow(10, c)
if (r1 > r2) {
arg1 = Number(arg1.toString().replace('.', ''))
arg2 = Number(arg2.toString().replace('.', '')) * cm
} else {
arg1 = Number(arg1.toString().replace('.', '')) * cm
arg2 = Number(arg2.toString().replace('.', ''))
}
} else {
arg1 = Number(arg1.toString().replace('.', ''))
arg2 = Number(arg2.toString().replace('.', ''))
}
return (arg1 + arg2) / m
}
/**
* 小数减法
*/
export const accSubtract = (arg1, arg2) => {
var r1, r2, m, c
try {
r1 = arg1.toString().split('.')[1].length
} catch (e) {
r1 = 0
}
try {
r2 = arg2.toString().split('.')[1].length
} catch (e) {
r2 = 0
}
c = Math.abs(r1 - r2)
m = Math.pow(10, Math.max(r1, r2))
if (c > 0) {
var cm = Math.pow(10, c)
if (r1 > r2) {
arg1 = Number(arg1.toString().replace('.', ''))
arg2 = Number(arg2.toString().replace('.', '')) * cm
} else {
arg1 = Number(arg1.toString().replace('.', '')) * cm
arg2 = Number(arg2.toString().replace('.', ''))
}
} else {
arg1 = Number(arg1.toString().replace('.', ''))
arg2 = Number(arg2.toString().replace('.', ''))
}
return (arg1 - arg2) / m
}
/**
* 小数乘法
*/
export const accMul = (arg1, arg2) => {
var m = 0
var s1 = arg1.toString()
var s2 = arg2.toString()
try { m += s1.split('.')[1].length } catch (e) {}
try { m += s2.split('.')[1].length } catch (e) {}
return Number(s1.replace('.', '')) * Number(s2.replace('.', '')) / Math.pow(10, m)
}
/**
* 小数除法
*/
export const accDiv = (arg1, arg2) => {
var t1 = 0
var t2 = 0
var r1, r2
try {
t1 = arg1.toString().split('.')[1].length
} catch (e) {}
try {
t2 = arg2.toString().split('.')[1].length
} catch (e) {}
r1 = Number(arg1.toString().replace('.', ''))
r2 = Number(arg2.toString().replace('.', ''))
return (r1 / r2) * Math.pow(10, t2 - t1)
}

17
src/images/oval-white.svg Normal file
View File

@@ -0,0 +1,17 @@
<!-- By Sam Herbert (@sherb), for everyone. More @ http://goo.gl/7AJzbL -->
<svg width="38" height="38" viewBox="0 0 38 38" xmlns="http://www.w3.org/2000/svg" stroke="#fff">
<g fill="none" fill-rule="evenodd">
<g transform="translate(1 1)" stroke-width="2">
<circle stroke-opacity=".5" cx="18" cy="18" r="18"/>
<path d="M36 18c0-9.94-8.06-18-18-18">
<animateTransform
attributeName="transform"
type="rotate"
from="0 18 18"
to="360 18 18"
dur="1s"
repeatCount="indefinite"/>
</path>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 694 B

48
src/main.js Normal file
View File

@@ -0,0 +1,48 @@
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './vuex/store'
import '@style/reset.css'
import '@style/layout.styl'
import fastClick from 'fastclick'
import infiniteScroll from 'vue-infinite-scroll'
import { DatePicker, Select, Option } from 'element-ui'
import '@config/rem.js'
import {post} from '@config/http.js'
import { Dialog, toast } from '@config/utils.js'
import filter from '@config/filter.js'
import JSEncrypt from 'jsencrypt'
fastClick.attach(document.body)
Vue.use(infiniteScroll)
Vue.use(DatePicker)
Vue.use(Select)
Vue.use(Option)
Vue.prototype.$post = post
Vue.prototype.Dialog = Dialog
Vue.prototype.toast = toast
Vue.config.productionTip = false
for (let k in filter) {
Vue.filter(k, filter[k])
}
const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANL378k3RiZHWx5AfJqdH9xRNBmD9wGD\n' +
'2iRe41HdTNF8RUhNnHit5NpMNtGL0NPTSSpPjjI1kJfVorRvaQerUgkCAwEAAQ=='
// 加密
export function encrypt (txt) {
const encryptor = new JSEncrypt()
encryptor.setPublicKey(publicKey) // 设置公钥
return encryptor.encrypt(txt) // 对需要加密的数据进行加密
}
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
store,
components: { App },
template: '<App/>'
})

111
src/pages/index.vue Normal file
View File

@@ -0,0 +1,111 @@
<template>
<div class="zd-row contianer">
<div class="zd-col-8 l-wrap">
<div class="zd-row filter-item border-b-0">
<div class="zd-col-10 filter-label">站点</div>
<div class="zd-col-13 filter-value">10-10-1</div>
</div>
<div class="zd-row filter-item">
<div class="zd-col-10 filter-label">目标站点</div>
<div class="zd-col-13 filter-value">
<el-select v-model="value" placeholder="请选择">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</div>
</div>
<div class="zd-row filter-item">
<div class="zd-col-10 filter-label">物料类型</div>
<div class="zd-col-13 filter-value">
<el-select v-model="value" placeholder="请选择">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</div>
</div>
<div class="zd-row jcflexend button-wrap">
<button class="button btn-primary">确认下料</button>
</div>
<div class="zd-row filter-item">
<div class="zd-col-10 filter-label">区域</div>
<div class="zd-col-13 filter-value">
<el-select v-model="value" placeholder="请选择">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</div>
</div>
<div class="zd-row jcflexend button-wrap">
<button class="button btn-primary">区域管控</button>
</div>
<div class="zd-row filter-item">
<div class="zd-col-24 filter-value">
<el-select v-model="value" placeholder="请选择">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</div>
</div>
<div class="zd-row button-wrap">
<button class="zd-col-6_w button button_s btn-primary">取消</button>
<button class="zd-col-6_w button button_s btn-primary">强制完成</button>
<button class="zd-col-6_w button button_s btn-primary">放货确认</button>
<button class="zd-col-6_w button button_s btn-primary">卸货确认</button>
</div>
</div>
<div class="zd-col-16 r-wrap"></div>
</div>
</template>
<script>
export default {
data () {
return {
options: [{
value: '选项1',
label: '黄金糕'
}],
value: ''
}
}
}
</script>
<style lang="stylus" scoped>
@import '~@style/mixin'
.contianer
_wh(100vw, 100vh)
.l-wrap
height 100%
padding 1%
.r-wrap
height 100%
padding 1%
.zd-col-6_w
width 24%
.filter-item
height 50px
border-bottom 2px solid #fff
.border-b-0
border-bottom 0
.filter-label
_font(14px, 50px, #fff,,)
.filter-value
_font(16px, 50px, #fff,,right)
</style>

18
src/router/index.js Normal file
View File

@@ -0,0 +1,18 @@
import Vue from 'vue'
import Router from 'vue-router'
const Index = r => require.ensure([], () => r(require('@page/index')), 'Index')
Vue.use(Router)
export default new Router({
routes: [
{
path: '/',
redirect: '/index'
},
{
path: '/index',
component: Index
}
]
})

37
src/style/iconfont.styl Normal file
View File

@@ -0,0 +1,37 @@
.dropdown_icon::before
position absolute
right 0
top 0
content: '\e626'
.radio__icon--disabled .icon::before
content '\e608'
.radio__icon--checked .icon::before
content '\e608'
.close_icon::before
content '\e60f'
.select_icon::before
content '\e608'
.icon_exit
&::before
content '\e892'
// new
[class*=" icon_"],[class^=icon_]
font-family: "iconfont" !important;
speak: none;
font-style: normal;
font-weight: 400;
font-variant: normal;
text-transform: none;
line-height: 1;
vertical-align: middle;
display: inline-block;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
.icon_dropdown
font-size 15px
&::before
content: '\e626'
.icon_home
&::before
content: '\e632'

Binary file not shown.

Binary file not shown.

Binary file not shown.

41
src/style/layout.styl Normal file
View File

@@ -0,0 +1,41 @@
@import 'iconfont.styl';
@import 'mixin.styl';
@font-face
font-family 'iconfont';
src: url('iconfont/iconfont.woff2') format('woff2'),
url('iconfont/iconfont.woff') format('woff'),
url('iconfont/iconfont.ttf') format('truetype');
//
.el-input {
font-size: 16px;
}
.el-input__inner {
height 50px;
line-height: 50px;
border: 0;
background-color: transparent;
color: #fff;
}
.button-wrap {
margin: 30px 0 50px 0;
}
.button {
font-size: 16px;
line-height: 40px;
color #fff;
padding: 0 10px
border: 1px solid #fff;
border-radius: 10px;
background-color: transparent;
}
.button_s {
font-size: 12px;
padding: 0 2px
}
.btn-primary {
background-color: #14A3F3;
border-color: #14A3F3;
}

47
src/style/mixin.styl Normal file
View File

@@ -0,0 +1,47 @@
$red = #e74f1a
$red1 = #E74F19
$red2 = #FA6400
$green = #6CBE8B
$green1 = #00d246
$yellow = #E9B451
$blue = #6798ef
$gray = #c9c9c9
$gray1 = #8B90A6
$gray2 = #DFE1E6
$fc1 = #323232
$orange = #ffa530
$lightgreen = #b7e15d
//
_wh(w, h)
width: w
height: h
//
_font(size,height,color=$fc1,weight=normal,align=left)
font-size: size
line-height: height
color: color
font-weight: weight
text-align: align
//flex
_fj(x=space-between,y=center,z=row)
display: flex
justify-content: x
align-items: y
flex-direction: z
//
_bis(url,w,h=auto,x=center,y=center)
background-position: x y
background-size: w h
background-image: url(url)
background-repeat: no-repeat
//
_ct()
position: absolute
top: 50%
transform: translateY(-50%)

156
src/style/reset.css Normal file
View File

@@ -0,0 +1,156 @@
* {
padding: 0;
margin: 0;
list-style: none;
font-style: normal;
text-decoration: none;
border: none;
outline: none;
font-family: Arial, "Microsoft Yahei", "Helvetica Neue", Helvetica, sans-serif;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-webkit-tap-highlight-color:transparent;
-webkit-font-smoothing: antialiased;
}
body, html {
-webkit-user-select: auto;
-ms-user-select: auto;
user-select: auto;
background-color: #1058A0;
}
input[type="button"], input[type="submit"], input[type="search"], input[type="reset"], textarea, select{
-webkit-appearance: none;
appearance: none;
}
.relative {
position: relative;
}
.hide {
display: none;
}
.vhide {
visibility:hidden;
}
.show {
display: block;
}
.ellipsis{
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.flexcol {
flex-direction: column;
}
.flexstart {
align-items: flex-start !important;
}
.jcflexstart {
justify-content: flex-start !important;
}
.jcflexend {
justify-content: flex-end !important;
}
.jccenter {
justify-content: center !important;
}
.zd-row {
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
}
.zd-col-24 {
width: 100%;
}
.zd-col-23 {
width: 95.83333%
}
.zd-col-22 {
width: 91.66667%
}
.zd-col-21 {
width: 87.5%
}
.zd-col-20 {
width: 83.33333%
}
.zd-col-19 {
width: 79.16667%
}
.zd-col-18 {
width: 75%
}
.zd-col-17 {
width: 70.83333%
}
.zd-col-16 {
width: 66.66667%
}
.zd-col-15 {
width: 62.5%
}
.zd-col-14 {
width: 58.33333%
}
.zd-col-13 {
width: 54.16667%
}
.zd-col-12 {
width: 50%;
}
.zd-col-11 {
width: 45.83333%
}
.zd-col-10 {
width: 41.66667%
}
.zd-col-9 {
width: 37.5%
}
.zd-col-8 {
width: 33.33333%
}
.zd-col-7 {
width: 29.16667%
}
.zd-col-6 {
width: 25%
}
.zd-col-5 {
width: 20.83333%
}
.zd-col-4 {
width: 16.66667%
}
.zd-col-3 {
width: 12.5%
}
.zd-col-2 {
width: 8.33333%
}
.zd-col-1 {
width: 4.16667%
}
.border-bottom {
border-bottom: 1rpx solid #e5e5e5;
}
.mgb10 {
margin-bottom: 10rpx;
}
.pdl20 {
padding-left: 20rpx;
}
.pdr20 {
padding-right: 20rpx;
}
.pdr10 {
padding-right: 10rpx;
}
.pdt0 {
padding-top: 0 !important
}

99
src/vuex/modules/com.js Normal file
View File

@@ -0,0 +1,99 @@
import * as types from '../types'
import { getStore, setStore } from '@config/utils.js'
const baseUrl = process.env.NODE_ENV === 'development' ? 'http://192.168.81.171:8018' : 'http://192.168.81.171:8018'
const imgBaseUrl = process.env.NODE_ENV === 'development' ? 'http://192.168.81.171:8018' : 'http://192.168.81.171:8018'
const state = {
baseUrl: getStore('baseUrl') || baseUrl,
imgBaseUrl: getStore('imgBaseUrl') || imgBaseUrl,
lockTime: getStore('lockTime') || 0,
loading: false,
showToast: false,
showAlert: false,
showSuccess: true,
showFail: false,
toastMsg: '',
alertMsg: ''
}
const getters = {
baseUrl: state => state.baseUrl,
imgBaseUrl: state => state.imgBaseUrl,
lockTime: state => state.lockTime,
loading: state => state.loading,
showToast: state => state.showToast,
showAlert: state => state.showAlert
}
const actions = {
setConfig ({commit}, res) {
setStore('baseUrl', res.baseUrl)
setStore('imgBaseUrl', res.imgBaseUrl)
setStore('lockTime', res.lockTime)
commit(types.COM_CONFIG, res)
},
setLoadingState ({ commit }, status) {
commit(types.COM_LOADING_STATUS, status)
},
showToast ({ commit }, status) {
commit(types.COM_SHOW_TOAST, status)
},
showAlert ({ commit }, status) {
commit(types.COM_SHOW_ALERT, status)
},
showSuccess ({ commit }, status) {
commit(types.COM_SHOW_SUCCESS, status)
},
showFail ({ commit }, status) {
commit(types.COM_SHOW_FAIL, status)
},
toastMsg ({ commit }, str) {
commit(types.COM_TOAST_MSG, str)
},
alertMsg ({ commit }, str) {
commit(types.COM_ALERT_MSG, str)
}
}
const mutations = {
[types.COM_CONFIG] (state, res) {
state.baseUrl = res.baseUrl
state.imgBaseUrl = res.imgBaseUrl
state.lockTime = res.lockTime
},
[types.COM_LOADING_STATUS] (state, status) {
state.loading = status
},
[types.COM_SHOW_TOAST] (state, status) {
state.showToast = status
},
[types.COM_SHOW_ALERT] (state, status) {
state.showAlert = status
},
[types.COM_SHOW_SUCCESS] (state, status) {
state.showSuccess = status
},
[types.COM_SHOW_FAIL] (state, status) {
state.showFail = status
},
[types.COM_TOAST_MSG] (state, str) {
state.toastMsg = str
},
[types.COM_ALERT_MSG] (state, str) {
state.alertMsg = str
}
}
export default {
state,
actions,
getters,
mutations
}

70
src/vuex/modules/data.js Normal file
View File

@@ -0,0 +1,70 @@
import * as types from '../types'
import { getStore, setStore } from '@config/utils.js'
const state = {
keepAlive: JSON.parse(getStore('keepAlive')) || [], // 缓存页面
materObj: getStore('materObj') || '', // 存储对象
materArr: JSON.parse(getStore('materArr')) || [], // 存储数组
deviceUuid: getStore('deviceUuid') || '',
deviceCode: getStore('deviceCode') || '',
isProductonplan: getStore('isProductonplan') || ''
}
const getters = {
keepAlive: state => state.keepAlive,
materObj: state => state.materObj,
materArr: state => state.materArr,
deviceUuid: state => state.deviceUuid,
deviceCode: state => state.deviceCode,
isProductonplan: state => state.isProductonplan
}
const actions = {
setKeepAlive ({commit}, res) {
setStore('keepAlive', res)
commit(types.SET_KEEP_ALIVE, res)
},
setMaterObj ({commit}, res) {
setStore('materObj', res)
commit(types.SET_MATER_OBJ, res)
},
setMaterArr ({commit}, res) {
setStore('materArr', res)
commit(types.SET_MATER_ARR, res)
},
setDevice ({commit}, res) {
setStore('deviceUuid', res.deviceUuid)
setStore('deviceCode', res.deviceCode)
commit(types.DATA_DEVICE, res)
},
getIsProplan ({ commit }, res) {
setStore('isProductonplan', res)
commit(types.DATA_IS_PROPLAN, res)
}
}
const mutations = {
[types.SET_KEEP_ALIVE] (state, res) {
state.keepAlive = res
},
[types.SET_MATER_OBJ] (state, res) {
state.materObj = res
},
[types.SET_MATER_ARR] (state, res) {
state.materArr = res
},
[types.DATA_DEVICE] (state, res) {
state.deviceUuid = res.deviceUuid
state.deviceCode = res.deviceCode
},
[types.DATA_IS_PROPLAN] (state, res) {
state.isProductonplan = res
}
}
export default {
state,
getters,
actions,
mutations
}

50
src/vuex/modules/user.js Normal file
View File

@@ -0,0 +1,50 @@
import * as types from '../types'
import { getStore, setStore } from '@config/utils.js'
const state = {
userInfo: getStore('userInfo') ? getStore('userInfo') : '',
saveToken: getStore('saveToken') || ''
}
const getters = {
accountId: state => state.accountId,
accountName: state => state.accountName,
userName: state => state.userName,
deptName: state => state.deptName,
userInfo: state => state.userInfo,
saveToken: state => state.saveToken
}
const actions = {
saveUserInfo ({commit}, res) {
setStore('userInfo', res)
commit(types.SAVE_USER_INFO, res)
},
delUserInfo ({commit}, res) {
localStorage.removeItem('userInfo')
localStorage.removeItem('saveToken')
commit(types.DEL_USER_INFO, res)
},
saveToken ({commit}, res) {
setStore('saveToken', res)
commit(types.SAVE_TOKEN, res)
}
}
const mutations = {
[types.SAVE_USER_INFO] (state, res) {
state.userInfo = res
},
[types.DEL_USER_INFO] (state, res) {
},
[types.SAVE_TOKEN] (state, res) {
state.saveToken = res
}
}
export default {
state,
getters,
actions,
mutations
}

16
src/vuex/store.js Normal file
View File

@@ -0,0 +1,16 @@
import Vue from 'vue'
import Vuex from 'vuex'
import com from './modules/com'
import user from './modules/user'
import data from './modules/data'
Vue.use(Vuex)
export default new Vuex.Store({
modules: {
com,
user,
data
}
})

23
src/vuex/types.js Normal file
View File

@@ -0,0 +1,23 @@
// 公共配置
export const COM_CONFIG = 'COM_CONFIG'
export const COM_LOADING_STATUS = 'COM_LOADING_STATUS'
export const COM_SHOW_TOAST = 'COM_SHOW_TOAST' // 显示toast
export const COM_SHOW_SUCCESS = 'COM_SHOW_SUCCESS' // 显示成功toast
export const COM_SHOW_FAIL = 'COM_SHOW_FAIL' // 显示失败toast
export const COM_TOAST_MSG = 'COM_TOAST_MSG' // 显示toast文字
export const COM_SHOW_ALERT = 'COM_SHOW_ALERT'
export const COM_ALERT_MSG = 'COM_ALERT_MSG'
// 用户
export const SAVE_USER_INFO = 'SAVE_USER_INFO'
export const DEL_USER_INFO = 'DEL_USER_INFO'
export const SAVE_TOKEN = 'SAVE_TOKEN'
// 缓存页面
export const SET_KEEP_ALIVE = 'SET_KEEP_ALIVE'
export const SET_MATER_ARR = 'SET_MATER_ARR'
// 数据
export const SET_MATER_OBJ = 'SET_MATER_OBJ'
export const DATA_DEVICE = 'DATA_DEVICE'
export const DATA_IS_PROPLAN = 'DATA_IS_PROPLAN'

0
static/.gitkeep Normal file
View File

View File

@@ -0,0 +1,27 @@
// A custom Nightwatch assertion.
// The assertion name is the filename.
// Example usage:
//
// browser.assert.elementCount(selector, count)
//
// For more information on custom assertions see:
// http://nightwatchjs.org/guide#writing-custom-assertions
exports.assertion = function (selector, count) {
this.message = 'Testing if element <' + selector + '> has count: ' + count
this.expected = count
this.pass = function (val) {
return val === this.expected
}
this.value = function (res) {
return res.value
}
this.command = function (cb) {
var self = this
return this.api.execute(function (selector) {
return document.querySelectorAll(selector).length
}, [selector], function (res) {
cb.call(self, res)
})
}
}

View File

@@ -0,0 +1,46 @@
require('babel-register')
var config = require('../../config')
// http://nightwatchjs.org/gettingstarted#settings-file
module.exports = {
src_folders: ['test/e2e/specs'],
output_folder: 'test/e2e/reports',
custom_assertions_path: ['test/e2e/custom-assertions'],
selenium: {
start_process: true,
server_path: require('selenium-server').path,
host: '127.0.0.1',
port: 4444,
cli_args: {
'webdriver.chrome.driver': require('chromedriver').path
}
},
test_settings: {
default: {
selenium_port: 4444,
selenium_host: 'localhost',
silent: true,
globals: {
devServerURL: 'http://localhost:' + (process.env.PORT || config.dev.port)
}
},
chrome: {
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true
}
},
firefox: {
desiredCapabilities: {
browserName: 'firefox',
javascriptEnabled: true,
acceptSslCerts: true
}
}
}
}

48
test/e2e/runner.js Normal file
View File

@@ -0,0 +1,48 @@
// 1. start the dev server using production config
process.env.NODE_ENV = 'testing'
const webpack = require('webpack')
const DevServer = require('webpack-dev-server')
const webpackConfig = require('../../build/webpack.prod.conf')
const devConfigPromise = require('../../build/webpack.dev.conf')
let server
devConfigPromise.then(devConfig => {
const devServerOptions = devConfig.devServer
const compiler = webpack(webpackConfig)
server = new DevServer(compiler, devServerOptions)
const port = devServerOptions.port
const host = devServerOptions.host
return server.listen(port, host)
})
.then(() => {
// 2. run the nightwatch test suite against it
// to run in additional browsers:
// 1. add an entry in test/e2e/nightwatch.conf.js under "test_settings"
// 2. add it to the --env flag below
// or override the environment flag, for example: `npm run e2e -- --env chrome,firefox`
// For more information on Nightwatch's config file, see
// http://nightwatchjs.org/guide#settings-file
let opts = process.argv.slice(2)
if (opts.indexOf('--config') === -1) {
opts = opts.concat(['--config', 'test/e2e/nightwatch.conf.js'])
}
if (opts.indexOf('--env') === -1) {
opts = opts.concat(['--env', 'chrome'])
}
const spawn = require('cross-spawn')
const runner = spawn('./node_modules/.bin/nightwatch', opts, { stdio: 'inherit' })
runner.on('exit', function (code) {
server.close()
process.exit(code)
})
runner.on('error', function (err) {
server.close()
throw err
})
})

19
test/e2e/specs/test.js Normal file
View File

@@ -0,0 +1,19 @@
// For authoring Nightwatch tests, see
// http://nightwatchjs.org/guide#usage
module.exports = {
'default e2e tests': function (browser) {
// automatically uses dev Server port from /config.index.js
// default: http://localhost:8080
// see nightwatch.conf.js
const devServer = browser.globals.devServerURL
browser
.url(devServer)
.waitForElementVisible('#app', 5000)
.assert.elementPresent('.hello')
.assert.containsText('h1', 'Welcome to Your Vue.js App')
.assert.elementCount('img', 1)
.end()
}
}

7
test/unit/.eslintrc Normal file
View File

@@ -0,0 +1,7 @@
{
"env": {
"jest": true
},
"globals": {
}
}

30
test/unit/jest.conf.js Normal file
View File

@@ -0,0 +1,30 @@
const path = require('path')
module.exports = {
rootDir: path.resolve(__dirname, '../../'),
moduleFileExtensions: [
'js',
'json',
'vue'
],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1'
},
transform: {
'^.+\\.js$': '<rootDir>/node_modules/babel-jest',
'.*\\.(vue)$': '<rootDir>/node_modules/vue-jest'
},
testPathIgnorePatterns: [
'<rootDir>/test/e2e'
],
snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue'],
setupFiles: ['<rootDir>/test/unit/setup'],
mapCoverage: true,
coverageDirectory: '<rootDir>/test/unit/coverage',
collectCoverageFrom: [
'src/**/*.{js,vue}',
'!src/main.js',
'!src/router/index.js',
'!**/node_modules/**'
]
}

3
test/unit/setup.js Normal file
View File

@@ -0,0 +1,3 @@
import Vue from 'vue'
Vue.config.productionTip = false

View File

@@ -0,0 +1,11 @@
import Vue from 'vue'
import HelloWorld from '@/components/HelloWorld'
describe('HelloWorld.vue', () => {
it('should render correct contents', () => {
const Constructor = Vue.extend(HelloWorld)
const vm = new Constructor().$mount()
expect(vm.$el.querySelector('.hello h1').textContent)
.toEqual('Welcome to Your Vue.js App')
})
})

9320
yarn.lock Normal file

File diff suppressed because it is too large Load Diff