PatentImage.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. <template>
  2. <div class="patent-image">
  3. <div class="block">
  4. <div class="demonstration">图片大小:</div>
  5. <el-slider v-model="value" @change="changeWidth" :min="25" :max="100" style="padding-left:90px"></el-slider>
  6. </div>
  7. <div class="imageCard" v-if="patent.image">
  8. <template v-if="patent.image.abstImgs && patent.image.abstImgs.length">
  9. <el-card class="preview" v-for="(item, index) in patent.image.abstImgs" :key="'abs'+index" shadow="hover" :style="{ width: width }" >
  10. <div class="text-align_center image_contain">
  11. <div class="image_name">摘要附图</div>
  12. <!-- <el-image fit="contain" :src="outside ? item : item.path" :preview-src-list="srcList"
  13. style="width:250px;height:250px;"></el-image> -->
  14. <patentImage fit="contain" lazy :patent="item" :preview-src-list="[item.patentAbsImage]"></patentImage>
  15. </div>
  16. </el-card>
  17. </template>
  18. <template v-if="patent.image.figures && patent.image.figures.length">
  19. <el-card class="preview" v-for="(item, index) in patent.image.figures" :key="'figures'+index" shadow="hover" :style="{ width: width }">
  20. <div class="text-align_center image_contain">
  21. <div class="image_name" v-if="item.name">{{ item.name }}</div>
  22. <el-image fit="contain" :src="outside ? item : item.path" :preview-src-list="srcList"
  23. style="width:250px;height:250px;"></el-image>
  24. </div>
  25. </el-card>
  26. </template>
  27. <template v-if="patent.image.fulltextImgs && patent.image.fulltextImgs.length">
  28. <el-card class="preview" v-for="(item, index) in patent.image.fulltextImgs" :key="'fulltextImgs'+index" shadow="hover" :style="{ width: width }">
  29. <div class="text-align_center image_contain">
  30. <div class="image_name" v-if="item.name">{{ item.name }}</div>
  31. <el-image fit="contain" :src="outside ? item : item.path" :preview-src-list="srcList"
  32. style="width:250px;height:250px;"></el-image>
  33. </div>
  34. </el-card>
  35. </template>
  36. <!-- <el-card class="preview" v-for="(item, index) in patent.image" :key="index" shadow="hover" :style="{ width: width }">
  37. <div slot="header" class="card-header" v-if="projectId">
  38. <span></span>
  39. <el-button class="delete" type="text" @click="handleDelete(item)">删除</el-button>
  40. <el-button class="edit" type="text" @click="handleEdit(item)">编辑</el-button>
  41. </div>
  42. <div class="text-align_center">
  43. <el-image fit="contain" :src="outside ? item : $commonJS.checkViewer(item)" :preview-src-list="srcList"
  44. style="width:250px;height:250px;"></el-image>
  45. </div>
  46. </el-card> -->
  47. </div>
  48. <!-- <div type="primary" class="up" @click="handleAdd">上传图片</div> -->
  49. <el-dialog :title="title" :visible.sync="visible" width="500px" append-to-body destroy-on-close :before-close="close"
  50. top="22vh">
  51. <el-form :model="form">
  52. <el-form-item label="是否设置为摘要附图">
  53. <el-radio-group v-model="form.status">
  54. <el-radio :label="1">是</el-radio>
  55. <el-radio :label="0">否</el-radio>
  56. </el-radio-group>
  57. </el-form-item>
  58. <el-form-item label="上传图片">
  59. <el-upload class="upload-file" drag action="#" :auto-upload="false" :show-file-list="false"
  60. :on-change="onChange">
  61. <i :class="!file ? 'el-icon-upload' : 'el-icon-refresh'"></i>
  62. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  63. <div class="el-upload__tip" slot="tip"></div>
  64. </el-upload>
  65. </el-form-item>
  66. </el-form>
  67. <div slot="footer" class="dialog-footer">
  68. <el-button @click="close">取 消</el-button>
  69. <el-button type="primary" @click="submit" :loading="btnLoading">确 定</el-button>
  70. </div>
  71. </el-dialog>
  72. </div>
  73. </template>
  74. <script>
  75. import { patentDetails } from './mixins';
  76. export default {
  77. mixins: [patentDetails],
  78. data() {
  79. return {
  80. value: 25,
  81. width: "25%",
  82. srcList: [],
  83. url: '',
  84. title: '',
  85. visible: false,
  86. form: {},
  87. file: null,
  88. btnLoading: false
  89. }
  90. },
  91. watch: {
  92. patentNo() {
  93. if (this.outside) {
  94. this.getData()
  95. }else {
  96. this.refreshData()
  97. }
  98. }
  99. },
  100. mounted() {
  101. // outside为true是外部
  102. if (this.outside) {//外部
  103. this.getData()
  104. } else {
  105. this.refreshData()
  106. }
  107. },
  108. methods: {
  109. // 获得外部的附图
  110. getData() {
  111. if(this.patent.image){
  112. return false
  113. }
  114. var params = {
  115. appNo: this.patent.rowApplicationNo,
  116. }
  117. this.loading = true
  118. this.$api.getExternalFigure(params).then(response => {
  119. if (response.code == 200) {
  120. if (response.data.length>0) {
  121. var image = {
  122. figures:[]
  123. }
  124. response.data.forEach(pic=>{
  125. image.figures.push(
  126. {
  127. path:pic,
  128. rowApplicationNo:this.patent.rowApplicationNo
  129. }
  130. )
  131. })
  132. this.$set(this.patent, 'image', image)
  133. this.$set(this, 'srcList', response.data)
  134. } else {
  135. this.$set(this.patent, 'image', null)
  136. this.$set(this, 'srcList', [])
  137. }
  138. this.loading = false
  139. }
  140. }).catch(error=>{
  141. this.loading = false
  142. })
  143. },
  144. // 获取内部的附图
  145. refreshData() {
  146. if(this.patent.image && this.patent.image.length>0){
  147. return false
  148. }
  149. var params = {
  150. patentNo:this.patent.patentNo
  151. }
  152. this.loading = true
  153. this.$api.getPatentFigures(params).then(response => {
  154. if (response.code == 200) {
  155. if (response.data&& Object.keys(response.data).length>0) {
  156. this.$set(this.patent, 'image', response.data)
  157. let srcList = []
  158. Object.keys(response.data).forEach(item=>{
  159. if(response.data[item] && response.data[item].length){
  160. response.data[item].forEach(pic=>{
  161. pic.rowApplicationNo = this.patent.rowApplicationNo
  162. srcList.push(pic.path)
  163. })
  164. }
  165. })
  166. // let srcList=response.data.map(item=>{
  167. // return this.$commonJS.checkViewer(item)
  168. // })
  169. this.$set(this, 'srcList', srcList)
  170. } else {
  171. this.$set(this.patent, 'image', null)
  172. this.$set(this, 'srcList', [])
  173. }
  174. this.loading = false
  175. }
  176. }).catch(error=>{
  177. this.loading = false
  178. })
  179. return
  180. var params = {
  181. appNo: this.patent.appNo,
  182. }
  183. this.loading = true
  184. this.$api.getFigure(params).then(response => {
  185. if (response.code == 200) {
  186. if (response.data.length>0) {
  187. this.$set(this.patent, 'image', response.data)
  188. let srcList=response.data.map(item=>{
  189. return this.$commonJS.checkViewer(item)
  190. })
  191. this.$set(this, 'srcList', srcList)
  192. } else {
  193. this.$set(this.patent, 'image', [])
  194. this.$set(this, 'srcList', [])
  195. }
  196. this.loading = false
  197. }
  198. }).catch(error=>{
  199. this.loading = false
  200. })
  201. },
  202. changeWidth() {
  203. this.width = this.value + '%'
  204. },
  205. close() {
  206. this.visible = false
  207. },
  208. onChange(file, fileList) {
  209. this.file = file.raw
  210. },
  211. handleAdd() {
  212. this.visible = true
  213. this.title = '新增附图'
  214. this.form = {
  215. patentId: this.patent.id,
  216. status: 0,
  217. url: ''
  218. }
  219. },
  220. handleEdit(row) {
  221. this.visible = true
  222. this.title = '编辑附图'
  223. this.form = { ...row }
  224. },
  225. handleDelete(row) {
  226. this.$confirm('确认删除本条数据吗?', '提示', {
  227. confirmButtonText: '确定',
  228. cancelButtonText: '取消',
  229. type: 'warning'
  230. }).then(() => {
  231. this.$api.deletePatentImage({ id: row.id }).then(response => {
  232. this.$message.success('删除成功')
  233. this.refreshPatent()
  234. }).catch(error => {
  235. })
  236. })
  237. },
  238. refreshPatent() {
  239. this.$emit('refresh')
  240. },
  241. submit() {
  242. let formData = new FormData()
  243. formData.append('patentId', this.form.patentId)
  244. formData.append('status', this.form.status)
  245. formData.append('url', this.form.url)
  246. if (this.file) {
  247. formData.append('file', this.file)
  248. }
  249. if (this.form.id) {
  250. this.btnLoading = true
  251. formData.append('id', this.form.id)
  252. this.$api.editPatentImage(formData).then(response => {
  253. this.btnLoading = false
  254. this.$message.success('操作成功')
  255. this.visible = false
  256. this.file = null
  257. this.refreshPatent()
  258. }).catch(error => {
  259. this.btnLoading = false
  260. })
  261. } else {
  262. if (!this.file) {
  263. this.$message.error('请选择文件')
  264. return false
  265. }
  266. this.btnLoading = true
  267. this.$api.uploadPatentImage(formData).then(response => {
  268. this.btnLoading = false
  269. this.$message.success('操作成功')
  270. this.visible = false
  271. this.file = null
  272. this.refreshPatent()
  273. }).catch(error => {
  274. this.btnLoading = false
  275. })
  276. }
  277. }
  278. }
  279. }
  280. </script>
  281. <style lang="scss" scoped>
  282. .image_contain{
  283. position: relative;
  284. width: 100%;
  285. height: 100%;
  286. .image_name{
  287. position: absolute;
  288. font-weight: bold;
  289. top: -25px;
  290. left: 0px;
  291. z-index: 999;
  292. }
  293. }
  294. </style>
  295. <style lang="scss">
  296. .up {
  297. width: 70px;
  298. height: 30px;
  299. line-height: 30px;
  300. color: rgb(65, 65, 224);
  301. cursor: pointer;
  302. position: absolute;
  303. right: 20px;
  304. top: 0px;
  305. }
  306. .up:hover {
  307. border-bottom: 1px solid rgb(45, 45, 235);
  308. }
  309. .block {
  310. width: 60%;
  311. margin: 0 auto;
  312. }
  313. .imageCard {
  314. display: flex;
  315. flex-direction: row;
  316. flex-wrap: wrap;
  317. justify-content: center;
  318. }
  319. .demonstration {
  320. float: left;
  321. line-height: 38px;
  322. text-align: center;
  323. }
  324. .patent-image {
  325. position: relative;
  326. .delete {
  327. float: right;
  328. padding: 3px 0;
  329. color: red;
  330. padding-left: 10px;
  331. }
  332. .edit {
  333. float: right;
  334. padding: 3px 0;
  335. }
  336. .add {
  337. font-size: 80px;
  338. color: #6b6868;
  339. margin-top: 60px;
  340. }
  341. .preview {
  342. // height: 300px;
  343. margin-right: 20px;
  344. margin-bottom: 20px;
  345. cursor: pointer;
  346. text-align: center;
  347. .card-header {
  348. height: 20px;
  349. }
  350. .el-card__header {
  351. border-bottom: 1px solid #EBEEF5;
  352. font-weight: normal;
  353. }
  354. .el-card__body{
  355. height: 100%;
  356. width: 100%;
  357. padding: 30px 20px;
  358. }
  359. }
  360. .el-image {
  361. width: 100%;
  362. }
  363. }</style>