<template>
  <div class="app-container">
    <div v-show="viewState == 1">
      <div class="tab-header webtop">
        <!-- 标题 -->
        <div>采购订单详情</div>
        <!-- start 添加修改按钮 -->
        <div>
          <el-button type="info" size="small" @click="handleReturn()">关闭</el-button>
        </div>
        <!-- end 添加修改按钮 -->
        <!-- end 详情按钮 -->
      </div>

      <div class="listconadd">

        <el-form ref="form_obj" :model="formobj" class="formaddcopy02">
          <!-- <div class="title">
          <div>基础信息</div>
        </div> -->
          <el-row class="first_row">

            <el-col :span="8">
              <div class="span-sty">制单人</div>
              <el-form-item><span class="addinputInfo">{{ formobj.createByName }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">制单部门</div>
              <el-form-item><span class="addinputInfo">{{ formobj.deptName }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">制单日期</div>
              <el-form-item><span class="addinputInfo">{{ formobj.createTime }}</span></el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="8">

              <div class="span-sty">供应商</div>
              <el-form-item><span class="addinputInfo">{{ formobj.supplierName }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">收货仓库</div>
              <el-form-item><span class="addinputInfo">{{ formobj.wareHouseName }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">业务员</div>
              <el-form-item><span class="addinputInfo">{{ formobj.purchaserName }}</span></el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="16">
              <div class="span-sty">银行账号</div>
              <el-form-item><span
                  class="addinputInfo">{{ formobj.purchaseBillAmount.bankAccount }}</span></el-form-item>

            </el-col>
            <el-col :span="8">
              <div class="span-sty">货币类别</div>
              <el-form-item><span
                  class="addinputInfo">{{ formobj.purchaseBillAmount.currencyValue }}</span></el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <div class="span-sty">备注</div>
              <el-form-item><span class="addinputInfo">{{ formobj.remarks }}</span></el-form-item>
            </el-col>
          </el-row>

          <div class="title titleOne" style="margin-top: 10px;">
            <div>商品列表</div>
          </div>
          <el-table v-loading="listLoading" :data="formobj.purchaseBillDetailList" border style="width: 100%;">
            <el-table-column fixed width="80" label="序号" type="index" :index="indexMethod" align="center" />
            <el-table-column label="商品编码" prop="goodsSkuCode" width="150" align="center" />
            <el-table-column label="商品名称" prop="goodsSkuTitle" width="150" align="center" />
            <el-table-column label="商品规格" prop="goodsSkuOwnSpec" width="150" align="center" />
            <el-table-column label="单位" prop="unit" width="120" align="center" />
            <el-table-column prop="count" label="采购数量" width="120" align="center" />
            <el-table-column label="数量(pcs)" prop="pcsCount" align="center" width="150" />
            <el-table-column label="吊牌价" prop="tagPrice" width="120" align="center" />
            <el-table-column label="单价" prop="cost" width="120" align="center" />
            <el-table-column prop="discountRate" label="折扣率(%)" width="120" align="center" />
            <el-table-column prop="discountPrice" label="折扣单价" width="120" align="center" />
            <el-table-column prop="shareAmount" label="分摊金额" width="150" align="center" />
            <el-table-column prop="amount" label="总价" width="120" align="center" />
            <el-table-column prop="taxRate" label="税率" width="120" align="center" />
            <el-table-column prop="unTaxPrice" label="未含税价" width="120" align="center" />
            <el-table-column prop="taxAmount" label="总税额" width="120" align="center" />
            <el-table-column prop="unTaxTotalAmount" label="未含总税价" width="120" align="center" />
            <el-table-column prop="cycle" label="采购周期" width="120" align="center" />
            <el-table-column prop="deliveryDate" label="预计到货日期" width="180" align="center" />
            <el-table-column prop="madeDate" label="生产日期" width="180" align="center" />
            <el-table-column prop="expireDate" label="过期日期" width="120" align="center" />
            <el-table-column prop="batchNumber" label="批次号" width="200" align="center" />
            <el-table-column prop="goodsNum" label="货号" width="120" align="center" />
            <el-table-column prop="remarks" label="备注" width="120" align="center" />
          </el-table>
          <el-row class="first_row" style="margin-top: 10px;">
            <el-col :span="8">
              <div class="span-sty">采购运费</div>
              <el-form-item><span class="addinputInfo">{{ formobj.purchaseBillAmount.freight }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">运费分摊方式</div>
              <el-form-item><span
                  class="addinputInfo">{{ formobj.purchaseBillAmount.freightShareTypeValue }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">结算账户</div>
              <el-form-item><span
                  class="addinputInfo">{{ formobj.purchaseBillAmount.settleAccountValue }}</span></el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="8">
              <div class="span-sty">其他费用</div>
              <el-form-item><span
                  class="addinputInfo">{{ formobj.purchaseBillAmount.otherAmountName }}</span></el-form-item>

            </el-col>
            <el-col :span="8">
              <div class="span-sty">其他费用分摊方式</div>
              <el-form-item><span
                  class="addinputInfo">{{ formobj.purchaseBillAmount.otherShareTypeValue }}</span></el-form-item>
            </el-col>
            <el-col :span="8">
              <div class="span-sty">预付金额</div>
              <el-form-item><span class="addinputInfo">{{ formobj.purchaseBillAmount.prepayment }}</span></el-form-item>
            </el-col>
          </el-row>
          <el-row>

            <el-col :span="24">
              <div class="span-sty">附件</div>
              <el-form-item><el-image class="addinputInfo" style="width: 150px;height: 150px"
                  v-for="(item, index) in formobj.purchaseAppendixList" :key="index" :src="item.url"
                  :preview-src-list="formobj.purchaseAppendixList" /></el-form-item>
            </el-col>

          </el-row>

        </el-form>

      </div>
    </div>
  </div>
</template>

<script>
  import req from '@/api/purchase/purchaseOrder.js'
  export default {
    components: {},
    data() {
      return {
        viewState: 1,
        listLoading: false,
        formobj: {
          purchaseBillAmount: {}
        },
      }
    },
    created() {

    },
    methods: {

      indexMethod(index) {
        return index + 1
      },

      showAdd(row) {
        req.fetchDetailsBySid(row.sid).then((resp) => {
          if (resp.success) {
            this.formobj = resp.data
          } else {
            this.$message({
              type: 'warning',
              message: "数据异常。",
              showClose: true
            })
          }
        }).catch(() => {
          this.$message({
            type: 'warning',
            message: "数据异常。",
            showClose: true
          })
        })

      },
      handleReturn() {
        this.$emit('doback')
      },

    }
  }
</script>
<style scoped>
  /deep/ .el-form-item__error {
    margin-left: 120px !important;
  }

  .must {
    color: #f00;
  }

  .span-sty {
    width: 130px !important;
  }

  .addinputInfo {
    margin-left: 120px !important;
  }

  .formaddcopy02 .el-row .el-col /deep/ .el-form-item .addinputw {
    margin-left: 120px !important;
    width: calc(100% - 115px);
  }

  .first_row {
    border-top: 1px solid #E0E3EB;
  }

  .titleOne {
    padding: 7px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
</style>
