<template>
  <div>
    <xy-dialog ref="dialog" :width='50' :is-show.sync="isShow" type="form" title="业务审核" :form="form" :rules="rules"
      @submit="submit">
      <template v-slot:work_status>
        <div class="xy-table-item">
          <div class="xy-table-item-label">
            <span style="color: red;font-weight: 600;padding-right: 4px;">*</span>审核状态：
          </div>
          <div class="xy-table-item-content">
            <el-select v-model="form.work_status" filterable style="width: 300px;" placeholder="请选择审核状态">
              <el-option v-for="item in checkstatusList" :key="item.value" :label="item.value" :value="item.value">
              </el-option>
            </el-select>
          </div>
        </div>
      </template>
    </xy-dialog>
  </div>
</template>

<script>
  import {
    save,
    index,
    show
  } from "@/api/system/baseForm.js"
  import {
    Message
  } from 'element-ui'
  export default {
    data() {
      return {
        isShow: false,
        id: '',
        tableName: 'workflows',

        form: {
          work_status: ''
        },
        rules: {},
        checkstatusList: [{
          label: '待审核',
          value: '待审核'
        }, {
          label: '通过',
          value: '通过'
        }, {
          label: '退回',
          value: '退回'
        }]

      }
    },
    created() {},
    watch: {
      isShow(newVal) {
        if (newVal) {
          this.getViewDetail()
        } else {
          this.id = ''
          this.$refs['dialog'].reset()
        }
      }
    },
    methods: {
      async getViewDetail() {
        const res = await show({
          id: this.id,
          table_name: this.tableName
        })
        this.form = {
          name: res?.name,
          idcard: res?.idcard,
          number: res?.number,
          mobile: res?.mobile,
          work_status: res?.work_status
        }
      },
      submit(val) {
        save({
          id: this.id,
          table_name: this.tableName,
          ...this.form
        }).then(res => {
          Message({
            type: 'success',
            message: '审核成功'
          })
          this.isShow = false
          this.$emit('refresh')
        })
      }
    },

  }
</script>

<style>
</style>