index.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <xm-cascader
  3. ref="cascaderRef"
  4. v-model="value"
  5. :options="list"
  6. :checkStrictly="checkStrictly"
  7. @input="handleInput"
  8. :showAllLevels="true"
  9. @confirm="handleConfirm"
  10. :props="{
  11. value: 'code',
  12. label: 'areaName',
  13. children: 'child'
  14. }"
  15. >
  16. </xm-cascader>
  17. </template>
  18. <script>
  19. import { getCodeAreaTree,getConfigKey} from "@/api/common/system.js";
  20. export default {
  21. props: {
  22. checkStrictly: { //传入此参数columns无效
  23. type: Boolean,
  24. default: true,
  25. },
  26. },
  27. data() {
  28. return {
  29. value: '',
  30. list: [
  31. /* {
  32. "code": 1,
  33. "areaName": "Parent 1",
  34. "parentId": 0,
  35. "child": [{
  36. "code": 2,
  37. "areaName": "Child 1.1",
  38. "parentId": 1,
  39. "child": []
  40. },
  41. {
  42. "code": 3,
  43. "areaName": "Child 1.2",
  44. "parentId": 1,
  45. "child": []
  46. }
  47. ]
  48. }, */
  49. ],
  50. }
  51. },
  52. created() {
  53. this.initOptions()
  54. },
  55. methods: {
  56. async initOptions() {
  57. let { msg } = await getConfigKey('areaCode');
  58. let { data } = await getCodeAreaTree({pCode: msg});
  59. this.list = data
  60. },
  61. handleInput(e) {
  62. // console.log(e,'eeee')
  63. },
  64. show() {
  65. this.$refs.cascaderRef.openDept()
  66. },
  67. close() {
  68. this.$refs.cascaderRef.close()
  69. },
  70. handleConfirm(e) {
  71. this.$emit('confirm', e)
  72. },
  73. }
  74. }
  75. </script>
  76. <style lang="scss" scoped></style>