department.js 1.5 KB

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