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.

489 lines
16 KiB

  1. <script>
  2. import {uploadFileList} from '@/api/base/baseFunction.js';
  3. import {deleteDocumentType,getProofDocument} from "@/api/eam/eamProofing.js";
  4. export default {
  5. name: "uploadFileList",
  6. props: {
  7. uploadDialog: {
  8. type: Boolean,
  9. default: false,
  10. },
  11. title: {
  12. type: String,
  13. default: '',
  14. },
  15. label: {
  16. type: String,
  17. default: '',
  18. },
  19. no: {
  20. type: [String],
  21. default: ''
  22. },
  23. noType:{
  24. type: [String,Number],
  25. default: ''
  26. },
  27. noDesc:{
  28. type: [String,Number],
  29. default: ''
  30. },
  31. path: {
  32. type: String,
  33. request: true,
  34. },
  35. uploadFlag: {
  36. type: String,
  37. default: '',
  38. },
  39. fileList: {
  40. type: Array,
  41. default:() => [],
  42. },
  43. folder: {
  44. type: String,
  45. default: ''
  46. },
  47. proofingId: {
  48. type: [String,Number],
  49. default: ''
  50. },
  51. projectId: {
  52. type: [String,Number],
  53. default: ''
  54. },
  55. projectDesc: {
  56. type: [String,Number],
  57. default: ''
  58. },
  59. customerNo:{
  60. type: [String,Number],
  61. default: ''
  62. },
  63. customerDesc:{
  64. type: [String,Number],
  65. default: ''
  66. },
  67. testPartNo:{
  68. type: [String,Number],
  69. default: ''
  70. },
  71. partDesc:{
  72. type: [String,Number],
  73. default: ''
  74. },
  75. columnFileContentArray: {
  76. type: Array,
  77. default: () => []
  78. },
  79. proofDocumentList: {
  80. type: Array,
  81. default: () => []
  82. },
  83. site:{
  84. type: [String,Number],
  85. default: ''
  86. },
  87. bu:{
  88. type: [String,Number],
  89. default: ''
  90. },
  91. id:{
  92. type: [String,Number],
  93. default: ''
  94. },
  95. isEditable: Boolean,
  96. isMassProductionStage: Boolean,
  97. },
  98. data () {
  99. return {
  100. //fileRemark: '',
  101. fileName: '',
  102. noType1: '',
  103. conclusion: '',
  104. documentGroupDesc: '',
  105. conclusionList: [
  106. {conclusion: '合格'},
  107. {conclusion: '不合格'},
  108. {conclusion: '让步接受'},
  109. {conclusion: 'N/A'}
  110. ],
  111. //选中当前行
  112. documentClickRow: {},
  113. bu : this.site + "-" + this.buNo,
  114. dataListLoading: false,
  115. rules: {
  116. noType: [
  117. {
  118. required: true,
  119. message: ' ',
  120. trigger: ['blur', 'change']
  121. }
  122. ],
  123. conclusion: [
  124. {
  125. required: true,
  126. message: ' ',
  127. trigger: ['blur', 'change']
  128. }
  129. ]
  130. }
  131. }
  132. },
  133. computed: {
  134. displayValue() {
  135. if (this.noType === null || this.noType === undefined) {
  136. return this.noDesc
  137. }else {
  138. return this.noType
  139. }
  140. },
  141. documentGroupDescJudgment() {
  142. if (this.id !== '-1') {
  143. return '常规'
  144. } else {
  145. return '其他'
  146. }
  147. },
  148. conclusionDefaultValue() {
  149. if (this.isMassProductionStage) {
  150. return 'N/A';
  151. }else {
  152. return this.isEditable ? 'N/A' : '';
  153. }
  154. }
  155. },
  156. watch: {
  157. conclusionDefaultValue(newValue) {
  158. this.conclusion = newValue;
  159. }
  160. },
  161. created() {
  162. this.conclusion = this.conclusionDefaultValue;
  163. },
  164. beforeDestroy() {
  165. // 组件销毁前清理数据
  166. if (this.isMassProductionStage) {
  167. this.conclusion = 'N/A';
  168. }else if (this.isEditable) {
  169. this.conclusion = 'N/A';
  170. }else {
  171. this.conclusion = '';
  172. }
  173. },
  174. methods: {
  175. triggerUpload() {
  176. this.fileName = ''; // 清空文件名称
  177. this.$refs.uploadFile.clearFiles(); // 清空上传文件列表
  178. this.$emit("update:fileList", []); // 清空文件列表
  179. this.$refs.uploadFile.$el.querySelector('input').click()
  180. },
  181. closeFileUpdate() {
  182. this.$emit('update:uploadDialog', false)
  183. //this.fileRemark = ''
  184. this.$refs.uploadFile.clearFiles()
  185. this.$emit("update:fileList", [])
  186. this.fileName = ''; // 清空文件名称
  187. this.noType = '';
  188. if (this.isMassProductionStage) {
  189. this.conclusion = 'N/A';
  190. }else if (this.isEditable) {
  191. this.conclusion = 'N/A';
  192. }else {
  193. this.conclusion = '';
  194. }
  195. },
  196. onRemove(file, fileList) {
  197. this.$emit("update:fileList", fileList)
  198. if (fileList.length === 0) {
  199. this.fileName = ''; // 清空文件名称
  200. }
  201. },
  202. onChange(file, fileList) {
  203. this.$emit("update:fileList", fileList)
  204. if (fileList.length > 0) {
  205. this.fileName = fileList[0].name; // 设置文件名称
  206. }
  207. },
  208. upload() {
  209. if (this.fileList.length === 0) {
  210. this.$message.warning("未选择需要上传的文件")
  211. return;
  212. }
  213. if (this.noType === null || this.noType === undefined || this.noType === '') {
  214. this.$message.warning("文件类型不能为空")
  215. return;
  216. }
  217. if (this.conclusion === null || this.conclusion === undefined || this.conclusion === '') {
  218. this.$message.warning("结论不能为空")
  219. return;
  220. }
  221. let data = new FormData();
  222. data.append("file", this.fileList[0].raw);
  223. data.append("orderRef1", this.$store.state.user.site);
  224. data.append("orderRef2", this.proofingId);
  225. data.append("orderRef3", this.id);
  226. data.append("orderRef4", this.projectId);
  227. data.append("documentDesc", this.no);
  228. data.append("cAdditionalInfo", this.noType);
  229. data.append("conclusion", this.conclusion);
  230. data.append("createBy", this.$store.state.user.name);
  231. data.append("folder", this.folder);
  232. uploadFileList(this.path, data).then(({data}) => {
  233. if (data && data.code === 0) {
  234. this.$emit('update:uploadDialog', false);
  235. this.$message.success(data.msg);
  236. this.fileList = [];
  237. this.fileName = '';
  238. this.noType = '';
  239. // this.$emit('get-document-list');
  240. // this.$emit('get-proof-document');
  241. } else {
  242. this.$message.warning(data.msg);
  243. this.fileList = [];
  244. this.fileName = '';
  245. this.noType = '';
  246. }
  247. }).catch((error) => {
  248. this.$message.error(error);
  249. this.fileList = [];
  250. this.fileName = '';
  251. this.noType = '';
  252. });
  253. },
  254. changeCurrentRow1 (row, oldRow) {
  255. // 判断是否是获取焦点的事件
  256. if (row) {
  257. this.documentClickRow = JSON.parse(JSON.stringify(row))
  258. }
  259. },
  260. uploadDocumentClickRow(row) {
  261. this.documentClickRow = JSON.parse(JSON.stringify(row))
  262. },
  263. DeleteDocumentType(row) {
  264. this.$confirm('是否删除该文档清单?', '提示', {
  265. confirmButtonText: '确定',
  266. cancelButtonText: '取消',
  267. type: 'warning'
  268. }).then(() => {
  269. deleteDocumentType(row).then(({data}) => {
  270. if (data && data.code === 0) {
  271. this.$message({
  272. message: '删除成功',
  273. type: 'success'
  274. })
  275. //刷新表格
  276. this.getProofDocument();
  277. // this.$emit('get-document-list');
  278. // this.$emit('get-proof-document');
  279. } else {
  280. this.$message({
  281. message: '删除失败',
  282. type: 'error'
  283. })
  284. }
  285. })
  286. }).catch(() => {
  287. this.$message({
  288. type: 'info',
  289. message: '已取消删除'
  290. });
  291. });
  292. },
  293. getProofDocument() {
  294. let tempData = {
  295. site: this.$store.state.user.site,
  296. username: this.$store.state.user.name,
  297. buNo: this.bu,
  298. proofingId: this.proofingId,
  299. projectId: this.projectId,
  300. projectDesc: this.projectDesc,
  301. customerId: this.customerNo,
  302. customerDesc: this.customerDesc,
  303. testPartNo: this.testPartNo,
  304. partDesc: this.partDesc,
  305. page: 1,
  306. limit: 1000
  307. }
  308. getProofDocument(tempData).then(({data}) => {
  309. if (data && data.code === 0) {
  310. this.proofDocumentList = data.page.list
  311. for (let i = 0; i < this.proofDocumentList.length; i++) {
  312. this.proofDocumentList[i].buNo = this.proofDocumenCurrentRow.buNo
  313. }
  314. if (this.totalPage > 0) {
  315. // 设置选中行
  316. this.$refs.proofDocumentTable.setCurrentRow(this.proofDocumentList[0])
  317. // 加载当前的页签的table
  318. this.refreshCurrentTabTable()
  319. this.proofDocumentClickRow = this.proofDocumentList[0]
  320. }
  321. } else {
  322. this.proofDocumentList = []
  323. }
  324. })
  325. },
  326. getCombinedDocumentType(row) {
  327. // 根据您的需求,组合或拼接需要显示的字段
  328. if (row.documentType === null || row.documentType === undefined) {
  329. return row.documentDesc
  330. }
  331. return row.documentType
  332. },
  333. validateField(fieldName) {
  334. this.$refs.validateField(fieldName);
  335. },
  336. // getDocumentList() {
  337. // getDocumentList(this.modalData).then(({data}) => {
  338. // if (data && data.code === 0) {
  339. // this.documentManifestDefinitionList = data.page.list
  340. // } else {
  341. // this.documentManifestDefinitionList = []
  342. // }
  343. // })
  344. // },
  345. // rowStyle ({row}) {
  346. // if (this.documentClickRow.documentTypeId === row.documentTypeId) {
  347. // return { 'background-color': '#E8F7F6', cursor: 'pointer' };
  348. // }
  349. // },
  350. }
  351. }
  352. </script>
  353. <template>
  354. <div>
  355. <el-dialog :title="title" v-drag @close="closeFileUpdate" :visible="uploadDialog" width="952px" append-to-body :close-on-click-modal="false">
  356. <el-form :inline="true" label-position="top" label-width="80px" style="margin-left: 7px;margin-top: -5px;">
  357. <el-form-item label="项目编码">
  358. <el-input v-model="projectId" readonly style="width: 113px;" class="red-text"></el-input>
  359. </el-form-item>
  360. <el-form-item label="项目名称">
  361. <el-input v-model="projectDesc" readonly style="width: 173px;" class="red-text"></el-input>
  362. </el-form-item>
  363. <el-form-item label="客户编码">
  364. <el-input v-model="customerNo" readonly style="width: 110px;" class="red-text"></el-input>
  365. </el-form-item>
  366. <el-form-item label="客户名称">
  367. <el-input v-model="customerDesc" readonly style="width: 170px;" class="red-text"></el-input>
  368. </el-form-item>
  369. <el-form-item :label="label" v-if="!isEditable">
  370. <el-input v-model="no" :readonly="!isEditable" style="width: 113px" class="red-text"></el-input>
  371. </el-form-item>
  372. <el-form-item label="文档类型" v-if="!isEditable">
  373. <el-input :value="displayValue" :readonly="!isEditable" style="width: 166px" class="red-text"></el-input>
  374. </el-form-item>
  375. </el-form>
  376. <el-form :inline="true" label-position="top" label-width="80px" style="margin-left: 7px;margin-top: -5px;">
  377. <el-form-item label="项目料号">
  378. <el-input v-model="testPartNo" readonly style="width: 113px;" class="red-text"></el-input>
  379. </el-form-item>
  380. <el-form-item label="料号描述">
  381. <el-input v-model="partDesc" readonly style="width: 173px;" class="red-text"></el-input>
  382. </el-form-item>
  383. <el-form-item label="BU">
  384. <el-input v-model="this.$props.site + '-' + this.$props.bu" readonly style="width: 110px;" class="red-text"></el-input>
  385. </el-form-item>
  386. <el-form-item label="打样单号">
  387. <el-input v-model="proofingId" readonly style="width: 170px;" class="red-text"></el-input>
  388. </el-form-item>
  389. </el-form>
  390. <el-form :inline="true" label-position="top" label-width="80px" style="margin-left: 7px;margin-top: -5px;">
  391. <el-form-item label=" ">
  392. <a href="javascript:void(0);" @click="triggerUpload">点击选择文件</a>
  393. <tr></tr>
  394. <el-input v-model="this.fileName" readonly placeholder="文件名称" style="width: 423px"></el-input>
  395. <el-form-item label="文档类型" v-if="isEditable" :rules="rules.noType" prop="noType" style="margin-top: -18px;margin-left: 11px;">
  396. <el-input v-model="noType" :readonly="!isEditable" style="width: 170px" @blur="validateField('noType')" @change="validateField('noType')"></el-input>
  397. </el-form-item>
  398. <el-form-item label="结论" prop="conclusion" v-if="!isMassProductionStage" :rules="rules.conclusion" style="margin-top: -18px;">
  399. <el-select v-model="conclusion" placeholder="请选择" clearable style="width: 110px;" @blur="validateField('conclusion')" @change="validateField('conclusion')">
  400. <el-option
  401. v-for = "i in conclusionList"
  402. :key = "i.conclusion"
  403. :label = "i.conclusion"
  404. :value = "i.conclusion">
  405. </el-option>
  406. </el-select>
  407. </el-form-item>
  408. <el-form-item label="文档种类" style="margin-top: -18px;" v-if="this.id === '-1'">
  409. <el-input readonly style="width: 110px;" :value="documentGroupDescJudgment"></el-input>
  410. </el-form-item>
  411. <el-form-item label="文档种类" style="margin-top: -18px;" v-if="this.id !== '-1'">
  412. <el-input readonly style="width: 110px;" :value="documentGroupDescJudgment"></el-input>
  413. </el-form-item>
  414. <el-button type="primary" @click="upload">上传</el-button>
  415. <el-upload drag :file-list="fileList"
  416. ref="uploadFile"
  417. :on-remove="onRemove" :on-change="onChange"
  418. :on-close="closeFileUpdate"
  419. multiple :auto-upload="false"
  420. :show-file-list="true"
  421. :limit="1"
  422. style="text-align: left;display: none;">
  423. </el-upload>
  424. </el-form-item>
  425. </el-form>
  426. <el-form>
  427. <el-table
  428. :data="proofDocumentList"
  429. border
  430. style="width: 100%;margin-top: 5px;"
  431. height="252"
  432. ref="proofDocumentTable"
  433. @row-click="uploadDocumentClickRow"
  434. @current-change="changeCurrentRow1">
  435. <el-table-column label="文档类型" align="center">
  436. <template slot-scope="scope">
  437. {{ getCombinedDocumentType(scope.row) }}
  438. </template>
  439. </el-table-column>
  440. <el-table-column
  441. v-for="(item,index) in columnFileContentArray" :key="index"
  442. :sortable="item.columnSortable"
  443. :prop="item.columnProp"
  444. :header-align="item.headerAlign"
  445. :show-overflow-tooltip="item.showOverflowTooltip"
  446. :align="item.align"
  447. :fixed="item.fixed==''?false:item.fixed"
  448. :min-width="item.columnWidth"
  449. :label="item.columnLabel">
  450. <template slot-scope="scope">
  451. <span v-if="!item.columnHidden"> {{scope.row[item.columnProp]}}</span>
  452. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
  453. style="width: 100px; height: 80px"/></span>
  454. </template>
  455. </el-table-column>
  456. <el-table-column
  457. header-align="center"
  458. align="center"
  459. width="100"
  460. fixed="right"
  461. label="操作">
  462. <template slot-scope="scope">
  463. <a type="text" size="small" @click="DeleteDocumentType(scope.row)">删除</a>
  464. </template>
  465. </el-table-column>
  466. </el-table>
  467. <!-- <el-form-item label="备注:">-->
  468. <!-- <el-input type="textarea" placeholder="请输入内容" v-model="fileRemark"></el-input>-->
  469. <!-- </el-form-item>-->
  470. </el-form>
  471. <span slot="footer" class="dialog-footer">
  472. <el-button @click="$emit('update:uploadDialog',false);this.fileList = [];this.fileName = '';this.conclusion='';this.noType = '';">关闭</el-button>
  473. </span>
  474. </el-dialog>
  475. </div>
  476. </template>
  477. <style scoped>
  478. /deep/ .el-form-item--medium .el-form-item__content{
  479. height: auto;
  480. }
  481. .red-text /deep/ .el-input__inner {
  482. color: red;
  483. }
  484. </style>