| | |
| | | "clipboard": "^2.0.0" |
| | | } |
| | | }, |
| | | "vue-cropper": { |
| | | "version": "0.6.5", |
| | | "resolved": "https://registry.npmmirror.com/vue-cropper/-/vue-cropper-0.6.5.tgz", |
| | | "integrity": "sha512-lSvY6IpeA/Tv/iPZ/FOkMHVRBPSlm7t57nuHEZFBMRNOH8ElvfqVlnHGDOAMlvPhh9gHiddiQoASS+fY0MFX0g==" |
| | | }, |
| | | "vue-eslint-parser": { |
| | | "version": "7.6.0", |
| | | "resolved": "https://registry.npm.taobao.org/vue-eslint-parser/download/vue-eslint-parser-7.6.0.tgz?cache=0&sync_timestamp=1614679548045&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue-eslint-parser%2Fdownload%2Fvue-eslint-parser-7.6.0.tgz", |
| | |
| | | "qrcodejs2": "0.0.2", |
| | | "vue": "^2.6.11", |
| | | "vue-clipboard2": "^0.3.1", |
| | | "vue-cropper": "^0.6.5", |
| | | "vue-json-viewer": "^2.2.22", |
| | | "vue-router": "^3.5.1", |
| | | "vuescroll": "^4.17.3", |
| | |
| | | <el-input v-model="form.code" placeholder="请è¾å
¥å工工å·" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="人è¸ç
§ç" prop="faceImgFull" > |
| | | <UploadAvatarImage |
| | | <UploadFaceImg |
| | | :file="{ 'imgurlfull': form.faceImgFull, 'imgurl': form.faceImg }" |
| | | :uploadData="uploadData" |
| | | @uploadSuccess="uploadAvatarSuccess" |
| | |
| | | import BaseOpera from '@/components/base/BaseOpera' |
| | | import GlobalWindow from '@/components/common/GlobalWindow' |
| | | import UploadAvatarImage from '@/components/common/UploadAvatarImage' |
| | | import UploadFaceImg from '@/components/common/UploadFaceImg' |
| | | import {checkMobile, validIdCardNo, validIdCardNoNew} from '@/utils/form' |
| | | export default { |
| | | name: 'OperaCompanyWindow', |
| | | extends: BaseOpera, |
| | | components: { GlobalWindow, UploadAvatarImage }, |
| | | components: { GlobalWindow, UploadAvatarImage,UploadFaceImg }, |
| | | data () { |
| | | return { |
| | | uploadData: { |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div class="iconShot"> |
| | | <div class="icon-dialog"> |
| | | <div class="clip"> |
| | | <div class="img" ref="img"> |
| | | <vue-cropper |
| | | ref="cropper" |
| | | :img="imgSrc" |
| | | :canScale="options.canScale" |
| | | :autoCrop="options.autoCrop" |
| | | :canMove="options.canMove" |
| | | :centerBox="options.centerBox" |
| | | :autoCropWidth="options.autoCropWidth" |
| | | :autoCropHeight="options.autoCropHeight" |
| | | @realTime="realTime" |
| | | ></vue-cropper> |
| | | </div> |
| | | <div class="previews"> |
| | | <img style="width: 100px;height: 100px;border-radius: 50%;object-fit: cover" :src="cutImgSrc" alt="å¾ç"> |
| | | <!-- <el-image--> |
| | | <!-- v-if="cutImgSrc"--> |
| | | <!-- style="width: 100px; height: 100px;vertical-align: middle;border-radius: 50%;"--> |
| | | <!-- :src="cutImgSrc"--> |
| | | <!-- fit="fill"></el-image>--> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import { VueCropper } from 'vue-cropper' |
| | | import {upload} from "@/api/system/common"; |
| | | export default { |
| | | name: 'ImageCropper', |
| | | components: { VueCropper }, |
| | | props: { |
| | | imgSrc: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | // 忾䏿¬¡ä¿åçæªå¾çä½ç½® |
| | | location: { |
| | | type: Object, |
| | | default () { |
| | | return {} |
| | | } |
| | | } |
| | | // iconItem:{ |
| | | // type:Object, |
| | | // default(){ |
| | | // return {}; |
| | | // } |
| | | // } |
| | | }, |
| | | data () { |
| | | return { |
| | | // å¦ä¹ æªå¾é项 |
| | | iconForm: { |
| | | originImgBase64: '', |
| | | imgBase64: '' |
| | | // location: "", |
| | | // matchingName: "", |
| | | // matchingType: "", |
| | | // note: "", |
| | | // picGroupId: "0", |
| | | // tsId: "", |
| | | }, |
| | | // å¨åæªå¾åºåçå¾ç,èªå·±ä¼ |
| | | // imgSrc:'', |
| | | // å¨åæªå¾åççæçbase64å¾ç |
| | | cutImgSrc: '', |
| | | // cropperæä»¶çé
ç½® |
| | | options: { |
| | | canScale: false, |
| | | autoCrop: true, |
| | | canMove: false, |
| | | centerBox: true, |
| | | autoCropWidth: 200, |
| | | autoCropHeight: 200, |
| | | fixed: true, |
| | | fixedNumber: [1, 1] |
| | | }, |
| | | // æªå¾æ¡ç¸å¯¹å¾ççä½ç½® |
| | | clipAxis: {}, |
| | | // æªå¾åæ¾æ å¿,åªè§¦å䏿¬¡å®ç°åæ¾ï¼ |
| | | flag: true |
| | | } |
| | | }, |
| | | mounted () { |
| | | |
| | | }, |
| | | watch: { |
| | | }, |
| | | methods: { |
| | | getImagecropper(){ |
| | | return this.$refs.cropper |
| | | }, |
| | | // å¦ä¹ æªå¾æ¡ååäºä»¶ |
| | | realTime (data) { |
| | | if (data.h) { |
| | | // è·åå¾çç¸å¯¹å®¹å¨çä½ç½® |
| | | const img = this.$refs.cropper.getImgAxis() |
| | | // è·åæªå¾æ¡ç¸å¯¹å®¹å¨çä½ç½® |
| | | const clip = this.$refs.cropper.getCropAxis() |
| | | this.clipAxis.x = clip.x1 - img.x1 |
| | | this.clipAxis.y = clip.y1 - img.y1 |
| | | // è·åæªå¾å¾ç |
| | | this.$refs.cropper.getCropData(img => { |
| | | this.clipAxis.width = data.w |
| | | this.clipAxis.height = data.h |
| | | this.cutImgSrc = img |
| | | }) |
| | | // è·ååå¾base64çå¾ç |
| | | // this.imageUrlToBase64(data.url); |
| | | |
| | | // 徿 å表ç¼è¾åæ¾(åå§ååªè§¦å䏿¬¡) |
| | | if (this.location.height != undefined && this.flag) { |
| | | this.$nextTick(() => { |
| | | // auto crop |
| | | this.$refs.cropper.goAutoCrop() |
| | | this.$nextTick(() => { |
| | | // if cropped and has position message, update crop box |
| | | this.$refs.cropper.cropOffsertX = this.location.x + img.x1 |
| | | this.$refs.cropper.cropOffsertY = this.location.y + img.y1 |
| | | this.$refs.cropper.cropW = this.location.width |
| | | this.$refs.cropper.cropH = this.location.height |
| | | |
| | | // this.iconForm.location=this.iconItem.location; |
| | | // this.iconForm.matchingName=this.iconItem.matchingName; |
| | | // this.iconForm.matchingType=this.iconItem.matchingType; |
| | | // this.iconForm.note=this.iconItem.note; |
| | | // this.picGroupId=this.iconItem.picGroupId.split(','); |
| | | // this.iconForm.id=this.iconItem.id; |
| | | // this.iconForm.tsId=this.iconItem.tsId; |
| | | this.flag = false |
| | | }) |
| | | }) |
| | | } |
| | | } |
| | | }, |
| | | // åå¾éè¿canvas转为base64çæ ¼å¼ |
| | | imageUrlToBase64 (src) { |
| | | // ä¸å®è¦è®¾ç½®ä¸ºletï¼ä¸ç¶å¾ç䏿¾ç¤º |
| | | const image = new Image() |
| | | // è§£å³è·¨åé®é¢ |
| | | image.setAttribute('crossOrigin', 'anonymous') |
| | | const imageUrl = src |
| | | image.src = imageUrl |
| | | |
| | | // image.onloadä¸ºå¼æ¥å è½½ |
| | | image.onload = () => { |
| | | var canvas = document.createElement('canvas') |
| | | canvas.width = image.width |
| | | canvas.height = image.height |
| | | var context = canvas.getContext('2d') |
| | | context.drawImage(image, 0, 0, image.width, image.height) |
| | | |
| | | // var quality = 0.8; |
| | | // è¿éçdataurlå°±æ¯base64ç±»å |
| | | const dataURL = canvas.toDataURL('image/jpeg')// 使ç¨toDataUrlå°å¾çè½¬æ¢æjpegçæ ¼å¼ |
| | | this.iconForm.originImgBase64 = dataURL |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .iconShot { |
| | | .icon-dialog { |
| | | .clip { |
| | | .img { |
| | | height: 400px; |
| | | // display: inline-block; |
| | | |
| | | .vue-cropper { |
| | | background-image: none; |
| | | } |
| | | .cropper-move { |
| | | cursor: default; |
| | | } |
| | | .cropper-face.cropper-move { |
| | | cursor: move; |
| | | } |
| | | |
| | | } |
| | | .previews { |
| | | width: 100%; |
| | | height: 100px; |
| | | position: relative; |
| | | >img { |
| | | position: absolute; |
| | | left: 50%; |
| | | transform: translateX(-50%); |
| | | max-height: 100%; |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | .icon-options { |
| | | font-size: 12px; |
| | | font-weight: 200; |
| | | >.el-row { |
| | | >.el-col { |
| | | >.el-row { |
| | | height: 36px; |
| | | line-height: 36px; |
| | | >.el-col:nth-child(1) { |
| | | font-weight: 600; |
| | | text-align: right; |
| | | } |
| | | .el-col:nth-child(2) { |
| | | .el-input,.el-select { |
| | | width: 185px !important; |
| | | } |
| | | } |
| | | >.el-col { |
| | | padding: 0 10px; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </style> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div> |
| | | <el-upload |
| | | class="avatar-uploader" |
| | | accept=".png,.jpg,.jpeg" |
| | | :style="customStyle" |
| | | action="" |
| | | :auto-upload="false" |
| | | :show-file-list="false" |
| | | :on-change='openUpdateIcon'> |
| | | <img v-if=" file.imgurlfull" style="width: 100%;" :src="file.imgurlfull" :style="customStyle" class="avatar"> |
| | | <div v-else :style="customStyle"> |
| | | <i class="el-icon-plus avatar-uploader-icon"></i> |
| | | <div class="tips-style">{{ tipsLabel }}</div> |
| | | </div> |
| | | </el-upload> |
| | | <el-dialog |
| | | append-to-body |
| | | :close-on-click-modal="false" |
| | | title="ä¸ä¼ å¾ç" |
| | | :visible.sync="updateImg" |
| | | width="800px" |
| | | class="icon-dialog-wrapper dialong-com-style"> |
| | | <ImageCropper ref="iconShot" v-if="updateImg" :imgSrc="img" > |
| | | </ImageCropper> |
| | | <span slot="footer" class="dialog-footer"> |
| | | <el-button @click="updateImg = false">å æ¶</el-button> |
| | | <el-button type="primary" @click="uploadIcon">ç¡® å®</el-button> |
| | | </span> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import ImageCropper from '@/components/common/ImageCropper' |
| | | import { upload } from '@/api/system/common' |
| | | export default { |
| | | components: { ImageCropper }, |
| | | props: { |
| | | file: { |
| | | type: Object, |
| | | default: () => {} |
| | | }, |
| | | tipsLabel: '', |
| | | customStyle: { |
| | | type: String, |
| | | default: 'width: 90px; height: 90px;' |
| | | }, |
| | | uploadData: Object |
| | | }, |
| | | data () { |
| | | return { |
| | | fileInfo:{}, |
| | | img: null, |
| | | updateImg: false, |
| | | imageSrc: null, |
| | | uploadImgUrl: process.env.VUE_APP_API_PREFIX + '/visitsAdmin/cloudService/public/upload' |
| | | } |
| | | }, |
| | | |
| | | methods: { |
| | | uploadIcon () { |
| | | // è·åè£åªåçå¾ç |
| | | this.$refs.iconShot.getImagecropper().getCropBlob((fileData) => { // è·åå½åè£åªå¥½çæ°æ® |
| | | // æ³¨æ¤æ¶çdataæ¯ä¸ä¸ªBlobæ°æ®ï¼é¨åæ¥å£æ¥æ¶çæ¯File转åçFormDataæ°æ® |
| | | console.log(fileData) |
| | | const formData = new FormData() |
| | | |
| | | formData.append('folder', 'member') |
| | | formData.append( |
| | | 'file', |
| | | new File( |
| | | [fileData], // å°Blobç±»å转åæFileç±»å |
| | | this.fileInfo.name, // 设置Fileç±»åçæä»¶åç§° |
| | | { type: this.fileInfo.type } // 设置Fileç±»åçæä»¶ç±»å |
| | | ) |
| | | ) |
| | | upload(formData).then(res => { |
| | | console.log(res) |
| | | this.file.imgurl = res.imgaddr |
| | | this.file.imgurlfull = res.url |
| | | this.$message.success('ä¸ä¼ æå') |
| | | this.imageSrc = res.url |
| | | this.updateImg = false |
| | | this.$emit('uploadSuccess', { imgurl: res.imgaddr, imgurlfull: res.url, name: res.originname }) |
| | | this.$emit('uploadEnd') |
| | | }) |
| | | }) |
| | | }, |
| | | |
| | | // ä¸ä¼ å¾ç |
| | | openUpdateIcon (file, fileList) { |
| | | const isJPG = file.raw.type === 'image/jpeg' || file.raw.type === 'image/png' |
| | | const isLt2M = file.size / 1024 / 1024 < 2 |
| | | if (!isJPG) { |
| | | this.$message.error('ä¸ä¼ 头åå¾çåªè½æ¯ JPG/PNG æ ¼å¼!') |
| | | return false |
| | | } |
| | | if (!isLt2M) { |
| | | this.$message.error('ä¸ä¼ 头åå¾ç大å°ä¸è½è¶
è¿ 2MB!') |
| | | return false |
| | | } |
| | | // ä¸ä¼ æååå°å¾çå°åèµå¼ç»è£åªæ¡æ¾ç¤ºå¾ç |
| | | this.$nextTick(async () => { |
| | | // base64æ¹å¼ |
| | | // this.option.img = await fileByBase64(file.raw) |
| | | this.fileInfo.name = file.name |
| | | this.fileInfo.type = file.type |
| | | console.log(file, fileList) |
| | | this.img = URL.createObjectURL(file.raw) |
| | | // this.loading = false |
| | | this.updateImg = true |
| | | }) |
| | | }, |
| | | handleAvatarSuccess (res, file) { |
| | | if (res.code == 200) { |
| | | const { data } = res |
| | | this.file.imgurl = data.imgaddr |
| | | this.file.imgurlfull = data.url |
| | | this.$message.success('ä¸ä¼ æå') |
| | | this.imageSrc = data.url |
| | | this.updateImg = true |
| | | // this.$emit('uploadSuccess', { imgurl: data.imgaddr, imgurlfull: data.url, name: data.originname }) |
| | | } else { |
| | | this.$message.error('ä¸ä¼ 失败') |
| | | } |
| | | this.$emit('uploadEnd') |
| | | }, |
| | | uploadError () { |
| | | this.$message.error('ä¸ä¼ 失败') |
| | | this.$emit('uploadEnd') |
| | | }, |
| | | // // æ¦æª |
| | | beforeAvatarUpload (file) { |
| | | this.$emit('uploadBegin') |
| | | return true |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | $image-width: 90px; |
| | | .avatar-uploader { |
| | | width: $image-width; |
| | | height: $image-width; |
| | | } |
| | | ::v-deep .el-upload { |
| | | border: 1px dashed #d9d9d9; |
| | | border-radius: 6px; |
| | | cursor: pointer; |
| | | position: relative; |
| | | overflow: hidden; |
| | | } |
| | | .avatar-uploader .el-upload:hover { |
| | | border-color: #409EFF; |
| | | } |
| | | .avatar-uploader-icon { |
| | | line-height: 90px; |
| | | font-size: 28px; |
| | | color: #8c939d; |
| | | width: $image-width; |
| | | height: $image-width; |
| | | text-align: center; |
| | | } |
| | | .avatar { |
| | | width: 100% !important; |
| | | height: auto !important; |
| | | display: block; |
| | | } |
| | | .tips-style { |
| | | height: 13px; |
| | | font-size: 13px; |
| | | font-weight: 400; |
| | | color: #999999; |
| | | line-height: 13px; |
| | | } |
| | | </style> |
| | | <style lang="scss" scoped> |
| | | ::v-deep .el-upload--picture-card{ |
| | | width: 90px !important; |
| | | height: 90px !important; |
| | | } |
| | | ::v-deep .el-upload-list__item { |
| | | width: 90px !important; |
| | | height: 90px !important; |
| | | } |
| | | .icon { |
| | | -webkit-transform: translate(-50%,-50%); |
| | | -ms-transform: translate(-50%,-50%); |
| | | transform: translate(0%, -85%); |
| | | } |
| | | ::v-deep .el-upload-list__item { |
| | | width: 90px !important; |
| | | height: 90px !important; |
| | | } |
| | | </style> |
| | |
| | | methods: { |
| | | changeRadio (e) { |
| | | if (e === '0') { |
| | | this.searchForm.startTime = timeForMat(0)[0] |
| | | this.searchForm.endTime = timeForMat(0)[1] |
| | | this.searchForm.startDate = timeForMat(0)[0] |
| | | this.searchForm.endDate = timeForMat(0)[1] |
| | | this.time = timeForMat(0) |
| | | } else if (e === '1') { |
| | | this.searchForm.startTime = timeForMat(6)[0] |
| | | this.searchForm.endTime = timeForMat(6)[1] |
| | | this.searchForm.startDate = timeForMat(6)[0] |
| | | this.searchForm.endDate = timeForMat(6)[1] |
| | | this.time = timeForMat(6) |
| | | } else if (e === '2') { |
| | | this.searchForm.startTime = timeForMat(29)[0] |
| | | this.searchForm.endTime = timeForMat(29)[1] |
| | | this.searchForm.startDate = timeForMat(29)[0] |
| | | this.searchForm.endDate = timeForMat(29)[1] |
| | | this.time = timeForMat(29) |
| | | } |
| | | this.search() |
| | |
| | | methods: { |
| | | changeRadio (e) { |
| | | if (e === '0') { |
| | | this.searchForm.startTime = timeForMat(0)[0] |
| | | this.searchForm.endTime = timeForMat(0)[1] |
| | | this.searchForm.startDate = timeForMat(0)[0] |
| | | this.searchForm.endDate = timeForMat(0)[1] |
| | | this.time = timeForMat(0) |
| | | } else if (e === '1') { |
| | | this.searchForm.startTime = timeForMat(6)[0] |
| | | this.searchForm.endTime = timeForMat(6)[1] |
| | | this.searchForm.startDate = timeForMat(6)[0] |
| | | this.searchForm.endDate = timeForMat(6)[1] |
| | | this.time = timeForMat(6) |
| | | } else if (e === '2') { |
| | | this.searchForm.startTime = timeForMat(29)[0] |
| | | this.searchForm.endTime = timeForMat(29)[1] |
| | | this.searchForm.startDate = timeForMat(29)[0] |
| | | this.searchForm.endDate = timeForMat(29)[1] |
| | | this.time = timeForMat(29) |
| | | } |
| | | this.search() |