FilterUser.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. <template>
  2. <div class="filter-user">
  3. <div class="filter-option">
  4. <div v-if="device">
  5. <el-select v-model="filterType" class="filter-item" :placeholder="$t('common.selectType')" @change="handleFilterTypeChange">
  6. <el-option v-for="(item,key) in allFilterTypes" :key="key" :label="item.name" :value="key" />
  7. </el-select>
  8. <el-select v-model="filterSymbol" class="filter-item" :placeholder="$t('common.selectFunction')">
  9. <el-option v-for="(item,key) in filterSymbols" :key="key" :label="item" :value="key" />
  10. </el-select>
  11. <template v-if="filterType !== '' && allFilterTypes[filterType].hasOwnProperty('other') && allFilterTypes[filterType].other === 'date'">
  12. <el-date-picker v-model="filterValue" class="filter-item" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" :placeholder="$t('common.selectDate')"/>
  13. </template>
  14. <template v-else-if="filterType !== '' && allFilterTypes[filterType].hasOwnProperty('other') && allFilterTypes[filterType].other === 'month'">
  15. <el-date-picker v-model="filterValue" class="filter-item" value-format="yyyyMM" type="month" :placeholder="$t('common.selectMonth')"/>
  16. </template>
  17. <template v-else-if="filterType !== '' && allFilterTypes[filterType].hasOwnProperty('other') && allFilterTypes[filterType].other === 'area'">
  18. <el-cascader v-model="filterAreaValue" class="filter-item" :options="regionData" :props="{ checkStrictly: true }"/>
  19. </template>
  20. <template v-else-if="filterType !== '' && allFilterTypes[filterType].hasOwnProperty('other') && allFilterTypes[filterType].other === 'select'">
  21. <el-select v-model="filterValue" class="filter-item" :placeholder="`${pleaseSelect.pleaseSelect}${allFilterTypes[filterType].name}`">
  22. <el-option v-for="(item,key) in allFilterTypes[filterType].selectData" :key="key" :label="item.name" :value="item.id"/>
  23. </el-select>
  24. </template>
  25. <template v-else-if="filterType !== '' && allFilterTypes[filterType].hasOwnProperty('other') && filterCustomType.hasOwnProperty(allFilterTypes[filterType].other)">
  26. <el-select v-model="filterValue" class="filter-item" :placeholder="`${filterCustomType[allFilterTypes[filterType].other].placeholder}`">
  27. <el-option v-for="(item,key) in filterCustomType[allFilterTypes[filterType].other].values" :key="key" :label="item[filterCustomType[allFilterTypes[filterType].other].labelField]" :value="item[filterCustomType[allFilterTypes[filterType].other].valueField]" />
  28. </el-select>
  29. </template>
  30. <template v-else>
  31. <el-input v-model="filterValue" class="filter-item filter-value" :placeholder="$t('common.pleaseInputContent')" />
  32. </template>
  33. <el-select v-model="filterRelation" class="filter-item filter-relation" :placeholder="$t('common.relation')">
  34. <el-option v-for="(item,key) in filterRelations" :key="key" :label="item" :value="key" />
  35. </el-select>
  36. <el-button class="filter-item" icon="el-icon-plus" @click="handleOptionPlus" />
  37. <el-button class="filter-item" type="primary" @click="handleFilterUser">{{ filterBtnName }}</el-button>
  38. <el-button class="filter-item" type="" @click="handleFilterClear">{{ $t('common.reset') }}</el-button>
  39. </div>
  40. <el-row :gutter="20" v-else>
  41. <el-col :xs="24" :sm="8" :md="8" :lg="8" style="margin-top: 5px;">
  42. <el-select v-model="filterType" class="filter-item" :placeholder="$t('common.selectType')" @change="handleFilterTypeChange">
  43. <el-option v-for="(item,key) in allFilterTypes" :key="key" :label="item.name" :value="key" />
  44. </el-select>
  45. </el-col>
  46. <el-col :xs="24" :sm="8" :md="8" :lg="8" style="margin-top: 5px;">
  47. <el-select v-model="filterSymbol" class="filter-item" :placeholder="$t('common.selectFunction')">
  48. <el-option v-for="(item,key) in filterSymbols" :key="key" :label="item" :value="key" />
  49. </el-select>
  50. </el-col>
  51. <el-col :xs="24" :sm="8" :md="8" :lg="8" style="margin-top: 5px;">
  52. <template v-if="filterType !== '' && allFilterTypes[filterType].hasOwnProperty('other') && allFilterTypes[filterType].other === 'date'">
  53. <el-date-picker v-model="filterValue" class="filter-item" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" :placeholder="$t('common.selectDate')"/>
  54. </template>
  55. <template v-else-if="filterType !== '' && allFilterTypes[filterType].hasOwnProperty('other') && allFilterTypes[filterType].other === 'month'">
  56. <el-date-picker v-model="filterValue" class="filter-item" value-format="yyyyMM" type="month" :placeholder="$t('common.selectMonth')"/>
  57. </template>
  58. <template v-else-if="filterType !== '' && allFilterTypes[filterType].hasOwnProperty('other') && allFilterTypes[filterType].other === 'area'">
  59. <el-cascader v-model="filterAreaValue" class="filter-item" :options="regionData" :props="{ checkStrictly: true }"/>
  60. </template>
  61. <template v-else-if="filterType !== '' && allFilterTypes[filterType].hasOwnProperty('other') && allFilterTypes[filterType].other === 'select'">
  62. <el-select v-model="filterValue" class="filter-item" :placeholder="`${pleaseSelect.pleaseSelect}${allFilterTypes[filterType].name}`">
  63. <el-option v-for="(item,key) in allFilterTypes[filterType].selectData" :key="key" :label="item.name" :value="item.id"/>
  64. </el-select>
  65. </template>
  66. <template v-else-if="filterType !== '' && allFilterTypes[filterType].hasOwnProperty('other') && filterCustomType.hasOwnProperty(allFilterTypes[filterType].other)">
  67. <el-select v-model="filterValue" class="filter-item" :placeholder="`${filterCustomType[allFilterTypes[filterType].other].placeholder}`">
  68. <el-option v-for="(item,key) in filterCustomType[allFilterTypes[filterType].other].values" :key="key" :label="item[filterCustomType[allFilterTypes[filterType].other].labelField]" :value="item[filterCustomType[allFilterTypes[filterType].other].valueField]" />
  69. </el-select>
  70. </template>
  71. <template v-else>
  72. <el-input v-model="filterValue" class="filter-item filter-value" :placeholder="$t('common.pleaseInputContent')" />
  73. </template>
  74. <el-select v-model="filterRelation" class="filter-item filter-relation" :placeholder="$t('common.relation')">
  75. <el-option v-for="(item,key) in filterRelations" :key="key" :label="item" :value="key" />
  76. </el-select>
  77. </el-col>
  78. <el-col :xs="24" :sm="24" :md="24" :lg="24" style="margin-top: 5px;">
  79. <el-button class="filter-item" icon="el-icon-plus" @click="handleOptionPlus" />
  80. <el-button class="filter-item" type="primary" @click="handleFilterUser">{{ filterBtnName }}</el-button>
  81. <el-button class="filter-item" type="" @click="handleFilterClear">{{ $t('common.reset') }}</el-button>
  82. </el-col>
  83. </el-row>
  84. </div>
  85. <div v-show="filterSelected.length > 0" class="filter-selected">
  86. <el-tag
  87. v-for="(item,key) in filterSelected"
  88. :key="key"
  89. class="selected-tag"
  90. closable
  91. @close="handleCloseTag(key)"
  92. >{{ item.filterTypeName }} {{ item.filterSymbolName }} {{ item.filterName }}
  93. </el-tag>
  94. </div>
  95. <el-dialog :title="$t('filter.memberSelect')" :visible.sync="filterUserDialogShow" width="80%">
  96. <el-table
  97. v-loading="loading"
  98. :data="tableData"
  99. stripe
  100. style="width: 100%;"
  101. @selection-change="handleSelectionChange"
  102. >
  103. <el-table-column type="selection" width="55" />
  104. <el-table-column :label="$t('filter.memberNumber')">
  105. <template slot-scope="scope">
  106. {{ scope.row.USER_NAME }}
  107. </template>
  108. </el-table-column>
  109. <el-table-column :label="$t('filter.name')">
  110. <template slot-scope="scope">
  111. {{ scope.row.REAL_NAME }}
  112. </template>
  113. </el-table-column>
  114. <el-table-column :label="$t('filter.idNumber')" width="180">
  115. <template slot-scope="scope">
  116. {{ scope.row.ID_CARD }}
  117. </template>
  118. </el-table-column>
  119. <el-table-column :label="$t('filter.phoneNumber')">
  120. <template slot-scope="scope">
  121. {{ scope.row.MOBILE }}
  122. </template>
  123. </el-table-column>
  124. <el-table-column :label="$t('filter.memberLevel')">
  125. <template slot-scope="scope">
  126. {{ scope.row.DEC_LV ? filterCustomType.decLevel.values[scope.row.DEC_LV]['LEVEL_NAME'] : '' }}
  127. </template>
  128. </el-table-column>
  129. <el-table-column :label="$t('filter.level')">
  130. <template slot-scope="scope">
  131. {{ scope.row.EMP_LV ? filterCustomType.empLevel.values[scope.row.EMP_LV]['LEVEL_NAME'] : '' }}
  132. </template>
  133. </el-table-column>
  134. </el-table>
  135. <div class="white-box-footer">
  136. <el-button type="primary" size="small" :disabled="multipleSelectionUserId == undefined || multipleSelectionUserId.length <= 0?true:false" @click="handleSelectValue(false)">{{ $t('filter.confirmSelect') }}</el-button>
  137. <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
  138. </div>
  139. </el-dialog>
  140. </div>
  141. </template>
  142. <script>
  143. import { filterUser } from '@/api/filter'
  144. import baseInfo from '@/utils/baseInfo'
  145. import store from '@/utils/vuexStore'
  146. import Pagination from './Pagination'
  147. import filterHelper from '@/utils/filterHelper'
  148. import {getOperatingSystem, getScreenWidth} from "@/utils"
  149. export default {
  150. name: 'FilterUser',
  151. components: { Pagination },
  152. props: {
  153. filterTypes: {
  154. type: Object,
  155. default() {
  156. return {
  157. 'USER_NAME': { isUserTable: true, name: this.$t('filter.memberNumber') },
  158. 'REAL_NAME': { isUserTable: true, name: this.$t('filter.memberName') },
  159. 'ID_CARD': { isUserTable: true, name: this.$t('filter.ID') },
  160. 'MOBILE': { isUserTable: true, name: this.$t('filter.phoneNumber') },
  161. 'CREATED_AT': { isUserTable: true, name: this.$t('filter.addAt'), other: 'date' }
  162. }
  163. }
  164. },
  165. filterBtnName: {
  166. type: String,
  167. default() {
  168. return this.$t('filter.memberSelect')
  169. }
  170. }
  171. },
  172. data() {
  173. return {
  174. loading: false,
  175. filterUserDialogShow: false,
  176. tableData: [],
  177. currentPage: 1,
  178. totalPages: 1,
  179. totalCount: 1,
  180. pageSize: 20,
  181. // filterCustomType: {
  182. // decLevel: {
  183. // placeholder: this.$t('filter.pleaseSelectDecLevel'),
  184. // labelField: 'LEVEL_NAME',
  185. // valueField: 'ID',
  186. // values: baseInfo.decLevels()
  187. // },
  188. // empLevel: {
  189. // placeholder: this.$t('filter.pleaseSelectEmpLevel'),
  190. // labelField: 'LEVEL_NAME',
  191. // valueField: 'ID',
  192. // values: baseInfo.empLevels()
  193. // },
  194. // decRole: {
  195. // placeholder: '请选择报单中心级别',
  196. // labelField: 'ROLE_NAME',
  197. // valueField: 'ID',
  198. // values: baseInfo.decRoles()
  199. // },
  200. // subCompany: {
  201. // placeholder: '请选择分公司',
  202. // labelField: 'COM_NAME',
  203. // valueField: 'ID',
  204. // values: baseInfo.subCompanies()
  205. // },
  206. // status: {
  207. // placeholder: '请选择会员状态',
  208. // labelField: 'label',
  209. // valueField: 'value',
  210. // values: baseInfo.allStatus()
  211. // },
  212. // dealTypes: {
  213. // placeholder: '请选择交易类型',
  214. // labelField: 'TYPE_NAME',
  215. // valueField: 'ID',
  216. // values: baseInfo.dealTypes()
  217. // },
  218. // systems: {
  219. // placeholder: '请选择体系',
  220. // labelField: 'SYSTEM_NAME',
  221. // valueField: 'ID',
  222. // values: baseInfo.systems()
  223. // },
  224. // sex: {
  225. // placeholder: '请选择性别',
  226. // labelField: 'label',
  227. // valueField: 'value',
  228. // values: {
  229. // '男': { label: '男', value: '男' },
  230. // '女': { label: '女', value: '女' }
  231. // }
  232. // },
  233. // yesOrNo: {
  234. // placeholder: '请选择是否',
  235. // labelField: 'label',
  236. // valueField: 'value',
  237. // values: {
  238. // 1: { label: '是', value: 1 },
  239. // 0: { label: '否', value: 0 }
  240. // }
  241. // },
  242. // banks: {
  243. // placeholder: '请选择开户行',
  244. // labelField: 'BANK_NAME',
  245. // valueField: 'BANK_CODE',
  246. // values: baseInfo.allOpenBank()
  247. // },
  248. // nations: {
  249. // placeholder: '请选择民族',
  250. // labelField: 'name',
  251. // valueField: 'id',
  252. // values: baseInfo.allNation()
  253. // },
  254. // location: {
  255. // placeholder: '请选择市场',
  256. // labelField: 'label',
  257. // valueField: 'value',
  258. // values: {
  259. // 1: { label: '一市场', value: 1 },
  260. // 2: { label: '二市场', value: 2 },
  261. // 3: { label: '三市场', value: 3 },
  262. // 4: { label: '四市场', value: 4 },
  263. // 5: { label: '五市场', value: 5 }
  264. // }
  265. // }
  266. // },
  267. filterModel: {
  268. userId: ''
  269. },
  270. allFilterTypes: this.filterTypes,
  271. filterType: '',
  272. filterSymbol: '',
  273. // filterSymbols: {
  274. // '=': this.$t('filter.eq'),
  275. // 'like': this.$t('filter.like'),
  276. // '<>': this.$t('filter.noeq'),
  277. // 'notLike': this.$t('filter.nolike'),
  278. // '>': this.$t('filter.moreThan'),
  279. // '>=': this.$t('filter.moreThanEq'),
  280. // '<': this.$t('filter.less'),
  281. // '<=': this.$t('filter.lessThan')
  282. // },
  283. filterRelation: 'and',
  284. // filterRelations: {
  285. // 'and': this.$t('filter.and'),
  286. // 'or': this.$t('filter.or')
  287. // },
  288. filterValue: '',
  289. filterName: '',
  290. filterSelected: [],
  291. selectData: [],
  292. multipleSelection: [],
  293. multipleSelectionUserId: [],
  294. regionData: store.state.regionInfo.regionData,
  295. filterAreaValue: [],
  296. filterRequest: {},
  297. device: getScreenWidth() > 920
  298. }
  299. },
  300. computed: {
  301. filterCustomType() {
  302. return {
  303. decLevel: {
  304. placeholder: this.$t('filter.pleaseSelectDecLevel'),
  305. labelField: 'LEVEL_NAME',
  306. valueField: 'ID',
  307. values: baseInfo.decLevels()
  308. },
  309. empLevel: {
  310. placeholder: this.$t('filter.pleaseSelectEmpLevel'),
  311. labelField: 'LEVEL_NAME',
  312. valueField: 'ID',
  313. values: baseInfo.empLevels()
  314. },
  315. decRole: {
  316. placeholder: this.$t('filter.selectStockistHint'),
  317. labelField: 'ROLE_NAME',
  318. valueField: 'ID',
  319. values: baseInfo.decRoles()
  320. },
  321. // subCompany: {
  322. // placeholder: '请选择分公司',
  323. // labelField: 'COM_NAME',
  324. // valueField: 'ID',
  325. // values: baseInfo.subCompanies()
  326. // },
  327. status: {
  328. placeholder: this.$t('filter.selectMemberStatusHint'),
  329. labelField: 'label',
  330. valueField: 'value',
  331. values: baseInfo.allStatus()
  332. },
  333. dealTypes: {
  334. placeholder: this.$t('filter.selectHint'),
  335. labelField: 'TYPE_NAME',
  336. valueField: 'ID',
  337. values: baseInfo.dealTypes()
  338. },
  339. // systems: {
  340. // placeholder: '请选择体系',
  341. // labelField: 'SYSTEM_NAME',
  342. // valueField: 'ID',
  343. // values: baseInfo.systems()
  344. // },
  345. sex: {
  346. placeholder: this.$t('filter.selectGenderHint'),
  347. labelField: 'label',
  348. valueField: 'value',
  349. values: {
  350. '男': { label: this.$t('filter.man'), value: '男' },
  351. '女': { label: this.$t('filter.woman'), value: '女' }
  352. }
  353. },
  354. yesOrNo: {
  355. placeholder: this.$t('filter.selectWhetherOrNotHint'),
  356. labelField: 'label',
  357. valueField: 'value',
  358. values: {
  359. 1: { label: this.$t('filter.yes'), value: 1 },
  360. 0: { label: this.$t('filter.not'), value: 0 }
  361. }
  362. },
  363. banks: {
  364. placeholder: this.$t('filter.selectBankHint'),
  365. labelField: 'BANK_NAME',
  366. valueField: 'BANK_CODE',
  367. values: baseInfo.allOpenBank()
  368. },
  369. // nations: {
  370. // placeholder: '请选择民族',
  371. // labelField: 'name',
  372. // valueField: 'id',
  373. // values: baseInfo.allNation()
  374. // },
  375. location: {
  376. placeholder: this.$t('filter.selectMarketHint'),
  377. labelField: 'label',
  378. valueField: 'value',
  379. values: {
  380. 1: { label: this.$t('filter.marketI'), value: 1 },
  381. 2: { label: this.$t('filter.marketII'), value: 2 },
  382. // 3: { label: '三市场', value: 3 },
  383. // 4: { label: '四市场', value: 4 },
  384. // 5: { label: '五市场', value: 5 }
  385. }
  386. }
  387. }
  388. },
  389. filterSymbols() {
  390. return {
  391. '=': this.$t('filter.eq'),
  392. 'like': this.$t('filter.like'),
  393. '<>': this.$t('filter.noeq'),
  394. 'notLike': this.$t('filter.nolike'),
  395. '>': this.$t('filter.moreThan'),
  396. '>=': this.$t('filter.moreThanEq'),
  397. '<': this.$t('filter.less'),
  398. '<=': this.$t('filter.lessThan')
  399. }
  400. },
  401. pleaseSelect() {
  402. return {
  403. 'pleaseSelect':this.$t('filter.pleaseSelectNotice'),
  404. }
  405. },
  406. filterRelations() {
  407. return {
  408. 'and': this.$t('filter.and'),
  409. 'or': this.$t('filter.or')
  410. }
  411. }
  412. },
  413. watch: {
  414. filterTypes(newVal) {
  415. this.allFilterTypes = this.filterTypes
  416. }
  417. },
  418. methods: {
  419. handleFilterTypeChange() {
  420. this.filterValue = ''
  421. },
  422. handleSelectionChange(val) {
  423. this.multipleSelection = val
  424. this.multipleSelectionUserId = []
  425. for (const i in this.multipleSelection) {
  426. this.multipleSelectionUserId.push(this.multipleSelection[i].ID)
  427. }
  428. },
  429. handleCurrentChange(page) {
  430. this.getData(this.filterRequest, page, this.pageSize)
  431. },
  432. handleSizeChange(pageSize) {
  433. this.getData(this.filterRequest, this.currentPage, pageSize)
  434. },
  435. remoteMethod(query) {
  436. if (query !== '') {
  437. this.loading = true
  438. filterUser({ kw: query }).then(response => {
  439. this.selectData = response
  440. this.loading = false
  441. }).catch(err => {
  442. this.loading = false
  443. })
  444. }
  445. },
  446. handleOptionPlus() {
  447. if (this.filterType === '' || this.filterSymbol === '' || (this.filterValue === '' && this.filterAreaValue === [])) {
  448. this.$message({
  449. message: this.$t('filter.selectContentNotice'),
  450. type: 'warning'
  451. })
  452. return false
  453. }
  454. let valueName = this.filterValue
  455. if (this.filterType !== '' && this.allFilterTypes[this.filterType].hasOwnProperty('other')) {
  456. // 获取下拉筛选时的选中项
  457. if (this.allFilterTypes[this.filterType].other === 'select') {
  458. let nameObj = []
  459. const _this = this
  460. if (!Array.isArray(this.allFilterTypes[this.filterType].selectData)) {
  461. nameObj[0] = this.allFilterTypes[this.filterType].selectData[_this.filterValue]
  462. } else {
  463. nameObj = (this.allFilterTypes[this.filterType].selectData).filter(function(item, index, array) {
  464. return item.id === _this.filterValue
  465. })
  466. }
  467. valueName = nameObj[0] ? nameObj[0].name : null
  468. } else if (this.allFilterTypes[this.filterType].other === 'area') {
  469. if (this.filterSymbol !== '=') {
  470. this.$message({
  471. message: this.$t('filter.areaSelectNotice'),
  472. type: 'warning'
  473. })
  474. return false
  475. }
  476. this.filterValue = this.filterAreaValue.join(',')
  477. valueName = ''
  478. for (const i in this.regionData) {
  479. if (this.regionData[i].value === this.filterAreaValue[0]) {
  480. valueName += this.regionData[i].label + ','
  481. for (const j in this.regionData[i].children) {
  482. if (this.regionData[i].children[j].value === this.filterAreaValue[1]) {
  483. valueName += this.regionData[i].children[j].label + ','
  484. for (const h in this.regionData[i].children[j].children) {
  485. if (this.regionData[i].children[j].children[h].value === this.filterAreaValue[2]) {
  486. valueName += this.regionData[i].children[j].children[h].label
  487. break
  488. }
  489. }
  490. break
  491. }
  492. }
  493. break
  494. }
  495. }
  496. } else if (this.filterCustomType.hasOwnProperty(this.allFilterTypes[this.filterType].other)) {
  497. const allCustomData = this.filterCustomType[this.allFilterTypes[this.filterType].other].values
  498. const customField = this.filterCustomType[this.allFilterTypes[this.filterType].other].labelField
  499. valueName = allCustomData[this.filterValue][customField]
  500. }
  501. }
  502. // 如果是筛选会员编号,则把会员编号转成小写
  503. // if(this.filterType === 'USER_NAME'){
  504. // this.filterValue = this.filterValue.toLowerCase()
  505. // }
  506. this.filterSelected.push({
  507. filterType: this.filterType,
  508. filterTypeName: this.allFilterTypes[this.filterType].name,
  509. filterSymbol: this.filterSymbol,
  510. filterSymbolName: this.filterSymbols[this.filterSymbol],
  511. filterValue: this.filterValue,
  512. filterRelation: this.filterRelation,
  513. filterRelationName: this.filterRelations[this.filterRelation],
  514. filterName: valueName,
  515. filterOther: this.filterType !== '' && this.allFilterTypes[this.filterType].hasOwnProperty('other') ? this.allFilterTypes[this.filterType].other : null,
  516. isUserTable: this.allFilterTypes[this.filterType].isUserTable
  517. })
  518. },
  519. handleCloseTag(tag) {
  520. this.filterSelected.splice(tag, 1)
  521. },
  522. handleFilterUser() {
  523. console.log('===>>>', this.filterSelected.length, '<<===')
  524. if (this.filterSelected.length > 0) {
  525. this.loading = true
  526. this.filterRequest = {}
  527. for (const i in this.filterSelected) {
  528. if (this.filterSelected[i].isUserTable) {
  529. let reqFilterValue = `${this.filterSelected[i].filterSymbol},${this.filterSelected[i].filterValue}`
  530. if (this.filterSelected[i].hasOwnProperty('filterOther')) {
  531. reqFilterValue += `,${this.filterSelected[i].filterOther}`
  532. }
  533. const filterType = this.filterSelected[i].filterType
  534. if (this.filterRequest[filterType]) {
  535. this.$set(this.filterRequest, filterType, (this.filterRequest[filterType] + '|' + reqFilterValue))
  536. } else {
  537. this.$set(this.filterRequest, filterType, reqFilterValue)
  538. }
  539. }
  540. }
  541. if (Object.keys(this.filterRequest).length === 0) {
  542. this.handleSelectValue(true)
  543. } else {
  544. this.getData(this.filterRequest, this.currentPage)
  545. }
  546. }
  547. },
  548. getData(request, page = null, pageSize = null) {
  549. request.page = page
  550. request.pageSize = pageSize
  551. filterUser(this.listQuery).then(response => {
  552. this.filterUserDialogShow = true
  553. })
  554. },
  555. handleSelectValue(isAll = false) {
  556. const otherFilterTypes = []
  557. for (const i in this.filterSelected) {
  558. if (!this.filterSelected[i].isUserTable) {
  559. otherFilterTypes.push(this.filterSelected[i])
  560. }
  561. }
  562. let userIds = this.multipleSelectionUserId
  563. if (isAll) {
  564. userIds = 'all'
  565. }
  566. this.$emit('select-value', {
  567. userIds: userIds,
  568. otherFilterTypes: otherFilterTypes
  569. })
  570. this.filterUserDialogShow = false
  571. },
  572. handleFilterClear() {
  573. Object.assign(this.$data, this.$options.data())
  574. this.allFilterTypes = this.filterTypes
  575. // 清空地址栏
  576. filterHelper.clearFilterOption(this)
  577. this.$emit('select-value', { userIds: 'all', otherFilterTypes: [] })
  578. }
  579. }
  580. }
  581. </script>
  582. <style scoped>
  583. .filter-option:after {
  584. content: '';
  585. clear: both;
  586. display: table;
  587. }
  588. .filter-item {
  589. float: left;
  590. margin-left: 10px;
  591. }
  592. .filter-value {
  593. width: 200px;
  594. }
  595. .filter-relation {
  596. width: 100px;
  597. display: none;
  598. }
  599. .down-button {
  600. float: right;
  601. }
  602. .filter-selected {
  603. clear: both;
  604. margin: 10px;
  605. padding: 5px;
  606. border: 1px solid #ebeef5;
  607. }
  608. .selected-tag {
  609. margin-left: 10px;
  610. }
  611. /deep/ .el-input__inner {
  612. width:203px;
  613. }
  614. </style>