list.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <div class="p-4">
  3. <BasicTable @register="registerTable">
  4. <template #toolbar> </template>
  5. <template #role="{ record }">
  6. {{ renderRoleType(record.role) }}
  7. </template>
  8. <template #status="{ record }">
  9. {{ renderStatus(record.status) }}
  10. </template>
  11. <!-- <template #createTime="{ record }">
  12. <Time v-if="record.createTime" :value="record.createTime" mode="datetime" />
  13. </template> {
  14. icon: 'mdi:printer-outline',
  15. label: t('common.print'),
  16. color: 'error',
  17. onClick: () => {
  18. createMessage.info(t('common.notConnect'));
  19. },
  20. icon: 'mdi:information-outline',
  21. },-->
  22. <template #action="{ record }">
  23. <TableAction
  24. :actions="[
  25. {
  26. label: t('routes.staff.setpaswd'),
  27. onClick: handleOpenModal.bind(null, record),
  28. },
  29. ]"
  30. />
  31. </template>
  32. </BasicTable>
  33. <SetpaswordModal @register="register" />
  34. </div>
  35. </template>
  36. <script lang="ts">
  37. import { defineComponent, computed } from 'vue';
  38. import { BasicTable, useTable, BasicColumn, FormProps, TableAction } from '/@/components/Table';
  39. import { useMessage } from '/@/hooks/web/useMessage';
  40. import { uploadApi } from '/@/api/sys/upload';
  41. import { useModal } from '/@/components/Modal';
  42. // import { Switch } from 'ant-design-vue';
  43. // import { h } from 'vue';
  44. import SetpaswordModal from './setpaswordModal.vue';
  45. import { ListApi } from '/@/api/staff/list';
  46. import { useI18n } from '/@/hooks/web/useI18n';
  47. // import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';
  48. import { useGo } from '/@/hooks/web/usePage';
  49. // import { Time } from '/@/components/Time';
  50. import { useLocaleStore } from '/@/store/modules/locale';
  51. const localeStore = useLocaleStore();
  52. const isJA = computed(() => localeStore.getLocale === 'ja');
  53. export default defineComponent({
  54. components: { BasicTable, TableAction, SetpaswordModal },
  55. setup() {
  56. const [register, { openModal }] = useModal();
  57. const { createMessage } = useMessage();
  58. const go = useGo();
  59. const { t } = useI18n();
  60. const columns: BasicColumn[] = [
  61. {
  62. title: 'ID',
  63. dataIndex: 'id',
  64. fixed: 'left',
  65. width: 60,
  66. },
  67. {
  68. title: t('routes.staff.deptName'),
  69. dataIndex: 'companyName',
  70. width: 100,
  71. },
  72. {
  73. title: t('routes.staff.userName'),
  74. dataIndex: 'userName',
  75. width: 200,
  76. },
  77. {
  78. title: t('routes.staff.nickName'),
  79. dataIndex: 'nickName',
  80. width: 200,
  81. },
  82. {
  83. title: t('common.roleName'),
  84. dataIndex: 'roleName',
  85. // slots: { customRender: 'role' },
  86. sorter: true,
  87. width: 80,
  88. },
  89. // {
  90. // title: t('common.state'),
  91. // dataIndex: 'status',
  92. // slots: { customRender: 'status' },
  93. // sorter: true,
  94. // width: 80,
  95. // },
  96. {
  97. title: t('routes.staff.createTime'),
  98. dataIndex: 'registerTime',
  99. // slots: { customRender: 'createTime' },
  100. width: 130,
  101. },
  102. {
  103. title: '操作',
  104. dataIndex: '',
  105. slots: { customRender: 'action' },
  106. fixed: 'right',
  107. align: 'center',
  108. width: isJA.value ? 160 : 80,
  109. },
  110. ];
  111. const searchForm: Partial<FormProps> = {
  112. labelWidth: 100,
  113. schemas: [
  114. {
  115. field: 'phoneNum',
  116. label: t('routes.staff.userName'),
  117. component: 'Input',
  118. colProps: {
  119. xl: 5,
  120. xxl: 5,
  121. },
  122. },
  123. ],
  124. };
  125. const [registerTable] = useTable({
  126. title: t('routes.staff.staffList'),
  127. api: ListApi,
  128. columns: columns,
  129. useSearchForm: true,
  130. formConfig: searchForm,
  131. showTableSetting: true,
  132. tableSetting: { fullScreen: true },
  133. showIndexColumn: false,
  134. rowKey: 'id',
  135. pagination: { pageSize: 20 },
  136. ellipsis: false,
  137. bordered: true,
  138. });
  139. function renderRoleType(type: number): string {
  140. switch (type) {
  141. case 0:
  142. return t('routes.staff.roleType.0');
  143. case 1:
  144. return t('routes.staff.roleType.1');
  145. default:
  146. return '';
  147. }
  148. }
  149. function renderStatus(type: number): string {
  150. switch (type) {
  151. case 1:
  152. return t('common.normal');
  153. case 0:
  154. return t('common.unNormal');
  155. default:
  156. return '';
  157. }
  158. }
  159. function handleOpenModal(record: Recordable) {
  160. openModal(true, record);
  161. }
  162. return {
  163. registerTable,
  164. createMessage,
  165. t,
  166. go,
  167. renderRoleType,
  168. renderStatus,
  169. uploadApi: uploadApi as any,
  170. handleOpenModal,
  171. register,
  172. };
  173. },
  174. });
  175. </script>