<template>
  <div class="app-container">
    <el-descriptions
      class="margin-top"
      :column="2"
      border
      :labelStyle="{
        'text-align': 'left',
        width: '180px',
        height: '50px',
      }"
      :contentStyle="{ minWidth: '350px' }"
    >
      <el-descriptions-item>
        <template slot="label"> 堤防横断面代码 </template>
        {{ this.form.bntrCode }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 测量日期 </template>
        {{ this.form.srDate }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 断面桩号 </template>
        {{ this.form.trCh }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 起始断面位置 </template>
        {{ this.form.intrPl }}
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label"> 起始断面桩号 </template>
        {{ this.form.intrCh }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 至起始断面距离 </template>
        {{ this.form.tointrDs }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 起测点位置 </template>
        {{ this.form.jmsrpnPl }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 起测点高程 </template>
        {{ this.form.jmsrpneLev }}
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label"> 堤身土质 </template>
        {{ this.form.bnbdSlch }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 堤身防渗形式 </template>
        {{ this.form.bnbdAntp }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 堤基地质 </template>
        {{ this.form.bnbsGl }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 堤基防渗形式 </template>
        {{ this.form.bnbsAntp }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 堤身净高度 </template>
        {{ this.form.bnbdHigh }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 堤顶高程 </template>
        {{ this.form.bntpeLev }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 堤顶超高 </template>
        {{ this.form.bntpFr }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 堤顶宽度 </template>
        {{ this.form.bntpWd }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 迎河面堤脚高程 </template>
        {{ this.form.upbnToel }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 背河面堤脚高程 </template>
        {{ this.form.dwbnToel }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 迎河坡坡比 </template>
        {{ this.form.upslSlrt }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 背河坡坡比 </template>
        {{ this.form.dwslSlrt }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 迎河坡护坡情况 </template>
        {{ this.form.uspsIn }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 背河坡护坡情况 </template>
        {{ this.form.dspsIn }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 迎河面滩地宽度 </template>
        {{ this.form.upbtWide }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 迎河面平台(前戗)顶高程 </template>
        {{ this.form.ufrteLev }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 迎河面平台(前戗)顶宽 </template>
        {{ this.form.ufrtWide }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 迎河面平台(前戗)坡度 </template>
        {{ this.form.upflRfsl }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 背河面平台(后戗)顶高程 </template>
        {{ this.form.dfrtEl }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 背河面平台(后戗)顶宽 </template>
        {{ this.form.dfrtWide }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 背河面平台(后戗)坡度 </template>
        {{ this.form.dwflRfsl }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label"> 备注 </template>
        {{ this.form.note }}
      </el-descriptions-item>
    </el-descriptions>
    <!-- <div class="btnList">
      <el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div> -->
  </div>
</template>

<script>
import {
  listHdmtzz,
  getHdmtzz,
  delHdmtzz,
  addHdmtzz,
  updateHdmtzz,
  exportHdmtzz,
} from "@/api/yg/dike/hdmtzz";

export default {
  name: "Hdmtzz",
  props: ["dikeCode"],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 横断面特征值表格数据
      hdmtzzList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        ids: null,
        data: {
          dikeCode: null,
          bntrCode: null,
          srDate: null,
          trCh: null,
          intrPl: null,
          intrCh: null,
          tointrDs: null,
          jmsrpnPl: null,
          jmsrpneLev: null,
          bnbdSlch: null,
          bnbdAntp: null,
          bnbsGl: null,
          bnbsAntp: null,
          bnbdHigh: null,
          bntpeLev: null,
          bntpFr: null,
          bntpWd: null,
          upbnToel: null,
          dwbnToel: null,
          upslSlrt: null,
          dwslSlrt: null,
          uspsIn: null,
          dspsIn: null,
          upbtWide: null,
          ufrteLev: null,
          ufrtWide: null,
          upflRfsl: null,
          dfrtEl: null,
          dfrtWide: null,
          dwflRfsl: null,
          note: null,
          effDate: null,
          exprDate: null,
          createUid: null,
          updateUid: null,
          owerDept: null,
          relation: null,
        },
        // 排序方式
        params: {
          // 按哪个字段排序
          orderBy: "create_time",
          // desc降序，升序asc
          sortBy: "desc",
        },
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询横断面特征值列表 */
    getList() {
      this.queryParams.data.dikeCode = this.dikeCode;
      listHdmtzz(this.queryParams).then((response) => {
        if (response.records[0]) {
          this.form = response.records[0];
        }
      });
    },
    // 取消按钮
    cancel() {
      // this.reset();
      this.$router.back();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        dikeCode: null,
        bntrCode: null,
        srDate: null,
        trCh: null,
        intrPl: null,
        intrCh: null,
        tointrDs: null,
        jmsrpnPl: null,
        jmsrpneLev: null,
        bnbdSlch: null,
        bnbdAntp: null,
        bnbsGl: null,
        bnbsAntp: null,
        bnbdHigh: null,
        bntpeLev: null,
        bntpFr: null,
        bntpWd: null,
        upbnToel: null,
        dwbnToel: null,
        upslSlrt: null,
        dwslSlrt: null,
        uspsIn: null,
        dspsIn: null,
        upbtWide: null,
        ufrteLev: null,
        ufrtWide: null,
        upflRfsl: null,
        dfrtEl: null,
        dfrtWide: null,
        dwflRfsl: null,
        note: null,
        effDate: null,
        exprDate: null,
        createUid: null,
        updateUid: null,
        createTime: null,
        updateTime: null,
        owerDept: null,
        remark: null,
        relation: null,
      };
      this.resetForm("form");
    },
    // 查询表单重置
    resetQueryForm() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
        data: {
          id: null,
          dikeCode: null,
          bntrCode: null,
          srDate: null,
          trCh: null,
          intrPl: null,
          intrCh: null,
          tointrDs: null,
          jmsrpnPl: null,
          jmsrpneLev: null,
          bnbdSlch: null,
          bnbdAntp: null,
          bnbsGl: null,
          bnbsAntp: null,
          bnbdHigh: null,
          bntpeLev: null,
          bntpFr: null,
          bntpWd: null,
          upbnToel: null,
          dwbnToel: null,
          upslSlrt: null,
          dwslSlrt: null,
          uspsIn: null,
          dspsIn: null,
          upbtWide: null,
          ufrteLev: null,
          ufrtWide: null,
          upflRfsl: null,
          dfrtEl: null,
          dfrtWide: null,
          dwflRfsl: null,
          note: null,
          effDate: null,
          exprDate: null,
          createUid: null,
          updateUid: null,
          createTime: null,
          updateTime: null,
          owerDept: null,
          remark: null,
          relation: null,
        },
        // 排序方式
        params: {
          // 按哪个字段排序
          orderBy: "create_time",
          // desc降序，升序asc
          sortBy: "desc",
        },
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetQueryForm();
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加横断面特征值";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getHdmtzz(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改横断面特征值";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updateHdmtzz(this.form).then((response) => {
              if (response.code === 200) {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              }
            });
          } else {
            this.form.dikeCode = this.dikeCode;
            addHdmtzz(this.form).then((response) => {
              if (response.code === 200) {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              }
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      if (ids) {
        this.$confirm("是否删除选中的数据？", "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(function () {
            return delHdmtzz(ids);
          })
          .then(() => {
            this.getList();
            this.msgSuccess("删除成功");
          })
          .catch(function () {});
      } else {
        this.$message.warning("请选择要删除的数据！！");
      }
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      let message = "是否确认导出所有的数据项?";
      if (this.ids) {
        message = "是否确认导出选中的数据项?";
        queryParams.ids = this.ids;
      }
      this.$confirm(message, "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          return exportHdmtzz(queryParams);
        })
        .then((response) => {
          this.downloadFile(response, true, response.msg);
          // this.download(response.msg);
        })
        .catch(function () {});
    },
  },
};
</script>
<style lang="scss" scoped>
.btnList {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1;
}
</style>
