代码整理

qianlishi 2 years ago
parent d988e42322
commit 8f894b8195

@ -7,6 +7,7 @@ const mixin = {
return { return {
reportCode: this.$route.query.reportCode, reportCode: this.$route.query.reportCode,
uploadUrl: process.env.BASE_API + "/reportDashboard/import/" + this.reportCode, uploadUrl: process.env.BASE_API + "/reportDashboard/import/" + this.reportCode,
revoke: null, //处理历史记录
rightClickIndex: -1, rightClickIndex: -1,
} }
}, },
@ -186,9 +187,7 @@ const mixin = {
widget.value.setup.widgetId = widget.value.widgetId; widget.value.setup.widgetId = widget.value.widgetId;
}); });
const { code, data } = await insertDashboard(screenData); const { code, data } = await insertDashboard(screenData);
if (code == "200") { if (code == "200") return this.$message.success("保存成功!");
this.$message.success("保存成功!");
}
}, },
// 预览 // 预览
viewScreen() { viewScreen() {
@ -232,38 +231,19 @@ const mixin = {
}, },
handleUndo() { handleUndo() {
const record = this.revoke.undo(); const record = this.revoke.undo();
if (!record) { if (!record) return false;
return false;
}
this.widgets = record; this.widgets = record;
}, },
handleRedo() { handleRedo() {
const record = this.revoke.redo(); const record = this.revoke.redo();
if (!record) { if (!record) return false;
return false;
}
this.widgets = record; this.widgets = record;
}, },
handleUpload(response, file, fileList) { handleUpload(response, file, fileList) {
this.$refs.upload.clearFiles(); this.$refs.upload.clearFiles();
this.initEchartData(); this.getData();
if (response.code == "200") { if (response.code == "200") return this.$message.success('导入成功!')
this.$message({ this.$message.error(response.message)
message: "导入成功!",
type: "success",
});
} else {
this.$message({
message: response.message,
type: "error",
});
}
},
handleError(err) {
this.$message({
message: "上传失败!",
type: "error",
});
}, },
// 右键 // 右键
rightClick(event, index) { rightClick(event, index) {
@ -294,7 +274,7 @@ const mixin = {
const obj = this.widgets[this.rightClickIndex]; const obj = this.widgets[this.rightClickIndex];
this.$set(obj.value.position, "disabled", true); this.$set(obj.value.position, "disabled", true);
}, },
// 解除锁定 // 解除锁定
noLockLayer() { noLockLayer() {
const obj = this.widgets[this.rightClickIndex]; const obj = this.widgets[this.rightClickIndex];
this.$set(obj.value.position, "disabled", false); this.$set(obj.value.position, "disabled", false);
@ -348,7 +328,7 @@ const mixin = {
} else { } else {
this.widgets.unshift(this.widgets.splice(this.rightClickIndex, 1)[0]); this.widgets.unshift(this.widgets.splice(this.rightClickIndex, 1)[0]);
} }
}, }
} }
} }

