zhanghua
2022-11-29 55b0cd22baf5aa729253639877e5bf3656144bf9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<template>
  <div class="vio">
    <!-- 到达现场情况 -->
    <MyArrive ref="arrive" :arriveData="arriveData"></MyArrive>
    <!-- 调查取证 -->
    <MyEvidence
      ref="evidence"
      :evidenceData="evidenceData"
      :mytype="1"
      :mycode="mycode"
    ></MyEvidence>
    <!-- 底部按钮 -->
    <div class="footer">
      <el-button @click="handleSubmit" type="primary">确定</el-button>
      <el-button @click="handleBack">返回</el-button>
    </div>
  </div>
</template>
<script>
import MyArrive from "../components/arrive";
import MyEvidence from "../components/evidence";
import casequery from "@/api/operate/basecase";
 
export default {
  components: {
    MyArrive,
    MyEvidence,
  },
  data() {
    return {
      arriveData: null,
      evidenceData: null,
    };
  },
  props: ["caseId", "closeDialog", "mycode", "vioData", "imageResourceId"],
  created() {
    this.arriveData = this.vioData.arrivalSituation;
    this.evidenceData = this.vioData.investigation;
  },
  methods: {
    handleSubmit() {
      const { arrive, evidence } = this.$refs;
      const { arriveForm } = arrive.$refs;
      const { evidenceForm } = evidence.$refs;
      arriveForm.validate((valid) => {
        if (valid) {
          evidenceForm.validate((flag) => {
            if (flag) {
              const arriveData = Object.assign({}, arrive.arrive);
              const evidenceData = Object.assign({}, evidence.evidence);
              const { partyInfo } = evidenceData;
              const arrivalSituationId = arriveData.id;
              const investigationId = evidenceData.id;
              const partyInfoId = partyInfo ? partyInfo.id : 0;
              const evidencePic = evidenceData.pic.join(",");
              const situationPic = arriveData.situationPic.join(",");
              delete evidenceData.id;
              delete evidenceData.partyInfo;
              delete evidenceData.pic;
              delete arriveData.situationPic;
              delete arriveData.id;
              casequery
                .updateDisposeResult({
                  caseId: this.caseId,
                  imageResourceId: this.imageResourceId,
                  pic: evidencePic,
                  arrivalSituationId,
                  situationPic,
                  partyInfoId,
                  investigationId,
                  ...arriveData,
                  ...evidenceData,
                  ...partyInfo,
                })
                .then(() => {
                  this.$message.success("操作成功");
                  this.$emit("closeDialog");
                })
                .catch((err) => {
                  this.$message.error(err);
                });
            } else {
              return false;
            }
          });
        } else {
          evidenceForm.validate((flag) => {
            if (!flag) {
              return false;
            }
          });
          return false;
        }
      });
    },
    handleBack() {
      this.$emit("closeDialog", { flag: false });
    },
  },
};
</script>
<style lang="scss" scoped>
.vio {
  padding: 20px 200px 100px;
}
 
.footer {
  display: flex;
  justify-content: flex-end;
}
</style>