大屏 图层

qianlishi 3 years ago
parent 4fda028a29
commit 13b17e3b6e

@ -6,57 +6,68 @@
*/ */
!--> !-->
<template> <template>
<el-select v-model="dictionary" placeholder="请选择" clearable @change="selectChange"> <el-select
<el-option v-for="item in dictionaryOptions" :key="item.id" :label="item.text" :value="item.id" /> v-model="dictionary"
placeholder="请选择"
clearable
@change="selectChange"
size="mini"
>
<el-option
v-for="item in dictionaryOptions"
:key="item.id"
:label="item.text"
:value="item.id"
/>
</el-select> </el-select>
</template> </template>
<script> <script>
import { getDictList } from '@/api/dict-data' // import { getDictList } from "@/api/dict-data"; //
export default { export default {
name: 'GetDictionary', name: "GetDictionary",
props: { props: {
dictKey: String, // code dictKey: String, // code
updataDict: String, // updataDict: String //
}, },
data() { data() {
return { return {
dictionary: '', // dictionary: "", //
dictionaryOptions: [], // dictionaryOptions: [] //
} };
}, },
watch: { watch: {
dictKey: { dictKey: {
immediate: true, immediate: true,
handler() { handler() {
this.getSystem() this.getSystem();
}, }
}, },
updataDict: { updataDict: {
immediate: true, immediate: true,
handler() { handler() {
this.dictionary = this.updataDict this.dictionary = this.updataDict;
}, }
}, }
}, },
created() { created() {
this.getSystem() this.getSystem();
}, },
mounted() { mounted() {
this.dictionary = this.updataDict this.dictionary = this.updataDict;
}, },
methods: { methods: {
// //
async getSystem() { async getSystem() {
const { code, data } = await getDictList(this.dictKey) const { code, data } = await getDictList(this.dictKey);
if (code != '200') return if (code != "200") return;
this.dictionaryOptions = data this.dictionaryOptions = data;
}, },
selectChange(val) { selectChange(val) {
this.$emit('input', val) this.$emit("input", val);
}, }
}, }
} };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

@ -1,6 +1,11 @@
<template> <template>
<div> <div>
<el-button type="primary" icon="el-icon-plus" plain @click="handleAddClick" <el-button
type="primary"
size="mini"
icon="el-icon-plus"
plain
@click="handleAddClick"
>新增</el-button >新增</el-button
> >
<el-table :data="formData" style="width: 100%"> <el-table :data="formData" style="width: 100%">
@ -43,19 +48,23 @@
v-model="colorValue" v-model="colorValue"
style="width: 200px" style="width: 200px"
placeholder="请输入颜色" placeholder="请输入颜色"
size="mini"
> >
<template slot="append"> <template slot="append">
<el-color-picker <el-color-picker
v-model="colorValue" v-model="colorValue"
:predefine="predefineColors" :predefine="predefineColors"
size="mini"
/> />
</template> </template>
</el-input> </el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button> <el-button size="mini" @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="handleSaveClick"> </el-button> <el-button size="mini" type="primary" @click="handleSaveClick"
> </el-button
>
</span> </span>
</el-dialog> </el-dialog>
</div> </div>

