説明なし

index.vue 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <script setup lang="ts">
  2. import { onMounted, watch } from 'vue';
  3. import { Page } from '@vben/common-ui';
  4. import { useRouter } from 'vue-router';
  5. import { useVbenVxeGrid, type VxeGridProps } from '#/adapter/vxe-table';
  6. import { columns, querySchema } from './config-data';
  7. // @ts-ignore
  8. import type { VbenFormProps } from '@vben/common-ui';
  9. import {
  10. queryrclassApilist,
  11. queryscheduleClassOpeningApi,
  12. } from '#/api/schedule/work/class';
  13. import { ElMessage } from 'element-plus';
  14. const router = useRouter();
  15. const mockData = [
  16. {
  17. roleId: 2,
  18. Name: '王保瑞',
  19. Position: '当班经理',
  20. roleSort: 1,
  21. status: '0',
  22. Startdate: '2024-01-15 10:00:00',
  23. remark: '当班',
  24. isEditing: false,
  25. },
  26. {
  27. roleId: 2,
  28. Name: '王凯',
  29. Position: '当班经理',
  30. roleSort: 1,
  31. status: '0',
  32. createTime: '2024-01-15 10:00:00',
  33. remark: '当班',
  34. isEditing: false,
  35. },
  36. {
  37. roleId: 2,
  38. Name: '威威',
  39. Position: '当班经理',
  40. roleSort: 1,
  41. status: '0',
  42. createTime: '2024-01-15 10:00:00',
  43. remark: '当班',
  44. isEditing: false,
  45. },
  46. // {
  47. // roleId: 3,
  48. // Name: '普通用户',
  49. // roleKey: 'user',
  50. // roleSort: 2,
  51. // status: '0',
  52. // createTime: '2024-01-16 12:00:00',
  53. // remark: '测试用户',
  54. // },
  55. ];
  56. const formOptions: VbenFormProps = {
  57. commonConfig: {
  58. labelWidth: 80,
  59. componentProps: {
  60. allowClear: true,
  61. },
  62. },
  63. schema: querySchema(),
  64. wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
  65. // 日期选择格式化
  66. fieldMappingTime: [
  67. [
  68. 'createTime',
  69. ['params[beginTime]', 'params[endTime]'],
  70. ['YYYY-MM-DD 00:00:00', 'YYYY-MM-DD 23:59:59'],
  71. ],
  72. ],
  73. };
  74. onMounted(() => {
  75. console.log(router);
  76. });
  77. // 列表中显示配置
  78. const gridOptions: VxeGridProps = {
  79. checkboxConfig: {
  80. // 高亮
  81. highlight: true,
  82. // 翻页时保留选中状态
  83. reserve: true,
  84. // 点击行选中
  85. trigger: 'default',
  86. checkMethod: ({ row }) => row?.roleId !== 1,
  87. },
  88. columns,
  89. size: 'medium',
  90. height: 'auto',
  91. // data: mockData,
  92. proxyConfig: {
  93. ajax: {
  94. query: async ({ page }, formValues = {}) => {
  95. const resp = await queryrclassApilist({
  96. ...formValues,
  97. pageNum: page.currentPage,
  98. pageSize: page.pageSize,
  99. });
  100. return { items: resp.rows, total: resp.total };
  101. },
  102. },
  103. },
  104. rowConfig: {
  105. keyField: 'roleId',
  106. },
  107. toolbarConfig: {
  108. custom: true,
  109. refresh: true,
  110. zoom: true,
  111. },
  112. id: 'system-role-index',
  113. };
  114. const [BasicTable, BasicTableApi] = useVbenVxeGrid({
  115. formOptions,
  116. gridOptions,
  117. });
  118. // 定义新增抽屉
  119. const handleAddClick = async () => {
  120. const formValues = (await BasicTableApi.formApi?.getValues()) || {};
  121. if (!formValues?.stationName) {
  122. ElMessage.warning('请先选择场站');
  123. return;
  124. }
  125. router.replace({
  126. path: '/schedule/work/class/addandedit',
  127. query: {
  128. stationId: formValues?.stationName,
  129. },
  130. });
  131. };
  132. const handleViewClick = (data: any) => {
  133. router.push({
  134. path: '/schedule/work/class/addandedit',
  135. query: {
  136. stationId: data.stationId,
  137. Detailsid: data.id,
  138. },
  139. });
  140. };
  141. // const handleEditClick = (row: any) => {
  142. // console.log(row);
  143. // };
  144. watch(
  145. () => router.currentRoute.value.path,
  146. (newPath, oldPath) => {
  147. if (newPath === '/schedule/work/class' && oldPath === '/schedule/work/class/addandedit') {
  148. BasicTableApi.reload();
  149. }
  150. }
  151. );
  152. </script>
  153. <template>
  154. <Page :auto-content-height="true">
  155. <BasicTable table-title="如每月8日后需调整上月数据,请联系系统管理员">
  156. <template #toolbar-tools>
  157. <el-space>
  158. <el-button type="primary" @click="handleAddClick"> 开班 </el-button>
  159. </el-space>
  160. </template>
  161. <template #action="{ row }">
  162. <el-button
  163. size="small"
  164. type="primary"
  165. plain
  166. @click="handleViewClick(row)"
  167. >查看</el-button
  168. >
  169. <!-- <el-button
  170. size="small"
  171. type="primary"
  172. plain
  173. @click="handleEditClick(row)"
  174. >编辑</el-button
  175. > -->
  176. </template>
  177. </BasicTable>
  178. </Page>
  179. </template>
  180. <style scoped lang="scss">
  181. :deep(.el-tooltip__trigger:focus) {
  182. outline: none;
  183. }
  184. </style>