Commit f0e3ea90993549574cdd1515729ee04b80142f4d

Authored by zhangzzzz
1 parent dfda9e28

文本组件可从静态数据中获取数据;多选图片地址选择可记录选择状态;全局数据保存样式错误问题解决;

src/store/index.js
@@ -7,6 +7,7 @@ import app from './modules/app' @@ -7,6 +7,7 @@ import app from './modules/app'
7 import user from './modules/user' 7 import user from './modules/user'
8 import cacheView from './modules/cachaView' 8 import cacheView from './modules/cachaView'
9 import help from './modules/help' 9 import help from './modules/help'
  10 +import dataSource from './modules/dataSource'
10 11
11 Vue.use(Vuex) 12 Vue.use(Vuex)
12 13
@@ -18,7 +19,8 @@ const store = new Vuex.Store({ @@ -18,7 +19,8 @@ const store = new Vuex.Store({
18 app, 19 app,
19 user, 20 user,
20 cacheView, 21 cacheView,
21 - help 22 + help,
  23 + dataSource
22 }, 24 },
23 state: { }, 25 state: { },
24 plugins: [initPlugin], 26 plugins: [initPlugin],
src/store/modules/dataSource.js 0 → 100644
  1 +const dataSource = {
  2 + namespaced: true,
  3 + state: {
  4 + staticData: {},
  5 + dynamicData: {}
  6 + },
  7 +
  8 + mutations: {
  9 + SET_STATIC_DATA: (state, data) => {
  10 + state.staticData = data;
  11 + },
  12 + SET_DYNAMIC_DATA: (state, data) => {
  13 + state.dynamicData = data;
  14 + }
  15 + },
  16 +
  17 + actions: {}
  18 +};
  19 +
  20 +export default dataSource;
src/views/bigscreenDesigner/designer/components/customUploadMulti.vue
1 <template> 1 <template>
2 <div> 2 <div>
3 - <el-input clearable v-model.trim="uploadImgUrl" size="mini" @change="changeInput"> 3 + <el-input clearable v-model="uploadImgUrl" size="mini" @change="changeInput">
4 <template slot="append"> 4 <template slot="append">
5 <i class="iconfont iconfolder-o" @click="dialogVisible = true"></i> 5 <i class="iconfont iconfolder-o" @click="dialogVisible = true"></i>
6 </template> 6 </template>
@@ -58,9 +58,10 @@ export default { @@ -58,9 +58,10 @@ export default {
58 uploadImgUrl: "" 58 uploadImgUrl: ""
59 }; 59 };
60 }, 60 },
61 - created() {  
62 - this.uploadImgUrl = this.value;  
63 - this.getFielList(); 61 + async created() {
  62 + this.uploadImgUrl = this.value.trim();
  63 + await this.getFielList();
  64 + this.getSelectedFileList();
64 }, 65 },
65 methods: { 66 methods: {
66 // 获取图片列表 67 // 获取图片列表
@@ -72,6 +73,14 @@ export default { @@ -72,6 +73,14 @@ export default {
72 this.fileList = fileList; 73 this.fileList = fileList;
73 } 74 }
74 }, 75 },
  76 + // 获取已选中图片列表
  77 + getSelectedFileList() {
  78 + const urlPathList = this.uploadImgUrl.split(',');
  79 + urlPathList.forEach(url => {
  80 + const temp = this.fileList.find(item => item.urlPath === url);
  81 + temp && this.selectedFileList.push(temp);
  82 + });
  83 + },
75 uploadHandler() { 84 uploadHandler() {
76 this.$refs.files.click(); 85 this.$refs.files.click();
77 }, 86 },
src/views/bigscreenDesigner/designer/components/dynamicForm.vue
@@ -111,6 +111,22 @@ @@ -111,6 +111,22 @@
111 /> 111 />
112 </el-select> 112 </el-select>
113 113
  114 + <el-select
  115 + v-if="item.type == 'el-select-static'"
  116 + size="mini"
  117 + v-model="formData[item.name]"
  118 + clearable
  119 + placeholder="请选择"
  120 + @change="val => changed(val, item.name)"
  121 + >
  122 + <el-option
  123 + v-for="(val, key) in staticData"
  124 + :key="key"
  125 + :label="key"
  126 + :value="key"
  127 + />
  128 + </el-select>
  129 +