@ -1,193 +1,213 @@
<template> <template>
<div> <div>
<el-form label-width="80px" <el-form label-width="80px" label-position="left">
label-position="left">
<el-form-item label="数据集"> <el-form-item label="数据集">
<el-select v-model="dataSetValue" <el-select
clearable size="mini"
placeholder="请选择" v-model="dataSetValue"
@change="selectDataSet"> clearable
<el-option v-for="item in dataSet" placeholder="请选择"
:key="item.code" @change="selectDataSet"
:label="item.setName" >
:value="item.id" /> <el-option
v-for="item in dataSet"
:key="item.code"
:label="item.setName"
:value="item.id"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item v-for="(item, index) in userNameList" <el-form-item
:key="index" v-for="(item, index) in userNameList"
:label="item.paramName"> :key="index"
<el-input v-model="item.sampleItem" /> :label="item.paramName"
>
<el-input v-model="item.sampleItem" size="mini" />
</el-form-item> </el-form-item>
<el-form-item v-for="item in setParamList" <el-form-item v-for="item in setParamList" :key="item" :label="item">
:key="item" <Dictionary
:label="item"> v-model="params"
<Dictionary v-model="params" :dict-key="'CHART_PROPERTIES'"
:dict-key="'CHART_PROPERTIES'" @input="selectParams($event, item)"
@input="selectParams($event, item)" /> />
</el-form-item> </el-form-item>
<el-button style="width: 100%" <el-button
type="primary" style="width: 100%"
plain type="primary"
@click="saveDataBtn">刷新</el-button> plain
size="mini"
@click="saveDataBtn"
>刷新</el-button
>
</el-form> </el-form>
</div> </div>
</template> </template>
<script> <script>
import { queryAllDataSet, detailBysetId, getData } from '@/api/bigscreen' import { queryAllDataSet, detailBysetId, getData } from "@/api/bigscreen";
import Dictionary from '@/components/Dictionary/index' import Dictionary from "@/components/Dictionary/index";
export default { export default {
name: 'DynamicComponents', name: "DynamicComponents",
components: { components: {
Dictionary, Dictionary
}, },
model: { model: {
prop: 'formData', prop: "formData",
event: 'input', event: "input"
}, },
props: { props: {
chartType: String, chartType: String,
props: ['formData'], props: ["formData"]
}, },
data () { data() {
return { return {
dataSetValue: '', dataSetValue: "",
dataSet: [], // dataSet: [], //
userNameList: [], // userNameList: [], //
setParamList: [], // setParamList: [], //
params: {}, params: {},
chartProperties: {}, chartProperties: {}
} };
}, },
computed: { computed: {
setCode () { setCode() {
let code = '' let code = "";
this.dataSet.forEach((el) => { this.dataSet.forEach(el => {
if (el.id == this.dataSetValue) { if (el.id == this.dataSetValue) {
code = el.setCode code = el.setCode;
} }
}) });
return code return code;
}, }
}, },
mounted () { mounted() {
this.loadDataSet() this.loadDataSet();
}, },
methods: { methods: {
async loadDataSet () { async loadDataSet() {
const { code, data } = await queryAllDataSet() const { code, data } = await queryAllDataSet();
this.dataSet = data this.dataSet = data;
if (code != '200') return if (code != "200") return;
}, },
async selectDataSet () { async selectDataSet() {
const { code, data } = await detailBysetId(this.dataSetValue) const { code, data } = await detailBysetId(this.dataSetValue);
this.userNameList = data.dataSetParamDtoList this.userNameList = data.dataSetParamDtoList;
this.setParamList = data.setParamList this.setParamList = data.setParamList;
if (code != '200') return if (code != "200") return;
}, },
async saveDataBtn () { async saveDataBtn() {
const contextData = {} const contextData = {};
for (let i = 0; i < this.userNameList.length; i++) { for (let i = 0; i < this.userNameList.length; i++) {
contextData[this.userNameList[i].paramName] = this.userNameList[i].sampleItem contextData[this.userNameList[i].paramName] = this.userNameList[
i
].sampleItem;
} }
const params = { const params = {
chartType: this.chartType, chartType: this.chartType,
setCode: this.setCode, setCode: this.setCode,
chartProperties: this.chartProperties, chartProperties: this.chartProperties,
contextData, contextData
} };
const { code, data } = await getData(params) const { code, data } = await getData(params);
const analysisData = this.analysisChartsData(data) const analysisData = this.analysisChartsData(data);
console.log(analysisData) console.log(analysisData);
this.$emit('input', analysisData) this.$emit("input", analysisData);
if (code != '200') return if (code != "200") return;
}, },
selectParams (val, key) { selectParams(val, key) {
this.chartProperties[key] = val this.chartProperties[key] = val;
}, },
// //
analysisChartsData (data) { analysisChartsData(data) {
// widget-barchart 线widget-linechart 线 widget-barlinechart 线widget-piechart widget-hollow-piechart // widget-barchart 线widget-linechart 线 widget-barlinechart 线widget-piechart widget-hollow-piechart
// widget-funnel widget-gauge // widget-funnel widget-gauge
const chartType = this.chartType const chartType = this.chartType;
if (chartType == 'widget-barchart' || chartType == 'widget-linechart' || chartType == 'widget-barlinechart') { if (
return this.barOrLineChartFn(data) chartType == "widget-barchart" ||
} else if (chartType == 'widget-piechart' || chartType == 'widget-hollow-piechart' || chartType == 'widget-funnel') { chartType == "widget-linechart" ||
return this.piechartFn(data) chartType == "widget-barlinechart"
} else if (chartType == 'widget-gauge') { ) {
return this.gaugeFn(data) return this.barOrLineChartFn(data);
} else if (
chartType == "widget-piechart" ||
chartType == "widget-hollow-piechart" ||
chartType == "widget-funnel"
) {
return this.piechartFn(data);
} else if (chartType == "widget-gauge") {
return this.gaugeFn(data);
} else { } else {
} }
}, },
// 线 // 线
barOrLineChartFn (data) { barOrLineChartFn(data) {
const ananysicData = {} const ananysicData = {};
const xAxisList = [] const xAxisList = [];
const series = [] const series = [];
for (const key in this.chartProperties) { for (const key in this.chartProperties) {
const obj = {} const obj = {};
const seriesData = [] const seriesData = [];
const value = this.chartProperties[key] const value = this.chartProperties[key];
obj['type'] = value obj["type"] = value;
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
if (value.startsWith('xAxis')) { if (value.startsWith("xAxis")) {
// x // x
xAxisList[i] = data[i][key] xAxisList[i] = data[i][key];
} else { } else {
// series // series
seriesData[i] = data[i][key] seriesData[i] = data[i][key];
} }
} }
obj['data'] = seriesData obj["data"] = seriesData;
if (!obj['type'].startsWith('xAxis')) { if (!obj["type"].startsWith("xAxis")) {
series.push(obj) series.push(obj);
} }
} }
ananysicData['xAxis'] = xAxisList ananysicData["xAxis"] = xAxisList;
ananysicData['series'] = series ananysicData["series"] = series;
// console.log(ananysicData, '') // console.log(ananysicData, '')
return ananysicData return ananysicData;
}, },
// //
piechartFn (data) { piechartFn(data) {
const ananysicData = [] const ananysicData = [];
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
const obj = {} const obj = {};
for (const key in this.chartProperties) { for (const key in this.chartProperties) {
const value = this.chartProperties[key] const value = this.chartProperties[key];
if (value === 'name') { if (value === "name") {
obj['name'] = data[i][key] obj["name"] = data[i][key];
} else { } else {
obj['value'] = data[i][key] obj["value"] = data[i][key];
} }
} }
ananysicData.push(obj) ananysicData.push(obj);
} }
// console.log(ananysicData, '') // console.log(ananysicData, '')
return ananysicData return ananysicData;
}, },
gaugeFn (data) { gaugeFn(data) {
const ananysicData = [] const ananysicData = [];
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
const obj = {} const obj = {};
for (const key in this.chartProperties) { for (const key in this.chartProperties) {
const value = this.chartProperties[key] const value = this.chartProperties[key];
if (value === 'name') { if (value === "name") {
obj['name'] = data[i][key] obj["name"] = data[i][key];
} else { } else {
obj['value'] = data[i][key] obj["value"] = data[i][key];
} }
} }
if (!obj['unit']) { if (!obj["unit"]) {
obj['unit'] = '%' obj["unit"] = "%";
} }
ananysicData.push(obj) ananysicData.push(obj);
} }
// console.log(ananysicData, '') // console.log(ananysicData, '')
return ananysicData[0] return ananysicData[0];
}, }
}, }
} };
</script> </script>
<style lang="sass" scoped></style> <style lang="sass" scoped></style>

