upload.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <!--upload申请单上传组件-->
  2. <template>
  3. <div>
  4. <input type="file" class="com-input" @change="update($event,index,apply.id)" accept="image/jpeg,image/jpg,image/gif,image/bmp,image/png,.pdf,.doc,.docx,.xls,.xlsx" />
  5. <div style="margin-left: 100px">
  6. <div v-if="index==0">
  7. <div v-for="(item,index1) in $store.state.fileList0">
  8. <span v-text="item.name"></span>
  9. <span @click="deleteAttach(item.id,0,index1)" class="delete" v-if="apply.status==201 || apply.status==205">
  10. <i class="fa fa-trash"></i>删除
  11. </span>
  12. </div>
  13. </div>
  14. <div v-if="index==1">
  15. <div v-for="(item,index1) in $store.state.fileList1">
  16. <span v-text="item.name"></span>
  17. <span @click="deleteAttach(item.id,1,index1)" class="delete" v-if="apply.status==201 || apply.status==205">
  18. <i class="fa fa-trash"></i>删除
  19. </span>
  20. </div>
  21. </div>
  22. <div v-if="index==2">
  23. <div v-for="(item,index1) in $store.state.fileList2">
  24. <span v-text="item.name"></span>
  25. <span @click="deleteAttach(item.id,2,index1)" class="delete" v-if="apply.status==201 || apply.status==205">
  26. <i class="fa fa-trash"></i>删除
  27. </span>
  28. </div>
  29. </div>
  30. <div v-if="index==3">
  31. <div v-for="(item,index1) in $store.state.fileList3">
  32. <span v-text="item.name"></span>
  33. <span @click="deleteAttach(item.id,3,index1)" class="delete" v-if="apply.status==201 || apply.status==205">
  34. <i class="fa fa-trash"></i>删除
  35. </span>
  36. </div>
  37. </div>
  38. <div v-if="index==4">
  39. <div v-for="(item,index1) in $store.state.fileList4">
  40. <span v-text="item.name"></span>
  41. <span @click="deleteAttach(item.id,4,index1)" class="delete" v-if="apply.status==201 || apply.status==205">
  42. <i class="fa fa-trash"></i>删除
  43. </span>
  44. </div>
  45. </div>
  46. <div v-if="index==5">
  47. <div v-for="(item,index1) in $store.state.fileList5">
  48. <span v-text="item.name"></span>
  49. <span @click="deleteAttach(item.id,5,index1)" class="delete" v-if="apply.status==201 || apply.status==205">
  50. <i class="fa fa-trash"></i>删除
  51. </span>
  52. </div>
  53. </div>
  54. <div v-if="index==6">
  55. <div v-for="(item,index1) in $store.state.fileList6">
  56. <span v-text="item.name"></span>
  57. <span @click="deleteAttach(item.id,6,index1)" class="delete" v-if="apply.status==201 || apply.status==205">
  58. <i class="fa fa-trash"></i>删除
  59. </span>
  60. </div>
  61. </div>
  62. <div v-if="index==7">
  63. <div v-for="(item,index1) in $store.state.fileList7">
  64. <span v-text="item.name"></span>
  65. <span @click="deleteAttach(item.id,7,index1)" class="delete" v-if="apply.status==201 || apply.status==205">
  66. <i class="fa fa-trash"></i>删除
  67. </span>
  68. </div>
  69. </div>
  70. <div v-if="index==8">
  71. <div v-for="(item,index1) in $store.state.fileList8">
  72. <span v-text="item.name"></span>
  73. <span @click="deleteAttach(item.id,8,index1)" class="delete" v-if="apply.status==201 || apply.status==205">
  74. <i class="fa fa-trash"></i>删除
  75. </span>
  76. </div>
  77. </div>
  78. <div v-if="index==9">
  79. <div v-for="(item,index1) in $store.state.fileList9">
  80. <span v-text="item.name"></span>
  81. <span @click="deleteAttach(item.id,9,index1)" class="delete" v-if="apply.status==201 || apply.status==205">
  82. <i class="fa fa-trash"></i>删除
  83. </span>
  84. </div>
  85. </div>
  86. <div v-if="index==10">
  87. <div v-for="(item,index1) in $store.state.fileList10">
  88. <span v-text="item.name"></span>
  89. <span @click="deleteAttach(item.id,10,index1)" class="delete" v-if="apply.status==201 || apply.status==205">
  90. <i class="fa fa-trash"></i>删除
  91. </span>
  92. </div>
  93. </div>
  94. <div v-if="index==11">
  95. <div v-for="(item,index1) in $store.state.fileList11">
  96. <span v-text="item.name"></span>
  97. <span @click="deleteAttach(item.id,11,index1)" class="delete" v-if="apply.status==201 || apply.status==205">
  98. <i class="fa fa-trash"></i>删除
  99. </span>
  100. </div>
  101. </div>
  102. <div v-if="index==12">
  103. <div v-for="(item,index1) in $store.state.fileList12">
  104. <span v-text="item.name"></span>
  105. <span @click="deleteAttach(item.id,12,index1)" class="delete" v-if="apply.status==201 || apply.status==205">
  106. <i class="fa fa-trash"></i>删除
  107. </span>
  108. </div>
  109. </div>
  110. <div v-if="index==13">
  111. <div v-for="(item,index1) in $store.state.fileList13">
  112. <span v-text="item.name"></span>
  113. <span @click="deleteAttach(item.id,13,index1)" class="delete" v-if="apply.status==201 || apply.status==205">
  114. <i class="fa fa-trash"></i>删除
  115. </span>
  116. </div>
  117. </div>
  118. <div v-if="index==14">
  119. <div v-for="(item,index1) in $store.state.fileList14">
  120. <span v-text="item.name"></span>
  121. <span @click="deleteAttach(item.id,14,index1)" class="delete" v-if="apply.status==201 || apply.status==205">
  122. <i class="fa fa-trash"></i>删除
  123. </span>
  124. </div>
  125. </div>
  126. <div v-if="index==15">
  127. <div v-for="(item,index1) in $store.state.fileList15">
  128. <span v-text="item.name"></span>
  129. <span @click="deleteAttach(item.id,15,index1)" class="delete" v-if="apply.status==201 || apply.status==205">
  130. <i class="fa fa-trash"></i>删除
  131. </span>
  132. </div>
  133. </div>
  134. <div v-if="index==16">
  135. <div v-for="(item,index1) in $store.state.fileList16">
  136. <span v-text="item.name"></span>
  137. <span @click="deleteAttach(item.id,16,index1)" class="delete" v-if="apply.status==201 || apply.status==205">
  138. <i class="fa fa-trash"></i>删除
  139. </span>
  140. </div>
  141. </div>
  142. <div v-if="index==17">
  143. <div v-for="(item,index1) in $store.state.fileList17">
  144. <span v-text="item.name"></span>
  145. <span @click="deleteAttach(item.id,17,index1)" class="delete" v-if="apply.status==201 || apply.status==205">
  146. <i class="fa fa-trash"></i>删除
  147. </span>
  148. </div>
  149. </div>
  150. <div v-if="index==18">
  151. <div v-for="(item,index1) in $store.state.fileList18">
  152. <span v-text="item.name"></span>
  153. <span @click="deleteAttach(item.id,18,index1)" class="delete" v-if="apply.status==201 || apply.status==205">
  154. <i class="fa fa-trash"></i>删除
  155. </span>
  156. </div>
  157. </div>
  158. <div v-if="index==19">
  159. <div v-for="(item,index1) in $store.state.fileList19">
  160. <span v-text="item.name"></span>
  161. <span @click="deleteAttach(item.id,19,index1)" class="delete" v-if="apply.status==201 || apply.status==205">
  162. <i class="fa fa-trash"></i>删除
  163. </span>
  164. </div>
  165. </div>
  166. <div v-if="index==20">
  167. <div v-for="(item,index1) in $store.state.fileList20">
  168. <span v-text="item.name"></span>
  169. <span @click="deleteAttach(item.id,20,index1)" class="delete" v-if="apply.status==201 || apply.status==205">
  170. <i class="fa fa-trash"></i>删除
  171. </span>
  172. </div>
  173. </div>
  174. <div v-if="index==21">
  175. <div v-for="(item,index1) in $store.state.fileList21">
  176. <span v-text="item.name"></span>
  177. <span @click="deleteAttach(item.id,21,index1)" class="delete" v-if="apply.status==201 || apply.status==205">
  178. <i class="fa fa-trash"></i>删除
  179. </span>
  180. </div>
  181. </div>
  182. <div v-if="index==22">
  183. <div v-for="(item,index1) in $store.state.fileList22">
  184. <span v-text="item.name"></span>
  185. <span @click="deleteAttach(item.id,22,index1)" class="delete" v-if="apply.status==201 || apply.status==205">
  186. <i class="fa fa-trash"></i>删除
  187. </span>
  188. </div>
  189. </div>
  190. </div>
  191. </div>
  192. </template>
  193. <script>
  194. export default{
  195. data(){
  196. return{
  197. attach: {id: '', type: '', applyid: '', name: '', path: '', size: ''},
  198. isShow: false,
  199. isPdf: false
  200. }
  201. },
  202. props: ['index', 'apply'],
  203. methods:{
  204. update: function (e, index, applyid) {
  205. let file = e.target.files[0]
  206. this.attach.name = file.name;
  207. this.attach.applyid = applyid;
  208. if (index == 0) {
  209. this.attach.type = '保理业务申请书';
  210. } else if (index == 1) {
  211. this.attach.type = '营业执照正副本';
  212. } else if (index == 2) {
  213. this.attach.type = '开户许可证';
  214. } else if (index == 3) {
  215. this.attach.type = '法人代表身份证';
  216. } else if (index == 4) {
  217. this.attach.type = '实际控制人身份证'
  218. } else if (index == 5) {
  219. this.attach.type = '法人代表证明书'
  220. } else if (index == 6) {
  221. this.attach.type = '公司章程'
  222. } else if (index == 7) {
  223. this.attach.type = '实际控制人征信授权书'
  224. } else if (index == 8) {
  225. this.attach.type = '租赁合同/房产证'
  226. } else if (index == 9) {
  227. this.attach.type = '法定代表人和实际控制人简历(Word版)'
  228. } else if (index == 10) {
  229. this.attach.type = '近三年财务报表和近一期月度财报(含资产负债表、损益表、现金流量表)'
  230. } else if (index == 11) {
  231. this.attach.type = '前五大上游企业贸易合同(两份)'
  232. } else if (index == 12) {
  233. this.attach.type = '前五大下游企业贸易合同(两份)'
  234. } else if (index == 13) {
  235. this.attach.type = '近1年税控系统导出的增值税发票清单(Excel版)'
  236. } else if (index == 14) {
  237. this.attach.type = '近一年最大的五份贸易合同'
  238. } else if (index == 15) {
  239. this.attach.type = '税控系统导出近一年全部发票(Excel版)'
  240. } else if (index == 16) {
  241. this.attach.type = '公司人行征信报告及对外担保信息'
  242. } else if (index == 17) {
  243. this.attach.type = '上一年度增值税(营业税)、所得税纳税证明'
  244. } else if (index == 18) {
  245. this.attach.type = '企业近1年主要结算银行流水'
  246. } else if (index == 19) {
  247. this.attach.type = '个人近1年主要结算银行流水'
  248. } else if (index == 20) {
  249. this.attach.type = '近三个月水电费单据'
  250. } else if (index == 21) {
  251. this.attach.type = '其他'
  252. } else if (index == 22) {
  253. this.attach.type = '担保人的人行征信报告及对外担保信息'
  254. }
  255. let param = new FormData()
  256. param.append('file', file)
  257. // param.append('attach',JSON.stringify(this.attach))
  258. param.append('type', this.attach.type)
  259. param.append('applyId', this.attach.applyid)
  260. param.append('chunk', '0')
  261. let _this = this
  262. let config = {
  263. headers: {'Content-Type': 'multipart/form-data'}
  264. }
  265. return this.$axios.post('/attach/upload', param, config)
  266. .then(response => {
  267. if(response.data.type == '保理业务申请书'){
  268. this.$store.state.fileList0.push(response.data)
  269. }else if (response.data.type == '营业执照正副本') {
  270. this.$store.state.fileList1.push(response.data)
  271. } else if (response.data.type == '开户许可证') {
  272. this.$store.state.fileList2.push(response.data)
  273. } else if (response.data.type == '法人代表身份证') {
  274. this.$store.state.fileList3.push(response.data)
  275. } else if (response.data.type == '实际控制人身份证') {
  276. this.$store.state.fileList4.push(response.data)
  277. } else if (response.data.type == '法人代表证明书') {
  278. this.$store.state.fileList5.push(response.data)
  279. } else if (response.data.type == '公司章程') {
  280. this.$store.state.fileList6.push(response.data)
  281. } else if (response.data.type == '实际控制人征信授权书' ) {
  282. this.$store.state.fileList7.push(response.data)
  283. } else if (response.data.type == '租赁合同/房产证') {
  284. this.$store.state.fileList8.push(response.data)
  285. } else if (response.data.type == '法定代表人和实际控制人简历(Word版)'){
  286. this.$store.state.fileList9.push(response.data)
  287. } else if (response.data.type == '近三年财务报表和近一期月度财报(含资产负债表、损益表、现金流量表)'){
  288. this.$store.state.fileList10.push(response.data)
  289. } else if (response.data.type == '前五大上游企业贸易合同(两份)') {
  290. this.$store.state.fileList11.push(response.data)
  291. } else if (response.data.type == '前五大下游企业贸易合同(两份)') {
  292. this.$store.state.fileList12.push(response.data)
  293. } else if (response.data.type == '近1年税控系统导出的增值税发票清单(Excel版)') {
  294. this.$store.state.fileList13.push(response.data)
  295. } else if (response.data.type == '近一年最大的五份贸易合同') {
  296. this.$store.state.fileList14.push(response.data)
  297. } else if (response.data.type == '税控系统导出近一年全部发票(Excel版)') {
  298. this.$store.state.fileList15.push(response.data)
  299. } else if (response.data.type == '公司人行征信报告及对外担保信息') {
  300. this.$store.state.fileList16.push(response.data)
  301. } else if (response.data.type == '上一年度增值税(营业税)、所得税纳税证明') {
  302. this.$store.state.fileList17.push(response.data)
  303. } else if (response.data.type == '企业近1年主要结算银行流水') {
  304. this.$store.state.fileList18.push(response.data)
  305. } else if (response.data.type == '个人近1年主要结算银行流水') {
  306. this.$store.state.fileList19.push(response.data)
  307. } else if (response.data.type == '近三个月水电费单据') {
  308. this.$store.state.fileList20.push(response.data)
  309. } else if (response.data.type == '其他') {
  310. this.$store.state.fileList21.push(response.data)
  311. } else if (response.data.type == '担保人的人行征信报告及对外担保信息') {
  312. this.$store.state.fileList22.push(response.data)
  313. }
  314. }).catch(function(error){
  315. alert('上传失败')
  316. })
  317. },
  318. deleteAttach: function (id, index, index1) {
  319. let _this = this;
  320. var params = new URLSearchParams();
  321. params.append('id',id)
  322. return this.$axios.post('/attach/delete', params)
  323. .then(function () {
  324. switch (index) {
  325. case 0:
  326. _this.$store.state.fileList0.splice(index1, 1)
  327. break;
  328. case 1:
  329. _this.$store.state.fileList1.splice(index1, 1)
  330. break;
  331. case 2:
  332. _this.$store.state.fileList2.splice(index1, 1)
  333. break;
  334. case 3:
  335. _this.$store.state.fileList3.splice(index1, 1)
  336. break;
  337. case 4:
  338. _this.$store.state.fileList4.splice(index1, 1)
  339. break;
  340. case 5:
  341. _this.$store.state.fileList5.splice(index1, 1)
  342. break;
  343. case 6:
  344. _this.$store.state.fileList6.splice(index1, 1)
  345. break;
  346. case 7:
  347. _this.$store.state.fileList7.splice(index1, 1)
  348. break;
  349. case 8:
  350. _this.$store.state.fileList8.splice(index1, 1)
  351. break;
  352. case 9:
  353. _this.$store.state.fileList9.splice(index1, 1)
  354. break;
  355. case 10:
  356. _this.$store.state.fileList10.splice(index1, 1)
  357. break;
  358. case 11:
  359. _this.$store.state.fileList11.splice(index1, 1)
  360. break;
  361. case 12:
  362. _this.$store.state.fileList12.splice(index1, 1)
  363. break;
  364. case 13:
  365. _this.$store.state.fileList13.splice(index1, 1)
  366. break;
  367. case 14:
  368. _this.$store.state.fileList14.splice(index1, 1)
  369. break;
  370. case 15:
  371. _this.$store.state.fileList15.splice(index1, 1)
  372. break;
  373. case 16:
  374. _this.$store.state.fileList16.splice(index1, 1)
  375. break;
  376. case 17:
  377. _this.$store.state.fileList17.splice(index1, 1)
  378. break;
  379. case 18:
  380. _this.$store.state.fileList18.splice(index1, 1)
  381. break;
  382. case 19:
  383. _this.$store.state.fileList19.splice(index1, 1)
  384. break;
  385. case 20:
  386. _this.$store.state.fileList20.splice(index1, 1)
  387. break;
  388. case 21:
  389. _this.$store.state.fileList21.splice(index1, 1)
  390. break;
  391. case 22:
  392. _this.$store.state.fileList22.splice(index1, 1)
  393. break;
  394. }
  395. }).catch(function (error) {
  396. alert(error)
  397. })
  398. },
  399. isIdRepeat (arr = [], idx) {
  400. let flag = false
  401. for (let i = 0; i < arr.length; i++) {
  402. if (arr[i].id === arr[idx].id && i < idx) {
  403. flag = true
  404. break
  405. }
  406. }
  407. return flag
  408. }
  409. }
  410. }
  411. </script>