2023西安数博会CIM演示-【前端】-Web
AdaKing88
2023-08-21 bc03b832caa49bbcd2674fe4cae3701b5059bf95
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
<template>
  <!--表格树内容栏-->
  <div style="width: 100%">
    <div
      style="text-align: right; border-top: 1px solid #ebeef5; padding: 10px"
    >
      <el-button @click="startEditData" size="small"
        ><i class="el-icon-edit"></i>
      </el-button>
      <el-button @click="saveEditData" size="small"
        ><i class="el-icon-check"></i>
      </el-button>
    </div>
    <div style="border-top: 1px solid #ebeef5">
      <el-table
        stripe
        size="mini"
        style="width: 100%"
        rowKey="propertyid"
        :data="data"
        ><el-table-column type="selection" width="55"> </el-table-column>
        <el-table-column
          prop="propertyid"
          header-align="center"
          align="center"
          width="55"
          label="序号"
        >
        </el-table-column>
        <el-table-column
          prop="propertyname"
          header-align="center"
          align="center"
          label="属性项"
        >
        </el-table-column>
        <el-table-column
          prop="propertyvalue"
          header-align="center"
          align="center"
          label="属性值"
        >
          <template slot-scope="scope">
            <el-input
              size="small"
              v-if="isedit"
              :ref="scope.column.property"
              v-model="scope.row.propertyvalue"
              @blur="alterData(scope.row, scope.column)"
            >
              ></el-input
            >
            <span v-else>{{ scope.row.propertyvalue }}</span>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>
<script>
export default {
  props: ["data", "owerid"],
  data() {
    return {
      isedit: false,
      editedData: [],
    };
  },
  methods: {
    startEditData() {
      this.editedData = [];
      this.isedit = true;
    },
    saveEditData() {
      this.isedit = false;
      console.log(this.editedData);
      //提交保存
      //this.$axios();
    },
    alterData(row, column) {
      let oldrows = this.data.find((item) => {
        return item.propertyid === row.propertyid;
      });
      let val = row[column.property];
      if (oldrows[column.property] !== val) {
        let d = {};
        d[row.propertyid] = val;
        this.editedData.push(d);
      }
    },
  },
  computed: {
    // 子组件computed中定义内容
    tabledata() {
      console.log(this.data);
      return this.data;
    },
  },
};
</script>