<template>
  <div class="detail-container">
    <el-page-header @back="goBack" content="详情"></el-page-header>

    <div id="printData">
      <div class="main-title">
        <div class="title">工程订单</div>
      </div>

      <div class="diy-table-1">
        <el-row>
          <el-col :span="8" class="item">
            <div class="label">发货申请单号</div>
            <div class="value">{{detailData.billNo}}</div>
          </el-col>
          <el-col :span="8" class="item">
            <div class="label">申请日期</div>
            <div class="value">{{detailData.fdate}}</div>
          </el-col>
          <el-col :span="8" class="item">
            <div class="label">单据状态</div>
            <div class="value">{{detailData.srcStockId}}</div>
          </el-col>
          <el-col :span="8" class="item">
            <div class="label">经销商编号</div>
            <div class="value">{{detailData.destStockId}}</div>
          </el-col>
          <el-col :span="8" class="item">
            <div class="label">经销商名称</div>
            <div class="value">{{detailData.approveDate}}</div>
          </el-col>
          <el-col :span="8" class="item">
            <div class="label">仓库</div>
            <div class="value">{{detailData.approverId}}</div>
          </el-col>
          <el-col :span="8" class="item">
            <div class="label">工程登录编码</div>
            <div class="value">{{detailData.approverId}}</div>
          </el-col>
          <el-col :span="8" class="item">
            <div class="label">制单人</div>
            <div class="value">{{detailData.approverId}}</div>
          </el-col>
          <el-col :span="8" class="item">
            <div class="label">制单日期</div>
            <div class="value">{{detailData.approverId}}</div>
          </el-col>
          <el-col :span="24" class="item">
            <div class="label">备注</div>
            <div class="value">{{detailData.approverId}}</div>
          </el-col>
          <el-col :span="12" class="item">
            <div class="label">审核人</div>
            <div class="value">{{detailData.approverId}}</div>
          </el-col>
          <el-col :span="12" class="item">
            <div class="label">审核日期</div>
            <div class="value">{{detailData.approverId}}</div>
          </el-col>
          <el-col :span="24" class="item">
            <div class="label">审批说明</div>
            <div class="value">{{detailData.approverId}}</div>
          </el-col>
        </el-row>
      </div>

      <div class="main-title">
        <div class="title">货品信息</div>
      </div>

      <div class="table" style="margin-top: 20px">
        <el-table :data="detailData.kingDeeTransferItems" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400">
          <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
          <el-table-column align="center" label="引用单号" prop="materialNumber" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="单号类型" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="销售类型" prop="model" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="货品名称" prop="baseUnitId" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="规格型号" prop="qty" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="计量单位" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="数量" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="备注" prop="qty" min-width="160" show-overflow-tooltip></el-table-column>
        </el-table>
      </div>

      <div class="main-title">
        <div class="title">审批记录</div>
      </div>
      <div class="diy-table-1">
        <el-row :gutter="0">
          <el-col :span="12" class="item">
            <div class="label">审批人</div>
            <div class="value">2022123233435342</div>
          </el-col>
          <el-col :span="12" class="item">
            <div class="label">审批结果</div>
            <div class="value">2022123233435342</div>
          </el-col>
          <el-col :span="24" class="item">
            <div class="label">审批说明</div>
            <div class="value">2022123233435342</div>
          </el-col>
        </el-row>
      </div>
      
    </div>
    
    <div class="page-footer">
      <div class="footer" :class="classObj">
        <el-button  type="primary" @click="openDeliverDialog">直调发货</el-button>
        <el-popconfirm title="确定关闭吗？" @onConfirm="goBack" style="margin-left: 10px;">
          <el-button slot="reference">关 闭</el-button>
        </el-popconfirm>
      </div>
    </div>

    <el-dialog
      title="直调发货"
      :visible.sync="isShowDeliverDialog"
      width="80%">
      <el-form ref="deliverForm" :model="deliverForm" label-width="70px" size="small" label-position="left">
        <el-row :gutter="20">
          <el-col :xs="24" :sm="8" :lg="8">
            <el-form-item label="工程订单" prop="orderNum">
              <el-input v-model="deliverForm.orderNum" placeholder="请输入工程订单"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="8" :lg="8" style="height: 51px;">
            <el-form-item label="发货日期" prop="date">
              <el-date-picker
                v-model="deliverForm.date"
                type="date"
                value-format="yyyy-MM-dd"
                style="width: 100%;"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="8" :lg="8">
            <el-form-item label="发货仓库" prop="warehouse">
              <el-select v-model="deliverForm.warehouse" placeholder="请选择发货仓库">
                <el-option
                  v-for="item in warehouseList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <div class="table" style="margin-top: 20px">
        <el-table :data="detailData.kingDeeTransferItems" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400">
          <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
          <el-table-column align="center" label="引用记录" prop="materialNumber" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="销售类型" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="产品编码" prop="model" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="产品名称" prop="baseUnitId" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="规格型号" prop="qty" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="单位" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="总数量" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="是否使用返利" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="返利使用比例" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="是否直调" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="直调数量" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="已发货数量" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="单价" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="金额" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="返利" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="备注" prop="qty" min-width="160" show-overflow-tooltip></el-table-column>
        </el-table>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="closeDeliverDialog">取 消</el-button>
        <el-button type="primary" @click="submitDeliverForm">确 定</el-button>
      </span>
    </el-dialog>

  </div>
</template>

<script>
import print from 'vue-print-nb'
import { getDetail } from "@/api/supply/reserve";

export default {
  name: 'CommerceDetail',
  componentName: 'CommerceDetail',
  props: ['listItem'],
  directives: {
    print
  },
  data() {
    return {
      printObj: {
        id: 'printData'
      },
      detailData: {},

      isShowDeliverDialog: false,
      deliverForm: {
        orderNum: '',
        date: '',
      },
      warehouseList: [],
    }
  },

  computed: {
    sidebar() {
      return this.$store.state.app.sidebar
    },
    classObj() {
      return {
        hideSidebar: !this.sidebar.opened,
        openSidebar: this.sidebar.opened
      }
    },
  },

  created() {
    this.getDetail();
  },

  methods: {
    // 返回列表
    goBack() {
      this.$emit('backListFormDetail');
    },

    // 获取详情
    getDetail() {
      getDetail({id: this.listItem.id}).then(res => {
        this.detailData = res.data;
      })
    },

    // 打开 直调发货
    openDeliverDialog() {
      this.isShowDeliverDialog = true;
    },

    // 关闭 直调发货
    closeDeliverDialog() {
      this.isShowDeliverDialog = false;
    },

    // 提交 直调发货
    submitDeliverForm() {

    },

  }
}
</script>

<style scoped lang="scss">
  .detail-container {
    width: 100%;
    height: 100%;
  }
  .main-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    height: 60px;
    border-bottom: 1px solid #DCDFE6;
    margin-bottom: 20px;
    .title {
      font-size: 16px;
      font-weight: 600;
      padding-left: 10px;
    }
  }
</style>