123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744 |
- <template>
- <div class="security-check-header">
- <template v-if="title">
- <div class="title">{{ title }}</div>
- </template>
- <a-form ref="form" class="form" name="basic" :model="formData" @keyup.enter.native="search">
- <template v-if="withChangeButton">
- <div class="but" @click="change"></div>
- <!-- <a-form-item style="margin-right: 16px">
- <a-button
- size="small"
- :class="['btn-icon-only', { 'icon-change': !changeButtonLoading }]"
- :loading="changeButtonLoading"
- @click="change"
- />
- </a-form-item> -->
- </template>
- <template v-if="withDatePicker">
- <a-form-item prop="beginDate" style="margin-right: 8px">
- <a-date-picker
- v-model="formData.beginDate"
- type="date"
- size="small"
- format="YYYY-MM-DD"
- valueFormat="YYYY-MM-DD"
- />
- </a-form-item>
- <a-form-item prop="endDate" style="margin-right: 36px">
- <a-date-picker
- v-model="formData.endDate"
- type="date"
- size="small"
- format="YYYY-MM-DD"
- valueFormat="YYYY-MM-DD"
- />
- </a-form-item>
- <a-form-item prop="dateRangeRadio" class="radio-wrapper" style="margin-right: 36px">
- <a-radio-group v-model="formData.dateRangeRadio" size="small">
- <a-radio-button
- value="当日"
- :class="formData.dateRangeRadio == '当日' ? 'btn-mo' : 'btn-mos'"
- style="border-right: none"
- ><div class="btn-day">当日</div></a-radio-button
- >
- <a-radio-button value="当月" :class="formData.dateRangeRadio == '当月' ? 'btn-mo' : 'btn-mos'"
- ><div class="btn-day">当月</div></a-radio-button
- >
- <a-radio-button
- value="当年"
- style="border-left: none"
- :class="formData.dateRangeRadio == '当年' ? 'btn-mo' : 'btn-mos'"
- ><div class="btn-day">当年</div></a-radio-button
- >
- </a-radio-group>
- </a-form-item>
- </template>
- <template v-if="withSelect">
- <a-form-item prop="selection" style="margin-right: 16px">
- <a-select
- :mode="mode"
- :placeholder="selectPlaceholder"
- :value="formData.selection ? formData.selection : undefined"
- @change="handleChange"
- allowClear
- >
- <a-select-option v-for="item in optionLists" :key="item.name" :value="item.name" :title="item.label">
- {{ item.name }}
- </a-select-option>
- </a-select>
- <!-- <a-select
- v-model="formData.selection"
- size="small"
- :default-value="optionLists[0]"
- >
- <a-select-option
- v-for="option in optionList"
- :key="option.value"
- :value="option.value"
- :label="option.label"
- />
- </a-select> -->
- </a-form-item>
- </template>
- <template v-if="withInput">
- <!-- <a-form-item prop="searchText" style="margin-right: 8px">
- <a-auto-complete
- ref="autocomplete"
- v-model="formData.searchText"
- size="small"
- prefix-icon="el-icon-search"
- :trigger-on-focus="false"
- :fetch-suggestions="querySearch"
- value-key="name"
- :placeholder="searchPlaceholder"
- clearable
- @clear="inputClearHandler"
- />
- </a-form-item> -->
- <!-- <a-form-item prop="searchText" style="margin-right: 16px">
- <a-select
- mode="multiple"
- :placeholder="searchPlaceholder"
- :value="formData.searchText ? formData.searchText : undefined"
- @change="handleChange"
- allowClear
- >
- <a-select-option v-for="item in optionLists" :key="item.name" :value="item.name" :title="item.label">
- {{ item.name }}
- </a-select-option>
- </a-select>
- </a-form-item> -->
- <a-select
- :placeholder="searchPlaceholder"
- v-model="formData.searchTexts"
- allowClear
- style="width: 200px"
- show-search
- mode="combobox"
- :filter-option="filterManager"
- @change="changeManager"
- >
- <a-select-option
- :value="item.agentName"
- v-for="(item, index) in locationsData"
- :key="index"
- :data_mobile="item.agentName"
- >
- {{ item.agentName }}
- </a-select-option>
- </a-select>
- </template>
- <template v-if="withSearchButton">
- <a-form-item style="margin-right: 16px">
- <a-button size="small" type="primary" @click="search">查询</a-button>
- </a-form-item>
- <!-- <a-form-item style="margin-right: 24px">
- <a-button size="small" class="btn-white" @click="resetSearch"
- >重置</a-button
- >
- </a-form-item> -->
- </template>
- <template v-if="withExportButton">
- <div class="buts" @click="exportexcel"></div>
- <!-- <a-form-item>
- <a-button size="small" class="btn-icon-only icon-export" />
- </a-form-item> -->
- </template>
- </a-form>
- </div>
- </template>
- <script>
- import { routepage } from '@/api/statistics/statistics.js'
- export default {
- props: {
- mode: {
- type: String,
- default: '',
- },
- title: {
- type: String,
- default: '',
- },
- withChangeButton: {
- type: Boolean,
- default: true,
- },
- withDatePicker: {
- type: Boolean,
- default: true,
- },
- withSelect: {
- type: Boolean,
- default: true,
- },
- // 传入下拉选项
- selectOptions: {
- type: Array,
- default: () => [],
- },
- selectPlaceholder: {
- type: String,
- default: '全部代理人等级',
- },
- withInput: {
- type: Boolean,
- default: true,
- },
- searchPlaceholder: {
- type: String,
- default: '请输入代理人名称',
- },
- // 传入输入框自动填充项
- inputOptions: {
- type: Array,
- default: () => [],
- },
- withSearchButton: {
- type: Boolean,
- default: true,
- },
- withExportButton: {
- type: Boolean,
- default: true,
- },
- optionLists: {
- type: Array,
- default: () => [
- {
- name: '全部',
- lable: '',
- },
- {
- name: 'A',
- lable: 'A',
- },
- {
- name: 'B',
- lable: 'B',
- },
- {
- name: 'C',
- lable: 'C',
- },
- {
- name: 'D',
- lable: 'D',
- },
- ],
- },
- },
- data() {
- return {
- changeButtonLoading: false,
- locationsData: [],
- locationsDatacopy: [],
- // optionLists: [
- // {
- // name: "全部",
- // lable: "",
- // },
- // {
- // name: "A",
- // lable: "A",
- // },
- // {
- // name: "B",
- // lable: "B",
- // },
- // {
- // name: "C",
- // lable: "C",
- // },
- // {
- // name: "D",
- // lable: "D",
- // },
- // ],
- // optionLists: ["", "A", "B", "C", "D"],
- formData: {
- beginDate: null,
- endDate: null,
- dateRangeRadio: '',
- selection: '',
- searchText: '',
- searchTexts: '',
- },
- optionList: [],
- inputList: [],
- }
- },
- watch: {
- // "$router": {
- // // handler(val) {
- // // debugger;
- // // if (val) {
- // // this.formData = this.$route.query;
- // // this.formData.beginDate = this.$route.query.startTime;
- // // }
- // // },
- // },
- // 'formData.searchText': {
- // handler(val) {
- // if (!val) {
- // this.locationsData = []
- // } else {
- // this.locationsData = this.locationsDatacopy
- // debugger
- // }
- // },
- // },
- 'formData.dateRangeRadio': {
- handler(val) {
- function formatNumber(num) {
- return num < 10 ? '0' + num : num
- }
- function getLastDayOfMonth(year, month) {
- if (month === 2) {
- if ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0) {
- return 29
- } else {
- return 28
- }
- } else if ([1, 3, 5, 7, 8, 10, 12].includes(month)) {
- return 31
- } else {
- return 30
- }
- }
- const now = new Date()
- const year = now.getFullYear()
- const month = now.getMonth() + 1
- const date = now.getDate()
- switch (val) {
- case '当日':
- this.formData.beginDate = this.formData.endDate = `${year}-${formatNumber(month)}-${formatNumber(date)}`
- break
- case '当月':
- this.formData.beginDate = `${year}-${formatNumber(month)}-01`
- this.formData.endDate = `${year}-${formatNumber(month)}-${getLastDayOfMonth(year, month)}`
- break
- case '当年':
- this.formData.beginDate = `${year}-01-01`
- this.formData.endDate = `${year}-12-31`
- break
- default:
- break
- }
- this.search()
- },
- },
- // "formData.beginDate": {
- // handler(val, oldVal) {
- // if (oldVal) {
- // this.search();
- // }
- // },
- // },
- // "formData.endDate": {
- // handler(val, oldVal) {
- // if (oldVal) {
- // this.search();
- // }
- // },
- // },
- selectOptions: {
- handler(val) {
- if (val.length) {
- this.optionList = val
- }
- },
- deep: true,
- immediate: true,
- },
- inputOptions: {
- handler(val) {
- if (val.length) {
- this.inputList = val
- }
- },
- deep: true,
- immediate: true,
- },
- },
- activated() {
- this.routepageall()
- if (Object.keys(this.$route.params).length == 0) {
- if (!this.formData.beginDate || !this.formData.endDate) {
- this.formData.dateRangeRadio = '当日'
- }
- } else {
- this.formData.dateRangeRadio = ''
- this.formData.beginDate = this.$route.params.startTime
- this.formData.endDate = this.$route.params.endTime
- if (this.$route.params.beginDate) {
- this.formData.beginDate = this.$route.params.beginDate
- }
- if (this.$route.params.endDate) {
- this.formData.endDate = this.$route.params.endDate
- }
- // this.formData.selection = this.$route.query.levelId
- // ? this.$route.query.levelId
- // : this.$route.query.agentLevel;
- this.formData.selection = this.$route.params.places
- ? this.$route.params.places
- : this.$route.params.levelId
- ? this.$route.params.levelId
- : this.$route.params.agentLevel
- this.formData.searchText = this.$route.params.proxyId ? this.$route.params.proxyId : this.$route.params.agentCode
- this.locationsDatacopy.forEach((element) => {
- if (element.agentId == this.formData.searchText) {
- this.formData.searchTexts = element.agentName
- }
- })
- // this.formData.agentLevel = this.$route.query.agentLevel;
- // this.formData.agentCode = this.$route.query.agentCode;
- }
- },
- mounted() {},
- methods: {
- changeManager(e) {
- if (e) {
- this.locationsData = JSON.parse(JSON.stringify(this.locationsDatacopy))
- this.locationsDatacopy.forEach((element) => {
- if (element.agentName == e) {
- this.formData.searchText = element.agentId
- }
- })
- } else {
- this.locationsData = []
- this.formData.searchText = ''
- this.formData.searchTexts = ''
- }
- },
- filterManager(input, option) {
- // option.componentOptions.children[0].text.toLowerCase()为内容值
- // option.data.attrs.data_mobile为绑定的属性值,可自行定义
- return (
- option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0 ||
- option.data.attrs.data_mobile.indexOf(input.toLowerCase()) >= 0
- )
- },
- //代理人等级
- async routepageall() {
- try {
- let params = {
- pageNum: '1',
- pageSize: '20',
- }
- const result = await routepage(params)
- // this.locationsData = result.data.list
- this.locationsDatacopy = JSON.parse(JSON.stringify(result.data.list))
- } catch (error) {
- console.log(error)
- }
- },
- //导出
- exportexcel() {
- this.$emit('exportex')
- },
- handleChange(data) {
- this.formData.selection = data
- },
- change() {
- this.changeButtonLoading = true
- this.$emit('change')
- },
- querySearch(queryString, callback) {
- const inputList = this.inputList
- const results = queryString
- ? inputList.filter((option) => option.name.toLowerCase().includes(queryString.toLowerCase()))
- : inputList
- callback(results)
- },
- inputClearHandler() {
- this.$refs['autocomplete'].activated = true
- },
- search() {
- const searchArray = []
- this.withDatePicker && searchArray.push([this.formData.beginDate, this.formData.endDate])
- this.withSelect && searchArray.push(this.formData.selection == '全部' ? '' : this.formData.selection)
- this.withInput && searchArray.push(this.formData.searchText)
- this.$emit('search', searchArray)
- },
- resetSearch() {
- this.$refs['form'].resetFields()
- this.$nextTick(() => {
- this.formData.dateRangeRadio = '当日'
- this.search()
- })
- },
- },
- }
- </script>
- <style lang="scss" scoped>
- .security-check-header {
- display: flex;
- justify-content: space-between;
- align-items: flex-start;
- ::v-deep .ant-form-item-control {
- // height: 32px;
- // line-height: 30px;
- }
- .form {
- z-index: 999;
- > .but {
- width: 32px;
- height: 32px;
- background-image: url('../../../../assets/logo/ic_change_default.png');
- cursor: pointer;
- margin-right: 16px;
- }
- > .buts {
- width: 32px;
- height: 32px;
- background-image: url('../../../../assets/logo/ic_export_default.png');
- cursor: pointer;
- }
- }
- ::v-deep .ant-calendar-picker-icon {
- display: none;
- }
- .ant-btn-primary {
- background-color: #2d67e3;
- }
- .ant-form-item-control {
- border: 1px solid #a4bdf3;
- color: #2d67e3;
- }
- ::v-deep .ant-select-selection__rendered {
- line-height: 30px;
- }
- ::v-deep .ant-form-item-children {
- height: 30px;
- line-height: 30px;
- .ant-btn {
- width: 32px !important;
- padding: 0 10px;
- height: 32px;
- line-height: 30px;
- font-size: 14px;
- font-family: Microsoft YaHei;
- font-weight: bold;
- // color: #ffffff;
- }
- }
- ::v-deep .btn-icon-only {
- width: 32px;
- border: none;
- background-color: #383c54;
- background-size: cover;
- }
- ::v-deep .icon-change {
- width: 32px;
- height: 32px;
- // background-image: url('../../../../assets/logo/ic_change_default.png');
- }
- ::v-deep .icon-export {
- width: 32px;
- height: 32px;
- background-image: url('../../../../assets/logo/ic_export_default.png');
- }
- ::v-deep .ant-radio-group {
- line-height: 1;
- vertical-align: middle;
- display: inline-block;
- .btn-mo {
- background-color: #ffffff;
- color: #303133;
- }
- .btn-mo:hover {
- background-color: #ffffff;
- color: #303133;
- }
- .btn-mos {
- background-color: #383c54;
- color: #ffffff;
- }
- .btn-mos:hover {
- background-color: #ffffff;
- color: #303133;
- }
- .ant-radio-button-wrapper {
- height: 32px;
- padding: 8px 9px;
- // background-color: #383c54;
- border: 2px solid #383c54;
- // border-right: none;
- // color: #ffffff;
- -webkit-box-shadow: unset;
- box-shadow: unset;
- font-size: 14px;
- font-family: Microsoft YaHei;
- .btn-day {
- width: 100%;
- height: 100%;
- display: flex;
- align-items: center;
- }
- .btn-days {
- width: 100%;
- height: 100%;
- display: flex;
- align-items: center;
- }
- }
- .ant-radio-button-checked + .ant-radio-button__inner {
- // background-color: #ffffff;
- color: #303133;
- }
- // .ant-radio-button-wrapper {
- // .ant-radio-button-inner {
- // height: 32px;
- // padding: 8px 9px;
- // background-color: #383c54;
- // border: 2px solid #383c54;
- // border-right: none;
- // color: #ffffff;
- // -webkit-box-shadow: unset;
- // box-shadow: unset;
- // font-size: 14px;
- // font-family: Microsoft YaHei;
- // }
- // }
- }
- ::v-deep .ant-form-item-control {
- height: 32px;
- line-height: 30px;
- .ant-form-item-children {
- height: 100%;
- }
- .ant-calendar-picker-input {
- height: 32px;
- line-height: 30px;
- border: none;
- }
- }
- ::v-deep .ant-select {
- width: 192px;
- height: 32px;
- line-height: 30px;
- .ant-select-selection--single {
- width: 192px;
- height: 32px;
- line-height: 30px;
- }
- }
- ::v-deep .ant-select-search__field__wrap {
- width: 192px;
- height: 32px;
- line-height: 30px;
- .ant-input {
- height: 100%;
- }
- }
- .title {
- margin-right: 24px;
- padding-left: 16px;
- min-width: 176px;
- height: 32px;
- line-height: 32px;
- font-size: 20px;
- font-family: Helvetica, 'Microsoft YaHei';
- font-weight: bold;
- position: relative;
- &::before {
- content: '';
- width: 4px;
- height: 20px;
- background: #2d67e3;
- position: absolute;
- top: 0;
- bottom: 0;
- left: 0;
- margin: auto;
- }
- }
- ::v-deep .form {
- display: flex;
- flex-wrap: wrap;
- .ant-form {
- margin-bottom: 24px;
- .ant-form-item__content {
- height: 32px;
- line-height: 30px;
- .ant-input .ant-input__inner {
- border-radius: 4px;
- }
- .ant-input .ant-input__inner {
- font-family: Helvetica, 'Microsoft YaHei';
- color: #101116;
- border-color: #ffffff;
- &:hover {
- border-color: #c0c4cc;
- }
- &:focus {
- border-color: #409eff;
- }
- }
- .ant-btn {
- padding: 0 10px;
- height: 32px;
- line-height: 30px;
- font-size: 14px;
- font-family: Microsoft YaHei;
- font-weight: bold;
- color: #ffffff;
- border: none;
- .btn-white {
- background-color: #ffffff;
- border: 1px solid #a4bdf3;
- color: #2d67e3;
- }
- }
- .ant-date-editor {
- .ant-input__inner {
- padding-left: 15px;
- }
- .ant-input__prefix {
- display: none;
- }
- }
- .ant-radio-button {
- .ant-radio-button__inner {
- height: 32px;
- padding: 8px 9px;
- background-color: #383c54;
- border: 2px solid #383c54;
- border-right: none;
- color: #ffffff;
- box-shadow: unset;
- font-size: 14px;
- font-family: Microsoft YaHei;
- &:hover {
- background-color: #ffffff;
- color: #303133;
- }
- }
- &:last-child .ant-radio-button__inner {
- border-right: 2px solid #383c54;
- }
- .ant-radio-button__orig-radio:checked + .ant-radio-button__inner {
- background-color: #ffffff;
- color: #303133;
- }
- }
- .ant-select .ant-input {
- .ant-input__icon::before {
- content: '\e78f';
- }
- .ant-input__icon,
- .ant-input__inner::-webkit-input-placeholder {
- color: #303133;
- }
- }
- }
- &.radio-wrapper .ant-form-item__content {
- line-height: 28px;
- }
- }
- }
- }
- </style>
|