From 627c3e0a6920131d75eafa4646db373ccc936546 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期四, 26 十月 2023 13:52:07 +0800
Subject: [PATCH] 小程序diamante
---
minipro_standard/uni_modules/uview-ui/components/u--form/u--form.vue | 78 +++++++++++++++++++++++++++++++++++++++
1 files changed, 78 insertions(+), 0 deletions(-)
diff --git a/minipro_standard/uni_modules/uview-ui/components/u--form/u--form.vue b/minipro_standard/uni_modules/uview-ui/components/u--form/u--form.vue
new file mode 100644
index 0000000..fdfc212
--- /dev/null
+++ b/minipro_standard/uni_modules/uview-ui/components/u--form/u--form.vue
@@ -0,0 +1,78 @@
+<template>
+ <uvForm
+ ref="uForm"
+ :model="model"
+ :rules="rules"
+ :errorType="errorType"
+ :borderBottom="borderBottom"
+ :labelPosition="labelPosition"
+ :labelWidth="labelWidth"
+ :labelAlign="labelAlign"
+ :labelStyle="labelStyle"
+ :customStyle="customStyle"
+ >
+ <slot />
+ </uvForm>
+</template>
+
+<script>
+ /**
+ * 姝ょ粍浠跺瓨鍦ㄧ殑鐞嗙敱鏄紝鍦╪vue涓嬶紝u-form琚玼ni-app瀹樻柟鍗犵敤浜嗭紝u-form鍦╪vue涓浉褰撲簬form缁勪欢
+ * 鎵�浠ュ湪nvue涓嬶紝鍙栧悕涓簎--form锛屽唴閮ㄥ叾瀹炶繕鏄痷-form.vue锛屽彧涓嶈繃鍋氫竴灞備腑杞�
+ */
+ import uvForm from '../u-form/u-form.vue';
+ import props from '../u-form/props.js'
+ export default {
+ // #ifdef MP-WEIXIN
+ name: 'u-form',
+ // #endif
+ // #ifndef MP-WEIXIN
+ name: 'u--form',
+ // #endif
+ mixins: [uni.$u.mpMixin, props, uni.$u.mixin],
+ components: {
+ uvForm
+ },
+ created() {
+ this.children = []
+ },
+ methods: {
+ // 鎵嬪姩璁剧疆鏍¢獙鐨勮鍒欙紝濡傛灉瑙勫垯涓湁鍑芥暟鐨勮瘽锛屽井淇″皬绋嬪簭涓細杩囨护鎺夛紝鎵�浠ュ彧鑳芥墜鍔ㄨ皟鐢ㄨ缃鍒�
+ setRules(rules) {
+ this.$refs.uForm.setRules(rules)
+ },
+ validate() {
+ /**
+ * 鍦ㄥ井淇″皬绋嬪簭涓紝閫氳繃this.$parent鎷垮埌鐨勭埗缁勪欢鏄痷--form锛岃�屼笉鏄叾鍐呭祵鐨剈-form
+ * 瀵艰嚧鍦╱-form缁勪欢涓紝鎷夸笉鍒板搴旂殑children鏁扮粍锛屼粠鑰屾牎楠屾棤鏁堬紝鎵�浠ヨ繖閲屾瘡娆¤皟鐢╱-form缁勪欢涓殑
+ * 瀵瑰簲鏂规硶鐨勬椂鍊欙紝鍦ㄥ皬绋嬪簭涓兘鍏堝皢u--form鐨刢hildren璧嬪�肩粰u-form涓殑children
+ */
+ // #ifdef MP-WEIXIN
+ this.setMpData()
+ // #endif
+ return this.$refs.uForm.validate()
+ },
+ validateField(value, callback) {
+ // #ifdef MP-WEIXIN
+ this.setMpData()
+ // #endif
+ return this.$refs.uForm.validateField(value, callback)
+ },
+ resetFields() {
+ // #ifdef MP-WEIXIN
+ this.setMpData()
+ // #endif
+ return this.$refs.uForm.resetFields()
+ },
+ clearValidate(props) {
+ // #ifdef MP-WEIXIN
+ this.setMpData()
+ // #endif
+ return this.$refs.uForm.clearValidate(props)
+ },
+ setMpData() {
+ this.$refs.uForm.children = this.children
+ }
+ },
+ }
+</script>
--
Gitblit v1.9.3