提交 7a9343dc 编写于 作者: xinglee23's avatar xinglee23

feat: update vue3

上级 f07b880a
{ {
"presets": ["es2015", "stage-2"], "presets": ["@babel/preset-env"],
"plugins": ["transform-runtime"], "plugins": ["@babel/plugin-transform-runtime"]
"comments": false,
} }
var utils = require('./utils')
module.exports = function (options) {
return {
loaders: utils.cssLoaders({
sourceMap: options.sourceMap
}),
postcss: [
require('autoprefixer')({
browsers: ['last 10 versions']
})
]
}
}
\ No newline at end of file
...@@ -10,7 +10,6 @@ var cssSourceMapDev = (env === 'development' && config.dev.cssSourceMap) ...@@ -10,7 +10,6 @@ var cssSourceMapDev = (env === 'development' && config.dev.cssSourceMap)
var cssSourceMapProd = (env === 'production' && config.build.productionSourceMap) var cssSourceMapProd = (env === 'production' && config.build.productionSourceMap)
var useCssSourceMap = cssSourceMapDev || cssSourceMapProd var useCssSourceMap = cssSourceMapDev || cssSourceMapProd
module.exports = { module.exports = {
entry: { entry: {
app: './src/main.js' app: './src/main.js'
...@@ -21,8 +20,7 @@ module.exports = { ...@@ -21,8 +20,7 @@ module.exports = {
filename: '[name].js' filename: '[name].js'
}, },
resolve: { resolve: {
extensions: ['', '.js', '.vue', '.less', '.css', '.scss'], extensions: ['*', '.js', '.vue', '.less', '.css', '.scss'],
fallback: [path.join(__dirname, '../node_modules')],
alias: { alias: {
'vue$': 'vue/dist/vue.common.js', 'vue$': 'vue/dist/vue.common.js',
'src': path.resolve(__dirname, '../src'), 'src': path.resolve(__dirname, '../src'),
...@@ -31,46 +29,49 @@ module.exports = { ...@@ -31,46 +29,49 @@ module.exports = {
'@': path.resolve('src') '@': path.resolve('src')
} }
}, },
resolveLoader: {
fallback: [path.join(__dirname, '../node_modules')]
},
module: { module: {
loaders: [{ rules: [{
test: /\.vue$/, test: /\.vue$/,
loader: 'vue' use: {
loader: 'vue-loader',
options: {
postcss: [
require('autoprefixer')({})
]
}
},
}, { }, {
test: /\.js$/, test: /\.js$/,
loader: 'babel',
include: projectRoot, include: projectRoot,
exclude: /node_modules/ exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}, { }, {
test: /\.json$/, test: /\.json$/,
loader: 'json' use: 'json-loader'
}, { }, {
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url', use: {
query: { loader: 'url-loader',
options: {
limit: 10000, limit: 10000,
name: utils.assetsPath('img/[name].[ext]') name: utils.assetsPath('img/[name].[ext]')
} }
}
}, { }, {
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url', use: {
query: { loader: 'url-loader',
options: {
limit: 5000, limit: 5000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]'), name: utils.assetsPath('fonts/[name].[hash:7].[ext]'),
publicPath: '../../' publicPath: '../../'
} }
}
}] }]
},
vue: {
loaders: utils.cssLoaders({
sourceMap: useCssSourceMap
}),
postcss: [
require('autoprefixer')({
browsers: ['last 10 versions']
})
]
} }
} }
\ No newline at end of file
var config = require('../config') var config = require('../config')
var path = require('path')
var webpack = require('webpack') var webpack = require('webpack')
var merge = require('webpack-merge') var merge = require('webpack-merge')
var utils = require('./utils') var utils = require('./utils')
...@@ -11,6 +12,11 @@ Object.keys(baseWebpackConfig.entry).forEach(function(name) { ...@@ -11,6 +12,11 @@ Object.keys(baseWebpackConfig.entry).forEach(function(name) {
}) })
module.exports = merge(baseWebpackConfig, { module.exports = merge(baseWebpackConfig, {
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
}
},
module: { module: {
loaders: utils.styleLoaders({ loaders: utils.styleLoaders({
sourceMap: config.dev.cssSourceMap sourceMap: config.dev.cssSourceMap
...@@ -23,9 +29,9 @@ module.exports = merge(baseWebpackConfig, { ...@@ -23,9 +29,9 @@ module.exports = merge(baseWebpackConfig, {
'process.env': config.dev.env 'process.env': config.dev.env
}), }),
// https://github.com/glenjamin/webpack-hot-middleware#installation--usage // https://github.com/glenjamin/webpack-hot-middleware#installation--usage
new webpack.optimize.OccurenceOrderPlugin(), // new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(), new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(), new webpack.NoEmitOnErrorsPlugin(),
// https://github.com/ampedandwired/html-webpack-plugin // https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
filename: 'index.html', filename: 'index.html',
......
{
"compilerOptions": {
"baseUrl": ".", // 这是根目录
"paths": {
"@/*": ["src/*"] // @ 指向 src 目录
}
},
"exclude": ["node_modules", "dist", "unpackage"]
}
此差异已折叠。
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"private": true, "private": true,
"license": "GPL", "license": "GPL",
"scripts": { "scripts": {
"dev": "cross-env BUILD_ENV=dev node build/dev-server.js", "dev": "cross-env BUILD_ENV=test node build/dev-server.js",
"local": "cross-env BUILD_ENV=development node build/dev-server.js", "local": "cross-env BUILD_ENV=development node build/dev-server.js",
"build": "node build/build.js", "build": "node build/build.js",
"build:dev": "cross-env BUILD_ENV=dev node build/build.js", "build:dev": "cross-env BUILD_ENV=dev node build/build.js",
...@@ -18,8 +18,11 @@ ...@@ -18,8 +18,11 @@
}, },
"dependencies": { "dependencies": {
"@babel/polyfill": "^7.2.5", "@babel/polyfill": "^7.2.5",
"@vue/compat": "^3.4.15",
"autoprefixer": "^10.4.17",
"axios": "0.16.2", "axios": "0.16.2",
"better-scroll": "^0.1.15", "better-scroll": "^0.1.15",
"core-js": "^3.8.3",
"dayjs": "^1.10.7", "dayjs": "^1.10.7",
"echarts": "^4.2.0-rc.2", "echarts": "^4.2.0-rc.2",
"element-ui": "^2.11.1", "element-ui": "^2.11.1",
...@@ -29,7 +32,7 @@ ...@@ -29,7 +32,7 @@
"js-cookie": "^2.2.0", "js-cookie": "^2.2.0",
"js-md5": "^0.7.3", "js-md5": "^0.7.3",
"jsencrypt": "^3.2.1", "jsencrypt": "^3.2.1",
"jspdf": "^1.5.3", "jspdf": "^2.5.1",
"node-sass": "^4.9.2", "node-sass": "^4.9.2",
"pdfh5": "^1.3.9", "pdfh5": "^1.3.9",
"qrcode": "^1.3.3", "qrcode": "^1.3.3",
...@@ -37,25 +40,24 @@ ...@@ -37,25 +40,24 @@
"showdown": "^1.6.4", "showdown": "^1.6.4",
"sortablejs": "^1.13.0", "sortablejs": "^1.13.0",
"storejs": "^2.0.1", "storejs": "^2.0.1",
"tiny-emitter": "^2.1.0",
"video.js": "^7.8.2", "video.js": "^7.8.2",
"vue": "^2.1.0", "vue": "^3.4.15",
"vue-infinite-scroll": "^2.0.2", "vue-infinite-scroll": "^2.0.2",
"vue-router": "^2.1.1", "vue-router": "^4.0.8",
"vue-ueditor-wrap": "^2.4.1", "vue-ueditor-wrap": "^2.4.1",
"vue-video-player": "^5.0.2", "vue-video-player": "^5.0.2",
"vuedraggable": "^2.24.3", "vuedraggable": "^2.24.3",
"vuex": "^2.0.0" "vuex": "^4.0.2"
}, },
"devDependencies": { "devDependencies": {
"autoprefixer": "^6.4.0", "@babel/core": "^7.23.7",
"autoprefixer-loader": "^3.2.0", "@babel/preset-env": "^7.23.8",
"babel-core": "^6.0.0", "@vue/cli-plugin-babel": "^5.0.1",
"babel-loader": "^6.0.0", "@vue/cli-service": "^5.0.1",
"@vue/compiler-sfc": "^3.4.15",
"babel-loader": "^8.3.0",
"babel-plugin-transform-runtime": "^6.0.0", "babel-plugin-transform-runtime": "^6.0.0",
"babel-preset-es2015": "^6.0.0",
"babel-preset-stage-2": "^6.0.0",
"babel-register": "^6.0.0",
"babel-runtime": "^6.23.0",
"chalk": "^1.1.3", "chalk": "^1.1.3",
"connect-history-api-fallback": "^1.1.0", "connect-history-api-fallback": "^1.1.0",
"cropperjs": "^1.5.7", "cropperjs": "^1.5.7",
...@@ -63,7 +65,7 @@ ...@@ -63,7 +65,7 @@
"css-loader": "^0.28.11", "css-loader": "^0.28.11",
"eventsource-polyfill": "^0.9.6", "eventsource-polyfill": "^0.9.6",
"express": "^4.13.3", "express": "^4.13.3",
"extract-text-webpack-plugin": "^1.0.1", "extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^0.9.0", "file-loader": "^0.9.0",
"function-bind": "^1.0.2", "function-bind": "^1.0.2",
"html-webpack-plugin": "^2.8.1", "html-webpack-plugin": "^2.8.1",
...@@ -76,7 +78,7 @@ ...@@ -76,7 +78,7 @@
"opn": "^4.0.2", "opn": "^4.0.2",
"ora": "^0.3.0", "ora": "^0.3.0",
"sass": "^0.5.0", "sass": "^0.5.0",
"sass-loader": "^4.1.1", "sass-loader": "^10.5.2",
"scss": "^0.2.4", "scss": "^0.2.4",
"scss-loader": "0.0.1", "scss-loader": "0.0.1",
"semver": "^5.3.0", "semver": "^5.3.0",
...@@ -84,10 +86,9 @@ ...@@ -84,10 +86,9 @@
"style-loader": "^0.13.1", "style-loader": "^0.13.1",
"url-loader": "^0.5.7", "url-loader": "^0.5.7",
"vue-lazyload": "^1.2.6", "vue-lazyload": "^1.2.6",
"vue-loader": "^10.0.0", "vue-loader": "^16.0.0",
"vue-style-loader": "^2.0.5", "vue-style-loader": "^2.0.5",
"vue-template-compiler": "^2.1.0", "webpack": "^3.12.0",
"webpack": "^1.13.2",
"webpack-dev-middleware": "^1.8.3", "webpack-dev-middleware": "^1.8.3",
"webpack-dev-server": "^1.16.2", "webpack-dev-server": "^1.16.2",
"webpack-hot-middleware": "^2.12.2", "webpack-hot-middleware": "^2.12.2",
...@@ -96,5 +97,10 @@ ...@@ -96,5 +97,10 @@
"engines": { "engines": {
"node": ">= 4.0.0", "node": ">= 4.0.0",
"npm": ">= 3.0.0" "npm": ">= 3.0.0"
} },
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
} }
此差异已折叠。
<template> <template>
<div class="bread-crumb"> <div class="bread-crumb">
<el-breadcrumb separator="/"> <el-breadcrumb separator="/">
<el-breadcrumb-item>{{curmbFirst}}</el-breadcrumb-item> <el-breadcrumb-item>{{ curmbFirst }}</el-breadcrumb-item>
<el-breadcrumb-item v-if="curmbSecond" :to="{ path: jumPathThird }">{{curmbSecond}}</el-breadcrumb-item> <el-breadcrumb-item v-if="curmbSecond" :to="{ path: jumPathThird }">{{
<el-breadcrumb-item v-if="curmbThird" :to="{ path: jumPathFouth }">{{curmbThird}}</el-breadcrumb-item> curmbSecond
<el-breadcrumb-item v-if="curmbFouth">{{curmbFouth}}</el-breadcrumb-item> }}</el-breadcrumb-item>
<el-breadcrumb-item v-if="curmbThird" :to="{ path: jumPathFouth }">{{
curmbThird
}}</el-breadcrumb-item>
<el-breadcrumb-item v-if="curmbFouth">{{
curmbFouth
}}</el-breadcrumb-item>
</el-breadcrumb> </el-breadcrumb>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
props: { props: {
curmbFirst: { curmbFirst: {
type: String type: String,
}, },
curmbSecond: { curmbSecond: {
type: String type: String,
}, },
curmbThird: { curmbThird: {
type: String type: String,
}, },
curmbFouth: { curmbFouth: {
type: String type: String,
}, },
jumPathThird: { jumPathThird: {
type: String type: String,
}, },
jumPathFouth: { jumPathFouth: {
type: String type: String,
} },
} },
} }
</script> </script>
<style lang="scss"> <style lang="scss">
.bread-crumb { .bread-crumb {
position: fixed; position: fixed;
...@@ -42,11 +50,9 @@ export default { ...@@ -42,11 +50,9 @@ export default {
height: 61px; height: 61px;
padding: 20px 20px 30px; padding: 20px 20px 30px;
z-index: 99; z-index: 99;
border-top: 3px solid #F0F2F5; border-top: 3px solid #f0f2f5;
.el-breadcrumb__inner { .el-breadcrumb__inner {
font-size: 14px; font-size: 14px;
} }
} }
</style> </style>
<template> <template>
<div class="rc-cropper" v-if="originImg"> <div class="rc-cropper" v-if="originImg">
<div :class="{'rc-cropper__canvasCrop1': cropOption.uploadType == 1, 'rc-cropper__canvasCrop2': cropOption.uploadType == 2}"> <div
<img :src="originImg" v-if="!cropper"> :class="{
<canvas :id="originImg" ref="canvas"/> 'rc-cropper__canvasCrop1': cropOption.uploadType == 1,
'rc-cropper__canvasCrop2': cropOption.uploadType == 2,
}"
>
<img :src="originImg" v-if="!cropper" />
<canvas :id="originImg" ref="canvas" />
<div class="rc-cropper__iconCrop"> <div class="rc-cropper__iconCrop">
<el-tooltip content="确认裁剪" placement="right" v-if="cropper"> <el-tooltip content="确认裁剪" placement="right" v-if="cropper">
<el-button type="success" size="mini" @click="sureCropper()"><i class="el-icon-check"></i></el-button> <el-button type="success" size="mini" @click="sureCropper()"
><i class="el-icon-check"></i
></el-button>
</el-tooltip> </el-tooltip>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { $on, $off, $once, $emit } from '../../../utils/gogocodeTransfer'
import Cropper from 'cropperjs' import Cropper from 'cropperjs'
import 'cropperjs/dist/cropper.min.css' import 'cropperjs/dist/cropper.min.css'
export default { export default {
...@@ -20,35 +29,35 @@ export default { ...@@ -20,35 +29,35 @@ export default {
cropOption: { cropOption: {
type: Object, type: Object,
required: true, required: true,
default: () => {} default: () => {},
}, },
originImg: { originImg: {
required: true required: true,
}, },
}, },
data () { data() {
return { return {
cropper: null, cropper: null,
croppShow: false croppShow: false,
} }
}, },
mounted () { mounted() {
this.drawImg() this.drawImg()
}, },
destroyed() { unmounted() {
this.cropper && this.cropper.destroy(); this.cropper && this.cropper.destroy()
}, },
methods: { methods: {
// 在canvas上绘制图片 // 在canvas上绘制图片
drawImg () { drawImg() {
const _this = this const _this = this
this.$nextTick(() => { this.$nextTick(() => {
let canvas = document.getElementById(this.originImg) let canvas = document.getElementById(this.originImg)
if (canvas) { if (canvas) {
// canvas.width = 1000 // canvas.width = 1000
// canvas.height = 800 // canvas.height = 800
canvas.width = _this.cropOption.cvWidth; canvas.width = _this.cropOption.cvWidth
canvas.height = _this.cropOption.cvHeight; canvas.height = _this.cropOption.cvHeight
let ctx = canvas.getContext('2d') let ctx = canvas.getContext('2d')
ctx.clearRect(0, 0, canvas.width, canvas.height) ctx.clearRect(0, 0, canvas.width, canvas.height)
let img = new Image() let img = new Image()
...@@ -62,7 +71,7 @@ export default { ...@@ -62,7 +71,7 @@ export default {
}) })
}, },
// 显示裁剪框 // 显示裁剪框
initCropper () { initCropper() {
this.croppShow = true this.croppShow = true
this.cropper = new Cropper(this.$refs.canvas, { this.cropper = new Cropper(this.$refs.canvas, {
checkCrossOrigin: true, checkCrossOrigin: true,
...@@ -86,7 +95,7 @@ export default { ...@@ -86,7 +95,7 @@ export default {
x: this.cropOption.offset_x, x: this.cropOption.offset_x,
y: this.cropOption.offset_y, y: this.cropOption.offset_y,
width: this.cropOption.width, width: this.cropOption.width,
height: this.cropOption.height height: this.cropOption.height,
}) })
// this.cropper.zoomTo(1); // this.cropper.zoomTo(1);
}, },
...@@ -99,50 +108,43 @@ export default { ...@@ -99,50 +108,43 @@ export default {
}) })
}, },
// 确认裁剪 // 确认裁剪
sureCropper () { sureCropper() {
let _this = this let _this = this
const cropParam = this.cropper.getData() const cropParam = this.cropper.getData()
console.log('cropParam', cropParam); console.log('cropParam', cropParam)
this.cropper.getCroppedCanvas().toBlob(function (blob) { this.cropper.getCroppedCanvas().toBlob(function (blob) {
let files = new window.File([blob], 'cropper.jpg'); let files = new window.File([blob], 'cropper.jpg')
console.log(files); console.log(files)
let oFileReader = new FileReader() let oFileReader = new FileReader()
oFileReader.onloadend = function (e) { oFileReader.onloadend = function (e) {
let base64 = e.target.result let base64 = e.target.result
_this.$emit('getCropImg', base64, cropParam, files, _this.cropper) $emit(_this, 'getCropImg', base64, cropParam, files, _this.cropper)
} }
oFileReader.readAsDataURL(blob) oFileReader.readAsDataURL(blob)
}, 'image/jpeg') }, 'image/jpeg')
} },
} },
emits: ['getCropImg'],
} }
</script> </script>
<style scoped lang="scss">
<style lang="scss" scoped>
.rc-cropper__canvasCrop1 { .rc-cropper__canvasCrop1 {
/* border: 1px solid red; */
width: 800px; width: 800px;
height: 540px; height: 540px;
} }
.rc-cropper__canvasCrop2 { .rc-cropper__canvasCrop2 {
/* border: 1px solid red; */
width: 400px; width: 400px;
height: 300px; height: 300px;
} }
.rc-cropper__iconCrop { .rc-cropper__iconCrop {
position: absolute; position: absolute; /*// left: 46%;*/
// left: 46%;
right: 13%; right: 13%;
top: 15%; top: 15%;
} }
.el-tooltip { .el-tooltip {
margin: 20px 4px; margin: 20px 4px;
display: block; display: block;
z-index: 10000; z-index: 10000;
} }
</style> </style>
<template> <template>
<div class="rc-cropper" v-if="originImg"> <div class="rc-cropper" v-if="originImg">
<div class="rc-cropper__canvasCrop2"> <div class="rc-cropper__canvasCrop2">
<img :src="originImg" v-if="!cropper"> <img :src="originImg" v-if="!cropper" />
<canvas :id="originImg" ref="canvas"/> <canvas :id="originImg" ref="canvas" />
<div class="rc-cropper__iconCrop"> <div class="rc-cropper__iconCrop">
<el-tooltip content="确认裁剪" placement="right" v-if="cropper"> <el-tooltip content="确认裁剪" placement="right" v-if="cropper">
<el-button type="success" size="mini" @click="sureCropper()"><i class="el-icon-check"></i></el-button> <el-button type="success" size="mini" @click="sureCropper()"
><i class="el-icon-check"></i
></el-button>
</el-tooltip> </el-tooltip>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { $on, $off, $once, $emit } from '../../../utils/gogocodeTransfer'
import Cropper from 'cropperjs' import Cropper from 'cropperjs'
import 'cropperjs/dist/cropper.min.css' import 'cropperjs/dist/cropper.min.css'
export default { export default {
...@@ -20,30 +24,30 @@ export default { ...@@ -20,30 +24,30 @@ export default {
cropOption: { cropOption: {
type: Object, type: Object,
required: true, required: true,
default: () => {} default: () => {},
}, },
originImg: { originImg: {
required: true required: true,
}, },
previewImg: { previewImg: {
type: String type: String,
}
}, },
data () { },
data() {
return { return {
cropper: null, cropper: null,
croppShow: false croppShow: false,
} }
}, },
mounted () { mounted() {
this.drawImg() this.drawImg()
}, },
destroyed() { unmounted() {
this.cropper && this.cropper.destroy(); this.cropper && this.cropper.destroy()
}, },
methods: { methods: {
// 在canvas上绘制图片 // 在canvas上绘制图片
drawImg () { drawImg() {
const _this = this const _this = this
this.$nextTick(() => { this.$nextTick(() => {
let canvas = document.getElementById(this.originImg) let canvas = document.getElementById(this.originImg)
...@@ -63,7 +67,7 @@ export default { ...@@ -63,7 +67,7 @@ export default {
}) })
}, },
// 显示裁剪框 // 显示裁剪框
initCropper () { initCropper() {
this.croppShow = true this.croppShow = true
this.cropper = new Cropper(this.$refs.canvas, { this.cropper = new Cropper(this.$refs.canvas, {
checkCrossOrigin: true, checkCrossOrigin: true,
...@@ -87,7 +91,7 @@ export default { ...@@ -87,7 +91,7 @@ export default {
x: this.cropOption.offset_x, x: this.cropOption.offset_x,
y: this.cropOption.offset_y, y: this.cropOption.offset_y,
width: this.cropOption.width, width: this.cropOption.width,
height: this.cropOption.height height: this.cropOption.height,
}) })
// this.cropper.zoomTo(1); // this.cropper.zoomTo(1);
}, },
...@@ -100,63 +104,30 @@ export default { ...@@ -100,63 +104,30 @@ export default {
}) })
}, },
// 确认裁剪 // 确认裁剪
sureCropper () { sureCropper() {
let _this = this let _this = this
const cropParam = this.cropper.getData() const cropParam = this.cropper.getData()
console.log('cropParam', cropParam); console.log('cropParam', cropParam)
this.cropper.getCroppedCanvas().toBlob(function (blob) { this.cropper.getCroppedCanvas().toBlob(function (blob) {
let files = new window.File([blob], 'cropper.jpg'); let files = new window.File([blob], 'cropper.jpg')
console.log(files); console.log(files)
let oFileReader = new FileReader() let oFileReader = new FileReader()
oFileReader.onloadend = function (e) { oFileReader.onloadend = function (e) {
let base64 = e.target.result let base64 = e.target.result
_this.$emit('getCropImg', base64, cropParam, files, _this.cropper) $emit(_this, 'getCropImg', base64, cropParam, files, _this.cropper)
} }
oFileReader.readAsDataURL(blob) oFileReader.readAsDataURL(blob)
}, 'image/jpeg') }, 'image/jpeg')
} },
} },
emits: ['getCropImg'],
} }
</script> </script>
<style scoped lang="scss">
// .rc-cropper { <style lang="scss" scoped>
// position: relative; /*// .rc-cropper*/{/*// position: relative;*//*// margin-top: 10px;*//*// img {*/
// margin-top: 10px;
// img {
// width: 100%; // width: 100%;
// height: 100%; // height: 100%;
// } // }
// } //}.rc-cropper__canvasCrop2{width:800px;height:540px}.rc-cropper__iconCrop{position:absolute;left:46%;top:10%}.el-tooltip{margin:20px 4px;display:block;z-index:10000}
/* img {
width: 100%;
height: 100%;
} */
.rc-cropper__canvasCrop2 {
/* border: 1px solid red; */
width: 800px;
height: 540px;
}
.rc-cropper__iconCrop {
position: absolute;
/* left: 8%; */
left: 46%;
top: 10%;
}
.el-tooltip {
margin: 20px 4px;
display: block;
z-index: 10000;
}
</style>
margin: 20px 4px;
display: block;
z-index: 10000;
}
</style> </style>
<template> <template>
<div class="rc-cropper" v-if="originImg"> <div class="rc-cropper" v-if="originImg">
<div :class="{'rc-cropper__canvasCrop1': cropOption.uploadType == 1, 'rc-cropper__canvasCrop2': cropOption.uploadType == 2}"> <div
<img :src="originImg" v-if="!cropper"> :class="{
<canvas :id="originImg" ref="canvas"/> 'rc-cropper__canvasCrop1': cropOption.uploadType == 1,
'rc-cropper__canvasCrop2': cropOption.uploadType == 2,
}"
>
<img :src="originImg" v-if="!cropper" />
<canvas :id="originImg" ref="canvas" />
<div class="rc-cropper__iconCrop"> <div class="rc-cropper__iconCrop">
<el-tooltip content="确认裁剪" placement="right" v-if="cropper"> <el-tooltip content="确认裁剪" placement="right" v-if="cropper">
<el-button type="success" size="mini" @click="sureCropper()"><i class="el-icon-check"></i></el-button> <el-button type="success" size="mini" @click="sureCropper()"
><i class="el-icon-check"></i
></el-button>
</el-tooltip> </el-tooltip>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { $on, $off, $once, $emit } from '../../../utils/gogocodeTransfer'
import Cropper from 'cropperjs' import Cropper from 'cropperjs'
import 'cropperjs/dist/cropper.min.css' import 'cropperjs/dist/cropper.min.css'
export default { export default {
...@@ -20,35 +29,35 @@ export default { ...@@ -20,35 +29,35 @@ export default {
cropOption: { cropOption: {
type: Object, type: Object,
required: true, required: true,
default: () => {} default: () => {},
}, },
originImg: { originImg: {
required: true required: true,
}, },
}, },
data () { data() {
return { return {
cropper: null, cropper: null,
croppShow: false croppShow: false,
} }
}, },
mounted () { mounted() {
this.drawImg() this.drawImg()
}, },
destroyed() { unmounted() {
this.cropper && this.cropper.destroy(); this.cropper && this.cropper.destroy()
}, },
methods: { methods: {
// 在canvas上绘制图片 // 在canvas上绘制图片
drawImg () { drawImg() {
const _this = this const _this = this
this.$nextTick(() => { this.$nextTick(() => {
let canvas = document.getElementById(this.originImg) let canvas = document.getElementById(this.originImg)
if (canvas) { if (canvas) {
// canvas.width = 1000 // canvas.width = 1000
// canvas.height = 800 // canvas.height = 800
canvas.width = _this.cropOption.cvWidth; canvas.width = _this.cropOption.cvWidth
canvas.height = _this.cropOption.cvHeight; canvas.height = _this.cropOption.cvHeight
let ctx = canvas.getContext('2d') let ctx = canvas.getContext('2d')
ctx.clearRect(0, 0, canvas.width, canvas.height) ctx.clearRect(0, 0, canvas.width, canvas.height)
let img = new Image() let img = new Image()
...@@ -62,24 +71,26 @@ export default { ...@@ -62,24 +71,26 @@ export default {
}) })
}, },
// 显示裁剪框 // 显示裁剪框
initCropper () { initCropper() {
if (!HTMLCanvasElement.prototype.toBlob) { if (!HTMLCanvasElement.prototype.toBlob) {
console.log('HTMLCanvasElement.prototype.toBlob####'); console.log('HTMLCanvasElement.prototype.toBlob####')
Object.defineProperty(HTMLCanvasElement.prototype, 'toBlob', { Object.defineProperty(HTMLCanvasElement.prototype, 'toBlob', {
value: function (callback, type, quality) { value: function (callback, type, quality) {
var canvas = this; var canvas = this
setTimeout(function () { setTimeout(function () {
var binStr = window.atob(canvas.toDataURL(type, quality).split(',')[1]); var binStr = window.atob(
var len = binStr.length; canvas.toDataURL(type, quality).split(',')[1]
var arr = new window.Uint8Array(len); )
var len = binStr.length
var arr = new window.Uint8Array(len)
for (var i = 0; i < len; i++) { for (var i = 0; i < len; i++) {
arr[i] = binStr.charCodeAt(i); arr[i] = binStr.charCodeAt(i)
} }
// callback(new window.Blob([arr], { type: type || 'image/jpeg' })); // callback(new window.Blob([arr], { type: type || 'image/jpeg' }));
callback(new window.Blob([arr], { type: type || 'image/jpeg' })); callback(new window.Blob([arr], { type: type || 'image/jpeg' }))
}); })
} },
}); })
} }
this.croppShow = true this.croppShow = true
...@@ -105,7 +116,7 @@ export default { ...@@ -105,7 +116,7 @@ export default {
x: this.cropOption.offset_x, x: this.cropOption.offset_x,
y: this.cropOption.offset_y, y: this.cropOption.offset_y,
width: this.cropOption.width, width: this.cropOption.width,
height: this.cropOption.height height: this.cropOption.height,
}) })
// this.cropper.zoomTo(1); // this.cropper.zoomTo(1);
}, },
...@@ -118,55 +129,51 @@ export default { ...@@ -118,55 +129,51 @@ export default {
}) })
}, },
// 确认裁剪 // 确认裁剪
sureCropper () { sureCropper() {
let _this = this let _this = this
const cropParam = this.cropper.getData() const cropParam = this.cropper.getData()
console.log('cropParam', cropParam); console.log('cropParam', cropParam)
this.cropper.getCroppedCanvas().toBlob(function (blob) { this.cropper.getCroppedCanvas().toBlob(function (blob) {
var objecturl = window.URL.createObjectURL(blob); var objecturl = window.URL.createObjectURL(blob)
console.log('objecturl', objecturl); console.log('objecturl', objecturl)
let files = new window.File([blob], 'cropper.jpg'); let files = new window.File([blob], 'cropper.jpg')
console.log('getCroppedCanvas', files); console.log('getCroppedCanvas', files)
let oFileReader = new window.FileReader() let oFileReader = new window.FileReader()
console.log('oFileReader', oFileReader); console.log('oFileReader', oFileReader)
oFileReader.onloadend = function (e) { oFileReader.onloadend = function (e) {
console.log('e.target.result', e, e.target, e.target.result); console.log('e.target.result', e, e.target, e.target.result)
let base64 = e.target.result; let base64 = e.target.result
_this.$emit('getCropImg', base64, cropParam, files, _this.cropper) $emit(_this, 'getCropImg', base64, cropParam, files, _this.cropper)
} }
oFileReader.readAsDataURL(blob) oFileReader.readAsDataURL(blob)
}, 'image/jpeg') }, 'image/jpeg')
} },
} },
emits: ['getCropImg'],
} }
</script> </script>
<style scoped lang="scss">
// .rc-cropper {
// margin-left: 20px;
// }
<style lang="scss" scoped>
/*// .rc-cropper*/
{
/*// margin-left: 20px;*/ /*//*/
}
.rc-cropper__canvasCrop1 { .rc-cropper__canvasCrop1 {
width: 800px; width: 800px;
height: 540px; height: 540px;
} }
.rc-cropper__canvasCrop2 { .rc-cropper__canvasCrop2 {
width: 400px; width: 400px;
height: 300px; height: 300px;
} }
.rc-cropper__iconCrop { .rc-cropper__iconCrop {
position: absolute; position: absolute; /*// left: 46%;*/
// left: 46%;
right: 13%; right: 13%;
top: 15%; top: 15%;
} }
.el-tooltip { .el-tooltip {
margin: 20px 4px; margin: 20px 4px;
display: block; display: block;
z-index: 10000; z-index: 10000;
} }
</style> </style>
...@@ -3,24 +3,28 @@ ...@@ -3,24 +3,28 @@
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<div class="rc-cropper__canvasCrop2"> <div class="rc-cropper__canvasCrop2">
<img :src="originImg" v-if="!cropper"> <img :src="originImg" v-if="!cropper" />
<canvas :id="originImg" ref="canvas"/> <canvas :id="originImg" ref="canvas" />
<div class="rc-cropper__iconCrop"> <div class="rc-cropper__iconCrop">
<el-tooltip content="确认裁剪" placement="right" v-if="cropper"> <el-tooltip content="确认裁剪" placement="right" v-if="cropper">
<el-button type="success" size="mini" @click="sureCropper()"><i class="el-icon-check"></i></el-button> <el-button type="success" size="mini" @click="sureCropper()"
><i class="el-icon-check"></i
></el-button>
</el-tooltip> </el-tooltip>
</div> </div>
</div> </div>
</el-col> </el-col>
<el-col :span="10"> <el-col :span="10">
<div class="rc-cropper__previewImg"> <div class="rc-cropper__previewImg">
<img :src="previewImg" id="previewImg"/> <img :src="previewImg" id="previewImg" />
</div> </div>
</el-col> </el-col>
</el-row> </el-row>
</div> </div>
</template> </template>
<script> <script>
import { $on, $off, $once, $emit } from '../../../utils/gogocodeTransfer'
import Cropper from 'cropperjs' import Cropper from 'cropperjs'
import 'cropperjs/dist/cropper.min.css' import 'cropperjs/dist/cropper.min.css'
export default { export default {
...@@ -29,27 +33,27 @@ export default { ...@@ -29,27 +33,27 @@ export default {
cropOption: { cropOption: {
type: Object, type: Object,
required: true, required: true,
default: () => {} default: () => {},
}, },
originImg: { originImg: {
required: true required: true,
}, },
previewImg: { previewImg: {
type: String type: String,
} },
}, },
data () { data() {
return { return {
cropper: null, cropper: null,
croppShow: false croppShow: false,
} }
}, },
mounted () { mounted() {
this.drawImg() this.drawImg()
}, },
methods: { methods: {
// 在canvas上绘制图片 // 在canvas上绘制图片
drawImg () { drawImg() {
const _this = this const _this = this
this.$nextTick(() => { this.$nextTick(() => {
let canvas = document.getElementById(this.originImg) let canvas = document.getElementById(this.originImg)
...@@ -69,7 +73,7 @@ export default { ...@@ -69,7 +73,7 @@ export default {
}) })
}, },
// 显示裁剪框 // 显示裁剪框
initCropper () { initCropper() {
this.croppShow = true this.croppShow = true
this.cropper = new Cropper(this.$refs.canvas, { this.cropper = new Cropper(this.$refs.canvas, {
checkCrossOrigin: true, checkCrossOrigin: true,
...@@ -81,56 +85,45 @@ export default { ...@@ -81,56 +85,45 @@ export default {
x: this.cropOption.offset_x, x: this.cropOption.offset_x,
y: this.cropOption.offset_y, y: this.cropOption.offset_y,
width: this.cropOption.width, width: this.cropOption.width,
height: this.cropOption.height height: this.cropOption.height,
}) })
} },
}) })
// this.cropper = cropper // this.cropper = cropper
}, },
// 确认裁剪 // 确认裁剪
sureCropper () { sureCropper() {
let _this = this let _this = this
const cropParam = this.cropper.getData() const cropParam = this.cropper.getData()
this.cropper.getCroppedCanvas().toBlob(function (blob) { this.cropper.getCroppedCanvas().toBlob(function (blob) {
let oFileReader = new FileReader() let oFileReader = new FileReader()
oFileReader.onloadend = function (e) { oFileReader.onloadend = function (e) {
let base64 = e.target.result let base64 = e.target.result
_this.$emit('getCropImg', base64, cropParam) $emit(_this, 'getCropImg', base64, cropParam)
} }
oFileReader.readAsDataURL(blob) oFileReader.readAsDataURL(blob)
}, 'image/jpeg') }, 'image/jpeg')
} },
} },
emits: ['getCropImg'],
} }
</script> </script>
<style >
/* .rc-cropper {
position: relative;
margin-top: 20px;
} */
/* img {
width: 100%;
height: 100%;
} */
<style>
.rc-cropper__canvasCrop2 { .rc-cropper__canvasCrop2 {
width: 720px; width: 720px;
height: 480px; height: 480px;
} }
.rc-cropper__iconCrop { .rc-cropper__iconCrop {
position: absolute; position: absolute;
left: 45%; left: 45%;
top: 0%; top: 0%;
} }
.el-tooltip { .el-tooltip {
margin: 20px 4px; margin: 20px 4px;
display: block; display: block;
z-index: 10000; z-index: 10000;
} }
.rc-cropper__previewImg { .rc-cropper__previewImg {
width: 600px; width: 600px;
height: 400px; height: 400px;
......
此差异已折叠。
此差异已折叠。
...@@ -11,24 +11,27 @@ ...@@ -11,24 +11,27 @@
> >
<!-- <canvas v-for="page in pages" :id="'the-canvas'+page" :key="page"></canvas> --> <!-- <canvas v-for="page in pages" :id="'the-canvas'+page" :key="page"></canvas> -->
<div id="demo"></div> <div id="demo"></div>
<div slot="footer" class="dialog-footer"> <template v-slot:footer>
<div class="dialog-footer">
<el-button type="primary" @click="close">确 定</el-button> <el-button type="primary" @click="close">确 定</el-button>
</div> </div>
</template>
</el-dialog> </el-dialog>
</template> </template>
<script> <script>
// import Pdfh5 from "pdfh5"; import { $on, $off, $once, $emit } from '../../../../utils/gogocodeTransfer'
export default { export default {
data() { data() {
return { return {
pdfh5: null pdfh5: null,
}; }
}, },
props: { props: {
dialogVisible: { dialogVisible: {
type: Boolean, type: Boolean,
default: false default: false,
} },
}, },
computed: {}, computed: {},
components: { components: {
...@@ -55,21 +58,16 @@ export default { ...@@ -55,21 +58,16 @@ export default {
}, },
methods: { methods: {
close() { close() {
this.$emit("close"); $emit(this, 'close')
} },
} },
}; emits: ['close'],
}
</script> </script>
<style scoped lang="scss">
// @import "pdfh5/css/pdfh5.css"; <style lang="scss" scoped>
// * { /*// @import "pdfh5/css/pdfh5.css";*/
// padding: 0; // *{/*// padding: 0;*//*// margin: 0;*//*//*/}/*// html,*/
// margin: 0;
// }
// html,
// body, // body,
// #app { // #app{/*// width: 100%;*//*// height: 100%;*//*//*/}
// width: 100%;
// height: 100%;
// }
</style> </style>
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
export const kolCol = [ export const kolCol = [
{ {
label: '顺序', label: '顺序',
prop: "seq" prop: 'seq',
}, },
{ {
label: '姓名', label: '姓名',
prop: "name" prop: 'name',
}, },
{ {
label: '地区', label: '地区',
prop: "district" prop: 'district',
}, },
{ {
label: '所在医院', label: '所在医院',
prop: "hospital" prop: 'hospital',
}, },
{ {
label: '科室', label: '科室',
prop: "department" prop: 'department',
}, },
{ {
label: '职称', label: '职称',
prop: "title" prop: 'title',
}, },
{ {
label: '所属团队', label: '所属团队',
prop: "team" prop: 'team',
}, },
{ {
label: '发布状态', label: '发布状态',
prop: "status" prop: 'status',
}, },
{ {
label: '操作', label: '操作',
prop: "operate" prop: 'operate',
} },
] ]
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
<!-- 圈子router -->
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册