<template>
  <div style="display: flex; align-items: center; width: 100%">
    <label class="font_normal_body">安检部门</label>
    <v-select class="select_list select"
              placeholder='安检部门' style="width: 60%"
              v-model='value'
              :value.sync="value"
              :options='departments'
              multiple
              clear-button>
    </v-select>
  </div>
</template>

<script>
  import {HttpResetClass} from 'vue-client'

  export default {
    name: "RoleSelector",
    props: {
      value: {
        default: ''
      },
    },
    data() {
      return {
        departments: []
      }
    },
    ready() {
      this.search()
    },
    methods: {
      async search() {
        const departments = []
        const res = await new HttpResetClass().load("POST", `/rs/sql/safe_singleTable_OrderBy`, {data:{
            items:"dep.id, dep.name",
            tablename:"t_department dep left join t_organization org on dep.parentid = org.id",
            orderitem:"dep.name",
            condition:`org.name = '新安检部'`
          }})
        console.log('res12=', JSON.stringify(res))
        for (const item of res.data) {
          departments.push({label: item.name, value: item.id})
        }
        this.departments = departments
        console.log('this.departments=', JSON.stringify(this.departments))
      },
    }
  }
</script>

<style scoped>

</style>
