WebApp【公共组件库】@前端(For Git Submodule)
‘chensiAb’
2025-03-25 3b03f87a02458f719e2eb4bf112a13441b427d14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
 * CUserSignatureBtn - 用户签名(按钮模式)
 * @author Tevin
 */
 
<template>
    <view class="c-user-signature-btn">
        <AtButton
            :class="btnClass"
            :type="btnType"
            :onClick="evt => handleOpenSign()"
        >签名</AtButton>
        <CForm
            ref="signForm"
            :formData="signData"
            :onChange="evt => handleSignChange(evt)"
            v-slot="{formRes}"
        >
            <CFormItem
                name="sign"
                :formRes="formRes"
                v-slot="{itemRes}"
            >
                <CUserSignature
                    ref="signature"
                    :itemRes="itemRes"
                />
            </CFormItem>
        </CForm>
    </view>
</template>
 
<script>
import { AtButton } from 'taro-ui-vue';
import { CForm, CFormItem } from '@components/forms/form';
import CUserSignature from './CUserSignature.vue';
 
export default {
    name: 'CUserSignatureBtn',
    components: {
        AtButton,
        CForm,
        CFormItem,
        CUserSignature,
    },
    props: {
        // 按钮样式
        btnClass: String,
        // 按钮类型
        btnType: {
            type: String,
            default: 'primary',
        },
        // 签名回调
        onSignChanged: Function,
    },
    data() {
        return {
            signData: {
                sign: '',
            },
        };
    },
    methods: {
        handleOpenSign() {
            this.$refs.signature.$startEdit();
        },
        handleSignChange({ sign }) {
            this.onSignChanged(sign);
        },
        $uploadImage(callback) {
            this.$refs.signature(callback);
        },
    },
    mounted() {},
};
</script>