index.vue
9.19 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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
<template>
<div class="equity-wrap">
<el-button type="primary" icon="el-icon-plus" size="small" @click="showDialog('add')"><span style="margin-left: 5px">新增特别约定</span></el-button>
<div class="equity-wrap contain" style="margin-top: 10px">
<GLCombiForm :rowNumber="1" ref="showSearch" :formObj="appointmentForm" :formData="searchFormData" @handleOk="seletTable('select')" @handleRest="seletTable('reset')"></GLCombiForm>
<el-button plain style="float:right;margin-bottom:10px;" size="small" @click="exportTable" class="selectBtn">导出</el-button>
<GLTable ref="appointmentTable" :searchForm="appointmentForm" :tableParams="tableParams" :pageConf="tablePageConf" :getListApi="getAppointmentList">
<span slot="auth-button" slot-scope="scope" :data="scope.scope">
<!-- 批次管理详情弹窗按钮 -->
<!-- <el-button type="text" @click="showDialog(scope.scope)">修改</el-button>
<el-button type="text" @click="del(scope.scope)">删除</el-button> -->
<GLTableButton :buttonList="buttonList" :buttonItem="scope" :buttonNum="3"></GLTableButton>
</span>
</GLTable>
<!-- 修改界面弹窗 -->
<GLDialog class="gl-form-page gl-form-min" :title="dialogTitle" mode="mid" v-if="modifyDialog" :visible.sync="modifyDialog" :before-close="handleClose" @onOk="submitForm('modifyForm')" @onCancel="cancelDialog">
<glsx-combi-form ref="spaRef" labelWidth="154px" defaultWidth="284px" formRef="modifyForm" :formObj="modifyDialogForm" :formData="modifyDialogData" :formRules="modifyDialogRules"></glsx-combi-form>
</GLDialog>
</div>
</div>
</template>
<script type="text/ecmascript-6">
import glsxCombiForm from '@/components/glsx-combi-form'
function date_format(date) {
var date2 = new Date(date)
var YY = date2.getFullYear() + '-'
var MM = (date2.getMonth() + 1 < 10 ? '0' + (date2.getMonth() + 1) : date2.getMonth() + 1) + '-'
var DD = date2.getDate() < 10 ? '0' + date2.getDate() : date2.getDate()
var hh = (date2.getHours() < 10 ? '0' + date2.getHours() : date2.getHours()) + ':'
var mm = (date2.getMinutes() < 10 ? '0' + date2.getMinutes() : date2.getMinutes()) + ':'
var ss = date2.getSeconds() < 10 ? '0' + date2.getSeconds() : date2.getSeconds()
return YY + MM + DD + ' ' + hh + mm + ss
}
import utils from '../../util/util'
export default {
name: '',
components:{
glsxCombiForm
},
data() {
return {
date_format,
buttonList: [
{
type: 'el-button',
name: row => {
return '修改'
},
attrs: {
type: 'text'
},
listeners: {
click: row => this.showDialog(row.scope)
}
},
{
type: 'el-button',
name: row => {
return '删除'
},
attrs: {
type: 'text'
},
listeners: {
click: row => this.del(row.scope)
}
}
],
searchFormData:[
{
label: '特约名称',
name: 'spaName',
type: 'input'
},
{
label: '特约内容',
name: 'spaContent',
type: 'input'
}
],
modifyDialogData: [
{
type: 'input',
label: '特约名称',
name: 'spaName',
isClear: true,
},
{
type: 'input',
label: '特约内容',
name: 'spaContent',
isClear: true,
maxlength: 200,
inputType:'textarea',
}
],
isAdd: false,
getAppointmentList: this.$apis.appointmentApi.getAppointmentList,
dialogTitle: '',
tablePageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
modifyDialog: false,
appointmentForm: {
spaName: '',
spaContent: ''
},
modifyDialogForm: {
spaName: '',
spaContent: '',
id: null
},
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'list',
tableOption: {
width: 120
},
tableColumns: [
{
label: '特约名称',
prop: 'spaName',
width: 400,
line:1
},
{
label: '特约内容',
prop: 'spaContent',
width: 400,
line:1
},
{
label: '操作人',
prop: 'updatedBy',
minWidth: 100,
},
{
label: '创建时间',
prop: 'createdDate',
width:220,
formatter: cellValue => {
return this.date_format(cellValue.createdDate)
}
},
{
label: '更新时间',
prop: 'updatedDate',
width:220,
formatter: cellValue => {
return this.date_format(cellValue.updatedDate)
}
}
]
},
modifyDialogRules: {
spaName: [{ required: true, message: '请输入名称', trigger: 'blur' }],
spaContent: [{ required: true, message: '请输入特约内容', trigger: 'blur' }]
}
}
},
mounted() {},
methods: {
handleClose() {
this.modifyDialog = false
this.modifyDialogForm = {}
},
cancelDialog() {
this.modifyDialog = false
this.modifyDialogForm = {}
},
submitForm(formName) {
this.$refs.spaRef.$refs[formName].validate(valid => {
if (valid) {
this.$apis.appointmentApi.modifyAppointment(this.modifyDialogForm).then(res => {
if (res.code == '0') {
this.$message({
message: '操作成功',
type: 'success'
})
this.modifyDialog = false
this.modifyDialogForm = {}
this.$refs.spaRef.$refs.modifyForm.clearValidate()
this.$refs.appointmentTable.refreshTable()
} else {
this.$message({
message: '该特约名称已存在,请修改',
type: 'error'
})
}
})
} else {
console.log('error submit!!')
return false
}
})
},
showDialog(e) {
if (e == 'add') {
this.dialogTitle = '新增特别约定'
this.isAdd = true
} else {
let obj = JSON.parse(JSON.stringify(e))
this.dialogTitle = '修改特别约定'
this.isAdd = false
this.modifyDialogForm = obj
}
this.modifyDialog = true
},
del(e) {
this.modifyDialogForm = e
this.$apis.appointmentApi.delAppointment(this.modifyDialogForm).then(res => {
if (res == '1') {
this.$message({
message: '操作成功',
type: 'success'
})
this.$refs.appointmentTable.refreshTable()
this.modifyDialogForm = {}
} else {
this.$message({
message: '新增失败',
type: 'error'
})
}
})
},
seletTable(e) {
let params = {
spaName: '',
spaContent: '',
pageSize: this.$refs.appointmentTable.page.pageSize,
pageNum: this.$refs.appointmentTable.page.pageNum
}
if (e == 'reset') {
this.appointmentForm.spaName = ''
this.appointmentForm.spaContent = ''
this.$apis.appointmentApi.getAppointmentList(params).then(res => {
this.$refs.appointmentTable.refreshTable()
})
} else if (e == 'select') {
params.spaName = this.appointmentForm.spaName
params.spaContent = this.appointmentForm.spaContent
this.$apis.appointmentApi.getAppointmentList(params).then(res => {
this.$refs.appointmentTable.refreshTable()
})
}
},
//导出
exportTable() {
let params = {
spaName: this.appointmentForm.spaName,
spaContent: this.appointmentForm.spaContent,
pageSize: this.$refs.appointmentTable.page.pageSize,
pageNum: this.$refs.appointmentTable.page.pageNum
}
this.$apis.appointmentApi.exportAppointment(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)
}
})
// this.$apis.appointmentApi.exportAppointment(params).then(res => {
// if (res) {
// console.log(res, 'res')
// var a = document.createElement('a')
// a.setAttribute('href', res)
// a.setAttribute('target', '_blank')
// a.setAttribute('id', 'd2admin-link-temp')
// a.setAttribute('download', '无忧卡导出' + '.xlsx') // 设置下载文件名称
// window.open(a)
// document.body.appendChild(a)
// a.click()
// document.body.removeChild(document.getElementById('d2admin-link-temp'))
// } else {
// console.log('导出失败')
// }
// })
}
}
}
</script>
<style lang="scss" scoped></style>