BaseShipArchiveList.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <div>
  3. <!--引用表格-->
  4. <BasicTable @register="registerTable" :rowSelection="rowSelection">
  5. <!--插槽:table标题-->
  6. <template #tableTitle>
  7. <a-button type="primary" v-auth="'baseCode:base_ship_archive:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
  8. <a-button type="primary" v-auth="'baseCode:base_ship_archive:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
  9. <j-upload-button type="primary" v-auth="'baseCode:base_ship_archive:importExcel'" 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 v-auth="'baseCode:base_ship_archive:deleteBatch'">批量操作
  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>
  33. </BasicTable>
  34. <!-- 表单区域 -->
  35. <BaseShipArchiveModal @register="registerModal" @success="handleSuccess"></BaseShipArchiveModal>
  36. </div>
  37. </template>
  38. <script lang="ts" name="baseCode-baseShipArchive" setup>
  39. import {ref, reactive, computed, unref} from 'vue';
  40. import {BasicTable, useTable, TableAction} from '/@/components/Table';
  41. import {useModal} from '/@/components/Modal';
  42. import { useListPage } from '/@/hooks/system/useListPage'
  43. import BaseShipArchiveModal from './components/BaseShipArchiveModal.vue'
  44. import {columns, searchFormSchema, superQuerySchema} from './BaseShipArchive.data';
  45. import {list, deleteOne, batchDelete, getImportUrl,getExportUrl} from './BaseShipArchive.api';
  46. import { downloadFile } from '/@/utils/common/renderUtils';
  47. import { useUserStore } from '/@/store/modules/user';
  48. const queryParam = reactive<any>({});
  49. const checkedKeys = ref<Array<string | number>>([]);
  50. const userStore = useUserStore();
  51. //注册model
  52. const [registerModal, {openModal}] = useModal();
  53. //注册table数据
  54. const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({
  55. tableProps:{
  56. title: '船舶档案',
  57. api: list,
  58. columns,
  59. canResize:false,
  60. formConfig: {
  61. //labelWidth: 120,
  62. schemas: searchFormSchema,
  63. autoSubmitOnEnter:true,
  64. showAdvancedButton:true,
  65. fieldMapToNumber: [
  66. ],
  67. fieldMapToTime: [
  68. ['shipDate', ['shipDate_begin', 'shipDate_end'], 'YYYY-MM-DD HH:mm:ss'],
  69. ],
  70. },
  71. actionColumn: {
  72. width: 120,
  73. fixed:'right'
  74. },
  75. beforeFetch: (params) => {
  76. return Object.assign(params, queryParam);
  77. },
  78. },
  79. exportConfig: {
  80. name:"船舶档案",
  81. url: getExportUrl,
  82. params: queryParam,
  83. },
  84. importConfig: {
  85. url: getImportUrl,
  86. success: handleSuccess
  87. },
  88. })
  89. const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext
  90. // 高级查询配置
  91. const superQueryConfig = reactive(superQuerySchema);
  92. /**
  93. * 高级查询事件
  94. */
  95. function handleSuperQuery(params) {
  96. Object.keys(params).map((k) => {
  97. queryParam[k] = params[k];
  98. });
  99. reload();
  100. }
  101. /**
  102. * 新增事件
  103. */
  104. function handleAdd() {
  105. openModal(true, {
  106. isUpdate: false,
  107. showFooter: true,
  108. });
  109. }
  110. /**
  111. * 编辑事件
  112. */
  113. function handleEdit(record: Recordable) {
  114. openModal(true, {
  115. record,
  116. isUpdate: true,
  117. showFooter: true,
  118. });
  119. }
  120. /**
  121. * 详情
  122. */
  123. function handleDetail(record: Recordable) {
  124. openModal(true, {
  125. record,
  126. isUpdate: true,
  127. showFooter: false,
  128. });
  129. }
  130. /**
  131. * 删除事件
  132. */
  133. async function handleDelete(record) {
  134. await deleteOne({id: record.id}, handleSuccess);
  135. }
  136. /**
  137. * 批量删除事件
  138. */
  139. async function batchHandleDelete() {
  140. await batchDelete({ids: selectedRowKeys.value}, handleSuccess);
  141. }
  142. /**
  143. * 成功回调
  144. */
  145. function handleSuccess() {
  146. (selectedRowKeys.value = []) && reload();
  147. }
  148. /**
  149. * 操作栏
  150. */
  151. function getTableAction(record){
  152. return [
  153. {
  154. label: '编辑',
  155. onClick: handleEdit.bind(null, record),
  156. auth: 'baseCode:base_ship_archive:edit'
  157. }
  158. ]
  159. }
  160. /**
  161. * 下拉操作栏
  162. */
  163. function getDropDownAction(record){
  164. return [
  165. {
  166. label: '详情',
  167. onClick: handleDetail.bind(null, record),
  168. }, {
  169. label: '删除',
  170. popConfirm: {
  171. title: '是否确认删除',
  172. confirm: handleDelete.bind(null, record),
  173. placement: 'topLeft',
  174. },
  175. auth: 'baseCode:base_ship_archive:delete'
  176. }
  177. ]
  178. }
  179. </script>
  180. <style lang="less" scoped>
  181. :deep(.ant-picker),:deep(.ant-input-number){
  182. width: 100%;
  183. }
  184. </style>