index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <div class="dispatch-manage flex flex-col">
  3. <SearchForm :fields="fields" :params="params"></SearchForm>
  4. <div class="flex-1 page-wrap">
  5. <div class="btn-group">
  6. <t-button theme="success" @click="handleAdd">新增</t-button>
  7. <t-button theme="success">作废</t-button>
  8. <t-button theme="success">批量划定</t-button>
  9. </div>
  10. <t-table
  11. size="small"
  12. row-key="id"
  13. :columns="columns"
  14. :data="tableData"
  15. bordered
  16. :pagination="{
  17. defaultCurrent: 1,
  18. defaultPageSize: 10,
  19. onChange,
  20. total: pagination.total,
  21. }"
  22. :selected-row-keys="selectedRowKeys"
  23. select-on-row-click
  24. @select-change="selectChange"
  25. >
  26. </t-table>
  27. </div>
  28. <AddDispatchDialog
  29. v-model:visible="showAddDispatchDialog"
  30. :title="title"
  31. :type="type"
  32. :handleSave="handleSave"
  33. :formData="formData"
  34. ref="formDialogRef"
  35. ></AddDispatchDialog>
  36. </div>
  37. </template>
  38. <script setup lang="jsx" name="DispatchManage">
  39. import { reactive, ref } from 'vue';
  40. import { useRequest } from 'vue-request';
  41. import { getTableData } from '@/api/test';
  42. import useFetchTable from '@/hooks/useFetchTable';
  43. import useTableCrud from '@/hooks/useTableCrud';
  44. import AddDispatchDialog from './add-dispatch-dialog.vue';
  45. const formDialogRef = ref(null);
  46. const selectedRowKeys = ref([]);
  47. const selectChange = (value, { selectedRowData }) => {
  48. selectedRowKeys.value = value;
  49. };
  50. const columns = [
  51. {
  52. colKey: 'row-select',
  53. type: 'multiple',
  54. width: 50,
  55. fixed: 'left',
  56. },
  57. { colKey: 'a', title: '服务单元', width: 80 },
  58. { colKey: 'b', title: '项目单号', width: 80 },
  59. { colKey: 'c', title: '派单时间', width: 80 },
  60. { colKey: 'd', title: '派单人', width: 70 },
  61. { colKey: 'e', title: '客户类型', width: 80 },
  62. { colKey: 'f', title: '客户名称', width: 80 },
  63. { colKey: 'g', title: '项目名称', width: 80 },
  64. { colKey: 'h', title: '实施产品', width: 80 },
  65. { colKey: 'i', title: '考试开始时间', width: 140 },
  66. { colKey: 'j', title: '考试结束时间', width: 140 },
  67. { colKey: 'k', title: '大区经理', width: 80 },
  68. { colKey: 'l', title: '提交人', width: 70 },
  69. { colKey: 'm', title: '提交时间', width: 140 },
  70. {
  71. title: '操作',
  72. colKey: 'operate',
  73. fixed: 'right',
  74. width: 200,
  75. cell: (h, { row }) => {
  76. return (
  77. <div class="table-operations">
  78. <t-link theme="primary" hover="color">
  79. 划定
  80. </t-link>
  81. <t-link
  82. theme="primary"
  83. hover="color"
  84. onClick={(e) => {
  85. e.stopPropagation();
  86. handleEdit(row);
  87. }}
  88. >
  89. 修改
  90. </t-link>
  91. <t-link theme="primary" hover="color">
  92. 重新划定
  93. </t-link>
  94. </div>
  95. );
  96. },
  97. },
  98. ];
  99. const fields = ref([
  100. {
  101. prop: 'a',
  102. label: '服务单元',
  103. type: 'select',
  104. labelWidth: '80px',
  105. colSpan: 5,
  106. },
  107. {
  108. prop: 'b',
  109. label: '大区经理',
  110. type: 'select',
  111. labelWidth: '80px',
  112. colSpan: 5,
  113. },
  114. {
  115. prop: 'c',
  116. label: '派单人',
  117. type: 'select',
  118. labelWidth: '80px',
  119. colSpan: 5,
  120. },
  121. {
  122. prop: 'd',
  123. label: '客户类型',
  124. type: 'select',
  125. labelWidth: '80px',
  126. colSpan: 5,
  127. },
  128. {
  129. type: 'buttons',
  130. colSpan: 3,
  131. children: [
  132. {
  133. type: 'button',
  134. text: '查询',
  135. },
  136. ],
  137. },
  138. {
  139. prop: 'e',
  140. label: '客户名称',
  141. labelWidth: '80px',
  142. colSpan: 5,
  143. },
  144. {
  145. prop: 'f',
  146. label: '项目单号',
  147. labelWidth: '80px',
  148. colSpan: 5,
  149. },
  150. {
  151. prop: 'g',
  152. label: '派单时间',
  153. type: 'daterange',
  154. labelWidth: '80px',
  155. colSpan: 10,
  156. },
  157. ]);
  158. const params = reactive({
  159. a: '',
  160. b: '',
  161. c: '',
  162. d: '',
  163. e: '',
  164. f: '',
  165. g: [],
  166. });
  167. const {
  168. loading: tableLoading,
  169. pagination,
  170. tableData,
  171. fetchData,
  172. onChange,
  173. } = useFetchTable(getTableData);
  174. const add = async () => {
  175. await 1;
  176. alert(1);
  177. };
  178. const update = async () => {};
  179. const refresh = async () => {};
  180. const {
  181. visible: showAddDispatchDialog,
  182. type,
  183. title,
  184. loading: dialogLoading,
  185. handleAdd,
  186. handleEdit,
  187. handleSave,
  188. formData,
  189. formRef,
  190. } = useTableCrud(
  191. {
  192. name: '派单',
  193. doCreate: add,
  194. doUpdate: update,
  195. refresh: refresh,
  196. initForm: {
  197. a: '',
  198. b: '',
  199. c: '',
  200. d: '',
  201. e: '',
  202. f: '',
  203. g: '',
  204. h: '',
  205. i: '',
  206. j: '',
  207. k: '',
  208. },
  209. },
  210. formDialogRef
  211. );
  212. </script>
  213. <style></style>