EveSubnetConfigurationManagementFather.vue 19.6 KB
Newer Older
YazhouChen's avatar
YazhouChen committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630
<template>
  <div id="main" class="h-all">
    <el-container class="h-all">
      <el-header height="auto">
        <!-- 通用工具栏 -->
        <div class="header-button-box">
          <el-button size='mini' icon="el-icon-circle-plus-outline" type="primary" @click="createEveSubnetInit"
                     v-if="createAndCopyEthernetSubnetCommand.visible">
            {{$t('common.createBtn')}}
          </el-button>
          <el-button size='mini' icon="el-icon-document" type="primary" @click="copyEveSubnetInit"
                     v-if="createAndCopyEthernetSubnetCommand.visible">
            {{$t('common.copyBtn')}}
          </el-button>
          <el-button size='mini' icon="el-icon-edit" type="primary" @click="updateEveSubnetInit"
                     v-if="updateEthernetSubnetCommand.visible">
            {{$t('common.updateBtn')}}
          </el-button>
          <el-button size='mini' icon="el-icon-delete" type="primary" @click="deleteEveSubnetInit"
                     v-if="deleteEthernetSubnetCommand.visible">
            {{$t('common.deleteBtn')}}
          </el-button>
        </div>
      </el-header>
      <!-- table数据表格 -->
      <el-main class="adapt-height-box">
        <el-table
          :empty-text="$t('common.noData')"
          tooltip-effect="dark"
          stripe
          header-row-class-name="table-header"
          cell-class-name="table-cell"
          class="adapt-height"
          height="auto"
          border
          ref="singleTable"
          :data="EveSubnetList"
          highlight-current-row
          @current-change="handleCurrentChange"
          @selection-change="handleSelectionChange">

          <el-table-column
            type="selection"
            width="28">
          </el-table-column>

          <el-table-column
            prop="serviceSubnetID"
            label="主键"
            v-if="false">
          </el-table-column>
          <el-table-column
            text-align="left"
            prop="serviceSubnetName"
            :label="$t('EthernetSubnetDialog.serviceSubnetName')"
            :show-overflow-tooltip="true">
          </el-table-column>
          <el-table-column
            prop="serviceSubnetTopo"
            :label="$t('EthernetSubnetDialog.serviceSubnetTopologyType')"
            :formatter="formatEveSubnetTopoType"
            :show-overflow-tooltip="true">
          </el-table-column>
          <el-table-column
            prop="serviceTypeID"
            :label="$t('EthernetSubnetDialog.serviceType')"
            :formatter="formatServerType"
            :show-overflow-tooltip="true">
          </el-table-column>
          <el-table-column
            :label="$t('EthernetSubnetDialog.view')">
            <template slot-scope="scope">
              <el-row type="flex">
                <el-button
                  style="margin-top:-3.8px"
                  size="mini"
                  type="text"
                  @click="handleOperateDevice(scope.$index, scope.row,scope.row.subnetDevices)">
                  {{$t('EthernetSubnetDialog.device')}}
                </el-button>
              </el-row>
            </template>
          </el-table-column>
        </el-table>
      </el-main>
    </el-container>
    <CommandExecuteContext v-bind:commands="commandContext"></CommandExecuteContext>
    <!-- 附属设备列表对话框 -->
    <el-dialog v-dialogDrag width='600px' :title="$t('EthernetSubnetDialog.affiliateDevices')"
               :visible.sync="dialog_foreignDevice">

      <el-main style="padding: 0">
        <el-table
          tooltip-effect="dark"
          stripe
          header-row-class-name="table-header"
          cell-class-name="table-cell"
          ref="singleTable"
          height="400px"
          :data="currentDeviceList"
          highlight-current-row
          @current-change=""
          @selection-change="">

          <el-table-column
            type="selection"
            v-if="false"
            width="28">
          <!--v-if="false">-->
          </el-table-column>

          <!--<el-table-column-->
            <!--prop="deviceKey"-->
            <!--label="主键"-->
            <!--v-if="false">-->
          <!--</el-table-column>-->
          <el-table-column
            text-align="left"
            prop="deviceKey"
            :label="$t('EthernetSubnetDialog.networkElementName')"
            :formatter="formatEndDeviceKey"
            :show-overflow-tooltip="true">
          </el-table-column>
          <el-table-column
            prop="port"
            :label="$t('EthernetSubnetDialog.ports')"
            :show-overflow-tooltip="true">
          </el-table-column>
        </el-table>
      </el-main>
    </el-dialog>

  </div>
</template>

