index.vue
7.34 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
258
259
260
261
262
263
264
265
266
267
268
<template>
<div class="container">
<GLCombiForm ref="showSearch" :formObj="searchForm" :formData="searchFormData" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm>
<div class="table-wrapper">
<div class="operate_wrap">
<span class="table_title">配置列表</span>
<div class="operate_btn">
<el-button :size="size" type="primary" @click="addClause(1)">新增</el-button>
<el-button :size="size" @click="handleExport">导出</el-button>
</div>
</div>
<GLTable ref="equityRef" :getListApi="getListApi" :searchForm="tableSearchForm" :tableParams="tableParams" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn">
<div slot="statusSlot" slot-scope="scope">
<span class="statsu-circle" :style="{ 'background-color': scope.scope.serviceStatus == 0 ? '#FDB757' : '#2CCA74' }"></span>
<span>{{ scope.scope.serviceStatus == 0 ? '待配置' : '已配置' }}</span>
</div>
<span slot="auth-button" slot-scope="scope" :data="scope.scope">
<GLTableButton :buttonList="buttonList" :buttonItem="scope" :buttonNum="3"></GLTableButton>
</span>
</GLTable>
</div>
</div>
</template>
<script>
import * as dayjs from 'dayjs'
import utils from '../../util/util'
export default {
name: 'equityList',
components: {},
data() {
return {
size: 'small',
buttonList: [
{
type: 'el-button',
name: row => {
return '查看'
},
attrs: {
type: 'text'
},
listeners: {
click: row => this.addClause(2, row.scope)
}
},
{
type: 'el-button',
name: row => {
return '编辑'
},
attrs: {
type: 'text'
},
listeners: {
click: row => this.addClause(3, row.scope)
}
}
],
searchForm: {
serviceName: '',
serviceStatus: '',
createdDate: '',
updatedDate: ''
},
tableSearchForm: {},
searchFormData: [
{
label: '服务名称',
name: 'serviceName',
type: 'input',
isClear: true
},
{
label: '状态',
name: 'serviceStatus',
type: 'select',
optionList: [
{
id: '',
label: '全部'
},
{
id: '0',
label: '待配置'
},
{
id: '1',
label: '已配置'
}
],
optionId: 'id',
optionLabel: 'label',
isClear: true
},
{
label: '创建时间',
name: 'createdDate',
type: 'datePicker',
labelWidth: 95,
isClear: true,
pickerOptions: 'beforeRangePickerOptions'
},
{
label: '更新时间',
name: 'updatedDate',
type: 'datePicker',
labelWidth: 95,
isClear: true,
pickerOptions: 'beforeRangePickerOptions'
}
],
// 表格
getListApi: this.$apis.serviceConfig.getServicesItemsList,
tableParams: {
listName: 'list',
tableOption: true,
tableColumns: [
{
label: '服务编号',
prop: 'serviceCode',
width: 200
},
{
label: '服务名称',
prop: 'serviceName',
width: 200
},
{
label: '可销售服务年限',
minWidth: 280,
prop: 'salePeriod',
formatter: cellValue => {
return cellValue.salePeriod?.length
? cellValue.salePeriod
.split(',')
.map(item => (item = item + '年'))
.join('、')
: '--'
}
},
{
label: '规格数量',
minWidth: 150,
prop: 'gradeCount'
},
{
label: '创建时间',
prop: 'createdDate',
width: 200,
formatter: cellValue => {
return cellValue.createdDate ? dayjs(cellValue.createdDate).format('YYYY-MM-DD HH:mm:ss') : '--'
}
},
{
label: '更新时间',
prop: 'updatedDate',
width: 200,
formatter: cellValue => {
return cellValue.updatedDate ? dayjs(cellValue.updatedDate).format('YYYY-MM-DD HH:mm:ss') : '--'
}
},
{
label: '状态',
minWidth: 150,
prop: 'status',
addHtml: 'statusSlot'
},
{
label: '操作人',
prop: 'updatedBy',
width: 140
}
]
},
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' }
}
},
mounted() {},
methods: {
getParams() {
let params = JSON.parse(JSON.stringify(this.searchForm))
if (this.searchForm?.createdDate?.length) {
params.beginCreateTime = new Date(this.searchForm.createdDate[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
params.endCreateTime = new Date(this.searchForm.createdDate[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
}
if (this.searchForm?.updatedDate?.length) {
params.beginUpdateTime = new Date(this.searchForm.updatedDate[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
params.endUpdateTime = new Date(this.searchForm.updatedDate[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
}
delete params.createdDate
delete params.updatedDate
return { ...params }
},
beforeSearchFn() {
return new Promise(resolve => {
this.tableSearchForm = this.getParams()
resolve()
})
},
// 导出
handleExport() {
var params = this.getParams()
this.$apis.serviceConfig.exportServicesItemsApi(params).then(res => {
// window.open(res)
let tempaa = utils.getExplorer()
if (tempaa == 'QQ') {
window.open(res)
} else {
let iframe = document.createElement('iframe')
iframe.style.display = 'none'
iframe.src = res
document.body.appendChild(iframe)
}
})
},
handleSearch() {
this.$refs.equityRef.refreshTable()
},
handleReset() {
this.searchForm = {
serviceName: '',
serviceStatus: '',
createdDate: '',
updatedDate: ''
}
this.handleSearch()
},
addClause(type, row) {
// 1新增 2查看 3编辑
const { id, serviceCode, serviceName } = row || {}
let query = {
type
}
if (type != 1) {
query.id = id
query.serviceCode = serviceCode
query.serviceName = serviceName
}
const queryStr = encodeURIComponent(JSON.stringify(query))
this.$router.push('/serviceConfig/addService/' + queryStr)
}
}
}
</script>
<style lang="scss" scoped>
.container {
background-color: #ffffff;
padding: 20px;
.statsu-circle {
display: inline-block;
width: 6px;
height: 6px;
border-radius: 50%;
background-color: #fdb757;
margin-right: 8px;
vertical-align: middle;
}
}
</style>