monitorManager.vue
8.49 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<template>
<div style="background-color: #FAFAFA">
<div class="common_con mb10">
<el-form ref="queryForm" :model="state.queryParams" :rules="queryRules" label-position="left" label-width="80px">
<el-row :gutter="20">
<el-col :span="8" v-for="item in state.queryColumns">
<el-form-item :label="item.label">
<el-input v-if="item.type === 'input'" v-model.trim="state.queryParams[item.prop]" :placeholder="'请输入'+item.label" clearable size="small"></el-input>
<el-select v-if="item.type === 'select'" style="width: 100%" v-model="state.queryParams[item.prop]" size="small" clearable>
<el-option v-for="dict in dict[item.options]" :label="dict.dictLabel" :value="dict.dictValue"></el-option>
</el-select>
<el-checkbox-group v-if="item.type === 'checkbox'" v-model="state.queryParams[item.prop]" size="small">
<el-checkbox v-for="dict in dict[item.options]" :label="dict.dictLabel" :value="dict.dictValue"></el-checkbox>
</el-checkbox-group>
<el-radio-group v-if="item.type === 'radio'" v-model="state.queryParams[item.prop]" size="small">
<el-radio v-for="dict in dict[item.options]" :label="dict.dictLabel" :value="dict.dictValue"></el-radio>
</el-radio-group>
<el-date-picker v-if="item.type === 'date'"
v-model="state.queryParams[item.prop]"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="YYYY-MM-DD"
size="small"
>
</el-date-picker>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="10">
<el-col :span="8">
<el-form-item>
<el-button type="primary" icon="Search" v-debounceClick="()=>handleSearch()">查询</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
</div>
<div class="common_con">
<el-row class="mb10">
<el-col :span="1.5">
<el-button type="primary" size="small" @click="handleUpdate('dialogOpen', 1)">新增账号</el-button>
</el-col>
</el-row>
<el-table :data="state.tableList" style="width: 100%" @selection-change="handleSelectionChange" border v-loading="state.isLoading" class="own_table" :row-class-name="rowClassName">
<el-table-column label="序号" prop="index"/>
<el-table-column v-for="(table, index) in state.tableColumns" :key="'table'+index" :label="table.label" :prop="table.prop" :min-width="table.width">
<template #default="scope">
<template v-if="table.limitLength && scope.row[table.prop]">
{{scope.row[table.prop].substring(0, table.limitLength)}}
</template>
<template v-else-if="table.prop === 'deptName'">
{{scope.row['dept'][table.prop]}}
</template>
<template v-else>
{{formatColumn(scope.row[table.prop], table.prop)}}
</template>
</template>
</el-table-column>
<el-table-column label="操作" width="200px">
<template #default="scope">
<el-button type="primary" size="small" icon="Edit" @click="handleUpdate('dialogOpen', 2, scope.row)">修改</el-button>
<el-button type="primary" size="small" icon="Edit" @click="handleUpdate('dialogOpen', 3, scope.row)">重置密码</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="state.total > 0"
:total="state.total"
:page.sync="state.queryParams.pageNum"
:limit.sync="state.queryParams.pageSize"
@pagination="({page, limit})=>getList(page, limit)"
/>
</div>
<add-user :title="state.dialogTitle" :open="state.dialogOpen" open-name="dialogOpen" :entry-type="state.entryType" :user-info="state.userInfo" :is-show-footer="true" @handleClose="handleClose"></add-user>
</div>
</template>
<script setup lang="ts">
import * as api from '../../interface/api.ts'
import { loginMain } from '../../store'
import { storeToRefs } from 'pinia';
import AddUser from "./addUser.vue";
import ReportOrder from "../../components/reportOrder/reportOrder.vue";
let loginAct = loginMain()
let { getStoreToken, getUserInfo } = storeToRefs(loginAct)
let queryForm = ref<FormInstance>()
let state = reactive( {
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
tableList: [],
isLoading: false,
total: 0,
queryParams: {
pageNum: 1,
pageSize: 10,
deptName: "",
userName: "",
phone: "",
dataStatus: "",
applicationDate: [],
},
tableColumns: [
{
label: "企业名称",
prop: "deptName"
},{
label: "姓名",
prop: "userName",
},{
label: "手机号码",
prop: "phone",
},{
label: "账号",
prop: "loginName",
},{
label: "创建日期",
prop: "storageTime",
limitLength: 10,
},{
label: "状态",
prop: "dataStatus",
},
],
queryColumns: [
{
type: "input",
label: "企业名称",
prop: "deptName",
}, {
type: "input",
label: "姓名",
prop: "userName",
}, {
type: "input",
label: "手机号码",
prop: "phone",
}, {
type: "radio",
label: "状态",
prop: "dataStatus",
options: "entrustTypeList"
},{
type: "date",
label: "创建日期",
prop: "applicationDate",
}
],
dialogOpen: false,
entryType: 1,
dialogTitle: "",
userInfo: {}
})
let dict = reactive({
entrustTypeList: [{dictLabel: '全部', dictValue: ""}, {dictLabel: '有效', dictValue: "0"}, {dictLabel: '无效', dictValue: "1"}]
})
let formatColumn = (value, prop) => {
let lastVal = ""
if (prop === 'dataStatus') {
dict.entrustTypeList.forEach(item=> {
if (parseInt(item.dictValue) === parseInt(value)) {
lastVal = item.dictLabel
}
})
} else {
lastVal = value
}
return lastVal
}
let queryRules = reactive<FormRules>({
enterpriseName: [
{ required: true, message: "企业名称不能为空", trigger: ["blur","change"] }
]
})
let rowClassName = ({row={}, rowIndex = -1}) => {
row.index = rowIndex + 1
}
let handleClose = (name: string, value: boolean, isRefresh: boolean) => {
state[name] = value
if (isRefresh) {
getList()
}
}
let handleSearch = () => {
state.queryParams.pageNum = 1
getList()
}
let handleSelectionChange = (selection: Array<any>) => {
state.ids = selection.map((item: Object) => item.id)
state.single = selection.length !== 1
state.multiple = !selection.length
}
let getList = (page = state.queryParams.pageNum, limit = state.queryParams.pageSize) => {
state.queryParams.pageNum = page
state.queryParams.pageSize = limit
queryForm.value.validate((valid: boolean, fields: Object)=> {
if (valid) {
state.isLoading = true
state.queryParams.startTime = ""
state.queryParams.doneTime = ""
if (state.queryParams.applicationDate && state.queryParams.applicationDate.length > 1) {
state.queryParams.startTime = state.queryParams.applicationDate[0]
state.queryParams.doneTime = state.queryParams.applicationDate[1]
}
let tempJson = Object.assign({}, state.queryParams)
delete tempJson.applicationDate
api.getInfoList(tempJson, '/web/frontUser/list').then((res: Object)=> {
state.tableList = res.data.rows
state.total = res.data.total
}).finally(()=> {
state.isLoading = false
})
}
})
}
let handleUpdate = (name: string, type: number, row: Object) => {
state[name] = true
state.entryType = type
state.userInfo = {}
if (type === 1) {
state.dialogTitle = '新增账号'
} else if (type === 2) {
state.dialogTitle = '修改账号'
} else {
state.dialogTitle = '重置密码'
}
if (row) {
state.userInfo = row
}
}
onMounted(()=>{
getList()
})
</script>
<style scoped>
</style>