This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
nezha-nezha-fronted/nezha-fronted/src/components/page/config/dc.vue

212 lines
6.1 KiB
Vue
Raw Normal View History

2020-02-21 17:57:19 +08:00
<template>
2021-04-13 20:33:12 +08:00
<div>
<nz-data-list
ref="dataList"
2021-04-13 20:33:12 +08:00
:api="url"
2021-08-23 18:50:08 +08:00
:layout="['searchInput', 'elementSet', 'pagination']"
:custom-table-title.sync="tools.customTableTitle"
:from="fromRoute.dc"
:search-msg="searchMsg"
@search="search"
>
<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"
type="button" @click="add">
<i class="nz-icon-create-square nz-icon"></i>
</button>
<top-tool-more-options
ref="export"
id="model"
:params="searchLabel"
:permissions="{
import: 'dc_add',
export: 'dc_view'
}"
class="top-tool-export margin-r-10"
export-file-name="datacenter"
export-url="/dc/export"
import-url="/dc/import"
@afterImport="getTableData"
>
<template v-slot:before>
<div>
<el-dropdown-item>
<delete-button :type="'link'" :title="$t('overall.batchDel')" id="account-list-batch-delete" v-has="'dc_delete'" :delete-objs="batchDeleteObjs" api="dc" @after="getTableData" @before="delFlag=true"></delete-button>
</el-dropdown-item>
</div>
</template>
</top-tool-more-options>
</template>
<template v-slot:default="slotProps">
2021-04-13 20:33:12 +08:00
<dc-table
ref="dataTable"
2021-05-18 19:18:14 +08:00
v-loading="tools.loading"
2021-04-13 20:33:12 +08:00
:api="url"
:custom-table-title="tools.customTableTitle"
:height="mainTableHeight"
2021-04-13 20:33:12 +08:00
:table-data="tableData"
@del="del"
@edit="edit"
2021-08-26 18:05:40 +08:00
@copy="copy"
2021-04-13 20:33:12 +08:00
@orderBy="tableDataSort"
@reload="getTableData"
@selectionChange="selectionChange"
2021-06-02 16:55:17 +08:00
@statusChange='statusChange'
2021-04-13 20:33:12 +08:00
@showBottomBox="(targetTab, object) => { $refs.dataList.showBottomBox(targetTab, object) }"></dc-table>
</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-05-11 16:46:16 +08:00
<dc-box v-if="rightBox.show" :obj="object" :user-data="userData" @close="closeRightBox" @reload="getTableData"></dc-box>
2020-07-16 17:33:20 +08:00
</transition>
2021-05-12 16:19:43 +08:00
<transition name="right-box">
<cabinetBox v-if="cabinetBoxShow" :obj="cabinet" :current-dc="{}" @close="closeRightBox" :dcDisabled="false" @reload="getTableData"></cabinetBox>
</transition>
2020-07-16 17:33:20 +08:00
</div>
2020-02-21 17:57:19 +08:00
</template>
<script>
import dcBox from '@/components/common/rightBox/dcBox' // dc弹框
2021-05-12 16:19:43 +08:00
import cabinetBox from '@/components/common/rightBox/cabinetBox' // 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'
import topToolMoreOptions from '@/components/common/popBox/topToolMoreOptions'
2021-03-19 18:52:19 +08:00
export default {
name: 'dc',
components: {
trafficSettingBox,
dcBox,
deleteButton,
2021-04-13 20:33:12 +08:00
nzDataList,
2021-05-12 16:19:43 +08:00
dcTable,
cabinetBox,
topToolMoreOptions
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用于记录每页数量
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-05-12 16:19:43 +08:00
cabinet: {
id: '',
idcId: '',
name: '',
remark: '',
seq: '',
uSize: 1
},
2021-03-19 18:52:19 +08:00
searchMsg: { // 给搜索框子组件传递的信息
zheze_none: true,
2021-05-10 15:59:39 +08:00
searchLabelList: [
{
name: 'ID',
type: 'input',
label: 'ids',
disabled: false
},
{
name: this.$t('overall.name'),
type: 'input',
label: 'name',
disabled: false
},
{
name: this.$t('asset.location'),
type: 'input',
label: 'location',
disabled: false
},
{
name: this.$t('asset.state'),
type: 'selectString',
label: 'dcState',
readonly: true,
2021-05-10 15:59:39 +08:00
disabled: false
}
]
},
2021-04-13 20:33:12 +08:00
regNum: /^[0-9]+.?[0-9]*/,
2021-05-12 16:19:43 +08:00
userData: [],
cabinetBoxShow: false
2021-03-19 18:52:19 +08:00
}
},
methods: {
2021-05-11 16:46:16 +08:00
statusChange (dc) {
this.$put(this.url, dc).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)
}
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
}
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-05-12 16:19:43 +08:00
},
addCabinet () {
this.cabinetBoxShow = true
},
closeRightBox (refresh) {
this.rightBox.show = false
this.cabinetBoxShow = false
if (refresh) {
this.delFlag = true
this.getTableData()
}
2021-03-19 18:52:19 +08:00
}
},
mounted () {
this.getUserData()
2021-05-12 16:19:43 +08:00
},
watch: {
$route: {
immediate: true,
handler () {
// 是否弹出侧滑
const add = this.$route.query.add
if (add) {
if (add === 'dc') {
this.add()
}
if (add === 'cabinet') {
this.addCabinet()
}
}
2021-05-11 22:29:14 +08:00
}
}
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>
/deep/ td .nz-icon-gear:before{
2020-10-12 13:46:31 +08:00
color: #606266;
}
</style>