Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
R
road-demo
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
王健
road-demo
Commits
f3556fbe
提交
f3556fbe
authored
1月 04, 2022
作者:
许言琪
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 添加车道划分,添加面积计算
上级
f3835a7d
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
178 行增加
和
6 行删除
+178
-6
drawing.vue
src/components/drawing.vue
+61
-6
numberUtils.js
src/utils/numberUtils.js
+117
-0
没有找到文件。
src/components/drawing.vue
浏览文件 @
f3556fbe
...
@@ -133,6 +133,17 @@
...
@@ -133,6 +133,17 @@
</el-option>
</el-option>
</el-select>
</el-select>
</el-form-item>
</el-form-item>
<el-form-item
label=
"所属车道"
prop=
"laneNum"
>
<el-select
v-model=
"diseaseForm.laneNum"
placeholder=
"请选择"
>
<el-option
v-for=
"item in laneNumOptions"
:key=
"item.value"
:label=
"item.label"
:value=
"item.value"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item
label=
"病害类型"
prop=
"diseaseType"
>
<el-form-item
label=
"病害类型"
prop=
"diseaseType"
>
<el-select
v-model=
"diseaseForm.diseaseType"
placeholder=
"请选择"
>
<el-select
v-model=
"diseaseForm.diseaseType"
placeholder=
"请选择"
>
<el-option
<el-option
...
@@ -186,6 +197,7 @@
...
@@ -186,6 +197,7 @@
<
script
>
<
script
>
import
paper
from
"paper"
;
import
paper
from
"paper"
;
import
{
Point
}
from
"paper/dist/paper-core"
;
import
{
Point
}
from
"paper/dist/paper-core"
;
import
{
Arabia_To_SimplifiedChinese
}
from
"@/utils/numberUtils"
;
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{
...
@@ -217,6 +229,8 @@ export default {
...
@@ -217,6 +229,8 @@ export default {
direction
:
"上行"
,
direction
:
"上行"
,
startStake
:
"615.700"
,
startStake
:
"615.700"
,
endStake
:
"615.800"
,
endStake
:
"615.800"
,
laneCount
:
4
,
laneNum
:
1
,
roadLength
:
1000
,
roadLength
:
1000
,
roadWidth
:
7
,
roadWidth
:
7
,
roadType
:
1
,
roadType
:
1
,
...
@@ -398,6 +412,17 @@ export default {
...
@@ -398,6 +412,17 @@ export default {
roadHalfWidth
()
{
roadHalfWidth
()
{
return
this
.
boxHeight
/
2
+
this
.
rulerHeight
;
return
this
.
boxHeight
/
2
+
this
.
rulerHeight
;
},
},
// 车道option
laneNumOptions
()
{
let
laneNumOptions
=
[];
for
(
let
i
=
1
;
i
<=
this
.
diseaseForm
.
laneCount
;
i
++
)
{
laneNumOptions
.
push
({
label
:
`
${
Arabia_To_SimplifiedChinese
(
i
)}
车道`
,
value
:
i
,
});
}
return
laneNumOptions
;
},
// 病害校验
// 病害校验
diseaseRules
()
{
diseaseRules
()
{
return
{
return
{
...
@@ -458,7 +483,6 @@ export default {
...
@@ -458,7 +483,6 @@ export default {
}
else
{
}
else
{
const
actualWidth
=
const
actualWidth
=
this
.
diseaseForm
.
roadWidth
/
2
-
this
.
diseaseForm
.
distance
;
this
.
diseaseForm
.
roadWidth
/
2
-
this
.
diseaseForm
.
distance
;
console
.
log
(
actualWidth
);
if
(
actualWidth
>=
value
)
{
if
(
actualWidth
>=
value
)
{
callback
();
callback
();
}
else
{
}
else
{
...
@@ -482,6 +506,8 @@ export default {
...
@@ -482,6 +506,8 @@ export default {
initCanvas
()
{
initCanvas
()
{
this
.
createCanvas
();
this
.
createCanvas
();
paper
.
setup
(
this
.
canvas
);
paper
.
setup
(
this
.
canvas
);
// 绘制车道
this
.
drawLane
();
// 绘制边框
// 绘制边框
this
.
drawCanvasBorder
();
this
.
drawCanvasBorder
();
// 绘制中间线
// 绘制中间线
...
@@ -501,6 +527,7 @@ export default {
...
@@ -501,6 +527,7 @@ export default {
drawCanvasBorder
()
{
drawCanvasBorder
()
{
let
path
=
new
paper
.
Path
();
let
path
=
new
paper
.
Path
();
path
.
strokeColor
=
"black"
;
path
.
strokeColor
=
"black"
;
path
.
strokeWidth
=
2
;
path
.
add
(
new
Point
(
0
,
0
));
path
.
add
(
new
Point
(
0
,
0
));
path
.
add
(
new
Point
(
this
.
boxWidth
,
0
));
path
.
add
(
new
Point
(
this
.
boxWidth
,
0
));
path
.
add
(
new
Point
(
this
.
boxWidth
,
this
.
boxHeight
+
this
.
rulerHeight
));
path
.
add
(
new
Point
(
this
.
boxWidth
,
this
.
boxHeight
+
this
.
rulerHeight
));
...
@@ -553,7 +580,7 @@ export default {
...
@@ -553,7 +580,7 @@ export default {
],
],
});
});
centerLine
.
strokeColor
=
"#ff0000"
;
centerLine
.
strokeColor
=
"#ff0000"
;
centerLine
.
strokeWidth
=
1
;
centerLine
.
strokeWidth
=
2
;
centerLine
.
strokeCap
=
"round"
;
centerLine
.
strokeCap
=
"round"
;
centerLine
.
dashArray
=
[
10
,
12
];
centerLine
.
dashArray
=
[
10
,
12
];
},
},
...
@@ -601,7 +628,6 @@ export default {
...
@@ -601,7 +628,6 @@ export default {
* 绘制病害
* 绘制病害
*/
*/
drawDisease
(
form
)
{
drawDisease
(
form
)
{
console
.
log
(
form
);
if
(
!
form
)
{
if
(
!
form
)
{
return
false
;
return
false
;
}
}
...
@@ -621,9 +647,6 @@ export default {
...
@@ -621,9 +647,6 @@ export default {
const
width
=
diseaseLength
*
10
;
const
width
=
diseaseLength
*
10
;
const
height
=
diseaseWidth
*
this
.
scale
;
const
height
=
diseaseWidth
*
this
.
scale
;
if
(
form
.
direction
==
"上行"
)
{
if
(
form
.
direction
==
"上行"
)
{
console
.
log
(
this
.
roadHalfWidth
-
distance
*
100
);
console
.
log
(
this
.
roadHalfWidth
);
console
.
log
(
distance
);
if
(
this
.
scale
===
10
)
{
if
(
this
.
scale
===
10
)
{
y
=
this
.
roadHalfWidth
-
distance
*
100
-
height
;
y
=
this
.
roadHalfWidth
-
distance
*
100
-
height
;
}
else
{
}
else
{
...
@@ -656,6 +679,15 @@ export default {
...
@@ -656,6 +679,15 @@ export default {
fontFamily
:
"Courier New"
,
fontFamily
:
"Courier New"
,
fontSize
:
14
,
fontSize
:
14
,
});
});
// 等边病害面积
new
paper
.
PointText
({
point
:
rectangle
.
leftCenter
,
content
:
`
${
diseaseWidth
*
diseaseLength
}
㎡`
,
fillColor
:
"black"
,
fontFamily
:
"Courier New"
,
fontSize
:
14
,
});
// 病害距离中间距离
// 病害距离中间距离
if
(
form
.
direction
==
"上行"
)
{
if
(
form
.
direction
==
"上行"
)
{
new
paper
.
PointText
({
new
paper
.
PointText
({
...
@@ -753,6 +785,29 @@ export default {
...
@@ -753,6 +785,29 @@ export default {
let
stakeString
=
"K"
+
stake
;
let
stakeString
=
"K"
+
stake
;
return
stakeString
.
replace
(
"."
,
"+"
);
return
stakeString
.
replace
(
"."
,
"+"
);
},
},
/** 绘制车道 */
drawLane
()
{
for
(
let
i
=
1
;
i
<=
this
.
diseaseForm
.
laneCount
;
i
++
)
{
var
centerLine
=
new
paper
.
Path
({
segments
:
[
[
0
,
(
this
.
boxHeight
/
this
.
diseaseForm
.
laneCount
)
*
i
+
this
.
rulerHeight
,
],
[
this
.
boxWidth
,
(
this
.
boxHeight
/
this
.
diseaseForm
.
laneCount
)
*
i
+
this
.
rulerHeight
,
],
],
});
centerLine
.
strokeColor
=
"#7f8c8d"
;
centerLine
.
strokeWidth
=
1
;
centerLine
.
strokeCap
=
"round"
;
centerLine
.
dashArray
=
[
10
,
12
];
}
},
},
},
};
};
</
script
>
</
script
>
...
...
src/utils/numberUtils.js
0 → 100644
浏览文件 @
f3556fbe
/*
* @Descripttion:
* @Author: xuyanqi
* @Date: 2022-01-04 10:11:22
*/
//阿拉伯数字转换为简写汉字
export
function
Arabia_To_SimplifiedChinese
(
Num
)
{
for
(
let
i
=
Num
.
length
-
1
;
i
>=
0
;
i
--
)
{
Num
=
Num
.
replace
(
","
,
""
);
//替换Num中的“,”
Num
=
Num
.
replace
(
" "
,
""
);
//替换Num中的空格
}
if
(
isNaN
(
Num
))
{
//验证输入的字符是否为数字
//alert("请检查小写金额是否正确");
return
;
}
//字符处理完毕后开始转换,采用前后两部分分别转换
let
part
=
String
(
Num
).
split
(
"."
);
let
newchar
=
""
;
//小数点前进行转化
for
(
let
i
=
part
[
0
].
length
-
1
;
i
>=
0
;
i
--
)
{
if
(
part
[
0
].
length
>
10
)
{
//alert("位数过大,无法计算");
return
""
;
}
//若数量超过拾亿单位,提示
let
tmpnewchar
=
""
;
let
perchar
=
part
[
0
].
charAt
(
i
);
switch
(
perchar
)
{
case
"0"
:
tmpnewchar
=
"零"
+
tmpnewchar
;
break
;
case
"1"
:
tmpnewchar
=
"一"
+
tmpnewchar
;
break
;
case
"2"
:
tmpnewchar
=
"二"
+
tmpnewchar
;
break
;
case
"3"
:
tmpnewchar
=
"三"
+
tmpnewchar
;
break
;
case
"4"
:
tmpnewchar
=
"四"
+
tmpnewchar
;
break
;
case
"5"
:
tmpnewchar
=
"五"
+
tmpnewchar
;
break
;
case
"6"
:
tmpnewchar
=
"六"
+
tmpnewchar
;
break
;
case
"7"
:
tmpnewchar
=
"七"
+
tmpnewchar
;
break
;
case
"8"
:
tmpnewchar
=
"八"
+
tmpnewchar
;
break
;
case
"9"
:
tmpnewchar
=
"九"
+
tmpnewchar
;
break
;
}
switch
(
part
[
0
].
length
-
i
-
1
)
{
case
0
:
// eslint-disable-next-line no-self-assign
tmpnewchar
=
tmpnewchar
;
break
;
case
1
:
if
(
perchar
!=
0
)
tmpnewchar
=
tmpnewchar
+
"十"
;
break
;
case
2
:
if
(
perchar
!=
0
)
tmpnewchar
=
tmpnewchar
+
"百"
;
break
;
case
3
:
if
(
perchar
!=
0
)
tmpnewchar
=
tmpnewchar
+
"千"
;
break
;
case
4
:
tmpnewchar
=
tmpnewchar
+
"万"
;
break
;
case
5
:
if
(
perchar
!=
0
)
tmpnewchar
=
tmpnewchar
+
"十"
;
break
;
case
6
:
if
(
perchar
!=
0
)
tmpnewchar
=
tmpnewchar
+
"百"
;
break
;
case
7
:
if
(
perchar
!=
0
)
tmpnewchar
=
tmpnewchar
+
"千"
;
break
;
case
8
:
tmpnewchar
=
tmpnewchar
+
"亿"
;
break
;
case
9
:
tmpnewchar
=
tmpnewchar
+
"十"
;
break
;
}
newchar
=
tmpnewchar
+
newchar
;
}
//替换所有无用汉字,直到没有此类无用的数字为止
while
(
newchar
.
search
(
"零零"
)
!=
-
1
||
newchar
.
search
(
"零亿"
)
!=
-
1
||
newchar
.
search
(
"亿万"
)
!=
-
1
||
newchar
.
search
(
"零万"
)
!=
-
1
)
{
newchar
=
newchar
.
replace
(
"零亿"
,
"亿"
);
newchar
=
newchar
.
replace
(
"亿万"
,
"亿"
);
newchar
=
newchar
.
replace
(
"零万"
,
"万"
);
newchar
=
newchar
.
replace
(
"零零"
,
"零"
);
}
//替换以“一十”开头的,为“十”
if
(
newchar
.
indexOf
(
"一十"
)
==
0
)
{
newchar
=
newchar
.
substr
(
1
);
}
//替换以“零”结尾的,为“”
if
(
newchar
.
lastIndexOf
(
"零"
)
==
newchar
.
length
-
1
)
{
newchar
=
newchar
.
substr
(
0
,
newchar
.
length
-
1
);
}
return
newchar
;
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论