classification-picker.vue 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <template>
  2. <ba-tree-picker
  3. ref="treePicker"
  4. key="verify"
  5. :multiple="false"
  6. @select-change="confirm"
  7. title="选择分类"
  8. :localdata="classificationList"
  9. valueKey="id"
  10. textKey="name"
  11. childrenKey="children"
  12. />
  13. </template>
  14. <script>
  15. import baTreePicker from "@/components/ba-tree-picker/ba-tree-picker.vue";
  16. import { getTreeByPid } from "@/api/classifyManage";
  17. export default {
  18. props: {
  19. warehousingType: {
  20. type: [String, Number],
  21. default: "1", //默认原料
  22. },
  23. },
  24. components: { baTreePicker },
  25. data() {
  26. return {
  27. classificationList: [],
  28. };
  29. },
  30. mounted() {
  31. this.getClassify();
  32. },
  33. methods: {
  34. show() {
  35. this.$refs.treePicker._show();
  36. },
  37. async getClassify() {
  38. const res = await getTreeByPid(this.warehousingType);
  39. this.classificationList = res.data;
  40. this.$nextTick(() => {
  41. this.confirm([res.data[0].id], res.data[0].name);
  42. });
  43. },
  44. confirm(...rest) {
  45. this.$emit("confirm", ...rest);
  46. },
  47. },
  48. };
  49. </script>