修改看板配置

master
suixy 4 days ago
parent 863830d6ca
commit 1eda00e462

@ -20,6 +20,7 @@
"dependencies": { "dependencies": {
"@element-plus/icons-vue": "2.3.1", "@element-plus/icons-vue": "2.3.1",
"@highlightjs/vue-plugin": "2.1.0", "@highlightjs/vue-plugin": "2.1.0",
"@vitejs/plugin-basic-ssl": "^2.0.0",
"@vue-flow/background": "^1.3.2", "@vue-flow/background": "^1.3.2",
"@vue-flow/core": "^1.43.1", "@vue-flow/core": "^1.43.1",
"@vue-flow/node-resizer": "^1.4.0", "@vue-flow/node-resizer": "^1.4.0",

@ -1,4 +1,5 @@
<template> <template>
<div >
<div class="leftPanel"> <div class="leftPanel">
<el-tabs v-model="leftPanelState" class="demo-tabs" type="border-card"> <el-tabs v-model="leftPanelState" class="demo-tabs" type="border-card">
<el-tab-pane label="图表组件" name="1"> <el-tab-pane label="图表组件" name="1">
@ -154,7 +155,7 @@
<el-button type="primary" text :icon="Close" @click="clear"></el-button> <el-button type="primary" text :icon="Close" @click="clear"></el-button>
</div> </div>
</div> </div>
<div class="flowArea"> <div class="flowArea" v-loading="loading">
<VueFlow :min-zoom="0.01" ref="flowRef" v-model:nodes="nodes" v-model:edges="edges" fit-view-on-init <VueFlow :min-zoom="0.01" ref="flowRef" v-model:nodes="nodes" v-model:edges="edges" fit-view-on-init
default-marker-color="#409EFF" default-marker-color="#409EFF"
@connect="logEvent('connect', $event)" @connect="logEvent('connect', $event)"
@ -375,6 +376,15 @@
controls-position="right" controls-position="right"
/> />
</el-form-item> </el-form-item>
<el-form-item label="提示框" v-if="Object.keys(nodeAttrForm).includes('tooltip')">
<el-switch v-model="nodeAttrForm.tooltip" active-text="" inactive-text="" />
</el-form-item>
<el-form-item label="图例" v-if="Object.keys(nodeAttrForm).includes('legend')">
<el-switch v-model="nodeAttrForm.legend" active-text="" inactive-text="" />
</el-form-item>
<el-form-item label="饼图标签" v-if="Object.keys(nodeAttrForm).includes('label')">
<el-switch v-model="nodeAttrForm.label" active-text="" inactive-text="" />
</el-form-item>
</el-form> </el-form>
</el-collapse-item> </el-collapse-item>
<el-collapse-item title="自定义配置" name="3" v-if="customDataForm"> <el-collapse-item title="自定义配置" name="3" v-if="customDataForm">
@ -397,6 +407,7 @@
</el-collapse-item> </el-collapse-item>
</el-collapse> </el-collapse>
</div> </div>
</div>
<el-dialog v-model="pageSettingVisible" title="页面设置" width="500"> <el-dialog v-model="pageSettingVisible" title="页面设置" width="500">
<el-form :model="pageSettingForm"> <el-form :model="pageSettingForm">
<el-form-item label="页面大小" label-width="80px"> <el-form-item label="页面大小" label-width="80px">
@ -411,11 +422,12 @@
<el-form-item label="页面背景" label-width="80px"> <el-form-item label="页面背景" label-width="80px">
<el-upload <el-upload
class="avatar-uploader" class="avatar-uploader"
action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15" :action="uploadFileUrl"
:show-file-list="false" :show-file-list="false"
:limit="1" :limit="1"
accept=".jpg,.png" accept=".jpg,.png"
:before-upload="pageBgUploadSuccess" :headers="headers"
:on-success="pageBgUploadSuccess"
> >
<img v-if="pageSettingForm.bg" :src="pageSettingForm.bg" class="avatar" /> <img v-if="pageSettingForm.bg" :src="pageSettingForm.bg" class="avatar" />
<el-icon v-else class="avatar-uploader-icon"> <el-icon v-else class="avatar-uploader-icon">
@ -435,6 +447,7 @@
</el-dialog> </el-dialog>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { globalHeaders } from '@/utils/request';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import { Check, Close, Plus, Setting, StarFilled } from '@element-plus/icons-vue'; import { Check, Close, Plus, Setting, StarFilled } from '@element-plus/icons-vue';
@ -472,6 +485,11 @@ const {
updateNode updateNode
} = useVueFlow(); } = useVueFlow();
const baseUrl = import.meta.env.VITE_APP_BASE_API;
const uploadFileUrl = ref(baseUrl + '/resource/oss/upload'); //
const headers = ref(globalHeaders());
const loading = ref(false)
const pageSettingVisible = ref(false); const pageSettingVisible = ref(false);
const pageSettingForm = ref({}); const pageSettingForm = ref({});
const pageTitle = ref('页面名称'); const pageTitle = ref('页面名称');
@ -492,6 +510,7 @@ const customData = ref([]);
const customBoard = ref([]); const customBoard = ref([]);
const boardData = ref({}); const boardData = ref({});
onMounted(async () => { onMounted(async () => {
loading.value = true
getDataSourceList({ getDataSourceList({
pageNum: 1, pageNum: 1,
pageSize: 9999999 pageSize: 9999999
@ -566,7 +585,11 @@ onMounted(async () => {
}; };
}) || []; }) || [];
pageData.value = JSON.parse(data.customContent) || {}; pageData.value = JSON.parse(data.customContent) || {};
}); })
.finally(()=>{
loading.value = false
})
// pageData.value = JSON.parse(localStorage.getItem('PAGEDATA')); // pageData.value = JSON.parse(localStorage.getItem('PAGEDATA'));
}); });
const customDataForm = ref({}); const customDataForm = ref({});
@ -755,18 +778,21 @@ const clear = () => {
edges.value = []; edges.value = [];
}; };
const pageBgUploadSuccess = (file) => { const pageBgUploadSuccess = (res) => {
const getFileText = (file) => { // const getFileText = (file) => {
const reader = new FileReader(); // const reader = new FileReader();
reader.onload = function(e) { // reader.onload = function(e) {
const fileContent = e.target.result; // const fileContent = e.target.result;
console.log(fileContent); // console.log(fileContent);
pageSettingForm.value.bg = fileContent; // pageSettingForm.value.bg = fileContent;
}; // };
reader.readAsDataURL(file); // reader.readAsDataURL(file);
}; // };
getFileText(file); // getFileText(file);
return false; // return false;
if (res.code === 200) {
pageSettingForm.value.bg = res.data.url
}
}; };
const setPageData = () => { const setPageData = () => {
pageData.value = JSON.parse(JSON.stringify(pageSettingForm.value)); pageData.value = JSON.parse(JSON.stringify(pageSettingForm.value));

@ -61,6 +61,7 @@ const defaultOption = {
top: '5%' top: '5%'
}, },
legend: { legend: {
show:props.data?.options?.legend||false,
icon: 'circle', icon: 'circle',
top: '5%', top: '5%',
right: '5%', right: '5%',
@ -71,6 +72,7 @@ const defaultOption = {
} }
}, },
tooltip: { tooltip: {
show:props.data?.options?.tooltip||false,
trigger: 'axis', trigger: 'axis',
axisPointer: { axisPointer: {
label: { label: {
@ -185,6 +187,12 @@ const getOption = () => {
title: { title: {
text: props.data.options.title || '' text: props.data.options.title || ''
}, },
legend: {
show: props.data?.options?.legend || false,
},
tooltip: {
show:props.data?.options?.tooltip||false,
},
grid: { grid: {
top: props.data?.options?.gridTop + '%' || '20%', top: props.data?.options?.gridTop + '%' || '20%',
left: props.data?.options?.gridLeft + '%' || '20%', left: props.data?.options?.gridLeft + '%' || '20%',

@ -61,6 +61,7 @@ const defaultOption = {
top: '5%' top: '5%'
}, },
legend: { legend: {
show:props.data?.options?.legend||false,
icon: 'circle', icon: 'circle',
top: '5%', top: '5%',
right: '5%', right: '5%',
@ -71,6 +72,7 @@ const defaultOption = {
} }
}, },
tooltip: { tooltip: {
show:props.data?.options?.tooltip||false,
trigger: 'axis', trigger: 'axis',
axisPointer: { axisPointer: {
label: { label: {
@ -192,6 +194,12 @@ const getOption = () => {
title: { title: {
text: props.data.options.title || '' text: props.data.options.title || ''
}, },
legend: {
show: props.data?.options?.legend || false,
},
tooltip: {
show:props.data?.options?.tooltip||false,
},
grid: { grid: {
top: props.data?.options?.gridTop + '%' || '20%', top: props.data?.options?.gridTop + '%' || '20%',
left: props.data?.options?.gridLeft + '%' || '20%', left: props.data?.options?.gridLeft + '%' || '20%',

@ -61,6 +61,7 @@ const defaultOption = {
top: '5%' top: '5%'
}, },
legend: { legend: {
show:props.data?.options?.legend||false,
icon: 'circle', icon: 'circle',
top: '5%', top: '5%',
right: '5%', right: '5%',
@ -71,6 +72,7 @@ const defaultOption = {
} }
}, },
tooltip: { tooltip: {
show:props.data?.options?.tooltip||false,
trigger: 'axis', trigger: 'axis',
axisPointer: { axisPointer: {
label: { label: {
@ -189,6 +191,12 @@ const getOption = () => {
title: { title: {
text: props.data.options.title || '' text: props.data.options.title || ''
}, },
legend: {
show: props.data?.options?.legend || false,
},
tooltip: {
show:props.data?.options?.tooltip||false,
},
grid: { grid: {
top: props.data?.options?.gridTop + '%' || '20%', top: props.data?.options?.gridTop + '%' || '20%',
left: props.data?.options?.gridLeft + '%' || '20%', left: props.data?.options?.gridLeft + '%' || '20%',
@ -235,7 +243,7 @@ onMounted(() => {
}); });
watch(() => [JSON.parse(JSON.stringify(props.inputData)), JSON.parse(JSON.stringify(props.data.options))], (obj1, obj2) => { watch(() => [JSON.parse(JSON.stringify(props.inputData)), JSON.parse(JSON.stringify(props.data.options))], (obj1, obj2) => {
if (JSON.stringify(obj1) !== JSON.stringify(obj2)) { if (JSON.stringify(obj1) !== JSON.stringify(obj2)) {
console.log(1123);
chart && chart.setOption(getOption(), false); chart && chart.setOption(getOption(), false);
} }
}, { deep: true, immediate: true }); }, { deep: true, immediate: true });

@ -76,6 +76,7 @@ const getOption = () => {
top: '5%' top: '5%'
}, },
legend: { legend: {
show:props.data?.options?.legend||false,
icon: 'circle', icon: 'circle',
top: '5%', top: '5%',
right: '5%', right: '5%',
@ -86,6 +87,7 @@ const getOption = () => {
} }
}, },
tooltip: { tooltip: {
show:props.data?.options?.tooltip||false,
trigger: 'axis', trigger: 'axis',
axisPointer: { axisPointer: {
label: { label: {

@ -76,6 +76,7 @@ const getOption = () => {
top: '5%' top: '5%'
}, },
legend: { legend: {
show: props.data?.options?.legend || false,
icon: 'circle', icon: 'circle',
top: '5%', top: '5%',
right: '5%', right: '5%',
@ -86,6 +87,7 @@ const getOption = () => {
} }
}, },
tooltip: { tooltip: {
show:props.data?.options?.tooltip||false,
trigger: 'axis', trigger: 'axis',
axisPointer: { axisPointer: {
label: { label: {

@ -76,6 +76,7 @@ const getOption = () => {
top: '5%' top: '5%'
}, },
legend: { legend: {
show:props.data?.options?.legend||false,
icon: 'circle', icon: 'circle',
top: '5%', top: '5%',
right: '5%', right: '5%',
@ -86,6 +87,7 @@ const getOption = () => {
} }
}, },
tooltip: { tooltip: {
show:props.data?.options?.tooltip||false,
trigger: 'axis', trigger: 'axis',
axisPointer: { axisPointer: {
label: { label: {

@ -62,6 +62,7 @@ const getOption = () => {
top: '5%' top: '5%'
}, },
legend: { legend: {
show:props.data?.options?.legend||false,
icon: 'circle', icon: 'circle',
top: '5%', top: '5%',
right: '5%', right: '5%',
@ -72,6 +73,7 @@ const getOption = () => {
} }
}, },
tooltip: { tooltip: {
show:props.data?.options?.tooltip||false,
trigger: 'axis', trigger: 'axis',
axisPointer: { axisPointer: {
label: { label: {
@ -102,6 +104,7 @@ const getOption = () => {
type: 'pie', type: 'pie',
radius: '50%', radius: '50%',
label: { label: {
show:props.data?.options?.label||false,
formatter: '{b}: {d}%' formatter: '{b}: {d}%'
} }
} }
@ -109,7 +112,7 @@ const getOption = () => {
}; };
let xData = [props.inputData?.x1 || []]; let xData = [props.inputData?.x1 || []];
let yData = [props.inputData?.y1 || []]; let yData = [props.inputData?.y1 || []];
console.log(props.inputData); console.log(chartOption);
let length = Math.min(...xData.map(e => e.length), ...yData.map(e => e.length)); let length = Math.min(...xData.map(e => e.length), ...yData.map(e => e.length));
let source = [['product', ...[props.data.options?.yNames?.[0] || '数量']]]; let source = [['product', ...[props.data.options?.yNames?.[0] || '数量']]];
Array(length).fill(0).forEach((_, i) => { Array(length).fill(0).forEach((_, i) => {

@ -10,13 +10,13 @@ const getId = (type) => {
const getOption = (e) => { const getOption = (e) => {
if (e === 'line' || e === 'multiLines') { if (e === 'line' || e === 'multiLines') {
return { title: '', yNames: [], gridTop: 30, gridLeft: 5, gridBottom: 10, gridRight: 10, xName: '', yName: '' }; return { title: '', yNames: [], gridTop: 30, gridLeft: 5, gridBottom: 10, gridRight: 10, xName: '', yName: '', tooltip:true, legend:true };
} else if (e === 'bar' || e === 'multiBars') { } else if (e === 'bar' || e === 'multiBars') {
return { title: '', yNames: [], gridTop: 30, gridLeft: 5, gridBottom: 10, gridRight: 10, xName: '', yName: '' }; return { title: '', yNames: [], gridTop: 30, gridLeft: 5, gridBottom: 10, gridRight: 10, xName: '', yName: '', tooltip:true, legend:true };
} else if (e === 'curve' || e === 'multiCurves') { } else if (e === 'curve' || e === 'multiCurves') {
return { title: '', yNames: [], gridTop: 30, gridLeft: 5, gridBottom: 10, gridRight: 10, xName: '', yName: '' }; return { title: '', yNames: [], gridTop: 30, gridLeft: 5, gridBottom: 10, gridRight: 10, xName: '', yName: '', tooltip:true, legend:true };
} else if (e === 'pie') { } else if (e === 'pie') {
return { title: '', yNames: [] }; return { title: '', yNames: [], tooltip:true, legend:true,label:true };
} else if (e === 'customBoard') { } else if (e === 'customBoard') {
return { title: '', yNames: [] }; return { title: '', yNames: [] };
} else if (e === 'data') { } else if (e === 'data') {

@ -5,7 +5,6 @@
<template v-if="i.type === 'customBoard'"> <template v-if="i.type === 'customBoard'">
<CustomBoardNode :isView="true" :inputData=getInputData(i.id) v-bind="i"></CustomBoardNode> <CustomBoardNode :isView="true" :inputData=getInputData(i.id) v-bind="i"></CustomBoardNode>
</template> </template>
00
<template v-if="i.type === 'customData'"> <template v-if="i.type === 'customData'">
<CustomDataNode :isView="true" :inputData=getInputData(i.id) v-bind="i"></CustomDataNode> <CustomDataNode :isView="true" :inputData=getInputData(i.id) v-bind="i"></CustomDataNode>
</template> </template>
@ -101,8 +100,8 @@ const getInputData = (e) => {
}); });
return outputData; return outputData;
}; };
onMounted(() => { onMounted(async () => {
getBoardApi(router.currentRoute.value.query.id) await getBoardApi(router.currentRoute.value.query.id)
.then((res) => { .then((res) => {
let data = res.data; let data = res.data;
nodes.value = data.designPagePointList?.length !== 0 ? data.designPagePointList.map(e => { nodes.value = data.designPagePointList?.length !== 0 ? data.designPagePointList.map(e => {
@ -157,8 +156,10 @@ onMounted(() => {
sourceHandle: e.sourceHandleId sourceHandle: e.sourceHandleId
}; };
}) || []; }) || [];
area.value = JSON.parse(data.customContent) || {};
}); });
area.value = JSON.parse(localStorage.getItem('PAGEDATA')); // area.value = nodes.value.find(e=>e.type==='area')
// console.log('area.value',area.value);
}); });
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>

@ -20,6 +20,7 @@
<el-input v-model="zoomInput" disabled style="margin-left: 8px;width:100px" /> <el-input v-model="zoomInput" disabled style="margin-left: 8px;width:100px" />
<el-button @click="zoomChange(0.1)" icon="ZoomIn" circle style="margin-left: 8px;" /> <el-button @click="zoomChange(0.1)" icon="ZoomIn" circle style="margin-left: 8px;" />
<el-button type="primary" @click="view" style="margin-left: 12px;">预览</el-button> <el-button type="primary" @click="view" style="margin-left: 12px;">预览</el-button>
<el-button type="primary" @click="imp" style="margin-left: 12px;">场景1</el-button>
<el-button type="primary" @click="save" style="margin-left: 12px;">保存</el-button> <el-button type="primary" @click="save" style="margin-left: 12px;">保存</el-button>
<el-button type="primary" @click="clear" style="margin-left: 12px;">清空</el-button> <el-button type="primary" @click="clear" style="margin-left: 12px;">清空</el-button>
</div> </div>
@ -442,17 +443,17 @@ const logEvent = async (eventname, event) => {
break; break;
} }
}; };
// const nodes = ref([{ const nodes = ref([{
// id: pid.value, id: pid.value,
// name: 'area', name: 'area',
// type: 'area', type: 'area',
// position: { position: {
// x: 0, x: 0,
// y: 0 y: 0
// }, },
// data: {} data: {}
// }]); }]);
const nodes = ref([]); // const nodes = ref([]);
const edges = ref([]); const edges = ref([]);
const setPage = (type, width, height) => { const setPage = (type, width, height) => {
@ -487,6 +488,17 @@ const save = () => {
localStorage.setItem('printNodes', JSON.stringify(nodes.value)); localStorage.setItem('printNodes', JSON.stringify(nodes.value));
}; };
const clear = () => { const clear = () => {
pid.value = `area_${uuidv4().replaceAll('-', '_')}`
nodes.value = [{
id: pid.value,
name: 'area',
type: 'area',
position: {
x: 0,
y: 0
},
data: {}
}]
}; };
onMounted(() => { onMounted(() => {
@ -497,8 +509,11 @@ onMounted(() => {
zoom: 1 zoom: 1
}); });
}); });
nodes.value = JSON.parse(localStorage.getItem('printNodes') || '[]'); let nodesData = localStorage.getItem('printNodes')
if(nodesData){
nodes.value = JSON.parse(nodesData);
pid.value = nodes.value.find(e => e.name === 'area')?.id; pid.value = nodes.value.find(e => e.name === 'area')?.id;
}
console.log(nodes.value); console.log(nodes.value);
}); });
watch(() => flowRef.value?.viewport, () => { watch(() => flowRef.value?.viewport, () => {
@ -524,6 +539,11 @@ window.addEventListener('keyup', keyup);
const nodeChange = () => { const nodeChange = () => {
updateNode(nodeData.value.id, JSON.parse(JSON.stringify(nodeData.value)), { replace: false }); updateNode(nodeData.value.id, JSON.parse(JSON.stringify(nodeData.value)), { replace: false });
}; };
const imp = () =>{
let json ='[{"id":"text_e0ed2e33_b370_493f_9e85_179277939055","type":"text","dimensions":{"width":189,"height":76},"computedPosition":{"x":283.4645669291338,"y":0,"z":0},"handleBounds":{"source":null,"target":null},"selected":false,"dragging":false,"resizing":false,"initialized":false,"isParent":false,"position":{"x":283.4645669291338,"y":0},"data":{"options":{"field":"planDetailId","default":"","border":[{"type":"top","isShow":false,"width":1,"color":"#000","borderType":"solid"},{"type":"right","isShow":false,"width":1,"color":"#000","borderType":"solid"},{"type":"bottom","isShow":true,"width":1,"color":"#000","borderType":"solid"},{"type":"left","isShow":false,"width":1,"color":"#000","borderType":"solid"}]},"outputData":{}},"events":{},"name":"text","extent":"parent"},{"id":"text_af484d4b_42c0_463f_b0f7_eb0f716fbc5a","type":"text","dimensions":{"width":189,"height":19},"computedPosition":{"x":283.4645669291338,"y":94.48818897637794,"z":0},"handleBounds":{"source":null,"target":null},"selected":false,"dragging":false,"resizing":false,"initialized":false,"isParent":false,"position":{"x":283.4645669291338,"y":94.48818897637794},"data":{"options":{"default":"planId","border":[{"type":"top","isShow":false,"width":1,"color":"#000","borderType":"solid"},{"type":"right","isShow":false,"width":1,"color":"#000","borderType":"solid"},{"type":"bottom","isShow":false,"width":1,"color":"#000","borderType":"solid"},{"type":"left","isShow":false,"width":1,"color":"#000","borderType":"solid"}]},"outputData":{}},"events":{},"name":"text","extent":"parent","style":{"width":"189px","height":"18.89763779527559px"}},{"id":"barCode_1dd4465e_928c_49f2_867b_061fc5f96843","type":"barCode","dimensions":{"width":189,"height":76},"computedPosition":{"x":0,"y":188.97637795275588,"z":0},"handleBounds":{"source":null,"target":null},"selected":false,"dragging":false,"resizing":false,"initialized":false,"isParent":false,"position":{"x":0,"y":188.97637795275588},"data":{"options":{"field":"returnBarcode","default":""},"outputData":{}},"events":{},"name":"barCode","extent":"parent"},{"id":"QRCode_9ad0beba_b555_45ac_a1c6_23f23a6c9e9a","type":"QRCode","dimensions":{"width":189,"height":189},"computedPosition":{"x":529.1338582677165,"y":151.1811023622047,"z":1000},"handleBounds":{"source":null,"target":null},"selected":true,"dragging":false,"resizing":false,"initialized":false,"isParent":false,"position":{"x":529.1338582677165,"y":151.1811023622047},"data":{"options":{"field":"returnBarcode","default":""},"outputData":{}},"events":{},"name":"QRCode","extent":"parent"}]'
nodes.value = JSON.parse(json);
pid.value = nodes.value.find(e => e.name === 'area')?.id;
}
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.borderOption { .borderOption {

Loading…
Cancel
Save