editSysFloor.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <el-dialog title="所属建筑楼层" :visible.sync="connectDialogVis" width="50%" id="messageDialog">
  3. <div class="cascader-row">
  4. <div style="line-height:32px;">添加{{system.SysLocalName}}所属建筑楼层 :</div>
  5. <div style="width:70%">
  6. <bfCascader ref="bfCascader" :SysID="system.SysID"></bfCascader>
  7. </div>
  8. </div>
  9. <span slot="footer" class="dialog-footer">
  10. <el-button size="small" @click="connectDialogVis=false">取消</el-button>
  11. <el-button size="small" type="primary" @click="save">确认</el-button>
  12. </span>
  13. </el-dialog>
  14. </template>
  15. <script>
  16. import bfCascader from './buildfloorCascader'
  17. import { sysRelateBuild, sysRelateFloor } from "@/api/scan/request";
  18. export default {
  19. data() {
  20. return {
  21. buildName: '',
  22. connectDialogVis: false,
  23. system: {}
  24. }
  25. },
  26. components: {
  27. bfCascader
  28. },
  29. props: {
  30. isCreate: {
  31. default: false
  32. }
  33. },
  34. methods: {
  35. showDialog(system) {
  36. this.system = system;
  37. this.connectDialogVis = true;
  38. this.$nextTick(() => {
  39. this.$refs.bfCascader.getCascader()
  40. let arr = this.system.BuildingFloorInfoList || [];
  41. let value = []
  42. if (arr.length) {
  43. arr.map(t => {
  44. if (t.FloorID) {
  45. value.push([t.BuildID, t.FloorID]);
  46. } else {
  47. value.push([t.BuildID])
  48. }
  49. })
  50. }
  51. this.$refs.bfCascader.value = value
  52. console.log(value)
  53. })
  54. },
  55. save() {
  56. // 如果是创建
  57. if (this.isCreate) {
  58. let data = this.$refs.bfCascader.getSelectedNodes();
  59. this.connectDialogVis = false;
  60. this.$emit('relateSuccess', data);
  61. return
  62. }
  63. let arr = this.$refs.bfCascader.value;
  64. let buildIds = [], floorIds = [];
  65. arr.map(t => {
  66. if (buildIds.indexOf(t[0]) < 0) {
  67. buildIds.push(t[0]);
  68. }
  69. if (t.length > 1 && floorIds.indexOf(t[1]) < 0) {
  70. floorIds.push(t[1]);
  71. }
  72. })
  73. let buildPa = {
  74. SysId: this.system.SysID,
  75. BuildingIdList: buildIds
  76. }
  77. let floorPa = {
  78. SysId: this.system.SysID,
  79. FloorIdList: floorIds
  80. }
  81. let promise1 = new Promise((resolve, reject) => {
  82. sysRelateBuild(buildPa, res => {
  83. resolve(res);
  84. })
  85. })
  86. let primise2 = new Promise((resolve, reject) => {
  87. sysRelateFloor(floorPa, res => {
  88. resolve(res);
  89. })
  90. })
  91. let buildFloor = this.$refs.bfCascader.getSelectedNodes();
  92. Promise.all([promise1, primise2]).then(res => {
  93. this.connectDialogVis = false;
  94. if (buildIds.length || floorIds.length) {
  95. this.$message.success("关联成功");
  96. } else {
  97. this.$message.success('清除关联成功');
  98. }
  99. this.$emit('relateSuccess', buildFloor);
  100. })
  101. }
  102. }
  103. }
  104. </script>
  105. <style lang="less" scoped>
  106. #messageDialog {
  107. .cascader-row {
  108. max-height: 200px;
  109. overflow: auto;
  110. }
  111. /*.el-row {*/
  112. /* !*height: 50px;*!*/
  113. /* max-height: 200px;*/
  114. /* overflow-y: auto;*/
  115. /* overflow-x: hidden;*/
  116. /*}*/
  117. /*.el-row > div {*/
  118. /* float: left;*/
  119. /*}*/
  120. /*.el-row > div + div {*/
  121. /* margin-left: 10px;*/
  122. /*}*/
  123. /*/deep/ .el-input__inner {*/
  124. /* vertical-align: baseline;*/
  125. /*}*/
  126. }
  127. </style>