|
@ -1,7 +1,7 @@ |
|
|
<template> |
|
|
<template> |
|
|
<Card class='DisposalPlan' title="处置预案"> |
|
|
<Card class='DisposalPlan' title="处置预案"> |
|
|
<canvas ref="FlowCanvasRef" /> |
|
|
<canvas ref="FlowCanvasRef" class="keep-ratio" /> |
|
|
</Card> |
|
|
</Card> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
@ -11,291 +11,291 @@ import { CanvasFlow } from "./utils"; |
|
|
import { merge } from "lodash"; |
|
|
import { merge } from "lodash"; |
|
|
|
|
|
|
|
|
function getDefaultBlockOption() { |
|
|
function getDefaultBlockOption() { |
|
|
return { |
|
|
return { |
|
|
width: 100, |
|
|
width: 100, |
|
|
height: 30, |
|
|
height: 30, |
|
|
radius: 9, |
|
|
radius: 9, |
|
|
linearGradient: "linear-gradient(180deg, #005C79 0%, #009BCC 100%)", |
|
|
linearGradient: "linear-gradient(180deg, #005C79 0%, #009BCC 100%)", |
|
|
text: { |
|
|
text: { |
|
|
font: "PingFang SC", |
|
|
font: "PingFang SC", |
|
|
fontSize: 14, |
|
|
fontSize: 14, |
|
|
color: "#FFFFFF" |
|
|
color: "#FFFFFF" |
|
|
}, |
|
|
}, |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function getDefaultLegendOption() { |
|
|
function getDefaultLegendOption() { |
|
|
return { |
|
|
return { |
|
|
width: 9, |
|
|
width: 9, |
|
|
height: 9, |
|
|
height: 9, |
|
|
y: 0, |
|
|
y: 0, |
|
|
text: { |
|
|
text: { |
|
|
font: "PingFang SC", |
|
|
font: "PingFang SC", |
|
|
fontSize: 9, |
|
|
fontSize: 9, |
|
|
align: 'left', |
|
|
align: 'left', |
|
|
color: "#FFFFFF" |
|
|
color: "#FFFFFF" |
|
|
}, |
|
|
}, |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const status = { |
|
|
const status = { |
|
|
0: `linear-gradient(180deg, #004960 0%, #004B62 100%)`, |
|
|
0: `linear-gradient(180deg, #004960 0%, #004B62 100%)`, |
|
|
1: `linear-gradient(90deg, #006121 0%, #488000 100%)`, |
|
|
1: `linear-gradient(90deg, #006121 0%, #488000 100%)`, |
|
|
2: `linear-gradient(180deg, #005C79 0%, #009BCC 100%)`, |
|
|
2: `linear-gradient(180deg, #005C79 0%, #009BCC 100%)`, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
|
name: 'DisposalPlan', |
|
|
name: 'DisposalPlan', |
|
|
components: { |
|
|
components: { |
|
|
Card |
|
|
Card |
|
|
}, |
|
|
}, |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
data: null |
|
|
data: null |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
watch: { |
|
|
watch: { |
|
|
data() { |
|
|
data() { |
|
|
this.draw(); |
|
|
this.draw(); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
mounted() { |
|
|
mounted() { |
|
|
this.canvasFlow = new CanvasFlow(this.$refs.FlowCanvasRef); |
|
|
this.canvasFlow = new CanvasFlow(this.$refs.FlowCanvasRef); |
|
|
|
|
|
|
|
|
this.draw(); |
|
|
this.draw(); |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
drawBlock({ x, y, width, height, backgroundColor, linearGradient, |
|
|
drawBlock({ x, y, width, height, backgroundColor, linearGradient, |
|
|
radius, |
|
|
radius, |
|
|
text: { |
|
|
text: { |
|
|
color, text, fontSize, fontWeight, fontFamily |
|
|
color, text, fontSize, fontWeight, fontFamily |
|
|
} = {} }) { |
|
|
} = {} }) { |
|
|
|
|
|
|
|
|
if (linearGradient) this.canvasFlow.setLinearGradient(...this.canvasFlow.transformCssLinearGradient(x, y, width, height, linearGradient)) |
|
|
if (linearGradient) this.canvasFlow.setLinearGradient(...this.canvasFlow.transformCssLinearGradient(x, y, width, height, linearGradient)) |
|
|
|
|
|
|
|
|
this.canvasFlow.drawRectangle({ x, y, width, height, backgroundColor, radius }); |
|
|
this.canvasFlow.drawRectangle({ x, y, width, height, backgroundColor, radius }); |
|
|
|
|
|
|
|
|
if (text) { |
|
|
if (text) { |
|
|
this.canvasFlow.fillText(text, { x, y, color, fontSize, fontWeight, fontFamily }, { width, height }); |
|
|
this.canvasFlow.fillText(text, { x, y, color, fontSize, fontWeight, fontFamily }, { width, height }); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
drawLegend({ x, y, width, height, backgroundColor, linearGradient, |
|
|
drawLegend({ x, y, width, height, backgroundColor, linearGradient, |
|
|
radius, |
|
|
radius, |
|
|
text: { |
|
|
text: { |
|
|
text, ...textOptions |
|
|
text, ...textOptions |
|
|
} = {} }) { |
|
|
} = {} }) { |
|
|
|
|
|
|
|
|
if (linearGradient) this.canvasFlow.setLinearGradient(...this.canvasFlow.transformCssLinearGradient(x, y, width, height, linearGradient)) |
|
|
if (linearGradient) this.canvasFlow.setLinearGradient(...this.canvasFlow.transformCssLinearGradient(x, y, width, height, linearGradient)) |
|
|
|
|
|
|
|
|
this.canvasFlow.drawRectangle({ x, y, width, height, backgroundColor, radius }); |
|
|
this.canvasFlow.drawRectangle({ x, y, width, height, backgroundColor, radius }); |
|
|
|
|
|
|
|
|
if (text) { |
|
|
if (text) { |
|
|
this.canvasFlow.fillText(text, { ...textOptions, x: x + width + 3, y: y + height / 2, }, { height }); |
|
|
this.canvasFlow.fillText(text, { ...textOptions, x: x + width + 3, y: y + height / 2, }, { height }); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
drawLine({ x, y, vertices }) { |
|
|
drawLine({ x, y, vertices }) { |
|
|
this.canvasFlow.drawLine({ x, y, color: '#154D6A', lineWidth: 6 }, vertices); |
|
|
this.canvasFlow.drawLine({ x, y, color: '#154D6A', lineWidth: 6 }, vertices); |
|
|
}, |
|
|
}, |
|
|
draw() { |
|
|
draw() { |
|
|
const { clientWidth } = this.$refs.FlowCanvasRef; |
|
|
const { clientWidth } = this.$refs.FlowCanvasRef; |
|
|
|
|
|
|
|
|
const defaultBlockOption = getDefaultBlockOption(); |
|
|
const defaultBlockOption = getDefaultBlockOption(); |
|
|
|
|
|
|
|
|
const halfWidth = defaultBlockOption.width / 2; |
|
|
const halfWidth = defaultBlockOption.width / 2; |
|
|
|
|
|
|
|
|
this.canvasFlow.clear(); |
|
|
this.canvasFlow.clear(); |
|
|
|
|
|
|
|
|
const legends = [ |
|
|
const legends = [ |
|
|
{ |
|
|
{ |
|
|
type: 'drawLegend', |
|
|
type: 'drawLegend', |
|
|
options: merge(getDefaultLegendOption(), { |
|
|
options: merge(getDefaultLegendOption(), { |
|
|
x: 150, |
|
|
x: 150, |
|
|
linearGradient: "linear-gradient(180deg, #004960 0%, #004B62 100%)", |
|
|
linearGradient: "linear-gradient(180deg, #004960 0%, #004B62 100%)", |
|
|
text: { |
|
|
text: { |
|
|
text: "未完成" |
|
|
text: "未完成" |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
type: 'drawLegend', |
|
|
type: 'drawLegend', |
|
|
options: merge(getDefaultLegendOption(), { |
|
|
options: merge(getDefaultLegendOption(), { |
|
|
x: 210, |
|
|
x: 210, |
|
|
linearGradient: "linear-gradient(90deg, #006121 0%, #488000 100%)", |
|
|
linearGradient: "linear-gradient(90deg, #006121 0%, #488000 100%)", |
|
|
text: { |
|
|
text: { |
|
|
text: "进行中" |
|
|
text: "进行中" |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
type: 'drawLegend', |
|
|
type: 'drawLegend', |
|
|
options: merge(getDefaultLegendOption(), { |
|
|
options: merge(getDefaultLegendOption(), { |
|
|
x: 270, |
|
|
x: 270, |
|
|
linearGradient: "linear-gradient(180deg, #005C79 0%, #009BCC 100%)", |
|
|
linearGradient: "linear-gradient(180deg, #005C79 0%, #009BCC 100%)", |
|
|
text: { |
|
|
text: { |
|
|
text: "已完成" |
|
|
text: "已完成" |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
|
const blockList = [ |
|
|
const blockList = [ |
|
|
{ |
|
|
{ |
|
|
type: 'drawBlock', |
|
|
type: 'drawBlock', |
|
|
key: "DisposalPlan", |
|
|
key: "DisposalPlan", |
|
|
options: merge(getDefaultBlockOption(), { |
|
|
options: merge(getDefaultBlockOption(), { |
|
|
x: clientWidth / 2 - halfWidth, |
|
|
x: clientWidth / 2 - halfWidth, |
|
|
y: 24, |
|
|
y: 24, |
|
|
text: { |
|
|
text: { |
|
|
text: "处置预案" |
|
|
text: "处置预案" |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
type: 'drawBlock', |
|
|
type: 'drawBlock', |
|
|
key: "AnalyzeConfirm", |
|
|
key: "AnalyzeConfirm", |
|
|
options: merge(getDefaultBlockOption(), { |
|
|
options: merge(getDefaultBlockOption(), { |
|
|
x: clientWidth / 2 - halfWidth, |
|
|
x: clientWidth / 2 - halfWidth, |
|
|
y: 75, |
|
|
y: 75, |
|
|
text: { |
|
|
text: { |
|
|
text: "分析确认" |
|
|
text: "分析确认" |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
type: 'drawBlock', |
|
|
type: 'drawBlock', |
|
|
key: "InstructionsGiven", |
|
|
key: "InstructionsGiven", |
|
|
options: merge(getDefaultBlockOption(), { |
|
|
options: merge(getDefaultBlockOption(), { |
|
|
x: clientWidth / 7 - halfWidth, |
|
|
x: clientWidth / 7 - halfWidth, |
|
|
y: 123, |
|
|
y: 123, |
|
|
linearGradient: "linear-gradient(90deg, #006121 0%, #488000 100%)", |
|
|
linearGradient: "linear-gradient(90deg, #006121 0%, #488000 100%)", |
|
|
text: { |
|
|
text: { |
|
|
text: "指令下达" |
|
|
text: "指令下达" |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
type: 'drawBlock', |
|
|
type: 'drawBlock', |
|
|
key: "OnSiteConfirmation", |
|
|
key: "OnSiteConfirmation", |
|
|
options: merge(getDefaultBlockOption(), { |
|
|
options: merge(getDefaultBlockOption(), { |
|
|
x: clientWidth / 7 * 6 - halfWidth, |
|
|
x: clientWidth / 7 * 6 - halfWidth, |
|
|
y: 123, |
|
|
y: 123, |
|
|
linearGradient: "linear-gradient(90deg, #006121 0%, #488000 100%)", |
|
|
linearGradient: "linear-gradient(90deg, #006121 0%, #488000 100%)", |
|
|
text: { |
|
|
text: { |
|
|
text: "现场确认" |
|
|
text: "现场确认" |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
type: 'drawBlock', |
|
|
type: 'drawBlock', |
|
|
key: "OnSiteDisposal", |
|
|
key: "OnSiteDisposal", |
|
|
options: merge(getDefaultBlockOption(), { |
|
|
options: merge(getDefaultBlockOption(), { |
|
|
x: clientWidth / 2 - halfWidth, |
|
|
x: clientWidth / 2 - halfWidth, |
|
|
y: 170, |
|
|
y: 170, |
|
|
linearGradient: "linear-gradient(180deg, #004960 0%, #004B62 100%)", |
|
|
linearGradient: "linear-gradient(180deg, #004960 0%, #004B62 100%)", |
|
|
text: { |
|
|
text: { |
|
|
text: "现场处置" |
|
|
text: "现场处置" |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
type: 'drawBlock', |
|
|
type: 'drawBlock', |
|
|
key: "FollowUpProcessing", |
|
|
key: "FollowUpProcessing", |
|
|
options: merge(getDefaultBlockOption(), { |
|
|
options: merge(getDefaultBlockOption(), { |
|
|
x: clientWidth / 2 - halfWidth, |
|
|
x: clientWidth / 2 - halfWidth, |
|
|
y: 225, |
|
|
y: 225, |
|
|
linearGradient: "linear-gradient(180deg, #004960 0%, #004B62 100%)", |
|
|
linearGradient: "linear-gradient(180deg, #004960 0%, #004B62 100%)", |
|
|
text: { |
|
|
text: { |
|
|
text: "后续处理" |
|
|
text: "后续处理" |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
const linePoints = [ |
|
|
const linePoints = [ |
|
|
{ |
|
|
{ |
|
|
x: blockList[0].options.x + blockList[0].options.width / 2, |
|
|
x: blockList[0].options.x + blockList[0].options.width / 2, |
|
|
y: blockList[0].options.y + blockList[0].options.height, |
|
|
y: blockList[0].options.y + blockList[0].options.height, |
|
|
vertices: [ |
|
|
vertices: [ |
|
|
{ |
|
|
{ |
|
|
x: blockList[0].options.x + blockList[0].options.width / 2, |
|
|
x: blockList[0].options.x + blockList[0].options.width / 2, |
|
|
y: blockList[2].options.y + blockList[2].options.height / 2 |
|
|
y: blockList[2].options.y + blockList[2].options.height / 2 |
|
|
} |
|
|
} |
|
|
] |
|
|
] |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
x: blockList[2].options.x + blockList[2].options.width / 2, |
|
|
x: blockList[2].options.x + blockList[2].options.width / 2, |
|
|
y: blockList[2].options.y + blockList[2].options.height / 2, |
|
|
y: blockList[2].options.y + blockList[2].options.height / 2, |
|
|
vertices: [ |
|
|
vertices: [ |
|
|
{ |
|
|
{ |
|
|
x: blockList[3].options.x + blockList[3].options.width / 2, |
|
|
x: blockList[3].options.x + blockList[3].options.width / 2, |
|
|
y: blockList[2].options.y + blockList[2].options.height / 2, |
|
|
y: blockList[2].options.y + blockList[2].options.height / 2, |
|
|
} |
|
|
} |
|
|
] |
|
|
] |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
x: blockList[0].options.x + blockList[0].options.width / 2, |
|
|
x: blockList[0].options.x + blockList[0].options.width / 2, |
|
|
y: blockList[4].options.y, |
|
|
y: blockList[4].options.y, |
|
|
vertices: [ |
|
|
vertices: [ |
|
|
{ |
|
|
{ |
|
|
x: blockList[0].options.x + blockList[0].options.width / 2, |
|
|
x: blockList[0].options.x + blockList[0].options.width / 2, |
|
|
y: blockList[5].options.y, |
|
|
y: blockList[5].options.y, |
|
|
} |
|
|
} |
|
|
] |
|
|
] |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
x: blockList[2].options.x + blockList[2].options.width / 2, |
|
|
x: blockList[2].options.x + blockList[2].options.width / 2, |
|
|
y: blockList[2].options.y + blockList[2].options.height, |
|
|
y: blockList[2].options.y + blockList[2].options.height, |
|
|
vertices: [ |
|
|
vertices: [ |
|
|
{ |
|
|
{ |
|
|
x: blockList[2].options.x + blockList[2].options.width / 2, |
|
|
x: blockList[2].options.x + blockList[2].options.width / 2, |
|
|
y: blockList[4].options.y + blockList[4].options.height / 2, |
|
|
y: blockList[4].options.y + blockList[4].options.height / 2, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
x: blockList[4].options.x, |
|
|
x: blockList[4].options.x, |
|
|
y: blockList[4].options.y + blockList[4].options.height / 2, |
|
|
y: blockList[4].options.y + blockList[4].options.height / 2, |
|
|
} |
|
|
} |
|
|
] |
|
|
] |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
x: blockList[3].options.x + blockList[3].options.width / 2, |
|
|
x: blockList[3].options.x + blockList[3].options.width / 2, |
|
|
y: blockList[3].options.y + blockList[3].options.height, |
|
|
y: blockList[3].options.y + blockList[3].options.height, |
|
|
vertices: [ |
|
|
vertices: [ |
|
|
{ |
|
|
{ |
|
|
x: blockList[3].options.x + blockList[3].options.width / 2, |
|
|
x: blockList[3].options.x + blockList[3].options.width / 2, |
|
|
y: blockList[4].options.y + blockList[4].options.height / 2, |
|
|
y: blockList[4].options.y + blockList[4].options.height / 2, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
x: blockList[4].options.x - blockList[3].options.width, |
|
|
x: blockList[4].options.x - blockList[3].options.width, |
|
|
y: blockList[4].options.y + blockList[4].options.height / 2, |
|
|
y: blockList[4].options.y + blockList[4].options.height / 2, |
|
|
} |
|
|
} |
|
|
] |
|
|
] |
|
|
}, |
|
|
}, |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
linePoints.forEach(item => this.drawLine(item)); |
|
|
linePoints.forEach(item => this.drawLine(item)); |
|
|
|
|
|
|
|
|
[...blockList, ...legends].forEach(item => { |
|
|
[...blockList, ...legends].forEach(item => { |
|
|
this[item.type]?.(item.options) |
|
|
this[item.type]?.(item.options) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<style lang='scss' scoped> |
|
|
<style lang='scss' scoped> |
|
|
.DisposalPlan { |
|
|
.DisposalPlan { |
|
|
::v-deep { |
|
|
::v-deep { |
|
|
.content { |
|
|
.content { |
|
|
display: flex; |
|
|
display: flex; |
|
|
flex-direction: column; |
|
|
flex-direction: column; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
canvas { |
|
|
canvas { |
|
|
flex: 1; |
|
|
flex: 1; |
|
|
width: 100%; |
|
|
width: 100%; |
|
|
height: 100%; |
|
|
height: 100%; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
</style> |
|
|
</style> |
|
|