securityCheckHeader.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. <template>
  2. <div class="security-check-header">
  3. <template v-if="title">
  4. <div class="title">{{ title }}</div>
  5. </template>
  6. <a-form
  7. ref="form"
  8. class="form"
  9. name="basic"
  10. :model="formData"
  11. @keyup.enter.native="search"
  12. >
  13. <template v-if="withChangeButton">
  14. <a-form-item style="margin-right: 16px">
  15. <a-button
  16. size="small"
  17. :class="['btn-icon-only', { 'icon-change': !changeButtonLoading }]"
  18. :loading="changeButtonLoading"
  19. @click="change"
  20. />
  21. </a-form-item>
  22. </template>
  23. <template v-if="withDatePicker">
  24. <a-form-item prop="beginDate" style="margin-right: 8px">
  25. <a-date-picker
  26. v-model="formData.beginDate"
  27. type="date"
  28. size="small"
  29. format="YYYY-MM-DD"
  30. valueFormat="YYYY-MM-DD"
  31. />
  32. </a-form-item>
  33. <a-form-item prop="endDate" style="margin-right: 36px">
  34. <a-date-picker
  35. v-model="formData.endDate"
  36. type="date"
  37. size="small"
  38. format="YYYY-MM-DD"
  39. valueFormat="YYYY-MM-DD"
  40. />
  41. </a-form-item>
  42. <a-form-item
  43. prop="dateRangeRadio"
  44. class="radio-wrapper"
  45. style="margin-right: 36px"
  46. >
  47. <a-radio-group v-model="formData.dateRangeRadio" size="small">
  48. <a-radio-button
  49. value="当日"
  50. :class="formData.dateRangeRadio == '当日' ? 'btn-mo' : 'btn-mos'"
  51. style="border-right: none"
  52. ><div class="btn-day">当日</div></a-radio-button
  53. >
  54. <a-radio-button
  55. value="当月"
  56. :class="formData.dateRangeRadio == '当月' ? 'btn-mo' : 'btn-mos'"
  57. ><div class="btn-day">当月</div></a-radio-button
  58. >
  59. <a-radio-button
  60. value="当年"
  61. style="border-left: none"
  62. :class="formData.dateRangeRadio == '当年' ? 'btn-mo' : 'btn-mos'"
  63. ><div class="btn-day">当年</div></a-radio-button
  64. >
  65. </a-radio-group>
  66. </a-form-item>
  67. </template>
  68. <template v-if="withSelect">
  69. <a-form-item prop="selection" style="margin-right: 16px">
  70. <a-select :placeholder="selectPlaceholder" @change="handleChange">
  71. <a-select-option
  72. v-for="item in optionLists"
  73. :key="item.name"
  74. :value="item.name"
  75. :title="item.label"
  76. >
  77. {{ item.name }}
  78. </a-select-option>
  79. </a-select>
  80. <!-- <a-select
  81. v-model="formData.selection"
  82. size="small"
  83. :default-value="optionLists[0]"
  84. >
  85. <a-select-option
  86. v-for="option in optionList"
  87. :key="option.value"
  88. :value="option.value"
  89. :label="option.label"
  90. />
  91. </a-select> -->
  92. </a-form-item>
  93. </template>
  94. <template v-if="withInput">
  95. <a-form-item prop="searchText" style="margin-right: 8px">
  96. <a-auto-complete
  97. ref="autocomplete"
  98. v-model="formData.searchText"
  99. size="small"
  100. prefix-icon="el-icon-search"
  101. :trigger-on-focus="false"
  102. :fetch-suggestions="querySearch"
  103. value-key="name"
  104. :placeholder="searchPlaceholder"
  105. clearable
  106. @clear="inputClearHandler"
  107. />
  108. </a-form-item>
  109. </template>
  110. <template v-if="withSearchButton">
  111. <a-form-item style="margin-right: 16px">
  112. <a-button size="small" type="primary" @click="search">查询</a-button>
  113. </a-form-item>
  114. <!-- <a-form-item style="margin-right: 24px">
  115. <a-button size="small" class="btn-white" @click="resetSearch"
  116. >重置</a-button
  117. >
  118. </a-form-item> -->
  119. </template>
  120. <template v-if="withExportButton">
  121. <a-form-item>
  122. <a-button size="small" class="btn-icon-only icon-export" />
  123. </a-form-item>
  124. </template>
  125. </a-form>
  126. </div>
  127. </template>
  128. <script>
  129. export default {
  130. props: {
  131. title: {
  132. type: String,
  133. default: "",
  134. },
  135. withChangeButton: {
  136. type: Boolean,
  137. default: true,
  138. },
  139. withDatePicker: {
  140. type: Boolean,
  141. default: true,
  142. },
  143. withSelect: {
  144. type: Boolean,
  145. default: true,
  146. },
  147. // 传入下拉选项
  148. selectOptions: {
  149. type: Array,
  150. default: () => [],
  151. },
  152. selectPlaceholder: {
  153. type: String,
  154. default: "全部代理人等级",
  155. },
  156. withInput: {
  157. type: Boolean,
  158. default: true,
  159. },
  160. searchPlaceholder: {
  161. type: String,
  162. default: "请输入代理人名称",
  163. },
  164. // 传入输入框自动填充项
  165. inputOptions: {
  166. type: Array,
  167. default: () => [],
  168. },
  169. withSearchButton: {
  170. type: Boolean,
  171. default: true,
  172. },
  173. withExportButton: {
  174. type: Boolean,
  175. default: true,
  176. },
  177. optionLists: {
  178. type: Array,
  179. default: () => [
  180. {
  181. name: "全部",
  182. lable: "",
  183. },
  184. {
  185. name: "A",
  186. lable: "A",
  187. },
  188. {
  189. name: "B",
  190. lable: "B",
  191. },
  192. {
  193. name: "C",
  194. lable: "C",
  195. },
  196. {
  197. name: "D",
  198. lable: "D",
  199. },
  200. ],
  201. },
  202. },
  203. data() {
  204. return {
  205. changeButtonLoading: false,
  206. // optionLists: [
  207. // {
  208. // name: "全部",
  209. // lable: "",
  210. // },
  211. // {
  212. // name: "A",
  213. // lable: "A",
  214. // },
  215. // {
  216. // name: "B",
  217. // lable: "B",
  218. // },
  219. // {
  220. // name: "C",
  221. // lable: "C",
  222. // },
  223. // {
  224. // name: "D",
  225. // lable: "D",
  226. // },
  227. // ],
  228. // optionLists: ["", "A", "B", "C", "D"],
  229. formData: {
  230. beginDate: null,
  231. endDate: null,
  232. dateRangeRadio: "",
  233. selection: "",
  234. searchText: "",
  235. },
  236. optionList: [],
  237. inputList: [
  238. {
  239. id: 1,
  240. name: "陈睿",
  241. },
  242. {
  243. id: 2,
  244. name: "赵科",
  245. },
  246. ],
  247. };
  248. },
  249. watch: {
  250. // "$router": {
  251. // // handler(val) {
  252. // // debugger;
  253. // // if (val) {
  254. // // this.formData = this.$route.query;
  255. // // this.formData.beginDate = this.$route.query.startTime;
  256. // // }
  257. // // },
  258. // },
  259. "formData.dateRangeRadio": {
  260. handler(val) {
  261. function formatNumber(num) {
  262. return num < 10 ? "0" + num : num;
  263. }
  264. function getLastDayOfMonth(year, month) {
  265. if (month === 2) {
  266. if ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0) {
  267. return 29;
  268. } else {
  269. return 28;
  270. }
  271. } else if ([1, 3, 5, 7, 8, 10, 12].includes(month)) {
  272. return 31;
  273. } else {
  274. return 30;
  275. }
  276. }
  277. const now = new Date();
  278. const year = now.getFullYear();
  279. const month = now.getMonth() + 1;
  280. const date = now.getDate();
  281. switch (val) {
  282. case "当日":
  283. this.formData.beginDate =
  284. this.formData.endDate = `${year}-${formatNumber(
  285. month
  286. )}-${formatNumber(date)}`;
  287. break;
  288. case "当月":
  289. this.formData.beginDate = `${year}-${formatNumber(month)}-01`;
  290. this.formData.endDate = `${year}-${formatNumber(
  291. month
  292. )}-${getLastDayOfMonth(year, month)}`;
  293. break;
  294. case "当年":
  295. this.formData.beginDate = `${year}-01-01`;
  296. this.formData.endDate = `${year}-12-31`;
  297. break;
  298. default:
  299. break;
  300. }
  301. this.search();
  302. },
  303. },
  304. // "formData.beginDate": {
  305. // handler(val, oldVal) {
  306. // if (oldVal) {
  307. // this.search();
  308. // }
  309. // },
  310. // },
  311. // "formData.endDate": {
  312. // handler(val, oldVal) {
  313. // if (oldVal) {
  314. // this.search();
  315. // }
  316. // },
  317. // },
  318. selectOptions: {
  319. handler(val) {
  320. if (val.length) {
  321. this.optionList = val;
  322. }
  323. },
  324. deep: true,
  325. immediate: true,
  326. },
  327. inputOptions: {
  328. handler(val) {
  329. if (val.length) {
  330. this.inputList = val;
  331. }
  332. },
  333. deep: true,
  334. immediate: true,
  335. },
  336. },
  337. mounted() {
  338. if (Object.keys(this.$route.query).length == 0) {
  339. this.formData.dateRangeRadio = "当日";
  340. } else {
  341. this.formData.beginDate = this.$route.query.startTime;
  342. this.formData.endDate = this.$route.query.endTime;
  343. this.formData.selection = this.$route.query.levelId;
  344. this.formData.searchText = this.$route.query.proxyId;
  345. this.formData.agentLevel = this.$route.query.agentLevel;
  346. this.formData.agentCode = this.$route.query.agentCode;
  347. }
  348. },
  349. methods: {
  350. handleChange(data) {
  351. this.formData.selection = data;
  352. },
  353. change() {
  354. this.changeButtonLoading = true;
  355. this.$emit("change");
  356. },
  357. querySearch(queryString, callback) {
  358. const inputList = this.inputList;
  359. const results = queryString
  360. ? inputList.filter((option) =>
  361. option.name.toLowerCase().includes(queryString.toLowerCase())
  362. )
  363. : inputList;
  364. callback(results);
  365. },
  366. inputClearHandler() {
  367. this.$refs["autocomplete"].activated = true;
  368. },
  369. search() {
  370. const searchArray = [];
  371. this.withDatePicker &&
  372. searchArray.push([this.formData.beginDate, this.formData.endDate]);
  373. this.withSelect && searchArray.push(this.formData.selection);
  374. this.withInput && searchArray.push(this.formData.searchText);
  375. this.$emit("search", searchArray);
  376. },
  377. resetSearch() {
  378. this.$refs["form"].resetFields();
  379. this.$nextTick(() => {
  380. this.formData.dateRangeRadio = "当日";
  381. this.search();
  382. });
  383. },
  384. },
  385. };
  386. </script>
  387. <style lang="scss" scoped>
  388. .security-check-header {
  389. display: flex;
  390. justify-content: space-between;
  391. align-items: flex-start;
  392. ::v-deep .ant-form-item-control {
  393. // height: 32px;
  394. // line-height: 30px;
  395. }
  396. ::v-deep .ant-calendar-picker-icon {
  397. display: none;
  398. }
  399. .ant-btn-primary {
  400. background-color: #2d67e3;
  401. }
  402. .ant-form-item-control {
  403. border: 1px solid #a4bdf3;
  404. color: #2d67e3;
  405. }
  406. ::v-deep .ant-select-selection__rendered {
  407. line-height: 30px;
  408. }
  409. ::v-deep .ant-form-item-children {
  410. height: 30px;
  411. line-height: 30px;
  412. .ant-btn {
  413. padding: 0 10px;
  414. height: 32px;
  415. line-height: 30px;
  416. font-size: 14px;
  417. font-family: Microsoft YaHei;
  418. font-weight: bold;
  419. // color: #ffffff;
  420. }
  421. }
  422. .btn-icon-only {
  423. width: 32px;
  424. border: none;
  425. background-color: #383c54;
  426. background-size: cover;
  427. }
  428. .icon-change {
  429. background-image: url("../../../assets/logo/ic_change_default.png");
  430. }
  431. .icon-export {
  432. background-image: url("../../../assets/logo/ic_export_default.png");
  433. }
  434. ::v-deep .ant-radio-group {
  435. line-height: 1;
  436. vertical-align: middle;
  437. display: inline-block;
  438. .btn-mo {
  439. background-color: #ffffff;
  440. color: #303133;
  441. }
  442. .btn-mo:hover {
  443. background-color: #ffffff;
  444. color: #303133;
  445. }
  446. .btn-mos {
  447. background-color: #383c54;
  448. color: #ffffff;
  449. }
  450. .btn-mos:hover {
  451. background-color: #ffffff;
  452. color: #303133;
  453. }
  454. .ant-radio-button-wrapper {
  455. height: 32px;
  456. padding: 8px 9px;
  457. // background-color: #383c54;
  458. border: 2px solid #383c54;
  459. // border-right: none;
  460. // color: #ffffff;
  461. -webkit-box-shadow: unset;
  462. box-shadow: unset;
  463. font-size: 14px;
  464. font-family: Microsoft YaHei;
  465. .btn-day {
  466. width: 100%;
  467. height: 100%;
  468. display: flex;
  469. align-items: center;
  470. }
  471. .btn-days {
  472. width: 100%;
  473. height: 100%;
  474. display: flex;
  475. align-items: center;
  476. }
  477. }
  478. .ant-radio-button-checked + .ant-radio-button__inner {
  479. // background-color: #ffffff;
  480. color: #303133;
  481. }
  482. // .ant-radio-button-wrapper {
  483. // .ant-radio-button-inner {
  484. // height: 32px;
  485. // padding: 8px 9px;
  486. // background-color: #383c54;
  487. // border: 2px solid #383c54;
  488. // border-right: none;
  489. // color: #ffffff;
  490. // -webkit-box-shadow: unset;
  491. // box-shadow: unset;
  492. // font-size: 14px;
  493. // font-family: Microsoft YaHei;
  494. // }
  495. // }
  496. }
  497. ::v-deep .ant-form-item-control {
  498. height: 32px;
  499. line-height: 30px;
  500. .ant-form-item-children {
  501. height: 100%;
  502. }
  503. .ant-calendar-picker-input {
  504. height: 32px;
  505. line-height: 30px;
  506. border: none;
  507. }
  508. }
  509. ::v-deep .ant-select {
  510. width: 192px;
  511. height: 32px;
  512. line-height: 30px;
  513. .ant-select-selection--single {
  514. width: 192px;
  515. height: 32px;
  516. line-height: 30px;
  517. }
  518. }
  519. ::v-deep .ant-select-search__field__wrap {
  520. width: 192px;
  521. height: 32px;
  522. line-height: 30px;
  523. .ant-input {
  524. height: 100%;
  525. }
  526. }
  527. .title {
  528. margin-right: 24px;
  529. padding-left: 16px;
  530. min-width: 176px;
  531. height: 32px;
  532. line-height: 32px;
  533. font-size: 20px;
  534. font-family: Helvetica, "Microsoft YaHei";
  535. font-weight: bold;
  536. position: relative;
  537. &::before {
  538. content: "";
  539. width: 4px;
  540. height: 20px;
  541. background: #2d67e3;
  542. position: absolute;
  543. top: 0;
  544. bottom: 0;
  545. left: 0;
  546. margin: auto;
  547. }
  548. }
  549. ::v-deep .form {
  550. display: flex;
  551. flex-wrap: wrap;
  552. .ant-form {
  553. margin-bottom: 24px;
  554. .ant-form-item__content {
  555. height: 32px;
  556. line-height: 30px;
  557. .ant-input .ant-input__inner {
  558. border-radius: 4px;
  559. }
  560. .ant-input .ant-input__inner {
  561. font-family: Helvetica, "Microsoft YaHei";
  562. color: #101116;
  563. border-color: #ffffff;
  564. &:hover {
  565. border-color: #c0c4cc;
  566. }
  567. &:focus {
  568. border-color: #409eff;
  569. }
  570. }
  571. .ant-btn {
  572. padding: 0 10px;
  573. height: 32px;
  574. line-height: 30px;
  575. font-size: 14px;
  576. font-family: Microsoft YaHei;
  577. font-weight: bold;
  578. color: #ffffff;
  579. border: none;
  580. .btn-white {
  581. background-color: #ffffff;
  582. border: 1px solid #a4bdf3;
  583. color: #2d67e3;
  584. }
  585. }
  586. .ant-date-editor {
  587. .ant-input__inner {
  588. padding-left: 15px;
  589. }
  590. .ant-input__prefix {
  591. display: none;
  592. }
  593. }
  594. .ant-radio-button {
  595. .ant-radio-button__inner {
  596. height: 32px;
  597. padding: 8px 9px;
  598. background-color: #383c54;
  599. border: 2px solid #383c54;
  600. border-right: none;
  601. color: #ffffff;
  602. box-shadow: unset;
  603. font-size: 14px;
  604. font-family: Microsoft YaHei;
  605. &:hover {
  606. background-color: #ffffff;
  607. color: #303133;
  608. }
  609. }
  610. &:last-child .ant-radio-button__inner {
  611. border-right: 2px solid #383c54;
  612. }
  613. .ant-radio-button__orig-radio:checked + .ant-radio-button__inner {
  614. background-color: #ffffff;
  615. color: #303133;
  616. }
  617. }
  618. .ant-select .ant-input {
  619. .ant-input__icon::before {
  620. content: "\e78f";
  621. }
  622. .ant-input__icon,
  623. .ant-input__inner::-webkit-input-placeholder {
  624. color: #303133;
  625. }
  626. }
  627. }
  628. &.radio-wrapper .ant-form-item__content {
  629. line-height: 28px;
  630. }
  631. }
  632. }
  633. }
  634. </style>