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.

178 lines
5.6 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" width="400px" style="" class="customer-dialog">
  4. <el-form :inline="true" label-position="top" label-width="80px" :rules="dataRole">
  5. <el-row>
  6. <el-col :span="12">
  7. <el-form-item class="customer-item" label="申请单编码:" >
  8. <el-input v-model="pageData.projectId" 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.projectName" style="width: 120px;" 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="文件类型:" prop="fileType" :role="dataRole.fileType">
  18. <el-select v-model="pageData.fileType" style="width: 110px">
  19. <el-option label="sop" value="sop"></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"
  28. drag
  29. action="javascript:void(0);" ref="uploadFile" :limit="1"
  30. :before-upload="beforeUploadHandle" :on-change="onChange"
  31. accept="*" :auto-upload="false"
  32. style="text-align: left;">
  33. <i class="el-icon-upload"></i>
  34. <div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
  35. </el-upload>
  36. </el-col>
  37. </el-row>
  38. <el-row>
  39. <el-col :span="24" style="margin-bottom: 30px;">
  40. <el-form-item class="customer-item" label="备注:" >
  41. <el-input type="textarea" style="width: 360px;" placeholder="请输入内容" v-model="pageData.fileRemark"></el-input>
  42. </el-form-item>
  43. </el-col>
  44. </el-row>
  45. <el-row>
  46. </el-row>
  47. </el-form>
  48. <span slot="footer" class="dialog-footer">
  49. <el-button type="primary" @click="saveUploadFile()">保存</el-button>
  50. <el-button type="primary" @click="closeDialog">关闭</el-button>
  51. </span>
  52. </el-dialog>
  53. </div>
  54. </template>
  55. <script>
  56. import {
  57. uploadProjectFile,
  58. } from "@/api/project/project.js"
  59. /* 引入组件 */
  60. var functionId = 'C10000002';
  61. export default {
  62. data() {
  63. return {
  64. titleCon: '项目文件上传',
  65. folder: 'eamObject',
  66. visible: false,
  67. userId: this.$store.state.user.name,
  68. fileList: [],
  69. pageData: {
  70. site: this.$store.state.user.site,
  71. username: this.$store.state.user.name,
  72. projectId: '',
  73. projectName: '',
  74. fileType: 'other',
  75. fileRemark: '',
  76. },
  77. dataListLoading: false,
  78. dataRole: {
  79. fileType: [
  80. {
  81. required: true,
  82. message: ' ',
  83. trigger: 'change'
  84. }
  85. ],
  86. },
  87. }
  88. },
  89. methods: {
  90. //初始化组件的参数
  91. init(currentRow) {
  92. if(currentRow.projectId==null||currentRow.projectId==''){
  93. this.$alert('请选择申请单!', '错误', {
  94. confirmButtonText: '确定'
  95. })
  96. return false;
  97. }
  98. //初始化参数
  99. this.pageData = JSON.parse(JSON.stringify(currentRow));
  100. this.pageData.fileType='other'
  101. //打开页面
  102. this.visible = true;
  103. //重置人员信息
  104. this.pageData.username = this.userId;
  105. //重置标题
  106. //this.titleCon = this.labels.titleCon;
  107. },
  108. // 上传之前
  109. beforeUploadHandle(file) {
  110. // if (file.type !== 'image/jpg' && file.type !== 'image/jpeg' && file.type !== 'image/png' && file.type !== 'image/gif' && file.type !== 'application/pdf') {
  111. // this.$message.error('只支持图片和PDF文档!')
  112. // return false
  113. // }
  114. this.num++
  115. },
  116. /*选择上传文件时*/
  117. onChange(file){
  118. this.fileList.push(file);
  119. },
  120. /*关闭modal*/
  121. closeDialog(){
  122. //刷新报工的页面
  123. this.$emit('refreshPageTables');
  124. //关闭当前的页面
  125. this.visible = false;
  126. },
  127. /*保修当前的数据*/
  128. saveUploadFile(){
  129. let remark = this.pageData.fileRemark;
  130. if(this.pageData.fileType === '' || this.pageData.fileType == null){
  131. this.$message.warning("请选择文件类型!");
  132. return false;
  133. }
  134. /*判断文件是否上传*/
  135. if(null == this.fileList || 0 == this.fileList.length){
  136. this.$message.error("请先上传文件!");
  137. return false;
  138. }
  139. const formData = new FormData();
  140. //片接文件
  141. formData.append("file", this.fileList[0].raw);
  142. formData.append("folder", this.folder);
  143. formData.append("site", this.pageData.site);
  144. formData.append("projectId", this.pageData.projectId);
  145. formData.append("orderRef3", this.pageData.fileType);
  146. formData.append("remark", remark);
  147. uploadProjectFile(formData).then(({data}) => {
  148. if (data.code === 0) {
  149. this.$message.success(data.msg);
  150. //清空文件上传记录
  151. this.$refs.uploadFile.clearFiles();
  152. this.pageData.fileRemark = '';
  153. }else {
  154. this.$message.warning(data.msg);
  155. }
  156. })
  157. }
  158. },
  159. created() {
  160. // this.factoryList()
  161. // this.getLanguageList()
  162. }
  163. }
  164. </script>
  165. <style scoped lang="scss">
  166. </style>