autograph.vue 2.2 KB

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