|
@@ -34,6 +34,11 @@
|
|
|
<template slot-scope="scope">
|
|
|
<el-button type="text"
|
|
|
size="small"
|
|
|
+ icon="el-icon-edit"
|
|
|
+ @click="updateChartItem(scope.row)">修改
|
|
|
+ </el-button>
|
|
|
+ <el-button type="text"
|
|
|
+ size="small"
|
|
|
icon="el-icon-delete"
|
|
|
style="color: red;"
|
|
|
@click="removeChartItem(scope.row)">删除
|
|
@@ -55,7 +60,7 @@
|
|
|
|
|
|
<!-- 新增首页图表 -->
|
|
|
<el-dialog
|
|
|
- title="添加图表"
|
|
|
+ :title="addIndexChart ? '添加图表' : '修改图表'"
|
|
|
width="600px"
|
|
|
top="5vh"
|
|
|
center
|
|
@@ -129,7 +134,8 @@
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<span slot='footer'>
|
|
|
- <el-button type="primary" @click="addIndexChartEvent">添加</el-button>
|
|
|
+ <el-button v-if="addIndexChart" type="primary" @click="addIndexChartEvent">添加</el-button>
|
|
|
+ <el-button v-else type="primary" @click="updateIndexChartEvent">修改</el-button>
|
|
|
<el-button @click="dialogClose">取消</el-button>
|
|
|
</span>
|
|
|
</el-dialog>
|
|
@@ -145,9 +151,8 @@
|
|
|
<script>
|
|
|
import DataItem from '@/components/CustomDialog/DataItem'
|
|
|
import UserGroup from '@/components/CustomDialog/UserGroup'
|
|
|
-import {goPage, showAlertMsgWin, showAlertWin, showConfirmWin, showLoading} from "@/utils/cqcy";
|
|
|
-import {delIndexChartById, getIndexChartById, getIndexChartList, saveIndexChart} from "@/api/chart";
|
|
|
-import {delItemGroupById} from "@/api/datasource";
|
|
|
+import { showAlertMsgWin, showAlertWin, showConfirmWin, showLoading} from "@/utils/cqcy";
|
|
|
+import {delIndexChartById, getIndexChartById, getIndexChartList, saveIndexChart, updateIndexChart} from "@/api/chart";
|
|
|
import {mapGetters} from "vuex";
|
|
|
|
|
|
export default {
|
|
@@ -159,6 +164,7 @@ export default {
|
|
|
return {
|
|
|
roleCodeList: [],
|
|
|
dialogIndexChartVisible: false,
|
|
|
+ addIndexChart: true,
|
|
|
hideMainViewFlag: true,
|
|
|
chartDataList: [],
|
|
|
chartTotal: 0,
|
|
@@ -239,8 +245,17 @@ export default {
|
|
|
},
|
|
|
/** 图表点击事件 */
|
|
|
handleChartNodeClick(row) {
|
|
|
+ },
|
|
|
+ /** 图表修改事件 */
|
|
|
+ updateChartItem(row) {
|
|
|
getIndexChartById(row.id).then(res => {
|
|
|
- console.log(res)
|
|
|
+ if (!res.data) {
|
|
|
+ showAlertMsgWin(this, null, '修改失败!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.chartForm = res.data
|
|
|
+ this.addIndexChart = false
|
|
|
+ this.dialogIndexChartVisible = true
|
|
|
}).catch((e) => {
|
|
|
showAlertWin(this, null, e)
|
|
|
})
|
|
@@ -262,6 +277,7 @@ export default {
|
|
|
},
|
|
|
/** 保存首页图表添加事件 */
|
|
|
addIndexChartBtnEvent() {
|
|
|
+ this.addIndexChart = true
|
|
|
this.dialogIndexChartVisible = true
|
|
|
},
|
|
|
/** 查询首页图表信息 */
|
|
@@ -294,6 +310,30 @@ export default {
|
|
|
// this.chartForm.startTime = this.chartForm.dateRange[0]
|
|
|
// this.chartForm.endTime = this.chartForm.dateRange[1]
|
|
|
saveIndexChart(this.chartForm).then(res => {
|
|
|
+ this.addIndexChart = true
|
|
|
+ this.dialogIndexChartVisible = false
|
|
|
+ this.getIndexAllChart()
|
|
|
+ showAlertMsgWin(this, null, res.data)
|
|
|
+ }).catch((e) => {
|
|
|
+ showAlertWin(this, null, e)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /** 修改图表信息 */
|
|
|
+ updateIndexChartEvent() {
|
|
|
+ if (!this.chartForm.chartName || !this.chartForm.chartName.trim()) {
|
|
|
+ showAlertMsgWin(this, null, '图表名称不能为空!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (this.chartForm.chartItemList.length == 0) {
|
|
|
+ showAlertMsgWin(this, null, '数据项不能为空!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (this.chartForm.userGroupList.length == 0) {
|
|
|
+ showAlertMsgWin(this, null, '用户组不能为空!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ updateIndexChart(this.chartForm).then(res => {
|
|
|
+ this.addIndexChart = true
|
|
|
this.dialogIndexChartVisible = false
|
|
|
this.getIndexAllChart()
|
|
|
showAlertMsgWin(this, null, res.data)
|
|
@@ -322,15 +362,32 @@ export default {
|
|
|
},
|
|
|
/** 选择数据项 */
|
|
|
chooseDataItemEvent() {
|
|
|
- this.$refs.dataItem.show()
|
|
|
+ let chartItemList = this.chartForm.chartItemList
|
|
|
+ let groupId = null
|
|
|
+ let items = []
|
|
|
+ if (chartItemList && chartItemList.length > 0) {
|
|
|
+ groupId = chartItemList[0].itemGroupId
|
|
|
+ chartItemList.forEach((t) => {
|
|
|
+ items.push(t.itemId)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.$refs.dataItem.show(groupId, items)
|
|
|
},
|
|
|
/** 选择用户组 */
|
|
|
chooseUserGroupEvent() {
|
|
|
- this.$refs.userGroup.show()
|
|
|
+ let userGroups = this.chartForm.userGroupList
|
|
|
+ let groups = []
|
|
|
+ if (userGroups && userGroups.length > 0) {
|
|
|
+ userGroups.forEach((t) => {
|
|
|
+ groups.push(t.id)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.$refs.userGroup.show(groups)
|
|
|
},
|
|
|
/** 弹出层关闭事件 */
|
|
|
dialogClose(done) {
|
|
|
Object.assign(this.$data.chartForm, this.$options.data.call(this).chartForm)
|
|
|
+ this.addIndexChart = true
|
|
|
if (typeof (done) === 'function') {
|
|
|
done()
|
|
|
} else {
|