widget.js
6.97 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
Vue.prototype.$layui = layui;
const vm = new Vue({
el: '#zbgl',
data: {
percentage: 10,
color: ['#FFA26D', '#0CC1EB', '#3283FF', '#FF8A9B'],
zbgk: [{ count: 20, zblx: '核心指标' }, { count: 20, zblx: '基础指标' }, { count: 20, zblx: '监测指标' }, { count: 40, zblx: '体系指标' }],
count: {},
id: ['zbgl-chart1', 'zbgl-chart2', 'zbgl-chart3', 'zbgl-chart4'],
inputVal: '',
tableData: [],
total: 60,
pagesize: 10,
currentPage: 1,
arr:[]
},
mounted() {
this.initZblbTable();
},
methods: {
initZblbTable() {
axios.post(CONF_NEWGHSC_SERVERURL + '/zbxgl/getZbgl')
.then(res => {
this.zbgk[0].zb = res.data.data.zbgk.jczb
this.zbgk[1].zb = res.data.data.zbgk.tjzb
this.zbgk[2].zb = res.data.data.zbgk.zczb
this.zbgk[3].zb = res.data.data.zbgk.yczb
this.tableData = res.data.data.list
this.total = this.tableData.length
})
},
// 导出模板
exportmb() {
axios({ // 用axios发送post请求
method: 'post',
url: CONF_NEWGHSC_SERVERURL + '/zbxgl/exportZbModel', // 请求地址
data: '', // 参数
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
responseType: 'blob' // 表明返回服务器返回的数据类型
})
.then(res => {
const content = res.data
// const blob = new Blob([content],{type: 'application/ms-excel'})
const fileName = '指标导入模板.xls'
if ('download' in document.createElement('a')) { // 非IE下载
const elink = document.createElement('a')
elink.download = fileName
elink.style.display = 'none'
elink.href = URL.createObjectURL(content)
document.body.appendChild(elink)
elink.click()
URL.revokeObjectURL(elink.href) // 释放URL 对象
document.body.removeChild(elink)
} else { // IE10+下载
navigator.msSaveBlob(content, fileName)
}
}).catch(res => {
});
},
// 批量导出指标值模板
batexport() {
axios({ // 用axios发送post请求
method: 'post',
url: CONF_NEWGHSC_SERVERURL + '/zbxgl/exportZbJczModel', // 请求地址
data: '', // 参数
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
responseType: 'blob' // 表明返回服务器返回的数据类型
})
.then(res => {
const content = res.data
// const blob = new Blob([content],{type: 'application/ms-excel'})
const fileName = '指标值导入模板.xls'
if ('download' in document.createElement('a')) { // 非IE下载
const elink = document.createElement('a')
elink.download = fileName
elink.style.display = 'none'
elink.href = URL.createObjectURL(content)
document.body.appendChild(elink)
elink.click()
URL.revokeObjectURL(elink.href) // 释放URL 对象
document.body.removeChild(elink)
} else { // IE10+下载
navigator.msSaveBlob(content, fileName)
}
}).catch(res => {
});
},
detail(row) {
axios.post(CONF_NEWGHSC_SERVERURL + '/zbxgl/getZbXq?bsm=' + row.zbbsm).then(res => {
})
window.location.href = '/frontweb/view/model/modeladd/widget.html?bsm=' + row.zbbsm
},
del(index, row) {
this.$confirm('此操作将永久删除该条信息, 是否继续?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
axios.post(CONF_NEWGHSC_SERVERURL + '/zbxgl/removeZb?bsm=' + row.zbbsm)
.then(res => {
if (res.data.code == 200) {
this.initZblbTable();
this.$message.success('删除成功');
}
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
},
searchVal() {
axios.get(CONF_NEWGHSC_SERVERURL + '/zbxgl/getZbglList?keyWord=' + this.inputVal
).then(res => {
var _data = {}
this.arr = []
for(var i = 0; i < res.data.data.list.length; i++) {
_data = {
dw: res.data.data.list[i].DW,
zbhqzt: res.data.data.list[i].ZBHQZT,
bsm: res.data.data.list[i].BSM,
zblx: res.data.data.list[i].ZBLX,
zbmc:res.data.data.list[i].ZBMC
}
this.arr.push(_data)
}
this.tableData = this.arr
this.total = this.tableData.length
})
},
cellStyle({ row, column, rowIndex, columnIndex }) {
if (columnIndex === 0) {
// 指定列号
return 'text-align:center'
} else {
return ''
}
},
resetxhFilter() {
this.$refs.filterTable.clearFilter('xh');
},
clearFilter() {
this.$refs.filterTable.clearFilter();
},
zblxFormat(row, column) {
if (row.zblx === '1') {
return '基础指标'
} else {
return '核心指标'
}
},
dwFormat(row, column) {
return row.zbmc;
},
zbztFormat(row, column) {
return row.zbmc;
},
filterTag(value, row) {
return row.tag === value;
},
filterHandler(value, row, column) {
const property = column['property'];
return row[property] === value;
},
indexMethod(index) {
return (index + 1) + (this.currentPage - 1) * this.pagesize;
},
// 分页功能
handleSizeChange(size) {
this.pagesize = size;
},
handleCurrentChange(currentPage) {
this.currentPage = currentPage;
}
}
});
$(".btn-prev").html('上一页');
$(".btn-next").html('下一页');