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

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