index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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('qyCheckListAdd')">
  18. <template #icon><plus-outlined /></template>
  19. 新增
  20. </a-button>
  21. <xn-batch-delete
  22. v-if="hasPerm('qyCheckListDelete')"
  23. :selectedRowKeys="selectedRowKeys"
  24. @batchDelete="deleteBatchQyCheckList"
  25. />
  26. <a-button @click="onExport" v-if="hasPerm('qyCheckListBatchExport')">
  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('qyCheckListView')">查看</a>
  36. <a-divider type="vertical" v-if="hasPerm('qyCheckListView') && hasPerm(['qyCheckListEdit', 'qyCheckListDelete'], 'or')" />
  37. <a @click="onDetail(record)" v-if="hasPerm('qyCheckListEdit')">编辑</a>
  38. <a-divider type="vertical" v-if="hasPerm(['qyCheckListEdit', 'qyCheckListDelete'], 'and')" />
  39. <a-popconfirm title="确定要删除吗?" @confirm="deleteQyCheckList(record)">
  40. <a-button type="link" danger size="small" v-if="hasPerm('qyCheckListDelete')">删除</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="qychecklist">
  50. import { cloneDeep } from 'lodash-es'
  51. import Detail from './detail.vue'
  52. import qyCheckListApi from '@/api/biz/qyCheckListApi'
  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: 'qyName',
  64. },
  65. {
  66. title: '单据类型',
  67. dataIndex: 'djType',
  68. },
  69. {
  70. title: '审核状态',
  71. dataIndex: 'checkType',
  72. },
  73. {
  74. title: '审核人',
  75. dataIndex: 'applyMan',
  76. },
  77. {
  78. title: '审核时间',
  79. dataIndex: 'checkTime',
  80. },
  81. {
  82. title: '审核结果回执',
  83. dataIndex: 'result',
  84. },
  85. ]
  86. // 操作栏通过权限判断是否显示
  87. if (hasPerm(['qyCheckListEdit', 'qyCheckListDelete'])) {
  88. columns.push({
  89. title: '操作',
  90. dataIndex: 'action',
  91. align: 'center',
  92. width: 200,
  93. fixed: 'right',
  94. })
  95. }
  96. const selectedRowKeys = ref([])
  97. // 列表选择配置
  98. const options = {
  99. // columns数字类型字段加入 needTotal: true 可以勾选自动算账
  100. alert: {
  101. show: true,
  102. clear: () => {
  103. selectedRowKeys.value = ref([])
  104. }
  105. },
  106. rowSelection: {
  107. onChange: (selectedRowKey, selectedRows) => {
  108. selectedRowKeys.value = selectedRowKey
  109. }
  110. }
  111. }
  112. const loadData = (parameter) => {
  113. tableRef.value.clearSelected()
  114. return qyCheckListApi.qyCheckListPage(parameter).then((data) => {
  115. return data
  116. })
  117. }
  118. // 搜索同时备份参数
  119. const onSearch = (parameter) => {
  120. searchFormStateReal.value = cloneDeep(searchFormState.value)
  121. nextTick(() => {
  122. tableRef.value.refresh(parameter)
  123. })
  124. }
  125. // 重置
  126. const reset = () => {
  127. searchFormRef.value.resetFields()
  128. onSearch(true)
  129. }
  130. // 删除
  131. const deleteQyCheckList = (record) => {
  132. let params = [
  133. {
  134. id: record.id
  135. }
  136. ]
  137. qyCheckListApi.qyCheckListDelete(params).then(() => {
  138. tableRef.value.refresh(true)
  139. })
  140. }
  141. // 批量删除
  142. const deleteBatchQyCheckList = (params) => {
  143. qyCheckListApi.qyCheckListDelete(params).then(() => {
  144. tableRef.value.clearRefreshSelected()
  145. })
  146. }
  147. // 批量导出
  148. const onExport = () => {
  149. const params = {
  150. ...filterParam.value
  151. }
  152. if (selectedRowKeys.value.length > 0) {
  153. params.ids = selectedRowKeys.value
  154. } else {
  155. Object.entries(searchFormStateReal.value).forEach(([key, value]) => {
  156. console.log(key)
  157. if (proxy.$util.isValue(value)) {
  158. params[key] = value
  159. }
  160. })
  161. }
  162. qyCheckListApi.qyCheckListExport(params).then((res) => {
  163. downloadUtil.resultDownload(res)
  164. tableRef.value.clearSelected()
  165. })
  166. }
  167. // 切换至表单
  168. const onDetail = (record = null, view) => {
  169. indexShow.value = false
  170. nextTick(() => {
  171. detailRef.value.onOpen(record, view)
  172. })
  173. }
  174. </script>
  175. <style lang="less" scoped>
  176. </style>