securityCheckHeader.vue 20 KB

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