| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443 |
- <template>
- <view class="device-detail">
- <view class="device-tab">
- <u-tabs
- class="devic-box-tab"
- :current="PageCur"
- :list="tabList"
- :activeStyle="activeTabStyle"
- :inactiveStyle="inactiveTabStyle"
- :itemStyle="tabItemStyle"
- lineColor="#2b7cff"
- :lineWidth="24"
- :lineHeight="3"
- @click="NavChange"
- ></u-tabs>
- </view>
- <view class="device-content">
- <view class="filter-card" v-if="PageCur != 0">
- <view class="filter-row">
- <view class="filter-label">
- <text class="req">*</text>
- <text>开始时间</text>
- </view>
- <uni-datetime-picker
- class="filter-picker"
- :clear-icon="false"
- placeholder="请选择开始时间"
- :disabled="isDisabled"
- type="datetime"
- v-model="datetimeStart"
- @change="changeStart"
- />
- <view
- class="filter-btn btn-primary"
- :class="{ 'is-disabled': isDisabled }"
- @click="getSearch"
- >查询</view
- >
- </view>
- <view class="filter-row">
- <view class="filter-label">
- <text class="req">*</text>
- <text>结束时间</text>
- </view>
- <uni-datetime-picker
- class="filter-picker"
- :clear-icon="false"
- placeholder="请选择结束时间"
- :disabled="isDisabled"
- type="datetime"
- v-model="datetimeEnd"
- @change="changeEnd"
- />
- <view
- class="filter-btn btn-plain"
- :class="{ 'is-disabled': isDisabled }"
- @click="getReset"
- >重置</view
- >
- </view>
- </view>
- <view class="bot-area">
- <view class="h-table">
- <view class="table-head">
- <view
- class="head-item"
- v-for="(item, index) in currentHead"
- :key="index"
- :style="{ width: item.width }"
- >{{ item.title }}</view
- >
- </view>
- <view class="table-content">
- <view
- class="content-tr"
- v-for="(ite, ind) in currentData"
- :key="ind"
- >
- <view
- class="content-td"
- v-for="(col, ci) in currentHead"
- :key="ci"
- :style="{ width: col.width }"
- >{{ cellText(ite, col.key) }}</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: "报警历史" }],
- tabItemStyle: { height: "46px", padding: "0 24px" },
- activeTabStyle: {
- color: "#2b7cff",
- fontWeight: "600",
- fontSize: "15px",
- },
- inactiveTabStyle: { color: "#666666", fontSize: "15px" },
- headList: [
- { title: "设备名称", key: "devicename", width: "20%" },
- { title: "报警类型", key: "nwartype_dictText", width: "20%" },
- { title: "报警开始时间", key: "starttime", width: "34%" },
- { title: "报警描述", key: "wardescrip", width: "26%" },
- ],
- 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();
- },
- //表格单元格文本
- cellText(item, key) {
- const value = item ? item[key] : "";
- return value === null || value === undefined || value === ""
- ? "--"
- : value;
- },
- },
- computed: {
- //当前表格表头
- currentHead() {
- return this.headList;
- },
- //当前表格数据
- currentData() {
- return this.isDisabled ? this.tableData : this.tableDataHis;
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .device-detail {
- position: relative;
- box-sizing: border-box;
- .device-tab {
- position: sticky;
- top: 0;
- z-index: 10;
- margin-bottom: 20rpx;
- }
- .devic-box-tab {
- padding: 0px 10px !important;
- }
- .device-content {
- display: flex;
- flex-direction: column;
- height: auto;
- min-height: 600px;
- box-sizing: border-box;
- overflow: hidden;
- /* 查询条件卡片 */
- .filter-card {
- flex-shrink: 0;
- width: 100%;
- padding: 12px 10px;
- box-sizing: border-box;
- background-color: #fff;
- border-radius: 10px;
- margin-bottom: 10px;
- .filter-row {
- width: 100%;
- display: flex;
- align-items: center;
- & + .filter-row {
- margin-top: 10px;
- }
- .filter-label {
- flex-shrink: 0;
- width: 64px;
- display: flex;
- align-items: center;
- font-size: 13px;
- color: #333;
- .req {
- color: #f5222d;
- font-size: 13px;
- margin-right: 3px;
- }
- }
- .filter-picker {
- flex: 1;
- min-width: 0;
- }
- .filter-btn {
- flex-shrink: 0;
- width: 64px;
- height: 32px;
- margin-left: 8px;
- box-sizing: border-box;
- display: flex;
- align-items: center;
- justify-content: center;
- border-radius: 4px;
- font-size: 13px;
- }
- .btn-primary {
- color: #fff;
- background: linear-gradient(90deg, #3f8cff 0%, #2b7cff 100%);
- }
- .btn-plain {
- color: #2b7cff;
- background-color: #fff;
- border: 1px solid #2b7cff;
- }
- .is-disabled {
- opacity: 0.6;
- }
- }
- }
- .bot-area {
- flex: 1;
- min-height: 0;
- width: 100%;
- padding: 10px;
- box-sizing: border-box;
- background-color: #fff;
- border-radius: 10px;
- box-shadow: 0 2px 8px rgba(43, 124, 255, 0.08);
- .h-table {
- display: flex;
- flex-direction: column;
- width: 100%;
- height: 100%;
- box-sizing: border-box;
- border: 1px solid #bcd7fb;
- border-radius: 4px;
- overflow: hidden;
- .table-head {
- flex-shrink: 0;
- display: flex;
- align-items: center;
- height: 38px;
- background-color: transparent;
- border-bottom: 1px solid #bcd7fb;
- box-sizing: border-box;
- .head-item {
- height: 100%;
- display: flex;
- justify-content: center;
- align-items: center;
- box-sizing: border-box;
- font-size: 12px;
- font-weight: 600;
- color: #1a6dff;
- text-align: center;
- border-right: 1px solid #bcd7fb;
- &:last-child {
- border-right: none;
- }
- }
- }
- .table-content {
- flex: 1;
- min-height: 0;
- overflow-y: auto;
- .content-tr {
- display: flex;
- align-items: stretch;
- min-height: 44px;
- box-sizing: border-box;
- border-bottom: 1px solid #cfe1fa;
- &:last-child {
- border-bottom: none;
- }
- &:nth-child(odd) {
- background-color: #f5f9ff;
- }
- &:nth-child(even) {
- background-color: #e9f3ff;
- }
- .content-td {
- display: flex;
- justify-content: center;
- align-items: center;
- box-sizing: border-box;
- padding: 6px 4px;
- font-size: 12px;
- color: #333;
- text-align: center;
- word-break: break-all;
- border-right: 1px solid #cfe1fa;
- &:last-child {
- border-right: none;
- }
- }
- }
- }
- }
- }
- }
- }
- /* 日期选择器样式覆盖 */
- ::v-deep .uni-date-editor--x {
- box-sizing: border-box;
- height: 32px;
- border-radius: 4px;
- border-color: #dcdfe6;
- background-color: #fff;
- }
- ::v-deep .uni-date-x {
- flex-direction: row-reverse;
- height: 32px;
- background-color: transparent;
- }
- ::v-deep .uni-date-x .icon-calendar {
- padding-left: 0;
- padding-right: 6px;
- }
- ::v-deep .uni-date__x-input {
- height: 32px !important;
- line-height: 32px !important;
- padding-left: 8px !important;
- font-size: 12px !important;
- color: #333 !important;
- text-align: left;
- }
- </style>
|