123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379 |
- <template>
- <div class="patent-image">
- <div class="block">
- <div class="demonstration">图片大小:</div>
- <el-slider v-model="value" @change="changeWidth" :min="25" :max="100" style="padding-left:90px"></el-slider>
- </div>
- <div class="imageCard" v-if="patent.image">
- <template v-if="patent.image.abstImgs && patent.image.abstImgs.length">
- <el-card class="preview" v-for="(item, index) in patent.image.abstImgs" :key="'abs'+index" shadow="hover" :style="{ width: width }" >
- <div class="text-align_center image_contain">
- <div class="image_name">摘要附图</div>
- <!-- <el-image fit="contain" :src="outside ? item : item.path" :preview-src-list="srcList"
- style="width:250px;height:250px;"></el-image> -->
- <patentImage fit="contain" lazy :patent="item" :preview-src-list="[item.patentAbsImage]"></patentImage>
- </div>
- </el-card>
- </template>
- <template v-if="patent.image.figures && patent.image.figures.length">
- <el-card class="preview" v-for="(item, index) in patent.image.figures" :key="'figures'+index" shadow="hover" :style="{ width: width }">
- <div class="text-align_center image_contain">
- <div class="image_name" v-if="item.name">{{ item.name }}</div>
- <el-image fit="contain" :src="outside ? item : item.path" :preview-src-list="srcList"
- style="width:250px;height:250px;"></el-image>
- </div>
- </el-card>
- </template>
- <template v-if="patent.image.fulltextImgs && patent.image.fulltextImgs.length">
- <el-card class="preview" v-for="(item, index) in patent.image.fulltextImgs" :key="'fulltextImgs'+index" shadow="hover" :style="{ width: width }">
- <div class="text-align_center image_contain">
- <div class="image_name" v-if="item.name">{{ item.name }}</div>
- <el-image fit="contain" :src="outside ? item : item.path" :preview-src-list="srcList"
- style="width:250px;height:250px;"></el-image>
- </div>
- </el-card>
- </template>
- <!-- <el-card class="preview" v-for="(item, index) in patent.image" :key="index" shadow="hover" :style="{ width: width }">
- <div slot="header" class="card-header" v-if="projectId">
- <span></span>
- <el-button class="delete" type="text" @click="handleDelete(item)">删除</el-button>
- <el-button class="edit" type="text" @click="handleEdit(item)">编辑</el-button>
- </div>
- <div class="text-align_center">
- <el-image fit="contain" :src="outside ? item : $commonJS.checkViewer(item)" :preview-src-list="srcList"
- style="width:250px;height:250px;"></el-image>
- </div>
- </el-card> -->
- </div>
- <!-- <div type="primary" class="up" @click="handleAdd">上传图片</div> -->
- <el-dialog :title="title" :visible.sync="visible" width="500px" append-to-body destroy-on-close :before-close="close"
- top="22vh">
- <el-form :model="form">
- <el-form-item label="是否设置为摘要附图">
- <el-radio-group v-model="form.status">
- <el-radio :label="1">是</el-radio>
- <el-radio :label="0">否</el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item label="上传图片">
- <el-upload class="upload-file" drag action="#" :auto-upload="false" :show-file-list="false"
- :on-change="onChange">
- <i :class="!file ? 'el-icon-upload' : 'el-icon-refresh'"></i>
- <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
- <div class="el-upload__tip" slot="tip"></div>
- </el-upload>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="close">取 消</el-button>
- <el-button type="primary" @click="submit" :loading="btnLoading">确 定</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import { patentDetails } from './mixins';
- export default {
- mixins: [patentDetails],
- data() {
- return {
- value: 25,
- width: "25%",
- srcList: [],
- url: '',
- title: '',
- visible: false,
- form: {},
- file: null,
- btnLoading: false
- }
- },
- watch: {
- patentNo() {
- if (this.outside) {
- this.getData()
- }else {
- this.refreshData()
- }
- }
- },
- mounted() {
- // outside为true是外部
- if (this.outside) {//外部
- this.getData()
- } else {
- this.refreshData()
- }
- },
- methods: {
- // 获得外部的附图
- getData() {
- if(this.patent.image){
- return false
- }
- var params = {
- appNo: this.patent.rowApplicationNo,
- }
- this.loading = true
- this.$api.getExternalFigure(params).then(response => {
- if (response.code == 200) {
- if (response.data.length>0) {
-
- var image = {
- figures:[]
- }
- response.data.forEach(pic=>{
- image.figures.push(
- {
- path:pic,
- rowApplicationNo:this.patent.rowApplicationNo
- }
- )
- })
- this.$set(this.patent, 'image', image)
- this.$set(this, 'srcList', response.data)
- } else {
- this.$set(this.patent, 'image', null)
- this.$set(this, 'srcList', [])
- }
- this.loading = false
- }
- }).catch(error=>{
- this.loading = false
- })
- },
- // 获取内部的附图
- refreshData() {
- if(this.patent.image && this.patent.image.length>0){
- return false
- }
- var params = {
- patentNo:this.patent.patentNo
- }
- this.loading = true
- this.$api.getPatentFigures(params).then(response => {
- if (response.code == 200) {
- if (response.data&& Object.keys(response.data).length>0) {
- this.$set(this.patent, 'image', response.data)
- let srcList = []
- Object.keys(response.data).forEach(item=>{
- if(response.data[item] && response.data[item].length){
- response.data[item].forEach(pic=>{
- pic.rowApplicationNo = this.patent.rowApplicationNo
- srcList.push(pic.path)
- })
- }
- })
- // let srcList=response.data.map(item=>{
- // return this.$commonJS.checkViewer(item)
- // })
- this.$set(this, 'srcList', srcList)
- } else {
- this.$set(this.patent, 'image', null)
- this.$set(this, 'srcList', [])
- }
- this.loading = false
- }
- }).catch(error=>{
- this.loading = false
- })
- return
- var params = {
- appNo: this.patent.appNo,
- }
- this.loading = true
- this.$api.getFigure(params).then(response => {
- if (response.code == 200) {
- if (response.data.length>0) {
- this.$set(this.patent, 'image', response.data)
- let srcList=response.data.map(item=>{
- return this.$commonJS.checkViewer(item)
- })
- this.$set(this, 'srcList', srcList)
- } else {
- this.$set(this.patent, 'image', [])
- this.$set(this, 'srcList', [])
- }
- this.loading = false
- }
- }).catch(error=>{
- this.loading = false
- })
- },
- changeWidth() {
- this.width = this.value + '%'
- },
- close() {
- this.visible = false
- },
- onChange(file, fileList) {
- this.file = file.raw
- },
- handleAdd() {
- this.visible = true
- this.title = '新增附图'
- this.form = {
- patentId: this.patent.id,
- status: 0,
- url: ''
- }
- },
- handleEdit(row) {
- this.visible = true
- this.title = '编辑附图'
- this.form = { ...row }
- },
- handleDelete(row) {
- this.$confirm('确认删除本条数据吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- this.$api.deletePatentImage({ id: row.id }).then(response => {
- this.$message.success('删除成功')
- this.refreshPatent()
- }).catch(error => {
- })
- })
- },
- refreshPatent() {
- this.$emit('refresh')
- },
- submit() {
- let formData = new FormData()
- formData.append('patentId', this.form.patentId)
- formData.append('status', this.form.status)
- formData.append('url', this.form.url)
- if (this.file) {
- formData.append('file', this.file)
- }
- if (this.form.id) {
- this.btnLoading = true
- formData.append('id', this.form.id)
- this.$api.editPatentImage(formData).then(response => {
- this.btnLoading = false
- this.$message.success('操作成功')
- this.visible = false
- this.file = null
- this.refreshPatent()
- }).catch(error => {
- this.btnLoading = false
- })
- } else {
- if (!this.file) {
- this.$message.error('请选择文件')
- return false
- }
- this.btnLoading = true
- this.$api.uploadPatentImage(formData).then(response => {
- this.btnLoading = false
- this.$message.success('操作成功')
- this.visible = false
- this.file = null
- this.refreshPatent()
- }).catch(error => {
- this.btnLoading = false
- })
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .image_contain{
- position: relative;
- width: 100%;
- height: 100%;
- .image_name{
- position: absolute;
- font-weight: bold;
- top: -25px;
- left: 0px;
- z-index: 999;
- }
- }
- </style>
- <style lang="scss">
- .up {
- width: 70px;
- height: 30px;
- line-height: 30px;
- color: rgb(65, 65, 224);
- cursor: pointer;
- position: absolute;
- right: 20px;
- top: 0px;
- }
- .up:hover {
- border-bottom: 1px solid rgb(45, 45, 235);
- }
- .block {
- width: 60%;
- margin: 0 auto;
- }
- .imageCard {
- display: flex;
- flex-direction: row;
- flex-wrap: wrap;
- justify-content: center;
- }
- .demonstration {
- float: left;
- line-height: 38px;
- text-align: center;
- }
- .patent-image {
- position: relative;
- .delete {
- float: right;
- padding: 3px 0;
- color: red;
- padding-left: 10px;
- }
- .edit {
- float: right;
- padding: 3px 0;
- }
- .add {
- font-size: 80px;
- color: #6b6868;
- margin-top: 60px;
- }
- .preview {
- // height: 300px;
- margin-right: 20px;
- margin-bottom: 20px;
- cursor: pointer;
- text-align: center;
- .card-header {
- height: 20px;
- }
- .el-card__header {
- border-bottom: 1px solid #EBEEF5;
- font-weight: normal;
- }
- .el-card__body{
- height: 100%;
- width: 100%;
- padding: 30px 20px;
- }
- }
- .el-image {
- width: 100%;
- }
- }</style>
|