UpLoadComponentV2.vue 25 KB

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