settleStyle.js 1.5 KB

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