index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <div class="add-range flex flex-col h-full">
  3. <SearchForm :fields="fields" :params="params"></SearchForm>
  4. <div class="flex-1 page-wrap">
  5. <div class="btn-group">
  6. <t-button
  7. theme="success"
  8. :disabled="!selectedRowKeys.length"
  9. @click="handlerBatchBind"
  10. >批量划定</t-button
  11. >
  12. </div>
  13. <t-table
  14. size="small"
  15. row-key="id"
  16. :columns="columns"
  17. :data="tableData"
  18. bordered
  19. :pagination="{
  20. defaultCurrent: 1,
  21. defaultPageSize: 10,
  22. onChange,
  23. current: pagination.page,
  24. }"
  25. v-loading="tableLoading"
  26. :selected-row-keys="selectedRowKeys"
  27. select-on-row-click
  28. @select-change="selectChange"
  29. >
  30. <template #type="{ col, row }">
  31. {{ customerTypeFilter(row[col.colKey]) }}
  32. </template>
  33. <template #begin-time="{ col, row }">
  34. {{ timestampFilter(row[col.colKey]) }}
  35. </template>
  36. <template #exam-start-time="{ col, row }">
  37. {{ timestampFilter(row[col.colKey]) }}
  38. </template>
  39. <template #exam-end-time="{ col, row }">
  40. {{ timestampFilter(row[col.colKey]) }}
  41. </template>
  42. <template #create-time="{ col, row }">
  43. {{ timestampFilter(row[col.colKey]) }}
  44. </template>
  45. </t-table>
  46. </div>
  47. <!-- SelectServiceUnitDialog -->
  48. <select-service-unit-dialog
  49. v-model:visible="showSelectServiceUnitDialog"
  50. :crm-ids="selectedRowKeys"
  51. @success="search"
  52. ></select-service-unit-dialog>
  53. </div>
  54. </template>
  55. <script setup name="AddRange">
  56. import { reactive, ref } from 'vue';
  57. import { omit } from 'lodash';
  58. import { MessagePlugin } from 'tdesign-vue-next';
  59. import { serviceScopeUnbindCrmQueryApi } from '@/api/service-unit';
  60. import useFetchTable from '@/hooks/useFetchTable';
  61. import { CUSTOMER_TYPE } from '@/config/constants';
  62. import { customerTypeFilter, timestampFilter } from '@/utils/filter';
  63. import SelectServiceUnitDialog from './select-service-unit-dialog.vue';
  64. let showSelectServiceUnitDialog = ref(false);
  65. const fields = ref([
  66. {
  67. prop: 'crmUserId',
  68. label: '派单人',
  69. type: 'select',
  70. labelWidth: 80,
  71. colSpan: 5,
  72. attrs: {
  73. clearable: true,
  74. },
  75. },
  76. {
  77. prop: 'productType',
  78. label: '客户类型',
  79. type: 'select',
  80. labelWidth: 80,
  81. colSpan: 5,
  82. attrs: {
  83. clearable: true,
  84. },
  85. },
  86. {
  87. prop: 'customName',
  88. label: '客户名称',
  89. labelWidth: 80,
  90. colSpan: 5,
  91. options: dictToOptionList(CUSTOMER_TYPE),
  92. attrs: {
  93. clearable: true,
  94. },
  95. },
  96. {
  97. prop: 'crmNo',
  98. label: '项目单号',
  99. labelWidth: 80,
  100. colSpan: 5,
  101. attrs: {
  102. clearable: true,
  103. },
  104. },
  105. {
  106. type: 'buttons',
  107. colSpan: 2,
  108. children: [
  109. {
  110. type: 'button',
  111. text: '查询',
  112. onClick: () => {
  113. search();
  114. },
  115. },
  116. ],
  117. },
  118. {
  119. prop: 'crmTime',
  120. label: '派单时间',
  121. type: 'daterange',
  122. labelWidth: 80,
  123. colSpan: 10,
  124. attrs: {
  125. clearable: true,
  126. },
  127. },
  128. ]);
  129. const params = reactive({
  130. crmUserId: '',
  131. productType: '',
  132. customName: '',
  133. crmNo: '',
  134. crmTime: [],
  135. });
  136. const computedParams = computed(() => {
  137. let data = omit(params, ['crmTime']);
  138. data.startTime = params.crmTime[0];
  139. data.endTime = params.crmTime[1];
  140. return data;
  141. });
  142. const selectedRowKeys = ref([]);
  143. const selectChange = (value) => {
  144. selectedRowKeys.value = value;
  145. };
  146. const columns = [
  147. {
  148. colKey: 'row-select',
  149. type: 'multiple',
  150. width: 50,
  151. fixed: 'left',
  152. },
  153. { colKey: 'crmNo', title: '项目单号', minWidth: 80 },
  154. { colKey: 'beginTime', title: '派单时间', width: 170, cell: 'begin-time' },
  155. { colKey: 'crmUserName', title: '派单人', minWidth: 80 },
  156. { colKey: 'productType', title: '客户类型', width: 90, cell: 'type' },
  157. { colKey: 'customName', title: '客户名称', minWidth: 100 },
  158. { colKey: 'productName', title: '项目名称', minWidth: 80 },
  159. { colKey: 'productName', title: '实施产品', minWidth: 80 },
  160. {
  161. colKey: 'examStartTime',
  162. title: '考试开始时间',
  163. width: 170,
  164. cell: 'exam-start-time',
  165. },
  166. {
  167. colKey: 'examEndTime',
  168. title: '考试结束时间',
  169. width: 170,
  170. cell: 'exam-end-time',
  171. },
  172. { colKey: 'creatorName', title: '提交人', minWidth: 80 },
  173. { colKey: 'createTime', title: '提交时间', width: 170, cell: 'create-time' },
  174. ];
  175. const {
  176. loading: tableLoading,
  177. pagination,
  178. tableData,
  179. search,
  180. onChange,
  181. } = useFetchTable(serviceScopeUnbindCrmQueryApi, {
  182. fetchDataHandle: () => {
  183. selectedRowKeys.value = [];
  184. },
  185. params: computedParams,
  186. });
  187. const handlerBatchBind = () => {
  188. if (!selectedRowKeys.value.length) {
  189. MessagePlugin.error('请选择要划定的记录');
  190. return;
  191. }
  192. showSelectServiceUnitDialog.value = true;
  193. };
  194. </script>