<!-- 按钮 -->
<template>
  <div>
    <el-button type="info" size="mini" v-if="isWin == 3" disabled style="margin-bottom:10px;">已流标</el-button>
    <el-button type="primary" plain size="mini" v-if="['add','edit'].includes($route.query.flag)" @click="handleConfirm(0)" style="margin-bottom:10px;">暂存</el-button>
    <el-button type="primary" plain size="mini" v-if="['add','edit'].includes($route.query.flag) || ['quotationSheetBidding'].includes(listType) && isWin==2 " @click="handleConfirm(1)" style="margin-bottom:10px;">{{saveTitle}}</el-button>
    <el-button type="primary" plain size="mini" v-if="['edit','show'].includes($route.query.flag)" @click="handleConfirm(2)" style="margin-bottom:10px;">打印预览</el-button>
    <el-button type="primary" plain size="mini" v-if="['show','edit'].includes($route.query.flag)" @click="handleConfirm(3)" style="margin-bottom:10px;">审批流程</el-button>
    <el-button type="success" plain size="mini" v-if="isAuthorised" @click="handleConfirm(4)" style="margin-bottom:10px;">同意</el-button>
    <el-button type="danger" plain size="mini" v-if="isAuthorised" @click="handleConfirm(5)" style="margin-bottom:10px;">驳回</el-button>
    <el-button type="primary" size="mini" @click="handleBack" style="margin-bottom:10px;">返回</el-button>
    <Toast :accessId="accessId" :newKey="key" :isOpen="isOpen" @onCancel="isOpen=false" />
  </div>
</template>

<script>
export default {
  name: '',
  components: {
    Toast: () => import('./components/Toast.vue')
  },
  props: {
    isAuthorised: Boolean,
    accessId: [Number, String],
    listType: String,
    isWin: [Number, String], // 是否流标 3：已流标 
    saveTitle: {
      type: String,
      default: '保存'
    }
  },
  data() {
    return {
      isOpen: false,
      key: null
    }
  },
  methods: {
    handleConfirm(key) {
      if (key == 4 || key == 5) {
        this.key = key
        this.isOpen = true
      } else {
        this.$emit('onConfirm', key)
      }
    },
    handleBack() {
      history.back()
    },
  }
}

</script>
<style lang='scss' scoped>
</style>