Procházet zdrojové kódy

'单位信息采集代码优化'

fanghuisheng před 2 roky
rodič
revize
a638f64772
1 změnil soubory, kde provedl 98 přidání a 25 odebrání
  1. 98 25
      src/pages/business/mhxf/unitInfoCollection/index.vue

+ 98 - 25
src/pages/business/mhxf/unitInfoCollection/index.vue

@@ -122,6 +122,13 @@
     <u-action-sheet :show="actionShow" :actions="actionsList" :title="'请选择' + actionTitle" @close="actionShow = false" @select="selectAction"> </u-action-sheet>
 
     <u-datetime-picker :show="showTime" v-model="timeValue" mode="date" @close="showTime = false" @cancel="showTime = false" @confirm="timeSubmit" :closeOnClickOverlay="true"></u-datetime-picker>
+
+    <u-modal :show="modalShow" title="系统提示" confirmText="是" cancelText="否" :showCancelButton="true" @confirm="modelSubmit('是')" @cancel="modelSubmit('否')">
+      <view class="slot-content">
+        <view style="text-align: center; margin-bottom: 10px">是否需要修改“单位名称”为:“{{ newCompanyName }}”的信息吗?</view>
+        <view style="text-align: center; font-size: 13px; color: #ff0000">注:“是”则继续修改,“否”则提交一次新的记录</view>
+      </view>
+    </u-modal>
   </view>
 </template>
 