<script>
  import CommandExecuteContext from '../../commands/CommandExecuteContext.vue'
  import EthernetSubnetCommands from '../../commands/EthernetSubnetCommands';
  import ServiceSubnetService from '@/domain/services/Business/ServiceSubnetService.js'
  import ServiceTypeService from '@/domain/services/Business/ServiceTypeService.js'
  import DeviceService from '@/domain/services/DeviceService'
  import HelperUtil from "@/utils/HelperUtil.js";
  export default {
    name: 'EveSubnetConfigurationManagementFather',

    components: {
      CommandExecuteContext
    },

    data: function () {   //存放数据
      return {
        //命令
        commandContext: {},

        //为了创建复制初始化传参
        createAndCopyInitList: [],
        createAndCopyTitle: '',

        //删除相关
        deleteList: [],

        //为修改传参数
        updateInitList: [],
        /** *********************************下面是以前的data ***********************************/
        fullscreenLoading: false,

        //Btn按钮text域
        createEveSubnetBtn: "创建",
        updateEveSubnetBtn: "修改",
        copyEveSubnetBtn: "复制",
        deleteEveSubnetBtn: "删除",

        dialog_foreignDevice:false,

        formLabelWidth: '150px',

        deviceKey0: '',

        deviceList: [],// [{"deviceKey": '1',"port": '1,2'},{"deviceKey": '2',"port": '1'}],//"port": ''}],


        lineType: '',
        currentDeviceList: [],
        //服务器类型下拉列表
        EveSubnetTopoList: [
          {
            value: '0',
            label: this.$t("EthernetSubnetDialog.singlePoint")
          }, {
            value: '1',
            label: this.$t("EthernetSubnetDialog.bus")
          }, {
            value: '2',
            label: this.$t("EthernetSubnetDialog.ring")
          }, {
            value: '3',
            label: this.$t("EthernetSubnetDialog.mesh")
          }, {
            value: '4',
            label: this.$t("EthernetSubnetDialog.hybrid")
          }],
        SelectEveSubnetTopo: '',

        //业务类型下拉列表
        serviceTypeList: [
//          {
//            serviceTypeID: '0',
//            serviceTypeName: 'serverType1'
//          },
//          {
//            serviceTypeID: '1',
//            serviceTypeName: 'serverType2'
//          },
//          {
//            serviceTypeID: '2',
//            serviceTypeName: 'serverType3'
//          }
        ],

        //双向绑定弹出窗口input域
        form: {
          serviceSubnetID: "",
          serviceSubnetName: "",
          serviceSubnetTopo: "",
          serviceTypeID: "",

          deviceKey: '',
          port: '',


        },


        SubnetDeviceForCreate: [],

        //为了修改
        serviceSubnetIDForUpdate: '',
        serviceSubnetNameForUpdate: '',

        //双向绑定展示数据

        EveSubnetList:[],
        //保存当前行数据
        currentRow: null,
        //保存多选行数据
        multipleSelection: [],
        multipleSelectionCreate: [],
        multipleSelectionCopy: [],
        multipleSelectionUpdate: [],

        //保存附属设备表当前行数据
        currentRowDevice: null,
        //保存附属设备表多选行数据
        multipleSelectionDevice: [],

      }
    },
    //vue加载初始化函数,加载数据
    created: function () {
      console.log('业务子网管理界面初始化:')


      this.getAllEveSubnetInit()
      //额外获取所有关联机房信息
      this.getAllEvc()

      this.getAllDevice()
    },
    computed: {
      openTab() {
        return this.$store.state.openTab;
      },
      activeIndex: {
        get() {
          return this.$store.state.activeIndex;
        },
        set(val) {
          this.$store.commit('set_active_index', val);
        }
      },
      createAndCopyEthernetSubnetCommand() {
        return EthernetSubnetCommands.createAndCopyEthernetSubnetCommand(this.createAndCopyTitle, this.createAndCopyInitList, this.commandContext)
      },
      deleteEthernetSubnetCommand() {
        return EthernetSubnetCommands.deleteEthernetSubnetCommand(this.deleteList, this.commandContext)
      },
      updateEthernetSubnetCommand() {
        return EthernetSubnetCommands.updateEthernetSubnetCommand(this.updateInitList, this.commandContext)
      },
      a() {
        this.lineType = this.$t('EthernetSubnetDialog.lineType')
      }
    },
    methods: {


      //对input输入内容进行校验
      /**
       * @Description  :业务子网名称非空校验
       * @author       :
       * @param        :
       * @return       :
       * @exception    :
       * @date         : 2019/3/13
       */
      serviceSubnetNameCheck: function () {
        const _this = this;
        if (_this.form.serviceSubnetName == '' || _this.form.serviceSubnetName == null) {
          _this.InfoTip.warningTip(_this, HelperUtil.getCheckStatusCodeObjectByCode(_this.successCode.SERVICE_SUBNET_NAME_CANNOT_BE_EMPTY))
          return false
        }
        return true
      },


      /**
       * @Description  :单选一行,将所选行进行保存
       */
      handleCurrentChange(val) {
        this.currentRow = val;
      },

      /**
       * @Description  :创建业务子网,表格多选框改变时,将所选行进行保存
       */
      handleSelectionChangeCreate(val) {
        this.SubnetDeviceForCreate = new Array()
        this.multipleSelectionCreate = val

        for (var i = 0; i < this.multipleSelectionCreate.length; i++) {
          this.SubnetDeviceForCreate.push({
            deviceKey: this.multipleSelectionCreate[i].deviceKey,
            port: this.multipleSelectionCreate[i].port,
          })
//          }
        }
        console.log("device", this.SubnetDeviceForCreate)
      },



      /**
       * @Description  :表格多选框改变时,将所选行进行保存
       */
      handleSelectionChange(val) {
        this.multipleSelection = val
      },

      getAllDevice() {
        //获取设备信息
        let _this = this
        console.log("执行获取设备")
        console.log('获取全部网元信息:')
        DeviceService.getAllDeviceCollection().then(result => {
          //成功
          _this.deviceList = Object.values(result)


//          console.log(this.deviceList)
        }).catch(err => {
          //失败
          _this.InfoTip.errorTip(_this, err);
        })
      },

      /**
       * @Description  :业务类型过滤
       */
      formatServerType: function (row, column) {


        for (var j = 0; j < this.serviceTypeList.length; j++) {
          if (row.serviceTypeID == this.serviceTypeList[j]['serviceTypeID']) {
            return this.serviceTypeList[j]['serviceTypeName']
          }
        }
//
//        if (this.serviceTypeList[row.serviceTypeID] != undefined) {
//          return this.serviceTypeList[row.serviceTypeID].serviceTypeName
//        }
//        else {
//          return row.serviceTypeID
//        }
      },

      /**
       * @Description  :子网拓扑类型过滤
       */
      formatEveSubnetTopoType: function (row, column) {
        for (var i = 0; i < this.EveSubnetTopoList.length; i++) {
          if (this.EveSubnetTopoList[i]['value'] == row.serviceSubnetTopo) {
            return this.EveSubnetTopoList[i]['label']
            break;
          }
        }
      },

      /**
       * @Description  :查看单选行的设备列表
       */
      handleOperateDevice(index, row, subnetDevices) {
        console.log(index, row);
        console.log('查看设备列表:')
        this.currentDeviceList = subnetDevices
        //弹出设备列表对话框
        if (this.currentDeviceList.length == 0) {
          // var message = '没有附属设备!'
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.HAVE_NO_AFFILIATD_DEVICE))

//          this.$message({
//            type: 'waring',
//            message: '没有附属设备! ',
//            duration: 10000,
//            showClose: true,
//          });
        } else {

          this.dialog_foreignDevice = true;
        }

      },

      formatEndDeviceKey: function (row, column) {
        console.log("过滤设备名称")
        for (var j = 0; j < this.deviceList.length; j++) {
          if (row.deviceKey === this.deviceList[j]['deviceKey']) {
            return this.deviceList[j]['deviceName']
          }
//          else{
//            return this.deviceList[j]['deviceKey']
//          }
        }
        return row.deviceKey
      },

      /**
       * @Description  :获取业务类型
       */
      getAllEvc: function () {
        console.log('获取全部业务信息:')
        let _this = this
        ServiceTypeService.getAllServiceTypeCollection().then(result => {
          //成功
          _this.serviceTypeList = Object.values(result)
        }).catch(err => {
          //失败
          _this.InfoTip.errorTip(_this, err);
        })

      },

      /**
       * @Description  :获取业务子网信息
       */
      getAllEveSubnetInit: function () {
        console.log('获取全部业务子网信息:')
        let _this = this
        ServiceSubnetService.getAllEveSubnetCollection().then(result => {
          //成功
          _this.EveSubnetList = Object.values(result)
        }).catch(err => {
          //失败
          _this.InfoTip.errorTip(_this, err);

        });

      },

      /**
       * @Description  :增删改后调用,重新加载table
       */
      getAllEveSubnet: function (vue) {
        console.log('获取全部业务子网信息:')

        ServiceSubnetService.getAllEveSubnetCollection().then(result => {
          //成功
          vue.EveSubnetList = Object.values(result)
          console.log("刷新成功")

        }).catch(err => {
          //失败
          vue.InfoTip.errorTip(vue, err);
        });

      },


      /**
       * @Description  :创建初始化
       */
      createEveSubnetInit: function () {
        var idList = new Array();
        for (var i = 0; i < this.EveSubnetList.length; i++) {
          idList[i] = parseInt(this.EveSubnetList[i]['serviceSubnetID']);
        }
        var tempid = 0
        for (var j = 0; j < idList.length; j++) {
          if (idList[j] > tempid) {
            tempid = idList[j]
          }
        }
        tempid += 1
        this.createAndCopyTitle = this.$t('EthernetSubnetDialog.serviceSubnetCreation');
        this.createAndCopyInitList = {
          'serviceSubnetID': tempid,
          'serviceSubnetName': "",
          'serviceSubnetTopo': "",
          'serviceTypeID': "",
          'deviceKey': '',
          'port': '',
          'subnetDevices': [],
        };
        console.log(this.createAndCopyInitList.serviceSubnetID)
        this.createAndCopyEthernetSubnetCommand.execute();
      },


      /**
       * @Description  :修改业务子网信息初始化
       */
      updateEveSubnetInit: function () {
        if (this.multipleSelection.length === 0) {
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.PLEASE_SELECT_ONLY_ONE_RECORD_TO_MODIFY))
          return;
        } else if (this.multipleSelection.length > 1) {
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.PLEASE_SELECT_ONLY_ONE_RECORD_TO_MODIFY))
          return;
        } else {
          this.currentRow = this.multipleSelection[0];
          this.updateInitList = {
            'serviceSubnetID': this.currentRow.serviceSubnetID,
            'serviceSubnetName': this.currentRow.serviceSubnetName,
            'serviceSubnetTopo': this.currentRow.serviceSubnetTopo,
            'serviceTypeID': this.currentRow.serviceTypeID,
            'currentDeviceList': this.currentRow.subnetDevices,
            'serviceSubnetIDForUpdate': this.currentRow.serviceSubnetID,
            'serviceSubnetNameForUpdate': this.currentRow.serviceSubnetName,
          };
          this.updateEthernetSubnetCommand.execute();
        }
      },


      /**
       * @Description  :复制业务子网信息初始化
       */
      copyEveSubnetInit: function () {
        this.currentDeviceList = new Array()
        if (this.multipleSelection.length == 0) {
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.PLEASE_SELECT_ONE_RECORD_TO_DUPLICATE))
          return;
        } else if (this.multipleSelection.length > 1) {
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.PLEASE_SELECT_ONLY_ONE_RECORD_TO_DUPLICATE))
          return;
        }
        else {

          var idList = new Array();
          for (var i = 0; i < this.EveSubnetList.length; i++) {
            idList[i] = parseInt(this.EveSubnetList[i]['serviceSubnetID']);
          }
          console.log('-------------------------------------------------------------------------------------------------------------------------------')
          var tempid = 0
          for (var j = 0; j < idList.length; j++) {
            console.log(idList[j])
            if (idList[j] > tempid) {
              tempid = idList[j]
            }
          }

          this.createAndCopyTitle = this.$t('EthernetSubnetDialog.duplicateServiceSubnet');
          this.currentRow = this.multipleSelection[0];
          this.createAndCopyInitList = {
            'serviceSubnetID': tempid + 1,
            'serviceSubnetName': this.currentRow.serviceSubnetName,
            'serviceSubnetTopo': this.currentRow.serviceSubnetTopo,
            'serviceTypeID': this.currentRow.serviceTypeID,
            'deviceKey': '',
            'port': '',
            'currentDeviceList': this.currentRow.subnetDevices,
            'serviceSubnetIDForCopy': this.currentRow.serviceSubnetID,
//            'serviceSubnetNameForCopy': this.currentRow.serviceSubnetName,


          };


          console.log(this.currentRow.subnetDevices)
          this.createAndCopyEthernetSubnetCommand.execute();
        }
      },


      /**
       * @Description  :删除业务子网信息初始化(支持批量)
       */
      deleteEveSubnetInit: function () {

        if (this.multipleSelection.length == 0) {
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.PLEASE_SELECT_ONE_RECORD_TO_DELETE))
          return;
        } else if (this.multipleSelection.length > 1) {
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.PLEASE_SELECT_ONLY_ONE_RECORD_TO_DELETE))
          return;
        }

        this.deleteList = []
        for (var i = 0; i < this.multipleSelection.length; i++) {
          this.deleteList.push(this.multipleSelection[i]['serviceSubnetID']);
        }
        this.deleteEthernetSubnetCommand.execute()

      },


    },
    watch: {
      commandContext(newVal, oldVal) {
        if (JSON.stringify(newVal) === '{}') {
          this.getAllEveSubnet(this)
          this.$refs.singleTable.clearSelection();
        }
        deep: true
      },
    },
  }
</script>

<style scoped>
</style>