list.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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: '手机',
  103. dataIndex: 'phone',
  104. width: 140,
  105. },
  106. {
  107. title: t('common.roleName'),
  108. dataIndex: 'roleName',
  109. // slots: { customRender: 'role' },
  110. sorter: true,
  111. width: 80,
  112. },
  113. {
  114. title: t('common.state'),
  115. dataIndex: 'status',
  116. slots: { customRender: 'status' },
  117. sorter: true,
  118. width: 80,
  119. },
  120. {
  121. title: t('routes.staff.createTime'),
  122. dataIndex: 'createTime',
  123. slots: { customRender: 'createTime' },
  124. width: 130,
  125. },
  126. // {
  127. // title: '操作',
  128. // dataIndex: '',
  129. // slots: { customRender: 'action' },
  130. // fixed: 'right',
  131. // width: 140,
  132. // },
  133. ];
  134. const searchForm: Partial<FormProps> = {
  135. labelWidth: 100,
  136. schemas: [
  137. {
  138. field: 'staffName',
  139. label: t('routes.corporation.phone'),
  140. component: 'Input',
  141. colProps: {
  142. xl: 5,
  143. xxl: 5,
  144. },
  145. },
  146. ],
  147. };
  148. const [registerTable] = useTable({
  149. title: t('routes.staff.staffList'),
  150. api: ListApi,
  151. columns: columns,
  152. useSearchForm: true,
  153. formConfig: searchForm,
  154. showTableSetting: true,
  155. tableSetting: { fullScreen: true },
  156. showIndexColumn: false,
  157. rowKey: 'id',
  158. pagination: { pageSize: 20 },
  159. ellipsis: false,
  160. bordered: true,
  161. });
  162. function renderRoleType(type: number): string {
  163. switch (type) {
  164. case 0:
  165. return t('routes.staff.roleType.0');
  166. case 1:
  167. return t('routes.staff.roleType.1');
  168. default:
  169. return '';
  170. }
  171. }
  172. function renderStatus(type: number): string {
  173. switch (type) {
  174. case 1:
  175. return t('common.normal');
  176. case 0:
  177. return t('common.unNormal');
  178. default:
  179. return '';
  180. }
  181. }
  182. return {
  183. registerTable,
  184. createMessage,
  185. t,
  186. go,
  187. renderRoleType,
  188. renderStatus,
  189. uploadApi: uploadApi as any,
  190. };
  191. },
  192. });
  193. </script>