salesmanDataDetail.vue 7.2 KB

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