<template>
  <el-select
    v-model="selected"
    filterable
    remote
    reserve-keyword
    placeholder="请输入关键字"
    :remote-method="remoteMethod"
    :loading="loading"
    v-bind="$attrs"
    @change="change"
  >
    <el-option
      v-for="item in options"
      :key="item.id"
      :label="item.processName"
      :value="item.processNo"
    >
      <el-row :gutter="20">
        <el-col :span="12">{{ item.processNo }}</el-col>
        <el-col :span="12" class="text-right">{{ item.processName }}</el-col>
      </el-row>
    </el-option>

  </el-select>
</template>

<script>
import { getProcessPage } from '@/api/wms/quality/iqcInspectionExecute'
export default {
  props: {
    value: {
      type: [String, Number, Array],
      default: ''
    }
  },
  data() {
    return {
      loading: false,
      options: [],
      copiedOptions: [],
      codeList: [],
      selectFlag: false
    }
  },
  computed: {
    selected: {
      get() {
        return this.value
      },
      set(v) {
        this.$emit('input', v)
      }
    }
  },
  methods: {
    remoteMethod(keyWord) {
      this.loading = true
      const params = {
        keyWord
      }
      getProcessPage(params).then(response => {
        this.options = response.data.list
      }).finally(() => {
        this.loading = false
      })
    },
    change(v) {
      const items = this.options.find(i => i.processNo === v)
      this.$emit('change', items)
    }
  }
}
</script>

  <style>

  </style>

