UpLoadComponentV2.vue 24 KB

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