<template>
  <div>
    <div>
      <el-page-header @back="goBack" content="详情"> </el-page-header>
    </div>
    <div style="margin-top: 20px">
      <el-form ref="screenForm" :model="detail" label-width="120px" size="small" label-position="left">
        <el-row :gutter="20">
          <el-col :xs="24" :sm="12" :lg="6">
            <el-form-item label="单据编号" prop="billId">
              <el-input placeholder="系统生成" disabled v-model="detail.updPriceBillId"></el-input>
            </el-form-item>
          </el-col>

          <el-col :xs="24" :sm="12" :lg="6">
            <el-form-item label="调价部门" prop="account">
              <el-input placeholder="系统生成" v-model="detail.adminWebsitName" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :lg="6">
            <el-form-item label="调价业务员" prop="operatorName">
              <el-input disabled placeholder="系统生成" v-model="detail.serviceName"></el-input>
            </el-form-item>
          </el-col>

          <el-col :xs="24" :sm="12" :lg="6">
            <el-form-item label="备注" prop="operatorName">
              <el-input disabled placeholder="系统生成" v-model="detail.remark"></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <div class="mymain-container">
          <!-- 列表 -->
          <div class="table">
            <el-table :data="detail.items" element-loading-text="Loading" border fit highlight-current-row stripe>
              <el-table-column
                align="center"
                label="销售类型"
                prop="saleTypeId"
                :formatter="formatterType"
                min-width="160"
                show-overflow-tooltip
              ></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="specification"
                min-width="160"
                show-overflow-tooltip
              ></el-table-column>
              <el-table-column
                align="center"
                label="计量单位"
                prop="unit"
                min-width="160"
                show-overflow-tooltip
              ></el-table-column>
              <el-table-column
                align="center"
                label="批发价"
                prop="batchPrice"
                min-width="160"
                show-overflow-tooltip
              ></el-table-column>
              <el-table-column align="center" label="格力折扣" prop="discAmount" min-width="160" show-overflow-tooltip>
              </el-table-column>
              <el-table-column
                align="center"
                label="返利类型（钱包）"
                prop="wallets2"
                min-width="200"
                show-overflow-tooltip
              >
                <template slot-scope="scope">
                  <template v-for="(item, index) in scope.row.wallets2">
                    <template v-if="item.type === 'REBATE'">
                      <el-tag type="success" style="margin: 0 10px" size="mini" :key="index">
                        {{ item.walletName }}
                      </el-tag>
                    </template>
                  </template>
                </template>
              </el-table-column>
              <el-table-column align="center" label="现金钱包" prop="wallets2" min-width="200" show-overflow-tooltip>
                <template slot-scope="scope">
                  <template v-for="(item, index) in scope.row.wallets2">
                    <template v-if="item.type === 'COMMONLY'">
                      <el-tag type="success" style="margin: 0 10px" size="mini" :key="index">
                        {{ item.walletName }}
                      </el-tag>
                    </template>
                  </template>
                </template>
              </el-table-column>
              <el-table-column align="center" label="生效日期" prop="startDate" min-width="160" show-overflow-tooltip>
              </el-table-column>
              <el-table-column align="center" label="失效日期" prop="endDate" min-width="160" show-overflow-tooltip>
              </el-table-column>
              <!-- <el-table-column
                align="center"
                label="是否促销价"
                prop="isPromote"
                min-width="160"
                show-overflow-tooltip
              >
                <template slot-scope="scope">
                  <el-tag type="success" v-if="scope.row.isPromote">是</el-tag>
                  <el-tag type="danger" v-else>否</el-tag>
                </template>
              </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="isPublish" min-width="160" show-overflow-tooltip>
                <template slot-scope="scope">
                  <el-tag type="success" size="mini" v-if="scope.row.isPublish">是</el-tag>
                  <el-tag type="danger" size="mini" v-else>否</el-tag>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
        <div class="diy-table-1">
          <el-row :gutter="0">
            <el-col :xs="12" :sm="8" :lg="8" class="item">
              <div class="label">审批人</div>
              <div class="value">
                <!-- {{ this.$store.getters.name }} -->
                {{ detail.confirmName }}
              </div>
            </el-col>
            <el-col :xs="12" :sm="8" :lg="8" class="item">
              <div class="label">审批结果</div>
              <div class="value">
                {{ detail.examineStatus == 'OK' ? '通过' : detail.examineStatus == 'FAIL' ? '驳回' : '' }}
              </div>
            </el-col>
            <el-col :xs="12" :sm="8" :lg="8" class="item">
              <div class="label">审批时间</div>
              <div class="value">{{ detail.confirmTime }}</div>
            </el-col>
            <el-col :xs="24" :sm="24" :lg="24" class="item">
              <div class="label">审批说明</div>
              <div class="value">{{ detail.examineNote }}</div>
            </el-col>
          </el-row>
        </div>
      </el-form>
    </div>
  </div>
</template>

<script>
import { getTypeList, getUserList } from '@/api/basic_data/material'

export default {
  props: {
    detail: {
      type: Object,
      default: {}
    }
  },
  data() {
    return {
      dataList: [
        {
          SalesType: '*一票机*',
          code: '23022051775',
          name: '夏之凉变频1',
          model: 'KFR-26GW',
          company: '套',
          wholesale: '2999',
          retail: '2899',
          rebate: '0.8',
          effectiveDate: '2021-11-02',
          expiryDate: '2021-11-02',
          promotion: '否',
          number: '51',
          release: '是'
        }
      ],
      typeList: [],
      userList: [],
      men: '',
      ren: ''
    }
  },
  created() {
    let params = {
      pageNum: 1,
      pageSize: -1,
      saleCode: '',
      saleName: '',
      status: ''
    }
    console.log(this.detail)
    getTypeList(params).then(res => {
      this.typeList = res.data.records
    })
    getUserList({
      pageNum: 1,
      pageSize: -1,
      adminWebsitId: '',
      isCustomer: 0,
      roleId: '',
      status: '',
      userName: ''
    }).then(res => {
      this.userList = res.data.records
      var a = this.userList.filter(k => {
        return k.roleId == this.detail.serviceId
      })[0]
      // this.men = a.adminCompanyName;
      // this.ren = a.nickName;
    })
  },
  methods: {
    formatterType(row) {
      return this.typeList.filter(k => {
        return k.id == row.saleTypeId
      })[0]?.saleName
    },
    goBack() {
      this.$emit('back')
    }
  }
}
</script>

<style lang="scss" scoped>
::v-deep .el-date-editor--date {
  width: 100%;
}
::v-deep .el-select {
  width: 100%;
}
</style>
