buildfloorCascader.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <el-cascader v-model="value" :options="options" :props="props" clearable ref="elCascader" @remove-tag="removeTag"></el-cascader>
  3. </template>
  4. <script>
  5. // import { buildingQuery } from "@/api/scan/request";
  6. import { buildingQuery } from '@/api/object/build';
  7. export default {
  8. data() {
  9. return {
  10. value: [],
  11. props: {
  12. multiple: true,
  13. checkStrictly: true,
  14. value: 'id',
  15. label: 'localName',
  16. children: 'floor'
  17. },
  18. options: []
  19. }
  20. },
  21. props: {
  22. SysID: {
  23. default: ''
  24. }
  25. },
  26. methods: {
  27. getCascader() {
  28. let param = {
  29. cascade: [
  30. { name: "floor", orders: "floorSequenceID desc" }
  31. ],
  32. orders: "localName asc",
  33. pageNumber: 1,
  34. pageSize: 50
  35. }
  36. buildingQuery(param, res => {
  37. res.content.map(t => {
  38. if (t.floor && t.floor.length) {
  39. t.floor = t.floor.map(item => {
  40. if (item.id == this.FloorID) return
  41. item.BuildID = item.id
  42. item.BuildLocalName = item.localName || item.name
  43. return item
  44. }).filter(it => it)
  45. }
  46. })
  47. this.options = res.content
  48. })
  49. },
  50. getSelectedNodes() {
  51. let nodes = this.$refs.elCascader.getCheckedNodes();
  52. let arr = [], flag = false, brr = [];
  53. if (nodes.length) {
  54. nodes.map(t => {
  55. let obj = {
  56. BuildName: t.pathLabels[0],
  57. BuildID: t.path[0]
  58. }
  59. if (t.path.length > 1) {
  60. obj.FloorName = t.pathLabels[1]
  61. obj.FloorID = t.path[1]
  62. } else {
  63. flag = true;
  64. }
  65. arr.push(obj);
  66. })
  67. if (flag) {
  68. for (let i = 0; i < arr.length; i++) {
  69. for (let j = 0; j < arr.length; j++) {
  70. if (!arr[i].FloorID && arr[j].FloorID && arr[i].BuildID == arr[j].BuildID) {
  71. brr.push(i)
  72. }
  73. }
  74. }
  75. arr = arr.map((t, i) => {
  76. if (brr.indexOf(i) > -1) {
  77. return undefined;
  78. }
  79. return t;
  80. }).filter(item => item);
  81. }
  82. }
  83. return arr;
  84. },
  85. removeTag(){
  86. console.log(arguments)
  87. }
  88. }
  89. }
  90. </script>
  91. <style lang="less" scoped>
  92. .el-cascader {
  93. width: 100%;
  94. }
  95. </style>