feat: panel页面 的删除 复制功能
This commit is contained in:
@@ -65,14 +65,23 @@ export default {
|
|||||||
this.$emit('refresh')
|
this.$emit('refresh')
|
||||||
},
|
},
|
||||||
editChart () {
|
editChart () {
|
||||||
this.$emit('edit-chart', this.chartInfo)
|
// this.$emit('edit-chart', this.chartInfo)
|
||||||
this.$store.dispatch('dispatchEditChart', this.chartInfo)
|
this.$store.dispatch('dispatchEditChart', {
|
||||||
|
chart: this.chartInfo,
|
||||||
|
type: 'edit'
|
||||||
|
})
|
||||||
},
|
},
|
||||||
removeChart () {
|
removeChart () {
|
||||||
this.$emit('delChart', this.chartInfo)
|
this.$store.dispatch('dispatchDelChart', {
|
||||||
|
chart: this.chartInfo,
|
||||||
|
type: 'delete'
|
||||||
|
})
|
||||||
},
|
},
|
||||||
duplicate () {
|
duplicate () {
|
||||||
|
this.$store.dispatch('dispatchEditChart', {
|
||||||
|
chart: this.chartInfo,
|
||||||
|
type: 'duplicate'
|
||||||
|
})
|
||||||
},
|
},
|
||||||
clickos () {
|
clickos () {
|
||||||
this.dropdownMenuShow = false
|
this.dropdownMenuShow = false
|
||||||
|
|||||||
@@ -149,9 +149,9 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
...mapActions(['loginSuccess']),
|
...mapActions(['loginSuccess']),
|
||||||
login () {
|
login () {
|
||||||
if (this.loading || !this.license.valid || !this.license.token) {
|
// if (this.loading || !this.license.valid || !this.license.token) {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
if (this.validateLogin() && (this.$route.path == '/' || this.$route.path == '/login')) {
|
if (this.validateLogin() && (this.$route.path == '/' || this.$route.path == '/login')) {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
this.$post('/sys/login', this.loginData).then(res => {
|
this.$post('/sys/login', this.loginData).then(res => {
|
||||||
|
|||||||
@@ -171,8 +171,8 @@ export default {
|
|||||||
this.$put('visual/panel/chart', params).then(response => {
|
this.$put('visual/panel/chart', params).then(response => {
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
||||||
this.esc(true)
|
|
||||||
this.$emit('on-create-success')
|
this.$emit('on-create-success')
|
||||||
|
this.esc(true)
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(response.msg)
|
this.$message.error(response.msg)
|
||||||
}
|
}
|
||||||
@@ -181,8 +181,8 @@ export default {
|
|||||||
this.$post('visual/panel/chart', params).then(response => {
|
this.$post('visual/panel/chart', params).then(response => {
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
||||||
this.esc(true)
|
|
||||||
this.$emit('on-create-success')
|
this.$emit('on-create-success')
|
||||||
|
this.esc(true)
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(response.msg)
|
this.$message.error(response.msg)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -461,7 +461,7 @@ export default {
|
|||||||
this.groupList = system.group
|
this.groupList = system.group
|
||||||
this.selectList = system.select
|
this.selectList = system.select
|
||||||
}
|
}
|
||||||
this.$refs.chartForm.clearValidate()
|
this.$refs.chartForm && this.$refs.chartForm.clearValidate()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(res.msg)
|
this.$message.error(res.msg)
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
<pick-time id="panel" ref="pickTime" v-model="searchTime" :refresh-data-func="dateChange" :use-chart-unit="false" class="margin-r-10"></pick-time>
|
<pick-time id="panel" ref="pickTime" v-model="searchTime" :refresh-data-func="dateChange" :use-chart-unit="false" class="margin-r-10"></pick-time>
|
||||||
|
|
||||||
<button id="panel-add-chart" v-has="'panel_chart_add'" :title="$t('overall.createChart')" class="top-tool-btn margin-r-10"
|
<button id="panel-add-chart" v-has="'panel_chart_add'" :title="$t('overall.createChart')" class="top-tool-btn margin-r-10"
|
||||||
type="button" @click="addChart">
|
type="button" @click="addChartBefore">
|
||||||
<i class="nz-icon-create-square nz-icon"></i>
|
<i class="nz-icon-create-square nz-icon"></i>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@
|
|||||||
<!-- @on-delete-success="delChartOk"-->
|
<!-- @on-delete-success="delChartOk"-->
|
||||||
<!-- ></chart-box>-->
|
<!-- ></chart-box>-->
|
||||||
<chart-right-box
|
<chart-right-box
|
||||||
v-if="rightBox.chart.show"
|
v-if="chartRightBoxShow"
|
||||||
ref="addChartModal"
|
ref="addChartModal"
|
||||||
:chart="chart"
|
:chart="chart"
|
||||||
:from="fromRoute.panel"
|
:from="fromRoute.panel"
|
||||||
@@ -278,6 +278,14 @@ export default {
|
|||||||
chartTempBox,
|
chartTempBox,
|
||||||
chartRightBox
|
chartRightBox
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
chartRightBoxShow () {
|
||||||
|
return this.$store.getters.getShowRightBox
|
||||||
|
},
|
||||||
|
delChartFlag () {
|
||||||
|
return this.$store.getters.getDelChart
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 刷新
|
// 刷新
|
||||||
Refresh () {
|
Refresh () {
|
||||||
@@ -355,7 +363,6 @@ export default {
|
|||||||
this.chart = this.newChart()
|
this.chart = this.newChart()
|
||||||
this.chart.panelId = this.showPanel.id
|
this.chart.panelId = this.showPanel.id
|
||||||
this.chart.panelName = this.showPanel.name
|
this.chart.panelName = this.showPanel.name
|
||||||
this.rightBox.chart.show = true
|
|
||||||
},
|
},
|
||||||
addChartByTemp () {
|
addChartByTemp () {
|
||||||
this.chart = JSON.parse(JSON.stringify(this.blankChartTemp))
|
this.chart = JSON.parse(JSON.stringify(this.blankChartTemp))
|
||||||
@@ -380,7 +387,6 @@ export default {
|
|||||||
this.chart.panelId = this.showPanel.id
|
this.chart.panelId = this.showPanel.id
|
||||||
this.chart.panelName = this.showPanel.name
|
this.chart.panelName = this.showPanel.name
|
||||||
this.chart.isGroup = true
|
this.chart.isGroup = true
|
||||||
this.rightBox.chart.show = true
|
|
||||||
},
|
},
|
||||||
newChart () {
|
newChart () {
|
||||||
return JSON.parse(JSON.stringify(this.blankChart))
|
return JSON.parse(JSON.stringify(this.blankChart))
|
||||||
@@ -391,7 +397,7 @@ export default {
|
|||||||
this.chart = JSON.parse(JSON.stringify(data))
|
this.chart = JSON.parse(JSON.stringify(data))
|
||||||
this.chart.panelId = this.showPanel.id
|
this.chart.panelId = this.showPanel.id
|
||||||
this.chart.panelName = this.showPanel.name
|
this.chart.panelName = this.showPanel.name
|
||||||
this.rightBox.chart.show = true
|
this.chart.id = ''
|
||||||
} else {
|
} else {
|
||||||
this.$get('visual/panel/chart/' + data.id).then(res => {
|
this.$get('visual/panel/chart/' + data.id).then(res => {
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
@@ -403,7 +409,6 @@ export default {
|
|||||||
if (!this.chart.groupId || this.chart.groupId == -1) {
|
if (!this.chart.groupId || this.chart.groupId == -1) {
|
||||||
this.chart.groupId = ''
|
this.chart.groupId = ''
|
||||||
}
|
}
|
||||||
this.rightBox.chart.show = true
|
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(res.msg)
|
this.$message.error(res.msg)
|
||||||
}
|
}
|
||||||
@@ -411,7 +416,8 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
closeChartBox (refresh) {
|
closeChartBox (refresh) {
|
||||||
this.rightBox.chart.show = false
|
// this.rightBox.chart.show = false
|
||||||
|
this.$store.dispatch('clearPanel')
|
||||||
/* if (refresh) {
|
/* if (refresh) {
|
||||||
this.getData(this.filter)
|
this.getData(this.filter)
|
||||||
} */
|
} */
|
||||||
@@ -442,26 +448,7 @@ export default {
|
|||||||
type: 'success',
|
type: 'success',
|
||||||
message: this.$t('tip.deleteSuccess')
|
message: this.$t('tip.deleteSuccess')
|
||||||
})
|
})
|
||||||
this.rightBox.chart.show = false
|
this.getData(this.filter)
|
||||||
const chartList = this.$refs.chartList.dataList
|
|
||||||
for (let i = 0; i < chartList.length; i++) {
|
|
||||||
/* if (chartList[i].id === data.id) {
|
|
||||||
chartList.splice(i, 1)
|
|
||||||
}
|
|
||||||
if (chartList[i].type === 'group') {
|
|
||||||
chartList[i].children = chartList[i].children.filter((item) => item.id !== data.id)
|
|
||||||
} */
|
|
||||||
// if(data.next != -1){
|
|
||||||
// if(chartList[i].id === data.next){
|
|
||||||
// nextChart = chartList[i]
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if(data.prev != 0){
|
|
||||||
// if(chartList[i].id === data.prev){
|
|
||||||
// prevChart = chartList[i]
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
// this.$refs.chartList.loadChartData(this.scrollbarWrap.scrollTop)
|
// this.$refs.chartList.loadChartData(this.scrollbarWrap.scrollTop)
|
||||||
// if(nextChart&&prevChart){ //删除图表为中间位置
|
// if(nextChart&&prevChart){ //删除图表为中间位置
|
||||||
// prevChart.next = nextChart.id;
|
// prevChart.next = nextChart.id;
|
||||||
@@ -736,6 +723,32 @@ export default {
|
|||||||
},
|
},
|
||||||
load () {
|
load () {
|
||||||
|
|
||||||
|
},
|
||||||
|
addChartBefore () {
|
||||||
|
this.$store.dispatch('dispatchEditChart', {
|
||||||
|
chart: '',
|
||||||
|
type: 'add'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
disposeChart () {
|
||||||
|
const chartInfo = this.$store.getters.getChart
|
||||||
|
const groupId = this.$store.getters.getGroupId
|
||||||
|
const type = this.$store.getters.getType
|
||||||
|
if (type === 'add') {
|
||||||
|
this.addChart()
|
||||||
|
}
|
||||||
|
if (type === 'edit') {
|
||||||
|
this.editChart(chartInfo)
|
||||||
|
}
|
||||||
|
if (type === 'addGroupItem') {
|
||||||
|
this.addGroupItem(groupId)
|
||||||
|
}
|
||||||
|
if (type === 'delete') {
|
||||||
|
this.delChart(chartInfo)
|
||||||
|
}
|
||||||
|
if (type === 'duplicate') {
|
||||||
|
this.editChart(chartInfo, true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
@@ -761,6 +774,24 @@ export default {
|
|||||||
localStorage.setItem('panelTime', JSON.stringify(n))
|
localStorage.setItem('panelTime', JSON.stringify(n))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
chartRightBoxShow: {
|
||||||
|
immediate: false,
|
||||||
|
deep: true,
|
||||||
|
handler (n) {
|
||||||
|
if (n) {
|
||||||
|
this.disposeChart()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
delChartFlag: {
|
||||||
|
immediate: false,
|
||||||
|
deep: true,
|
||||||
|
handler (n) {
|
||||||
|
if (n) {
|
||||||
|
this.disposeChart()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
$route: {
|
$route: {
|
||||||
immediate: true,
|
immediate: true,
|
||||||
handler () {
|
handler () {
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ const panel = {
|
|||||||
state: {
|
state: {
|
||||||
showRightBox: false,
|
showRightBox: false,
|
||||||
chart: '',
|
chart: '',
|
||||||
delChart: false
|
delChart: false,
|
||||||
|
groupId: '',
|
||||||
|
type: ''
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
setShowRightBox (state, flag) {
|
setShowRightBox (state, flag) {
|
||||||
@@ -12,12 +14,20 @@ const panel = {
|
|||||||
state.chart = chart
|
state.chart = chart
|
||||||
},
|
},
|
||||||
setDelChart (state, flag) {
|
setDelChart (state, flag) {
|
||||||
state.chart = flag
|
state.delChart = flag
|
||||||
},
|
},
|
||||||
clean (state) {
|
setType (state, type) {
|
||||||
|
state.type = type
|
||||||
|
},
|
||||||
|
setGroupId (state, id) {
|
||||||
|
state.groupId = id
|
||||||
|
},
|
||||||
|
cleanPanel (state) {
|
||||||
state.showRightBox = false
|
state.showRightBox = false
|
||||||
state.chart = ''
|
state.chart = ''
|
||||||
state.delChart = false
|
state.delChart = false
|
||||||
|
state.groupId = ''
|
||||||
|
state.type = ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
@@ -27,23 +37,35 @@ const panel = {
|
|||||||
getChart (state) {
|
getChart (state) {
|
||||||
return state.chart
|
return state.chart
|
||||||
},
|
},
|
||||||
|
getType (state) {
|
||||||
|
return state.type
|
||||||
|
},
|
||||||
|
getGroupId (state) {
|
||||||
|
return state.groupId
|
||||||
|
},
|
||||||
getDelChart (state) {
|
getDelChart (state) {
|
||||||
return state.delChart
|
return state.delChart
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
dispatchShowRightBox (flag) {
|
dispatchShowRightBox (store,flag) {
|
||||||
this.store.commit('setShowRightBox', flag)
|
store.commit('setShowRightBox', flag)
|
||||||
},
|
},
|
||||||
dispatchChart (chart) {
|
dispatchChart (store, chart) {
|
||||||
this.store.commit('setShowRightBox', chart)
|
store.commit('setShowRightBox', chart)
|
||||||
},
|
},
|
||||||
dispatchDelChart (flag) {
|
dispatchDelChart (store, playload) {
|
||||||
this.store.commit('setChart', flag)
|
store.commit('setDelChart', true)
|
||||||
|
store.commit('setChart', playload.chart)
|
||||||
|
store.commit('setType', playload.type)
|
||||||
},
|
},
|
||||||
dispatchEditChart (chart) {
|
dispatchEditChart (store, playload) {
|
||||||
this.store.commit('setShowRightBox', true)
|
store.commit('setShowRightBox', true)
|
||||||
this.store.commit('setChart', chart)
|
store.commit('setChart', playload.chart)
|
||||||
|
store.commit('setType', playload.type)
|
||||||
|
},
|
||||||
|
clearPanel (store) {
|
||||||
|
store.commit('cleanPanel')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user