<template>
  <div class="borderless" v-loading="pageLoading">
    <div class="customer-head">
      <div class="customer-back">
        <el-button type="danger" style="border: none;background: none;color: red" icon="el-icon-arrow-left"
          @click="backToList">返回列表
        </el-button>
      </div>
    </div>
    <div class="customer-main">
      <trade-card title="基础明细">
        <avue-crud ref="crud" :data="data" :option="tableOption" @saveColumn="saveColumn" @resetColumn="resetColumn"
          :cell-style="cellStyle">
        </avue-crud>
      </trade-card>
    </div>
  </div>
</template>

<script>
import tableOption from "./config/customerContact.json";
export default {
  name: "detailsPageEdit",
  data() {
    return {
      show: true,
      treeStyle: "height:" + (window.innerHeight - 315) + "px",
      disabled: false,
      tableOption: {},
      data: [],
    };
  },
  props: {
    detailData: {
      type: Object
    }
  },
  async created() {
    if (this.detailData.id) {
      this.getDetail(this.detailData.id);
    }
    this.tableOption = await this.getColumnData(
      this.getColumnName(179.1),
      tableOption
    );

  },
  methods: {
    cellStyle() {
      return "padding:0;height:40px;";
    },
    getDetail(id) {
      this.loading = true;
      this.pageLoading = true;
    },
    //返回列表
    backToList() {
      this.$emit("goBack");
    },
    openEdit() {
      this.detailData.status = 2;
      this.option = this.$options.data().option;
      this.$refs.crud.refreshTable();
    },
    async saveColumn() {
      const inSave = await this.saveColumnData(
        this.getColumnName(179.1),
        this.tableOption
      );
      if (inSave) {
        this.$nextTick(() => {
          this.$refs.crud.doLayout();
        });
        this.$message.success("保存成功");
        //关闭窗口
        this.$refs.crud.$refs.dialogColumn.columnBox = false;
      }
    },
    async resetColumn() {
      this.tableOption = tableOption;
      const inSave = await this.delColumnData(
        this.getColumnName(179.1),
        tableOption
      );
      if (inSave) {
        this.$nextTick(() => {
          this.$refs.crud.doLayout();
        });
        this.$message.success("重置成功");
        //关闭窗口
        setTimeout(() => {
          this.$refs.crud.$refs.dialogColumn.columnBox = false;
        }, 1000);
      }
    }
  },
  watch: {
  }
};
</script>

<style lang="scss" scoped>
.trading-form ::v-deep .el-form-item {
  margin-bottom: 8px !important;
}

::v-deep .el-form-item__error {
  display: none !important;
}

::v-deep .select-component {
  display: flex !important;
}
</style>
