autograph.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <view>
  3. <slot name="top"></slot>
  4. <VueSignaturePad width="100%" height="600rpx" ref="signaturePad" :options="options" disable-scroll="true"
  5. class="my-canvas-cls" />
  6. <slot name="footer"></slot>
  7. <view class="footer" v-if="footerShow">
  8. <u-button type="success" @click.stop="finish" size="mini">保存</u-button>
  9. <u-button type="warning" @click.stop="clear" size="mini">清除</u-button>
  10. <u-button type="error" @click.stop="close" size="mini">关闭</u-button>
  11. <!-- <view class="left" @click.stop="finish">保存</view> -->
  12. <!-- <view class="right" @click="clear">清除</view> -->
  13. <!-- <view class="close" @click="close">关闭</view> -->
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. data() {
  20. return {
  21. //绘图图像
  22. ctx: '',
  23. //路径点集合
  24. points: [],
  25. //签名图片
  26. SignatureImg: '',
  27. options: {
  28. penColor: "#000",
  29. minWidth: 1, //控制画笔最小宽度
  30. maxWidth: 1, //控制画笔最大宽度
  31. },
  32. };
  33. },
  34. props: {
  35. footerShow: {
  36. type: Boolean,
  37. default: true
  38. }
  39. },
  40. watch: {},
  41. methods: {
  42. clear() {
  43. this.$refs.signaturePad.clearSignature();
  44. this.$emit("clear", '')
  45. },
  46. finish() {
  47. const {
  48. data
  49. } = this.$refs.signaturePad.saveSignature()
  50. this.$emit("save", data)
  51. },
  52. close() {
  53. this.$emit("close")
  54. }
  55. }
  56. };
  57. </script>
  58. <style lang="less" scoped>
  59. .bigbox {
  60. touch-action: none
  61. }
  62. .my-canvas-cls {
  63. height: 500rpx;
  64. width: 100%;
  65. display: block;
  66. position: relative;
  67. background: #F6F6F6;
  68. z-index: 9999;
  69. border-radius: 8rpx;
  70. }
  71. .footer {
  72. font-size: 14px;
  73. height: 150upx;
  74. display: flex;
  75. justify-content: space-around;
  76. align-items: center;
  77. padding-left: 40rpx;
  78. .left {
  79. background-color: #ecf5ff;
  80. color: #a0cfff;
  81. border-radius: 8rpx;
  82. padding: 10rpx 15rpx;
  83. border: 1px solid #a0cfff;
  84. }
  85. .right {
  86. background-color: #fdf6ec;
  87. color: #fcbd71;
  88. border-radius: 8rpx;
  89. padding: 10rpx 15rpx;
  90. border: 1px solid #fcbd71;
  91. }
  92. .close {
  93. background-color: #fef0f0;
  94. color: #fab6b6;
  95. border-radius: 8rpx;
  96. padding: 10rpx 15rpx;
  97. border: 1px solid #fab6b6;
  98. }
  99. }
  100. .but-class {
  101. margin-right: 40rpx;
  102. }
  103. </style>