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.

142 lines
4.5 KiB

6 months ago
  1. <template>
  2. <div class="customer-css">
  3. <el-dialog :title="pageData.titleCon" :close-on-click-modal="false" :visible.sync="visible" width="390px" style="height: 520px;" class="customer-dialog">
  4. <el-form :inline="true" label-position="top" label-width="80px">
  5. <el-row>
  6. <el-col :span="12">
  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-row>
  12. <el-row>
  13. <el-col :span="24">
  14. <el-upload class="customer-upload" drag multiple :file-list="fileList"
  15. action="javascript:void(0);" ref="uploadFile"
  16. :before-upload="beforeUploadHandle" :on-change="onChange"
  17. accept="*" :auto-upload="false"
  18. style="text-align: left;">
  19. <i class="el-icon-upload"></i>
  20. <div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
  21. </el-upload>
  22. </el-col>
  23. </el-row>
  24. <el-row>
  25. <el-col :span="24" style="margin-bottom: 30px;">
  26. <el-form-item class="customer-item" label="备注:">
  27. <el-input type="textarea" style="width: 360px;" placeholder="请输入内容" v-model="pageData.fileRemark"></el-input>
  28. </el-form-item>
  29. </el-col>
  30. </el-row>
  31. <el-row>
  32. </el-row>
  33. </el-form>
  34. <span slot="footer" class="dialog-footer">
  35. <el-button type="primary" @click="saveUploadFile">保存</el-button>
  36. <el-button type="primary" @click="closeDialog">关闭</el-button>
  37. </span>
  38. </el-dialog>
  39. </div>
  40. </template>
  41. <script>
  42. import {
  43. uploadEamObjectFile,
  44. } from '@/api/eam/com_eam_object_upload_file.js';
  45. /* 引入组件 */
  46. var functionId = 'C10000002'
  47. export default {
  48. data() {
  49. return {
  50. folder: '',
  51. visible: false,
  52. userId: this.$store.state.user.name,
  53. fileList: [],
  54. pageData: {
  55. titleCon: '',
  56. site: '',
  57. buNo: '',
  58. username: this.$store.state.user.name,
  59. inspectionNo: '',
  60. fileRemark: '',
  61. folder: '',
  62. },
  63. dataListLoading: false,
  64. }
  65. },
  66. methods: {
  67. //初始化组件的参数
  68. init (currentRow) {
  69. //初始化参数
  70. this.pageData = JSON.parse(JSON.stringify(currentRow))
  71. this.folder = this.pageData.folder
  72. //打开页面
  73. this.visible = true
  74. //重置人员信息
  75. this.pageData.username = this.userId
  76. },
  77. // 上传之前
  78. beforeUploadHandle (file) {
  79. // if (file.type !== 'image/jpg' && file.type !== 'image/jpeg' && file.type !== 'image/png' && file.type !== 'image/gif' && file.type !== 'application/pdf') {
  80. // this.$message.error('只支持图片和PDF文档!')
  81. // return false
  82. // }
  83. // this.num++
  84. },
  85. // 选择上传文件时
  86. onChange (file, fileList) {
  87. this.fileList = fileList
  88. },
  89. // 关闭modal
  90. closeDialog () {
  91. this.fileList = []
  92. // 清空文件上传记录
  93. this.$refs.uploadFile.clearFiles()
  94. // 刷新报工的页面
  95. this.$emit('refreshPageTables')
  96. //关闭当前的页面
  97. this.visible = false
  98. },
  99. // 保修当前的数据
  100. saveUploadFile () {
  101. let remark = this.pageData.fileRemark
  102. if (null === remark || remark === undefined) {
  103. remark = ''
  104. }
  105. // 判断文件是否上传
  106. if (null == this.fileList || 0 === this.fileList.length) {
  107. this.$message.error("请先上传文件!")
  108. return false
  109. }
  110. const formData = new FormData()
  111. // 片接文件
  112. for (let i = 0; i < this.fileList.length; i++) {
  113. formData.append("file",this.fileList[i].raw)
  114. }
  115. formData.append("folder", this.folder)
  116. formData.append("site", this.pageData.site)
  117. formData.append("objectID", this.pageData.inspectionNo)
  118. formData.append("remark", remark)
  119. formData.append("orderRef4", this.pageData.buNo)
  120. uploadEamObjectFile(formData).then(({data}) => {
  121. if (data.code === 0) {
  122. this.$message.success(data.msg)
  123. //清空文件上传记录
  124. this.$refs.uploadFile.clearFiles()
  125. this.pageData.fileRemark = ''
  126. this.fileList = []
  127. // 刷新报工的页面
  128. this.$emit('refreshPageTables')
  129. } else {
  130. this.$message.warning(data.msg)
  131. }
  132. })
  133. }
  134. },
  135. }
  136. </script>
  137. <style scoped lang="scss">
  138. </style>