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.

156 lines
5.2 KiB

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