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.

507 lines
16 KiB

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