2020-02-21 17:57:19 +08:00
|
|
|
|
<template>
|
2021-04-13 20:33:12 +08:00
|
|
|
|
<div>
|
2021-04-08 20:28:54 +08:00
|
|
|
|
<nz-data-list
|
|
|
|
|
|
ref="dataList"
|
2021-04-13 20:33:12 +08:00
|
|
|
|
:api="url"
|
|
|
|
|
|
:layout="['searchInput', 'elementSet']"
|
2021-04-08 20:28:54 +08:00
|
|
|
|
:custom-table-title.sync="tools.customTableTitle"
|
|
|
|
|
|
:from="fromRoute.dc"
|
2021-04-13 20:33:12 +08:00
|
|
|
|
:search-msg="searchMsg">
|
2021-04-08 20:28:54 +08:00
|
|
|
|
<template v-slot:top-tool-right>
|
2021-04-13 20:33:12 +08:00
|
|
|
|
<button id="dc-add" v-has="'dc_add'" :title="$t('overall.createDatacenter')" class="top-tool-btn margin-r-10"
|
2021-04-08 20:28:54 +08:00
|
|
|
|
type="button" @click="add">
|
|
|
|
|
|
<i class="nz-icon-create-square nz-icon"></i>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
<delete-button id="account-list-batch-delete" v-has="'dc_delete'" :delete-objs="batchDeleteObjs" api="dc" @after="getTableData" @before="delFlag=true"></delete-button>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-slot:default="slotProps">
|
2021-04-13 20:33:12 +08:00
|
|
|
|
<dc-table
|
2021-04-08 20:28:54 +08:00
|
|
|
|
ref="dataTable"
|
2021-04-13 20:33:12 +08:00
|
|
|
|
v-loading="slotProps.loading"
|
|
|
|
|
|
:api="url"
|
|
|
|
|
|
:custom-table-title="tools.customTableTitle"
|
2021-04-07 09:58:34 +08:00
|
|
|
|
:height="mainTableHeight"
|
2021-04-13 20:33:12 +08:00
|
|
|
|
:table-data="tableData"
|
|
|
|
|
|
@del="del"
|
|
|
|
|
|
@edit="edit"
|
|
|
|
|
|
@orderBy="tableDataSort"
|
|
|
|
|
|
@reload="getTableData"
|
|
|
|
|
|
@selectionChange="selectionChange"
|
|
|
|
|
|
@showBottomBox="(targetTab, object) => { $refs.dataList.showBottomBox(targetTab, object) }"></dc-table>
|
2021-04-08 20:28:54 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
<!-- 分页组件 -->
|
|
|
|
|
|
<template v-slot:pagination>
|
|
|
|
|
|
<Pagination ref="Pagination" :pageObj="pageObj" :tableId="tableId" @pageNo='pageNo' @pageSize='pageSize'></Pagination>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</nz-data-list>
|
2020-07-16 17:33:20 +08:00
|
|
|
|
<transition name="right-box">
|
2021-04-08 20:28:54 +08:00
|
|
|
|
<dc-box v-if="rightBox.dc.show" :dc="object" :user-data="userData" @close="closeDcBox" @reload="getTableData"></dc-box>
|
2020-07-16 17:33:20 +08:00
|
|
|
|
</transition>
|
|
|
|
|
|
<transition name="right-box">
|
2021-04-08 20:28:54 +08:00
|
|
|
|
<traffic-setting-box v-if="rightBox.trafficSetting.show" ref="trafficBox" :dc="object" @close="closeTrafficBox"></traffic-setting-box>
|
2020-07-16 17:33:20 +08:00
|
|
|
|
</transition>
|
2020-12-25 11:52:27 +08:00
|
|
|
|
<span v-if="dcDataRefresh" style="display: none"></span>
|
2020-07-16 17:33:20 +08:00
|
|
|
|
</div>
|
2020-02-21 17:57:19 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
<script>
|
2021-04-08 20:28:54 +08:00
|
|
|
|
import bus from '@/libs/bus'
|
|
|
|
|
|
import dcBox from '@/components/common/rightBox/dcBox' // dc弹框
|
|
|
|
|
|
import trafficSettingBox from '@/components/common/rightBox/trafficSetting/trafficSettingBox'
|
|
|
|
|
|
import deleteButton from '@/components/common/deleteButton'
|
|
|
|
|
|
import nzDataList from '@/components/common/table/nzDataList'
|
2021-04-13 20:33:12 +08:00
|
|
|
|
import dataListMixin from '@/components/common/mixin/dataList'
|
|
|
|
|
|
import dcTable from '@/components/common/table/settings/dcTable'
|
2021-03-19 18:52:19 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: 'dc',
|
|
|
|
|
|
components: {
|
2021-04-08 20:28:54 +08:00
|
|
|
|
trafficSettingBox,
|
|
|
|
|
|
dcBox,
|
|
|
|
|
|
deleteButton,
|
2021-04-13 20:33:12 +08:00
|
|
|
|
nzDataList,
|
|
|
|
|
|
dcTable
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
mixins: [dataListMixin],
|
2021-03-19 18:52:19 +08:00
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
2021-04-13 20:33:12 +08:00
|
|
|
|
url: 'dc',
|
2021-03-19 18:52:19 +08:00
|
|
|
|
tableId: 'dcTable', // 需要分页的table的id,用于记录每页数量
|
2021-04-08 20:28:54 +08:00
|
|
|
|
blankObject: {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
id: '',
|
|
|
|
|
|
name: '',
|
|
|
|
|
|
location: '',
|
|
|
|
|
|
tel: '',
|
|
|
|
|
|
principal: '',
|
|
|
|
|
|
state: 'ON',
|
|
|
|
|
|
longitude: undefined,
|
|
|
|
|
|
latitude: undefined
|
2020-02-21 17:57:19 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
rightBox: {
|
|
|
|
|
|
dc: { show: false },
|
|
|
|
|
|
trafficSetting: { show: false }
|
2020-02-21 17:57:19 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
searchMsg: { // 给搜索框子组件传递的信息
|
|
|
|
|
|
zheze_none: true,
|
|
|
|
|
|
searchLabelList: [{
|
|
|
|
|
|
id: 10,
|
|
|
|
|
|
name: this.$t('overall.name'),
|
|
|
|
|
|
type: 'input',
|
|
|
|
|
|
label: 'name',
|
|
|
|
|
|
disabled: false
|
|
|
|
|
|
}]
|
2020-03-30 14:14:09 +08:00
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
regNum: /^[0-9]+.?[0-9]*/,
|
2021-03-19 18:52:19 +08:00
|
|
|
|
tabShow: 1, // 控制显示一级页面和二级页面 1 dc 2cabinet
|
2021-04-08 20:28:54 +08:00
|
|
|
|
userData: []
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
computed: {
|
|
|
|
|
|
dcDataRefresh () { // 通过vuex更新dc 需要该属性到页面 否则不被监听
|
|
|
|
|
|
if (this.$store.getters.getDcDataRefresh) {
|
|
|
|
|
|
this.getTableData()
|
|
|
|
|
|
}
|
|
|
|
|
|
return this.$store.getters.getDcDataRefresh
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
assetStatClassName (param) {
|
|
|
|
|
|
if (param.column.label == this.$t('config.dc.assets')) {
|
|
|
|
|
|
return 'asset-state'
|
|
|
|
|
|
}
|
|
|
|
|
|
return ''
|
|
|
|
|
|
},
|
|
|
|
|
|
edit (u) {
|
|
|
|
|
|
this.dc = JSON.parse(JSON.stringify(u))
|
2021-04-13 20:33:12 +08:00
|
|
|
|
if (!this.regNum.test(this.dc.longitude)) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.dc.longitude = undefined
|
|
|
|
|
|
}
|
2021-04-13 20:33:12 +08:00
|
|
|
|
if (!this.regNum.test(this.dc.latitude)) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.dc.latitude = undefined
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!this.dc.area) {
|
|
|
|
|
|
this.$set(this.dc, 'area', { id: '', name: '' })
|
|
|
|
|
|
}
|
|
|
|
|
|
this.rightBox.dc.show = true
|
|
|
|
|
|
},
|
|
|
|
|
|
detail (u) {
|
2021-04-08 20:28:54 +08:00
|
|
|
|
this.bottomBox.object = JSON.parse(JSON.stringify(u))
|
|
|
|
|
|
if (!this.bottomBox.object.area) {
|
|
|
|
|
|
this.$set(this.bottomBox.object, 'area', { id: '', name: '' })
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
this.bottomBox.targetTab = 'detail'
|
|
|
|
|
|
this.bottomBox.showSubList = true
|
|
|
|
|
|
},
|
|
|
|
|
|
add () {
|
2021-04-08 20:28:54 +08:00
|
|
|
|
this.object = this.newObject()
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.rightBox.dc.show = true
|
|
|
|
|
|
},
|
|
|
|
|
|
closeDcBox (refresh) {
|
|
|
|
|
|
this.rightBox.dc.show = false
|
|
|
|
|
|
if (refresh) {
|
|
|
|
|
|
this.delFlag = true
|
|
|
|
|
|
this.getTableData()
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
closeTrafficBox (refresh) {
|
|
|
|
|
|
this.rightBox.trafficSetting.show = false
|
|
|
|
|
|
if (refresh) {
|
|
|
|
|
|
this.delFlag = true
|
|
|
|
|
|
this.getTableData()
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
statusChange (idc) {
|
2021-04-08 19:36:14 +08:00
|
|
|
|
this.$put('dc', idc).then(response => {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.rightBox.show = false
|
|
|
|
|
|
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg)
|
2020-07-15 18:32:25 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.getTableData()
|
|
|
|
|
|
})
|
2020-03-25 18:38:13 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
getUserData () {
|
|
|
|
|
|
return new Promise(resolve => {
|
2021-04-08 19:36:14 +08:00
|
|
|
|
this.$get('sys/user', { pageSize: -1, pageNo: 1 }).then(response => {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.userData = response.data.list
|
2020-12-31 17:41:40 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
resolve()
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
regNumTest (val) { // 校验是否是数字
|
2021-04-13 20:33:12 +08:00
|
|
|
|
return this.regNum.test(val)
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
initEvent () {
|
|
|
|
|
|
bus.$on('dc-list-change', () => {
|
|
|
|
|
|
this.getTableData()
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
beforeDestroy () {
|
|
|
|
|
|
bus.$off('dc-list-change')
|
|
|
|
|
|
},
|
|
|
|
|
|
mounted () {
|
|
|
|
|
|
this.getUserData()
|
2020-02-21 17:57:19 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
2020-02-21 17:57:19 +08:00
|
|
|
|
</script>
|
2020-10-12 13:46:31 +08:00
|
|
|
|
<style scoped>
|
2020-10-16 14:13:02 +08:00
|
|
|
|
/deep/ td .nz-icon-gear:before{
|
2020-10-12 13:46:31 +08:00
|
|
|
|
color: #606266;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|