costManagement.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. <template>
  2. <div>
  3. <PageMain class="vh100">
  4. <SearchForm :fields="fields" :formInline="formInline" :onSearch="agreementQuery" :onReset="resetForm" />
  5. <ComplexTable :tableData="tableData" :columns="columns" :showIndex="false" :columnwidth="200" :showSelect="true"
  6. :pageInfo="pageInfo" @getList="getList" @selectionChange="selectionChange" uniqueIdName="costId">
  7. <template v-slot:table-title-btn>
  8. <el-button type="primary" @click="agreementSelection()">
  9. 添加费用
  10. <template #icon>
  11. <el-icon>
  12. <Plus />
  13. </el-icon>
  14. </template>
  15. </el-button>
  16. <el-dropdown placement="bottom-start">
  17. <el-button> 批量管理<el-icon>
  18. <arrow-down />
  19. </el-icon>
  20. </el-button>
  21. <template #dropdown>
  22. <el-dropdown-menu>
  23. <el-dropdown-item :disabled="!sysUpAndDownList.length" @click="batchDel">删除</el-dropdown-item>
  24. <el-dropdown-item :disabled="!sysUpAndDownList.length" @click="batchdisable">禁用</el-dropdown-item>
  25. <el-dropdown-item :disabled="!sysUpAndDownList.length" @click="batchenable">启用</el-dropdown-item>
  26. </el-dropdown-menu>
  27. </template>
  28. </el-dropdown>
  29. </template>
  30. <template v-slot:operation="scope">
  31. <el-button type="primary" link @click="agreemenUpdate(scope.operationData)"> 编辑
  32. </el-button>
  33. <el-dropdown placement="bottom-start" trigger="click">
  34. <span class="el-dropdown-link">
  35. 更 多
  36. </span>
  37. <template #dropdown>
  38. <el-dropdown-menu>
  39. <el-dropdown-item @click="enable(scope.operationData.costId)">启用</el-dropdown-item>
  40. <el-dropdown-item @click="disable(scope.operationData.costId)">禁用</el-dropdown-item>
  41. <el-dropdown-item @click="del(scope.operationData.costId)">删除</el-dropdown-item>
  42. </el-dropdown-menu>
  43. </template>
  44. </el-dropdown>
  45. </template>
  46. </ComplexTable>
  47. </PageMain>
  48. <el-dialog v-model="agreementSelectionVisible" title="选择协议" width="50%">
  49. <div class="Selection flex ">
  50. <div class="agreement flex f-c">
  51. <div class="flex a-c">
  52. <el-input v-model="agreementQueryName" style="width: 240px;margin-right: 10px;"
  53. placeholder="输入协议名称,简称,编码查找" />
  54. <el-button type="primary">查询</el-button>
  55. </div>
  56. <div class="flex f-c m-top-20" style="max-height: 400px;overflow-y: auto;">
  57. <div class="agreementItem flex f-c " :class="{ active: agritem.id == AgreementId }"
  58. v-for="(agritem, agrindex) in agreementList" :key="agrindex" @click="ItemClick(agritem)">
  59. <span class="m-btn-10">{{ agritem.agreementCode }}</span>
  60. <span>{{ agritem.agreementTitle }}</span>
  61. </div>
  62. </div>
  63. </div>
  64. <div class="rule flex f-c">
  65. <span class="strong">承保规则</span>
  66. <div class="flex f-c m-top-20" style="max-height: 400px;overflow-y: auto;">
  67. <el-radio-group v-model="ruleId">
  68. <div class="flex f-c ">
  69. <el-radio :value="item.id" v-for="(item, index) in ruleList" :key="index" @change="ruleItemclick"
  70. style="margin: 20px 0;">
  71. <p class="white-space">{{ item.ruleDescription }}</p>
  72. </el-radio>
  73. </div>
  74. </el-radio-group>
  75. </div>
  76. </div>
  77. </div>
  78. <template #footer>
  79. <div class="dialog-footer">
  80. <el-button @click="agreementSelectionVisible = false">取消</el-button>
  81. <el-button type="primary" @click="agreementSelectionConfirm">
  82. 确定
  83. </el-button>
  84. </div>
  85. </template>
  86. </el-dialog>
  87. <!-- 规则费用抽屉组件 -->
  88. <ruleFeeDialog v-if="ruleFeeVisible" :ruleFeeVisible="ruleFeeVisible" :agreementInfo="AgreementInfo"
  89. :RulesInfo="ruleInfo" @save="ruleFeeSave" @cancel="ruleFeeVisible = false" />
  90. <!-- 规则费用编辑组件 -->
  91. <ruleFeeDialogEdit :ruleFeeVisible="ruleFeeEditVisible" :headerTitle="ruleFeeHeaderTitle"
  92. :agreementInfo="AgreementInfo" :RulesInfo="ruleInfo" :costitemEditInfo="costitemEditInfo" @save="ruleFeeEditSave"
  93. @cancel="ruleFeeEditVisible = false" />
  94. </div>
  95. </template>
  96. <script lang="ts" setup>
  97. import { ref, reactive } from 'vue'
  98. import { useRouter } from "vue-router";
  99. import { ElMessage, ElMessageBox } from 'element-plus'
  100. import { loadDicts, getDict } from '@/utils/composables/dictService';//字典组件
  101. import ruleFeeDialog from "./agreement/components/ruleFeeDialog.vue";
  102. import ruleFeeDialogEdit from "./agreement/components/ruleFeeDialogEdit.vue";
  103. import api from '@/api';
  104. interface PageInfo {
  105. pageNum: number;
  106. pageSize: number;
  107. sizes: number[];
  108. total: number;
  109. }
  110. onBeforeMount(async () => {
  111. await loadDicts([ 'valid_status', 'is_enable', 'audit_status','insurance_type']);//获取多个字典
  112. findpage();//列表数据
  113. getDeptTree();
  114. agreement();
  115. valid_status.value = getDict('valid_status');//生效状态
  116. is_enable.value = getDict('is_enable');//协议状态
  117. insurance_type.value=getDict('insurance_type')
  118. audit_status.value=getDict('audit_status')
  119. });
  120. const tableData = ref([
  121. ]);
  122. const agreementQueryName = ref();//选择协议查询
  123. const agreementList = ref();//协议列表
  124. const sysUpAndDownList = ref<string[]>([])//选中id
  125. const deptOptions = ref()//机构数据
  126. const insurance_type=ref();
  127. const valid_status = ref();
  128. const audit_status=ref();
  129. const is_enable = ref();
  130. const router = useRouter();
  131. const pageInfo = ref({
  132. pageNum: 1,
  133. pageSize: 20,
  134. sizes: [10, 20, 30, 40, 50],
  135. total: 100,
  136. });
  137. const formInline = reactive({
  138. searchValue: '',//协议信息
  139. deptId: "",//归属
  140. companyId: '',//保险公司id
  141. agreementType: '',//协议类型
  142. validStatus: "",//有效状态
  143. isEnable: "",//协议状态
  144. withTax: "",
  145. dockingPerson: "",
  146. attributionName: "",
  147. takeStartDate: "",
  148. takeEndDate: "",
  149. loseStartDate: "",
  150. loseEndDate: "",
  151. })
  152. //表格字段数据
  153. const fields = ref([
  154. { label: "所属协议", model: "agreement", type: "input", placeholder: "输入代码,名称,简称查找" },
  155. {
  156. label: "险种", model: "productId", type: "select", options: insurance_type,
  157. },
  158. {
  159. label: "承保规则", model: "rulesName", type: "input", placeholder: "输入业务规则查找",
  160. },
  161. {
  162. label: "费用规则", model: "costRules", type: "input", placeholder: "输入费用规则关键字查找",
  163. },
  164. {
  165. label: "费用状态", model: "agreementStatus", type: "select", placeholder: "选择状态", options: is_enable,
  166. },
  167. {
  168. label: "审核状态", model: "auditStatus", type: "select", placeholder: "选择状态", options: audit_status,
  169. },
  170. {
  171. label: "有效状态", model: "validState", type: "select", placeholder: "请选择状态", options: valid_status,
  172. },
  173. {
  174. label: "生效时间", model: "effectiveTime", type: "date", dateType: "datetimerange", startplaceholder: "开始时间", endplaceholder: "结束时间",
  175. onChange: (value: any) => {
  176. console.log(value)
  177. formInline.takeStartDate = value[0];
  178. formInline.takeEndDate = value[1];
  179. }
  180. },
  181. {
  182. label: "失效时间", model: "failureTime", type: "date", dateType: "datetimerange", startplaceholder: "开始时间", endplaceholder: "结束时间",
  183. onChange: (value: any) => {
  184. formInline.loseStartDate = value[0];
  185. formInline.loseEndDate = value[1];
  186. }
  187. },
  188. ]);
  189. //费用数据查询
  190. function findpage() {
  191. api.agreementApi.queryByFeePage({ pages: pageInfo.value.pageNum, size: pageInfo.value.pageSize, ...formInline }).then((res: any) => {
  192. if (res.code == '200') {
  193. tableData.value = res.data.records;
  194. pageInfo.value.pageNum = res.data.current;
  195. pageInfo.value.pageSize = res.data.size;
  196. pageInfo.value.total = res.data.total;
  197. } else {
  198. }
  199. });
  200. }
  201. //协议列表查询
  202. function agreement() {
  203. api.agreementApi.agreementList({ pages: pageInfo.value.pageNum, size: pageInfo.value.pageSize, searchValue: agreementQueryName.value }).then((res: any) => {
  204. if (res.code == '200') {
  205. agreementList.value = res.data.records;
  206. } else {
  207. }
  208. });
  209. }
  210. const columns = [
  211. {
  212. prop: "agreementAbbreviation", label: "协议信息", width: '300',
  213. formatter: (row: any) => {
  214. return `${row.agreementCode}\n${row.agreementAbbreviation}`
  215. }
  216. },
  217. {
  218. prop: "ruleDescription", label: "承保规则", width: '500',
  219. },
  220. { prop: "productName", label: "险种", width: '120', },
  221. {
  222. prop: "costRules", label: "费用规则",width: '500',
  223. },
  224. {
  225. prop: "isEnabled", label: "费用状态", width: '100', component: "Tag",
  226. formatter: (row: any) => {
  227. let name = getDict('is_enable').find(val => val.value == row.isEnabled).label
  228. if (name) {
  229. return { type: 'primary', text: name };
  230. }
  231. }
  232. },
  233. {
  234. prop: "approved", label: "审核状态", width: '120', component: "Tag",
  235. formatter: (row: any) => {
  236. let name = getDict('audit_status').find(val => val.value == row.approved).label
  237. if (name) {
  238. return { type: 'warning', text: name };
  239. }
  240. }
  241. },
  242. { prop: "effectiveTime", label: "生效时间", width: '200' },
  243. { prop: "failureTime", label: "失效时间", width: '200' },
  244. {
  245. prop: "ruleConditions", label: "交强费用", width: '300', formatter: (row: any) => {
  246. let info = row.ruleConditions.find((val: any) => val.costType == '交强险');
  247. if (info) {
  248. return `入口:${info.inlet.toFixed(2)}% 出口:${info.export.toFixed(2)}%\n加投:${info.addThrow.toFixed(2)}% 手续费:${info.commission.toFixed(2)}%`
  249. } else {
  250. return '-';
  251. }
  252. }
  253. },
  254. {
  255. prop: "ruleConditions", label: "商业费用", width: '300', formatter: (row: any) => {
  256. let info = row.ruleConditions.find((val: any) => val.costType == '商业险');
  257. if (info) {
  258. return `入口:${info.inlet.toFixed(2)}% 出口:${info.export.toFixed(2)}%\n加投:${info.addThrow.toFixed(2)}% 手续费:${info.commission.toFixed(2)}%`
  259. } else {
  260. return '-';
  261. }
  262. }
  263. },
  264. {
  265. prop: "ruleConditions", label: "驾意险费用", width: '300', formatter: (row: any) => {
  266. let info = row.ruleConditions.find((val: any) => val.costType == '驾意险');
  267. if (info) {
  268. return `入口:${info.inlet.toFixed(2)}% 出口:${info.export.toFixed(2)}%\n加投:${info.addThrow.toFixed(2)}% 手续费:${info.commission.toFixed(2)}%`
  269. } else {
  270. return '-';
  271. }
  272. }
  273. },
  274. ];
  275. //分页事件
  276. function getList(item: PageInfo) {
  277. pageInfo.value.pageNum = item.pageNum;
  278. pageInfo.value.pageSize = item.pageSize;
  279. findpage();
  280. };
  281. const agreemenUpdate = async (item: any) => {
  282. ruleFeeHeaderTitle.value = item.productName;
  283. AgreementInfo.value = { agreementCode: item.agreementCode, agreementTitle: item.agreementAbbreviation };
  284. ruleInfo.value = { ruleDescription: item.ruleDescription };
  285. await regionLicenseRegion('0');//车牌地区
  286. await regionLicenseNumber('14');//车牌号
  287. await api.agreementApi.AgreementFeeById(item.costId).then((res: any) => {
  288. if (res.code == '200') {
  289. res.data.ruleConditions = processArray(res.data.ruleConditions);
  290. costitemEditInfo.value = res.data;
  291. ruleFeeEditVisible.value = true;
  292. } else {
  293. }
  294. });
  295. }
  296. const ruleFeeEditSave = (data: object) => {
  297. api.agreementApi.AgreementFeeupdate(data).then((res: any) => {
  298. if (res.code == '200') {
  299. ElMessage({
  300. type: 'success',
  301. message: res.msg,
  302. plain: true,
  303. })
  304. ruleFeeEditVisible.value=false;
  305. findpage();
  306. } else {
  307. }
  308. });
  309. }
  310. //添加车牌和车牌地区
  311. const processArray = (array: any[]) => {
  312. return array.map((val) => {
  313. switch (val.attrType) {
  314. case 'inputNumber':
  315. case 'datetime':
  316. if (!val.operator) {
  317. val.operator = '1'; // 设置默认值
  318. }
  319. break;
  320. default:
  321. break;
  322. }
  323. if (val.attrCode == 'LicenseNo') {
  324. val.dictLabal = licensePlateNumber.value;
  325. }
  326. if (val.attrCode == 'LicenseArea') {
  327. val.dictLabal = licensePlateRegion.value;
  328. }
  329. return val;
  330. });
  331. };
  332. const licensePlateRegion = ref();//车牌地区
  333. const licensePlateNumber = ref();//车牌号
  334. const regionLicenseRegion = (value: string) => {
  335. api.agreementApi.getAreaLicense(value).then((res: any) => {
  336. if (res.code == '200') {
  337. let data: any = [];
  338. res.data.map((val: any) => {
  339. data.push({
  340. code: val.areaNumber,
  341. name: val.license,
  342. })
  343. return val;
  344. })
  345. licensePlateRegion.value = data;
  346. } else {
  347. }
  348. });
  349. }
  350. const regionLicenseNumber = (value: string) => {
  351. api.agreementApi.getAreaLicense(value).then((res: any) => {
  352. if (res.code == '200') {
  353. let data: any = [];
  354. res.data.map((val: any) => {
  355. data.push({
  356. code: val.areaNumber,
  357. name: val.license,
  358. })
  359. return val;
  360. })
  361. licensePlateNumber.value = data;
  362. } else {
  363. }
  364. });
  365. }
  366. //多选事件
  367. const selectionChange = (val: any) => {
  368. console.log(val)
  369. sysUpAndDownList.value = val;
  370. }
  371. //禁用
  372. const disable = (value: string) => {
  373. console.log(value)
  374. ElMessageBox.confirm(
  375. '确定要禁用该协议吗,禁用后,该协议不在支持报价出单,并且已核保待缴费,待支付的订单,都将失效,请确认是否禁用?',
  376. '禁用协议',
  377. {
  378. confirmButtonText: '确定禁用',
  379. type: 'error',
  380. center: true,
  381. confirmButtonClass: 'el-button--danger',
  382. }
  383. )
  384. .then(() => {
  385. sysUpAndDown(false, [value]);
  386. })
  387. }
  388. //启用
  389. const enable = (value: string) => {
  390. sysUpAndDown(true, [value]);
  391. }
  392. const del = (value: string) => {
  393. ElMessageBox.confirm(
  394. '确定要删除该协议吗,删除后,该协议不在支持报价出单,并且已核保待缴费,待支付的订单,都将失效,请确认是否删除?',
  395. '删除协议',
  396. {
  397. confirmButtonText: '确定删除',
  398. type: 'error',
  399. center: true,
  400. confirmButtonClass: 'el-button--danger',
  401. }
  402. )
  403. .then(() => {
  404. api.agreementApi.AgreementFeedeleteByIds([value]).then((res: any) => {
  405. if (res.code == '200') {
  406. ElMessage({
  407. type: 'success',
  408. message: res.msg,
  409. plain: true,
  410. })
  411. router.push({
  412. name: 'reload',
  413. })
  414. }
  415. });
  416. })
  417. }
  418. //批量删除
  419. const batchDel = () => {
  420. ElMessageBox.confirm(
  421. '确定要删除该协议吗,删除后,该协议不在支持报价出单,并且已核保待缴费,待支付的订单,都将失效,请确认是否删除?',
  422. '删除协议',
  423. {
  424. confirmButtonText: '确定删除',
  425. type: 'error',
  426. center: true,
  427. confirmButtonClass: 'el-button--danger',
  428. }
  429. )
  430. .then(() => {
  431. api.agreementApi.agreementDelete(sysUpAndDownList.value).then((res: any) => {
  432. if (res.code == '200') {
  433. ElMessage({
  434. type: 'success',
  435. message: res.msg,
  436. plain: true,
  437. })
  438. router.push({
  439. name: 'reload',
  440. })
  441. }
  442. });
  443. })
  444. }
  445. //批量禁用
  446. const batchdisable = () => {
  447. ElMessageBox.confirm(
  448. '确定要禁用该协议吗,禁用后,该协议不在支持报价出单,并且已核保待缴费,待支付的订单,都将失效,请确认是否禁用?',
  449. '禁用协议',
  450. {
  451. confirmButtonText: '确定禁用',
  452. type: 'error',
  453. center: true,
  454. confirmButtonClass: 'el-button--danger',
  455. }
  456. )
  457. .then(async () => {
  458. await sysUpAndDown(false, undefined);
  459. })
  460. .catch(() => {
  461. })
  462. }
  463. //批量启用
  464. const batchenable = async () => {
  465. await sysUpAndDown(true, undefined);
  466. }
  467. const agreementQuery = () => {
  468. findpage();
  469. }
  470. const sysUpAndDown = async (type: boolean, list?: string[]) => {
  471. await api.agreementApi.AgreementFeeEnableByIds(type, list ? list : sysUpAndDownList.value).then((res: any) => {
  472. if (res.code == '200') {
  473. findpage();
  474. ElMessage({
  475. type: 'success',
  476. message: res.msg,
  477. plain: true,
  478. })
  479. }
  480. });
  481. }
  482. const resetForm = () => {
  483. for(let key in formInline){
  484. formInline[key as keyof typeof formInline]='';
  485. }
  486. findpage();
  487. }
  488. const getDeptTree = () => {
  489. api.institutionApi.institutionList({}).then((res: any) => {
  490. if (res.code == '200') {
  491. deptOptions.value = res.data;
  492. } else {
  493. }
  494. });
  495. }
  496. //选择协议弹窗
  497. const agreementSelectionVisible = ref(false);
  498. const ruleFeeVisible = ref(false);
  499. const ruleFeeEditVisible = ref(false);//编辑弹窗
  500. const ruleFeeHeaderTitle = ref();//编辑弹窗title
  501. const costitemEditInfo = ref();//编辑对象
  502. const AgreementInfo = ref();//协议对象
  503. const ruleInfo = ref();//规则对象
  504. const AgreementId = ref();//规则id
  505. const ruleId = ref();//规则id
  506. const ruleList = ref();//协议规则列表
  507. const agreementSelection = () => {
  508. agreementSelectionVisible.value = true;
  509. }
  510. const ItemClick = (item: any) => {
  511. AgreementInfo.value = item;
  512. AgreementId.value = item.id;
  513. api.agreementApi.agreementRulesList(AgreementId.value).then((res: any) => {
  514. if (res.code == '200') {
  515. ruleList.value = res.data;
  516. }
  517. });
  518. }
  519. //
  520. const ruleItemclick = (value: string | number | boolean | undefined) => {
  521. let info = ruleList.value.find((val: any) => val.id == value);
  522. ruleInfo.value = info;
  523. }
  524. const agreementSelectionConfirm = () => {
  525. agreementSelectionVisible.value = false;
  526. ruleFeeVisible.value = true;
  527. }
  528. //规则弹窗回调方法
  529. const ruleFeeSave = (data: object) => {
  530. console.log(data)
  531. api.agreementApi.ptlAgreementCostsave(data).then((res: any) => {
  532. if (res.code == '200') {
  533. ElMessage({
  534. type: 'success',
  535. message: res.msg,
  536. plain: true,
  537. })
  538. ruleFeeVisible.value = false;
  539. findpage();
  540. } else {
  541. }
  542. });
  543. }
  544. </script>
  545. <style lang="scss" scoped>
  546. .demo-form-inline .el-input {
  547. --el-input-width: 220px;
  548. }
  549. .demo-form-inline .el-select {
  550. --el-select-width: 220px;
  551. }
  552. :deep(.el-dropdown-link) {
  553. display: flex;
  554. align-items: center;
  555. margin-left: 15px;
  556. color: var(--el-color-primary);
  557. cursor: pointer;
  558. }
  559. .el-inputs {
  560. width: 100% !important;
  561. }
  562. .Selection {
  563. border: 1px solid #dcdfe6;
  564. border-radius: 4px;
  565. .agreement {
  566. width: 40%;
  567. padding: 15px;
  568. border-right: 1px solid #dcdfe6;
  569. .agreementItem {
  570. padding: 10px;
  571. border-radius: 5px;
  572. &:hover {
  573. background: #f2f2f2;
  574. }
  575. }
  576. }
  577. .active {
  578. color: #1890ff;
  579. background: #f2f2f2;
  580. }
  581. .rule {
  582. width: 60%;
  583. padding: 15px;
  584. .white-space {
  585. display: inline-block;
  586. margin-bottom: 10px;
  587. white-space: normal;
  588. }
  589. }
  590. }
  591. </style>