114 <el-slider 130 <el-slider
115 v-if="item.type == 'el-slider'" 131 v-if="item.type == 'el-slider'"
116 v-model="formData[item.name]" 132 v-model="formData[item.name]"
@@ -301,6 +317,7 @@ import dynamicAddRadar from &quot;./dynamicAddRadar&quot;; @@ -301,6 +317,7 @@ import dynamicAddRadar from &quot;./dynamicAddRadar&quot;;
301 import CustomUploadNew from "./customUploadNew"; 317 import CustomUploadNew from "./customUploadNew";
302 import DatasourceSelect from "./datasourceSelect"; 318 import DatasourceSelect from "./datasourceSelect";
303 import CustomUploadMulti from "./customUploadMulti"; 319 import CustomUploadMulti from "./customUploadMulti";
  320 +import { mapState } from 'vuex';
304 export default { 321 export default {
305 name: "DynamicForm", 322 name: "DynamicForm",
306 components: { 323 components: {
@@ -342,9 +359,12 @@ export default { @@ -342,9 +359,12 @@ export default {
342 hintOptions: { 359 hintOptions: {
343 completeSingle: true // 当匹配只有一项的时候是否自动补全 360 completeSingle: true // 当匹配只有一项的时候是否自动补全
344 } 361 }
345 - } 362 + },
346 }; 363 };
347 }, 364 },
  365 + computed: {
  366 + ...mapState('dataSource', ['staticData']),
  367 + },
