<template>
  <el-form-item label="系统编号">
    <el-select
      v-model="pkVertex"
      clearable
      @change="handleChange"
    >
      <el-option
        v-for="item in verList"
        :key="item.pkVertex"
        :label="`${item.memberCode} (${item.memberName})`"
        :value="item.memberCode"
      />
    </el-select>
  </el-form-item>
</template>

<script>
import * as api from '@/api/settle.js'
export default {
  name: 'TopMemberSelect',
  props: {
    model: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      pkVertex: '',
      verList: []
    }
  },
  created() {
    this.getList()
  },
  methods: {
    handleChange() {
      this.$emit('change', this.pkVertex)
    },
    getList() {
      api.topVertexList().then((res) => {
        this.verList = res.rows || []
        this.pkVertex = this.verList[0]?.memberCode || ''
        this.pkVertex && this.handleChange()
      })
    },
    reset() {
      this.pkVertex = ''
    }
  }
}
</script>