@ -183,7 +183,6 @@
:headers="headers" :headers="headers"
accept=".zip" accept=".zip"
:on-success="handleUpload" :on-success="handleUpload"
:on-error="handleError"
:show-file-list="false" :show-file-list="false"
:limit="1" :limit="1"
> >
@ -283,7 +282,7 @@
@onActivated="setOptionsOnClickWidget" @onActivated="setOptionsOnClickWidget"
@contextmenu.prevent.native="rightClick($event, index)" @contextmenu.prevent.native="rightClick($event, index)"
@mousedown.prevent.native="widgetsClick(index)" @mousedown.prevent.native="widgetsClick(index)"
@mouseup.prevent.native="widgetsMouseup" @mouseup.prevent.native="grade = false"
/> />
</div> </div>
</vue-ruler-tool> </vue-ruler-tool>
@ -381,31 +380,14 @@ export default {
bigscreenWidth: 1920, // bigscreenWidth: 1920, //
bigscreenHeight: 1080, bigscreenHeight: 1080,
revoke: null, // 2022-02-22
dashboard: {}, dashboard: {},
// //
screenCode: "", screenCode: "",
dragWidgetCode: "", //code dragWidgetCode: "", //code
// //
widgets: [ widgets: [], //
{
// typevaluegaea_report_dashboard_widget
type: "widget-text",
value: {
setup: {},
data: {},
position: {
width: 100,
height: 100,
left: 0,
top: 0,
zIndex: 0,
},
},
// optionstools
options: [],
},
], //
// //
widgetIndex: 0, widgetIndex: 0,
// //
@ -469,7 +451,7 @@ export default {
watch: { watch: {
widgets: { widgets: {
handler(val) { handler(val) {
this.handlerLayerWidget(val); this.getLayerData(val);
this.handlerdynamicDataParamsConfig(val); this.handlerdynamicDataParamsConfig(val);
// //
this.$nextTick(() => { this.$nextTick(() => {
@ -489,7 +471,8 @@ export default {
}); });
}, },
methods: { methods: {
handlerLayerWidget(val) { //
getLayerData(val) {
const layerWidgetArr = []; const layerWidgetArr = [];
for (let i = 0; i < val.length; i++) { for (let i = 0; i < val.length; i++) {
const obj = {}; const obj = {};
@ -516,7 +499,6 @@ export default {
return item.value.data; return item.value.data;
}); });
}, },
// //
getPXUnderScale(px) { getPXUnderScale(px) {
return this.bigscreenScaleInWorkbench * px; return this.bigscreenScaleInWorkbench * px;
@ -569,9 +551,6 @@ export default {
this.currentSizeRangeIndex === this.defaultSize.index this.currentSizeRangeIndex === this.defaultSize.index
? this.bigscreenScaleInWorkbench ? this.bigscreenScaleInWorkbench
: this.sizeRange[this.currentSizeRangeIndex] / 100; : this.sizeRange[this.currentSizeRangeIndex] / 100;
// x y
// const x = widgetLeftInWorkbench / this.bigscreenScaleInWorkbench
// const y = widgetTopInWorkbench / this.bigscreenScaleInWorkbench
const x = widgetLeftInWorkbench / targetScale; const x = widgetLeftInWorkbench / targetScale;
const y = widgetTopInWorkbench / targetScale; const y = widgetTopInWorkbench / targetScale;
@ -593,9 +572,8 @@ export default {
options: tool.options, options: tool.options,
}; };
// //
const widgetJsonValue = this.handleDefaultValue(widgetJson); const widgetJsonValue = this.getWidgetConfigValue(widgetJson);
//20220222
widgetJsonValue.value.position.left = widgetJsonValue.value.position.left =
x - widgetJsonValue.value.position.width / 2; x - widgetJsonValue.value.position.width / 2;
widgetJsonValue.value.position.top = widgetJsonValue.value.position.top =
@ -606,46 +584,33 @@ export default {
// //
this.setOptionsOnClickWidget(this.widgets.length - 1); this.setOptionsOnClickWidget(this.widgets.length - 1);
}, },
// getWidgetConfigValue(widgetJson) {
handleDefaultValue(widgetJson) { this.setWidgetConfigValue(
console.log(widgetJson); widgetJson.options.setup,
for (const key in widgetJson) { widgetJson.value.setup
if (key == "options") { );
// collapsedatapositionsetup this.setWidgetConfigValue(
// setup widgetJson.options.position,
for (let i = 0; i < widgetJson.options.setup.length; i++) { widgetJson.value.position
const item = widgetJson.options.setup[i]; );
if (this.isObjectFn(item)) { this.setWidgetConfigValue(widgetJson.options.data, widgetJson.value.data);
widgetJson.value.setup[item.name] = item.value;
} else if (this.isArrayFn(item)) {
for (let j = 0; j < item.length; j++) {
const list = item[j].list;
list.forEach((el) => {
widgetJson.value.setup[el.name] = el.value;
});
}
}
}
// position
for (let i = 0; i < widgetJson.options.position.length; i++) {
const item = widgetJson.options.position[i];
if (item.value) {
widgetJson.value.position[item.name] = item.value;
}
}
// data
if (widgetJson.options.data && widgetJson.options.data.length > 0) {
for (let i = 0; i < widgetJson.options.data.length; i++) {
const item = widgetJson.options.data[i];
if (item.value) {
widgetJson.value.data[item.name] = item.value;
}
}
}
}
}
return widgetJson; return widgetJson;
}, },
setWidgetConfigValue(config, configValue) {
config.forEach((item) => {
if (this.isObjectFn(item)) {
configValue[item.name] = item.value;
}
if (this.isArrayFn(item)) {
item.forEach((itemChild) => {
itemChild.forEach((ev) => {
configValue[ev.name] = ev.value;
});
});
}
});
},
layerClick(index) { layerClick(index) {
this.widgetIndex = index; this.widgetIndex = index;
this.widgetsClick(index); this.widgetsClick(index);
@ -690,9 +655,6 @@ export default {
this.setOptionsOnClickWidget(index); this.setOptionsOnClickWidget(index);
this.grade = true; this.grade = true;
}, },
widgetsMouseup(e) {
this.grade = false;
},
handleMouseDown() { handleMouseDown() {
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++) {

Loading…
Cancel
Save