348 watch: { 368 watch: {
349 value(newValue, oldValue) { 369 value(newValue, oldValue) {
350 this.formData = newValue || {}; 370 this.formData = newValue || {};
@@ -352,7 +372,7 @@ export default { @@ -352,7 +372,7 @@ export default {
352 options(val) { 372 options(val) {
353 this.setDefaultValue(); 373 this.setDefaultValue();
354 this.isShowData(); 374 this.isShowData();
355 - } 375 + },
356 }, 376 },
357 created() { 377 created() {
358 this.isShowData(); 378 this.isShowData();
src/views/bigscreenDesigner/designer/index.vue
@@ -297,6 +297,7 @@ import VueRulerTool from &quot;vue-ruler-tool&quot;; // 大屏设计页面的标尺插件 @@ -297,6 +297,7 @@ import VueRulerTool from &quot;vue-ruler-tool&quot;; // 大屏设计页面的标尺插件
297 import contentMenu from "./components/contentMenu"; 297 import contentMenu from "./components/contentMenu";
298 import { getToken } from "@/utils/auth"; 298 import { getToken } from "@/utils/auth";
299 import { Revoke } from "@/utils/revoke"; //处理历史记录 2022-02-22 299 import { Revoke } from "@/utils/revoke"; //处理历史记录 2022-02-22
  300 +import { mapMutations } from 'vuex';
300 301
301 export default { 302 export default {
302 name: "Login", 303 name: "Login",
@@ -331,11 +332,12 @@ export default { @@ -331,11 +332,12 @@ export default {
331 height: 1080, // 大屏设计高度 332 height: 1080, // 大屏设计高度
332 backgroundColor: "", // 大屏背景色 333 backgroundColor: "", // 大屏背景色
333 backgroundImage: "", // 大屏背景图片 334 backgroundImage: "", // 大屏背景图片
334 - master: null, // 全局数据源  
335 - refreshMasterTime: 600000, // 刷新时间(毫秒) 335 + // master: null, // 全局数据源
  336 + // refreshMasterTime: 600000, // 刷新时间(毫秒)
336 refreshSeconds: null, // 大屏刷新时间间隔 337 refreshSeconds: null, // 大屏刷新时间间隔
337 presetLine: [], // 辅助线 338 presetLine: [], // 辅助线
338 presetLineVisible: true, // 辅助线是否显示 339 presetLineVisible: true, // 辅助线是否显示
  340 + data: [],
339 }, 341 },
340 masterData:{"sName1":"测试文本1","sName2":"测试文本2"}, 342 masterData:{"sName1":"测试文本1","sName2":"测试文本2"},
341 // 大屏的标记 343 // 大屏的标记
@@ -450,6 +452,7 @@ export default { @@ -450,6 +452,7 @@ export default {
450 }); 452 });
451 }, 453 },
452 methods: { 454 methods: {
  455 + ...mapMutations('dataSource', ['SET_STATIC_DATA']),
453 /** 456 /**
454 * @description: 恢复 457 * @description: 恢复
455 * @param {*} 458 * @param {*}
@@ -785,13 +788,18 @@ export default { @@ -785,13 +788,18 @@ export default {
785 // 选中不同的组件 右侧都显示第一栏 788 // 选中不同的组件 右侧都显示第一栏
786 this.activeName = "first"; 789 this.activeName = "first";
787 this.widgetOptions = getToolByCode("screen")["options"]; 790 this.widgetOptions = getToolByCode("screen")["options"];
  791 + this.SET_STATIC_DATA(this.widgetOptions.data.find(item => item.name === 'staticData').value);
788 }, 792 },
789 793
790 // 如果是点击某个组件,获取该组件的配置项 794 // 如果是点击某个组件,获取该组件的配置项
791 setOptionsOnClickWidget(obj) { 795 setOptionsOnClickWidget(obj) {
792 this.screenCode = ""; 796 this.screenCode = "";
793 if (typeof obj == "number") { 797 if (typeof obj == "number") {
794 - this.widgetOptions = this.deepClone(this.widgets[obj]["options"]); 798 + this.widgetOptions = {};
  799 + // 直接赋值数据不刷新。。。
  800 + this.$nextTick(() => {
  801 + this.widgetOptions = this.deepClone(this.widgets[obj]["options"]);
  802 + });
795 return; 803 return;
796 } 804 }
797 if (obj.index < 0 || obj.index >= this.widgets.length) { 805 if (obj.index < 0 || obj.index >= this.widgets.length) {
@@ -831,32 +839,43 @@ export default { @@ -831,32 +839,43 @@ export default {
831 }, 839 },
832 // 将当前选中的组件,右侧属性值更新 840 // 将当前选中的组件,右侧属性值更新
833 widgetValueChanged(key, val) { 841 widgetValueChanged(key, val) {
834 - // console.log("key", key);  
835 - // console.log("val", val);  
836 - // console.log(this.widgetOptions);  
837 if (this.screenCode == "screen") { 842 if (this.screenCode == "screen") {
838 - let newSetup = new Array();  
839 - this.dashboard = this.deepClone(val);  
840 - // console.log("asd", this.dashboard);  
841 - // console.log(this.widgetOptions);  
842 - if (this.bigscreenWidth != this.dashboard.width) {  
843 - this.bigscreenWidth = this.dashboard.width;  
844 - }  
845 - if (this.bigscreenHeight != this.dashboard.height) {  
846 - this.bigscreenHeight = this.dashboard.height;  
847 - }  
848 - this.widgetOptions.setup.forEach((el) => {  
849 - if (el.name == "width") {  
850 - el.value = this.bigscreenWidth;  
851 - } else if (el.name == "height") {  
852 - el.value = this.bigscreenHeight;  
853 - } else if (this.hasOwn(el.name)) {  
854 - el["value"] = this.dashboard[el.name]; 843 + if (key === 'setup') {
  844 + // 全局配置更改
  845 + let newSetup = new Array();
  846 + this.dashboard = this.deepClone(val);
  847 + if (this.bigscreenWidth !== this.dashboard.width && this.dashboard.width) {
  848 + this.bigscreenWidth = this.dashboard.width;
855 } 849 }
856 - newSetup.push(el);  
857 - });  
858 - // console.log(newSetup);  
859 - this.widgetOptions.setup = newSetup; 850 + if (this.bigscreenHeight !== this.dashboard.height && this.dashboard.height) {
  851 + this.bigscreenHeight = this.dashboard.height;
  852 + }
  853 +
  854 + this.widgetOptions.setup.forEach((el) => {
  855 + if (el.name == "width") {
  856 + el.value = this.bigscreenWidth;
  857 + } else if (el.name == "height") {
  858 + el.value = this.bigscreenHeight;
  859 + } else if (Object.hasOwn(this.dashboard, el.name)) {
  860 + el["value"] = this.dashboard[el.name];
  861 + }
  862 + newSetup.push(el);
  863 + });
  864 + this.widgetOptions.setup = newSetup;
  865 + } else if (key === 'data') {
  866 + // 全局数据更改
  867 + val.staticData && this.SET_STATIC_DATA(val.staticData);
  868 + let newData = new Array();
  869 + const cloneVal = this.deepClone(val);
  870 + this.widgetOptions.data.forEach((el) => {
  871 + if (Object.hasOwn(cloneVal, el.name)) {
  872 + el["value"] = cloneVal[el.name];
  873 + }
  874 + newData.push(el);
  875 + });
  876 + this.widgetOptions.data = newData;
  877 + }
  878 +
860 } else { 879 } else {
861 for (let i = 0; i < this.widgets.length; i++) { 880 for (let i = 0; i < this.widgets.length; i++) {
862 if (this.widgetIndex == i) { 881 if (this.widgetIndex == i) {
src/views/bigscreenDesigner/designer/tools/configure/texts/widget-text.js
@@ -32,6 +32,15 @@ export const widgetText = { @@ -32,6 +32,15 @@ export const widgetText = {
32 value: '文本框', 32 value: '文本框',
33 }, 33 },
34 { 34 {
  35 + type: 'el-select-static',
  36 + label: '全局静态数据选择',
  37 + name: 'slectedDataType',
  38 + require: false,
  39 + placeholder: '',
  40 + selectOptions: [],
  41 + value: '',
  42 + },
  43 + {
35 type: 'el-input-number', 44 type: 'el-input-number',
36 label: '字体字号', 45 label: '字体字号',
37 name: 'fontSize', 46 name: 'fontSize',
@@ -92,57 +101,57 @@ export const widgetText = { @@ -92,57 +101,57 @@ export const widgetText = {
92 }, 101 },
93 ], 102 ],
94 // 数据 103 // 数据
95 - data: [  
96 - {  
97 - type: 'el-radio-group',  
98 - label: '数据类型',  
99 - name: 'dataType',  
100 - require: false,  
101 - placeholder: '',  
102 - selectValue: true,  
103 - selectOptions: [  
104 - {  
105 - code: 'staticData',  
106 - name: '静态数据',  
107 - },  
108 - {  
109 - code: 'dynamicData',  
110 - name: '动态数据',  
111 - },  
112 - ],  
113 - value: 'staticData',  
114 - },  
115 - {  
116 - type: 'el-input-number',  
117 - label: '刷新时间(毫秒)',  
118 - name: 'refreshTime',  
119 - relactiveDom: 'dataType',  
120 - relactiveDomValue: 'dynamicData',  
121 - value: 5000  
122 - },  
123 - {  
124 - type: 'el-button',  
125 - label: '静态数据',  
126 - name: 'staticData',  
127 - required: false,  
128 - placeholder: '',  
129 - relactiveDom: 'dataType',  
130 - relactiveDomValue: 'staticData',  
131 - value: '文本框',  
132 - },  
133 - {  
134 - type: 'dycustComponents',  
135 - label: '',  
136 - name: 'dynamicData',  
137 - required: false,  
138 - placeholder: '',  
139 - relactiveDom: 'dataType',  
140 - relactiveDomValue: 'dynamicData',  
141 - chartType: 'widget-text',  
142 - dictKey: 'TEXT_PROPERTIES',  
143 - value: '',  
144 - }  
145 - ], 104 + // data: [
  105 + // {
  106 + // type: 'el-radio-group',
  107 + // label: '数据类型',
  108 + // name: 'dataType',
  109 + // require: false,
  110 + // placeholder: '',
  111 + // selectValue: true,
  112 + // selectOptions: [
  113 + // {
  114 + // code: 'staticData',
  115 + // name: '静态数据',
  116 + // },
  117 + // {
  118 + // code: 'dynamicData',
  119 + // name: '动态数据',
  120 + // },
  121 + // ],
  122 + // value: 'staticData',
  123 + // },
  124 + // {
  125 + // type: 'el-input-number',
  126 + // label: '刷新时间(毫秒)',
  127 + // name: 'refreshTime',
  128 + // relactiveDom: 'dataType',
  129 + // relactiveDomValue: 'dynamicData',
  130 + // value: 5000
  131 + // },
  132 + // {
  133 + // type: 'el-button',
  134 + // label: '静态数据',
  135 + // name: 'staticData',
  136 + // required: false,
  137 + // placeholder: '',
  138 + // relactiveDom: 'dataType',
  139 + // relactiveDomValue: 'staticData',
  140 + // value: '文本框',
  141 + // },
  142 + // {
  143 + // type: 'dycustComponents',
  144 + // label: '',
  145 + // name: 'dynamicData',
  146 + // required: false,
  147 + // placeholder: '',
  148 + // relactiveDom: 'dataType',
  149 + // relactiveDomValue: 'dynamicData',
  150 + // chartType: 'widget-text',
  151 + // dictKey: 'TEXT_PROPERTIES',
  152 + // value: '',
  153 + // }
  154 + // ],
146 155
147 // 坐标 156 // 坐标
148 position: [ 157 position: [
src/views/bigscreenDesigner/designer/widget/text/widgetText.vue
1 <template> 1 <template>
2 - <div class="text" :style="styleColor">{{ styleColor.text }}</div> 2 + <div class="text" :style="styleColor">{{ showText }}</div>
3 </template> 3 </template>
4 4
5 <script> 5 <script>
  6 +import { mapState } from 'vuex';
6 export default { 7 export default {
7 name: "WidgetText", 8 name: "WidgetText",
8 components: {}, 9 components: {},
@@ -17,6 +18,7 @@ export default { @@ -17,6 +18,7 @@ export default {
17 }; 18 };
18 }, 19 },
19 computed: { 20 computed: {
  21 + ...mapState('dataSource', ['staticData']),
20 transStyle() { 22 transStyle() {
21 return this.objToOne(this.options); 23 return this.objToOne(this.options);
22 }, 24 },
@@ -36,6 +38,10 @@ export default { @@ -36,6 +38,10 @@ export default {
36 top: this.transStyle.top + "px", 38 top: this.transStyle.top + "px",
37 right: this.transStyle.right + "px" 39 right: this.transStyle.right + "px"
38 }; 40 };
  41 + },
  42 + showText() {
  43 + const {text, slectedDataType} = this.transStyle;
  44 + return this.staticData[slectedDataType] || text;
39 } 45 }
40 }, 46 },
41 watch: { 47 watch: {
@@ -46,7 +52,7 @@ export default { @@ -46,7 +52,7 @@ export default {
46 this.setOptionsData(); 52 this.setOptionsData();
47 }, 53 },
48 deep: true 54 deep: true
49 - } 55 + },
50 }, 56 },
51 mounted() { 57 mounted() {
52 this.options = this.value; 58 this.options = this.value;