@ -104,6 +104,7 @@
<el-button <el-button
v-if="item.type == 'el-button'" v-if="item.type == 'el-button'"
type="primary" type="primary"
size="mini"
plain plain
@click="addStaticData" @click="addStaticData"
>编辑</el-button >编辑</el-button
@ -311,12 +312,6 @@ export default {
this.setDefaultValue(); this.setDefaultValue();
this.isShowData(); this.isShowData();
} }
// formData: {
// handler () {
// this.$emit('onChanged', this.formData)
// },
// deep: true,
// },
}, },
created() { created() {
this.isShowData(); this.isShowData();

@ -34,6 +34,8 @@
v-for="(item, index) in layerWidget" v-for="(item, index) in layerWidget"
:key="index" :key="index"
class="tools-item" class="tools-item"
:class="widgetIndex == index ? 'is-active' : ''"
@click="layerClick(index)"
> >
<span class="tools-item-icon"> <span class="tools-item-icon">
<i class="iconfont" :class="item.icon"></i> <i class="iconfont" :class="item.icon"></i>
@ -123,7 +125,7 @@
:bigscreen="{ bigscreenWidth, bigscreenHeight }" :bigscreen="{ bigscreenWidth, bigscreenHeight }"
@onActivated="setOptionsOnClickWidget" @onActivated="setOptionsOnClickWidget"
@contextmenu.prevent.native="rightClick($event, index)" @contextmenu.prevent.native="rightClick($event, index)"
@click.prevent.native="widgetsClick(index)" @mousedown.prevent.native="widgetsClick(index)"
/> />
</div> </div>
</vue-ruler-tool> </vue-ruler-tool>
@ -197,6 +199,7 @@ export default {
}, },
data() { data() {
return { return {
layerWidget: [],
widgetTools: widgetTools, // js widgetTools: widgetTools, // js
widthLeftForTools: 200, // widthLeftForTools: 200, //
widthLeftForToolsHideButton: 15, // widthLeftForToolsHideButton: 15, //
@ -292,13 +295,14 @@ export default {
}, },
bigscreenHeightInWorkbench() { bigscreenHeightInWorkbench() {
return this.getPXUnderScale(this.bigscreenHeight); return this.getPXUnderScale(this.bigscreenHeight);
}, }
layerWidget() { },
const layerWidgetArr = []; watch: {
for (let i = 0; i < this.widgets.length; i++) { widgets: {
layerWidgetArr.push(getToolByCode(this.widgets[i].type)); handler(val) {
} this.handlerLayerWidget(val);
return layerWidgetArr; },
deep: true
} }
}, },
mounted() { mounted() {
@ -310,6 +314,22 @@ export default {
this.widgets = []; this.widgets = [];
}, },
methods: { methods: {
handlerLayerWidget(val) {
const layerWidgetArr = [];
for (let i = 0; i < val.length; i++) {
console.log(getToolByCode(val[i].type));
const obj = {};
obj.icon = getToolByCode(val[i].type).icon;
const options = val[i].options["setup"];
options.forEach(el => {
if (el.name == "layerName") {
obj.label = el.value;
}
});
layerWidgetArr.push(obj);
}
this.layerWidget = layerWidgetArr;
},
async initEchartData() { async initEchartData() {
const reportCode = this.$route.query.reportCode; const reportCode = this.$route.query.reportCode;
const { code, data } = await detailDashboard(reportCode); const { code, data } = await detailDashboard(reportCode);
@ -512,7 +532,10 @@ export default {
} }
return widgetJson; return widgetJson;
}, },
layerClick(index) {
this.widgetIndex = index;
this.widgetsClick(index);
},
// //
setOptionsOnClickScreen() { setOptionsOnClickScreen() {
this.screenCode = "screen"; this.screenCode = "screen";
@ -523,6 +546,10 @@ export default {
// //
setOptionsOnClickWidget(obj) { setOptionsOnClickWidget(obj) {
if (typeof obj == "number") {
this.widgetOptions = this.deepClone(this.widgets[obj]["options"]);
return;
}
if (obj.index < 0 || obj.index >= this.widgets.length) { if (obj.index < 0 || obj.index >= this.widgets.length) {
return; return;
} }
@ -536,7 +563,6 @@ export default {
} }
} }
}); });
console.log(this.widgets);
}, },
widgetsClick(index) { widgetsClick(index) {
const draggableArr = this.$refs.widgets; const draggableArr = this.$refs.widgets;
@ -547,9 +573,9 @@ export default {
this.$refs.widgets[i].$refs.draggable.setActive(false); this.$refs.widgets[i].$refs.draggable.setActive(false);
} }
} }
this.setOptionsOnClickWidget(index);
}, },
handleMouseDown() { handleMouseDown() {
console.log(1);
const draggableArr = this.$refs.widgets; const draggableArr = this.$refs.widgets;
for (let i = 0; i < draggableArr.length; i++) { for (let i = 0; i < draggableArr.length; i++) {
this.$refs.widgets[i].$refs.draggable.setActive(false); this.$refs.widgets[i].$refs.draggable.setActive(false);
@ -557,15 +583,6 @@ export default {
}, },
// //
widgetValueChanged(key, val) { widgetValueChanged(key, val) {
/* this.widgets this.widgetIndex value
widgets: [{
type: 'widget-text',
value: {
setup:{},
data: {},
position: {}
}
}]*/
if (this.screenCode == "screen") { if (this.screenCode == "screen") {
this.dashboard = this.deepClone(val); this.dashboard = this.deepClone(val);
} }
@ -624,6 +641,10 @@ export default {
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.is-active {
background: #409eff !important;
color: #373d41 !important;
}
.layout { .layout {
display: -webkit-box; display: -webkit-box;
display: -ms-flexbox; display: -ms-flexbox;

Loading…
Cancel
Save