2019-11-29 15:00:26 +08:00
|
|
|
|
<template>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
<div>
|
|
|
|
|
|
<nz-data-list
|
|
|
|
|
|
ref="dataList"
|
|
|
|
|
|
:api="url"
|
|
|
|
|
|
:custom-table-title.sync="tools.customTableTitle"
|
2021-04-29 22:24:38 +08:00
|
|
|
|
:from="fromRoute.asset"
|
|
|
|
|
|
:layout="dataListLayout"
|
|
|
|
|
|
:search-msg="searchMsg"
|
|
|
|
|
|
@search="search"
|
|
|
|
|
|
>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
<template v-slot:top-tool-right>
|
2021-05-14 18:32:47 +08:00
|
|
|
|
<button id="asset-filter" :class="{ 'is-focus': dataListLayout.indexOf('clickSearch') > -1 }" class="top-tool-btn margin-r-10" @click.stop="showClickSearch">
|
|
|
|
|
|
<i class="nz-icon nz-icon-funnel"></i>
|
|
|
|
|
|
</button>
|
2021-05-14 17:09:57 +08:00
|
|
|
|
<button id="asset-create-asset" v-has="'asset_add'" :title="$t('overall.createAsset')" class="top-tool-btn" @click.stop="add">
|
|
|
|
|
|
<i class="nz-icon nz-icon-create-square"></i>
|
2021-04-29 22:24:38 +08:00
|
|
|
|
</button>
|
2021-05-14 17:09:57 +08:00
|
|
|
|
<top-tool-more-options
|
2021-05-17 16:41:01 +08:00
|
|
|
|
ref="export"
|
2021-05-14 17:09:57 +08:00
|
|
|
|
id="model"
|
2021-05-17 16:41:01 +08:00
|
|
|
|
:params="searchLabel"
|
2021-05-14 17:09:57 +08:00
|
|
|
|
:permissions="{
|
|
|
|
|
|
import: 'asset_add',
|
|
|
|
|
|
export: 'asset_view'
|
|
|
|
|
|
}"
|
|
|
|
|
|
class="top-tool-export margin-l-10 margin-r-10"
|
2021-06-30 16:56:18 +08:00
|
|
|
|
export-file-name="asset"
|
2021-05-12 14:53:55 +08:00
|
|
|
|
export-url="/asset/asset/export"
|
|
|
|
|
|
import-url="/asset/asset/import"
|
2021-04-22 12:25:23 +08:00
|
|
|
|
@afterImport="getTableData"
|
2020-08-03 20:12:20 +08:00
|
|
|
|
>
|
2021-05-14 17:09:57 +08:00
|
|
|
|
<template v-slot:before>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<el-dropdown-item>
|
|
|
|
|
|
<div id="asset-batch-asset" v-has="'asset_edit'" @click.stop="batchEdit"><i class="nz-icon nz-icon-batch-edit"></i>{{$t('overall.batchEdit')}}</div>
|
|
|
|
|
|
</el-dropdown-item>
|
2021-05-14 17:19:21 +08:00
|
|
|
|
<el-dropdown-item>
|
|
|
|
|
|
<delete-button :type="'link'" :title="$t('overall.batchDel')" id="asset-list-batch-delete" v-has="'asset_delete'" :api="url" :delete-objs="batchDeleteObjs" @after="getTableData" @before="delFlag=true"></delete-button>
|
|
|
|
|
|
</el-dropdown-item>
|
2021-05-14 17:09:57 +08:00
|
|
|
|
</div>
|
2020-09-08 11:18:18 +08:00
|
|
|
|
</template>
|
2021-05-14 17:09:57 +08:00
|
|
|
|
</top-tool-more-options>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
</template>
|
2021-04-23 19:58:08 +08:00
|
|
|
|
<template v-slot:search>
|
2021-04-26 21:42:15 +08:00
|
|
|
|
<click-search ref="clickSearch" :select-value.sync="selectValue" :title-search-list="titleSearchList" @reload="reloadTable"/>
|
2021-04-23 19:58:08 +08:00
|
|
|
|
</template>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
<template v-slot:default="slotProps">
|
|
|
|
|
|
<asset-table
|
|
|
|
|
|
ref="dataTable"
|
2021-05-18 19:18:14 +08:00
|
|
|
|
v-loading="tools.loading"
|
2021-04-22 12:25:23 +08:00
|
|
|
|
:api="url"
|
|
|
|
|
|
:custom-table-title="tools.customTableTitle"
|
2021-04-29 22:24:38 +08:00
|
|
|
|
:height="dataListLayout.indexOf('clickSearch') > -1 ? assetTableHeight : mainTableHeight"
|
2021-04-22 12:25:23 +08:00
|
|
|
|
:table-data="tableData"
|
|
|
|
|
|
@cli="cli"
|
|
|
|
|
|
@del="del"
|
|
|
|
|
|
@edit="edit"
|
2021-04-26 21:42:15 +08:00
|
|
|
|
@duplicate="duplicate"
|
2021-04-22 12:25:23 +08:00
|
|
|
|
@orderBy="tableDataSort"
|
|
|
|
|
|
@reload="getTableData"
|
|
|
|
|
|
@selectionChange="selectionChange"
|
2021-06-01 14:26:09 +08:00
|
|
|
|
@addSilence="addSilence"
|
2021-04-22 12:25:23 +08:00
|
|
|
|
@showBottomBox="(targetTab, object) => { $refs.dataList.showBottomBox(targetTab, object) }"></asset-table>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<!-- 分页组件 -->
|
|
|
|
|
|
<template v-slot:pagination>
|
|
|
|
|
|
<Pagination ref="Pagination" :pageObj="pageObj" :tableId="tableId" @pageNo='pageNo' @pageSize='pageSize'></Pagination>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</nz-data-list>
|
2020-07-24 19:22:52 +08:00
|
|
|
|
<transition name="right-box">
|
2021-04-22 12:25:23 +08:00
|
|
|
|
<asset-box v-if="rightBox.show"
|
|
|
|
|
|
ref="assetBox"
|
|
|
|
|
|
:dc-data="dcData"
|
|
|
|
|
|
:field-group-data="fieldGroupData"
|
|
|
|
|
|
:from="fromRoute.asset"
|
|
|
|
|
|
:obj="object"
|
|
|
|
|
|
:snmp-credential-data="snmpCredentialData"
|
|
|
|
|
|
:state-data="stateData"
|
|
|
|
|
|
:type-data="typeData"
|
|
|
|
|
|
@close="closeRightBox"
|
|
|
|
|
|
@refresh="getTableData"></asset-box>
|
2020-07-24 19:22:52 +08:00
|
|
|
|
</transition>
|
2020-11-04 17:54:55 +08:00
|
|
|
|
<transition name="right-box">
|
2021-04-22 12:25:23 +08:00
|
|
|
|
<asset-batch-edit-box v-if="rightBox.batchShow"
|
|
|
|
|
|
:field-group-data="fieldGroupData"
|
|
|
|
|
|
:snmp-credential-data="snmpCredentialData"
|
|
|
|
|
|
:state-data="stateData"
|
|
|
|
|
|
@close="closeRightBox"
|
|
|
|
|
|
@refresh="getTableData"></asset-batch-edit-box>
|
2020-11-04 17:54:55 +08:00
|
|
|
|
</transition>
|
2021-06-01 15:19:47 +08:00
|
|
|
|
<transition name="right-box"><alert-silence-box v-if='silenceBoxShow' :alert-silence="objectSilence" @close="closeSilenceBox"></alert-silence-box>
|
|
|
|
|
|
</transition>
|
2020-01-02 18:13:01 +08:00
|
|
|
|
</div>
|
2019-11-29 15:00:26 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-04-22 12:25:23 +08:00
|
|
|
|
import deleteButton from '@/components/common/deleteButton'
|
|
|
|
|
|
import assetBox from '@/components/common/rightBox/asset/assetBox'
|
|
|
|
|
|
import assetBatchEditBox from '@/components/common/rightBox/asset/assetBatchEditBox'
|
|
|
|
|
|
import nzDataList from '@/components/common/table/nzDataList'
|
|
|
|
|
|
import dataListMixin from '@/components/common/mixin/dataList'
|
|
|
|
|
|
import assetTable from '@/components/common/table/asset/assetTable'
|
2021-04-26 21:42:15 +08:00
|
|
|
|
import clickSearch from '@/components/common/labelFilter/clickSearch'
|
2021-05-14 17:09:57 +08:00
|
|
|
|
import topToolMoreOptions from '@/components/common/popBox/topToolMoreOptions'
|
2021-06-01 15:19:47 +08:00
|
|
|
|
import alertSilenceBox from '@/components/common/rightBox/alertSilenceBox'
|
2021-03-11 16:46:09 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: 'asset',
|
|
|
|
|
|
components: {
|
2021-04-22 12:25:23 +08:00
|
|
|
|
deleteButton,
|
|
|
|
|
|
assetBox,
|
|
|
|
|
|
nzDataList,
|
|
|
|
|
|
assetBatchEditBox,
|
|
|
|
|
|
assetTable,
|
2021-04-23 19:58:08 +08:00
|
|
|
|
clickSearch,
|
2021-06-01 14:26:09 +08:00
|
|
|
|
topToolMoreOptions,
|
|
|
|
|
|
alertSilenceBox
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
2021-04-22 12:25:23 +08:00
|
|
|
|
mixins: [dataListMixin],
|
2021-03-19 18:52:19 +08:00
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
2021-04-22 12:25:23 +08:00
|
|
|
|
url: 'asset/asset',
|
2021-05-17 16:41:01 +08:00
|
|
|
|
filter: {},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// 侧滑
|
|
|
|
|
|
rightBox: {
|
|
|
|
|
|
batchShow: false
|
|
|
|
|
|
},
|
2021-06-01 14:26:09 +08:00
|
|
|
|
silenceBoxShow: false,
|
2021-06-01 17:10:54 +08:00
|
|
|
|
dataListLayout: ['searchInput', 'elementSet', 'clickSearch'],
|
2021-04-26 21:42:15 +08:00
|
|
|
|
assetTableHeight: `calc(100% - ${48 + 201 + 20}px)`,
|
2021-04-22 12:25:23 +08:00
|
|
|
|
blankObject: {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
id: '',
|
2021-04-22 12:25:23 +08:00
|
|
|
|
name: '',
|
|
|
|
|
|
pid: '',
|
2021-03-19 18:52:19 +08:00
|
|
|
|
sn: '',
|
2021-04-22 12:25:23 +08:00
|
|
|
|
manageIp: '',
|
|
|
|
|
|
stateId: '',
|
|
|
|
|
|
purchaseDate: null,
|
|
|
|
|
|
dcId: '',
|
2021-03-19 18:52:19 +08:00
|
|
|
|
cabinetId: '',
|
2021-04-22 12:25:23 +08:00
|
|
|
|
brandId: '',
|
|
|
|
|
|
brand: { id: '', name: '' },
|
2021-03-19 18:52:19 +08:00
|
|
|
|
modelId: '',
|
2021-04-22 12:25:23 +08:00
|
|
|
|
model: { id: '', name: '' },
|
|
|
|
|
|
type: { name: '', id: '' },
|
|
|
|
|
|
brandAndModel: [],
|
|
|
|
|
|
typeId: '',
|
|
|
|
|
|
authProtocolPort: '',
|
|
|
|
|
|
authType: '',
|
|
|
|
|
|
authUsername: '',
|
|
|
|
|
|
authPin: '',
|
|
|
|
|
|
authPriKey: '',
|
|
|
|
|
|
authUserTip: '',
|
|
|
|
|
|
authPinTip: '',
|
|
|
|
|
|
fields: [],
|
2021-03-19 18:52:19 +08:00
|
|
|
|
accounts: []
|
|
|
|
|
|
},
|
2021-06-01 14:26:09 +08:00
|
|
|
|
blankSilenceObject: {
|
|
|
|
|
|
id: '',
|
|
|
|
|
|
startAt: '',
|
|
|
|
|
|
endAt: '',
|
|
|
|
|
|
ruleId: '',
|
|
|
|
|
|
type: 'asset',
|
|
|
|
|
|
linkId: '',
|
|
|
|
|
|
remark: '',
|
|
|
|
|
|
time: [],
|
|
|
|
|
|
matchers: [
|
|
|
|
|
|
{ name: '', value: '', regex: 0 }
|
|
|
|
|
|
],
|
|
|
|
|
|
name: ''
|
|
|
|
|
|
},
|
|
|
|
|
|
objectSilence: {},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
tableId: 'assetTable', // 需要分页的table的id,用于记录每页数量
|
|
|
|
|
|
searchMsg: { // 给搜索框子组件传递的信息
|
|
|
|
|
|
searchLabelList: [{
|
|
|
|
|
|
name: 'ID',
|
|
|
|
|
|
type: 'input',
|
2021-05-10 15:59:39 +08:00
|
|
|
|
label: 'ids',
|
|
|
|
|
|
disabled: false
|
|
|
|
|
|
}, {
|
2021-05-20 11:39:12 +08:00
|
|
|
|
name: this.$t('overall.name'),
|
2021-05-10 15:59:39 +08:00
|
|
|
|
type: 'input',
|
|
|
|
|
|
label: 'name',
|
2021-03-19 18:52:19 +08:00
|
|
|
|
disabled: false
|
|
|
|
|
|
}, {
|
|
|
|
|
|
name: 'SN',
|
|
|
|
|
|
type: 'input',
|
|
|
|
|
|
label: 'sn',
|
|
|
|
|
|
disabled: false
|
|
|
|
|
|
}, {
|
2021-05-10 15:59:39 +08:00
|
|
|
|
name: 'IP',
|
2021-03-19 18:52:19 +08:00
|
|
|
|
type: 'input',
|
2021-05-10 15:59:39 +08:00
|
|
|
|
label: 'manageIp',
|
2021-03-19 18:52:19 +08:00
|
|
|
|
disabled: false
|
|
|
|
|
|
}, {
|
|
|
|
|
|
name: this.$t('asset.state'),
|
2021-05-10 15:59:39 +08:00
|
|
|
|
type: 'assetState',
|
|
|
|
|
|
label: 'stateIds',
|
2021-03-19 18:52:19 +08:00
|
|
|
|
disabled: false
|
|
|
|
|
|
}]
|
|
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
|
2021-04-22 12:25:23 +08:00
|
|
|
|
modelData: [],
|
|
|
|
|
|
stateData: [],
|
|
|
|
|
|
typeData: [],
|
|
|
|
|
|
dcData: [],
|
|
|
|
|
|
snmpCredentialData: [],
|
2021-04-23 19:58:08 +08:00
|
|
|
|
fieldGroupData: [],
|
|
|
|
|
|
titleSearchList: {
|
2021-06-07 15:09:11 +08:00
|
|
|
|
ready: false,
|
2021-04-23 19:58:08 +08:00
|
|
|
|
dc: {
|
|
|
|
|
|
label: this.$t('overall.dc'),
|
|
|
|
|
|
key: 'dcIds',
|
|
|
|
|
|
type: 'checkBox',
|
|
|
|
|
|
children: [],
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
showMore: false,
|
|
|
|
|
|
width: 0,
|
2021-06-07 15:09:11 +08:00
|
|
|
|
index: -1
|
2021-04-23 19:58:08 +08:00
|
|
|
|
},
|
|
|
|
|
|
type: {
|
|
|
|
|
|
label: this.$t('overall.type'),
|
|
|
|
|
|
key: 'typeIds',
|
|
|
|
|
|
type: 'checkBox',
|
|
|
|
|
|
children: [],
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
showMore: false,
|
|
|
|
|
|
width: 0,
|
2021-06-07 15:09:11 +08:00
|
|
|
|
index: -1
|
2021-04-23 19:58:08 +08:00
|
|
|
|
},
|
|
|
|
|
|
ping: {
|
|
|
|
|
|
label: 'ping',
|
|
|
|
|
|
key: 'ping',
|
|
|
|
|
|
type: 'checkBox',
|
|
|
|
|
|
children: [
|
|
|
|
|
|
{ key: 'Down', value: 0, name: 'Down' },
|
|
|
|
|
|
{ key: 'Up', value: 1, name: 'Up' }
|
|
|
|
|
|
],
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
showMore: false,
|
|
|
|
|
|
width: 0,
|
2021-06-07 15:09:11 +08:00
|
|
|
|
index: -1
|
2021-04-23 19:58:08 +08:00
|
|
|
|
},
|
|
|
|
|
|
model: {
|
|
|
|
|
|
label: this.$t('asset.model'),
|
|
|
|
|
|
key: 'modelIds',
|
|
|
|
|
|
type: 'dropdownCheckBox',
|
|
|
|
|
|
children: [],
|
|
|
|
|
|
show: true,
|
2021-04-26 21:42:15 +08:00
|
|
|
|
showMore: false,
|
2021-04-23 19:58:08 +08:00
|
|
|
|
width: 0,
|
2021-06-07 15:09:11 +08:00
|
|
|
|
index: -1
|
2021-04-23 19:58:08 +08:00
|
|
|
|
},
|
|
|
|
|
|
assetLabel: {
|
|
|
|
|
|
label: 'More',
|
|
|
|
|
|
key: 'fields',
|
|
|
|
|
|
type: 'dropdownCheckBox',
|
|
|
|
|
|
children: [],
|
|
|
|
|
|
show: true,
|
2021-04-26 21:42:15 +08:00
|
|
|
|
showMore: false,
|
2021-04-23 19:58:08 +08:00
|
|
|
|
width: 0,
|
2021-06-07 15:09:11 +08:00
|
|
|
|
index: -1
|
2021-04-23 19:58:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
selectValue: {
|
|
|
|
|
|
dcIds: [],
|
|
|
|
|
|
typeIds: [],
|
|
|
|
|
|
ping: [],
|
|
|
|
|
|
modelIds: [],
|
|
|
|
|
|
fields: ''
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2021-05-25 14:21:14 +08:00
|
|
|
|
cli (row) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
const consoleParam = {
|
2021-05-25 14:21:14 +08:00
|
|
|
|
id: row.id,
|
|
|
|
|
|
host: row.manageIp,
|
|
|
|
|
|
port: row.authProtocolPort
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
this.$store.commit('addConsole', consoleParam)
|
|
|
|
|
|
},
|
2021-04-26 21:42:15 +08:00
|
|
|
|
duplicate (row) {
|
|
|
|
|
|
this.object = { ...row, id: '', name: `${row.name}-copy` }
|
2021-04-23 19:58:08 +08:00
|
|
|
|
this.rightBox.show = true
|
|
|
|
|
|
},
|
2021-04-22 12:25:23 +08:00
|
|
|
|
getStateData () {
|
|
|
|
|
|
return new Promise(resolve => {
|
2021-04-26 21:42:15 +08:00
|
|
|
|
this.$get('asset/stateConf?pageSize=-1').then(response => {
|
2021-04-22 12:25:23 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.stateData = response.data.list
|
2020-01-02 18:13:01 +08:00
|
|
|
|
}
|
2021-04-22 12:25:23 +08:00
|
|
|
|
resolve()
|
|
|
|
|
|
})
|
2021-03-19 18:52:19 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
2021-04-22 12:25:23 +08:00
|
|
|
|
getTypeData () {
|
2021-04-23 19:58:08 +08:00
|
|
|
|
return new Promise(resolve => {
|
2021-04-26 21:42:15 +08:00
|
|
|
|
this.$get('asset/typeConf?pageSize=-1').then(response => {
|
2021-04-23 19:58:08 +08:00
|
|
|
|
if (response.code === 200) {
|
2021-06-07 15:09:11 +08:00
|
|
|
|
resolve(response.data.list.map(d => { return { ...d, value: d.id } }))
|
|
|
|
|
|
// this.titleSearchList.type.children = response.data.list.map(d => { return { ...d, value: d.id } })
|
2021-04-23 19:58:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
resolve()
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
getTypeTreeData () {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
return new Promise(resolve => {
|
2021-04-22 12:25:23 +08:00
|
|
|
|
this.$get('asset/typeConf/tree').then(response => {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (response.code === 200) {
|
2021-04-22 12:25:23 +08:00
|
|
|
|
this.typeData = response.data.list
|
2021-03-11 16:46:09 +08:00
|
|
|
|
}
|
2021-04-22 12:25:23 +08:00
|
|
|
|
resolve()
|
2021-03-19 18:52:19 +08:00
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2021-04-23 19:58:08 +08:00
|
|
|
|
reloadTable (obj) {
|
|
|
|
|
|
Object.keys(obj).forEach(key => {
|
|
|
|
|
|
if (typeof obj[key] === 'string') {
|
2021-04-26 21:42:15 +08:00
|
|
|
|
this.searchCheckBox[key] = obj[key] ? obj[key] : null
|
2021-04-23 19:58:08 +08:00
|
|
|
|
} else {
|
2021-04-26 21:42:15 +08:00
|
|
|
|
obj[key] && obj[key].length > 0 ? this.searchCheckBox[key] = obj[key].join(',') : this.searchCheckBox[key] = null
|
2021-04-23 19:58:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.getTableData()
|
|
|
|
|
|
},
|
2021-04-22 12:25:23 +08:00
|
|
|
|
getDcData () {
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
|
this.$get('dc', { pageSize: -1 }).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.dcData = response.data.list
|
2021-06-07 15:09:11 +08:00
|
|
|
|
resolve(response.data.list.map(d => { return { ...d, value: d.id } }))
|
|
|
|
|
|
// this.titleSearchList.dc.children = response.data.list.map(d => { return { ...d, value: d.id } })
|
2020-10-15 17:12:55 +08:00
|
|
|
|
}
|
2021-04-22 12:25:23 +08:00
|
|
|
|
resolve()
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
2021-04-22 12:25:23 +08:00
|
|
|
|
getSnmpCredentialData () {
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
|
this.$get('snmp/credential', { pageSize: -1 }).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.snmpCredentialData = response.data.list
|
|
|
|
|
|
}
|
|
|
|
|
|
resolve()
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
2021-04-22 12:25:23 +08:00
|
|
|
|
getFieldGroupData () {
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
|
this.$get('asset/field/group', { pageSize: -1 }).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.fieldGroupData = response.data.list
|
|
|
|
|
|
}
|
|
|
|
|
|
resolve()
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
2021-04-23 19:58:08 +08:00
|
|
|
|
getSearchableMetaData () {
|
|
|
|
|
|
return new Promise(resolve => {
|
2021-04-29 22:24:38 +08:00
|
|
|
|
this.$get('asset/field/meta', { pageSize: -1 }).then(response => {
|
2021-04-23 19:58:08 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
const data = []
|
2021-04-29 22:24:38 +08:00
|
|
|
|
const searchableData = response.data.list.filter(d => d.search === 1)
|
|
|
|
|
|
const showData = response.data.list.filter(d => d.display === 1).map(item => {
|
2021-06-02 16:55:17 +08:00
|
|
|
|
return { label: item.name, prop: item.name, show: false, allowed: true, type: 'label' }
|
2021-04-29 22:24:38 +08:00
|
|
|
|
})
|
|
|
|
|
|
searchableData.forEach(m => {
|
2021-04-23 19:58:08 +08:00
|
|
|
|
if (m.param) {
|
|
|
|
|
|
const param = JSON.parse(m.param)
|
|
|
|
|
|
if (param.items) {
|
|
|
|
|
|
data.push({ ...m, children: param.items.map(p => { return { ...p, id: p.name, metaId: m.id } }) })
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2021-06-07 15:09:11 +08:00
|
|
|
|
// this.titleSearchList.assetLabel.children = data
|
|
|
|
|
|
resolve(data)
|
2021-04-29 22:24:38 +08:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
const title = this.tools.customTableTitle
|
|
|
|
|
|
const originalTitle = title.slice(0, this.$refs.dataTable.tableTitle.length) // 原title
|
|
|
|
|
|
const oldLabelTitle = title.slice(this.$refs.dataTable.tableTitle.length, title.length) // 旧labelTitle
|
|
|
|
|
|
|
|
|
|
|
|
const newLabel = showData.filter(item => { return !oldLabelTitle.find(t => { return item.label === t.label }) })
|
|
|
|
|
|
const keepLabel = oldLabelTitle.filter(item => showData.find(t => item.label === t.label))
|
|
|
|
|
|
|
|
|
|
|
|
let result = originalTitle.concat([{ label: 'Label', show: false, NotSet: true, type: 'title', prop: 'table-label' }])
|
|
|
|
|
|
|
|
|
|
|
|
result = result.concat(keepLabel).concat(newLabel)
|
|
|
|
|
|
this.tools.customTableTitle = JSON.parse(JSON.stringify(result))
|
|
|
|
|
|
}, 200)
|
2021-04-23 19:58:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
resolve()
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
getModelData () {
|
2021-04-22 12:25:23 +08:00
|
|
|
|
return new Promise(resolve => {
|
2021-04-26 21:42:15 +08:00
|
|
|
|
this.$get('asset/model?pageSize=-1').then(response => {
|
2021-04-22 12:25:23 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.modelData = response.data.list
|
2021-04-23 19:58:08 +08:00
|
|
|
|
const titleSearchData = {}
|
|
|
|
|
|
this.modelData.forEach(m => {
|
|
|
|
|
|
if (titleSearchData[m.brand.name]) {
|
|
|
|
|
|
titleSearchData[m.brand.name].children.push(m)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
titleSearchData[m.brand.name] = { ...m.brand, children: [m] }
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2021-06-07 15:09:11 +08:00
|
|
|
|
resolve(Object.keys(titleSearchData).map(b => titleSearchData[b]))
|
|
|
|
|
|
// this.titleSearchList.model.children = Object.keys(titleSearchData).map(b => titleSearchData[b])
|
2021-04-22 12:25:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
resolve()
|
|
|
|
|
|
})
|
2021-03-19 18:52:19 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
showEndpoint (asset) {
|
|
|
|
|
|
if (!this.hasButton('asset_endpoint_view')) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
this.bottomBox.asset = Object.assign({}, asset)
|
|
|
|
|
|
this.bottomBox.targetTab = 'endpoint'
|
|
|
|
|
|
this.bottomBox.showSubList = true
|
|
|
|
|
|
},
|
2021-04-22 12:25:23 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
batchEdit () {
|
|
|
|
|
|
this.rightBox.batchShow = true
|
|
|
|
|
|
},
|
|
|
|
|
|
closeRightBox (refresh) {
|
|
|
|
|
|
this.rightBox.show = false
|
|
|
|
|
|
this.rightBox.batchShow = false
|
|
|
|
|
|
if (refresh) {
|
|
|
|
|
|
this.delFlag = true
|
|
|
|
|
|
this.getTableData()
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
getPrincipalName (data) {
|
|
|
|
|
|
for (const item in this.userData) {
|
|
|
|
|
|
if (this.userData[item].userId === data) {
|
|
|
|
|
|
return this.userData[item].username
|
2020-02-26 15:38:56 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
2021-06-02 15:23:38 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
mounted () {
|
|
|
|
|
|
// 初始化数据
|
2021-06-07 15:09:11 +08:00
|
|
|
|
Promise.all([this.getModelData(), this.getTypeData(), this.getDcData(), this.getSearchableMetaData()]).then(res => {
|
|
|
|
|
|
this.titleSearchList.model.children = res[0]
|
|
|
|
|
|
this.titleSearchList.type.children = res[1]
|
|
|
|
|
|
this.titleSearchList.dc.children = res[2]
|
|
|
|
|
|
this.titleSearchList.assetLabel.children = res[3]
|
|
|
|
|
|
this.titleSearchList.ready = true
|
|
|
|
|
|
})
|
2021-04-22 12:25:23 +08:00
|
|
|
|
this.getStateData()
|
2021-04-23 19:58:08 +08:00
|
|
|
|
this.getTypeTreeData()
|
2021-04-22 12:25:23 +08:00
|
|
|
|
this.getSnmpCredentialData()
|
|
|
|
|
|
this.getFieldGroupData()
|
2021-05-12 16:19:43 +08:00
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
$route: {
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
handler () {
|
|
|
|
|
|
// 是否弹出侧滑
|
|
|
|
|
|
const add = this.$route.query.add
|
|
|
|
|
|
const importAsset = this.$route.query.importAsset
|
|
|
|
|
|
if (add) {
|
|
|
|
|
|
if (add === 'asset') {
|
|
|
|
|
|
this.add()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (importAsset) {
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.$refs.export.showImportBox(1)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2021-05-11 22:29:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-12-04 13:45:37 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
2019-11-29 15:00:26 +08:00
|
|
|
|
</script>
|