aboutFile.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <view class="section about-file">
  3. <view class="section-title">
  4. <image :src="$static('images/crm_about/folder.png')" class="icon" />
  5. <text class="title">
  6. 附件
  7. </text>
  8. <view
  9. v-if="!isSeas"
  10. class="add-btn"
  11. @click="handleUploadFile">
  12. <text class="wk wk-plus icon-add" />
  13. <text>新建</text>
  14. </view>
  15. </view>
  16. <view class="section-body">
  17. <template v-if="listData.length > 0">
  18. <wk-file-content :list="listData" show-delete @delete="handleDelete" />
  19. </template>
  20. <template v-else>
  21. <view class="no-data">
  22. 暂无数据
  23. </view>
  24. </template>
  25. </view>
  26. <uni-popup ref="popup" type="dialog">
  27. <uni-popup-dialog
  28. content="您确定要删除该文件吗?"
  29. type="warning"
  30. @confirm="handleDialogConfirm" />
  31. </uni-popup>
  32. </view>
  33. </template>
  34. <script>
  35. /**
  36. * 文件列表
  37. */
  38. import {QueryFileList as LeadsQueryFileList} from 'API/crm/leads'
  39. import {QueryFileList as CustomerQueryFileList} from 'API/crm/customer'
  40. import {QueryFileList as ContactsQueryFileList} from 'API/crm/concat'
  41. import {QueryFileList as BusinessQueryFileList} from 'API/crm/business'
  42. import {QueryFileList as ContractQueryFileList} from 'API/crm/contract'
  43. import {QueryFileList as ProductQueryFileList} from 'API/crm/product'
  44. import {QueryFileList as InvoiceQueryFileList} from 'API/crm/invoice'
  45. import {FileDeleteById} from 'API/file'
  46. import UploadFile from '@/utils/file.js'
  47. export default {
  48. name: 'AboutFile',
  49. props: {
  50. type: {
  51. type: String,
  52. default: null
  53. },
  54. batchId: {
  55. type: [String, Number],
  56. default: null
  57. },
  58. detailId: {
  59. type: [String, Number],
  60. default: null
  61. },
  62. isSeas: {
  63. type: Boolean,
  64. default: false
  65. }
  66. },
  67. data() {
  68. return {
  69. listData: [],
  70. deleteItem: null
  71. }
  72. },
  73. created() {
  74. this.getList()
  75. },
  76. methods: {
  77. getList() {
  78. const request = {
  79. crm_leads: LeadsQueryFileList,
  80. crm_customer: CustomerQueryFileList,
  81. crm_contacts: ContactsQueryFileList,
  82. crm_business: BusinessQueryFileList,
  83. crm_contract: ContractQueryFileList,
  84. crm_product: ProductQueryFileList,
  85. crm_invoice: InvoiceQueryFileList,
  86. }[this.type]
  87. if (!request) return
  88. request({
  89. id: this.detailId
  90. }).then(res => {
  91. this.listData = res
  92. }).catch()
  93. },
  94. handleDelete(index, item) {
  95. this.deleteItem = {
  96. index: index,
  97. data: item
  98. }
  99. this.$refs.popup.open()
  100. },
  101. handleDialogConfirm() {
  102. this.$refs.popup.close()
  103. FileDeleteById({
  104. id: this.deleteItem.data.fileId
  105. }).then(() => {
  106. this.$toast('删除成功')
  107. this.listData.splice(this.deleteItem.index, 1)
  108. }).catch()
  109. },
  110. /**
  111. * 上传附件
  112. */
  113. handleUploadFile() {
  114. let fileObj = new UploadFile({
  115. type: 'file',
  116. batchId: this.batchId
  117. })
  118. fileObj.choose().then(response => {
  119. this.listData = this.listData.concat(response)
  120. fileObj = null
  121. })
  122. },
  123. }
  124. }
  125. </script>
  126. <style scoped lang="scss">
  127. @import './style.scss';
  128. .section-body {
  129. padding: 15rpx 20rpx;
  130. }
  131. .no-data {
  132. padding-top: 20rpx;
  133. padding-bottom: 4rpx;
  134. }
  135. </style>