allocateType.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import { allocateTypeTreeList } from '@/api/allocateType'
  2. const AllocateType = {
  3. template: `
  4. <a-cascader
  5. :value="defaultVal"
  6. allowClear
  7. :change-on-select="changeOnSelect"
  8. @change="handleChange"
  9. :options="list"
  10. expand-trigger="hover"
  11. :placeholder="placeholder"
  12. :id="id"
  13. :fieldNames="{ label: 'name', value: 'allocateTypeSn', children: 'sonList' }"/>
  14. `,
  15. props: {
  16. value: {
  17. type: Array,
  18. defatut: function(){
  19. return []
  20. }
  21. },
  22. id: {
  23. type: String,
  24. default: ''
  25. },
  26. placeholder:{
  27. type: String,
  28. default: '请选择'
  29. },
  30. changeOnSelect:{
  31. type: Boolean,
  32. default: false
  33. }
  34. },
  35. data() {
  36. return {
  37. defaultVal: this.value,
  38. list: []
  39. };
  40. },
  41. mounted() {
  42. this.getProductBrand()
  43. },
  44. watch: {
  45. value(newValue, oldValue) {
  46. this.defaultVal = newValue
  47. }
  48. },
  49. methods: {
  50. filterOption (input, option) {
  51. return (
  52. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  53. )
  54. },
  55. handleChange(value,opts) {
  56. this.defaultVal = value;
  57. this.$emit('input', value);
  58. this.$emit('change', value,opts);
  59. },
  60. // 调拨类型
  61. getProductBrand () {
  62. allocateTypeTreeList({}).then(res => {
  63. if (res.status == 200) {
  64. this.list = res.data
  65. } else {
  66. this.list = []
  67. }
  68. })
  69. },
  70. },
  71. };
  72. export default AllocateType