occupation_direction.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <template>
  2. <div>
  3. <el-cascader :options="list" v-model="value" @change="change"></el-cascader>
  4. </div>
  5. </template>
  6. <script>
  7. export default {
  8. data() {
  9. return {
  10. value: [],
  11. list: []
  12. };
  13. },
  14. async mounted() {
  15. const res = await this.$axios.$post(
  16. "/uapi/work/get/get.occupation.direction.form.sign.new"
  17. );
  18. this.list = res.data.list;
  19. },
  20. methods: {
  21. getValue(arr) {
  22. if (!arr || arr.length == 0) {
  23. this.$message.error("请选择方向");
  24. }
  25. let result = [];
  26. let target = this.list;
  27. arr.forEach(selectItem => {
  28. let {
  29. children,
  30. ...options
  31. } = target.find(item => item.value == selectItem)
  32. result.push(options);
  33. target = children;
  34. });
  35. return result
  36. },
  37. change(e) {
  38. let result = this.getValue(e)
  39. this.$emit('change', result)
  40. }
  41. }
  42. };
  43. </script>
  44. <style lang="scss" scoped></style>