<template>
  <div class="OrderSync">
    <div class="page-head">
      <div class="page-title">同步销售订单</div>
      <div class="head-btn">
        <el-button size="mini" @click="onGoBack">返回</el-button>
        <el-button type="primary" size="mini" :loading="loading" @click="onEdit">提交</el-button>
      </div>
    </div>
    <div class="page-body">
      <el-form :model="sapInfo" label-width="120px" size="mini">
        <el-row :gutter="10">
          <el-col :span="6">
            <el-form-item label="销售凭证">
              <el-input v-model="sapInfo.VBELN" placeholder="" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="销售凭证类型" required>
              <el-input v-model="sapInfo.AUART" placeholder="" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="销售组织" required>
              <el-input v-model="sapInfo.VKORG" placeholder="" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="分销渠道" required>
              <el-input v-model="sapInfo.VTWEG" placeholder="" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="产品组" required>
              <el-input v-model="sapInfo.SPART" placeholder="" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="订单原因">
              <el-input v-model="sapInfo.AUGRU" placeholder="" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="销售办事处">
              <el-input v-model="sapInfo.VKBUR" placeholder="" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="销售组">
              <el-input v-model="sapInfo.VKGRP" placeholder="" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="客户编号">
              <el-input v-model="sapInfo.KUNNR" placeholder="" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="客户参考">
              <el-input v-model="sapInfo.BSTNK" placeholder="" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="要求的交货日期">
              <el-input v-model="sapInfo.VDATU" placeholder="" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="客户参考日期">
              <el-input v-model="sapInfo.BSTDK" placeholder="" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="国际贸易条款">
              <el-input v-model="sapInfo.INCO1" placeholder="" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="国际贸易位置">
              <el-input v-model="sapInfo.INCO2" placeholder="" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="付款条件代码">
              <el-input v-model="sapInfo.ZTERM" placeholder="" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="记录创建日期">
              <el-input v-model="sapInfo.ERDAT" placeholder="" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="备注">
              <el-input v-model="sapInfo.LTEXT" placeholder="" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="跟单员">
              <el-input v-model="sapInfo.ZKUNR" placeholder="" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="生产发货方式">
              <el-input v-model="sapInfo.ZF14" placeholder="" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="条码">
              <el-input v-model="sapInfo.ZBARDE" placeholder="" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="申购号">
              <el-input v-model="sapInfo.ZPONUM" placeholder="" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="款式">
              <el-input v-model="sapInfo.ZSTYLE" placeholder="" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="OSP订单号">
              <el-input v-model="sapInfo.ZOSP" placeholder="" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="交货冻结">
              <el-input v-model="sapInfo.LIFSK" placeholder="" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="开票冻结">
              <el-input v-model="sapInfo.FAKSK" placeholder="" clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="更新标识">
              <el-input v-model="sapInfo.UPDKZ" placeholder="" clearable/>
            </el-form-item>
           </el-col>
        </el-row>
      </el-form>

      <el-table :data="sapInfo.ITEM" max-height="800px" size="mini">
        <el-table-column min-width="150" label="销售凭证项目" prop="POSNR"><template slot-scope="{row}"><el-input v-model=row.POSNR placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="物料编号" prop="MATNR"><template slot-scope="{row}"><el-input v-model=row.MATNR placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="工厂" prop="WERKS"><template slot-scope="{row}"><el-input v-model=row.WERKS placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="以销售单位表示的累计订购数量" prop="KWMENG"><template slot-scope="{row}"><el-input v-model=row.KWMENG placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="客户物料编号" prop="KDMAT"><template slot-scope="{row}"><el-input v-model=row.KDMAT placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="客户物料名称" prop="ARKTX"><template slot-scope="{row}"><el-input v-model=row.ARKTX placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="折扣率（Z001的金额）" prop="NETPR"><template slot-scope="{row}"><el-input v-model=row.NETPR placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="装运点/收货点" prop="VSTEL"><template slot-scope="{row}"><el-input v-model=row.VSTEL placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="存储地点" prop="LGORT"><template slot-scope="{row}"><el-input v-model=row.LGORT placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="批次编号" prop="CHARG"><template slot-scope="{row}"><el-input v-model=row.CHARG placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="计划行日期" prop="EDATU"><template slot-scope="{row}"><el-input v-model=row.EDATU placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="拒绝原因" prop="ABGRU"><template slot-scope="{row}"><el-input v-model=row.ABGRU placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="工厂单价（PR01的金额）" prop="NETWR"><template slot-scope="{row}"><el-input v-model=row.NETWR placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="订单行折前总金额（Z002的定价值）" prop="KWERT"><template slot-scope="{row}"><el-input v-model=row.KWERT placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="定价单位" prop="KPEIN"><template slot-scope="{row}"><el-input v-model=row.KPEIN placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="货币" prop="KOEIN"><template slot-scope="{row}"><el-input v-model=row.KOEIN placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="尺码组" prop="ZSIZEGROUP"><template slot-scope="{row}"><el-input v-model=row.ZSIZEGROUP placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="尺码单位（客户）" prop="ZSIZEUNITC"><template slot-scope="{row}"><el-input v-model=row.ZSIZEUNITC placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="指令号" prop="ZINSTNUM"><template slot-scope="{row}"><el-input v-model=row.ZINSTNUM placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="型体号" prop="ZMOLD"><template slot-scope="{row}"><el-input v-model=row.ZMOLD placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="配色号" prop="ZMAPCOLOR"><template slot-scope="{row}"><el-input v-model=row.ZMAPCOLOR placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="颜色" prop="ZCLOLOR"><template slot-scope="{row}"><el-input v-model=row.ZCLOLOR placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="销线" prop="ZSALEAREA"><template slot-scope="{row}"><el-input v-model=row.ZSALEAREA placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="段别" prop="ZDUANBIE"><template slot-scope="{row}"><el-input v-model=row.ZDUANBIE placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="季度" prop="ZSEASON"><template slot-scope="{row}"><el-input v-model=row.ZSEASON placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="整/半码" prop="ZTOTALSIZE"><template slot-scope="{row}"><el-input v-model=row.ZTOTALSIZE placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="特殊SIZE" prop="ZSPECSIZE"><template slot-scope="{row}"><el-input v-model=row.ZSPECSIZE placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="PO#" prop="ZCPONUM"><template slot-scope="{row}"><el-input v-model=row.ZCPONUM placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="WIP#" prop="ZWIPNUM"><template slot-scope="{row}"><el-input v-model=row.ZWIPNUM placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="装箱数" prop="ZBOXQUAN"><template slot-scope="{row}"><el-input v-model=row.ZBOXQUAN placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="产地" prop="ZORIGIN"><template slot-scope="{row}"><el-input v-model=row.ZORIGIN placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="周期" prop="ZCYCLE"><template slot-scope="{row}"><el-input v-model=row.ZCYCLE placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="SK编号" prop="ZSKCODE"><template slot-scope="{row}"><el-input v-model=row.ZSKCODE placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="专利号" prop="ZPATENTCODE"><template slot-scope="{row}"><el-input v-model=row.ZPATENTCODE placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="材质描述" prop="ZMATERIALDES"><template slot-scope="{row}"><el-input v-model=row.ZMATERIALDES placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="签收人" prop="ZSIGNPERSON"><template slot-scope="{row}"><el-input v-model=row.ZSIGNPERSON placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="SHIP TO ID" prop="ZSHIPID"><template slot-scope="{row}"><el-input v-model=row.ZSHIPID placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="产品规格" prop="ZPRODSPEC"><template slot-scope="{row}"><el-input v-model=row.ZPRODSPEC placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="产品用途" prop="ZPRODUSAGE"><template slot-scope="{row}"><el-input v-model=row.ZPRODUSAGE placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="厚度（丝）" prop="ZTHICK"><template slot-scope="{row}"><el-input v-model=row.ZTHICK placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="包装方式" prop="ZPACKINGMOT"><template slot-scope="{row}"><el-input v-model=row.ZPACKINGMOT placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="印刷方向" prop="ZPRINTDIRECT"><template slot-scope="{row}"><el-input v-model=row.ZPRINTDIRECT placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="工厂代号" prop="ZPLANTCODE"><template slot-scope="{row}"><el-input v-model=row.ZPLANTCODE placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="指令数(客户)汇总" prop="ZINCSUM"><template slot-scope="{row}"><el-input v-model=row.ZINCSUM placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="LOSS数(客户)汇总" prop="ZLOSSUM"><template slot-scope="{row}"><el-input v-model=row.ZLOSSUM placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="SIZE 序号" prop="SIZE.0.ZSIZE_NUM"><template slot-scope="{row}"><el-input v-model=row.SIZE[0].ZSIZE_NUM placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="尺码" prop="SIZE.0.ZSIZE"><template slot-scope="{row}"><el-input v-model=row.SIZE[0].ZSIZE placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="指令数(客户)" prop="SIZE.0.ZINSNUM"><template slot-scope="{row}"><el-input v-model=row.SIZE[0].ZINSNUM placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="LOSS数(客户)" prop="SIZE.0.ZLOSSC"><template slot-scope="{row}"><el-input v-model=row.SIZE[0].ZLOSSC placeholder=""/></template></el-table-column>
        <el-table-column min-width="150" label="尺码备注" prop="SIZE.0.ZSIZECOM"><template slot-scope="{row}"><el-input v-model=row.SIZE[0].ZSIZECOM placeholder=""/></template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>

import { getSapInfo, syncSapData } from '@/api/mes/od/salesOrder'

export default {
  data() {
    return {
      loading: false,
      sapInfo: {
        ITEM: []
      }
    }
  },
  methods: {
    onEdit() {
      this.$confirm("确定同步该条数据记录").then(() => {
        syncSapData(this.sapInfo).then(res => res)
      })
    },

    onGoBack() {
      this.$store.dispatch('tagsView/delView', this.$router.currentRoute)
      this.$router.push('/order/sales')
    },
    onGetSapInfo() {
      let id = this.$route.query.id
      if (id) getSapInfo(id).then(res => this.sapInfo = JSON.parse(res.data))
    },
  },
  created() {
    this.onGetSapInfo()
  }
}
</script>

<style scoped>
.page-head {
  border-bottom: 1px solid #dddddd;
  box-shadow: 0 2px 2px #dddddd;
}

.page-title {
  line-height: 50px;
  text-align: center;
  font-size: 18px;
  font-weight: bold;
}

.head-btn {
  margin: 0 20px 20px;
}

.page-body {
  margin: 20px 20px 100px;
}
</style>
