|
@@ -0,0 +1,377 @@
|
|
1
|
+<template>
|
|
2
|
+ <div class="">
|
|
3
|
+ <div class="filter-container">
|
|
4
|
+ <el-button size="small" class="filter-item" style="float:right;" @click="handleCreate" type="primary"
|
|
5
|
+ icon="el-icon-circle-plus-outline">{{$t('table.add')}}
|
|
6
|
+ </el-button>
|
|
7
|
+ </div>
|
|
8
|
+ <el-table :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)'}" :key='tableKey' :data="list"
|
|
9
|
+ v-loading="listLoading" border fit highlight-current-row style="width: 100%;min-height:500px;">
|
|
10
|
+ <!-- <el-table-column align="center" :label="$t('table.id')" width="65" @click="handleUpdate(scope.row)">
|
|
11
|
+ <template slot-scope="scope">
|
|
12
|
+ <span>{{scope.row.id}}</span>
|
|
13
|
+ </template>
|
|
14
|
+ </el-table-column> -->
|
|
15
|
+ <el-table-column align="center" label="标题">
|
|
16
|
+ <template slot-scope="scope">
|
|
17
|
+ <!-- <span @click="handleUpdate(scope.row)">{{scope.row.name}}</span> -->
|
|
18
|
+ <span>{{scope.row.title}}</span>
|
|
19
|
+ </template>
|
|
20
|
+ </el-table-column>
|
|
21
|
+ <el-table-column align="center" label="内容">
|
|
22
|
+ <template slot-scope="scope">
|
|
23
|
+ <span v-html="scope.row.content">{{scope.row.content}}</span>
|
|
24
|
+ </template>
|
|
25
|
+ </el-table-column>
|
|
26
|
+ <el-table-column align="center" :label="$t('table.actions')" width="230" class-name="small-padding fixed-width">
|
|
27
|
+ <template slot-scope="scope">
|
|
28
|
+ <el-tooltip class="item" effect="dark" content="编辑" placement="top">
|
|
29
|
+ <el-button icon="el-icon-edit-outline" type="primary" size="small"
|
|
30
|
+ @click="handleUpdate(scope.row)"></el-button>
|
|
31
|
+ </el-tooltip>
|
|
32
|
+ <el-tooltip class="item" effect="dark" content="删除" placement="top">
|
|
33
|
+ <el-button icon="el-icon-delete" v-if="scope.row.status!='deleted'" size="small" type="danger"
|
|
34
|
+ @click="handleModifyStatus(scope.row,'deleted')">
|
|
35
|
+ </el-button>
|
|
36
|
+ </el-tooltip>
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+ </template>
|
|
40
|
+ </el-table-column>
|
|
41
|
+ </el-table>
|
|
42
|
+
|
|
43
|
+ <!-- <div class="pagination-container">
|
|
44
|
+ <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="listQuery.page" :page-sizes="[10,20,30, 50]" :page-size="listQuery.limit" layout="total, sizes, prev, pager, next, jumper" :total="total">
|
|
45
|
+ </el-pagination>
|
|
46
|
+ </div> -->
|
|
47
|
+
|
|
48
|
+ <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
|
|
49
|
+ <el-form :rules="rules" ref="dataForm" :model="temp" label-position="right" label-width="70px">
|
|
50
|
+ <el-form-item label="标题" prop="title">
|
|
51
|
+ <el-input v-model="temp.title" maxlength="100" placeholder="请输入标题"></el-input>
|
|
52
|
+ </el-form-item>
|
|
53
|
+
|
|
54
|
+ <el-form-item label="内容" v-if="type == 'course_disease'">
|
|
55
|
+ <keep-alive>
|
|
56
|
+ <editor ref="editor"
|
|
57
|
+ id="editor"
|
|
58
|
+ style="width: 600px"
|
|
59
|
+ v-bind:r_content="temp.content">
|
|
60
|
+ </editor>
|
|
61
|
+ </keep-alive>
|
|
62
|
+ </el-form-item>
|
|
63
|
+
|
|
64
|
+ <el-form-item label="内容" prop="content" v-else>
|
|
65
|
+ <el-input type="textarea" :autosize="{ minRows: 4, maxRows: 4}" v-model="temp.content"
|
|
66
|
+ placeholder="请输入内容"></el-input>
|
|
67
|
+ </el-form-item>
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+ <el-form-item :label="$t('data_config.remark')">
|
|
71
|
+ <el-input type="textarea" :autosize="{ minRows: 4, maxRows: 4}" placeholder="请输入备注"
|
|
72
|
+ v-model="temp.remark"></el-input>
|
|
73
|
+ </el-form-item>
|
|
74
|
+ </el-form>
|
|
75
|
+ <div slot="footer" class="dialog-footer">
|
|
76
|
+ <el-button @click="dialogFormVisible = false">{{$t('table.cancel')}}</el-button>
|
|
77
|
+ <el-button v-if="dialogStatus=='create'" type="primary" @click="createData">{{$t('table.confirm')}}</el-button>
|
|
78
|
+ <el-button v-else type="primary" @click="updateData">{{$t('table.confirm')}}</el-button>
|
|
79
|
+ </div>
|
|
80
|
+ </el-dialog>
|
|
81
|
+
|
|
82
|
+ <el-dialog title="Reading statistics" :visible.sync="dialogPvVisible">
|
|
83
|
+ <el-table :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)'}" :data="pvData" border fit
|
|
84
|
+ highlight-current-row style="width: 100%">
|
|
85
|
+ <el-table-column prop="key" label="Channel"></el-table-column>
|
|
86
|
+ <el-table-column prop="pv" label="Pv"></el-table-column>
|
|
87
|
+ </el-table>
|
|
88
|
+ <span slot="footer" class="dialog-footer">
|
|
89
|
+ <el-button type="primary" @click="dialogPvVisible = false">{{$t('table.confirm')}}</el-button>
|
|
90
|
+ </span>
|
|
91
|
+ </el-dialog>
|
|
92
|
+
|
|
93
|
+ </div>
|
|
94
|
+</template>
|
|
95
|
+
|
|
96
|
+<script>
|
|
97
|
+ import { createChildConfig, createConfig, deleteChildConfig, updateChildConfig, updateTemplate } from '@/api/data'
|
|
98
|
+ import waves from '@/directive/waves' // 水波纹指令
|
|
99
|
+ import { parseTime } from '@/utils'
|
|
100
|
+ import store from '@/store'
|
|
101
|
+ import bus from '@/assets/eventBus'
|
|
102
|
+ import Editor from '@/components/Editor'
|
|
103
|
+
|
|
104
|
+ export default {
|
|
105
|
+ name: 'hisConfigInfo',
|
|
106
|
+ directives: {
|
|
107
|
+ waves
|
|
108
|
+ },
|
|
109
|
+ components: {
|
|
110
|
+ Editor
|
|
111
|
+ },
|
|
112
|
+ props: {
|
|
113
|
+ type: {
|
|
114
|
+ type: String,
|
|
115
|
+ default: 'patient'
|
|
116
|
+ }
|
|
117
|
+ },
|
|
118
|
+ beforeMount(){
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+ },
|
|
122
|
+ data() {
|
|
123
|
+ return {
|
|
124
|
+ currentId: undefined,
|
|
125
|
+ tableKey: 0,
|
|
126
|
+ // list: null,
|
|
127
|
+ total: null,
|
|
128
|
+ listLoading: true,
|
|
129
|
+ listQuery: {
|
|
130
|
+ page: 1,
|
|
131
|
+ limit: 20,
|
|
132
|
+ importance: undefined,
|
|
133
|
+ title: undefined,
|
|
134
|
+ type: this.type,
|
|
135
|
+ sort: '+id'
|
|
136
|
+ },
|
|
137
|
+ importanceOptions: [1, 2, 3],
|
|
138
|
+ // calendarTypeOptions,
|
|
139
|
+ sortOptions: [{ label: 'ID Ascending', key: '+id' }, { label: 'ID Descending', key: '-id' }],
|
|
140
|
+ statusOptions: ['published', 'draft', 'deleted'],
|
|
141
|
+ showReviewer: false,
|
|
142
|
+ temp: {
|
|
143
|
+ id: undefined,
|
|
144
|
+ parent_id: 0,
|
|
145
|
+ module: this.type,
|
|
146
|
+ org_id: 0,
|
|
147
|
+ title: '',
|
|
148
|
+ content: '',
|
|
149
|
+ remark: ''
|
|
150
|
+ },
|
|
151
|
+ dialogFormVisible: false,
|
|
152
|
+ dialogStatus: '',
|
|
153
|
+ textMap: {
|
|
154
|
+ update: '修改',
|
|
155
|
+ create: '新增'
|
|
156
|
+ },
|
|
157
|
+ dialogPvVisible: false,
|
|
158
|
+ pvData: [],
|
|
159
|
+ rules: {
|
|
160
|
+ title: [{ required: true, message: '请输入名称', trigger: 'blur' }],
|
|
161
|
+ content: [{ required: true, message: '请输入字段名', trigger: 'blur' }]
|
|
162
|
+ },
|
|
163
|
+ downloadLoading: false
|
|
164
|
+ }
|
|
165
|
+ },
|
|
166
|
+ // watch: {
|
|
167
|
+ // 'temp.config_field':function(){
|
|
168
|
+ // this.temp.config_field = this.temp.config_field.replace(/[^A-Za-z]/g,'');
|
|
169
|
+ // }
|
|
170
|
+ // },
|
|
171
|
+ computed: {
|
|
172
|
+ list: function() {
|
|
173
|
+ // const list = store.getters.configlist[this.type]
|
|
174
|
+ // this.total = list.length
|
|
175
|
+ return store.getters.configlist[this.type]
|
|
176
|
+ }
|
|
177
|
+ },
|
|
178
|
+ filters: {
|
|
179
|
+ statusFilter(status) {
|
|
180
|
+ const statusMap = {
|
|
181
|
+ published: 'success',
|
|
182
|
+ draft: 'info',
|
|
183
|
+ deleted: 'danger'
|
|
184
|
+ }
|
|
185
|
+ return statusMap[status]
|
|
186
|
+ },
|
|
187
|
+ typeFilter(type) {
|
|
188
|
+ return calendarTypeKeyValue[type]
|
|
189
|
+ }
|
|
190
|
+ },
|
|
191
|
+ created() {
|
|
192
|
+ this.getList()
|
|
193
|
+ },
|
|
194
|
+ methods: {
|
|
195
|
+ fieldChange: function(newValue) {
|
|
196
|
+ this.temp.config_field = newValue.replace(/[^A-Za-z]/g, '')
|
|
197
|
+ },
|
|
198
|
+ handleRowChange(currentRow, oldCurrentRow) {
|
|
199
|
+ if (currentRow != undefined) {
|
|
200
|
+ this.currentId = currentRow.id
|
|
201
|
+ bus.$emit('parentChangeId', currentRow)
|
|
202
|
+ }
|
|
203
|
+ },
|
|
204
|
+ getList() {
|
|
205
|
+ this.listLoading = false
|
|
206
|
+ // setTimeout(() => {
|
|
207
|
+ // this.listLoading = false
|
|
208
|
+ // }, 1 * 1000)
|
|
209
|
+ },
|
|
210
|
+ handleFilter() {
|
|
211
|
+ this.listQuery.page = 1
|
|
212
|
+ this.getList()
|
|
213
|
+ },
|
|
214
|
+ handleSizeChange(val) {
|
|
215
|
+ this.listQuery.limit = val
|
|
216
|
+ this.getList()
|
|
217
|
+ },
|
|
218
|
+ handleCurrentChange(val) {
|
|
219
|
+ this.listQuery.page = val
|
|
220
|
+ this.getList()
|
|
221
|
+ },
|
|
222
|
+ handleModifyStatus(row, status) {
|
|
223
|
+ this.temp = Object.assign({}, row) // copy obj
|
|
224
|
+ this.$confirm('此操作将永久删除该配置项, 是否继续?', '提示', {
|
|
225
|
+ confirmButtonText: '确 定',
|
|
226
|
+ cancelButtonText: '取 消',
|
|
227
|
+ type: 'warning'
|
|
228
|
+ }).then(() => {
|
|
229
|
+ const tempData = Object.assign({}, this.temp)
|
|
230
|
+ deleteChildConfig(tempData).then(response => {
|
|
231
|
+ if (!response.data) {
|
|
232
|
+ // 由于mockjs 不支持自定义状态码只能这样hack
|
|
233
|
+ reject('error')
|
|
234
|
+ }
|
|
235
|
+ if (response.data.state === 0) {
|
|
236
|
+ this.$message.error(response.data.msg)
|
|
237
|
+ }
|
|
238
|
+
|
|
239
|
+ const result = response.data.data.dataconfig
|
|
240
|
+ store.dispatch('updateParentConfigList', [tempData, 'delete']).then(() => {
|
|
241
|
+ next()
|
|
242
|
+ })
|
|
243
|
+ })
|
|
244
|
+
|
|
245
|
+ this.$message({
|
|
246
|
+ type: 'success',
|
|
247
|
+ message: '删除成功!'
|
|
248
|
+ })
|
|
249
|
+ })
|
|
250
|
+ .catch(() => {
|
|
251
|
+ this.$message({
|
|
252
|
+ type: 'info',
|
|
253
|
+ message: '已取消删除'
|
|
254
|
+ })
|
|
255
|
+ })
|
|
256
|
+ },
|
|
257
|
+ resetTemp() {
|
|
258
|
+ this.temp = {
|
|
259
|
+ id: undefined,
|
|
260
|
+ parent_id: 0,
|
|
261
|
+ module: this.type,
|
|
262
|
+ org_id: 0,
|
|
263
|
+ title: '',
|
|
264
|
+ content: '',
|
|
265
|
+ remark: ''
|
|
266
|
+ }
|
|
267
|
+ },
|
|
268
|
+ handleCreate() {
|
|
269
|
+ this.resetTemp()
|
|
270
|
+ this.dialogStatus = 'create'
|
|
271
|
+ this.dialogFormVisible = true
|
|
272
|
+ this.$nextTick(() => {
|
|
273
|
+ this.$refs['dataForm'].clearValidate()
|
|
274
|
+ })
|
|
275
|
+ },
|
|
276
|
+ createData() {
|
|
277
|
+ this.$refs['dataForm'].validate((valid) => {
|
|
278
|
+ if(this.type == "course_disease"){
|
|
279
|
+ this.temp.content = this.$refs.editor.content;
|
|
280
|
+ }
|
|
281
|
+
|
|
282
|
+ if (valid) {
|
|
283
|
+ createConfig(this.temp).then(response => {
|
|
284
|
+ if (!response.data) { // 由于mockjs 不支持自定义状态码只能这样hack
|
|
285
|
+ reject('error')
|
|
286
|
+ }
|
|
287
|
+ if (response.data.state === 0) {
|
|
288
|
+ this.$message.error(response.data.msg)
|
|
289
|
+ }
|
|
290
|
+ const result = response.data.data.dataconfig
|
|
291
|
+ // 更新store
|
|
292
|
+ store.dispatch('updateConfigList', result).then(() => {
|
|
293
|
+
|
|
294
|
+ })
|
|
295
|
+
|
|
296
|
+ this.dialogFormVisible = false
|
|
297
|
+
|
|
298
|
+ this.$message.success('创建成功')
|
|
299
|
+ })
|
|
300
|
+ }
|
|
301
|
+ })
|
|
302
|
+ },
|
|
303
|
+ handleUpdate(row) {
|
|
304
|
+ this.temp = Object.assign({}, row) // copy obj
|
|
305
|
+ this.dialogStatus = 'update'
|
|
306
|
+ this.dialogFormVisible = true
|
|
307
|
+ this.$nextTick(() => {
|
|
308
|
+ this.$refs['dataForm'].clearValidate()
|
|
309
|
+ })
|
|
310
|
+ },
|
|
311
|
+ updateData() {
|
|
312
|
+ this.$refs['dataForm'].validate(valid => {
|
|
313
|
+ if (valid) {
|
|
314
|
+ const tempData = Object.assign({}, this.temp)
|
|
315
|
+ if(this.type == "course_disease"){
|
|
316
|
+ tempData.content = this.$refs.editor.content;
|
|
317
|
+ }
|
|
318
|
+ updateTemplate(tempData).then(response => {
|
|
319
|
+ if (!response.data) {
|
|
320
|
+ // 由于mockjs 不支持自定义状态码只能这样hack
|
|
321
|
+ reject('error')
|
|
322
|
+ }
|
|
323
|
+ if (response.data.state === 0) {
|
|
324
|
+ this.$message.error(response.data.msg)
|
|
325
|
+ }
|
|
326
|
+
|
|
327
|
+ const result = response.data.data.dataconfig
|
|
328
|
+ store.dispatch('updateParentConfigList', [result, 'update']).then(() => {
|
|
329
|
+ next()
|
|
330
|
+ })
|
|
331
|
+
|
|
332
|
+ this.dialogFormVisible = false
|
|
333
|
+
|
|
334
|
+ this.$message.success('更新成功')
|
|
335
|
+ })
|
|
336
|
+ }
|
|
337
|
+ })
|
|
338
|
+ },
|
|
339
|
+ handleDelete(row) {
|
|
340
|
+
|
|
341
|
+ this.$message.success('删除成功')
|
|
342
|
+
|
|
343
|
+ const index = this.list.indexOf(row)
|
|
344
|
+ this.list.splice(index, 1)
|
|
345
|
+ },
|
|
346
|
+ handleFetchPv(pv) {
|
|
347
|
+ fetchPv(pv).then(response => {
|
|
348
|
+ this.pvData = response.data.pvData
|
|
349
|
+ this.dialogPvVisible = true
|
|
350
|
+ })
|
|
351
|
+ },
|
|
352
|
+ handleDownload() {
|
|
353
|
+ this.downloadLoading = true
|
|
354
|
+ import('@/vendor/Export2Excel').then(excel => {
|
|
355
|
+ const tHeader = ['timestamp', 'title', 'type', 'importance', 'status']
|
|
356
|
+ const filterVal = ['timestamp', 'title', 'type', 'importance', 'status']
|
|
357
|
+ const data = this.formatJson(filterVal, this.list)
|
|
358
|
+ excel.export_json_to_excel({
|
|
359
|
+ header: tHeader,
|
|
360
|
+ data,
|
|
361
|
+ filename: 'table-list'
|
|
362
|
+ })
|
|
363
|
+ this.downloadLoading = false
|
|
364
|
+ })
|
|
365
|
+ },
|
|
366
|
+ formatJson(filterVal, jsonData) {
|
|
367
|
+ return jsonData.map(v => filterVal.map(j => {
|
|
368
|
+ if (j === 'timestamp') {
|
|
369
|
+ return parseTime(v[j])
|
|
370
|
+ } else {
|
|
371
|
+ return v[j]
|
|
372
|
+ }
|
|
373
|
+ }))
|
|
374
|
+ }
|
|
375
|
+ }
|
|
376
|
+ }
|
|
377
|
+</script>
|