shelfTemplate.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { shelfTemplateList } from '@/api/shelfTemplate'
  2. const custType = {
  3. template: `
  4. <a-select
  5. :placeholder="placeholder"
  6. :id="id"
  7. allowClear
  8. :value="defaultVal"
  9. :showSearch="true"
  10. @change="handleChange"
  11. option-filter-prop="children"
  12. :dropdownMatchSelectWidth="false"
  13. :filter-option="filterOption">
  14. <a-select-option v-for="item in list" :key="item.templateSn" :value="item.templateSn">{{ item.templateName }}</a-select-option>
  15. </a-select>
  16. `,
  17. props: {
  18. value: {
  19. type: String,
  20. },
  21. id: {
  22. type: String,
  23. default: ''
  24. },
  25. placeholder: {
  26. type: String,
  27. default: '请选择货架模板'
  28. }
  29. },
  30. data() {
  31. return {
  32. defaultVal: this.value,
  33. list: []
  34. };
  35. },
  36. mounted() {
  37. this.getList()
  38. },
  39. watch: {
  40. value(newValue, oldValue) {
  41. this.defaultVal = newValue
  42. }
  43. },
  44. methods: {
  45. filterOption (input, option) {
  46. return (
  47. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  48. )
  49. },
  50. handleChange(value) {
  51. this.defaultVal = value;
  52. this.$emit('change', value);
  53. this.$emit('input', value);
  54. },
  55. getList () {
  56. shelfTemplateList({pageNo:1,pageSize:100}).then(res => {
  57. if (res.status == 200) {
  58. this.list = res.data.list
  59. } else {
  60. this.list = []
  61. }
  62. })
  63. },
  64. },
  65. };
  66. export default custType