<template>
  <!-- 中日程计划查询 -->
  <el-container>
    <el-header style="width: 100%">
      <el-row>
        <el-col :span="18">
          <el-col :span="4">
            <el-select v-model="request.dcCh" placeholder="船号" clearable>
              <el-option
                v-for="item in ShipNoList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-col>
        </el-col>
        <el-col :span="6" style="text-align: right">
          <el-button type="primary" @click="initList()">查询</el-button>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="18">
          <el-col :span="4">
            <el-select v-model="request.Zt" placeholder="状态" clearable>
              <el-option
                v-for="item in statusOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-col>
        </el-col>
      </el-row>
    </el-header>
    <el-container style="padding-top: 10px">
      <el-container>
        <el-main>
          <div class="mytable">
            <vxe-grid
              id="id"
              ref="tableRef"
              border
              resizable
              keep-source
              :height="height"
              :auto-resize="true"
              :columns="tableColumn"
              :data="list"
              :custom-config="{ storage: true }"
              highlight-hover-row
            >
              <template #dcCh_default="{ row }">
                {{ row.dcCh }}
              </template>
              <template #Zt_default="{ row }">
                <div v-for="(item, index) in statusOptions" :key="index">
                  <div v-if="row.zt === item.value">{{ item.label }}</div>
                </div>
              </template>
            </vxe-grid>
          </div>
        </el-main>
      </el-container>
    </el-container>
  </el-container>
</template>

<script>
import { getList } from "@/api/jhzx/zrcCX";
export default {
  name: "zrcCX",
  data() {
    return {
      request: {
        dcCh: "",
        Zt: "",
      },
      list: [],
      height: "500px",
      tableColumn: [
        { type: "seq", width: 60, title: "序号" },
        {
          field: "dcCh",
          title: "船号",
          slots: { default: "dcCh_default" },
          minWidth: "70",
        },
        {
          field: "qy",
          title: "区域",
          minWidth: "70",
        },
        {
          field: "zdh",
          title: "总段号",
          minWidth: "70",
        },
        {
          field: "yzd",
          title: "预组段",
          minWidth: "70",
        },
        {
          field: "dcFD",
          title: "分段号",
          minWidth: "70",
        },
        {
          field: "ZL",
          title: "重量",
          minWidth: "70",
        },
        {
          field: "dcPL",
          title: "批量号",
          minWidth: "70",
        },
        {
          field: "kssjDz",
          title: "大组开始",
          minWidth: "70",
        },
        {
          field: "gjjsDz",
          title: "钢加大组结束",

          minWidth: "120",
        },
        {
          field: "jssjXz",
          title: "小组结束",
          minWidth: "70",
        },
        {
          field: "xzzq",
          title: "小组周期",
          minWidth: "70",
        },
        {
          field: "kssjXz",
          title: "小组开始",
          minWidth: "70",
        },
        {
          field: "xbzl",
          title: "线表重量",
          minWidth: "70",
        },
        {
          field: "gjjsDzPl",
          title: "批量表（钢加大组结束）",
          minWidth: "120",
        },
        {
          field: "LP",
          title: "时间差（L-P）",
          minWidth: "120",
        },
        {
          field: "gjjsXz",
          title: "钢加小组结束",
          minWidth: "120",
        },
        {
          field: "gjjsXzPl",
          title: "批量表（钢加小组结束）",
          minWidth: "120",
        },
        {
          field: "RS",
          title: "时间差（R-S）",
          minWidth: "120",
        },
        {
          field: "gjks",
          title: "钢加开始",
          minWidth: "70",
        },
        {
          field: "gjksPl",
          title: "批量表（钢加开始）",
          minWidth: "120",
        },
        {
          field: "UV",
          title: "时间差（U-V）",
          minWidth: "90",
        },
        {
          field: "xfqTlt",
          title: "套料图下发",
          minWidth: "90",
        },
        {
          field: "jsqTlt",
          title: "套料图接收",
          minWidth: "90",
        },
        {
          field: "xfqLqb",
          title: "板材领取表下发",
          minWidth: "120",
        },
        {
          field: "jsqLqb",
          title: "板材领取表接收",
          minWidth: "90",
        },
        {
          field: "xfqPtb",
          title: "零件配套表下发",
          minWidth: "120",
        },
        {
          field: "jsqPtb",
          title: "零件配套表接收",
          minWidth: "90",
        },
        {
          field: "dhqd",
          title: "订货清单号",
          minWidth: "90",
        },
        {
          field: "xfqDhqd",
          title: "订货清单下发",
          minWidth: "90",
        },
        {
          field: "sjdhq",
          title: "实际订货日期",
          minWidth: "90",
        },
        {
          field: "bcdq",
          title: "板材计划到齐",
          minWidth: "90",
        },
        {
          field: "Zt",
          title: "状态",
          slots: { default: "Zt_default" },
          minWidth: "50",
        },
      ],
      statusOptions: [
        {
          value: "0",
          label: "编辑",
        },
        {
          value: "1",
          label: "提交",
        },
        {
          value: "2",
          label: "审核",
        },
      ],
      ShipNoList: [],
      checkedList: [],
    };
  },
  created() {
    window.addEventListener("resize", this.getHeight);
    this.getHeight();
    this.initList();
  },
  methods: {
    // 获取列表接口(船号)
    initList() {
      let params = {
        Zt: this.request.Zt,
        dcCh: "",
      };
      if (this.ShipNoList.length > 0 && this.request.dcCh) {
        params.dcCh = this.ShipNoList[this.request.dcCh - 1].label;
      } else {
        params.dcCh = "";
      }
      getList(params).then((res) => {
        this.list = res.data;
        this.ShipNoList = [];
        var arrList = [];
        if (this.list.length > 0) {
          this.list.forEach((item, index) => {
            arrList.push(item.dcCh);
            this.ShipNoList = [];
            Array.from(new Set(arrList)).forEach((em, eindex) => {
              this.ShipNoList.push({
                label: em,
                value: eindex + 1,
              });
            });
          });
        }
      });
    },
    getHeight() {
      this.height = window.innerHeight - 160;
    },
  },
};
</script>
<style lang="scss" scoped>
.el-header {
  margin: 0;
  padding: 5px 0;
  height: auto;
}
.el-container {
  padding: 0;
  margin: 0;
}
.el-main {
  padding: 0;
}
.el-col {
  padding: 0;
}
.el-aside {
  background: #fff;
  padding: 0;
}
.el-container {
  padding: 0;
}
.el-row {
  margin-bottom: 5px;
}
.el-row:last-child {
  margin-bottom: 0;
}
.tableStyles {
  background: #0a76a4;
}
.my-dropdown {
  width: 450px;
  height: 250px;
  background-color: #fff;
  border: 1px solid #dcdfe6;
  box-shadow: 0 0 6px 2px rgba(0, 0, 0, 0.1);
  font-size: 12px;
}
::v-deep .mytable .vxe-input {
  display: flex !important;
}
</style>
