Showing
1 changed file
with
28 additions
and
17 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-09-06 16:29:31 | 2 | * @Date: 2022-09-06 16:29:31 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2022-09-07 16:50:16 | 4 | + * @LastEditTime: 2023-02-09 13:01:54 |
| 5 | * @FilePath: /data-table/src/components/SignField/index.vue | 5 | * @FilePath: /data-table/src/components/SignField/index.vue |
| 6 | * @Description: 电子签名控件 | 6 | * @Description: 电子签名控件 |
| 7 | --> | 7 | --> |
| 8 | <template> | 8 | <template> |
| 9 | <div v-if="HideShow" class="sign-page"> | 9 | <div v-if="HideShow" class="sign-page"> |
| 10 | <div class="label"> | 10 | <div class="label"> |
| 11 | - {{ item.component_props.label }}{{ valid | 11 | + {{ item.component_props.label }}{{ |
| 12 | + valid | ||
| 12 | }}<span v-if="item.component_props.required"> *</span> | 13 | }}<span v-if="item.component_props.required"> *</span> |
| 13 | </div> | 14 | </div> |
| 14 | - <div style="padding: 1rem; position: relative"> | 15 | + <div ref="wrapperRef" class="esign-wrapper"> |
| 15 | <!-- <div style="padding: 1rem; position: relative; height: 150px; background-color: #FCFCFC;border: 1px solid #EAEAEA; border-radius: 5px;"> --> | 16 | <!-- <div style="padding: 1rem; position: relative; height: 150px; background-color: #FCFCFC;border: 1px solid #EAEAEA; border-radius: 5px;"> --> |
| 16 | - <vue-esign | 17 | + <vue-esign v-if="esignWidth" ref="esign" class="sign-wrapper" :width="esignWidth" :height="esignHeight" :isCrop="isCrop" |
| 17 | - ref="esign" | 18 | + :lineWidth="lineWidth" :lineColor="lineColor" :bgColor.sync="bgColor" /> |
| 18 | - class="sign-wrapper" | ||
| 19 | - style="" | ||
| 20 | - :isCrop="isCrop" | ||
| 21 | - :lineWidth="lineWidth" | ||
| 22 | - :lineColor="lineColor" | ||
| 23 | - :bgColor.sync="bgColor" | ||
| 24 | - /> | ||
| 25 | <div v-if="show_sign" class="whiteboard"> | 19 | <div v-if="show_sign" class="whiteboard"> |
| 26 | <div class="text" @click="startSign"> | 20 | <div class="text" @click="startSign"> |
| 27 | <van-icon name="edit" /> 点击开始签署电子签名 | 21 | <van-icon name="edit" /> 点击开始签署电子签名 |
| ... | @@ -43,11 +37,7 @@ | ... | @@ -43,11 +37,7 @@ |
| 43 | <van-button type="danger" block @click="handleReset">删除签名</van-button> | 37 | <van-button type="danger" block @click="handleReset">删除签名</van-button> |
| 44 | </div> | 38 | </div> |
| 45 | </div> | 39 | </div> |
| 46 | - <div | 40 | + <div v-if="show_empty" class="van-field__error-message" style="padding: 0 1rem 1rem 1rem"> |
| 47 | - v-if="show_empty" | ||
| 48 | - class="van-field__error-message" | ||
| 49 | - style="padding: 0 1rem 1rem 1rem" | ||
| 50 | - > | ||
| 51 | 电子签名不能为空 | 41 | 电子签名不能为空 |
| 52 | </div> | 42 | </div> |
| 53 | <van-divider /> | 43 | <van-divider /> |
| ... | @@ -80,6 +70,16 @@ const emit = defineEmits(["active"]); | ... | @@ -80,6 +70,16 @@ const emit = defineEmits(["active"]); |
| 80 | 70 | ||
| 81 | const esign = ref(null); | 71 | const esign = ref(null); |
| 82 | 72 | ||
| 73 | +let esignWidth = ref(); | ||
| 74 | +let esignHeight = ref(); | ||
| 75 | +const wrapperRef = ref(null) | ||
| 76 | +onMounted(() => { | ||
| 77 | + // 动态计算画板canvas宽度/高度 | ||
| 78 | + setTimeout(() => { | ||
| 79 | + esignWidth.value = wrapperRef.value.offsetWidth - 32; | ||
| 80 | + esignHeight.value = (document.body.offsetHeight) / 5; | ||
| 81 | + }, 100); | ||
| 82 | +}) | ||
| 83 | const lineWidth = ref(6); | 83 | const lineWidth = ref(6); |
| 84 | const lineColor = ref("#000000"); | 84 | const lineColor = ref("#000000"); |
| 85 | const bgColor = ref("#FCFCFC"); | 85 | const bgColor = ref("#FCFCFC"); |
| ... | @@ -240,6 +240,7 @@ export default { | ... | @@ -240,6 +240,7 @@ export default { |
| 240 | 240 | ||
| 241 | <style lang="less" scoped> | 241 | <style lang="less" scoped> |
| 242 | .sign-page { | 242 | .sign-page { |
| 243 | + | ||
| 243 | // padding-bottom: 1rem; | 244 | // padding-bottom: 1rem; |
| 244 | .label { | 245 | .label { |
| 245 | padding: 1rem 1rem 0 1rem; | 246 | padding: 1rem 1rem 0 1rem; |
| ... | @@ -250,10 +251,17 @@ export default { | ... | @@ -250,10 +251,17 @@ export default { |
| 250 | color: red; | 251 | color: red; |
| 251 | } | 252 | } |
| 252 | } | 253 | } |
| 254 | + | ||
| 255 | + .esign-wrapper { | ||
| 256 | + padding: 1rem; | ||
| 257 | + position: relative; | ||
| 258 | + box-sizing: border-box; | ||
| 259 | + | ||
| 253 | .sign-wrapper { | 260 | .sign-wrapper { |
| 254 | border: 1px solid #eaeaea; | 261 | border: 1px solid #eaeaea; |
| 255 | border-radius: 5px; | 262 | border-radius: 5px; |
| 256 | } | 263 | } |
| 264 | + | ||
| 257 | .whiteboard { | 265 | .whiteboard { |
| 258 | position: absolute; | 266 | position: absolute; |
| 259 | height: 100%; | 267 | height: 100%; |
| ... | @@ -262,6 +270,7 @@ export default { | ... | @@ -262,6 +270,7 @@ export default { |
| 262 | top: 50%; | 270 | top: 50%; |
| 263 | transform: translate(-50%, -50%); | 271 | transform: translate(-50%, -50%); |
| 264 | text-align: center; | 272 | text-align: center; |
| 273 | + | ||
| 265 | .text { | 274 | .text { |
| 266 | position: absolute; | 275 | position: absolute; |
| 267 | width: 100%; | 276 | width: 100%; |
| ... | @@ -271,6 +280,8 @@ export default { | ... | @@ -271,6 +280,8 @@ export default { |
| 271 | } | 280 | } |
| 272 | } | 281 | } |
| 273 | 282 | ||
| 283 | + } | ||
| 284 | + | ||
| 274 | .control-sign { | 285 | .control-sign { |
| 275 | padding-bottom: 1rem; | 286 | padding-bottom: 1rem; |
| 276 | } | 287 | } | ... | ... |
-
Please register or login to post a comment