OkkiShowlistList.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <div>
  3. <!--引用表格-->
  4. <BasicTable @register="registerTable" :rowSelection="rowSelection">
  5. <!--插槽:table标题-->
  6. <template #tableTitle>
  7. <a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
  8. <a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
  9. <j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
  10. <a-dropdown v-if="selectedRowKeys.length > 0">
  11. <template #overlay>
  12. <a-menu>
  13. <a-menu-item key="1" @click="batchHandleDelete">
  14. <Icon icon="ant-design:delete-outlined"></Icon>
  15. 删除
  16. </a-menu-item>
  17. </a-menu>
  18. </template>
  19. <a-button>批量操作
  20. <Icon icon="mdi:chevron-down"></Icon>
  21. </a-button>
  22. </a-dropdown>
  23. <!-- 高级查询 -->
  24. <super-query :config="superQueryConfig" @search="handleSuperQuery" />
  25. </template>
  26. <!--操作栏-->
  27. <template #action="{ record }">
  28. <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/>
  29. </template>
  30. <!--字段回显插槽-->
  31. <template v-slot:bodyCell="{ column, record, index, text }">
  32. <template v-if="column.dataIndex==='advantageContent'">
  33. <!--富文本件字段回显插槽-->
  34. <div v-html="text"></div>
  35. </template>
  36. </template>
  37. </BasicTable>
  38. <!-- 表单区域 -->
  39. <OkkiShowlistModal @register="registerModal" @success="handleSuccess"></OkkiShowlistModal>
  40. </div>
  41. </template>
  42. <script lang="ts" name="showlist-okkiShowlist" setup>
  43. import {ref, reactive, computed, unref} from 'vue';
  44. import {BasicTable, useTable, TableAction} from '/@/components/Table';
  45. import { useListPage } from '/@/hooks/system/useListPage'
  46. import {useModal} from '/@/components/Modal';
  47. import OkkiShowlistModal from './components/OkkiShowlistModal.vue'
  48. import {columns, searchFormSchema, superQuerySchema} from './OkkiShowlist.data';
  49. import {list, deleteOne, batchDelete, getImportUrl,getExportUrl} from './OkkiShowlist.api';
  50. import {downloadFile} from '/@/utils/common/renderUtils';
  51. import { useUserStore } from '/@/store/modules/user';
  52. const queryParam = reactive<any>({});
  53. const userStore = useUserStore();
  54. const checkedKeys = ref<Array<string | number>>([]);
  55. //注册model
  56. const [registerModal, {openModal}] = useModal();
  57. //注册table数据
  58. const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({
  59. tableProps:{
  60. title: 'showlist',
  61. api: list,
  62. columns,
  63. canResize:false,
  64. formConfig: {
  65. //labelWidth: 120,
  66. schemas: searchFormSchema,
  67. autoSubmitOnEnter:true,
  68. showAdvancedButton:true,
  69. fieldMapToNumber: [
  70. ],
  71. fieldMapToTime: [
  72. ],
  73. },
  74. actionColumn: {
  75. width: 120,
  76. fixed:'right'
  77. },
  78. beforeFetch: (params) => {
  79. return Object.assign(params, queryParam);
  80. },
  81. },
  82. exportConfig: {
  83. name:"showlist",
  84. url: getExportUrl,
  85. params: queryParam,
  86. },
  87. importConfig: {
  88. url: getImportUrl,
  89. success: handleSuccess
  90. },
  91. })
  92. const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext
  93. // 高级查询配置
  94. const superQueryConfig = reactive(superQuerySchema);
  95. /**
  96. * 高级查询事件
  97. */
  98. function handleSuperQuery(params) {
  99. Object.keys(params).map((k) => {
  100. queryParam[k] = params[k];
  101. });
  102. reload();
  103. }
  104. /**
  105. * 新增事件
  106. */
  107. function handleAdd() {
  108. openModal(true, {
  109. isUpdate: false,
  110. showFooter: true,
  111. });
  112. }
  113. /**
  114. * 编辑事件
  115. */
  116. function handleEdit(record: Recordable) {
  117. openModal(true, {
  118. record,
  119. isUpdate: true,
  120. showFooter: true,
  121. });
  122. }
  123. /**
  124. * 详情
  125. */
  126. function handleDetail(record: Recordable) {
  127. openModal(true, {
  128. record,
  129. isUpdate: true,
  130. showFooter: false,
  131. });
  132. }
  133. /**
  134. * 删除事件
  135. */
  136. async function handleDelete(record) {
  137. await deleteOne({id: record.id}, handleSuccess);
  138. }
  139. /**
  140. * 批量删除事件
  141. */
  142. async function batchHandleDelete() {
  143. await batchDelete({ids: selectedRowKeys.value}, handleSuccess);
  144. }
  145. /**
  146. * 成功回调
  147. */
  148. function handleSuccess() {
  149. (selectedRowKeys.value = []) && reload();
  150. }
  151. /**
  152. * 操作栏
  153. */
  154. function getTableAction(record){
  155. return [
  156. {
  157. label: '编辑',
  158. onClick: handleEdit.bind(null, record),
  159. }
  160. ]
  161. }
  162. /**
  163. * 下拉操作栏
  164. */
  165. function getDropDownAction(record){
  166. return [
  167. {
  168. label: '详情',
  169. onClick: handleDetail.bind(null, record),
  170. }, {
  171. label: '删除',
  172. popConfirm: {
  173. title: '是否确认删除',
  174. confirm: handleDelete.bind(null, record),
  175. placement: 'topLeft',
  176. }
  177. }
  178. ]
  179. }
  180. </script>
  181. <style scoped>
  182. </style>