123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415 |
- <template>
- <view class="device-detail">
- <u-tabs class="devic-box-tab" :current="PageCur" :list="tabList" @click="NavChange"></u-tabs>
- <view class="device-content">
- <view class="top-area">
- <view class="date-box" style="margin-bottom: 10px;">
- <view class="date-text">开始时间:</view>
- <uni-datetime-picker :clear-icon="false" placeholder="请选择开始时间..." :disabled="isDisabled" type="datetime"
- v-model="datetimeStart" @change="changeStart" />
- <u-button type="primary" size="small" :disabled="isDisabled" @click="getSearch">查询</u-button>
- </view>
- <view class="date-box">
- <view class="date-text">结束时间:</view>
- <uni-datetime-picker :clear-icon="false" placeholder="请选择结束时间..." :disabled="isDisabled" type="datetime"
- v-model="datetimeEnd" @change="changeEnd" />
- <u-button type="primary" size="small" :disabled="isDisabled" @click="getReset">重置</u-button>
- </view>
- </view>
- <view class="bot-area">
- <view class="h-table">
- <view class="table-head" v-if="isDisabled">
- <view class="head-item" v-for="(item, index) in headList" :key="index">{{ item.title }}</view>
- </view>
- <view class="table-headHis" v-else>
- <view class="head-item" v-for="(item, index) in headListHis" :key="index">{{ item.title }}</view>
- </view>
- <view class="table-content" v-if="isDisabled">
- <view class="content-tr" v-for="(ite, ind) in tableData" :key="ind">
- <view class="content-td td">{{ ite.devicename }}</view>
- <view class="content-td td1">{{ ite.nwartype_dictText }}</view>
- <view class="content-td td2">{{ ite.starttime }}</view>
- <!-- <view class="content-td td3">{{ ite.endTime }}</view> -->
- <view class="content-td td3">{{ ite.wardescrip }}</view>
- </view>
- </view>
- <view class="table-contentHis" v-else>
- <view class="content-tr" v-for="(ite, ind) in tableDataHis" :key="ind">
- <view class="content-td td">{{ ite.devicename }}</view>
- <view class="content-td td1">{{ ite.nwartype_dictText }}</view>
- <view class="content-td td2">{{ ite.starttime }}</view>
- <view class="content-td td3">{{ ite.warntime }}</view>
- <view class="content-td td4">{{ ite.wardescrip }}</view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import api from "@/api/api";
- import uniDatetimePicker from '../../../uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue';
- export default {
- name: 'deviceDetail',
- components: {
- uniDatetimePicker
- },
- props: {},
- watch: {},
- data() {
- return {
- isDisabled: true,
- datetimeStart: null,
- datetimeEnd: null,
- PageCur: "0",
- tabList: [
- { name: '实时预警' },
- { name: '报警历史' },
- ],
- headList: [
- { title: '设备名称' },
- { title: '报警类型' },
- { title: '报警开始时间' },
- // { title: '报警持续时间' },
- { title: '报警描述' },
- ],
- headListHis: [
- { title: '设备名称' },
- { title: '报警类型' },
- { title: '开始时间' },
- { title: '持续时间' },
- { title: '报警描述' },
- ],
- tableData: [],
- tableDataHis: [],
- };
- },
- mounted() {
- this.getTableList()
- },
- methods: {
- NavChange: function (item) {
- this.PageCur = item.index;
- this.isDisabled = item.index ? false : true
- if (item.index) {
- this.datetimeStart= Date.now() - 1 * 24 * 3600 * 1000,
- this.datetimeEnd= Date.now(),
- this.getHistoryList()
- } else {
- this.getTableList()
- }
- },
- //开始时间选项切换
- changeStart(date) {
- console.log(date, 'date------------')
- this.datetimeStart = date
- },
- //结束时间选项切换
- changeEnd(date) {
- this.datetimeEnd = date
- },
- //获取实时监测列表数据
- getTableList() {
- new Promise((resolve, reject) => {
- api
- .warningList({ isok: 0 })
- .then((response) => {
- if (response.data.code == 200) {
- console.log(response.data, '设备详情数据-------')
- let data = response.data.result
- this.tableData = data.list
- } else {
- reject(response);
- }
- })
- .catch((error) => {
- console.log("catch===>response", response);
- reject(error);
- });
- });
- },
- //获取历史监测列表数据
- getHistoryList() {
- new Promise((resolve, reject) => {
- api
- .historyList({ pages: 1, size: 200, starttime_begin: this.datetimeStart, starttime_end: this.datetimeEnd })
- .then((response) => {
- if (response.data.code == 200) {
- console.log(response.data, '设备历史详情数据-------')
- let data = response.data.result
- this.tableDataHis = data.records
- } else {
- reject(response);
- }
- })
- .catch((error) => {
- console.log("catch===>response", response);
- reject(error);
- });
- });
- },
- //查询列表数据
- getSearch() {
- this.getHistoryList()
- },
- //重置列表数据
- getReset() {
- this.datetimeStart = Date.now() - 1 * 24 * 3600 * 1000
- this.datetimeEnd = Date.now()
- this.getHistoryList()
- }
- },
- computed: {},
- };
- </script>
- <style lang="scss" scoped>
- .device-detail {
- position: relative;
- box-sizing: border-box;
- .devic-box-tab {
- padding: 0px 10px !important;
- }
- .device-content {
- height: 704px;
- box-sizing: border-box;
- overflow-y: auto;
- .top-area {
- width: 100%;
- padding: 10px;
- box-sizing: border-box;
- background-color: #FFF;
- margin-bottom: 2px;
- .date-box {
- width: 100%;
- display: flex;
- align-items: center;
- .date-text {
- font-size: 12px;
- }
- .uni-date {
- flex: 2.5;
- border: 1px solid #0eb4fc;
- border-radius: 5px;
- margin: 0px 5px;
- }
- .u-button {
- flex: 1;
- font-size: 12px;
- }
- }
- }
- .bot-area {
- width: 100%;
- height: calc(100% - 96px);
- padding: 10px;
- box-sizing: border-box;
- background-color: #fff;
- .h-table {
- width: 100%;
- height: 100%;
- border: 1px solid #0eb4fc;
- .table-head {
- display: flex;
- justify-content: space-between;
- align-items: center;
- height: 36px;
- border-bottom: 1px solid #0eb4fc;
- padding: 0px 10px;
- box-sizing: border-box;
- .head-item {
- font-size: 12px;
- color: #0eb4fc;
- display: flex;
- justify-content: center;
- align-items: center;
- font-weight: bold;
- &:nth-child(1) {
- width: 20%;
- }
- &:nth-child(2) {
- width: 20%;
- }
- &:nth-child(3) {
- width: 35%;
- }
- &:nth-child(4) {
- width: 25%;
- }
- }
- }
- .table-headHis {
- display: flex;
- justify-content: space-between;
- align-items: center;
- height: 36px;
- border-bottom: 1px solid #0eb4fc;
- padding: 0px 10px;
- box-sizing: border-box;
- .head-item {
- font-size: 12px;
- color: #0eb4fc;
- display: flex;
- justify-content: center;
- align-items: center;
- font-weight: bold;
- &:nth-child(1) {
- width: 15%;
- }
- &:nth-child(2) {
- width: 15%;
- }
- &:nth-child(3) {
- width: 30%;
- }
- &:nth-child(4) {
- width: 20%;
- }
- &:nth-child(5) {
- width: 20%;
- }
- }
- }
- .table-content {
- height: calc(100% - 36px);
- overflow-y: auto;
- .content-tr {
- height: 32px;
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 0px 10px;
- box-sizing: border-box;
- &:nth-child(odd) {
- background-color: #f3faff;
- }
- &:nth-child(even) {
- background-color: #e8f5ff;
- }
- .content-td {
- height: 100%;
- font-size: 12px;
- display: flex;
- justify-content: center;
- align-items: center;
- text-align: center;
- }
- .td {
- width: 20%;
- }
- .td1 {
- width: 20%;
- }
- .td2 {
- width: 35%;
- }
- .td3 {
- width: 25%;
- }
- }
- }
- .table-contentHis {
- height: calc(100% - 36px);
- overflow-y: auto;
- .content-tr {
- height: 32px;
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 0px 10px;
- box-sizing: border-box;
- &:nth-child(odd) {
- background-color: #f3faff;
- }
- &:nth-child(even) {
- background-color: #e8f5ff;
- }
- .content-td {
- height: 100%;
- font-size: 12px;
- display: flex;
- justify-content: center;
- align-items: center;
- text-align: center;
- }
- .td {
- width: 15%;
- }
- .td1 {
- width: 15%;
- }
- .td2 {
- width: 30%;
- }
- .td3 {
- width: 20%;
- }
- .td4 {
- width: 20%;
- }
- }
- }
- }
- }
- }
- }
- ::v-deep .uni-date__x-input {
- height: 28px !important;
- line-height: 28px !important;
- }
- </style>
|