Преглед изворни кода

单位信息采集BUG修复/单位信息采集逻辑处理/修改u-formUI框架源码

fanghuisheng пре 2 година
родитељ
комит
e9438f15c5

+ 184 - 96
src/pages/business/mhxf/unitInfoCollection/index.vue

@@ -57,7 +57,7 @@
 
           <view style="position: fixed; left: 0; right: 0; bottom: 0; padding: 15px">
             <view>
-              <u-button type="primary" style="width: 100%; height: 40px; font-size: 14px" @click="nextSubmit" shape="circle"> 下一步 </u-button>
+              <u-button type="primary" style="width: 100%; height: 40px; font-size: 14px" @click="handleSubmit('下一步')" shape="circle"> 下一步 </u-button>
             </view>
           </view>
         </view>
@@ -67,7 +67,7 @@
     <view class="centerTwo" v-else>
       <view style="color: #333333; text-align: center; margin-top: 10px"> 所在建筑信息(2/2) </view>
 
-      <u--form :model="form.baseBuildList" ref="uForm1" :rules="rules" labelWidth="130">
+      <u--form ref="uForm1" :model="form" :rules="rules" labelWidth="130">
         <view style="padding: 10px 0" v-for="(li, index) in form.baseBuildList" :key="index">
           <view class="" style="padding: 10px 10px 20px 10px; background: #ffffff">
             <view style="display: flex; overflow: hidden">
@@ -76,10 +76,10 @@
               <u-icon v-if="form.baseBuildList.length > 1" name="trash" color="#FF0000" size="20" style="float: right" @click="deleteSubmit(index)"></u-icon>
             </view>
             <view style="padding-left: 9px">
-              <u-form-item label="建筑名称" prop="li.buildName" required :borderBottom="true">
+              <u-form-item label="建筑名称" :prop="`baseBuildList.${index}.buildName`" required :borderBottom="true">
                 <u-input v-model="li.buildName" placeholder="请输入建筑名称" border="none" />
               </u-form-item>
-              <u-form-item label="建筑地址" prop="li.address" required :borderBottom="true">
+              <u-form-item label="建筑地址" :prop="`baseBuildList.${index}.address`" required :borderBottom="true">
                 <u-input v-model="li.address" placeholder="请输入建筑地址" border="none" />
               </u-form-item>
               <u-form-item label="建筑结构" prop="li.buildStructure" required :borderBottom="true" @click="handleAction('建筑结构', index)">
@@ -88,13 +88,13 @@
               <u-form-item label="地上层数" prop="li.aboveFloor" required :borderBottom="true">
                 <u-input v-model="li.aboveFloor" placeholder="请输入地上层数" border="none" />
               </u-form-item>
-              <u-form-item label="地下层数" prop="li.underFloor" required :borderBottom="true">
+              <u-form-item label="地下层数" prop="li.underFloor" :borderBottom="true">
                 <u-input v-model="li.underFloor" placeholder="请输入地下层数" border="none" />
               </u-form-item>
               <u-form-item label="建筑面积" prop="li.buildArea" required :borderBottom="true">
                 <u-input v-model="li.buildArea" placeholder="请输入建筑面积" suffixIcon="平方米" suffixIconStyle="color:#999999;font-size:15px" border="none" />
               </u-form-item>
-              <u-form-item label="地下空间" prop="li.underSpace" required :borderBottom="true">
+              <u-form-item label="地下空间" prop="li.underSpace" :borderBottom="true">
                 <u-input v-model="li.underSpace" placeholder="请输入地下空间面积" suffixIcon="平方米" suffixIconStyle="color:#999999;font-size:15px" border="none" />
               </u-form-item>
               <u-form-item label="使用性质" prop="li.useCharacter" required :borderBottom="true" @click="handleAction('使用性质', index)">
@@ -117,9 +117,11 @@
 
       <view style="position: fixed; left: 0; right: 0; bottom: 0; padding: 15px; background-color: transparent">
         <view style="display: flex">
