<template>
  <div>
    <div>
      <el-page-header @back="goBack" content="审批"> </el-page-header>
    </div>
    <br />
    <br />
    <div>
      <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"
                min-width="160"
                :formatter="formatterType"
                show-overflow-tooltip
              >
              </el-table-column>
              <el-table-column
                align="center"
                label="物料编码"
                prop="materialId"
                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="small" :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="small" :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" v-if="scope.row.isPublish">是</el-tag>
                  <el-tag type="danger" v-else>否</el-tag>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
        <el-row>
          <el-col :xs="24" :sm="24" :lg="24">
            <h3>审批</h3>
            <hr />
          </el-col>
        </el-row>
        <div class="diy-table-1">
          <el-row :gutter="0">
            <el-col :xs="12" :sm="12" :lg="12" class="item">
              <div class="label">审批人</div>
              <div class="value">{{ this.$store.getters.name }}</div>
            </el-col>
            <el-col :xs="12" :sm="12" :lg="12" class="item">
              <div class="label">审批结果</div>
              <div class="value">
                <el-radio-group v-model="radio">
                  <el-radio label="OK">通过</el-radio>
                  <el-radio label="FAIL">驳回</el-radio>
                </el-radio-group>
              </div>
            </el-col>
            <el-col :xs="24" :sm="24" :lg="24" class="item">
              <div class="label">审批说明</div>
              <div class="value">
                <el-input v-model="detail.examineNote" size="small"></el-input>
              </div>
            </el-col>
          </el-row>
        </div>
        <br />
        <div class="btn-group clearfix">
          <div class="fl">
            <el-button type="primary" size="small" @click="onSubmit">提交审批</el-button>
            <!-- <el-button type="primary" size="small" @click="resetScreenForm"
              >重置</el-button
            > -->
          </div>
        </div>
      </el-form>
    </div>
  </div>
</template>

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

export default {
  // mixins: [Mixin],
  props: {
    detail: {
      type: Object,
      default: {}
    }
  },
  data() {
    return {
      radio: 'OK',
      dataList: [],
      typeList: [],
      userList: [],
      men: '',
      ren: ''
    }
  },

  created() {
    let params = {
      pageNum: 1,
      pageSize: -1,
      saleCode: '',
      saleName: '',
      status: ''
    }
    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
    })
  },
  methods: {
    formatterType(row) {
      return this.typeList.filter(k => {
        return k.id == row.saleTypeId
      })[0]?.saleName
    },
    goBack() {
      // console.log(this.$parent)
      // this.$parent.show = 1
      this.$emit('back')
    },
    onSubmit() {
      const params = {
        ids: this.detail.updPriceBillId,
        examineNote: this.detail.examineNote,
        examineStatus: this.radio
      }

      getProductRriceConfirm(params).then(res => {
        this.$successMsg('已提交审核')
        // this.$parent.show = 1
        // this.$parent.getList()
        this.goBack()
      })
    },
    resetScreenForm() {
      this.detail = {}
    }
  }
}
</script>

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