<template> <div class="content-main-manage"> <div class="search-list"> <div class="search-left"> <Form class="common-form common-form-list" ref="tableParams" :model="tableParams" inline> <FormItem label="" prop="lineId"> <Select v-model="tableParams.lineId" placeholder="线路" @on-select="selectLine"> <Option v-for="item in lineTypeData" :value="String(item.id)" :key="item.id">{{ item.lineName }}</Option> </Select> </FormItem> <FormItem label="" prop="stationId"> <Select v-model="tableParams.stationId" placeholder="站点"> <Option v-for="item in stationTypeData" :value="String(item.id)" :key="item.id">{{ item.stationName }}</Option> </Select> </FormItem> <FormItem label="" prop="equipmentStatus"> <Select v-model="tableParams.equipmentStatus" placeholder="设备状态"> <Option v-for="item in equipStateData" :value="item.id" :key="item.id">{{ item.value }}</Option> </Select> </FormItem> <!-- <FormItem label="" prop="equipmentType"> <Select v-model="tableParams.equipmentType" placeholder="设备类型"> <Option v-for="item in equipTypeData" :value="(item.id)" :key="item.id">{{ item.name }}</Option> </Select> </FormItem> --> <FormItem label=""> <DatePicker type="daterange" :value="dateRange" :clearable="false" class="common-date-picker date-picker-main" placement="bottom-start" placeholder="启用日期范围" @on-change="changePicker"></DatePicker> </FormItem> <FormItem label="" prop="equipmentName"> <Input placeholder="请输入关键字查询" clearable search v-model="tableParams.equipmentName" /> </FormItem> <FormItem label="" > <Button type="primary" class="common-btn-search" @click="searchClick"> <Icon type="ios-search" style="margin-right:4px;font-size: 16px"/> 筛选 </Button> <Button type="primary" class="common-btn-search" style="margin-left:10px" @click="resetClick('tableParams')"> <Icon type="ios-search" style="margin-right:4px;font-size: 16px"/> 重置 </Button> </FormItem> </Form> </div> </div> <div class="btn-container"> <Button icon="ios-add" class="common-add-btn" @click="addClick">新增设备</Button> </div> <div class="manage-main-center"> <Table :columns="columns" :data="tableData" class="common-table app-table" no-data-text="" :row-class-name="rowClassName" :loading="loading"> <template slot="loading"> <Loading-animation></Loading-animation> </template> <template slot-scope="{ row }" slot="lineName"> <span>{{!row.lineName ? '/' : row.lineName}}</span> </template> <template slot-scope="{ row }" slot="stationName"> <span>{{!row.stationName ? '/' : row.stationName}}</span> </template> <template slot-scope="{ row }" slot="action"> <Tooltip content="详情" placement="top"> <i class="iconfont icon-xiangqingmingxi" style="cursor:pointer;color:#B8B532;fontSize:20px;marginRight:6px" @click="detailClick(row)"></i> </Tooltip> <Tooltip content="编辑" placement="top"> <i class="iconfont icon-bianji" style="cursor:pointer;color:#64ACFE;fontSize:20px;marginRight:6px" @click="editClick(row)"></i> </Tooltip> <Tooltip content="删除" placement="top"> <i class="iconfont icon-shanchu" style="cursor:pointer;color:#E92E2E;fontSize:20px;marginRight:6px" @click="delClick(row)"></i> </Tooltip> </template> </Table> </div> <div class="common-page"> <div class="common-page-total"> 共<span>{{tablePage}}</span>页 / <span>{{tableTotal}}</span>条数据 </div> <Page :total="tableTotal" :current="tableParams.pageNum" :page-size="tableParams.pageSize" @on-change="changePage" @on-page-size-change="sizeChange" show-elevator /> </div> <Modal v-model="showModal" :title="title" width="36" ref="modalGrag" draggable reset-drag-position @on-visible-change="modalChange" :mask-closable="false" class-name="common-modal"> <Form class="common-form" ref="formOption" :model="formOption" :rules="ruleValidate" :label-width="120" inline> <FormItem label="归属线路:" prop="lineId" style="width:48%"> <Select v-model="formOption.lineId" placeholder="线路" @on-change="selectModalLine" label-in-value> <Option v-for="item in lineTypeData" :value="String(item.id)" :key="item.id">{{ item.lineName }}</Option> </Select> </FormItem> <FormItem label="归属站点:" prop="stationId" style="width:48%"> <Select v-model="formOption.stationId" placeholder="站点" @on-change="selectModalStation" label-in-value> <Option v-for="item in stationTypeData" :value="String(item.id)" :key="item.id">{{ item.stationName }}</Option> </Select> </FormItem> <FormItem label="归属应用:" prop="appId" style="width:48%"> <Select v-model="formOption.appId" placeholder="归属应用" @on-change="selectModalApp"> <Option v-for="item in equipAppModalData" :value="item.id" :key="item.id">{{ item.appName }}</Option> </Select> </FormItem> <FormItem label="设备类型:" prop="equipmentType" style="width:48%"> <Select v-model="formOption.equipmentType" placeholder="设备类型"> <Option v-for="item in equipTypeModalData" :value="item.equipmentTypeId" :key="item.equipmentTypeId">{{ item.equipmentName }}</Option> </Select> </FormItem> <FormItem label="设备ID:" style="width:100%"> <span v-show="title=='新增设备'">系统自动生成,唯一不重复</span> <span v-show="title=='编辑设备'">{{formOption.equipmentId}}</span> </FormItem> <FormItem label="设备名称:" prop="equipmentName" style="width:100%"> <Input v-model.trim="formOption.equipmentName" type="textarea" :rows="3" maxlength="100" show-word-limit /> </FormItem> <FormItem label="设备状态:" prop="equipmentStatus" style="width:48%"> <Select v-model="formOption.equipmentStatus" placeholder="设备状态"> <Option v-for="item in equipStateModalData" :value="item.id" :key="item.id">{{ item.value }}</Option> </Select> </FormItem> <FormItem label="启用日期:" prop="useDate" style="width:48%"> <DatePicker type="date" :value="formOption.useDate" :clearable="false" class="common-date-picker" placement="bottom-start" placeholder="启用日期" style="width: 100%" @on-change="changeMoldaPicker"></DatePicker> </FormItem> <FormItem label="设备型号:" prop="equipmentVersion" style="width:100%"> <Input v-model="formOption.equipmentVersion" maxlength="20" show-word-limit /> </FormItem> <FormItem label="供应商:" prop="supplier" style="width:100%"> <Input v-model="formOption.supplier" maxlength="20" show-word-limit /> </FormItem> <FormItem label="说明:" prop="remark" style="width:100%"> <Input v-model="formOption.remark" type="textarea" :rows="6" maxlength="200" show-word-limit /> </FormItem> </Form> <div slot="footer"> <Button @click="modalCancel">取消</Button> <Button type="primary" @click="modalOk('formOption')">确定</Button> </div> </Modal> <Modal v-model="modalStatus" :title="commonTitle" width="30" ref="modalGrag" draggable reset-drag-position :mask-closable="false" class-name="common-modal"> <Icon type="ios-information-circle" :style="{ color: activeColor}" class="modal-icon"></Icon> <span class="modal-text">{{modalTitle}}</span> <div slot="footer"> <Button @click="commonCancel">取消</Button> <Button type="primary" @click="commonOk">确定</Button> </div> </Modal> <Modal v-model="detailStatus" title="设备详情" width="45" ref="modalGrag" draggable reset-drag-position footer-hide :mask-closable="false" class-name="common-modal"> <div v-for="(item,index) in detailLabel" :key="index"> <div class="common-modal-top"> <span class="common-modal-top-text">{{item.name}}</span> </div> <div class="common-modal-content"> <div class="modal-content-item" v-for="(val,i) in item.value" :key="i" :class="{'item-especial': val.name == '说明'|| val.name == '最后通讯时间' && item.value.length%2!=0,'item-especial-bot':(i==item.value.length-1 || i==item.value.length-2) && item.value.length%2==0}"> <div class="modal-content-item-name"> {{val.name}} </div> <div class="modal-content-item-value"> <Tooltip placement="top-start" transfer max-width="350" v-if="val.name == '归属线路' || val.name == '归属站点' || val.value || val.value===0"> <span v-if="val.name == '归属线路' || val.name == '归属站点'">{{!val.value ? '/' : val.value}}</span> <span v-else>{{val.value}}</span> <div slot="content"> <span v-if="val.name == '归属线路' || val.name == '归属站点'">{{!val.value ? '/' : val.value}}</span> <span v-else>{{val.value}}</span> </div> </Tooltip> <span v-else>{{val.value}}</span> </div> </div> </div> </div> </Modal> </div> </template> <script> const defaultFrom = {lineId: '',stationId: '',appId:'',equipmentName: '',equipmentType:'',equipmentStatus: '',equipmentVersion: '',supplier: '',remark: ''} export default { name: "DeviceManageIndex", components:{ }, data() { return { applicationParams: { level: '', lineId: '', stationId: '', equipmentCheck: '', instrumentCheck: '', pageNum: 1, pageSize: 9999 }, appParams: { applicationId: '', equipmentTypeId: '', keywords: '', pageNum: 1, pageSize: 9999 }, loading: true, dateRange: [], tableParams: { lineId: '', stationId: '', equipmentStatus: '', keywords: '', applicationId:'', equipmentType: '', useDateBegin: '', useDateEnd: '', equipmentName: '', pageNum: 1, pageSize: 10 }, tableData: [], tableTotal: 0, tablePage: 0, rowObj: {}, lineTypeData: [], stationTypeData: [], equipStateData: [], equipStateModalData: [], equipTypeData: [], equipTypeModalData: [], equipAppModalData: [], columns: [ // { // type: 'selection', // width: 60, // align: 'center' // }, { title: '设备ID', key: 'equipmentId', align: 'center' }, { title: '设备名称', key: 'equipmentName', align: 'center', ellipsis: true, tooltip: true }, { title: '设备类型', key: 'equipmentTypeName', align: 'center' }, { title: '归属应用', key: 'appName', align: 'center', ellipsis: true, tooltip: true }, { title: '归属线路', slot: 'lineName', align: 'center', ellipsis: true, tooltip: true }, { title: '归属站点', align: 'center', slot: 'stationName', ellipsis: true, tooltip: true }, { title: '设备状态', key: 'equipmentStatusValue', align: 'center' }, { title: '启用日期', key: 'useDate', align: 'center' }, { title: '操作', align: 'center', slot: 'action', width: 120, } ], showModal: false, detailStatus: false, modalStatus: false, title: '新增设备', commonTitle: "确认删除", activeColor: '#E92E2E', activeClass: '', modalTitle: '', formOption: {lineId: '',stationId: '',appId:'',equipmentName: '',equipmentType:'',equipmentStatus: '',useDate:'',equipmentVersion: '',supplier: '',remark: ''}, ruleValidate: { lineId: [{ required: true, message: '请选择所属线路', trigger: 'change' }], stationId: [{ required: true, message: '请选择所属站点', trigger: 'change' }], appId: [{ required: true, type: 'number', message: '请选择归属应用', trigger: 'change' }], equipmentName: [{ required: true, message: '请输入设备名称', trigger: 'change' }], appName: [{ required: true, message: '请输入设备名称', trigger: 'blur' }], equipmentType: [{ required: true, type: 'number', message: '请选择设备类型', trigger: 'change' }], equipmentStatus: [{ required: true, type: 'number', message: '请选择设备状态', trigger: 'change' }] }, detailLabel: [], }; }, mounted() { this.getType() this.getAppApplicate() this.getTableData() }, methods: { go (){ // this.$router.push({path:'//ApplicationManage'}) // this.$router.push({path:'/MainPage/ApplicationManage/2'}) this.$router.push({ name: 'ApplicationManage', params: { type:2 }}) // -> /home/123 }, changePicker (date) { this.tableParams.useDateBegin = date[0] this.tableParams.useDateEnd = date[1] }, rowClassName(row, index) { if (index % 2 == 0) { return "ivu-table-stripe-even"; } else { return "ivu-table-stripe-odd"; } }, // 分页 changePage (val) { this.tableParams.pageNum = val this.getTableData() }, //跳转 sizeChange (val) { this.tableParams.pageSize = val this.getTableData() }, getType () { //获取所属线路 this.$get('metroapi/lineStation/queryLine', {lineName:''}).then(res=>{ if (res.httpCode == 1 ){ this.lineTypeData = res.data this.lineTypeData.unshift({ id: '-1', lineName: '线路' }) this.getStationData ('-1') } else { this.lineTypeData = [] } }) // 获取设备状态 this.$get('metroapi/dic/queryDictionary', {name:'设备状态'}).then(res=>{ if (res.httpCode == 1 ){ this.equipStateModalData = JSON.parse(JSON.stringify(res.data)) this.equipStateData = res.data this.equipStateData.unshift({ id: '-1', value: '设备状态' }) } else { this.equipStateData = [] this.equipStateModalData = [] } }) // 获取归属应用 // this.$get('metroapi/application/info/list', this.applicationParams).then(res=>{ // if (res.httpCode == 1 ){ // this.equipAppModalData = res.data.data // } else { // this.equipAppModalData = [] // } // }) }, // 获取归属应用 getAppApplicate () { this.$get('metroapi/application/info/list', this.applicationParams).then(res=>{ if (res.httpCode == 1 ){ this.equipAppModalData = res.data.data } else { this.equipAppModalData = [] } }) }, selectLine (val) { // 获取站点类型 this.tableParams.stationId = '' this.tableParams.lineId = val.value if (this.tableParams.lineId) { this.getStationData(val.value) } }, // 获取所属站点 getStationData (lineId) { if(lineId == '-1') { this.stationTypeData = [{ id: '-1', stationName: '站点' }] } else { this.$get('metroapi/lineStation/queryStationByLineId', {lineId:lineId}).then(res=>{ if (res.httpCode == 1 ){ this.stationTypeData = res.data this.stationTypeData.unshift({ id: '-1', stationName: '站点' }) } }) } }, // selectChange (selection) { // console.log(selection) // let user = selection.map(item => item.id) // console.log(user) // }, // 获取表格数据 getTableData (keywords,arr,level) { if (level) { this.tableParams.keywords = '' if (level == 2) { this.tableParams.applicationId = arr[arr.length-1] this.tableParams.equipmentType = '' } else if (level == 3) { this.tableParams.applicationId = arr[arr.length-2] this.tableParams.equipmentType = arr[arr.length-1] } else { this.tableParams.applicationId = '' this.tableParams.equipmentType = '' } } else { this.tableParams.applicationId = '' this.tableParams.equipmentType = '' if (keywords == '合肥轨道交通' || keywords == '' || !keywords) { this.tableParams.keywords = '' } else { this.tableParams.keywords = keywords } } let params = JSON.parse(JSON.stringify(this.tableParams)) params.lineId = params.lineId == '-1' ? '':params.lineId params.stationId = params.stationId == '-1' ?'':params.stationId params.equipmentStatus = params.equipmentStatus == '-1' ?'':params.equipmentStatus this.loading = true this.$get('metroapi/equipment/queryEquipmentPage', params).then(res=>{ this.loading = false if (res.httpCode == 1 ){ this.tableData = res.data.data this.tableTotal = res.data.count if (res.data.data.length==0) { this.tablePage = 0 } else { this.tablePage = res.data.count<= 10 ? 1: Math.ceil(res.data.count/this.tableParams.pageSize) } if (res.data.data.length==0 && this.tableParams.pageNum>1) { this.tableParams.pageNum-- return this.getTableData() } } else { this.tableData = [] this.tableTotal = 0 } }) }, selectModalLine (val) { this.formOption.stationId = '' if (val) { this.getStationData(val.value) } }, selectModalStation (val) { if (val) { this.formOption.stationId =val.value } }, selectModalApp (val) { this.appParams.applicationId = val this.formOption.equipmentType = '' if (val) { this.getAddEquipType( this.appParams) } }, // 获取新增设备类型 getAddEquipType (params) { this.$get('metroapi/application/equipmentTypeInfo', params).then(res=>{ if (res.httpCode == 1 ){ this.equipTypeModalData = res.data.data } else { this.equipTypeModalData = [] } }) }, searchClick () { this.getTableData() // this.$router.push({ path: '/MainPage/ApplicationManage', query: {deptName: "2"}}) }, resetClick (name) { this.dateRange = [] this.tableParams.useDateBegin = '' this.tableParams.useDateEnd = '' this.$refs[name].resetFields() this.stationTypeData = [{ id: '-1', stationName: '站点' }] this.getTableData() }, changeMoldaPicker (val) { this.formOption.useDate = val }, addClick () { this.formOption = JSON.parse(JSON.stringify(defaultFrom)) this.title = '新增设备' this.showModal = true }, detailClick (row) { this.rowObj = row this.detailStatus = true this.$get('metroapi/equipment/equipmentDetail', {equipmentId:row.id}).then(res=>{ if (res.httpCode == 1 ){ this.detailLabel = res.data } else { this.$Message.info(res.msg) } }) }, editClick (row) { this.rowObj = row this.formOption = JSON.parse(JSON.stringify(row)); this.formOption.lineId = this.formOption.lineId ? String(this.formOption.lineId) : '-1' this.formOption.stationId = this.formOption.stationId ? String(this.formOption.stationId) : '-1' this.getStationData(this.formOption.lineId) this.appParams.applicationId = this.formOption.appId this.getAddEquipType(this.appParams) this.title = '编辑设备' this.showModal = true }, delClick (row) { this.rowObj = row this.commonTitle = '确认删除' this.activeColor = '#E92E2E' this.activeClass = '' this.modalTitle = '删除不影响已产生的操作和记录。' this.modalStatus = true }, modalChange (modalStatus) { if (!modalStatus) { this.$refs.formOption.resetFields(); } }, modalOk (formName) { let params = JSON.parse(JSON.stringify(this.formOption)) //把对象中的数据给了某个变量,改变一个对象的值,另一个对象也变化的解决方法 params.lineId = params.lineId == '-1' ? '':params.lineId params.stationId = params.stationId == '-1' ? '':params.stationId if (this.title == '新增设备') { this.$refs[formName].validate((valid) => { if (valid) { this.$post('metroapi/equipment/addEquipment', params).then(res=>{ if ( res.httpCode == 1 ){ this.showModal = false this.$Message.info(res.msg) this.getTableData() } else { this.$Message.info(res.msg) } }) } else { this.showModal = true } }) } else { this.$refs[formName].validate((valid) => { if (valid) { this.$post('metroapi/equipment/editEquipment', params).then(res=>{ if (res.httpCode == 1 ){ this.showModal = false this.$Message.info(res.msg) this.getTableData() } else { this.$Message.info(res.msg) } }) } else { this.showModal = true } }) } }, modalCancel () { this.showModal = false }, commonOk () { let params = { id: this.rowObj.id } this.delData(params) }, commonCancel () { this.modalStatus = false }, // 删除接口 delData (params) { this.$get('metroapi/equipment/delEquipment',params).then(res=>{ if (res.httpCode == 1 ){ this.modalStatus = false this.$Message.info(res.msg) this.getTableData() } else { this.$Message.info(res.msg) } }) } } }; </script> <style scoped lang="stylus"> .content-main-manage { position: relative; height: calc(100% - 50px); } .search-list { display: flex; padding: 10px 0; } .search-left { display: flex; align-items: center; .ivu-select { width: 150px; padding-right: 10px; height: 32px; } .ivu-select-single .ivu-select-selection { height: 100%; } >>> .ivu-input { width: 165px; height: 32px; } >>> .ivu-date-picker-editor .ivu-input { width: 210px; } >>> .ivu-input-prefix, >>> .ivu-input-suffix { height: 32px; line-height: 32px; } >>> .ivu-input-icon { height: 32px; line-height: 32px; } >>> .date-picker-main .ivu-date-picker-header { border-bottom: 0.0052083333rem solid #204384; } } .btn-container { display: flex; justify-content: flex-end; padding-bottom: 10px; } .common-form { display: flex; flex-wrap: wrap; justify-content: space-between; } >>> .common-form-list .ivu-form-item { margin-bottom: 0; } .manage-main-center { width: 100%; height: calc(100% - 150px); } .common-table { max-height: 100%; } >>> .common-table .ivu-table th { height: 51px; } >>> .common-table .ivu-table td { height: 51px; } >>> .common-table .ivu-spin-fix { top: 51px; } >>> .app-table .ivu-spin-fix { height: calc(100vh - 375px); } >>> .ivu-table-tip { background: url('../../../assets/images/noData.png') no-repeat center; } >>> .app-table .ivu-table-tip { height: calc(100vh - 375px); } >>> .common-table .ivu-table-tip table { display: none; } >>> .modal-table { overflow: auto !important; } >>> .modal-table .ivu-spin-fix { height: 200px; } >>> .modal-table .ivu-table-tip { height: 200px; } .common-page { margin-top: 15px; display: flex; align-items: center; justify-content: flex-end; position: absolute; bottom: 0; right: 0; } .common-page-total { color: #fff; padding-right: 10px; font-size: 14px; span { color #409EFF; } } >>> .modal-tabs-item { margin-top: 10px; } >>> .common-modal-top-text { font-size: 14px; font-weight: bold; color: #29A0FF; line-height: 42px; border-left: 3px solid #1590F1; padding-left: 12px; } >>> .common-modal-content { display: flex; width: 100%; justify-content: space-between; flex-wrap: wrap; margin-bottom: 15px; border-right: 1px solid #21437B; } >>> .modal-content-item { width: 50%; display: flex; } >>> .item-especial { width: 100%; } >>> .modal-content-item-name { width: 50%; height: 45px; line-height: 45px; background: #13305F; border-top: 1px solid #21437B; border-left: 1px solid #21437B; font-size: 14px; color: #F5F5F5; padding-left: 20px; } >>> .modal-content-item-value { width: 50%; height: 45px; line-height: 45px; background: #06214D; border-top: 1px solid #21437B; border-left: 1px solid #21437B; font-size: 14px; color: #F5F5F5; padding-left: 20px; } >>> .item-especial .modal-content-item-name{ width: 25%; height: 45px; line-height: 45px; border-bottom: 1px solid #21437B; } >>> .item-especial .modal-content-item-value{ width: 75%; height: 45px; line-height: 45px; border-bottom: 1px solid #21437B; } >>> .item-especial-bot .modal-content-item-name { border-bottom: 1px solid #21437B; } >>> .item-especial-bot .modal-content-item-value { border-bottom: 1px solid #21437B; } /deep/ .ivu-input::-webkit-input-placeholder{ color: #718EBD; } /deep/ .ivu-input::-moz-placeholder{ /* Mozilla Firefox 19+ */ color: #718EBD; } /deep/ .ivu-input::-moz-placeholder{ /* Mozilla Firefox 4 to 18 */ color: #718EBD; } /deep/ .ivu-input::-ms-input-placeholder{ /* Internet Explorer 10-11 */ color: #718EBD; } >>> .modal-content-item-value .ivu-tooltip { width: 100%; } >>> .modal-content-item-value .ivu-tooltip-rel { overflow: hidden; text-overflow:ellipsis; white-space: nowrap; } </style>