outTenant.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import { getReportTenantList } from '@/api/allocLinkagePut'
  2. // 调出对象
  3. const SettleStyle = {
  4. template: `
  5. <a-select
  6. :id="id"
  7. :placeholder="placeholder"
  8. allowClear
  9. :value="defaultVal"
  10. :showSearch="true"
  11. @change="handleChange"
  12. :filter-option="filterOption">
  13. <a-select-option v-for="item in list" :key="item[defValKey]" :value="item[defValKey]">{{ item.dealerName }}</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. defValKey: {
  26. type: String,
  27. default: 'dealerSn'
  28. },
  29. placeholder: {
  30. type: String,
  31. default: '请选择调出对象'
  32. }
  33. },
  34. data() {
  35. return {
  36. defaultVal: this.value||undefined,
  37. list: []
  38. };
  39. },
  40. watch: {
  41. value(newValue, oldValue) {
  42. console.log(newValue)
  43. this.defaultVal = newValue||undefined
  44. }
  45. },
  46. mounted() {
  47. this.getList()
  48. },
  49. methods: {
  50. filterOption (input, option) {
  51. return (
  52. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  53. )
  54. },
  55. handleChange(value) {
  56. console.log(value)
  57. this.defaultVal = value;
  58. const row = this.list.find(item => item[this.defValKey] == value)
  59. this.$emit('input', value);
  60. this.$emit('change', this.defaultVal, row?row.dealerName:'');
  61. },
  62. // 列表数据
  63. getList () {
  64. const _this = this
  65. getReportTenantList({}).then(res => {
  66. if (res.status == 200) {
  67. _this.list = res.data || []
  68. } else {
  69. _this.list = []
  70. }
  71. })
  72. },
  73. },
  74. };
  75. export default SettleStyle