<template>
  <div>
    <sd-picker-source-list :load-list-data="roleLoadListData" v-bind="$attrs" v-on="$listeners"
  /></div>
</template>

<script>
import GroupUserService from '@/addressbook/group-user-service'
import axios from '@/common/services/axios-instance'
import components from './_import-components/sd-default-strategy-picker-import'

export default {
  name: 'SdDefaultStrategyPicker',
  metaInfo: {
    title: 'SdDefaultStrategyPicker',
  },
  components,
  props: {
    title: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      roleStrategyIdList: [
        'C.chargeGroupOperatorResolver',
        'C.roleOfHierarchyOperatorResolver',
        'C.oaApproveRoleMemberByCreatorDeptOperatorResolver',
      ],
    }
  },
  methods: {
    loadListData() {
      return axios.get('api/framework/v1/process-query/operator-strategy/children').then((res) => {
        return res.data.filter((r) => this.roleStrategyIdList.includes(r.id))
      })
    },
    roleLoadListData() {
      return GroupUserService.getRoles().then((val) => {
        return val.map((item) => {
          return {
            id: item.code,
            type: 'Role',
            value: item.code,
            text: item.name,
          }
        })
      })
    },
  },
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
</style>
