index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <a-card :bordered="false" v-if="indexShow">
  3. <s-table
  4. ref="tableRef"
  5. :columns="columns"
  6. :data="loadData"
  7. :alert="options.alert.show"
  8. bordered
  9. :row-key="(record) => record.id"
  10. :tool-config="toolConfig"
  11. :row-selection="options.rowSelection"
  12. v-model:filterParam="filterParam"
  13. :scroll="{ x: 2000 }"
  14. >
  15. <template #operator class="table-operator">
  16. <a-space>
  17. <a-button type="primary" @click="onDetail()" v-if="hasPerm('qyRecordAttachmentAdd')">
  18. <template #icon><plus-outlined /></template>
  19. 新增
  20. </a-button>
  21. <xn-batch-delete
  22. v-if="hasPerm('qyRecordAttachmentDelete')"
  23. :selectedRowKeys="selectedRowKeys"
  24. @batchDelete="deleteBatchQyRecordAttachment"
  25. />
  26. <a-button @click="onExport" v-if="hasPerm('qyRecordAttachmentBatchExport')">
  27. <template #icon><export-outlined /></template>
  28. 批量导出
  29. </a-button>
  30. </a-space>
  31. </template>
  32. <template #bodyCell="{ column, record }">
  33. <template v-if="column.dataIndex === 'action'">
  34. <a-space>
  35. <a @click="onDetail(record, true)" v-if="hasPerm('qyRecordAttachmentView')">查看</a>
  36. <a-divider type="vertical" v-if="hasPerm('qyRecordAttachmentView') && hasPerm(['qyRecordAttachmentEdit', 'qyRecordAttachmentDelete'], 'or')" />
  37. <a @click="onDetail(record)" v-if="hasPerm('qyRecordAttachmentEdit')">编辑</a>
  38. <a-divider type="vertical" v-if="hasPerm(['qyRecordAttachmentEdit', 'qyRecordAttachmentDelete'], 'and')" />
  39. <a-popconfirm title="确定要删除吗?" @confirm="deleteQyRecordAttachment(record)">
  40. <a-button type="link" danger size="small" v-if="hasPerm('qyRecordAttachmentDelete')">删除</a-button>
  41. </a-popconfirm>
  42. </a-space>
  43. </template>
  44. </template>
  45. </s-table>
  46. </a-card>
  47. <Detail v-else ref="detailRef" @onClose="indexShow = true" @successful="onSearch()" />
  48. </template>
  49. <script setup name="qyrecordattachment">
  50. import { cloneDeep } from 'lodash-es'
  51. import Detail from './detail.vue'
  52. import qyRecordAttachmentApi from '@/api/yqyc/qyRecordAttachmentApi'
  53. import downloadUtil from "@/utils/downloadUtil";
  54. const { proxy } = getCurrentInstance()
  55. const tableRef = ref()
  56. const filterParam = ref({})
  57. const detailRef = ref()
  58. const indexShow = ref(true)
  59. const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
  60. const columns = [
  61. {
  62. title: '附件名称',
  63. dataIndex: 'attachmentName',
  64. },
  65. {
  66. title: '附件格式',
  67. dataIndex: 'attachmentFormat',
  68. },
  69. {
  70. title: '附件内容',
  71. dataIndex: 'attachmentContent',
  72. },
  73. {
  74. title: '上传时间',
  75. dataIndex: 'uploadTime',
  76. },
  77. ]
  78. // 操作栏通过权限判断是否显示
  79. if (hasPerm(['qyRecordAttachmentEdit', 'qyRecordAttachmentDelete'])) {
  80. columns.push({
  81. title: '操作',
  82. dataIndex: 'action',
  83. align: 'center',
  84. width: 200,
  85. fixed: 'right',
  86. })
  87. }
  88. const selectedRowKeys = ref([])
  89. // 列表选择配置
  90. const options = {
  91. // columns数字类型字段加入 needTotal: true 可以勾选自动算账
  92. alert: {
  93. show: true,
  94. clear: () => {
  95. selectedRowKeys.value = ref([])
  96. }
  97. },
  98. rowSelection: {
  99. onChange: (selectedRowKey, selectedRows) => {
  100. selectedRowKeys.value = selectedRowKey
  101. }
  102. }
  103. }
  104. const loadData = (parameter) => {
  105. tableRef.value.clearSelected()
  106. return qyRecordAttachmentApi.qyRecordAttachmentPage(parameter).then((data) => {
  107. return data
  108. })
  109. }
  110. // 搜索同时备份参数
  111. const onSearch = (parameter) => {
  112. searchFormStateReal.value = cloneDeep(Object.assign(searchFormState.value, filterParam.value))
  113. nextTick(() => {
  114. tableRef.value.refresh(parameter)
  115. })
  116. }
  117. // 重置
  118. const reset = () => {
  119. searchFormRef.value.resetFields()
  120. onSearch(true)
  121. }
  122. // 删除
  123. const deleteQyRecordAttachment = (record) => {
  124. let params = [
  125. {
  126. id: record.id
  127. }
  128. ]
  129. qyRecordAttachmentApi.qyRecordAttachmentDelete(params).then(() => {
  130. tableRef.value.refresh(true)
  131. })
  132. }
  133. // 批量删除
  134. const deleteBatchQyRecordAttachment = (params) => {
  135. qyRecordAttachmentApi.qyRecordAttachmentDelete(params).then(() => {
  136. tableRef.value.clearRefreshSelected()
  137. })
  138. }
  139. // 批量导出
  140. const onExport = () => {
  141. const params = {
  142. ...filterParam.value
  143. }
  144. if (selectedRowKeys.value.length > 0) {
  145. params.ids = selectedRowKeys.value
  146. } else {
  147. Object.entries(searchFormStateReal.value).forEach(([key, value]) => {
  148. console.log(key)
  149. if (proxy.$util.isValue(value)) {
  150. params[key] = value
  151. }
  152. })
  153. }
  154. qyRecordAttachmentApi.qyRecordAttachmentExport(params).then((res) => {
  155. downloadUtil.resultDownload(res)
  156. tableRef.value.clearSelected()
  157. })
  158. }
  159. // 切换至表单
  160. const onDetail = (record = null, view) => {
  161. indexShow.value = false
  162. nextTick(() => {
  163. detailRef.value.onOpen(record, view)
  164. })
  165. }
  166. </script>
  167. <style lang="less" scoped>
  168. </style>