panhui 4 лет назад
Родитель
Сommit
b1ad27aa2b
1 измененных файлов с 41 добавлено и 22 удалено
  1. 41 22
      src/main/h5/src/views/TrainingInstitution.vue

+ 41 - 22
src/main/h5/src/views/TrainingInstitution.vue

@@ -15,10 +15,9 @@
 
         <van-cell-group>
           <van-cell
-            v-for="item in list"
-            :key="item.id"
-            :title="item.name"
-            :label="item.uscc"
+            v-for="(item, index) in list"
+            :key="index"
+            :title="item"
             @click="choose(item)"
           />
         </van-cell-group>
@@ -28,10 +27,14 @@
         label="注册号"
         placeholder="请输入注册号"
         v-model="form.uscc"
-        @change="changeUsscc"
         :rules="[{ required: true, message: '请填写注册号' }]"
       />
-      <template v-if="form.id">
+      <div style="margin:30px" v-if="!form.id">
+        <van-button class="submit" round block type="info" @click="byUscc">
+          查询
+        </van-button>
+      </div>
+      <template v-else>
         <van-field
           type="textarea"
           name="经营范围"
@@ -297,31 +300,44 @@ export default {
         data.query[key] = this.form[key];
       }
       this.$http
-        .post("/trainingInstitution/all", data, { body: "json" })
+        .post("/trainingInstitution/name", data, { body: "json" })
         .then(res => {
           this.$toast.clear();
-          if (res.empty) {
-            this.$toast("暂无该企业信息");
-          } else {
-            this.list = res.content;
-            setTimeout(() => {
-              this.$nextTick(() => {
-                this.showPopover = true;
-              });
-            }, 500);
-          }
+          this.list = res.content;
+          setTimeout(() => {
+            this.$nextTick(() => {
+              this.showPopover = true;
+            });
+          }, 500);
         });
     },
-    changeUsscc() {
-      if (!this.form.id) {
-        this.like("", "uscc");
-      }
+    byUscc() {
+      this.$toast.loading({
+        message: "加载中...",
+        forbidClick: true,
+        duration: 0
+      });
+      this.$http
+        .post(
+          `/trainingInstitution/byUscc?name=${this.form.name}&uscc=${this.form.uscc}`
+        )
+        .then(res => {
+          this.$toast.clear();
+          this.form = { ...res };
+        })
+        .catch(e => {
+          this.$toast(e.error);
+        });
     },
     choose(info) {
-      this.form = { examPoint: false, ...info };
+      this.form.name = info;
+      // this.form = { examPoint: false, ...info };
       this.showPopover = false;
     },
     submit() {
+      if (!this.form.id) {
+        return;
+      }
       this.$toast.loading({
         message: "加载中...",
         forbidClick: true,
@@ -338,6 +354,9 @@ export default {
             message: "信息已经提交成功,感谢您的配合。",
             showConfirmButton: false
           });
+        })
+        .catch(e => {
+          this.$toast(e.error);
         });
     },
     saveWeb() {