settleAccount.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import { settleAccountList } from '@/api/settleAcount'
  2. // 结算账户
  3. const SettleAccount = {
  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.accountName }}-{{item.accountNo}}</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: 'settleAccountSn'
  28. },
  29. placeholder: {
  30. type: String,
  31. default: '请选择结算账户'
  32. },
  33. settleStyleSn:{
  34. type: String,
  35. default: ''
  36. }
  37. },
  38. data() {
  39. return {
  40. defaultVal: this.value||undefined,
  41. list: []
  42. };
  43. },
  44. watch: {
  45. value(newValue, oldValue) {
  46. console.log(newValue)
  47. this.defaultVal = newValue||undefined
  48. },
  49. settleStyleSn(a,b){
  50. if(a){
  51. this.getList()
  52. }
  53. }
  54. },
  55. mounted() {
  56. if(this.settleStyleSn){
  57. this.getList()
  58. }
  59. },
  60. methods: {
  61. filterOption (input, option) {
  62. return (
  63. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  64. )
  65. },
  66. handleChange(value) {
  67. this.defaultVal = value;
  68. const accountName = this.list.find(item => item[this.defValKey] == value).accountName
  69. this.$emit('input', value);
  70. this.$emit('change', this.value, accountName);
  71. },
  72. // 列表数据
  73. getList () {
  74. const _this = this
  75. settleAccountList({settleStyleSn: this.settleStyleSn,pageNo:1,pageSize:500,state:'ENABLE'}).then(res => {
  76. if (res.status == 200) {
  77. _this.list = res.data.list || []
  78. } else {
  79. _this.list = []
  80. }
  81. })
  82. },
  83. },
  84. };
  85. export default SettleAccount