1
0

DistrictTeam.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <!-- eslint-disable vue/multi-word-component-names -->
  2. <!-- 该文件主要用于单独管理 所属区队 字典的内容 -->
  3. <template>
  4. <BasicTable @register="registerTable" :rowClassName="getRowClassName">
  5. <template #tableTitle>
  6. <a-button type="primary" @click="handleCreate">新增</a-button>
  7. </template>
  8. <template #bodyCell="{ column, record }">
  9. <template v-if="column.dataIndex === 'action'">
  10. <TableAction :actions="getTableAction(record)" />
  11. </template>
  12. </template>
  13. </BasicTable>
  14. <DictItemModal @register="registerModal" @success="reload" :dictId="dictId" />
  15. </template>
  16. <script lang="ts" setup>
  17. import { onMounted, ref, unref } from 'vue';
  18. import { BasicTable, useTable, TableAction } from '/@/components/Table';
  19. import { useModal } from '/@/components/Modal';
  20. import { useDesign } from '/@/hooks/web/useDesign';
  21. import DictItemModal from './DictItemModal.vue';
  22. import { dictItemColumns, dictItemSearchFormSchema } from '../dict.data';
  23. import { itemList, deleteItem } from '../dict.api';
  24. import { ColEx } from '/@/components/Form/src/types';
  25. const { prefixCls } = useDesign('row-invalid');
  26. const dictId = ref('');
  27. //字典配置model
  28. const [registerModal, { openModal }] = useModal();
  29. // 自适应列配置
  30. const adaptiveColProps: Partial<ColEx> = {
  31. xs: 24, // <576px
  32. sm: 24, // ≥576px
  33. md: 24, // ≥768px
  34. lg: 10, // ≥992px
  35. xl: 10, // ≥1200px
  36. xxl: 6, // ≥1600px
  37. };
  38. const [registerTable, { reload, setProps }] = useTable({
  39. //需要配置rowKey,否则会有警告
  40. rowKey: 'dictId',
  41. api: itemList,
  42. columns: dictItemColumns,
  43. formConfig: {
  44. baseColProps: adaptiveColProps,
  45. labelAlign: 'left',
  46. // labelCol: {
  47. // offset: 1,
  48. // xs: 24,
  49. // sm: 24,
  50. // md: 24,
  51. // lg: 9,
  52. // xl: 7,
  53. // xxl: 4,
  54. // },
  55. schemas: dictItemSearchFormSchema,
  56. autoSubmitOnEnter: true,
  57. },
  58. striped: true,
  59. useSearchForm: true,
  60. bordered: true,
  61. showIndexColumn: false,
  62. canResize: false,
  63. immediate: false,
  64. actionColumn: {
  65. width: 100,
  66. title: '操作',
  67. dataIndex: 'action',
  68. //slots: { customRender: 'action' },
  69. fixed: undefined,
  70. },
  71. });
  72. /**
  73. * 新增
  74. */
  75. function handleCreate() {
  76. openModal(true, {
  77. isUpdate: false,
  78. });
  79. }
  80. /**
  81. * 编辑
  82. */
  83. function handleEdit(record) {
  84. openModal(true, {
  85. record,
  86. isUpdate: true,
  87. });
  88. }
  89. /**
  90. * 删除
  91. */
  92. async function handleDelete(record) {
  93. await deleteItem({ id: record.id }, reload);
  94. }
  95. /**
  96. * 操作栏
  97. */
  98. function getTableAction(record) {
  99. return [
  100. {
  101. label: '编辑',
  102. onClick: handleEdit.bind(null, record),
  103. },
  104. {
  105. label: '删除',
  106. popConfirm: {
  107. title: '是否确认删除',
  108. confirm: handleDelete.bind(null, record),
  109. },
  110. },
  111. ];
  112. }
  113. function getRowClassName(record) {
  114. return record.status == 0 ? prefixCls : '';
  115. }
  116. onMounted(() => {
  117. dictId.value = '1826791852479107073';
  118. setProps({ searchInfo: { dictId: unref(dictId) } });
  119. reload();
  120. });
  121. </script>
  122. <style scoped lang="less">
  123. @prefix-cls: ~'@{namespace}-row-invalid';
  124. :deep(.@{prefix-cls}) {
  125. background: #f4f4f4;
  126. color: #bababa;
  127. }
  128. </style>