bizUser.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import { queryPage } from '@/api/bizuser'
  2. const BizUser = {
  3. template: `
  4. <a-select
  5. :placeholder="placeholder"
  6. :id="id"
  7. allowClear
  8. :value="defaultVal"
  9. :showSearch="true"
  10. :disabled="disabledFlag"
  11. @change="handleChange"
  12. option-filter-prop="children"
  13. :filter-option="filterOption">
  14. <a-select-option v-for="item in list" :key="item.bizUserSn" :value="item.bizUserSn">
  15. {{ item.userName }}
  16. </a-select-option>
  17. </a-select>
  18. `,
  19. props: {
  20. value: {
  21. type: String,
  22. defatut: ''
  23. },
  24. id: {
  25. type: String,
  26. default: ''
  27. },
  28. placeholder: {
  29. type: String,
  30. default: '请选择负责人'
  31. },
  32. disabledFlag: {
  33. type: Boolean,
  34. default: false
  35. }
  36. },
  37. data () {
  38. return {
  39. defaultVal: this.value,
  40. list: []
  41. }
  42. },
  43. mounted () {
  44. this.getList()
  45. },
  46. watch: {
  47. value (newValue, oldValue) {
  48. this.defaultVal = newValue
  49. }
  50. },
  51. methods: {
  52. filterOption (input, option) {
  53. return (
  54. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  55. )
  56. },
  57. handleChange (value) {
  58. this.defaultVal = value
  59. const item = this.list.find(item => item.bizUserSn == value)
  60. this.$emit('input', value)
  61. this.$emit('change', value, item)
  62. },
  63. getList () {
  64. queryPage({bizUserType:'qy',pageNo:1,pageSize:100}).then(res => {
  65. if (res.status == 200) {
  66. this.list = res.data.list
  67. } else {
  68. this.list = []
  69. }
  70. })
  71. }
  72. }
  73. }
  74. export default BizUser