detail.vue 5.42 KB
<template>
    <el-dialog
      class="manage-dialog dev-detail-dialog"
      :visible.sync="detailVisible"
      :close-on-click-modal="false"
      @close="detailDialogClose">
        <!-- <div class=""> -->
        <!-- <ul class="detail-content">
                <li class="detail-content-item">
                    <span class="item-label">序列号:</span>
                    <span class="item-content">{{ detailForm.serialnum }}</span>
                </li>
                <li class="detail-content-item">
                    <span class="item-label">IP:</span>
                    <span class="item-content">{{ detailForm.localIp }}</span>
                </li>
            </ul> -->
        <div slot="title" class="detail-title-wrapper">
            <span>{{$t('dialog.deviceDetail')}}</span>
            <span class="detail-title">{{ detailForm.serialnum }}</span>
            <span class="detail-title">{{ detailForm.localIp }}</span>
        </div>
        <el-table class="dev-detail-table" :data="detailTabData">
            <el-table-column align="center" width="100" :label="$t('table.order')">
                <template slot-scope="scope">
                    <div class="child-order-column">
                        <div class="child-order__icon-inner">
                            {{ scope.row.tableOrder }}
                        </div>
                    </div>
                </template>
            </el-table-column>
            <el-table-column prop="serialnum" :label="$t('dialog.number')" align="center"></el-table-column>
            <el-table-column prop="gateName" :label="$t('table.monitorSiteName')" align="center"></el-table-column>
            <el-table-column prop="belongsName" :label="$t('table.ownShop')" align="center"></el-table-column>
        </el-table>
        <!-- </div> -->
        <div slot="footer" class="dialog-footer">
            <el-button @click="detailVisible = false" class="dialog-btn">{{$t('dialog.close')}}</el-button>
        </div>
    </el-dialog>
</template>

<script>
export default {
    data() {
        return {
            detailVisible: false,
            detailForm: {
                serialnum: '',
                localIp: ''
            },
            detailTabData: [],
        }
    },
    methods: {
        dialogInit(data) {
            this.getChannel(data.id);
            this.detailVisible = true;
        },
        getChannel(deviceId) {
			this.detailTabData = [];
			this.$api.base.channel({
                deviceId: deviceId,
                // _t: Date.parse(new Date()) / 1000
			})
				.then((data) => {
					let result = data.data;
					result.data.forEach((item, index) => {
						item.tableOrder = ++index;
						item.gateName = item.gate ? item.gate.name : '--';
						if (item.gateId) {
							item.belongsName = '';
							this.getChannelInfo(item.id, index - 1);
							// 	this.getChannelGate(item.mallId, item.gateId);
						} else {
							item.belongsName = '--';
						}
					})
					this.detailTabData = result.data;
					// this.getChannel(result.data.id);
				})
				.catch(err => { })
		},
		getChannelInfo(channelId, tabIndex) {
			this.$api.base.singleChannel(channelId, {
                // _t: Date.parse(new Date()) / 1000
			})
				.then((data) => {
					let result = data.data;
					if (result.data.gate) {
						if (result.data.zones.length > 0) {
							this.detailTabData[tabIndex].belongsName = result.data.zones.map(item => {
								return item.name;
							}).join(',');
						} else if (result.data.floors.length > 0) {
							this.detailTabData[tabIndex].belongsName = result.data.floors.map(item => {
								return item.name;
							}).join(',');
						} else {
							this.detailTabData[tabIndex].belongsName = '--';
						}
					}
				})
				.catch(err => { })
		},
        // getChannelGate(mall_id, gate_id) {
		// 	// let gateNameStr = '';
		// 	this.$api.base.gate({
		// 			mallId: mall_id,
		// 			id: gate_id,
		// 			// _t: Date.parse(new Date()) / 1000
		// 	})
		// 		.then((res) => {
		// 			let result = res.data;
		// 			result.data.forEach(key => {
		// 				this.detailTabData.forEach(item => {
		// 					if (key.id == item.gateId) {
		// 						this.getBelongs()
		// 						if (item.gateName) {
		// 							if (item.gateName !== key.name) {
		// 								item.gateName = item.gateName + ' ' + key.name;
		// 							}
		// 						} else {
		// 							item.gateName += key.name;
		// 						}
		// 					}
		// 				})
		// 			})
		// 		})
		// 	// return gateNameStr;
		// },
        detailDialogClose() {
			this.detailForm = {};
            this.detailTabData = [];
		},
    },
}
</script>

<style scoped>
    .detail-title-wrapper {
        color: #fff;
        font-size: 18px;
    }

    .detail-title+.detail-title {
        padding-left: 20px;
    }

    .child-order-column {
        position: relative;
        z-index: 1;
        display: inline-flex;
        justify-content: center;
        align-items: center;
        width: 16px;
        height: 16px;
        font-size: 10px;
        box-sizing: border-box;
        background: #fff;
        transition: .15s ease-out;
        border-radius: 50%;
        border: 1px solid;
        border-color: inherit;
    }

    .child-order__icon-inner {
        display: inline-block;
        user-select: none;
        text-align: center;
        font-weight: normal;
        line-height: 1;
        color: #888;
    }

    .manage-input-box .el-input {
        width: 150px;
    }

    .manage-input-box .el-select {
        width: 110px;
    }
</style>