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.

505 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. EventBus.$emit('updateThisProjectPartDocumentInfo');
  257. EventBus.$emit('getProjectOtherDocument');
  258. // this.$emit('get-document-list');
  259. // this.$emit('get-proof-document');
  260. } else {
  261. this.$alert(data.msg, '错误', {
  262. confirmButtonText: '确定'
  263. })
  264. this.fileList = [];
  265. this.fileName = '';
  266. this.noType = '';
  267. }
  268. }).catch((error) => {
  269. this.$message.error(error);
  270. this.fileList = [];
  271. this.fileName = '';
  272. this.noType = '';
  273. });
  274. },
  275. changeCurrentRow1 (row, oldRow) {
  276. // 判断是否是获取焦点的事件
  277. if (row) {
  278. this.documentClickRow = JSON.parse(JSON.stringify(row))
  279. }
  280. },
  281. uploadDocumentClickRow(row) {
  282. this.documentClickRow = JSON.parse(JSON.stringify(row))
  283. },
  284. DeleteDocumentType(row) {
  285. this.$confirm('是否删除该文档清单?', '提示', {
  286. confirmButtonText: '确定',
  287. cancelButtonText: '取消',
  288. type: 'warning'
  289. }).then(() => {
  290. deleteDocumentType(row).then(({data}) => {
  291. if (data && data.code === 0) {
  292. this.$message({
  293. message: '删除成功',
  294. type: 'success'
  295. })
  296. //刷新表格
  297. this.getProofDocument();
  298. EventBus.$emit('updateAgencyMatterForUploads');
  299. EventBus.$emit('updateProjectPartDocumentInfo');
  300. EventBus.$emit('updateThisProjectPartDocumentInfo');
  301. // this.$emit('get-document-list');
  302. // this.$emit('get-proof-document');
  303. } else {
  304. this.$alert(data.msg, '错误', {
  305. confirmButtonText: '确定'
  306. })
  307. }
  308. })
  309. }).catch(() => {
  310. this.$message({
  311. type: 'info',
  312. message: '已取消删除'
  313. });
  314. });
  315. },
  316. getProofDocument() {
  317. let tempData = {
  318. site: this.$store.state.user.site,
  319. username: this.$store.state.user.name,
  320. buNo: this.bu,
  321. proofingId: this.proofingId,
  322. projectId: this.projectId,
  323. projectDesc: this.projectDesc,
  324. customerId: this.customerNo,
  325. customerDesc: this.customerDesc,
  326. testPartNo: this.testPartNo,
  327. partDesc: this.partDesc,
  328. page: 1,
  329. limit: 1000
  330. }
  331. getProofDocument(tempData).then(({data}) => {
  332. if (data && data.code === 0) {
  333. this.proofDocumentList = data.page.list
  334. for (let i = 0; i < this.proofDocumentList.length; i++) {
  335. this.proofDocumentList[i].buNo = this.proofDocumenCurrentRow.buNo
  336. }
  337. } else {
  338. this.proofDocumentList = []
  339. }
  340. })
  341. },
  342. getCombinedDocumentType(row) {
  343. // 根据您的需求,组合或拼接需要显示的字段
  344. if (row.documentType === null || row.documentType === undefined) {
  345. return row.documentDesc
  346. }
  347. return row.documentType
  348. },
  349. validateField(fieldName) {
  350. this.$refs.validateField(fieldName);
  351. },
  352. // getDocumentList() {
  353. // getDocumentList(this.modalData).then(({data}) => {
  354. // if (data && data.code === 0) {
  355. // this.documentManifestDefinitionList = data.page.list
  356. // } else {
  357. // this.documentManifestDefinitionList = []
  358. // }
  359. // })
  360. // },
  361. // rowStyle ({row}) {
  362. // if (this.documentClickRow.documentTypeId === row.documentTypeId) {
  363. // return { 'background-color': '#E8F7F6', cursor: 'pointer' };
  364. // }
  365. // },
  366. }
  367. }
  368. </script>
  369. <template>
  370. <div>
  371. <el-dialog :title="title" v-drag @close="closeFileUpdate" :visible="uploadDialog" width="952px" append-to-body :close-on-click-modal="false">
  372. <el-form :inline="true" label-position="top" label-width="80px" style="margin-left: 7px;margin-top: -5px;">
  373. <el-form-item label="项目编码">
  374. <el-input v-model="projectNo" readonly style="width: 113px;" class="red-text"></el-input>
  375. </el-form-item>
  376. <el-form-item label="项目名称">
  377. <el-input v-model="projectDesc" readonly style="width: 173px;" class="red-text"></el-input>
  378. </el-form-item>
  379. <el-form-item label="客户编码">
  380. <el-input v-model="customerNo" readonly style="width: 110px;" class="red-text"></el-input>
  381. </el-form-item>
  382. <el-form-item label="客户名称">
  383. <el-input v-model="customerDesc" readonly style="width: 170px;" class="red-text"></el-input>
  384. </el-form-item>
  385. <el-form-item :label="label" v-if="!isEditable">
  386. <el-input v-model="no" :readonly="!isEditable" style="width: 113px" class="red-text"></el-input>
  387. </el-form-item>
  388. <el-form-item label="文档类型" v-if="!isEditable">
  389. <el-input :value="displayValue" :readonly="!isEditable" style="width: 166px" class="red-text"></el-input>
  390. </el-form-item>
  391. </el-form>
  392. <el-form :inline="true" label-position="top" label-width="80px" style="margin-left: 7px;margin-top: -5px;">
  393. <el-form-item label="项目料号">
  394. <el-input v-model="testPartNo" readonly style="width: 113px;" class="red-text"></el-input>
  395. </el-form-item>
  396. <el-form-item label="料号描述">
  397. <el-input v-model="partDesc" readonly style="width: 173px;" class="red-text"></el-input>
  398. </el-form-item>
  399. <el-form-item label="BU">
  400. <el-input v-model="this.$props.site + '-' + this.$props.bu" readonly style="width: 110px;" class="red-text"></el-input>
  401. </el-form-item>
  402. <el-form-item label="打样单号">
  403. <el-input v-model="proofingNo" readonly style="width: 170px;" class="red-text"></el-input>
  404. </el-form-item>
  405. </el-form>
  406. <el-form :inline="true" label-position="top" label-width="80px" :model="this.conclusion" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
  407. <el-form-item label=" ">
  408. <a href="javascript:void(0);" @click="triggerUpload">点击选择文件</a>
  409. <tr></tr>
  410. <el-input v-model="this.fileName" readonly placeholder="文件名称" style="width: 423px"></el-input>
  411. <el-form-item label="文档类型" v-if="isEditable" :rules="rules.noType" prop="noType" style="margin-top: -18px;margin-left: 11px;">
  412. <el-input v-model="noType" :readonly="!isEditable" style="width: 170px" @blur="validateField('noType')" @change="validateField('noType')"></el-input>
  413. </el-form-item>
  414. <el-form-item label="结论" prop="conclusion" v-if="!isMassProductionStage" :rules="rules.conclusion" style="margin-top: -18px;">
  415. <el-select v-model="conclusion" placeholder="请选择" clearable style="width: 110px;" @blur="validateField('conclusion')" @change="validateField('conclusion')">
  416. <el-option
  417. v-for = "i in conclusionList"
  418. :key = "i.conclusion"
  419. :label = "i.conclusion"
  420. :value = "i.conclusion">
  421. </el-option>
  422. </el-select>
  423. </el-form-item>
  424. <el-form-item label="文档种类" style="margin-top: -18px;" v-if="this.id === '-1'">
  425. <el-input readonly style="width: 110px;" :value="documentGroupDescJudgment"></el-input>
  426. </el-form-item>
  427. <el-form-item label="文档种类" style="margin-top: -18px;" v-if="this.id !== '-1'">
  428. <el-input readonly style="width: 110px;" :value="documentGroupDescJudgment"></el-input>
  429. </el-form-item>
  430. <el-button type="primary" @click="upload">上传</el-button>
  431. <el-upload drag :file-list="fileList"
  432. ref="uploadFile"
  433. :on-remove="onRemove" :on-change="onChange"
  434. :on-close="closeFileUpdate"
  435. multiple :auto-upload="false"
  436. :show-file-list="true"
  437. :limit="1"
  438. style="text-align: left;display: none;">
  439. </el-upload>
  440. </el-form-item>
  441. </el-form>
  442. <el-form>
  443. <el-table
  444. :data="proofDocumentList"
  445. border
  446. style="width: 100%;margin-top: 5px;"
  447. height="252"
  448. ref="proofDocumentTable"
  449. @row-click="uploadDocumentClickRow"
  450. @current-change="changeCurrentRow1">
  451. <el-table-column label="文档类型" align="center">
  452. <template slot-scope="scope">
  453. {{ getCombinedDocumentType(scope.row) }}
  454. </template>
  455. </el-table-column>
  456. <el-table-column
  457. v-for="(item,index) in columnFileContentArray" :key="index"
  458. :sortable="item.columnSortable"
  459. :prop="item.columnProp"
  460. :header-align="item.headerAlign"
  461. :show-overflow-tooltip="item.showOverflowTooltip"
  462. :align="item.align"
  463. :fixed="item.fixed==''?false:item.fixed"
  464. :min-width="item.columnWidth"
  465. :label="item.columnLabel">
  466. <template slot-scope="scope">
  467. <span v-if="!item.columnHidden"> {{scope.row[item.columnProp]}}</span>
  468. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
  469. style="width: 100px; height: 80px"/></span>
  470. </template>
  471. </el-table-column>
  472. <el-table-column
  473. header-align="center"
  474. align="center"
  475. width="100"
  476. fixed="right"
  477. label="操作">
  478. <template slot-scope="scope">
  479. <a type="text" size="small" @click="DeleteDocumentType(scope.row)">删除</a>
  480. </template>
  481. </el-table-column>
  482. </el-table>
  483. <!-- <el-form-item label="备注:">-->
  484. <!-- <el-input type="textarea" placeholder="请输入内容" v-model="fileRemark"></el-input>-->
  485. <!-- </el-form-item>-->
  486. </el-form>
  487. <span slot="footer" class="dialog-footer">
  488. <el-button @click="$emit('update:uploadDialog',false);this.fileList = [];this.fileName = '';this.conclusion='';this.noType = '';">关闭</el-button>
  489. </span>
  490. </el-dialog>
  491. </div>
  492. </template>
  493. <style scoped>
  494. /deep/ .el-form-item--medium .el-form-item__content{
  495. height: auto;
  496. }
  497. .red-text /deep/ .el-input__inner {
  498. color: red;
  499. }
  500. </style>