From d1448cb0ef10f358bb7bddb4e1ec268515e0b787 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 15 七月 2025 11:46:57 +0800
Subject: [PATCH] 项目初始化

---
 uni_modules/uview-ui/components/u--form/u--form.vue |   78 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 78 insertions(+), 0 deletions(-)

diff --git a/uni_modules/uview-ui/components/u--form/u--form.vue b/uni_modules/uview-ui/components/u--form/u--form.vue
new file mode 100644
index 0000000..fdfc212
--- /dev/null
+++ b/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