<template>
  <div>
    <el-popover
      placement="top"
      v-model="visible">
      <p  class="mt-10 normal-title">选择评审类型</p>
      <el-select class="mt-10" v-model="value" placeholder="请选择" size="mini">
        <el-option
          v-for="item in options"
          :key="item.value"
          :label="item.value + '-' + item.remarks"
          :value="item.value">
          <span style="float: left">{{ item.value }}</span>
          <span style="float: right; color: #8492a6; font-size: 12px">{{ item.remarks?item.remarks:'暂无描述' }}</span>
        </el-option>
      </el-select>
      <div style="text-align: right; margin: 0">
        <el-button size="mini" type="text" @click="visible = false">取消</el-button>
        <el-button  type="primary" size="mini" @click="confirm">{{ siteId == 'TZ' ? '下一步' : '确定'}}</el-button>
      </div>
      <el-button v-if="tool.checkAuth($route.name,'examine')"  :disabled="data.status !== '提交' && data.status !== '交期确认'" type="primary" size="mini" slot="reference">审 核</el-button>
    </el-popover>

    <el-dialog title="选择押金单号" :visible.sync="visible2" append-to-body width="1000px">
      <el-table
        :header-cell-style="{background:'#EEEEEE',color:'#333'}" 
        size="mini"
        border
        :data="list"
        style="width: 100%">
        <el-table-column
          prop="TYPE"
          label="来源">
        </el-table-column>
        <el-table-column
          prop="APA01"
          label="押金单号">
        </el-table-column>
        <el-table-column
          prop="APA07"
          label="客户名称">
        </el-table-column>
        <el-table-column
          prop="APA21"
          label="申请人">
        </el-table-column>
        <el-table-column
          prop="APA31"
          label="金额">
        </el-table-column>
        <el-table-column
          prop="APA22"
          label="所属部门">
        </el-table-column>
        <el-table-column
          prop="APA25"
          label="摘要说明">
        </el-table-column>
        <el-table-column
          label="操作"
          width="140">
          <template slot-scope="scope">
            <el-button type="text" size="mini" @click="onSubmit(scope.row)">选 择</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div  class="container normal-panel" style="text-align:right">
        <el-pagination
            background
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="param.content.pageNumber"
            :page-sizes="[20, 50, 100, 200]"
            :total="total">
        </el-pagination>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props:['data'],
  data () {
    return {
      list:[],
      siteId:JSON.parse(sessionStorage.getItem('active_account')).siteid,
      options:[],
      value:'',
      visible:false,
      visible2:false,
      param: {
        id:'20230414111602',
        content: {
          "pageNumber":1,
          "pageSize":20,
          keywords:''
        }
      },
      total:0
    }
  },
  methods: {
    async listData () {
      let res = await this.$api.requested(this.param)
      this.list = res.data
      this.total = res.total
      console.log(this.list);
    },
    async orderreviewtype () {
      const res = await this.$store.dispatch('optiontypeselect','orderreviewtype')
      this.options = res.data
      this.value = res.data[0].value
    },
    confirm () {
      if (this.siteId == 'TZ') {
        this.listData()
        this.visible2 = true
      } else {
        this.$emit('onSubmit','审核')
      }
    },
    async onSubmit (data) {
      let res = await this.$api.requested({
        id:'20230114161402',
        "content": {
            "sa_orderid": this.data.sa_orderid,
            "sys_enterpriseid": this.data.sys_enterpriseid,
            "sa_accountclassid": this.data.accountclass.sa_accountclassid,
            "reviewtype":this.value,
            "erpNo":data.APA01
          },
      })
      this.tool.showMessage(res,() => {
        this.visible2 = false
        this.$emit('onSuccess')
      })
    },
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
      this.param.content.pageSize = val
      this.listData()
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.param.content.pageNumber = val
      this.listData()
    },
  },
  created () {
    this.orderreviewtype()
  }
}
</script>

<style  scoped>

</style>
