wk-field-write-sign.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <view class="wk-field wk-field-write-sign" @click.stop>
  3. <view v-if="_label" class="wk-field__label">
  4. <view v-if="field.isNull === 1" class="line" />
  5. {{ _label }}
  6. </view>
  7. <view class="wk-field__body" @click="handleToSignature">
  8. <view v-if="!formValue" class="signature-area">
  9. <text class="wk wk-edit-pen" />
  10. <text>添加手写签名</text>
  11. </view>
  12. <view v-else class="signature-img">
  13. <wk-signature-view
  14. :batch-id="formValue"
  15. :preview="false" />
  16. </view>
  17. </view>
  18. <wk-popup-sign ref="signature" v-model="formValue" />
  19. </view>
  20. </template>
  21. <script>
  22. import mixins from './mixins'
  23. export default {
  24. name: 'WkFieldWriteSign',
  25. mixins: [mixins],
  26. data() {
  27. return {
  28. guid: null
  29. }
  30. },
  31. created() {
  32. this.guid = this.$guid()
  33. },
  34. methods: {
  35. handleToSignature() {
  36. this.$refs.signature
  37. .sign()
  38. .then(batchId => {
  39. this.signatureFn(batchId)
  40. })
  41. .catch(() => {});
  42. },
  43. signatureFn(batchId) {
  44. this.formValue = null
  45. setTimeout(() => {
  46. this.formValue = batchId || ''
  47. this.$emit('input', batchId)
  48. this.$emit('change', {
  49. index: this.index,
  50. field: this.field,
  51. value: this.formValue
  52. })
  53. }, 100)
  54. }
  55. }
  56. }
  57. </script>
  58. <style scoped lang="scss">
  59. @import './wkField.scss';
  60. .wk-field {
  61. .wk-field__body {
  62. border: 1rpx dashed #C0C0C0;
  63. padding: 0;
  64. overflow: hidden;
  65. @include center;
  66. .signature-area {
  67. font-size: $wk-font-mini;
  68. color: $theme-color;
  69. padding: 50rpx 0;
  70. .wk-edit-pen {
  71. margin-right: 10rpx;
  72. }
  73. }
  74. .signature-img {
  75. width: 100%;
  76. height: 100%;
  77. }
  78. }
  79. }
  80. </style>