returnReason.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. const ReturnReason = {
  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: 'small'
  36. },
  37. goodFlag: {
  38. type: String,
  39. default: ''
  40. }
  41. },
  42. data() {
  43. return {
  44. defaultVal: this.value,
  45. list: []
  46. };
  47. },
  48. created() {
  49. // 不良品
  50. if(this.goodFlag == 'DEFECTIVE_PRODUCT_RETURN'){
  51. this.list = this.$store.state.app.defectiveReturnReason
  52. }
  53. // 良品
  54. if(this.goodFlag == 'GOOD_PRODUCT_RETURN'){
  55. this.list = this.$store.state.app.goodReturnReason
  56. }
  57. // 全部
  58. if(!this.goodFlag){
  59. this.list = [...this.$store.state.app.defectiveReturnReason, ...this.$store.state.app.goodReturnReason]
  60. }
  61. },
  62. watch: {
  63. value(newValue, oldValue) {
  64. this.defaultVal = newValue || undefined
  65. }
  66. },
  67. methods: {
  68. filterOption(input, option) {
  69. return (
  70. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  71. );
  72. },
  73. handleChange(value) {
  74. this.defaultVal = value;
  75. const row = this.list.find(item => item.code == value)
  76. this.$emit('change', value, row);
  77. this.$emit('input', value);
  78. }
  79. },
  80. };
  81. export default ReturnReason