-          <u-button style="width: 50%; height: 40px; font-size: 14px; margin-right: 15px" @click="backSubmit" shape="circle" customStyle="border-color:#3c9cff;color:#3c9cff"> 上一步 </u-button>
+          <u-button style="width: 50%; height: 40px; font-size: 14px; margin-right: 15px" @click="handleSubmit('上一步')" shape="circle" customStyle="border-color:#3c9cff;color:#3c9cff">
+            上一步
+          </u-button>
 
-          <u-button type="primary" style="width: 50%; height: 40px; font-size: 14px" @click="submit" shape="circle"> 提交 </u-button>
+          <u-button type="primary" style="width: 50%; height: 40px; font-size: 14px" @click="handleSubmit('提交')" shape="circle"> 提交 </u-button>
         </view>
       </view>
     </view>
@@ -156,8 +158,8 @@
       cancelText="新增"
       :showCancelButton="true"
       cancelColor="#2979ff"
-      @confirm="modelSubmit('是')"
-      @cancel="modelSubmit('否')"
+      @confirm="handleSubmitApi('是')"
+      @cancel="handleSubmitApi('否')"
       :closeOnClickOverlay="true"
       @close="modalShow = false"
     >
@@ -183,8 +185,8 @@ const newPublicStore = publicStore();
 
 const dataList = reactive({
   form: {
-    organization: "", //信用代码
     companyName: "", //单位名称
+    organization: "", //信用代码
     delegateName: "", //法人代表姓名
     streetTown: "", //所属街镇
     streetTownValue: 0, //所属街镇
@@ -199,24 +201,32 @@ const dataList = reactive({
     companyNatureValue: 0, //单位性质
     buildArea: "", //建筑面积
 
-    baseBuildList: [
+    baseBuildList: [],
+  },
+
+  baseBuildListForm: {
+    buildName: "", //建筑名称
+    address: "", //详细地址
+    buildStructure: "", //建筑结构
+    buildStructureValue: 0, //建筑结构
+    aboveFloor: "", //地上楼层
+    underFloor: "", //地下楼层
+    buildArea: "", //建筑面积
+    underSpace: "", //地下空间
+    useCharacter: "", //使用性质
+    useCharacterValue: 0,
+    completeYear: "", //竣工年份
+    buildHigh: "", //建筑高度
+  },
+
+  rules: {
+    companyName: [
       {
-        buildName: "", //建筑名称
-        address: "", //详细地址
-        buildStructure: "", //建筑结构
-        buildStructureValue: 0, //建筑结构
-        aboveFloor: "", //地上楼层
-        underFloor: "", //地下楼层
-        buildArea: "", //建筑面积
-        underSpace: "", //地下空间
-        useCharacter: "", //使用性质
-        useCharacterValue: 0,
-        completeYear: "", //竣工年份
-        buildHigh: "", //建筑高度
+        required: true,
+        message: "请输入单位名称",
+        trigger: ["blur", "change"],
       },
     ],
-  },
-  rules: {
     organization: [
       {
         required: true,
@@ -231,7 +241,27 @@ const dataList = reactive({
         trigger: ["change"],
       },
     ],
-
+    delegateName: [
+      {
+        required: true,
+        message: "请输入法人代表",
+        trigger: ["blur", "change"],
+      },
+    ],
+    streetTown: [
+      {
+        required: true,
+        message: "请选择所属街镇",
+        trigger: ["blur", "change"],
+      },
+    ],
+    address: [
+      {
+        required: true,
+        message: "请输入单位地址",
+        trigger: ["blur", "change"],
+      },
+    ],
     fireManagePhone: [
       {
         required: true,
@@ -247,7 +277,35 @@ const dataList = reactive({
         trigger: ["blur", "change"],
       },
     ],
+    foundTime: [
+      {
+        required: true,
+        message: "请选择成立时间",
+        trigger: ["blur", "change"],
+      },
+    ],
+
+    baseBuildList: [],
   },
+
+  baseBuildListRules: {
+    buildName: [
+      {
+        required: true,
+        message: "请输入建筑名称",
+        trigger: ["blur", "change"],
+      },
+    ],
+
+    address: [
+      {
+        required: true,
+        message: "请输入建筑地址",
+        trigger: ["blur", "change"],
+      },
+    ],
+  },
+
   noticeBarText: "注:信息提交后不可修改,提交前请核对填写是否有误",
   pagingBool: true,
 
@@ -263,7 +321,8 @@ const dataList = reactive({
   modalShow: false,
 });
 
-const { form, rules, noticeBarText, pagingBool, actionTitle, actionIndex, actionsList, actionShow, showTime, timeValue, timeTitle, timeIndex, modalShow } = toRefs(dataList);
+const { form, baseBuildListForm, rules, baseBuildListRules, noticeBarText, pagingBool, actionTitle, actionIndex, actionsList, actionShow, showTime, timeValue, timeTitle, timeIndex, modalShow } =
+  toRefs(dataList);
 
 const uForm = ref(null);
 const uForm1 = ref(null);
@@ -295,36 +354,45 @@ function companySubmit(e) {
 }
 
 /**
+ * @上一步
+ * @下一步
  * @提交
  * @按钮点击事件
  */
-function submit() {
-  if (newCompanyName.value == "") {
-    handleSubmitApi("否");
-  } else {
-    modalShow.value = true;
+function handleSubmit(value) {
+  if (value === "上一步") {
+    pagingBool.value = true;
+  } else if (value === "下一步") {
+    uForm.value
+      .validate()
+      .then((res) => {
+        uni.$u.toast("校验通过");
+        pagingBool.value = false;
+      })
+      .catch((errors) => {
+        uni.$u.toast("校验失败");
+      });
+  } else if (value === "提交") {
+    if (newCompanyName.value == "") {
+      handleSubmitApi("否");
+    } else {
+      modalShow.value = true;
+    }
   }
 }
 
-/**
- * @model弹窗
- * @按钮点击事件
- */
-function modelSubmit(value) {
-  handleSubmitApi(value);
-}
-
 /**
  * @api提交
  */
 function handleSubmitApi(value) {
+  console.log(form.value);
+
   let param = {};
 
   uForm1.value
     .validate()
     .then((res) => {
       uni.$u.toast("校验通过");
-      uni.$u.toast("校验通过");
 
       param = {
         baseCompany: {
@@ -633,8 +701,6 @@ function handleAction(value, index) {
  * @action弹出框选择事件
  */
 function selectAction(e) {
-  console.log(e);
-
   if (actionTitle.value == "建筑结构") {
     form.value.baseBuildList[actionIndex.value].buildStructure = e.value[0].name;
     form.value.baseBuildList[actionIndex.value].buildStructureValue = e.value[0].value;
@@ -656,8 +722,15 @@ function selectAction(e) {
   }
 
   if (actionTitle.value == "单位名称") {
+    form.value.baseBuildList = [];
+
     newCompanyName.value = e.value[0].companyName;
     // form.value = e.value[0];
+    form.value.id = e.value[0].id;
+    form.value.id1 = e.value[0].id1;
+    form.value.id2 = e.value[0].id2;
+    form.value.companyId = e.value[0].companyId;
+
     form.value.companyName = e.value[0].companyName;
     form.value.organization = e.value[0].organization;
     form.value.delegateName = e.value[0].delegateName;
@@ -667,23 +740,64 @@ function selectAction(e) {
     if (e.value[0].baseBuildList != null) {
       form.value.baseBuildList = e.value[0].baseBuildList;
     } else {
-      form.value.baseBuildList = [
-        {
-          buildName: "", //建筑名称
-          address: "", //详细地址
-          buildStructure: "", //建筑结构
-          buildStructureValue: 0, //建筑结构
-          aboveFloor: "", //地上楼层
-          underFloor: "", //地下楼层
-          buildArea: "", //建筑面积
-          underSpace: "", //地下空间
-          useCharacter: "", //使用性质
-          useCharacterValue: 0,
-          completeYear: "", //竣工年份
-          buildHigh: "", //建筑高度
-        },
-      ];
+      form.value.baseBuildList.push(baseBuildListForm.value);
     }
+
+    form.value.baseBuildList.forEach((el) => {
+      el.buildStructureValue = el.buildStructure;
+
+      el.buildStructure =
+        el.buildStructure == 1
+          ? "砖混结构"
+          : el.buildStructure == 2
+          ? "钢筋混凝土"
+          : el.buildStructure == 3
+          ? "钢结构"
+          : el.buildStructure == 4
+          ? "大型钢筋混凝土"
+          : el.buildStructure == 5
+          ? "木质结构"
+          : el.buildStructure == 6
+          ? "砖木结构"
+          : "未知";
+
+      el.useCharacterValue = el.useCharacter;
+
+      el.useCharacter =
+        el.useCharacter == 1
+          ? "饭店、旅馆"
+          : el.useCharacter == 2
+          ? "公寓、住宅"
+          : el.useCharacter == 3
+          ? "体育场馆"
+          : el.useCharacter == 4
+          ? "俱乐部、夜总会、歌舞厅电影院、剧院、礼堂办公、商务科研 (包括实验室等)"
+          : el.useCharacter == 5
+          ? "医院"
+          : el.useCharacter == 6
+          ? "教学"
+          : el.useCharacter == 7
+          ? "商业 (包括商店、商场、集贸市场等)"
+          : el.useCharacter == 8
+          ? "金融"
+          : el.useCharacter == 9
+          ? "交通"
+          : el.useCharacter == 10
+          ? "文博馆(包括展览馆、博物馆、图书馆、档案馆、文化馆等)"
+          : el.useCharacter == 11
+          ? "通信枢纽、电视广播发射、中转"
+          : el.useCharacter == 12
+          ? "厂房"
+          : el.useCharacter == 13
+          ? "库房"
+          : el.useCharacter == 14
+          ? "油气罐站、管线"
+          : el.useCharacter == 15
+          ? "综台建筑"
+          : el.useCharacter == 16
+          ? "其他"
+          : "未知";
+    });
   }
 
   actionShow.value = false;
@@ -725,20 +839,8 @@ function timeSubmit(data) {
  * @按钮点击事件
  */
 function addSubmit() {
-  form.value.baseBuildList.push({
-    buildName: "", //建筑名称
-    address: "", //详细地址
-    buildStructure: "", //建筑结构
-    buildStructureValue: 0, //建筑结构
-    aboveFloor: "", //地上楼层
-    underFloor: "", //地下楼层
-    buildArea: "", //建筑面积
-    underSpace: "", //地下空间
-    useCharacter: "", //使用性质
-    useCharacterValue: 0,
-    completeYear: "", //竣工年份
-    buildHigh: "", //建筑高度
-  });
+  form.value.baseBuildList.push(baseBuildListForm.value);
+  rules.value.baseBuildList.push(baseBuildListRules.value);
 }
 
 /**
@@ -755,31 +857,17 @@ function deleteSubmit(index) {
   } else {
     form.value.baseBuildList.splice(index, 1);
   }
-}
 
-/**
- * @上一步
- * @按钮点击事件
- */
-function backSubmit() {
-  pagingBool.value = true;
+  rules.value.baseBuildList.splice(index, 1);
 }
 
-/**
- * @下一步
- * @按钮点击事件
- */
-function nextSubmit() {
-  uForm.value
-    .validate()
-    .then((res) => {
-      uni.$u.toast("校验通过");
-      pagingBool.value = false;
-    })
-    .catch((errors) => {
-      uni.$u.toast("校验失败");
-    });
-}
+onLoad((options) => {
+  form.value.baseBuildList = [];
+  rules.value.baseBuildList = [];
+
+  form.value.baseBuildList.push(baseBuildListForm.value);
+  rules.value.baseBuildList.push(baseBuildListRules.value);
+});
 </script>
 
 <style lang="scss">

+ 11 - 1
src/uni_modules/uview-plus/components/u-form/u-form.vue

@@ -146,7 +146,17 @@
 							const propertyName =
 								propertyChain[propertyChain.length - 1];
 
-							const rule = this.formRules[child.prop];
+							//修改:将const改为let 
+							let rule = this.formRules[child.prop];
+							//修改:链式是无法通过上面的方式获取的,改为下面的方式
+							
+							if(!rule){
+								rule=uni.$u.getProperty(
+								this.formRules,
+								child.prop
+								);
+							}
+							
 							// 如果不存在对应的规则,直接返回,否则校验器会报错
 							if (!rule) return;
 							// rule规则可为数组形式,也可为对象形式,此处拼接成为数组