|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <m-dialog ref="dialog" v-bind="$attrs" title="图表编辑" @sure="onSure">
|
|
|
+ <m-dialog ref="dialog" v-bind="$attrs" title="图表编辑" hideFooter>
|
|
|
<div class="pa-3 fullscreen border-box" v-loading="loading">
|
|
|
<m-card shadow="never" class="fullscreen border-box" :body-style="{ height: '100%', padding: 0 }">
|
|
|
<div class="d-flex box fullscreen">
|
|
@@ -10,7 +10,13 @@
|
|
|
></PrivateChartEditType>
|
|
|
</div>
|
|
|
<div class="box-main border-box">
|
|
|
- <m-card shadow="never" class="fullHeight" :bodyStyle="{ height: '100%' }">
|
|
|
+ <m-card class="box-main-top" shadow="never">
|
|
|
+ <div class="d-flex justify-between">
|
|
|
+ <el-tag>{{ itemData.content?.name }}</el-tag>
|
|
|
+ <m-button type="orange" size="small" @click="onSave" :disabled="empty">保存图表</m-button>
|
|
|
+ </div>
|
|
|
+ </m-card>
|
|
|
+ <m-card shadow="never" class="box-main-bottom" :bodyStyle="{ height: '100%', 'box-sizing': 'border-box' }">
|
|
|
<el-empty v-if="empty"></el-empty>
|
|
|
<PrivateChartEditShow
|
|
|
ref="privateChartEditShowRefs"
|
|
@@ -23,7 +29,6 @@
|
|
|
ref="privateChartEditParamsRefs"
|
|
|
class="fullscreen"
|
|
|
@render="onChangParams"
|
|
|
- @render:config="onChangeConfig"
|
|
|
></PrivateChartEditParams>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -36,6 +41,10 @@
|
|
|
import PrivateChartEditShow from './privateChartEditShow.vue'
|
|
|
import PrivateChartEditType from './privateChartEditType.vue'
|
|
|
import PrivateChartEditParams from './privateChartEditParams.vue'
|
|
|
+import {
|
|
|
+ getWebSetting,
|
|
|
+ saveWebSetting
|
|
|
+} from '@/api/system'
|
|
|
export default {
|
|
|
name: 'privateChartEdit',
|
|
|
components: {
|
|
@@ -51,29 +60,42 @@ export default {
|
|
|
option: {
|
|
|
xAxisData: []
|
|
|
},
|
|
|
- data: [[1, 2, 3, 4, 5, 6]]
|
|
|
+ data: [[1, 2, 3, 4, 5, 6]],
|
|
|
+ itemData: {}
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
async open (item) {
|
|
|
this.$refs.dialog.open()
|
|
|
- // this.loading = true
|
|
|
- this.$nextTick(async () => {
|
|
|
+ this.loading = true
|
|
|
+ try {
|
|
|
+ const { data } = await getWebSetting({
|
|
|
+ webSettingId: item.webSettingId
|
|
|
+ })
|
|
|
+ this.itemData = data
|
|
|
+ this.$nextTick(async () => {
|
|
|
// 实例化图例
|
|
|
- this.$refs.privateChartEditShowRefs.onInit()
|
|
|
- if (!item.data) {
|
|
|
- this.empty = true
|
|
|
- return
|
|
|
- }
|
|
|
- this.empty = false
|
|
|
- // // 获取初始化设置
|
|
|
- // const { key } = this.$refs.privateChartEditTypeRefs.getDefault()
|
|
|
- // this.key = key
|
|
|
- // this.option.xAxisData = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
|
|
|
- // this.setData()
|
|
|
- // this.loading = false
|
|
|
- // }
|
|
|
- })
|
|
|
+ this.$refs.privateChartEditShowRefs.onInit()
|
|
|
+ const _data = data.content.data
|
|
|
+ if (!_data) {
|
|
|
+ this.empty = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.empty = false
|
|
|
+ this.key = _data.key
|
|
|
+ this.option = _data.option
|
|
|
+ this.data = _data.data
|
|
|
+ // // 获取初始化设置
|
|
|
+ // const { key } = this.$refs.privateChartEditTypeRefs.getDefault()
|
|
|
+ // this.key = key
|
|
|
+ // this.option.xAxisData = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
|
|
|
+ this.setData()
|
|
|
+ })
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error(error)
|
|
|
+ } finally {
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
},
|
|
|
setData () {
|
|
|
this.empty = false
|
|
@@ -85,18 +107,45 @@ export default {
|
|
|
this.setData()
|
|
|
},
|
|
|
// 改变数据参数
|
|
|
- onChangParams (data) {
|
|
|
+ onChangParams ({ type, data }) {
|
|
|
+ this.option.xAxisData = type
|
|
|
this.data = data
|
|
|
+ if (!this.key) {
|
|
|
+ const { key } = this.$refs.privateChartEditTypeRefs.getDefault()
|
|
|
+ this.key = key
|
|
|
+ }
|
|
|
this.setData()
|
|
|
+ console.log(type, data)
|
|
|
},
|
|
|
// x、y轴数据
|
|
|
- onChangeConfig (obj) {
|
|
|
- // const { x, y } = obj
|
|
|
- console.log(obj)
|
|
|
- },
|
|
|
- onSure () {
|
|
|
- this.$refs.dialog.close()
|
|
|
- this.$emit('refresh')
|
|
|
+ // onChangeConfig (obj) {
|
|
|
+ // // const { x, y } = obj
|
|
|
+ // console.log(obj)
|
|
|
+ // },
|
|
|
+ async onSave () {
|
|
|
+ const {
|
|
|
+ data,
|
|
|
+ ...obj
|
|
|
+ } = this.itemData.content
|
|
|
+ try {
|
|
|
+ await saveWebSetting({
|
|
|
+ webSettingId: this.itemData.webSettingId,
|
|
|
+ content: {
|
|
|
+ ...obj,
|
|
|
+ data: {
|
|
|
+ data: this.data,
|
|
|
+ key: this.key,
|
|
|
+ option: this.option
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.$refs.dialog.close()
|
|
|
+ this.$emit('refresh')
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error(error)
|
|
|
+ } finally {
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -108,7 +157,8 @@ export default {
|
|
|
}
|
|
|
.box {
|
|
|
$left: 146px;
|
|
|
- $right: 500px;
|
|
|
+ $right: 650px;
|
|
|
+ box-sizing: border-box;
|
|
|
&-left {
|
|
|
width: $left;
|
|
|
}
|
|
@@ -116,6 +166,15 @@ export default {
|
|
|
padding: 10px 0;
|
|
|
width: calc(100% - #{$left} - #{$right});
|
|
|
height: 100%;
|
|
|
+ $h: 72px;
|
|
|
+ $heightMB: 12px;
|
|
|
+ &-top {
|
|
|
+ height: $h;
|
|
|
+ margin-bottom: 12px;
|
|
|
+ }
|
|
|
+ &-bottom {
|
|
|
+ height: calc(100% - 84px);
|
|
|
+ }
|
|
|
}
|
|
|
&-right {
|
|
|
width: $right;
|