代码整理

qianlishi 2 years ago
parent d988e42322
commit 8f894b8195

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

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

Loading…
Cancel
Save