yujialong 2 years ago
parent 0d452dcd3e
commit 0440ca2be2
  1. 6
      src/components/img-upload/Cropper.vue
  2. 127
      src/components/modules/content.vue
  3. 27
      src/const/modules.js
  4. 2
      src/pages/article/list/index.vue
  5. 10
      src/pages/column/page/application.vue
  6. 1
      src/pages/column/page/edu.vue
  7. 8
      src/pages/column/page/research.vue

@ -17,7 +17,7 @@
:auto-crop-width="option.autoCropWidth" :auto-crop-width="option.autoCropWidth"
:auto-crop-height="option.autoCropHeight" :auto-crop-height="option.autoCropHeight"
:fixed-box="option.fixedBox" :fixed-box="option.fixedBox"
:fixed="option.fixed" :fixed="fixed"
:fixed-number="fixedNumber" :fixed-number="fixedNumber"
@realTime="realTime" /> @realTime="realTime" />
<!-- <vueCropper ref="cropper" :img="option.img" :outputSize="option.size" :outputType="option.outputType"></vueCropper> --> <!-- <vueCropper ref="cropper" :img="option.img" :outputSize="option.size" :outputType="option.outputType"></vueCropper> -->
@ -80,6 +80,10 @@ export default {
fixedNumber: { fixedNumber: {
type: Array, type: Array,
default: [1, 0.26] default: [1, 0.26]
},
fixed: {
type: Boolean,
default: true
} }
}, },
data() { data() {

@ -9,10 +9,11 @@
<el-upload <el-upload
v-if="item.type === 'upload'" v-if="item.type === 'upload'"
class="uploader" class="uploader"
accept=".jpg,.png,.jpeg" accept=".jpg,.png,.jpeg,.gif"
:on-success="res => uploadSuccess(res, data.form)" :on-change="res => changeFile(res, data.form)"
:show-file-list="false" :show-file-list="false"
:action="api.upload"> :action="api.upload"
:auto-upload="false">
<img v-if="data.form[item.prop]" :src="data.form[item.prop]" class="avatar"> <img v-if="data.form[item.prop]" :src="data.form[item.prop]" class="avatar">
<div class="uploader-default" v-else> <div class="uploader-default" v-else>
<i class="el-icon-plus"></i> <i class="el-icon-plus"></i>
@ -39,17 +40,32 @@
<el-button type="primary" @click="contentSubmit">确定</el-button> <el-button type="primary" @click="contentSubmit">确定</el-button>
</span> </span>
</el-dialog> </el-dialog>
<Link ref="link" :visible.sync="linkVisible" :data.sync="linkForm" @linkSubmit="linkSubmit" /> <Link ref="link" :visible.sync="linkVisible" :data.sync="linkForm" @linkSubmit="linkSubmit" />
<!-- 剪裁组件弹窗 -->
<el-dialog title="图片裁剪" append-to-body :visible.sync="cropperModel" width="1100px" :close-on-click-modal="false">
<Cropper
ref="cropper"
:img-file.sync="file"
:is-upload="isUpload"
:fixed="fixed"
:fixedNumber.sync="fixedNumber"
@upload="customUpload" />
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import Link from '@/components/modules/link' import Link from '@/components/modules/link'
import Util from '@/libs/util' import Util from '@/libs/util'
import Cropper from '@/components/img-upload/Cropper'
import Axios from 'axios'
export default { export default {
props: ['data', 'visible'], props: ['data', 'visible'],
components: { components: {
Link Link,
Cropper
}, },
data() { data() {
return { return {
@ -57,6 +73,13 @@ export default {
linkVisible: false, linkVisible: false,
linkForm: {}, linkForm: {},
curIndex: 0, curIndex: 0,
cropperModel: false,
isUpload: false,
file: {}, //
fileId: '',
curForm: {},
fixed: false,
fixedNumber: [0.88, 1]
}; };
}, },
watch: { watch: {
@ -75,6 +98,14 @@ export default {
// //
if (type === 'form' || type === 'introduce') { if (type === 'form' || type === 'introduce') {
forms.map(e => { forms.map(e => {
if (e.type === 'upload') {
if (e.fixedNumber) {
this.fixed = true
this.fixedNumber = e.fixedNumber
} else {
this.fixed = false
}
}
if (e.required) { if (e.required) {
this.rules[e.prop] = [ this.rules[e.prop] = [
{ {
@ -90,12 +121,88 @@ export default {
close() { close() {
this.$emit('update:visible', false) this.$emit('update:visible', false)
}, },
// //
uploadSuccess(res, row) { customUpload(data) {
// let url = this.form.columnBanner const blob = this.dataURItoBlob(data)
// url && this.$del(this.api.delFile, [url.split('/').pop()]).then(res => {}).catch(e => {}) const formData = new FormData()
this.$set(row, 'pic', res.url) formData.append('file', blob, this.file.name)
// row.pic = res.url this.imgUpload(formData)
},
//
compress(img) {
const canvas = document.createElement('canvas')
const ctx = canvas.getContext('2d')
// let initSize = img.src.length;
const width = img.width
const height = img.height
canvas.width = width
canvas.height = height
//
ctx.fillStyle = '#fff'
ctx.fillRect(0, 0, canvas.width, canvas.height)
ctx.drawImage(img, 0, 0, width, height)
//
const ndata = canvas.toDataURL('image/jpeg', 0.8)
return ndata
},
// base64bolb
dataURItoBlob(base64Data) {
let byteString
if (base64Data.split(',')[0].indexOf('base64') >= 0) {
byteString = atob(base64Data.split(',')[1])
} else {
byteString = unescape(base64Data.split(',')[1])
}
const mimeString = base64Data
.split(',')[0]
.split(':')[1]
.split(';')[0]
const ia = new Uint8Array(byteString.length)
for (let i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i)
}
return new Blob([ia], {
type: mimeString
})
},
//
imgUpload(formData) {
this.isUpload = true
Axios({
method: 'post',
url: this.api.upload,
data: formData,
headers: {
'Content-Type': 'multipart/form-data'
},
}).then(({ data }) => {
this.$set(this.curForm, 'pic', data.url)
}).catch(res => {})
this.$refs.cropper.isDisabled = false
this.isUpload = false
this.cropperModel = false
},
//
changeFile(file, form) {
const { size, name } = file
const ext = name.substring(name.lastIndexOf('.') + 1)
if (!Util.isImg(ext)) {
this.$message.error('请上传图片!')
return false
}
if (size / 1024 / 1024 > 5) {
this.$message.error('请上传5M以内的图片!')
return false
}
this.file = file
this.curForm = form
this.cropperModel = true
this.$nextTick(() => {
this.$refs.cropper.updateImg({
url: window.URL.createObjectURL(file.raw),
size: file.size
})
})
}, },
// //
toLink(row, i = 0) { toLink(row, i = 0) {

@ -1426,7 +1426,8 @@ export default {
type: 'upload', type: 'upload',
prop: 'pic', prop: 'pic',
label: '图片', label: '图片',
required: true required: true,
fixedNumber: [0.88, 1]
}, },
{ {
type: 'input', type: 'input',
@ -2788,7 +2789,7 @@ export default {
list: [ list: [
{ {
pic: 'http://192.168.31.136/images/research/3.png', pic: 'http://192.168.31.136/images/research/3.png',
title: 'Accelerator', title: 'Accelerator Cryogenic System',
link: { link: {
linkName: '无', linkName: '无',
connectionType: 1, connectionType: 1,
@ -2803,7 +2804,7 @@ export default {
}, },
{ {
pic: 'http://192.168.31.136/images/research/4.png', pic: 'http://192.168.31.136/images/research/4.png',
title: 'Physics', title: 'Accelerator Laser Science ',
link: { link: {
linkName: '无', linkName: '无',
connectionType: 1, connectionType: 1,
@ -2818,7 +2819,7 @@ export default {
}, },
{ {
pic: 'http://192.168.31.136/images/research/5.png', pic: 'http://192.168.31.136/images/research/5.png',
title: 'Mechanical Engineering', title: 'Quantum Materials',
link: { link: {
linkName: '无', linkName: '无',
connectionType: 1, connectionType: 1,
@ -2833,7 +2834,7 @@ export default {
}, },
{ {
pic: 'http://192.168.31.136/images/research/6.png', pic: 'http://192.168.31.136/images/research/6.png',
title: 'Digital Light-source', title: 'Surface Science and Catalysis',
link: { link: {
linkName: '无', linkName: '无',
connectionType: 1, connectionType: 1,
@ -2848,7 +2849,7 @@ export default {
}, },
{ {
pic: 'http://192.168.31.136/images/research/7.png', pic: 'http://192.168.31.136/images/research/7.png',
title: 'Beam Lines', title: 'Atomic and Molecular Science',
link: { link: {
linkName: '无', linkName: '无',
connectionType: 1, connectionType: 1,
@ -2863,7 +2864,7 @@ export default {
}, },
{ {
pic: 'http://192.168.31.136/images/research/8.png', pic: 'http://192.168.31.136/images/research/8.png',
title: 'End Stations', title: 'Atmospheric and Interstellar Science',
link: { link: {
linkName: '无', linkName: '无',
connectionType: 1, connectionType: 1,
@ -3358,7 +3359,7 @@ export default {
list: [ list: [
{ {
pic: 'http://192.168.31.136/images/application/3.png', pic: 'http://192.168.31.136/images/application/3.png',
title: 'Accelerator', title: 'Biomedicine',
link: { link: {
linkName: '无', linkName: '无',
connectionType: 1, connectionType: 1,
@ -3373,7 +3374,7 @@ export default {
}, },
{ {
pic: 'http://192.168.31.136/images/application/4.png', pic: 'http://192.168.31.136/images/application/4.png',
title: 'Physics', title: 'Advanced Materials ',
link: { link: {
linkName: '无', linkName: '无',
connectionType: 1, connectionType: 1,
@ -3388,7 +3389,7 @@ export default {
}, },
{ {
pic: 'http://192.168.31.136/images/application/5.png', pic: 'http://192.168.31.136/images/application/5.png',
title: 'Mechanical Engineering', title: 'Advanced Manufacturing',
link: { link: {
linkName: '无', linkName: '无',
connectionType: 1, connectionType: 1,
@ -3403,7 +3404,7 @@ export default {
}, },
{ {
pic: 'http://192.168.31.136/images/application/6.png', pic: 'http://192.168.31.136/images/application/6.png',
title: 'Digital Light-source', title: 'High-throughput Measurements ',
link: { link: {
linkName: '无', linkName: '无',
connectionType: 1, connectionType: 1,
@ -3418,7 +3419,7 @@ export default {
}, },
{ {
pic: 'http://192.168.31.136/images/application/7.png', pic: 'http://192.168.31.136/images/application/7.png',
title: 'Beam Lines', title: 'Marine Titanium Alloy',
link: { link: {
linkName: '无', linkName: '无',
connectionType: 1, connectionType: 1,
@ -3433,7 +3434,7 @@ export default {
}, },
{ {
pic: 'http://192.168.31.136/images/application/8.png', pic: 'http://192.168.31.136/images/application/8.png',
title: 'End Stations', title: 'Lead Bismuth Reactor',
link: { link: {
linkName: '无', linkName: '无',
connectionType: 1, connectionType: 1,

@ -2,7 +2,7 @@
<div class="flex page"> <div class="flex page">
<div style="width: 218px;border-right: 1px solid #EBEDF0"> <div style="width: 218px;border-right: 1px solid #EBEDF0">
<p class="page-name mb">全部栏目</p> <p class="page-name mb">全部栏目</p>
<div style="height: 504px;overflow: auto"> <div style="height: calc(100% - 50px);overflow: auto">
<el-tree ref="column" :data="columns" highlight-current :expand-on-click-node="false" default-expand-all :props="defaultProps" node-key="id" @node-click="initData"></el-tree> <el-tree ref="column" :data="columns" highlight-current :expand-on-click-node="false" default-expand-all :props="defaultProps" node-key="id" @node-click="initData"></el-tree>
</div> </div>
</div> </div>

@ -243,13 +243,17 @@ export default {
height: 353px; height: 353px;
} }
.text { .text {
display: flex;
justify-content: center;
align-items: center;
height: 143px;
font-size: 30px; font-size: 30px;
font-family: SFProDisplay-Bold, SFProDisplay; font-family: SFProDisplay-Bold, SFProDisplay;
font-weight: bold; font-weight: bold;
line-height: 143px; line-height: 40px;
color: #272727;
text-align: center; text-align: center;
background-color: #fff; color: #272727;
background-color: #F5F5F5;
} }
} }
.news-block { .news-block {

@ -96,6 +96,7 @@ export default {
text-align: right; text-align: right;
.texts { .texts {
left: 0; left: 0;
text-align: left;
} }
} }
} }

@ -174,12 +174,16 @@ export default {
height: 353px; height: 353px;
} }
.text { .text {
display: flex;
justify-content: center;
align-items: center;
height: 143px;
font-size: 30px; font-size: 30px;
font-family: SFProDisplay-Bold, SFProDisplay; font-family: SFProDisplay-Bold, SFProDisplay;
font-weight: bold; font-weight: bold;
line-height: 143px; line-height: 40px;
color: #272727;
text-align: center; text-align: center;
color: #272727;
background-color: #F5F5F5; background-color: #F5F5F5;
} }
} }

Loading…
Cancel
Save