returnReason.js 1.8 KB

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