Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
PrintVue
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
刘旭
PrintVue
Commits
2919c85f
提交
2919c85f
authored
6月 15, 2023
作者:
刘旭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改配置
上级
0cd56cf6
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
46 行增加
和
34 行删除
+46
-34
package.json
package.json
+1
-1
index.ts
src/index.ts
+1
-1
preview.vue
src/printTemplate/components/preview.vue
+0
-2
printDrawer.vue
src/printTemplate/components/printDrawer.vue
+42
-29
index.vue
src/printTemplate/index.vue
+2
-1
没有找到文件。
package.json
浏览文件 @
2919c85f
...
...
@@ -12,7 +12,7 @@
}
},
"publishConfig"
:
{
"registry"
:
"http://192.168.1.
42
:8081/repository/vue/"
,
"registry"
:
"http://192.168.1.
87
:8081/repository/vue/"
,
"access"
:
"public"
},
"scripts"
:
{
...
...
src/index.ts
浏览文件 @
2919c85f
import
type
{
App
}
from
'vue'
import
'element-plus/dist/index.css'
import
PrintTemplate
from
'./printTemplate/
index
.vue'
import
PrintTemplate
from
'./printTemplate/
components/printDrawer
.vue'
const
components
=
[
PrintTemplate
...
...
src/printTemplate/components/preview.vue
浏览文件 @
2919c85f
...
...
@@ -73,5 +73,4 @@ defineExpose({
:deep
(
.el-dialog__wrapper
)
{
margin-bottom
:
24px
;
}
</
style
>
\ No newline at end of file
src/printTemplate/components/printDrawer.vue
浏览文件 @
2919c85f
<
template
>
<el-drawer
v-model=
"props.modelValue"
title=
"新增打印"
size=
"80%"
@
close=
"handel
Close"
>
<el-drawer
v-model=
"props.modelValue"
:title=
"paperTitle"
size=
"80%"
@
close=
"handle
Close"
>
<div
class=
"app-containter flex-col"
>
<div
class=
"header flex-row justify-center"
style=
"margin-bottom: 10px"
>
<!-- 纸张大小 A3、A4 等 -->
...
...
@@ -30,7 +30,7 @@
<el-input
type=
"number"
v-model=
"paperHeight"
style=
"width: 100px; text-align: center; border-left: 0"
placeholder=
"高(mm)"
/>
</el-input-group>
<el-button
type=
"primary"
style=
"width: 100%"
@
click=
"
handleClos
e"
>
确定
</el-button>
<el-button
type=
"primary"
style=
"width: 100%"
@
click=
"
setPaperRul
e"
>
确定
</el-button>
</div>
</el-popover>
</el-button-group>
...
...
@@ -62,8 +62,15 @@
</el-button> -->
</el-button-group>
<el-button-group
class=
"ml-10"
>
<el-button
type=
"success"
icon=
"Finished"
@
click
.
stop=
"clear
Paper"
>
<el-button
type=
"success"
ref=
"buttonSaveRef"
icon=
"Finished"
@
click
.
stop=
"save
Paper"
>
保存
<el-popover
ref=
"popoverSaveRef"
:virtual-ref=
"buttonSaveRef"
trigger=
"click"
title=
"设置模板名称"
:width=
"300"
virtual-triggering
>
<div
class=
"input-group"
>
<el-input
v-model=
"paperTitle"
style=
" text-align: center"
/>
<el-button
type=
"primary"
style=
"width: 100%"
@
click=
"setPaperTitle"
>
确定
</el-button>
</div>
</el-popover>
</el-button>
<el-button
type=
"danger"
@
click
.
stop=
"clearPaper"
>
清空
<el-icon
class=
"el-icon--right"
>
...
...
@@ -98,11 +105,10 @@
</template>
<
script
setup
lang=
"ts"
>
import
{
onMounted
,
ref
,
getCurrentInstance
,
unref
}
from
"vue"
;
import
{
ref
,
unref
}
from
"vue"
;
import
{
hiprint
}
from
"vue-plugin-hiprint"
;
import
{
provider1
}
from
"../ts/provider1"
;
import
{
provider2
}
from
"../ts/provider2"
;
import
template
from
"../ts/template"
;
// 组合式函数 hooks
import
{
usePaper
}
from
"../../hooks/use-paper"
;
import
{
useZoom
}
from
"../../hooks/use-zoom"
;
...
...
@@ -116,18 +122,29 @@ const props = defineProps({
modelValue
:
{
type
:
Boolean
,
defalut
:
false
},
templateData
:
{
type
:
Object
,
default
:
{}
},
templateTitle
:
{
type
:
String
,
default
:
''
}
})
const
emits
=
defineEmits
([
'update:modelValue'
])
const
emits
=
defineEmits
([
'update:modelValue'
,
'savePrintData'
,
'update:templateTitle'
])
// const TEMPLATE_KEY = getCurrentInstance().type.name; // 存储模板对象的 key
// console.log(TEMPLATE_KEY);
const
TEMPLATE_KEY
=
undefined
const
{
paperTypes
,
curPaperType
,
paperWidth
,
paperHeight
,
setPaper
,
setPaperOther
}
=
usePaper
(
TEMPLATE_KEY
);
const
{
scaleValue
,
changeScale
}
=
useZoom
(
TEMPLATE_KEY
);
const
buttonRef
=
ref
(
)
const
paperTitle
=
ref
(
'默认模板'
)
const
popoverRef
=
ref
()
const
popoverSaveRef
=
ref
()
const
buttonRef
=
ref
()
const
buttonSaveRef
=
ref
()
const
previewRef
=
ref
()
const
jsonviewRef
=
ref
()
...
...
@@ -175,7 +192,7 @@ const onClickOutside = () => {
unref
(
popoverRef
).
popperRef
?.
delayHide
?.()
}
const
handleClos
e
=
()
=>
{
const
setPaperRul
e
=
()
=>
{
setPaperOther
()
popoverRef
.
value
.
hide
();
}
...
...
@@ -213,7 +230,7 @@ const print = () => {
},
};
const
list
=
hiprintTemplate
.
getJson
().
panels
console
.
log
(
list
);
console
.
log
(
list
,
'list'
);
let
printData
=
{}
as
any
if
(
list
)
list
[
0
].
printElements
.
map
((
item
:
any
)
=>
printData
[
item
.
options
.
field
]
=
item
.
options
.
testData
)
...
...
@@ -241,32 +258,22 @@ const print2 = () => {
const
rotatePaper
=
()
=>
{
hiprintTemplate
.
rotatePaper
();
};
/**
* 清空所有元素
*/
const
clearPaper
=
()
=>
{
hiprintTemplate
.
clear
();
};
const
clearPaper
=
()
=>
hiprintTemplate
.
clear
();
/**
* 导出模板 json
* 必须确保 hiprintTemplate 已成功创建
* 清空所有元素
*/
const
exportJson
=
()
=>
{
jsonviewRef
.
value
.
show
(
hiprintTemplate
)
// let json = hiprintTemplate.getJson();
// console.log(json);
// alert("导出成功! 请查看控制台输出");
};
const
savePaper
=
()
=>
unref
(
popoverSaveRef
).
popperRef
?.
delayHide
?.()
/**
* 导出模板 json tid
* 仅导出 options, 不导出 printElementType
* 导出模板 json
* 必须确保 hiprintTemplate 已成功创建
*/
const
exportJsonTid
=
()
=>
{
let
json
=
hiprintTemplate
.
getJsonTid
();
console
.
log
(
json
);
alert
(
"导出成功! 请查看控制台输出"
);
};
const
exportJson
=
()
=>
jsonviewRef
.
value
.
show
(
hiprintTemplate
)
// 预览
const
show
=
()
=>
{
...
...
@@ -278,16 +285,21 @@ const show = () => {
previewRef
.
value
.
show
(
hiprintTemplate
,
printData
)
}
const
hand
el
Close
=
()
=>
{
const
hand
le
Close
=
()
=>
{
emits
(
'update:modelValue'
,
false
)
}
const
setPaperTitle
=
()
=>
{
emits
(
'savePrintData'
,
hiprintTemplate
.
getJson
())
popoverSaveRef
.
value
.
hide
();
}
/**
* 这里必须要在 onMounted 中去构建 左侧可拖拽元素 或者 设计器
* 因为都是把元素挂载到对应容器中, 必须要先找到该容器
*/
const
mounted
=
()
=>
{
templateRef
.
value
=
template
templateRef
.
value
=
props
.
templateData
setTimeout
(()
=>
{
buildLeftElement
();
buildDesigner
();
...
...
@@ -297,6 +309,7 @@ const mounted = () => {
defineExpose
({
templateRef
,
paperTitle
,
mounted
})
</
script
>
...
...
src/printTemplate/index.vue
浏览文件 @
2919c85f
...
...
@@ -17,13 +17,14 @@
</
template
>
</el-table-column>
</el-table>
<indexVue
v-model=
"showDrawer"
ref=
"printRef"
/>
<indexVue
v-model=
"showDrawer"
ref=
"printRef"
:templateData=
"template"
/>
</div>
</template>
<
script
lang=
"ts"
setup
>
import
{
ref
}
from
'vue'
import
indexVue
from
'./components/printDrawer.vue'
;
import
template
from
'./ts/template'
;
const
showDrawer
=
ref
(
false
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论