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.

397 lines
13 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. },
  97. computed: {
  98. displayValue() {
  99. if (this.noType === null || this.noType === undefined) {
  100. return this.noDesc
  101. }else {
  102. return this.noType
  103. }
  104. }
  105. },
  106. data () {
  107. return {
  108. //fileRemark: '',
  109. fileName: '',
  110. //选中当前行
  111. documentClickRow: {},
  112. bu : this.props.site + "-" + this.props.buNo,
  113. dataListLoading: false,
  114. }
  115. },
  116. methods: {
  117. triggerUpload() {
  118. this.fileName = ''; // 清空文件名称
  119. this.$refs.uploadFile.clearFiles(); // 清空上传文件列表
  120. this.$emit("update:fileList", []); // 清空文件列表
  121. this.$refs.uploadFile.$el.querySelector('input').click()
  122. },
  123. closeFileUpdate() {
  124. this.$emit('update:uploadDialog', false)
  125. //this.fileRemark = ''
  126. this.$refs.uploadFile.clearFiles()
  127. this.$emit("update:fileList", [])
  128. },
  129. onRemove(file, fileList) {
  130. this.$emit("update:fileList", fileList)
  131. if (fileList.length === 0) {
  132. this.fileName = ''; // 清空文件名称
  133. }
  134. },
  135. onChange(file, fileList) {
  136. this.$emit("update:fileList", fileList)
  137. if (fileList.length > 0) {
  138. this.fileName = fileList[0].name; // 设置文件名称
  139. }
  140. },
  141. upload() {
  142. if (this.fileList.length === 0) {
  143. this.$message.warning("未选择需要上传的文件")
  144. return;
  145. }
  146. let data = new FormData();
  147. data.append("file", this.fileList[0].raw);
  148. data.append("orderRef1", this.$store.state.user.site);
  149. data.append("orderRef2", this.proofingId);
  150. data.append("orderRef3", this.id);
  151. data.append("orderRef4", this.projectId);
  152. data.append("documentDesc", this.no);
  153. data.append("cAdditionalInfo", this.noType);
  154. data.append("createBy", this.$store.state.user.name);
  155. data.append("folder", this.folder);
  156. uploadFileList(this.path, data).then(({data}) => {
  157. if (data && data.code === 0) {
  158. this.$emit('update:uploadDialog', false);
  159. this.$message.success(data.msg);
  160. this.fileList = [];
  161. this.fileName = '';
  162. // this.$emit('get-document-list');
  163. // this.$emit('get-proof-document');
  164. } else {
  165. this.$message.warning(data.msg);
  166. this.fileList = [];
  167. this.fileName = '';
  168. }
  169. }).catch((error) => {
  170. this.$message.error(error);
  171. this.fileList = [];
  172. this.fileName = '';
  173. });
  174. },
  175. changeCurrentRow1 (row, oldRow) {
  176. // 判断是否是获取焦点的事件
  177. if (row) {
  178. this.documentClickRow = JSON.parse(JSON.stringify(row))
  179. }
  180. },
  181. uploadDocumentClickRow(row) {
  182. this.documentClickRow = JSON.parse(JSON.stringify(row))
  183. },
  184. DeleteDocumentType(row) {
  185. this.$confirm('是否删除该文档清单?', '提示', {
  186. confirmButtonText: '确定',
  187. cancelButtonText: '取消',
  188. type: 'warning'
  189. }).then(() => {
  190. deleteDocumentType(row).then(({data}) => {
  191. if (data && data.code === 0) {
  192. this.$message({
  193. message: '删除成功',
  194. type: 'success'
  195. })
  196. //刷新表格
  197. this.getProofDocument();
  198. // this.$emit('get-document-list');
  199. // this.$emit('get-proof-document');
  200. } else {
  201. this.$message({
  202. message: '删除失败',
  203. type: 'error'
  204. })
  205. }
  206. })
  207. }).catch(() => {
  208. this.$message({
  209. type: 'info',
  210. message: '已取消删除'
  211. });
  212. });
  213. },
  214. getProofDocument() {
  215. let tempData = {
  216. site: this.$store.state.user.site,
  217. username: this.$store.state.user.name,
  218. buNo: this.bu,
  219. proofingId: this.proofingId,
  220. projectId: this.projectId,
  221. projectDesc: this.projectDesc,
  222. customerId: this.customerNo,
  223. customerDesc: this.customerDesc,
  224. testPartNo: this.testPartNo,
  225. partDesc: this.partDesc,
  226. page: 1,
  227. limit: 1000
  228. }
  229. getProofDocument(tempData).then(({data}) => {
  230. if (data && data.code === 0) {
  231. this.proofDocumentList = data.page.list
  232. for (let i = 0; i < this.proofDocumentList.length; i++) {
  233. this.proofDocumentList[i].buNo = this.proofDocumenCurrentRow.buNo
  234. }
  235. console.log(this.proofDocumentList)
  236. if (this.totalPage > 0) {
  237. // 设置选中行
  238. this.$refs.proofDocumentTable.setCurrentRow(this.proofDocumentList[0])
  239. // 加载当前的页签的table
  240. this.refreshCurrentTabTable()
  241. this.proofDocumentClickRow = this.proofDocumentList[0]
  242. }
  243. } else {
  244. this.proofDocumentList = []
  245. }
  246. })
  247. },
  248. getCombinedDocumentType(row) {
  249. // 根据您的需求,组合或拼接需要显示的字段
  250. if (row.documentType === null || row.documentType === undefined) {
  251. return row.documentDesc
  252. }
  253. return row.documentType
  254. },
  255. // getDocumentList() {
  256. // getDocumentList(this.modalData).then(({data}) => {
  257. // if (data && data.code === 0) {
  258. // this.documentManifestDefinitionList = data.page.list
  259. // } else {
  260. // this.documentManifestDefinitionList = []
  261. // }
  262. // })
  263. // },
  264. // rowStyle ({row}) {
  265. // if (this.documentClickRow.documentTypeId === row.documentTypeId) {
  266. // return { 'background-color': '#E8F7F6', cursor: 'pointer' };
  267. // }
  268. // },
  269. }
  270. }
  271. </script>
  272. <template>
  273. <div>
  274. <el-dialog :title="title" v-drag @close="closeFileUpdate" :visible="uploadDialog" width="705px" append-to-body :close-on-click-modal="false">
  275. <el-form :inline="true" label-position="top" label-width="80px" style="margin-left: 7px;margin-top: -5px;">
  276. <el-form-item label="项目编码">
  277. <el-input v-model="projectId" readonly style="width: 113px;" class="red-text"></el-input>
  278. </el-form-item>
  279. <el-form-item label="项目名称">
  280. <el-input v-model="projectDesc" readonly style="width: 173px;" class="red-text"></el-input>
  281. </el-form-item>
  282. <el-form-item label="客户编码">
  283. <el-input v-model="customerNo" readonly style="width: 110px;" class="red-text"></el-input>
  284. </el-form-item>
  285. <el-form-item label="客户名称">
  286. <el-input v-model="customerDesc" readonly style="width: 170px;" class="red-text"></el-input>
  287. </el-form-item>
  288. </el-form>
  289. <el-form :inline="true" label-position="top" label-width="80px" style="margin-left: 7px;margin-top: -5px;">
  290. <el-form-item label="项目料号">
  291. <el-input v-model="testPartNo" readonly style="width: 113px;" class="red-text"></el-input>
  292. </el-form-item>
  293. <el-form-item label="料号描述">
  294. <el-input v-model="partDesc" readonly style="width: 173px;" class="red-text"></el-input>
  295. </el-form-item>
  296. <el-form-item label="BU">
  297. <el-input v-model="this.$props.site + '-' + this.$props.bu" readonly style="width: 110px;" class="red-text"></el-input>
  298. </el-form-item>
  299. <el-form-item label="打样单号">
  300. <el-input v-model="proofingId" readonly style="width: 170px;" class="red-text"></el-input>
  301. </el-form-item>
  302. </el-form>
  303. <el-form :inline="true" label-position="top" label-width="80px" style="margin-left: 7px;margin-top: -5px;">
  304. <el-form-item :label="label" v-if="!isEditable">
  305. <el-input v-model="no" :readonly="!isEditable" style="width: 113px" class="red-text"></el-input>
  306. </el-form-item>
  307. <el-form-item label="文档类型" v-if="!isEditable">
  308. <el-input :value="displayValue" :readonly="!isEditable" style="width: 173px" class="red-text"></el-input>
  309. </el-form-item>
  310. </el-form>
  311. <el-form :inline="true" label-position="top" label-width="80px" style="margin-left: 7px;margin-top: -5px;">
  312. <el-form-item label=" ">
  313. <a href="javascript:void(0);" @click="triggerUpload">点击选择文件</a>
  314. <tr></tr>
  315. <el-input v-model="this.fileName" readonly placeholder="文件名称" style="width: 300px"></el-input>
  316. <el-form-item :label="label" v-if="isEditable" style="margin-top: -18px;margin-left: 10px">
  317. <el-input v-model="no" :readonly="!isEditable" style="width: 110px"></el-input>
  318. </el-form-item>
  319. <el-form-item label="文件类型" v-if="isEditable" style="margin-top: -18px">
  320. <el-input v-model="noType" :readonly="!isEditable" style="width: 170px"></el-input>
  321. </el-form-item>
  322. <el-button type="primary" @click="upload">上传</el-button>
  323. <el-upload drag :file-list="fileList"
  324. ref="uploadFile"
  325. :on-remove="onRemove" :on-change="onChange"
  326. :on-close="closeFileUpdate"
  327. multiple :auto-upload="false"
  328. :show-file-list="true"
  329. :limit="1"
  330. style="text-align: left;display: none;">
  331. </el-upload>
  332. </el-form-item>
  333. </el-form>
  334. <el-form>
  335. <el-table
  336. :data="proofDocumentList"
  337. border
  338. style="width: 100%;margin-top: 5px;"
  339. height="252"
  340. ref="proofDocumentTable"
  341. @row-click="uploadDocumentClickRow"
  342. @current-change="changeCurrentRow1">
  343. <el-table-column label="文档类型" align="center">
  344. <template slot-scope="scope">
  345. {{ getCombinedDocumentType(scope.row) }}
  346. </template>
  347. </el-table-column>
  348. <el-table-column
  349. v-for="(item,index) in columnFileContentArray" :key="index"
  350. :sortable="item.columnSortable"
  351. :prop="item.columnProp"
  352. :header-align="item.headerAlign"
  353. :show-overflow-tooltip="item.showOverflowTooltip"
  354. :align="item.align"
  355. :fixed="item.fixed==''?false:item.fixed"
  356. :min-width="item.columnWidth"
  357. :label="item.columnLabel">
  358. <template slot-scope="scope">
  359. <span v-if="!item.columnHidden"> {{scope.row[item.columnProp]}}</span>
  360. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
  361. style="width: 100px; height: 80px"/></span>
  362. </template>
  363. </el-table-column>
  364. <el-table-column
  365. header-align="center"
  366. align="center"
  367. width="100"
  368. fixed="right"
  369. label="操作">
  370. <template slot-scope="scope">
  371. <a type="text" size="small" @click="DeleteDocumentType(scope.row)">删除</a>
  372. </template>
  373. </el-table-column>
  374. </el-table>
  375. <!-- <el-form-item label="备注:">-->
  376. <!-- <el-input type="textarea" placeholder="请输入内容" v-model="fileRemark"></el-input>-->
  377. <!-- </el-form-item>-->
  378. </el-form>
  379. <span slot="footer" class="dialog-footer">
  380. <el-button @click="$emit('update:uploadDialog',false);this.fileName = '';">关闭</el-button>
  381. </span>
  382. </el-dialog>
  383. </div>
  384. </template>
  385. <style scoped>
  386. /deep/ .el-form-item--medium .el-form-item__content{
  387. height: auto;
  388. }
  389. .red-text /deep/ .el-input__inner {
  390. color: red;
  391. }
  392. </style>