returnReason.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import { removeEmptyStr } from '@/libs/tools'
  2. const ReturnReason = {
  3. template: `
  4. <a-select
  5. allowClear
  6. :size="size"
  7. mode="combobox"
  8. :value="defaultVal"
  9. show-search
  10. :placeholder="placeholder"
  11. option-filter-prop="children"
  12. style="width: 100%"
  13. :filter-option="filterOption"
  14. :dropdownMatchSelectWidth="false"
  15. @change="onChange"
  16. @blur="onBlur"
  17. @focus="open=true"
  18. @select="open=false"
  19. :open="open"
  20. >
  21. <a-select-option v-for="item in list" :key="item.code" :value="item.dispName">
  22. {{item.dispName}}
  23. </a-select-option>
  24. </a-select>
  25. `,
  26. props: {
  27. value: {
  28. type: String,
  29. defatut: ''
  30. },
  31. id: {
  32. type: String,
  33. default: ''
  34. },
  35. placeholder: {
  36. type: String,
  37. default: '请输入退货原因(最多50字符)'
  38. },
  39. size: {
  40. type: String,
  41. default: 'small'
  42. }
  43. },
  44. data() {
  45. return {
  46. defaultVal: this.value,
  47. open: false,
  48. list: []
  49. };
  50. },
  51. mounted() {
  52. this.list = this.$store.state.app.returnReason
  53. },
  54. watch: {
  55. value(newValue, oldValue) {
  56. this.defaultVal = removeEmptyStr(newValue)
  57. },
  58. },
  59. methods: {
  60. filterOption(input, option) {
  61. return (
  62. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  63. );
  64. },
  65. onChange(value) {
  66. console.log(value,'----')
  67. this.open = true;
  68. const ret = value?value.substr(0,50):'';
  69. this.defaultVal = removeEmptyStr(ret);
  70. this.$emit('input', this.defaultVal);
  71. this.$emit('change', this.defaultVal);
  72. },
  73. onBlur(value){
  74. this.open = false;
  75. this.$emit('blur', removeEmptyStr(value));
  76. }
  77. },
  78. };
  79. export default ReturnReason