decoration.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <div class="p-4">
  3. <BasicTable @register="registerTable">
  4. <template #toolbar> </template>
  5. <template #createTime="{ record }">
  6. <Time :value="record.createTime" mode="datetime" />
  7. </template>
  8. <template #action>
  9. <TableAction
  10. :actions="[
  11. {
  12. icon: 'clarity:note-edit-line',
  13. label: '编辑',
  14. onClick: () => {
  15. createMessage.info(`暂未接入`);
  16. },
  17. },
  18. {
  19. icon: 'ant-design:delete-outlined',
  20. color: 'error',
  21. label: '删除',
  22. popConfirm: {
  23. title: '是否确认删除',
  24. confirm: () => {
  25. createMessage.info(`暂未接入`);
  26. },
  27. },
  28. },
  29. ]"
  30. />
  31. </template>
  32. </BasicTable>
  33. </div>
  34. </template>
  35. <script lang="ts">
  36. import { defineComponent } from 'vue';
  37. import { BasicTable, useTable, BasicColumn, FormProps, TableAction } from '/@/components/Table';
  38. import { useMessage } from '/@/hooks/web/useMessage';
  39. // import { Tag } from 'ant-design-vue';
  40. import { h } from 'vue';
  41. import { Switch } from 'ant-design-vue';
  42. import { decorationListApi } from '/@/api/bulletin/rent';
  43. import { Time } from '/@/components/Time';
  44. // param type 1
  45. export default defineComponent({
  46. components: { BasicTable, TableAction, Time },
  47. setup() {
  48. const { createMessage } = useMessage();
  49. const columns: BasicColumn[] = [
  50. {
  51. title: 'ID',
  52. dataIndex: 'id',
  53. fixed: 'left',
  54. width: 100,
  55. },
  56. {
  57. title: '发布时间',
  58. dataIndex: 'createTime',
  59. slots: { customRender: 'createTime' },
  60. width: 230,
  61. },
  62. {
  63. title: '信息标题',
  64. dataIndex: 'title',
  65. width: 230,
  66. },
  67. {
  68. title: '发布账号',
  69. dataIndex: 'userName',
  70. width: 120,
  71. },
  72. {
  73. title: '状态',
  74. dataIndex: 'state',
  75. width: 180,
  76. customRender: ({ record }) => {
  77. if (!Reflect.has(record, 'pendingStatus')) {
  78. record.pendingStatus = false;
  79. }
  80. return h(Switch, {
  81. checked: record.state === 0,
  82. checkedChildren: '已启用',
  83. unCheckedChildren: '已禁用',
  84. loading: false,
  85. onChange(checked: boolean) {
  86. record.pendingStatus = true;
  87. const newStatus = checked ? '1' : '0';
  88. const { createMessage } = useMessage();
  89. createMessage.info(`暂未接入` + newStatus);
  90. // setRoleStatus(record.id, newStatus)
  91. // .then(() => {
  92. // record.status = newStatus;
  93. // createMessage.success(`已成功修改角色状态`);
  94. // })
  95. // .catch(() => {
  96. // createMessage.error('修改角色状态失败');
  97. // })
  98. // .finally(() => {
  99. // record.pendingStatus = false;
  100. // });
  101. },
  102. });
  103. },
  104. },
  105. {
  106. title: '操作',
  107. dataIndex: '',
  108. slots: { customRender: 'action' },
  109. width: 150,
  110. },
  111. ];
  112. const searchForm: Partial<FormProps> = {
  113. labelWidth: 100,
  114. schemas: [
  115. {
  116. field: 'part',
  117. component: 'Select',
  118. label: '选择',
  119. defaultValue: '1',
  120. colProps: {
  121. span: 4,
  122. },
  123. componentProps: {
  124. options: [
  125. {
  126. label: '全部',
  127. value: '1',
  128. key: '1',
  129. },
  130. {
  131. label: '正常',
  132. value: '2',
  133. key: '2',
  134. },
  135. {
  136. label: '已关闭',
  137. value: '2',
  138. key: '2',
  139. },
  140. ],
  141. },
  142. },
  143. {
  144. field: 'phone',
  145. label: '手机号',
  146. component: 'Input',
  147. colProps: {
  148. span: 6,
  149. },
  150. },
  151. {
  152. field: 'fieldTime',
  153. component: 'RangePicker',
  154. label: '时间字段',
  155. colProps: {
  156. span: 8,
  157. },
  158. },
  159. ],
  160. };
  161. // { getForm }
  162. const [registerTable] = useTable({
  163. title: '工地装修',
  164. api: decorationListApi,
  165. columns: columns,
  166. useSearchForm: true,
  167. formConfig: searchForm,
  168. showTableSetting: true,
  169. tableSetting: { fullScreen: true },
  170. showIndexColumn: false,
  171. rowKey: 'id',
  172. fetchSetting: {
  173. pageField: 'pageNum',
  174. sizeField: 'pageSize',
  175. listField: 'list',
  176. totalField: 'total',
  177. },
  178. });
  179. return {
  180. registerTable,
  181. createMessage,
  182. };
  183. },
  184. });
  185. </script>