xuqiang 4 лет назад
Родитель
Сommit
831cf2ba20
1 измененных файлов с 74 добавлено и 36 удалено
  1. 74 36
      src/main/h5/src/views/record/recordAdd.vue

+ 74 - 36
src/main/h5/src/views/record/recordAdd.vue

@@ -1,3 +1,4 @@
+// eslint-disable
 <template>
   <div class="container">
     <div class="page-title">
@@ -7,16 +8,30 @@
     <div class="score-list">
       <div class="score-item" :key="index" v-for="(item, index) in List">
         <div class="text1">{{ index + 1 }}.{{ item.label }}</div>
-        <template>
-          <el-radio v-model="item.value" :label="true">是</el-radio>
-          <el-radio v-model="item.value" :label="false">否</el-radio>
-        </template>
+        <div style="margin-top:10px">
+          <template>
+            <el-radio
+              @change="changeRadio(item, true)"
+              v-model="item.value"
+              :label="true"
+              >是</el-radio
+            >
+            <el-radio
+              @change="changeRadio(item, false)"
+              v-model="item.value"
+              :label="false"
+              >否</el-radio
+            >
+          </template>
+        </div>
         <div>
           <template>
             <van-uploader
-              :after-read="afterReads"
+              :after-read="(file, detail) => afterReads(file, detail, index)"
               :before-read="beforeRead"
-              :before-delete="beforeDeletes"
+              :before-delete="
+                (file, detail) => beforeDeletes(file, detail, index)
+              "
               v-model="item.img"
               class="miniImg"
             >
@@ -29,10 +44,23 @@
         </div>
       </div>
     </div>
-    <div class="score-card">
+    <!-- <div class="score-card">
       <div class="name">
         其他
       </div>
+      <van-field
+        type="textarea"
+        class="textarea"
+        placeholder="请输入…"
+        v-model="supervisor"
+        :autosize="{ maxHeight: 200, minHeight: 160 }"
+        :maxlength="150"
+      ></van-field>
+    </div> -->
+    <div class="score-card">
+      <div class="name">
+        检查情况
+      </div>
       <van-field
         type="textarea"
         class="textarea"
@@ -112,6 +140,7 @@ export default {
         imgs: []
       },
       img: [],
+      supervisor: "",
       submitList: {},
       List: []
     };
@@ -126,20 +155,25 @@ export default {
           recordId: this.$route.query.recordId,
           type: item.type,
           value: item.value,
-          img: this.img
+          img: item.imgArr
+          // supervisor: this.supervisor
         };
       });
     }
   },
   created() {
     this.categories.forEach(item => {
-      item.value = Boolean;
+      item.value = undefined;
+      item.imgArr = [];
       this.List.push(item);
     });
     console.log(this.List);
   },
   mounted() {},
   methods: {
+    changeRadio(item, flag) {
+      this.$forceUpdate();
+    },
     afterRead(file, detail) {
       this.$toast.loading({
         message: "加载中...",
@@ -156,7 +190,7 @@ export default {
           this.form.file = imgs;
         });
     },
-    afterReads(file, detail) {
+    afterReads(file, detail, index) {
       this.$toast.loading({
         message: "加载中...",
         forbidClick: true
@@ -166,11 +200,14 @@ export default {
           base64: file.content
         })
         .then(res => {
-          this.img.push(res);
+          this.List[index].imgArr.push(res);
+          console.log(this.List);
         });
     },
-    beforeDeletes(file, detail) {
-      this.img.splice(detail.index, 1);
+    beforeDeletes(file, detail, index) {
+      this.List[index].imgArr.splice(detail.index, 1);
+      // this.img.splice(detail.index, 1);
+      // console.log(item);
     },
     beforeDelete(file, detail) {
       let submitForm = { ...this.form };
@@ -194,31 +231,32 @@ export default {
       });
     },
     save() {
-      // let form = { ...this.form };
-      // this.$toast.loading({
-      //   message: "加载中...",
-      //   forbidClick: true
-      // });
-      // delete form.imgs;
-      // form.userId = this.$store.state.userInfo.id;
-      // form.recordId = this.$route.query.recordId;
-      // this.$http
-      //   .post("/recordCheck/save", form, { body: "json" })
-      //   .then(() => {
-      //     this.saving = false;
-      //     this.$toast.success("成功");
-      //     // setTimeout(() => {
-      //     //   this.$router.go(-1);
-      //     // }, 1500);
-      //   })
-      //   .catch(e => {
-      //     console.log(e);
-      //     this.saving = false;
-      //     this.$message.error(e.error);
-      //   });
+      let form = { ...this.form };
+      this.$toast.loading({
+        message: "加载中...",
+        forbidClick: true
+      });
+      delete form.imgs;
+      form.userId = this.$store.state.userInfo.id;
+      form.recordId = this.$route.query.recordId;
+      console.log(form);
+      this.$http
+        .post("/recordCheck/save", form, { body: "json" })
+        .then(() => {
+          this.saving = false;
+          this.$toast.success("成功");
+          // setTimeout(() => {
+          //   this.$router.go(-1);
+          // }, 1500);
+        })
+        .catch(e => {
+          console.log(e);
+          this.saving = false;
+          this.$message.error(e.error);
+        });
     },
     submit() {
-      // this.save();
+      this.save();
       this.$toast.loading({
         message: "加载中...",
         forbidClick: true