bookReason.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. const BookReason = {
  2. template: `
  3. <a-select
  4. :placeholder="placeholder"
  5. style="width:100%"
  6. :size="size"
  7. :id="id"
  8. allowClear
  9. :value="defaultVal"
  10. :showSearch="true"
  11. @change="handleChange"
  12. option-filter-prop="children"
  13. :dropdownMatchSelectWidth="false"
  14. :filter-option="filterOption">
  15. <a-select-option v-for="item in list" :key="item.code" :value="item.code">
  16. {{item.dispName}}
  17. </a-select-option>
  18. </a-select>
  19. `,
  20. props: {
  21. value: {
  22. type: String,
  23. default: undefined
  24. },
  25. id: {
  26. type: String,
  27. default: ''
  28. },
  29. placeholder: {
  30. type: String,
  31. default: '请选择收款事由'
  32. },
  33. size: {
  34. type: String,
  35. default: 'default'
  36. }
  37. },
  38. data() {
  39. return {
  40. defaultVal: this.value,
  41. list: []
  42. };
  43. },
  44. created() {
  45. this.list = this.$store.state.app.bookReason
  46. },
  47. watch: {
  48. value(newValue, oldValue) {
  49. this.defaultVal = newValue || undefined
  50. }
  51. },
  52. methods: {
  53. filterOption(input, option) {
  54. return (
  55. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  56. );
  57. },
  58. handleChange(value) {
  59. this.defaultVal = value;
  60. const row = this.list.find(item => item.code == value)
  61. this.$emit('change', value, row);
  62. this.$emit('input', value);
  63. },
  64. getCodeByName(value){
  65. const row = this.list.find(item => item.dispName == value)
  66. return row? row.code : ''
  67. }
  68. },
  69. };
  70. export default BookReason