hejianhao
2025-04-16 dab2d210ca06c1faa514c6388fbd5de1ab355360
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
<template>
  <div class='village_edit'>
    <section class="sec">
      <p class="label">房屋面积:</p>
      <article>
        <el-input
          size="small"
          v-model="num"
        ></el-input>m2
      </article>
    </section>
  </div>
</template>
 
<script>
export default {
  props: {
    item: {
      type: Object,
      default: () => {
        return {};
      },
    },
    door: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  components: {},
  data() {
    return { num: "", detail: {} };
  },
  watch: {
    item: {
      handler() {
        this.setItem();
      },
      deep: true,
    },
    door: {
      handler(n) {
        if (n.r) {
          this.sub(n.t);
        }
      },
      deep: true,
    },
  },
  methods: {
    sub(type) {
      if (isNaN(this.num) || this.num === "" || !this.num || this.num < 0) {
        demo.toast("请输入正整数");
        return 0;
      }
      let o = demo.copy(Object.assign(this.detail, { square: this.num }));
      this.$api.put("communitymanager/house", o, () => {
        demo.toast("编辑成功");
        this.$nextTick(() => {
          this.$store.dispatch("setFixed", {
            event: "del",
            type: type,
            time: Date.now(),
          });
          this.$store.dispatch(
            "setPageReset",
            "/man_bui_villages/" + this.item.id
          );
        });
      });
    },
    setItem() {
      if (this.item.id) {
        this.detail = this.item.item;
        this.num = this.detail.square;
      }
    },
  },
  mounted() {
    this.setItem();
  },
};
</script>
<style lang='less' scoped>
.village_edit {
  .el-input {
    width: 300px;
    margin: 0 20px;
  }
  .sec {
    width: 500px;
    margin: 0 auto;
  }
}
</style>