<!--
 * @Date: 2021-01-07 20:09:37
 * @LastEditors: zwq
 * @LastEditTime: 2022-03-10 14:25:50
 * @FilePath: \basic-admin\src\components\BaseTable\subcomponents\CheckDetail.vue
 * @Description:
-->
<template>
  <span>
    <el-popover
      v-model="visible"
      placement="top"
      width="160"
    >
      <div>
        <el-select v-model="value" placeholder="请选择">
          <el-option
            v-for="item in options"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          />
        </el-select>
      </div>
      <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="emitClick">确定</el-button>
      </div>
      <el-button slot="reference" type="text">{{ $t('module.basicData.Warehouse.RelateProcess') }}</el-button>
    </el-popover>
  </span>
</template>

<script>
import { list } from '@/api/art-manage/art.js'
import { ProcessInfoUpdata } from '@/api/orderManage/00A'
export default {
  props: {
    injectData: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      visible: false,
      options: [],
      value: ''
    }
  },
  created() {
    this.init()
  },
  methods: {
    init() {
      list({
        current: 1,
        size: 999
      }).then(response => {
        this.options = response.data.records
      })
    },
    emitClick() {
      const data = {
        id: this.injectData.id,
        subProcessId: this.value
      }
      ProcessInfoUpdata(data).then(res => {
        this.$message({
          message: this.$t('module.basicData.visual.success'),
          type: 'success',
          duration: 1500,
          onClose: () => {
            this.visible = false
          }
        })
      })
    }
  }
}
</script>
