user.vue
3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<!-- 用户管理 -->
<template>
<d2-container>
<el-form
slot="header"
inline="true"
>
<el-form-item label="客户名称:">
<el-select
v-model="searchForm.customerName"
filterable
remote
clearable
placeholder="请选择客户名称"
:remote-method="getUserDownList"
:size="$store.state.d2admin.size.value"
>
<el-option
v-for="(item, index) in baseData.userList"
:key="index"
:label="item"
:value="item"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="注册时间:">
<el-date-picker
v-model="registerTime"
:size="$store.state.d2admin.size.value"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
:clearable="false"
>
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
:size="$store.state.d2admin.size.value"
:id="tableParams.btnId"
>查询</el-button>
<el-button
:size="$store.state.d2admin.size.value"
@click="handleRest"
>重置</el-button>
</el-form-item>
</el-form>
<d2-table
:hasNum="false"
:beforeSearchFn="beforeSearchFn"
:searchForm="searchForm"
:tableParams="tableParams"
:getListApi="getListApi"
></d2-table>
</d2-container>
</template>
<script>
import { userList, userDropList } from '@api/api'
export default {
name: 'user',
data() {
return {
searchForm: {
customerName: ''
},
registerTime: [],
getListApi: userList,
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'list',
tableColumns: [{
label: 'id',
prop: 'id',
width: '80px'
}, {
label: '昵称',
prop: 'nickname'
}, {
label: '联系电话',
prop: 'contactNumber',
width: '100px'
}, {
label: '微信ID',
prop: 'wechatId',
width: '250px'
}, {
label: '省份',
prop: 'provinceName'
}, {
label: '城市',
prop: 'cityName'
}, {
label: '所属客户名称',
prop: 'customerName'
}, {
label: '注册时间',
prop: 'createTime',
width: '160px'
}, {
label: '最后登录时间',
prop: 'lastLoginTime',
width: '160px'
}]
},
baseData: {
userList: []
}
}
},
watch: {
'searchForm.customerName'(newVal) {
!newVal && (this.baseData.userList = [])
}
},
mounted() { },
methods: {
beforeSearchFn() {
return new Promise(resolve => {
if (this.registerTime && this.registerTime.length) {
this.searchForm.registerStartTime = new Date(this.registerTime[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
this.searchForm.registerEndTime = new Date(this.registerTime[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
}
resolve()
})
},
handleRest() {
this.registerTime = []
this.searchForm = {
customerName: ''
}
this.baseData.userList = []
},
getUserDownList(query) {
userDropList({ customerName: query }).then(res => {
this.baseData.userList = res
})
}
}
}
</script>
<style scoped>
</style>