add-range-dialog.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <my-drawer
  3. :visible="visible"
  4. size="80%"
  5. :header="false"
  6. :footer="false"
  7. attach="body"
  8. class="add-range-dialog"
  9. >
  10. <div class="add-range">
  11. <div class="page-action">
  12. <t-button
  13. theme="primary"
  14. :disabled="!selectedRowKeys.length"
  15. @click="handlerBatchBind"
  16. >
  17. <template #icon><SaveIcon /></template>
  18. 批量划定
  19. </t-button>
  20. <t-button variant="text" @click="handleClose">
  21. <template #icon><CloseIcon /></template>
  22. </t-button>
  23. </div>
  24. <SearchForm :fields="fields" :params="params">
  25. <template #user="{ item, params }">
  26. <select-type-user
  27. v-model="params[item.prop]"
  28. type="ACCOUNT_MANAGER"
  29. ></select-type-user>
  30. </template>
  31. </SearchForm>
  32. <div class="flex-1 page-wrap">
  33. <div class="btn-group"> </div>
  34. <t-table
  35. size="small"
  36. row-key="crmId"
  37. :columns="columns"
  38. :data="tableData"
  39. bordered
  40. :pagination="{
  41. defaultCurrent: 1,
  42. defaultPageSize: 10,
  43. onChange,
  44. showJumper: true,
  45. showPageSize: false,
  46. current: pagination.pageNumber,
  47. }"
  48. v-loading="tableLoading"
  49. :selected-row-keys="selectedRowKeys"
  50. @select-change="selectChange"
  51. >
  52. <template #type="{ col, row }">
  53. {{ customerTypeFilter(row[col.colKey]) }}
  54. </template>
  55. <template #begin-time="{ col, row }">
  56. {{ timestampFilter(row[col.colKey]) }}
  57. </template>
  58. <template #exam-start-time="{ col, row }">
  59. {{ timestampFilter(row[col.colKey]) }}
  60. </template>
  61. <template #exam-end-time="{ col, row }">
  62. {{ timestampFilter(row[col.colKey]) }}
  63. </template>
  64. <template #create-time="{ col, row }">
  65. {{ timestampFilter(row[col.colKey]) }}
  66. </template>
  67. </t-table>
  68. </div>
  69. </div>
  70. </my-drawer>
  71. <!-- MultDelineationDialog -->
  72. <mult-delineation-dialog
  73. v-model:visible="showMultDelineationDialog"
  74. :crm-ids="selectedRowKeys"
  75. dialog-title="保存划定"
  76. @success="search"
  77. >
  78. <p style="color: #595959; margin-bottom: 28px"
  79. >请选择您要需要将这些派单划定的服务单元!</p
  80. >
  81. </mult-delineation-dialog>
  82. </template>
  83. <script setup name="AddRangeDialog">
  84. import { reactive, ref, computed } from 'vue';
  85. import { omit } from 'lodash';
  86. import { MessagePlugin } from 'tdesign-vue-next';
  87. import { SaveIcon, CloseIcon } from 'tdesign-icons-vue-next';
  88. import { serviceScopeUnbindCrmQueryApi } from '@/api/service-unit';
  89. import useFetchTable from '@/hooks/useFetchTable';
  90. import { CUSTOMER_TYPE } from '@/config/constants';
  91. import { customerTypeFilter, timestampFilter } from '@/utils/filter';
  92. import MultDelineationDialog from '../../dispatch/dispatch-manage/mult-delineation-dialog.vue';
  93. import { dictToOptionList } from '@/utils/tool';
  94. const emit = defineEmits(['update:visible', 'success']);
  95. const props = defineProps({
  96. visible: Boolean,
  97. });
  98. let showMultDelineationDialog = ref(false);
  99. const fields = ref([
  100. {
  101. prop: 'crmUserId',
  102. label: '客户经理',
  103. type: 'select',
  104. labelWidth: 80,
  105. colSpan: 5,
  106. cell: 'user',
  107. },
  108. {
  109. prop: 'productType',
  110. label: '客户类型',
  111. type: 'select',
  112. labelWidth: 80,
  113. colSpan: 5,
  114. attrs: {
  115. clearable: true,
  116. },
  117. },
  118. {
  119. prop: 'customName',
  120. label: '客户名称',
  121. labelWidth: 80,
  122. colSpan: 5,
  123. options: dictToOptionList(CUSTOMER_TYPE),
  124. attrs: {
  125. clearable: true,
  126. },
  127. },
  128. {
  129. prop: 'crmNo',
  130. label: '项目单号',
  131. labelWidth: 80,
  132. colSpan: 5,
  133. attrs: {
  134. clearable: true,
  135. },
  136. },
  137. {
  138. type: 'buttons',
  139. colSpan: 2,
  140. children: [
  141. {
  142. type: 'button',
  143. text: '搜索',
  144. onClick: () => {
  145. search();
  146. },
  147. },
  148. ],
  149. },
  150. {
  151. prop: 'crmTime',
  152. label: '派单时间',
  153. type: 'daterange',
  154. labelWidth: 80,
  155. colSpan: 10,
  156. attrs: {
  157. clearable: true,
  158. valueType: 'time-stamp',
  159. },
  160. },
  161. ]);
  162. const params = reactive({
  163. crmUserId: '',
  164. productType: '',
  165. customName: '',
  166. crmNo: '',
  167. crmTime: [],
  168. });
  169. const computedParams = computed(() => {
  170. let data = omit(params, ['crmTime']);
  171. data.startTime = params.crmTime[0];
  172. data.endTime = params.crmTime[1];
  173. return data;
  174. });
  175. const selectedRowKeys = ref([]);
  176. const selectChange = (value) => {
  177. selectedRowKeys.value = value;
  178. };
  179. const columns = [
  180. {
  181. colKey: 'row-select',
  182. type: 'multiple',
  183. width: 50,
  184. fixed: 'left',
  185. },
  186. { colKey: 'crmNo', title: '项目单号', minWidth: 80 },
  187. { colKey: 'beginTime', title: '派单时间', width: 180, cell: 'begin-time' },
  188. { colKey: 'crmUserName', title: '客户经理', minWidth: 80 },
  189. { colKey: 'productType', title: '客户类型', width: 90, cell: 'type' },
  190. { colKey: 'customName', title: '客户名称', minWidth: 100 },
  191. { colKey: 'productName', title: '项目名称', minWidth: 80 },
  192. { colKey: 'productName', title: '实施产品', minWidth: 80 },
  193. {
  194. colKey: 'examStartTime',
  195. title: '考试开始时间',
  196. width: 180,
  197. cell: 'exam-start-time',
  198. },
  199. {
  200. colKey: 'examEndTime',
  201. title: '考试结束时间',
  202. width: 180,
  203. cell: 'exam-end-time',
  204. },
  205. { colKey: 'creatorName', title: '提交人', minWidth: 80 },
  206. { colKey: 'createTime', title: '提交时间', width: 180, cell: 'create-time' },
  207. ];
  208. const {
  209. loading: tableLoading,
  210. pagination,
  211. tableData,
  212. search,
  213. onChange,
  214. } = useFetchTable(serviceScopeUnbindCrmQueryApi, {
  215. fetchDataHandle: () => {
  216. selectedRowKeys.value = [];
  217. },
  218. params: computedParams,
  219. });
  220. const handlerBatchBind = () => {
  221. if (!selectedRowKeys.value.length) {
  222. MessagePlugin.error('您还没有选择任何派单!');
  223. return;
  224. }
  225. showMultDelineationDialog.value = true;
  226. };
  227. const handleClose = () => {
  228. emit('update:visible', false);
  229. };
  230. </script>
  231. <style lang="less">
  232. .add-range-dialog {
  233. .t-drawer__body {
  234. background-color: #f2f3f5;
  235. padding: 0;
  236. }
  237. .page-action {
  238. display: flex;
  239. justify-content: space-between;
  240. align-items: center;
  241. }
  242. }
  243. </style>