plm前端
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.

117 lines
3.7 KiB

2 years ago
2 years ago
2 years 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.partNo" readonly style="width: 120px"></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
  15. action="javascript:void(0);" ref="uploadFile" :limit="1"
  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. uploadFile // 文件上传
  44. } from '@/api/quotation/quotationInformation.js'
  45. export default {
  46. data() {
  47. return {
  48. visible: false,
  49. fileList: [],
  50. pageData: {
  51. titleCon: '',
  52. site: this.$store.state.user.site,
  53. createBy: this.$store.state.user.name,
  54. partNo: '',
  55. fileRemark: '',
  56. },
  57. dataListLoading: false,
  58. }
  59. },
  60. methods: {
  61. // 初始化组件的参数
  62. init(currentRow) {
  63. // 初始化参数
  64. this.pageData = JSON.parse(JSON.stringify(currentRow))
  65. // 打开页面
  66. this.visible = true
  67. },
  68. // 上传之前
  69. beforeUploadHandle(file) {},
  70. /*选择上传文件时*/
  71. onChange(file){
  72. this.fileList.push(file)
  73. },
  74. /*关闭modal*/
  75. closeDialog(){
  76. this.fileList = []
  77. // 刷新报工的页面
  78. this.$emit('refreshPageTables')
  79. //关闭当前的页面
  80. this.visible = false
  81. },
  82. /*保修当前的数据*/
  83. saveUploadFile(){
  84. let remark = this.pageData.fileRemark
  85. if(remark == null || remark == undefined){
  86. remark = ''
  87. }
  88. /*判断文件是否上传*/
  89. if(this.fileList == null || this.fileList.length === 0){
  90. this.$message.error("请先上传文件!")
  91. return false
  92. }
  93. const formData = new FormData()
  94. //片接文件
  95. formData.append("file", this.fileList[0].raw)
  96. formData.append("orderRef1", this.pageData.site)
  97. formData.append("orderRef2", this.pageData.partNo)
  98. formData.append("fileRemark", remark)
  99. uploadFile(formData).then(({data}) => {
  100. if (data.code === 0) {
  101. this.$message.success(data.msg)
  102. // 清空文件上传记录
  103. this.$refs.uploadFile.clearFiles()
  104. this.pageData.fileRemark = ''
  105. this.fileList = []
  106. }else {
  107. this.$message.warning(data.msg)
  108. }
  109. })
  110. }
  111. },
  112. }
  113. </script>
  114. <style scoped lang="scss">
  115. </style>