CuspSupplierProfileList.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <div>
  3. <!--引用表格-->
  4. <BasicTable @register="registerTable" :rowSelection="rowSelection">
  5. <!--插槽:table标题-->
  6. <template #tableTitle>
  7. <a-button type="primary" v-auth="'cuspCode:cusp_supplier_profile:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
  8. <a-button type="primary" v-auth="'cuspCode:cusp_supplier_profile:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
  9. <j-upload-button type="primary" v-auth="'cuspCode:cusp_supplier_profile: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="'cuspCode:cusp_supplier_profile: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. <CuspSupplierProfileModal @register="registerModal" @success="handleSuccess"></CuspSupplierProfileModal>
  36. </div>
  37. </template>
  38. <script lang="ts" name="cuspCode-cuspSupplierProfile" setup>
  39. import {ref, reactive, computed, unref} from 'vue';
  40. import {BasicTable, useTable, TableAction} from '/@/components/Table';
  41. import { useListPage } from '/@/hooks/system/useListPage'
  42. import {useModal} from '/@/components/Modal';
  43. import CuspSupplierProfileModal from './components/CuspSupplierProfileModal.vue'
  44. import {columns, searchFormSchema, superQuerySchema} from './CuspSupplierProfile.data';
  45. import {list, deleteOne, batchDelete, getImportUrl,getExportUrl} from './CuspSupplierProfile.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. ],
  69. },
  70. actionColumn: {
  71. width: 120,
  72. fixed:'right'
  73. },
  74. beforeFetch: (params) => {
  75. return Object.assign(params, queryParam);
  76. },
  77. },
  78. exportConfig: {
  79. name:"供应商档案",
  80. url: getExportUrl,
  81. params: queryParam,
  82. },
  83. importConfig: {
  84. url: getImportUrl,
  85. success: handleSuccess
  86. },
  87. })
  88. const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext
  89. // 高级查询配置
  90. const superQueryConfig = reactive(superQuerySchema);
  91. /**
  92. * 高级查询事件
  93. */
  94. function handleSuperQuery(params) {
  95. Object.keys(params).map((k) => {
  96. queryParam[k] = params[k];
  97. });
  98. reload();
  99. }
  100. /**
  101. * 新增事件
  102. */
  103. function handleAdd() {
  104. openModal(true, {
  105. isUpdate: false,
  106. showFooter: true,
  107. });
  108. }
  109. /**
  110. * 编辑事件
  111. */
  112. function handleEdit(record: Recordable) {
  113. openModal(true, {
  114. record,
  115. isUpdate: true,
  116. showFooter: true,
  117. });
  118. }
  119. /**
  120. * 详情
  121. */
  122. function handleDetail(record: Recordable) {
  123. openModal(true, {
  124. record,
  125. isUpdate: true,
  126. showFooter: false,
  127. });
  128. }
  129. /**
  130. * 删除事件
  131. */
  132. async function handleDelete(record) {
  133. await deleteOne({id: record.id}, handleSuccess);
  134. }
  135. /**
  136. * 批量删除事件
  137. */
  138. async function batchHandleDelete() {
  139. await batchDelete({ids: selectedRowKeys.value},handleSuccess);
  140. }
  141. /**
  142. * 成功回调
  143. */
  144. function handleSuccess() {
  145. (selectedRowKeys.value = []) && reload();
  146. }
  147. /**
  148. * 操作栏
  149. */
  150. function getTableAction(record){
  151. return [
  152. {
  153. label: '编辑',
  154. onClick: handleEdit.bind(null, record),
  155. auth: 'cuspCode:cusp_supplier_profile:edit'
  156. }
  157. ]
  158. }
  159. /**
  160. * 下拉操作栏
  161. */
  162. function getDropDownAction(record){
  163. return [
  164. {
  165. label: '详情',
  166. onClick: handleDetail.bind(null, record),
  167. }, {
  168. label: '删除',
  169. popConfirm: {
  170. title: '是否确认删除',
  171. confirm: handleDelete.bind(null, record),
  172. placement: 'topLeft'
  173. },
  174. auth: 'cuspCode:cusp_supplier_profile:delete'
  175. }
  176. ]
  177. }
  178. </script>
  179. <style lang="less" scoped>
  180. :deep(.ant-picker),:deep(.ant-input-number){
  181. width: 100%;
  182. }
  183. </style>