InvoiceReimbursementUpLoadComponent.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. <!--文件上传组件-->
  2. <template>
  3. <div :key="uploadKey">
  4. <el-divider v-if="showDivider" content-position="left"><i class="el-icon-document"></i> {{dividerName}} </el-divider>
  5. <el-upload ref="upload" style="display: inline-block; :show-header='status'" action=""
  6. :limit="999" :http-request="httpRequest"
  7. multiple
  8. :on-exceed="(files, fileList) =>{
  9. $message.warning(`当前限制选择 999 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`)
  10. }"
  11. :show-file-list="false"
  12. :before-upload="beforeUpload"
  13. :on-change="changes"
  14. :on-progress="uploadVideoProcess"
  15. :file-list="fileList">
  16. <template v-if="auth==='view'&&uploadFlag===false" #tip>
  17. <el-button :loading="loading" type="primary" size="default" :disabled="true"> 点击上传 </el-button>
  18. </template>
  19. <template v-else #trigger>
  20. <el-button :loading="loading" type="primary" size="default"> 点击上传 </el-button> <span style="margin-left: 20px;font-size:14px;font-weight:normal;color:red;" type="primary"> 上传报销的数电发票xml文件</span>
  21. </template>
  22. </el-upload>
  23. <div style="height: calc(100% - 80px);margin-top: 10px">
  24. <!-- 进度条 -->
  25. <el-progress style="margin-left: 5em" v-if="progressFlag" :percentage="loadProgress"></el-progress>
  26. <el-table
  27. ref="uploadTable"
  28. v-loading="loading"
  29. :key="tableKey"
  30. :data="dataListNew">
  31. <el-table-column type="seq" width="40"></el-table-column>
  32. <el-table-column label="文件名称" prop="name" align="center">
  33. <template #default="scope">
  34. <div v-if="ifName(scope.row) === true">
  35. <el-image
  36. style="width: 30px; height: 30px;padding-top: 4px;"
  37. :src="scope.row.lsUrl"
  38. :preview-src-list="[scope.row.lsUrl]"
  39. :preview-teleported="true"
  40. ></el-image>
  41. </div>
  42. <div v-else>
  43. <el-link type="primary" :underline="false" @click="showFile(scope.row)">{{scope.row.name}}</el-link>
  44. </div>
  45. </template>
  46. </el-table-column>
  47. <el-table-column label="创建人" prop="createBy.name" align="center"></el-table-column>
  48. <el-table-column label="创建时间" prop="createTime" align="center"></el-table-column>
  49. <el-table-column label="文件大小" prop="size" align="center">
  50. <template #default="scope">
  51. {{getSize(scope.row.size)}}
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="操作" width="200px" fixed="right" align="center">
  55. <template #default="scope">
  56. <el-button text type="primary" key="01" icon="el-icon-download" size="small" @click="toHref(scope.row)" >下载</el-button>
  57. <el-button text type="primary" key="02" icon="el-icon-delete" size="small" @click="deleteById(scope.row, scope.$index,fileList)" :disabled="auth==='view'&&delFlag === false&&createBy!==scope.row.createBy.name">删除</el-button>
  58. <!-- <el-button v-if="createBy===scope.row.createBy.name" type="text" icon="el-icon-delete" size="small" @click="deleteById(scope.row, scope.$index)" :disabled="auth==='view'&&delFlag === false">删除2</el-button>-->
  59. </template>
  60. </el-table-column>
  61. </el-table>
  62. </div>
  63. <!-- <el-image-viewer v-if="showViewer" :on-close="closeViewer" :url-list="[url]" :zIndex=9999></el-image-viewer>-->
  64. </div>
  65. </template>
  66. <script>
  67. // eslint-disable-next-line no-unused-vars
  68. import OSSSerivce, {
  69. httpRequest,
  70. // eslint-disable-next-line no-unused-vars
  71. handleRemove,
  72. fileNameInvoice,
  73. // eslint-disable-next-line no-unused-vars
  74. beforeAvatarUpload,
  75. exnameFix,
  76. // eslint-disable-next-line no-unused-vars
  77. openWindowOnUrl,
  78. // eslint-disable-next-line no-unused-vars
  79. toHref
  80. } from '@/api/sys/OSSService'
  81. // import ElImageViewer from 'element-ui/packages/image/src/image-viewer'
  82. import moment from 'moment'
  83. export default {
  84. data () {
  85. return {
  86. uploadKey: '',
  87. progressFlag: false,
  88. loadProgress: 0,
  89. fileList: [],
  90. dataList: [],
  91. oldDataList: [],
  92. dataListNew: [],
  93. url: '',
  94. showViewer: false,
  95. ossService: null,
  96. auth: '',
  97. directory: 'public',
  98. maxValue: 300,
  99. tableKey: '',
  100. fileLoading: true,
  101. dividerName: '',
  102. uploadFlag: false,
  103. delFlag: false,
  104. createBy: '',
  105. showDivider: true,
  106. loading: false,
  107. dataListLength: '',
  108. uploadDelFlag: false
  109. }
  110. },
  111. watch: {
  112. },
  113. created () {
  114. this.ossService = new OSSSerivce()
  115. },
  116. components: {
  117. // ElImageViewer
  118. },
  119. mounted () {
  120. window.onPreview = this.onPreview
  121. },
  122. methods: {
  123. /**
  124. * dividerName: 组件中divider的名称赋值
  125. * showDivider: ‘附件‘Divider是否展示
  126. * 注:值为空时,默认值为true
  127. * showDivider=false时 ‘附件‘Divider隐藏
  128. **/
  129. setDividerName (dividerName, showDivider) {
  130. if (this.commonJS.isNotEmpty(dividerName)) {
  131. this.dividerName = dividerName
  132. }
  133. if (this.commonJS.isNotEmpty(showDivider)) {
  134. if (showDivider === false) {
  135. this.showDivider = false
  136. } else {
  137. this.showDivider = true
  138. }
  139. } else {
  140. this.showDivider = true
  141. }
  142. },
  143. /**
  144. * 文件上传组件初始化
  145. * @param auth
  146. * auth的值为"view"时,不可上传/编辑文件
  147. * auth为其他值时,可上传/编辑文件
  148. * @param fileList 要显示到文件上传列表中的文件。
  149. * 注:文件必须要有url属性并且文件的url属性值必须是在oss中的路径值
  150. * 例:'/attachment-file/xxx/xxx/2022/9/08/xxx.jpg'
  151. * @param directory 要存放到oss的哪个文件夹下。
  152. * 注:值为空时,默认存放到"public"文件夹
  153. * @param maxValue 上传文件允许的最大值,单位:MB
  154. * 注:值为空时,默认值为300MB
  155. * @param dividerName 组件中divider的名称
  156. * 注:值为空时,默认值为‘附件’
  157. * @param uploadFlag ‘上传文件’按钮是否禁用
  158. * 注:值为空时,默认值为false
  159. * auth=view&&uploadFlag=false时 ‘上传文件’按钮禁用
  160. * @param delFlag ‘删除’按钮是否禁用
  161. * 注:值为空时,默认值为false
  162. * auth=view&&delFlag=false时 ‘删除’按钮禁用
  163. * @param showDivider ‘附件‘Divider是否展示
  164. * 注:值为空时,默认值为true
  165. * showDivider=false时 ‘附件‘Divider隐藏
  166. */
  167. async newUpload (auth, fileList, directory, maxValue, dividerName, uploadFlag, delFlag, showDivider) {
  168. this.uploadKey = Math.random()
  169. await this.fileLoadingFalse()
  170. if (this.commonJS.isEmpty(fileList)) {
  171. fileList = []
  172. this.fileLoading = true
  173. } else {
  174. this.dataListLength = fileList.length
  175. }
  176. if (this.commonJS.isEmpty(dividerName)) {
  177. this.dividerName = '附件'
  178. } else {
  179. this.dividerName = dividerName
  180. }
  181. if (directory !== undefined && directory !== null && directory !== '' && directory !== {}) {
  182. this.directory = directory
  183. } else {
  184. this.directory = 'public'
  185. }
  186. if (maxValue !== undefined && maxValue !== null && maxValue !== '' && maxValue !== 0) {
  187. this.maxValue = maxValue
  188. } else {
  189. this.maxValue = 300
  190. }
  191. this.auth = auth
  192. if (this.commonJS.isEmpty(uploadFlag)) {
  193. this.uploadFlag = false
  194. } else {
  195. if (uploadFlag !== true && uploadFlag !== false) {
  196. this.uploadFlag = false
  197. } else {
  198. this.uploadFlag = uploadFlag
  199. }
  200. }
  201. if (this.commonJS.isEmpty(delFlag)) {
  202. this.delFlag = false
  203. } else {
  204. if (delFlag !== true && delFlag !== false) {
  205. this.delFlag = false
  206. this.createBy = delFlag
  207. } else {
  208. this.delFlag = delFlag
  209. }
  210. }
  211. this.oldDataList = []
  212. for await (let item of fileList) {
  213. await this.ossService.getFileSizeByUrl(item.url).then((data) => {
  214. item.lsUrl = data.url
  215. item.size = data.size
  216. this.dataList.push(item)
  217. this.oldDataList.push(item)
  218. this.dataListNew.push(item)
  219. if (this.dataListNew.length === fileList.length) {
  220. this.fileLoading = true
  221. }
  222. })
  223. }
  224. // this.dataList = JSON.parse(JSON.stringify(fileList))
  225. // this.dataListNew = JSON.parse(JSON.stringify(fileList))
  226. if (this.commonJS.isEmpty(showDivider)) {
  227. this.showDivider = true
  228. } else {
  229. if (showDivider === false) {
  230. this.showDivider = false
  231. } else {
  232. this.showDivider = true
  233. }
  234. }
  235. },
  236. async httpRequest (file) {
  237. await httpRequest(file, fileNameInvoice(file), this.directory, this.maxValue)
  238. },
  239. async beforeUpload(file) {
  240. if(this.uploadDelFlag){
  241. this.$message.warning('该文件已上传,请勿重复上传');
  242. this.uploadKey = Math.random()
  243. return true; // 取消上传
  244. }else{
  245. // 对文件进行判定
  246. const isXml = file.type === 'text/xml'; // 假设只接受 XML 文件
  247. if (!isXml) {
  248. this.$message.error('只能上传 XML 文件');
  249. return false; // 取消上传
  250. }else{
  251. try {
  252. //对上传的xml文件信息进行处理并通过后端接口进行解析返回到父页面进行调整
  253. const formBody = new FormData()
  254. formBody.append('file', file)
  255. await this.ossService.disposeXmlFile(formBody).then((data) => {
  256. if(Object.keys(data).length === 0){
  257. this.$message.warning('上传的数电发票格式错误');
  258. this.loading = false;
  259. // 在验证失败时删除已经添加的行
  260. const index = this.fileList.findIndex(item => item.name === file.name);
  261. if (index !== -1) {
  262. this.deleteFileById(this.fileList[index], index, this.fileList);
  263. }
  264. }else{
  265. let parent = this.$parent
  266. while (!parent.invoiceReimbursementDispose) {
  267. parent = parent['$parent']
  268. }
  269. var flag = parent.invoiceReimbursementDispose(data)
  270. //var flag = this.$parent.invoiceReimbursementDispose(data);
  271. if(!flag){
  272. this.httpRequest(file);
  273. }else{
  274. this.$message.error('发票号:' + data.InvoiceNumber + "已上传,请勿重复上传")
  275. // 在验证失败时删除已经添加的行
  276. const index = this.dataListNew.findIndex(item => item.name === file.name);
  277. if (index !== -1) {
  278. this.deleteFileById(this.dataListNew[index], index, this.dataListNew);
  279. }
  280. this.loading = false;
  281. }
  282. }
  283. })
  284. } catch (error) {
  285. console.error(error);
  286. }
  287. }
  288. // 其他判定逻辑...
  289. return true; // 允许上传
  290. }
  291. },
  292. uploadVideoProcess (event, file, fileList) {
  293. let parent = this.$parent
  294. while (!parent.inputForm) {
  295. parent = parent['$parent']
  296. }
  297. var reimbursementType = parent.inputForm.reimbursementType
  298. this.progressFlag = true // 显示进度条
  299. this.loadProgress = parseInt(event.percent) // 动态获取文件上传进度
  300. if (this.loadProgress >= 100) {
  301. this.loadProgress = 100
  302. if("1" === reimbursementType){
  303. var fileName = file.raw.name;
  304. const spliceLength2 = fileName.lastIndexOf(".");
  305. var fileNameSuffix = fileName.slice(spliceLength2 + 1);
  306. if(fileNameSuffix === "xml" ) {
  307. //对上传的xml文件信息进行处理并通过后端接口进行解析返回到父页面进行调整
  308. const formBody = new FormData()
  309. formBody.append('file', file.raw)
  310. this.ossService.disposeXmlFile(formBody).then((data) => {
  311. if(Object.keys(data).length > 0){
  312. parent.invoiceReimbursementDisposeData(data,file)
  313. }else{
  314. this.$message.warning('上传的数电发票格式错误')
  315. this.loading = false;
  316. // 在验证失败时删除已经添加的行
  317. const index = this.fileList.findIndex(item => item.name === file.name);
  318. if (index !== -1) {
  319. this.deleteFileById(this.fileList[index], index, this.fileList);
  320. }
  321. }
  322. })
  323. }
  324. }
  325. setTimeout(() => {
  326. this.progressFlag = false
  327. }, 1000) // 一秒后关闭进度条
  328. }
  329. },
  330. getSize (value) {
  331. if (this.commonJS.isEmpty(value)) {
  332. return '0 B'
  333. } else {
  334. let val = parseInt(value)
  335. if (this.commonJS.isEmpty(val)) {
  336. return '0 B'
  337. }
  338. if (isNaN(val)) {
  339. return '0 B'
  340. }
  341. if (val === 0) {
  342. return '0 B'
  343. }
  344. let k = 1024
  345. let sizes = ['B', 'KB', 'MB', 'GB', 'PB', 'TB', 'EB', 'ZB', 'YB']
  346. let i = Math.floor(Math.log(val) / Math.log(k))
  347. let result = val / Math.pow(k, i);
  348. let kb = parseFloat(result.toPrecision(3));
  349. return kb + '' + sizes[i]
  350. }
  351. },
  352. async changes (file, fileList) {
  353. this.uploadKey = Math.random()
  354. console.log(fileList)
  355. for (let i = 0; i < fileList.length; i++) {
  356. var fileItem = fileList[i];
  357. if(fileList[i].raw !== undefined && fileList[i].raw !== null && fileList[i].raw !== {}){
  358. fileItem = fileList[i].raw;
  359. }
  360. const isXml = fileItem.type === 'text/xml'; // 假设只接受 XML 文件
  361. if (!isXml) {
  362. console.log("删除该文件")
  363. //fileList[i].remove()
  364. fileList.splice(i, 1);
  365. // Since the element is removed, decrease the index by 1 to adjust for the removed element
  366. i--;
  367. }
  368. }
  369. this.uploadDelFlag = false;
  370. // if (file.status !== 'ready') {
  371. // return
  372. // }
  373. if (!beforeAvatarUpload(file, fileList, this.maxValue)) {
  374. this.$message.error('文件大小不能超过 ' + this.maxValue + ' MB!')
  375. return
  376. }
  377. var verificationFileList = []
  378. if(this.oldDataList){
  379. for (let item of this.oldDataList) {
  380. verificationFileList.push(item)
  381. }
  382. }
  383. for (let item of fileList) {
  384. verificationFileList.push(item)
  385. }
  386. var fileCount = 0;
  387. for (let item of verificationFileList) {
  388. var fileItem = item;
  389. if(item.raw !== undefined && item.raw !== null && item.raw !== {}){
  390. fileItem = item.raw;
  391. }
  392. if(file.raw.name === fileItem.name){
  393. fileCount ++
  394. }
  395. }
  396. if(fileCount>1){
  397. this.uploadDelFlag = true;
  398. return
  399. }
  400. this.dataListNew = []
  401. this.dataList.forEach((item) => {
  402. this.dataListNew.push(item)
  403. })
  404. var fileListNames = []
  405. for (let fileItem of this.fileList) {
  406. fileListNames.push(fileItem.name)
  407. }
  408. for (let item of fileList) {
  409. if(fileListNames.length === 0 || fileListNames.indexOf(item.name) === -1){
  410. this.fileList.push(item)
  411. }
  412. item.createTime = moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
  413. item.createBy = {
  414. id: '',
  415. name: ''
  416. }
  417. item.createBy.id = this.$store.state.user.id
  418. item.createBy.name = this.$store.state.user.name
  419. this.dataListNew.push(item)
  420. }
  421. for (let item of this.dataListNew) {
  422. if (item.raw !== undefined && item.raw !== null && item.raw !== {}) {
  423. item.url = item.raw.url
  424. if (item.raw.url !== undefined && item.raw.url !== null && item.raw.url !== {}) {
  425. this.ossService.getTemporaryUrl(item.raw.url).then((data) => {
  426. item.lsUrl = data
  427. })
  428. }
  429. }
  430. }
  431. },
  432. showFile (row) {
  433. openWindowOnUrl(row)
  434. },
  435. onPreview (url) {
  436. this.url = url
  437. this.showViewer = true
  438. },
  439. // 关闭查看器
  440. closeViewer () {
  441. this.url = ''
  442. this.showViewer = false
  443. },
  444. toHref (row) {
  445. toHref(row)
  446. },
  447. async deleteById (row, index,fileList) {
  448. console.log("dasfgasdas")
  449. // this.$refs.upload.handleRemove(this.dataListNew[index])
  450. await this.dataListNew.splice(index, 1)
  451. await this.dataList.splice(index, 1)
  452. if (this.commonJS.isNotEmpty(row.id)) {
  453. this.ossService.deleteMsgById(row.id)
  454. }
  455. var newFileList = [];
  456. for (var i = 0; i < fileList.length; i++) {
  457. if (fileList[i].name !== row.name) {
  458. newFileList.push(fileList[i])
  459. }
  460. }
  461. this.fileList = newFileList;
  462. let parent = this.$parent
  463. while (!parent.inputForm) {
  464. parent = parent['$parent']
  465. }
  466. var reimbursementType = parent.inputForm.reimbursementType
  467. if("1" === reimbursementType){
  468. var fileName = ''
  469. if(null === row.raw || undefined === row.raw){
  470. fileName = row.name;
  471. }else{
  472. fileName = row.raw.name;
  473. }
  474. const spliceLength2 = fileName.lastIndexOf(".");
  475. var fileNameSuffix = fileName.slice(spliceLength2 + 1);
  476. if(fileNameSuffix === "xml" ) {
  477. //对上传的xml文件信息进行处理并通过后端接口进行解析返回到父页面进行调整
  478. const formBody = new FormData()
  479. if(null === row.raw || undefined === row.raw){
  480. this.ossService.downLoadFileDisposeXmlFile(row.url).then((data) => {
  481. parent.deleteInvoiceReimbursementDisposeData(data)
  482. })
  483. }else{
  484. formBody.append('file', row.raw)
  485. this.ossService.disposeXmlFile(formBody).then((data) => {
  486. if(data){
  487. parent.deleteInvoiceReimbursementDisposeData(data)
  488. }else{
  489. this.$message.warning('上传的数电发票格式错误')
  490. this.loading = false;
  491. // 在验证失败时删除已经添加的行
  492. const index = this.fileList.findIndex(item => item.name === file.name);
  493. if (index !== -1) {
  494. this.deleteFileById(this.fileList[index], index, this.fileList);
  495. }
  496. }
  497. })
  498. }
  499. }
  500. }
  501. },
  502. async deleteFileById (row, index,fileList) {
  503. // this.$refs.upload.handleRemove(this.dataListNew[index])
  504. await this.dataListNew.splice(index, 1)
  505. await this.dataList.splice(index, 1)
  506. if (this.commonJS.isNotEmpty(row.id)) {
  507. this.ossService.deleteMsgById(row.id)
  508. }
  509. var newFileList = [];
  510. for (var i = 0; i < fileList.length; i++) {
  511. if (fileList[i].name !== row.name) {
  512. newFileList.push(fileList[i])
  513. }
  514. }
  515. this.fileList = newFileList;
  516. let parent = this.$parent
  517. while (!parent.inputForm) {
  518. parent = parent['$parent']
  519. }
  520. var reimbursementType = parent.inputForm.reimbursementType
  521. if("1" === reimbursementType){
  522. var fileName = ''
  523. if(null === row.raw || undefined === row.raw){
  524. fileName = row.name;
  525. }else{
  526. fileName = row.raw.name;
  527. }
  528. const spliceLength2 = fileName.lastIndexOf(".");
  529. var fileNameSuffix = fileName.slice(spliceLength2 + 1);
  530. if(fileNameSuffix === "xml" ) {
  531. //对上传的xml文件信息进行处理并通过后端接口进行解析返回到父页面进行调整
  532. const formBody = new FormData()
  533. if(null === row.raw || undefined === row.raw){
  534. this.ossService.downLoadFileDisposeXmlFile(row.url).then((data) => {
  535. //parent.deleteInvoiceReimbursementDisposeData(data)
  536. })
  537. }else{
  538. formBody.append('file', row.raw)
  539. this.ossService.disposeXmlFile(formBody).then((data) => {
  540. if(data){
  541. //parent.deleteInvoiceReimbursementDisposeData(data)
  542. }else{
  543. this.$message.warning('上传的数电发票格式错误')
  544. this.loading = false;
  545. // 在验证失败时删除已经添加的行
  546. const index = this.fileList.findIndex(item => item.name === file.name);
  547. if (index !== -1) {
  548. this.deleteFileById(this.fileList[index], index, this.fileList);
  549. }
  550. }
  551. })
  552. }
  553. }
  554. }
  555. },
  556. async parentDeleteById (row) {
  557. console.log('this.dataListNew',this.dataListNew)
  558. var index = null;
  559. for (var j = 0; j < this.dataListNew.length; j++) {
  560. if (this.dataListNew[j].name === row.name) {
  561. index = j;
  562. }
  563. }
  564. await this.dataListNew.splice(index, 1)
  565. await this.dataList.splice(index, 1)
  566. if (this.commonJS.isNotEmpty(row.id)) {
  567. this.ossService.deleteMsgById(row.id)
  568. }
  569. var newFileList = [];
  570. for (var i = 0; i < this.fileList.length; i++) {
  571. if (this.fileList[i].name !== row.name) {
  572. newFileList.push(this.fileList[i])
  573. }
  574. }
  575. this.fileList = newFileList;
  576. let parent = this.$parent
  577. while (!parent.inputForm) {
  578. parent = parent['$parent']
  579. }
  580. var reimbursementType = parent.inputForm.reimbursementType
  581. if("1" === reimbursementType){
  582. var fileName = ''
  583. if(null === row.raw || undefined === row.raw){
  584. fileName = row.name;
  585. }else{
  586. fileName = row.raw.name;
  587. }
  588. const spliceLength2 = fileName.lastIndexOf(".");
  589. var fileNameSuffix = fileName.slice(spliceLength2 + 1);
  590. if(fileNameSuffix === "xml" ) {
  591. //对上传的xml文件信息进行处理并通过后端接口进行解析返回到父页面进行调整
  592. const formBody = new FormData()
  593. if(null === row.raw || undefined === row.raw){
  594. this.ossService.downLoadFileDisposeXmlFile(row.url).then((data) => {
  595. parent.deleteInvoiceReimbursementDisposeData(data)
  596. })
  597. }else{
  598. formBody.append('file', row.raw)
  599. this.ossService.disposeXmlFile(formBody).then((data) => {
  600. parent.deleteInvoiceReimbursementDisposeData(data)
  601. })
  602. }
  603. }
  604. }
  605. },
  606. async deleteFileinfo (row) {
  607. var index = null;
  608. for (var j = 0; j < this.dataListNew.length; j++) {
  609. if (this.dataListNew[j].name === row.name) {
  610. index = j;
  611. }
  612. }
  613. await this.dataListNew.splice(index, 1)
  614. await this.dataList.splice(index, 1)
  615. var newFileList = [];
  616. for (var i = 0; i < this.fileList.length; i++) {
  617. if (this.fileList[i].name !== row.name) {
  618. newFileList.push(this.fileList[i])
  619. }
  620. }
  621. this.fileList = newFileList;
  622. },
  623. /**
  624. * 关闭dialog时使用 清除el-upload中上传的文件
  625. */
  626. clearUpload () {
  627. this.fileList = []//用于清除上传文件的缓存
  628. this.$refs.upload.clearFiles()
  629. this.dataList = []
  630. this.dataListNew = []
  631. this.createBy = ''
  632. },
  633. /**
  634. * 获取当前文件列表中的文件数据
  635. */
  636. getDataList () {
  637. return this.dataListNew
  638. },
  639. /**
  640. * 判断进度条是否结束,附件是否加载完成
  641. * @returns {boolean}
  642. */
  643. checkProgress () {
  644. if (this.progressFlag === true) {
  645. this.$message.warning('请等待附件上传完成再进行操作')
  646. return true
  647. }
  648. if (this.fileLoading === false) {
  649. this.$message.warning('请等待附件加载完成再进行操作')
  650. if (this.dataListLength === this.dataListNew.length) {
  651. this.fileLoading = true
  652. }
  653. return true
  654. }
  655. return false
  656. },
  657. ifName (row) {
  658. if (this.commonJS.isEmpty(row.name)) {
  659. row.name = '---'
  660. return false
  661. }
  662. let suffix = row.name.substring(row.name.lastIndexOf('.') + 1)
  663. if (suffix === 'jpg' || suffix === 'png' || suffix === 'gif' || suffix === 'bmp' || suffix === 'jpeg') {
  664. return true
  665. } else {
  666. return false
  667. }
  668. },
  669. fileLoadingFalse () {
  670. this.fileLoading = false
  671. },
  672. // 开启/关闭页面的加载中状态
  673. changeLoading (loading) {
  674. if (this.commonJS.isNotEmpty(loading)) {
  675. this.loading = loading
  676. } else {
  677. this.loading = false
  678. }
  679. }
  680. }
  681. }
  682. </script>
  683. <style>
  684. .el-divider__text {
  685. font-size: 16px;
  686. font-weight: bold;
  687. }
  688. </style>