BaseShipArchiveList.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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-button type="primary" @click="relateCustomer"> 关联客户</a-button>
  11. <a-button type="primary" @click="hisCustomer"> 历史客户</a-button>
  12. <a-dropdown v-if="selectedRowKeys.length > 0">
  13. <template #overlay>
  14. <a-menu>
  15. <a-menu-item key="1" @click="batchHandleDelete">
  16. <Icon icon="ant-design:delete-outlined"></Icon>
  17. 删除
  18. </a-menu-item>
  19. </a-menu>
  20. </template>
  21. <a-button v-auth="'baseCode:base_ship_archive:deleteBatch'">批量操作
  22. <Icon icon="mdi:chevron-down"></Icon>
  23. </a-button>
  24. </a-dropdown>
  25. <!-- 高级查询 -->
  26. <super-query :config="superQueryConfig" @search="handleSuperQuery" />
  27. </template>
  28. <!--操作栏-->
  29. <template #action="{ record }">
  30. <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/>
  31. </template>
  32. <!--字段回显插槽-->
  33. <template v-slot:bodyCell="{ column, record, index, text }">
  34. </template>
  35. </BasicTable>
  36. <!-- 表单区域 -->
  37. <BaseShipArchiveModal @register="registerModal" @success="handleSuccess"></BaseShipArchiveModal>
  38. <BaseShipArchiveRelateCustomerModal @register="registerCustomerAdd" @success="handleSuccess"></BaseShipArchiveRelateCustomerModal>
  39. </div>
  40. </template>
  41. <script lang="ts" name="baseCode-baseShipArchive" setup>
  42. import {ref, reactive, computed, unref} from 'vue';
  43. import {BasicTable, useTable, TableAction} from '/@/components/Table';
  44. import {useModal} from '/@/components/Modal';
  45. import { useListPage } from '/@/hooks/system/useListPage'
  46. import BaseShipArchiveModal from './components/BaseShipArchiveModal.vue'
  47. import BaseShipArchiveRelateCustomerModal from './components/BaseShipArchiveRelateCustomerModal.vue'
  48. import {columns, searchFormSchema, superQuerySchema} from './BaseShipArchive.data';
  49. import {list, deleteOne, batchDelete, getImportUrl,getExportUrl} from './BaseShipArchive.api';
  50. import { downloadFile } from '/@/utils/common/renderUtils';
  51. import { useUserStore } from '/@/store/modules/user';
  52. import { useMessage } from '/@/hooks/web/useMessage';
  53. const queryParam = reactive<any>({});
  54. const checkedKeys = ref<Array<string | number>>([]);
  55. const userStore = useUserStore();
  56. //注册model
  57. const { createMessage, createConfirm, createSuccessModal, createInfoModal, createErrorModal, createWarningModal, notification } = useMessage();
  58. const [registerModal,{openModal: openModal}] = useModal();
  59. const [registerCustomerAdd, { openModal: openModalCustomerAdd }] = useModal();
  60. //注册table数据
  61. const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({
  62. tableProps:{
  63. title: '船舶档案',
  64. api: list,
  65. columns,
  66. canResize:false,
  67. formConfig: {
  68. //labelWidth: 120,
  69. schemas: searchFormSchema,
  70. autoSubmitOnEnter:true,
  71. showAdvancedButton:true,
  72. fieldMapToNumber: [
  73. ],
  74. fieldMapToTime: [
  75. ['shipDate', ['shipDate_begin', 'shipDate_end'], 'YYYY-MM-DD HH:mm:ss'],
  76. ],
  77. },
  78. actionColumn: {
  79. width: 120,
  80. fixed:'right'
  81. },
  82. beforeFetch: (params) => {
  83. return Object.assign(params, queryParam);
  84. },
  85. },
  86. exportConfig: {
  87. name:"船舶档案",
  88. url: getExportUrl,
  89. params: queryParam,
  90. },
  91. importConfig: {
  92. url: getImportUrl,
  93. success: handleSuccess
  94. },
  95. })
  96. const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext
  97. // 高级查询配置
  98. const superQueryConfig = reactive(superQuerySchema);
  99. /**
  100. * 高级查询事件
  101. */
  102. function handleSuperQuery(params) {
  103. Object.keys(params).map((k) => {
  104. queryParam[k] = params[k];
  105. });
  106. reload();
  107. }
  108. /**
  109. * 关联客户
  110. */
  111. function relateCustomer(record: Recordable) {
  112. if (selectedRowKeys.value.length != 1) {
  113. createWarningModal({ title: '提示', content: '请选择一条数据' });
  114. return;
  115. }
  116. // selectedRowKeys.value.forEach((item) => {
  117. // console.log(item);
  118. // });
  119. record.headId=rowSelection.selectedRows[0].id;
  120. record.name=rowSelection.selectedRows[0].shipName;
  121. record.imo=rowSelection.selectedRows[0].imo;
  122. openModalCustomerAdd(true, {
  123. record,
  124. isUpdate: false,
  125. showFooter: true,
  126. });
  127. } /**
  128. * 关联客户
  129. */
  130. function hisCustomer(record: Recordable) {
  131. if (selectedRowKeys.value.length != 1) {
  132. createWarningModal({ title: '提示', content: '请选择一条数据' });
  133. return;
  134. }
  135. // selectedRowKeys.value.forEach((item) => {
  136. // console.log(item);
  137. // });
  138. record.headId=rowSelection.selectedRows[0].id;
  139. record.name=rowSelection.selectedRows[0].shipName;
  140. record.imo=rowSelection.selectedRows[0].imo;
  141. openModalCustomerAdd(true, {
  142. record,
  143. isUpdate: true,
  144. showFooter: false,
  145. });
  146. }
  147. /**
  148. * 新增事件
  149. */
  150. function handleAdd() {
  151. openModal(true, {
  152. isUpdate: false,
  153. showFooter: true,
  154. });
  155. }
  156. /**
  157. * 编辑事件
  158. */
  159. function handleEdit(record: Recordable) {
  160. openModal(true, {
  161. record,
  162. isUpdate: true,
  163. showFooter: true,
  164. });
  165. }
  166. /**
  167. * 详情
  168. */
  169. function handleDetail(record: Recordable) {
  170. openModal(true, {
  171. record,
  172. isUpdate: true,
  173. showFooter: false,
  174. });
  175. }
  176. /**
  177. * 删除事件
  178. */
  179. async function handleDelete(record) {
  180. await deleteOne({id: record.id}, handleSuccess);
  181. }
  182. /**
  183. * 批量删除事件
  184. */
  185. async function batchHandleDelete() {
  186. await batchDelete({ids: selectedRowKeys.value}, handleSuccess);
  187. }
  188. /**
  189. * 成功回调
  190. */
  191. function handleSuccess() {
  192. (selectedRowKeys.value = []) && reload();
  193. }
  194. /**
  195. * 操作栏
  196. */
  197. function getTableAction(record){
  198. return [
  199. {
  200. label: '编辑',
  201. onClick: handleEdit.bind(null, record),
  202. auth: 'baseCode:base_ship_archive:edit'
  203. }
  204. ]
  205. }
  206. /**
  207. * 下拉操作栏
  208. */
  209. function getDropDownAction(record){
  210. return [
  211. {
  212. label: '详情',
  213. onClick: handleDetail.bind(null, record),
  214. }, {
  215. label: '删除',
  216. popConfirm: {
  217. title: '是否确认删除',
  218. confirm: handleDelete.bind(null, record),
  219. placement: 'topLeft',
  220. },
  221. auth: 'baseCode:base_ship_archive:delete'
  222. }
  223. ]
  224. }
  225. </script>
  226. <style lang="less" scoped>
  227. :deep(.ant-picker),:deep(.ant-input-number){
  228. width: 100%;
  229. }
  230. </style>