list.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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 :value="record.createTime" mode="datetime" />
  13. </template>
  14. <template #action="{ record }">
  15. <TableAction
  16. :actions="[
  17. {
  18. icon: 'mdi:information-outline',
  19. label: t('common.details'),
  20. onClick: () => {
  21. go(`/order/list/detail/${record.orderNo}`);
  22. },
  23. },
  24. {
  25. icon: 'mdi:printer-outline',
  26. label: t('common.print'),
  27. color: 'error',
  28. onClick: () => {
  29. createMessage.info(t('common.notConnect'));
  30. },
  31. },
  32. ]"
  33. />
  34. </template>
  35. </BasicTable>
  36. </div>
  37. </template>
  38. <script lang="ts">
  39. import { defineComponent } from 'vue';
  40. import { BasicTable, useTable, BasicColumn, FormProps, TableAction } from '/@/components/Table';
  41. import { useMessage } from '/@/hooks/web/useMessage';
  42. import { uploadApi } from '/@/api/sys/upload';
  43. // import { Switch } from 'ant-design-vue';
  44. // import { h } from '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. // appid: null
  51. // companyId: 1107
  52. // companyName: "南山居"
  53. // createTime: 1644801035000
  54. // createUser: "11111111111"
  55. // fdkkPassword: null
  56. // fdkkUser: null
  57. // head: null
  58. // id: 20356
  59. // memoName: "顶顶顶顶"
  60. // message: null
  61. // nickName: "用户13822221234"
  62. // phone: "13822221234"
  63. // roleIdList: null
  64. // roleList: null
  65. // roleName: "公司员工"
  66. // state: null
  67. // token: null
  68. // type: 1
  69. // updateTime: 1644801035000
  70. // updateUser: "11111111111"
  71. // userName: "13822221234"
  72. // userPassword: "2a22bac40f44af4d3b5fdc20ea706fc5"
  73. export default defineComponent({
  74. components: { BasicTable, TableAction, Time },
  75. setup() {
  76. const { createMessage } = useMessage();
  77. const go = useGo();
  78. const { t } = useI18n();
  79. const columns: BasicColumn[] = [
  80. {
  81. title: 'ID',
  82. dataIndex: 'id',
  83. fixed: 'left',
  84. width: 60,
  85. },
  86. {
  87. title: t('routes.staff.deptName'),
  88. dataIndex: 'companyName',
  89. width: 100,
  90. },
  91. {
  92. title: t('routes.staff.userName'),
  93. dataIndex: 'userName',
  94. width: 200,
  95. },
  96. {
  97. title: t('routes.staff.nickName'),
  98. dataIndex: 'nickName',
  99. width: 200,
  100. },
  101. {
  102. title: t('common.roleName'),
  103. dataIndex: 'roleName',
  104. // slots: { customRender: 'role' },
  105. sorter: true,
  106. width: 80,
  107. },
  108. // {
  109. // title: t('common.state'),
  110. // dataIndex: 'status',
  111. // slots: { customRender: 'status' },
  112. // sorter: true,
  113. // width: 80,
  114. // },
  115. {
  116. title: t('routes.staff.createTime'),
  117. dataIndex: 'createTime',
  118. slots: { customRender: 'createTime' },
  119. width: 130,
  120. },
  121. // {
  122. // title: '操作',
  123. // dataIndex: '',
  124. // slots: { customRender: 'action' },
  125. // fixed: 'right',
  126. // width: 140,
  127. // },
  128. ];
  129. const searchForm: Partial<FormProps> = {
  130. labelWidth: 100,
  131. schemas: [
  132. {
  133. field: 'phoneNum',
  134. label: t('routes.mobile.phone'),
  135. component: 'Input',
  136. colProps: {
  137. xl: 5,
  138. xxl: 5,
  139. },
  140. },
  141. ],
  142. };
  143. const [registerTable] = useTable({
  144. title: t('routes.staff.staffList'),
  145. api: ListApi,
  146. columns: columns,
  147. useSearchForm: true,
  148. formConfig: searchForm,
  149. showTableSetting: true,
  150. tableSetting: { fullScreen: true },
  151. showIndexColumn: false,
  152. rowKey: 'id',
  153. pagination: { pageSize: 20 },
  154. ellipsis: false,
  155. bordered: true,
  156. });
  157. function renderRoleType(type: number): string {
  158. switch (type) {
  159. case 0:
  160. return t('routes.staff.roleType.0');
  161. case 1:
  162. return t('routes.staff.roleType.1');
  163. default:
  164. return '';
  165. }
  166. }
  167. function renderStatus(type: number): string {
  168. switch (type) {
  169. case 1:
  170. return t('common.normal');
  171. case 0:
  172. return t('common.unNormal');
  173. default:
  174. return '';
  175. }
  176. }
  177. return {
  178. registerTable,
  179. createMessage,
  180. t,
  181. go,
  182. renderRoleType,
  183. renderStatus,
  184. uploadApi: uploadApi as any,
  185. };
  186. },
  187. });
  188. </script>