channelDataDetail.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <div class="log">
  3. <PageMain class="vh100">
  4. <div class='btn-box'>
  5. <el-button type="primary" plain class='query-btn'
  6. @click='dialogShow'>{{selectedKeys.length?`已选${selectedKeys.length}项`:'筛选条件'}}</el-button>
  7. <div class='query-btn'>
  8. <DowButton @endAnim='downloadFile'></DowButton>
  9. </div>
  10. </div>
  11. <QueryForm :option="listOption" @query='query' @delSelect='delSelect' ref='queryFormRef'></QueryForm>
  12. <!-- 表格 -->
  13. <ComplexTable :tableData="tableData" :showSelect='false' :columns="listOption.columns" :showIndex="false"
  14. :columnwidth="120" :pageInfo="pageInfo" @getList="getList" :showOperation='false'>
  15. <template v-slot:search="scope">
  16. <Sort :scope="scope.slotData" :globalSortKey="globalSortKey" :globalSortOrder="globalSortOrder"
  17. @update:sort="handleSortUpdate"></Sort>
  18. </template>
  19. </ComplexTable>
  20. <FilterDialog :show='isShow' @close='isShow=false' @sure='filterSure' ref='filterDialogRef' @selectedKeys='selected'
  21. routerKey='routerKey'>
  22. </FilterDialog>
  23. </PageMain>
  24. </div>
  25. </template>
  26. <script setup lang="ts">
  27. import { useRouter } from "vue-router";
  28. import api from "@/api";
  29. import QueryForm from "../../components/queryForm.vue";
  30. import FilterDialog from "../../components/filterDialog.vue";
  31. import DowButton from "../../components/button.vue";
  32. import Sort from "../../components/sort.vue";
  33. import useUserStore from "@/store/modules/message";
  34. import PageInfo from "@/api/types/agreementTypes";
  35. import { ElMessage } from "element-plus";
  36. const router = useRouter();
  37. const userStore = useUserStore();
  38. const isShow = ref(false);
  39. const isSort = ref();
  40. const pageInfo = ref({
  41. pageNum: 1,
  42. pageSize: 10,
  43. sizes: [10, 20, 30, 40, 50],
  44. total: 0,
  45. });
  46. const listOption = reactive({
  47. rowKey: "channelDelId",
  48. //查询
  49. queryFormFields: [],
  50. // 表格列
  51. columns: [
  52. {
  53. prop: "salesmanName",
  54. label: "姓名",
  55. width: "100",
  56. },
  57. {
  58. prop: "salesmanPhone",
  59. label: "手机号",
  60. width: "120",
  61. },
  62. {
  63. prop: "deptName",
  64. label: "所属机构",
  65. width: "300",
  66. },
  67. {
  68. prop: "orderNo",
  69. label: "订单号",
  70. width: "180",
  71. },
  72. {
  73. prop: "licenseNo",
  74. label: "车牌号",
  75. width: "180",
  76. },
  77. {
  78. prop: "orderTypeName",
  79. label: "订单类型",
  80. width: "180",
  81. },
  82. {
  83. prop: "riskName",
  84. label: "险种",
  85. width: "180",
  86. },
  87. {
  88. prop: "orderSourceName",
  89. label: "报价来源",
  90. width: "180",
  91. },
  92. {
  93. prop: "sumPremium",
  94. label: "保费",
  95. width: "180",
  96. align: "right",
  97. sortable: true,
  98. },
  99. {
  100. prop: "orderStatusName",
  101. label: "状态",
  102. width: "180",
  103. },
  104. {
  105. prop: "createTime",
  106. label: "录单时间",
  107. width: "180",
  108. },
  109. {
  110. prop: "recordTime",
  111. label: "签单时间",
  112. width: "180",
  113. },
  114. {
  115. prop: "companyName",
  116. label: "保险公司",
  117. width: "180",
  118. },
  119. {
  120. prop: "partnerCompanyName",
  121. label: "合作保险公司",
  122. width: "300",
  123. },
  124. ],
  125. });
  126. const selectedKeys = ref([]);
  127. const selected = function (val) {
  128. selectedKeys.value = val;
  129. };
  130. //查询数据
  131. const phone = JSON.parse(localStorage.getItem("userInfo")).username;
  132. //获取默认选择数据
  133. const queryFormRes = ref();
  134. const routerKey = ref("channelDataDetail");
  135. const defaultList = ref();
  136. const pageHiddenList = ref([]); //页面不显示的数据
  137. const initDefaultList = async () => {
  138. const { data } = await api.manageApi.getSearchDefaultList({
  139. routerKey: routerKey.value,
  140. userId: phone,
  141. });
  142. listOption.queryFormFields = data.filter((e) => e.showFlag);
  143. pageHiddenList.value = data.filter((e) => !e.showFlag);
  144. defaultList.value = data.map((e) => e.id);
  145. selectedKeys.value = defaultList.value;
  146. queryFormRes.value = queryFormRef.value?.initDefaultSaveForm();
  147. queryList();
  148. };
  149. //删除
  150. const filterDialogRef = ref();
  151. const delSelect = (id) => {
  152. listOption.queryFormFields = listOption.queryFormFields.filter(
  153. (item) => item.id != id
  154. );
  155. filterDialogRef.value.initList(
  156. [...listOption.queryFormFields, ...pageHiddenList.value],
  157. defaultList.value
  158. );
  159. };
  160. //打开dialogShow
  161. const dialogShow = function () {
  162. isShow.value = true;
  163. filterDialogRef.value.initList(
  164. [...listOption.queryFormFields, ...pageHiddenList.value],
  165. defaultList.value
  166. );
  167. };
  168. //确定
  169. const queryFormRef = ref();
  170. const filterSure = (item, index) => {
  171. isShow.value = false;
  172. const secondGroupIds = item.list.map((item) => item.id);
  173. const oldList = listOption.queryFormFields.filter((item) =>
  174. secondGroupIds.includes(item.id)
  175. );
  176. const firstGroupIds = listOption.queryFormFields.map((item) => item.id);
  177. let newList = item.list.filter((item) => !firstGroupIds.includes(item.id));
  178. //过滤掉默认不显示的数据
  179. const hiddenList = new Set(pageHiddenList.value.map((item) => item.id));
  180. const filterList = newList.filter((item) => !hiddenList.has(item.id));
  181. listOption.queryFormFields = [...oldList, ...filterList];
  182. queryFormRef.value?.initDefaultSaveForm();
  183. selectedKeys.value = item.list.filter((item) => item.id);
  184. };
  185. const globalSortKey = ref("");
  186. const globalSortOrder = ref<"asc" | "desc">("asc");
  187. // 处理子组件传递的排序更新
  188. const handleSortUpdate = (sortInfo: {
  189. key: string;
  190. order: string;
  191. name: string;
  192. }) => {
  193. globalSortKey.value = sortInfo.key;
  194. globalSortOrder.value = sortInfo.order;
  195. queryList();
  196. };
  197. //查询
  198. const query = (item) => {
  199. queryFormRes.value = item;
  200. queryList();
  201. };
  202. //数据查询
  203. const tableData = ref([]);
  204. const queryList = async () => {
  205. let query = { ...queryFormRes.value };
  206. const { data } = await api.manageApi.channelDataDetailPageList({
  207. pageNo: pageInfo.value.pageNum,
  208. pageSize: pageInfo.value.pageSize,
  209. routerKey: routerKey.value,
  210. userId: phone,
  211. orderType: globalSortKey.value
  212. ? globalSortKey.value + " " + globalSortOrder.value
  213. : "",
  214. ...query,
  215. });
  216. tableData.value = data.records;
  217. pageInfo.value.pageNum = data.current;
  218. pageInfo.value.pageSize = data.size;
  219. pageInfo.value.total = data.total;
  220. };
  221. //分页事件
  222. function getList(item: PageInfo) {
  223. pageInfo.value.pageNum = item.pageNum;
  224. pageInfo.value.pageSize = item.pageSize;
  225. queryList();
  226. }
  227. //导出
  228. const downloadFile = async () => {
  229. let query = { ...queryFormRes.value };
  230. const { data, msg } = await api.manageApi.channelDataDetailToPage({
  231. pageNo: pageInfo.value.pageNum,
  232. pageSize: pageInfo.value.pageSize,
  233. routerKey: routerKey.value,
  234. userId: phone,
  235. orderType: globalSortKey.value
  236. ? globalSortKey.value + " " + globalSortOrder.value
  237. : "",
  238. ...query,
  239. });
  240. ElMessage({
  241. message: msg,
  242. type: "success",
  243. });
  244. userStore.count++;
  245. };
  246. onMounted(() => {
  247. initDefaultList();
  248. });
  249. </script>
  250. <style scoped lang="scss">
  251. .log {
  252. .query-btn {
  253. margin-left: 20px;
  254. }
  255. .btn-box {
  256. padding-bottom: 15px;
  257. margin-bottom: 24px;
  258. border-bottom: 1px solid #eeeeee;
  259. display: flex;
  260. justify-content: flex-end;
  261. }
  262. }
  263. :deep(.caret-wrapper) {
  264. display: none !important;
  265. }
  266. </style>