diff --git a/components/districtSelector/districtSelector.vue b/components/districtSelector/districtSelector.vue
index b7bfd6b..a82b73c 100644
--- a/components/districtSelector/districtSelector.vue
+++ b/components/districtSelector/districtSelector.vue
@@ -1,6 +1,6 @@
-
+
@@ -82,9 +82,9 @@
trigger: ['change', 'blur']
},
brigade: {
- type: 'any',
- required: true,
- message: '不能为空',
+ validator: (rule, value, callback )=>{
+ value?callback():callback('不能为空')
+ },
trigger: ['change', 'blur']
},
},
@@ -103,7 +103,7 @@
methods:{
validate(){
return new Promise((resolve, reject)=>{
- this.$refs.uForm.validate().then(res=>{
+ this.$refs.districtForm.validate().then(res=>{
if(res)resolve(true);
else reject(false);
})
diff --git a/components/newArchives/breeding.vue b/components/newArchives/breeding.vue
index 7ff488e..0ebd8b2 100644
--- a/components/newArchives/breeding.vue
+++ b/components/newArchives/breeding.vue
@@ -1,122 +1,131 @@
-
-
-
-
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
+
+
+
+
+
+
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -125,27 +134,106 @@
data() {
return {
landPlanList: ['自己种养', '出租', '代种养', '租更多地扩大种植'],
- formData: {
- breedingList: [{
- landPlan: '', //土地规划
- }, ]
- },
+ formData: [{
+ "category_id": "1",
+ "category_child": "0",
+ "cultivated_area": "20", //耕地总面积
+ "planning": 66, //土地规划
+ "breeding_training": 1, //有无种养殖培训
+ "planting_company": 0, //有无注册成立种殖公司
+ "notes": "试试备注", //备注
+ "breeding_type": 22, //种养殖类型
+ "area": 20, //面积
+ "breeding_time": "2022-07-22", //种养殖开始时间
+ "mature_time": "2022-07-22", //上市时间
+ "yield": 600, //产量
+ "estimated_income": 1500, //预计收益
+ "farm_tools": "收割机一台,打米机一台", //农资农具使用情况
+ "ecological_farming": 1, //是否生态种养殖
+ "modernization": 30, //现代化程度
+ "pre_price": "30.00", //预售卖价格
+ "method_sales": 1, //销售方式
+ "processing_storage": 0, //有无加工仓储
+ "promote": 0, //有无宣传推广
+ "transportation": 0, //有无运输
+ "expand_business_needs": 0, //是否有扩大经营需求
+ "demand": "没有述求", //种养殖述求
+ "policy_subsidies": "无补助" //政策补助
+ }],
rules: {
-
+
}
}
},
+ created() {
+ this.initRules()
+ },
methods: {
+ // 初始化校验
+ initRules(){
+ let arr = Object.keys(this.formData[0]);
+ arr.forEach(key=>{
+ this.rules[key] = {
+ validator: (rule, value, callback )=>{
+ if(Array.isArray(this.$refs.breedingForm)) for(let i = 0;i {
if (res.confirm) {
- this.formData.breedingList.splice(index, 1);
+ this.formData.splice(index, 1);
}
}
})
diff --git a/components/newArchives/residents.vue b/components/newArchives/residents.vue
index c77abd4..4a60b0d 100644
--- a/components/newArchives/residents.vue
+++ b/components/newArchives/residents.vue
@@ -1,25 +1,25 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
+
+
+
-
+
@@ -85,7 +84,7 @@
export default {
data() {
return {
- situationList: ['公务员','国企事业单位','民营企业','自由职业','其他'],
+ situationList: ['公务员', '国企事业单位', '民营企业', '自由职业', '其他'],
// 常住人口
residents: {
family: [{
@@ -107,29 +106,64 @@
],
},
rules: {
-
+ family: {
+ validator: (rule, value, callback ) => {
+ if (Array.isArray(value) && value.length > 0) {
+ for (let i = 0; i < value.length; i++) {
+ const item = value[i];
+ for (const key in item) {
+ // 检查每个属性值是否为空
+ if (!item[key]) {
+ callback(new Error('以上四项基本信息必填'));
+ return;
+ }
+ }
+ }
+ // 数组每个属性都不为空,校验通过
+ callback();
+ } else {
+ // 数组为空,校验未通过
+ callback(new Error('数组不能为空'));
+ }
+ },
+ trigger: ['change', 'blur']
+ },
+ child: {
+ validator: (rule, value, callback )=>{
+ typeof value==='number'?callback():callback('不能为空')
+ },
+ trigger: ['change', 'blur']
+ },
}
}
},
methods: {
+ validate() {
+ return new Promise((resolve, reject) => {
+ this.$refs.residentsForm.validate().then(res => {
+ if (res) resolve(true);
+ else reject(false);
+ })
+ })
+ },
// 选择生日
- changebirth_time(e){
+ changebirth_time(e) {
let index = e.currentTarget.dataset.index;
this.residents.family[index].birth_time = e.detail.value;
},
// 选择就业
- changesituation(e){
+ changesituation(e) {
let index = e.currentTarget.dataset.index;
this.residents.family[index].situation = this.situationList[e.detail.value];
},
// 添加人口
pushFamily() {
this.residents.family.push({
- name: '',
- birth_time: '',
- situation: '', // 工作
- skills: '', // 技能
- })
+ name: '',
+ birth_time: '',
+ situation: '', // 工作
+ skills: '', // 技能
+ })
},
// 删除人口
removeFamily(index) {
@@ -146,13 +180,13 @@
// 添加婴幼儿
pushChildArr() {
this.residents.child_arr.push({
- age: '',
- feeding: '', //喂养方式
- grade: '', //年级
- is_lesson: '', //是否补课
- lessons: '', //课程
- notes: '' //备注
- })
+ age: '',
+ feeding: '', //喂养方式
+ grade: '', //年级
+ is_lesson: '', //是否补课
+ lessons: '', //课程
+ notes: '' //备注
+ })
},
// 删除婴幼儿
removeChildArr(index) {
@@ -166,6 +200,7 @@
}
})
},
+
},
}
diff --git a/subpkg/newArchives/newArchives.vue b/subpkg/newArchives/newArchives.vue
index 725ae12..e7c8b96 100644
--- a/subpkg/newArchives/newArchives.vue
+++ b/subpkg/newArchives/newArchives.vue
@@ -1,7 +1,7 @@
-
+
基本信息
@@ -31,7 +31,7 @@
-
+
-
+
-
+
@@ -110,12 +110,36 @@
message: '请选择男或女',
trigger: ['blur', 'change']
},
+ age: {
+ type: 'number',
+ required: true,
+ message: '请输入年龄',
+ trigger: ['blur', 'change']
+ },
name: {
type: 'string',
required: true,
message: '姓名不能为空',
trigger: ['change', 'blur']
},
+ address: {
+ type: 'string',
+ required: true,
+ message: '地址不能为空',
+ trigger: ['change', 'blur']
+ },
+ highway: {
+ validator: (rule, value, callback )=>{
+ typeof value==='number'?callback():callback('不能为空')
+ },
+ trigger: ['change', 'blur']
+ },
+ smart_phone: {
+ validator: (rule, value, callback )=>{
+ typeof value==='number'?callback():callback('不能为空')
+ },
+ trigger: ['change', 'blur']
+ },
},
}
},
@@ -124,21 +148,34 @@
methods: {
// 新增档案
async addArchives() {
- console.log(await this.$refs.districtSelectorRef.validate());
- this.$refs.uForm.validate().then(async (e) => {
+ Toast('开发中')
+ let flag = true;
+ // flag = await this.$refs.districtSelectorRef.validate();
+ // if(flag) flag = await this.$refs.residentsRef.validate();
+ if(flag) flag = await this.$refs.breedingRef.validate();
+ if(flag) this.$refs.archives.validate().then(async (e) => {
if (e) {
- // uni.showLoading()
- // let res = await informationAdd(this.formData);
- // uni.hideLoading()
- // uni.showToast({
- // icon: "none",
- // title: "添加成功",
- // success: () => {
- // setTimeout(() => {
- // uni.navigateBack()
- // }, 1000)
- // }
- // })
+ uni.showLoading()
+ let districtForm = {
+ area_id:this.$refs.districtSelectorRef.formData.area,
+ street_id:this.$refs.districtSelectorRef.formData.street,
+ village_id:this.$refs.districtSelectorRef.formData.village,
+ brigade_id:this.$refs.districtSelectorRef.formData.brigade,
+ }
+ let res = await informationAdd({
+ ...this.formData,
+ ...districtForm
+ });
+ uni.hideLoading()
+ uni.showToast({
+ icon: "none",
+ title: "添加成功",
+ success: () => {
+ setTimeout(() => {
+ uni.navigateBack()
+ }, 1000)
+ }
+ })
}
})