123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <template>
- <div>
- <!-- 做使用el-dialog做签字的弹框 -->
- <el-dialog title="签字" :visible.sync="show" width="800px" destroy-on-close >
- <!-- 使用这个签名组件 -->
- <vue-esign
- ref="esign"
- class="mySign"
- :width="800"
- :height="300"
- :isCrop="isCrop"
- :lineWidth="lineWidth"
- :lineColor="lineColor"
- :bgColor.sync="bgColor"
- />
- <span slot="footer" class="dialog-footer fx-row jc-end">
- <!-- <el-popover-->
- <!-- placement="top-start"-->
- <!-- title="协议"-->
- <!-- width="200"-->
- <!-- trigger="click"-->
- <!-- content="协议内容">-->
- <!-- <el-button slot="reference">协议</el-button>-->
- <!-- </el-popover>-->
- <div>
- <el-button @click="handleGenerate" type="primary">保存</el-button>
- <el-button @click="handleReset">清空画板</el-button>
- <el-button @click="show = false">取消</el-button>
- </div>
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import { saveEsign } from '@/api/webApi/elective/selected-subject'
- export default {
- // props: ['generation'],
- data() {
- return {
- show: false, // 弹框是否开启
- lineWidth: 3, // 画笔的线条粗细
- lineColor: '#000000', // 画笔的颜色
- bgColor: '', // 画布的背景颜色
- base64Img: '', // 最终画布生成的base64图片
- isCrop: false // 是否裁剪,在画布设定尺寸基础上裁掉四周空白部分
- }
- },
- inject: {
- 'refreshData': {
- default: function() {
- // do nothing
- }
- }
- },
- methods: {
- // 清空画板
- handleReset() {
- this.$refs.esign.reset()
- },
- saveElective() {
- saveEsign({
- id: this.flowId,
- esignPath:this.base64Img
- }).then(res => {
- if (res.code == 200) {
- this.show = false
- this.success()
- }
- })
- },
- // 生成签字图
- handleGenerate() {
- this.$refs.esign
- .generate() // 使用生成器调用把签字的图片转换成为base64图片格式
- .then((res) => {
- this.base64Img = res
- this.saveElective()
- // 在这里向后端发请求把转换后的base64文件传给后端,后端接收以后再转换成图片做静态图片存储
- // 当然也可以把base64转成流文件blob格式的,类似上传给后端这样,具体哪种方式看后端要求
- })
- .catch((err) => {
- console.log(err)
- // 画布没有签字时会执行这里提示一下
- this.$message({
- type: 'warning',
- message: '请先签名'
- })
- return
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- #app {
- width: 100%;
- height: 100%;
- padding: 60px;
- .checkMan {
- width: 400px;
- height: 360px;
- text-align: center;
- border: 1px solid #e9e9e9;
- padding-top: 40px;
- h2 {
- margin-bottom: 20px;
- }
- .el-button {
- margin-bottom: 20px;
- }
- img {
- width: 100%;
- height: 200px;
- }
- }
- }
- ::v-deep .el-dialog__body {
- // 设置一下签字区域的虚线边框
- .mySign {
- border: 1px dashed #000;
- }
- }
- </style>
|