adjustRecord.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <script setup lang="ts">
  2. import api from '@/api';
  3. import { useRoute, useRouter } from 'vue-router';
  4. import { dictData } from '@/views/localDict/index';
  5. import { loadDicts, getDict } from '@/utils/composables/dictService';
  6. import { downloadByData } from '@/utils/composables/download';
  7. interface PageInfo {
  8. pageNum: number;
  9. pageSize: number;
  10. sizes: number[];
  11. total: number;
  12. }
  13. // router
  14. const route = useRoute();
  15. const router = useRouter();
  16. // state
  17. const typeData = dictData.ADJUST_TYPEDATA;
  18. const statusData = dictData.ADJUST_STATUSDATA;
  19. const companyData = ref([]);
  20. // table
  21. const tableData = ref([]);
  22. const pageInfo = ref<PageInfo>({
  23. pageNum: 1,
  24. pageSize: 10,
  25. sizes: [10, 20, 30, 40, 50],
  26. total: 0,
  27. });
  28. const columns: any = [
  29. {
  30. prop: "orderNo", label: "订单号", width: 200,
  31. },
  32. {
  33. prop: "licenseNo", label: "车牌号", width: 100,
  34. },
  35. {
  36. prop: "companyName", label: "保险公司", width: 200,
  37. },
  38. {
  39. prop: "premium", label: "保费", width: 150,
  40. formatter: (row: any) => {
  41. return '¥' + row.premium
  42. }
  43. },
  44. {
  45. prop: "status", label: "批单状态", width: 150, component: "Tag",
  46. formatter: (row: any) => {
  47. // let name = getDict('is_enable').find(val => val.value == 1).label;
  48. // 批单状态 0.订单批改中 1.待审核 2.审核通过 3.退回修改 4.拒绝批改
  49. let name = statusData.find(val => val.value == row.status)?.label;
  50. let type = 'primary';
  51. if (row.status === 4) {
  52. type = 'danger';
  53. } else if (row.status === 3) {
  54. type = 'warning';
  55. }
  56. return { type: type, text: name };
  57. }
  58. },
  59. {
  60. prop: "type", label: "批改类型", width: 150,
  61. formatter: (row: any) => {
  62. let name = typeData.find(val => val.value == row.type)?.label;
  63. return name;
  64. }
  65. },
  66. {
  67. prop: "changePremium", label: "保费变化", width: 150,
  68. formatter: (row: any) => {
  69. if (!row.afterPremium) {
  70. return '--';
  71. }
  72. let val = (((row.premium * 100) - (row.afterPremium * 100)) / 100);
  73. return val > 0 ? `-¥${val}` : `¥${Math.abs(val)}`;
  74. }
  75. },
  76. {
  77. prop: "afterPremium", label: "批改后保费", width: 150,
  78. formatter: (row: any) => {
  79. return row.afterPremium ? `¥${row.afterPremium}` : '--';
  80. }
  81. },
  82. {
  83. prop: "createBy", label: "批改人", width: 150,
  84. },
  85. {
  86. prop: "createTime", label: "批改时间", width: 200,
  87. },
  88. ];
  89. // search
  90. const fields = computed(() => {
  91. return [
  92. {
  93. label: "订单号", model: "orderNo", type: "input", placeholder: "输入订单号查找",
  94. },
  95. {
  96. label: "车牌号", model: "licenseNo", type: "input", placeholder: "输入车牌号查找",
  97. },
  98. {
  99. label: "保险公司", model: "companyId", type: "select", filterable: true, options: companyData.value,
  100. },
  101. {
  102. label: "业务员信息", model: "salesman", type: "input", placeholder: "输入业务员姓名、手机号查找",
  103. },
  104. {
  105. label: "录入类型", model: "entryStatus", type: "select", closeable: false, options: dictData.ADJUST_ENTRYSTATUSDATA,
  106. },
  107. {
  108. label: "批改状态", model: "status", type: "select", options: statusData,
  109. },
  110. {
  111. label: "批改类型", model: "type", type: "select", options: typeData,
  112. },
  113. {
  114. label: "批改时间", model: "time", type: "date", dateType: "datetimerange", startplaceholder: "开始时间", endplaceholder: "结束时间",
  115. format: "YYYY-MM-DD HH:mm:ss", valueFormat: "YYYY-MM-DD HH:mm:ss", timeFormat: "HH:mm:ss",
  116. onChange: (value: any) => {
  117. if (value) {
  118. formInline.value.endDate = value[1];
  119. formInline.value.startDate = value[0];
  120. } else {
  121. formInline.value.endDate = '';
  122. formInline.value.startDate = '';
  123. }
  124. }
  125. },
  126. ]
  127. });
  128. const initialForm = {
  129. time: [],
  130. endDate: '',
  131. startDate: '',
  132. entryStatus: 1
  133. };
  134. const formInline = ref<any>({ ...initialForm });
  135. // 生命周期
  136. onBeforeMount(async () => {
  137. // 路由参数
  138. if (route.query.orderNo) formInline.value.orderNo = route.query.orderNo;
  139. // 获取多个字典
  140. // await loadDicts(['valid_status', 'is_enable', 'audit_status', 'insurance_type']);
  141. api.insuranceApi.leftList('').then((res: any) => {
  142. if(res.code == 200) {
  143. companyData.value = res.data.map((item: any) => ({
  144. label: item.name,
  145. value: item.id
  146. }));
  147. }
  148. });
  149. // table数据
  150. getData();
  151. });
  152. // 分页数据
  153. const getData = () => {
  154. const { time, ...params } = formInline.value;
  155. api.insurancePolicyApi.adjustList({
  156. pages: pageInfo.value.pageNum,
  157. size: pageInfo.value.pageSize,
  158. ...params
  159. }).then((res: any) => {
  160. if (res.code == '200') {
  161. tableData.value = res.data.records;
  162. // 分页
  163. pageInfo.value.total = res.data.total;
  164. pageInfo.value.pageNum = res.data.current;
  165. pageInfo.value.pageSize = res.data.size;
  166. }
  167. });
  168. };
  169. // 搜索事件
  170. const searchForm = () => {
  171. getData();
  172. }
  173. const resetForm = () => {
  174. formInline.value = { ...initialForm };
  175. getData();
  176. }
  177. // 分页事件
  178. const getList = (item: PageInfo) => {
  179. pageInfo.value.pageNum = item.pageNum;
  180. pageInfo.value.pageSize = item.pageSize;
  181. getData();
  182. };
  183. // 多选事件
  184. const selectionChange = (val: any) => {
  185. console.log('sel', val)
  186. };
  187. // 导出事件
  188. const exportLoading = ref(false);
  189. const handleExport = () => {
  190. exportLoading.value = true;
  191. const { time, ...params } = formInline.value;
  192. api.insurancePolicyApi.exportAdjustList(params).then((res: any) => {
  193. const fileName = '批改明细' + new Date().getTime() + '.xlsx';
  194. downloadByData(res, fileName, 'application/vnd.ms-excel');
  195. }).finally(() => {
  196. exportLoading.value = false;
  197. });
  198. }
  199. // 详情
  200. const toDetail = (e: any) => {
  201. router.push({
  202. path: '/insurancePolicy/adjustRecord/detail',
  203. query: {
  204. id: e.operationData.id,
  205. orderNo: e.operationData.orderNo,
  206. }
  207. });
  208. // window.open(`/#/insurancePolicy/adjustRecord/detail?id=${e.operationData.id}&orderNo=${e.operationData.orderNo}`, '_blank');
  209. }
  210. defineOptions({
  211. name: 'InsurancePolicyRecord',
  212. })
  213. </script>
  214. <template>
  215. <PageMain class="vh100">
  216. <SearchForm :isOffset="true"
  217. :fields="fields" :formInline="formInline"
  218. :onSearch="searchForm" :onReset="resetForm"
  219. />
  220. <ComplexTable
  221. :columns="columns" :columnwidth="200"
  222. :showIndex="false" :showSelect="true"
  223. :pageInfo="pageInfo"
  224. :tableData="tableData"
  225. @getList="getList"
  226. @selectionChange="selectionChange">
  227. <template v-slot:table-title-btn>
  228. <el-button class="radius-2px width-100" type="primary" :loading="exportLoading" @click="handleExport">导出</el-button>
  229. </template>
  230. <template v-slot:operation="scope">
  231. <el-button type="primary" link
  232. @click="toDetail(scope)">
  233. 详情
  234. </el-button>
  235. </template>
  236. </ComplexTable>
  237. </PageMain>
  238. </template>
  239. <style lang="scss" scoped>
  240. /* 样式 */
  241. </style>