@@ -152,7 +159,22 @@ const dataList = reactive({
     coverArea: "", //占地面积
     buildArea: "", //建筑面积
 
-    baseBuildList: [],
+    baseBuildList: [
+      {
+        buildName: "", //建筑名称
+        address: "", //详细地址
+        buildStructure: "", //建筑结构
+        buildStructureValue: 0, //建筑结构
+        aboveFloor: "", //地上楼层
+        underFloor: "", //地下楼层
+        buildArea: "", //建筑面积
+        underSpace: "", //地下空间
+        useCharacter: "", //使用性质
+        useCharacterValue: 0,
+        completeYear: "", //竣工年份
+        buildHigh: "", //建筑高度
+      },
+    ],
   },
   rules: {
     organization: [
@@ -181,12 +203,15 @@ const dataList = reactive({
   timeValue: Number(new Date()),
   timeTitle: "",
   timeIndex: 0,
+
+  modalShow: false,
 });
 
-const { form, rules, noticeBarText, pagingBool, actionTitle, actionIndex, actionsList, actionShow, showTime, timeValue, timeTitle, timeIndex } = toRefs(dataList);
+const { form, rules, noticeBarText, pagingBool, actionTitle, actionIndex, actionsList, actionShow, showTime, timeValue, timeTitle, timeIndex, modalShow } = toRefs(dataList);
 
 const uForm = ref(null);
 const uForm1 = ref(null);
+const newCompanyName = ref("");
 
 /**
  * @单位名称
@@ -206,8 +231,6 @@ function companySubmit(e) {
           actionsList.value.push(el);
         });
         actionTitle.value = "单位名称";
-
-        console.log(actionsList.value);
       } else {
         proxy.$modal.msg("未匹配到您所输入的单位!");
       }
@@ -220,26 +243,55 @@ function companySubmit(e) {
  * @按钮点击事件
  */
 function submit() {
-  console.log(form.value);
+  let param = {};
+
+  if (newCompanyName.value == "") {
+    param = {
+      baseCompany: {
+        companyName: form.value.companyName, //单位名称
+        organization: form.value.organization, //组织机构代码
+        address: form.value.address, //单位地址
+        foundTime: form.value.foundTime + "T00:00:00", //成立时间
+      },
+      baseCompanyAttach1: {
+        employeeNum: form.value.employeeNum, //职工人数
+        coverArea: form.value.coverArea, //占地面积
+        buildArea: form.value.buildArea, //建筑面积
+        fixedAssets: form.value.fixedAssets, //固定资产
+      },
+      baseCompanyPerson: {
+        delegateName: form.value.delegateName, //法人代表姓名
+        fireDutyName: form.value.fireDutyName, //消防安全责任人姓名
+        fireManageName: form.value.fireManageName, //消防安全管理人姓名
+        fireManagePhone: form.value.fireManagePhone, //消防安全管理人电话
+      },
+      baseBuildList: [],
+    };
+    handleSubmitApi(param);
+  } else {
+    modalShow.value = true;
+  }
+}
 
-  var param = {
+/**
+ * @model弹窗
+ * @按钮点击事件
+ */
+function modelSubmit(value) {
+  let param = {
     baseCompany: {
-      id: "id" in form.value ? form.value.id : undefined, //主键ID
-      companyId: "companyId" in form.value ? form.value.companyId : undefined, //单位ID
       companyName: form.value.companyName, //单位名称
       organization: form.value.organization, //组织机构代码
       address: form.value.address, //单位地址
       foundTime: form.value.foundTime + "T00:00:00", //成立时间
     },
     baseCompanyAttach1: {
-      id: "id1" in form.value ? form.value.id1 : undefined, //附表ID(id1)
       employeeNum: form.value.employeeNum, //职工人数
       coverArea: form.value.coverArea, //占地面积
       buildArea: form.value.buildArea, //建筑面积
       fixedAssets: form.value.fixedAssets, //固定资产
     },
     baseCompanyPerson: {
-      id: "id2" in form.value ? form.value.id2 : undefined, //单位关联人员表ID(id2)
       delegateName: form.value.delegateName, //法人代表姓名
       fireDutyName: form.value.fireDutyName, //消防安全责任人姓名
       fireManageName: form.value.fireManageName, //消防安全管理人姓名
@@ -248,27 +300,47 @@ function submit() {
     baseBuildList: [],
   };
 
-  form.value.baseBuildList.forEach((el) => {
-    param.baseBuildList.push({
-      buildName: el.buildName, //建筑名称
-      address: el.address, //详细地址
-      buildStructure: el.buildStructureValue, //建筑结构
-      aboveFloor: el.aboveFloor, //地上楼层
-      underFloor: el.underFloor, //地下楼层
-      buildArea: el.buildArea, //建筑面积
-      underSpace: el.underSpace, //地下空间
-      useCharacter: el.useCharacterValue, //使用性质
-      completeYear: el.completeYear, //竣工年份
-      buildHigh: el.buildHigh, //建筑高度
-    });
-  });
+  if (value === "是") {
+    param.baseCompany.id = "id" in form.value ? form.value.id : undefined; //主键ID
+    param.baseCompany.companyId = "companyId" in form.value ? form.value.companyId : undefined; //单位ID
 
-  addBaseCompany(param).then((res) => {});
+    param.baseCompanyAttach1.id = "id1" in form.value ? form.value.id1 : undefined; //附表ID(id1)
 
+    param.baseCompanyPerson.id = "id2" in form.value ? form.value.id2 : undefined; //单位关联人员表ID(id2)
+  }
+
+  handleSubmitApi(param);
+}
+
+/**
+ * @api提交
+ */
+function handleSubmitApi(param) {
   uForm1.value
     .validate()
     .then((res) => {
       uni.$u.toast("校验通过");
+
+      form.value.baseBuildList.forEach((el) => {
+        param.baseBuildList.push({
+          buildName: el.buildName, //建筑名称
+          address: el.address, //详细地址
+          buildStructure: el.buildStructureValue, //建筑结构
+          aboveFloor: el.aboveFloor, //地上楼层
+          underFloor: el.underFloor, //地下楼层
+          buildArea: el.buildArea, //建筑面积
+          underSpace: el.underSpace, //地下空间
+          useCharacter: el.useCharacterValue, //使用性质
+          completeYear: el.completeYear, //竣工年份
+          buildHigh: el.buildHigh, //建筑高度
+        });
+      });
+
+      addBaseCompany(param).then((res) => {
+        if (res.status == "SUCCESS") {
+          proxy.$tab.reLaunch("/pages/index");
+        }
+      });
     })
     .catch((errors) => {
       uni.$u.toast("校验失败");
@@ -363,6 +435,7 @@ function selectAction(e) {
     form.value.baseBuildList[actionIndex.value].useCharacter = e.name;
     form.value.baseBuildList[actionIndex.value].useCharacterValue = e.value;
   } else if (actionTitle.value == "单位名称") {
+    newCompanyName.value = e.companyName;
     form.value = e;
     form.value.foundTime = e.foundTime.split("T")[0];
     form.value.baseBuildList = [