祥兆质量前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

181 lines
5.7 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div class="customer-css">
  3. <el-dialog :title="titleCon" :close-on-click-modal="false" :visible.sync="visible" :before-close="closeDialog" :showClose="false" width="390px" style="height: 530px;" class="customer-dialog">
  4. <el-form :inline="true" label-position="top" label-width="80px">
  5. <el-row>
  6. <el-col :span="12" style="width:36%">
  7. <el-form-item class="customer-item" label="检验单号">
  8. <el-input v-model="pageData.inspectionNo" style="width: 120px;" disabled ></el-input>
  9. </el-form-item>
  10. </el-col>
  11. <el-col :span="12">
  12. <el-form-item class="customer-item" label="项目编码">
  13. <el-input v-model="pageData.itemNo" style="width: 120px;" disabled ></el-input>
  14. </el-form-item>
  15. </el-col>
  16. </el-row>
  17. <el-row>
  18. <!-- 图像区域 -->
  19. <ul class="content-image" v-viewer>
  20. <li v-for="(item, index) in descImgs" :key="index" style="float: left;display: inline">
  21. <img :src="item.url" style="width:70px;height: 70px"/>
  22. <!-- 删除图标 -->
  23. <div class="delete-img">
  24. <i class="el-icon-delete" @click="deleteImage(index,item.id)"></i>
  25. </div>
  26. </li>
  27. </ul>
  28. </el-row>
  29. <el-row>
  30. <el-col :span="24">
  31. <el-upload class="customer-upload" drag multiple :file-list="fileList"
  32. action="javascript:void(0);" ref="uploadFile"
  33. :before-upload="beforeUploadHandle" :on-change="onChange"
  34. accept=".jpg,.jpeg,.png,.gif" :auto-upload="false"
  35. style="text-align: left;">
  36. <i class="el-icon-upload"></i>
  37. <div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
  38. </el-upload>
  39. </el-col>
  40. </el-row>
  41. </el-form>
  42. <span slot="footer" class="dialog-footer">
  43. <el-button type="primary" @click="saveUploadFile">保存</el-button>
  44. <el-button type="primary" @click="closeDialog">关闭</el-button>
  45. </span>
  46. </el-dialog>
  47. </div>
  48. </template>
  49. <script>
  50. import {uploadEamObjectFile} from '@/api/eam/com_eam_object_upload_file.js';
  51. import {
  52. searchItemFileUrl, // 查询文件路径
  53. imageDelete, // 删除图片
  54. } from "@/api/qc/qc.js"
  55. /* 引入组件 */
  56. var functionId = 'C10000002';
  57. export default {
  58. data() {
  59. return {
  60. titleCon: '项目图片上传',
  61. visible: false,
  62. userId: this.$store.state.user.name,
  63. fileList: [],
  64. pageData: {
  65. site: '',
  66. buNo: '',
  67. username: this.$store.state.user.name,
  68. inspectionNo: '',
  69. itemNo: '',
  70. fileRemark: '',
  71. folder: ''
  72. },
  73. dataListLoading: false,
  74. descImgs: [],
  75. }
  76. },
  77. methods: {
  78. // 初始化组件的参数
  79. init (currentRow) {
  80. // 初始化参数
  81. this.pageData = JSON.parse(JSON.stringify(currentRow))
  82. // 打开页面
  83. this.visible = true
  84. this.descImgs = []
  85. this.searchItemFileUrl()
  86. },
  87. // 查询图片列表
  88. searchItemFileUrl () {
  89. this.descImgs = []
  90. searchItemFileUrl(this.pageData).then(({data}) => {
  91. if (data.code === 0) {
  92. for (let i = 0; i < data.rows.length; i++) {
  93. this.descImgs.push(data.rows[i])
  94. }
  95. } else {
  96. this.$message.warning(data.msg)
  97. }
  98. })
  99. },
  100. // 上传之前
  101. beforeUploadHandle (file) {
  102. if (file.type !== 'image/jpg' && file.type !== 'image/jpeg' && file.type !== 'image/png' && file.type !== 'image/gif') {
  103. this.$message.error('只支持图片!')
  104. return false
  105. }
  106. },
  107. // 选择上传文件时
  108. onChange (file, fileList) {
  109. this.fileList = fileList
  110. },
  111. // 关闭modal
  112. closeDialog () {
  113. this.fileList = []
  114. // 清空文件上传记录
  115. this.$refs.uploadFile.clearFiles()
  116. // 刷新报工的页面
  117. //this.$emit('refreshPageTables2')
  118. // 关闭当前的页面
  119. this.visible = false
  120. },
  121. // 保修当前的数据
  122. saveUploadFile () {
  123. // 判断文件是否上传
  124. if (null == this.fileList || 0 === this.fileList.length) {
  125. this.$message.error("请先上传图片!")
  126. return false
  127. }
  128. const formData = new FormData()
  129. // 片接文件
  130. for (let i = 0; i < this.fileList.length; i++) {
  131. formData.append("file",this.fileList[i].raw)
  132. }
  133. formData.append("site", this.pageData.site)
  134. formData.append("folder", this.pageData.folder)
  135. formData.append("objectID", this.pageData.inspectionNo)
  136. formData.append("orderRef1", this.pageData.itemNo)
  137. formData.append("orderRef4", this.pageData.buNo)
  138. uploadEamObjectFile(formData).then(({data}) => {
  139. if (data.code === 0) {
  140. this.$message.success(data.msg)
  141. // 清空文件上传记录
  142. this.$refs.uploadFile.clearFiles()
  143. this.searchItemFileUrl()
  144. this.fileList = []
  145. } else {
  146. this.$message.warning(data.msg)
  147. }
  148. })
  149. },
  150. // 删除图片
  151. deleteImage (index, id) {
  152. let param = {
  153. id: id
  154. }
  155. this.$confirm(`是否删除该图片?`, '提示', {
  156. confirmButtonText: '确定',
  157. cancelButtonText: '取消',
  158. type: 'warning'
  159. }).then(() => {
  160. imageDelete(param).then(({data}) => {
  161. if (data.code === 0) {
  162. this.searchItemFileUrl()
  163. this.$message.success(data.msg)
  164. }else {
  165. this.$message.warning(data.msg)
  166. }
  167. })
  168. }).catch(() => {
  169. })
  170. },
  171. },
  172. }
  173. </script>
  174. <style scoped lang="scss">
  175. </style>