device-detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. <template>
  2. <view class="device-detail">
  3. <u-tabs
  4. class="devic-box-tab"
  5. :current="PageCur"
  6. :list="tabList"
  7. @click="NavChange"
  8. ></u-tabs>
  9. <view class="device-content">
  10. <view class="top-area">
  11. <view class="date-box" style="margin-bottom: 10px">
  12. <view class="date-text">开始时间:</view>
  13. <uni-datetime-picker
  14. :clear-icon="false"
  15. placeholder="请选择开始时间..."
  16. :disabled="isDisabled"
  17. type="datetime"
  18. v-model="datetimeStart"
  19. @change="changeStart"
  20. />
  21. <u-button
  22. type="primary"
  23. size="small"
  24. :disabled="isDisabled"
  25. @click="getSearch"
  26. >查询</u-button
  27. >
  28. </view>
  29. <view class="date-box">
  30. <view class="date-text">结束时间:</view>
  31. <uni-datetime-picker
  32. :clear-icon="false"
  33. placeholder="请选择结束时间..."
  34. :disabled="isDisabled"
  35. type="datetime"
  36. v-model="datetimeEnd"
  37. @change="changeEnd"
  38. />
  39. <u-button
  40. type="primary"
  41. size="small"
  42. :disabled="isDisabled"
  43. @click="getReset"
  44. >重置</u-button
  45. >
  46. </view>
  47. </view>
  48. <view class="bot-area">
  49. <view class="h-table">
  50. <view class="table-head" v-if="isDisabled">
  51. <view
  52. class="head-item"
  53. v-for="(item, index) in headList"
  54. :key="index"
  55. >{{ item.title }}</view
  56. >
  57. </view>
  58. <view class="table-headHis" v-else>
  59. <view
  60. class="head-item"
  61. v-for="(item, index) in headListHis"
  62. :key="index"
  63. >{{ item.title }}</view
  64. >
  65. </view>
  66. <view class="table-content" v-if="isDisabled">
  67. <view class="content-tr" v-for="(ite, ind) in tableData" :key="ind">
  68. <view class="content-td td">{{ ite.devicename }}</view>
  69. <view class="content-td td1">{{ ite.nwartype_dictText }}</view>
  70. <view class="content-td td2">{{ ite.starttime }}</view>
  71. <!-- <view class="content-td td3">{{ ite.endTime }}</view> -->
  72. <view class="content-td td3">{{ ite.wardescrip }}</view>
  73. </view>
  74. </view>
  75. <view class="table-contentHis" v-else>
  76. <view
  77. class="content-tr"
  78. v-for="(ite, ind) in tableDataHis"
  79. :key="ind"
  80. >
  81. <view class="content-td td">{{ ite.devicename }}</view>
  82. <view class="content-td td1">{{ ite.nwartype_dictText }}</view>
  83. <view class="content-td td2">{{ ite.starttime }}</view>
  84. <view class="content-td td3">{{ ite.warntime }}</view>
  85. <view class="content-td td4">{{ ite.wardescrip }}</view>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. </template>
  93. <script>
  94. import api from "@/api/api";
  95. import uniDatetimePicker from "../../../uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue";
  96. export default {
  97. name: "deviceDetail",
  98. components: {
  99. uniDatetimePicker,
  100. },
  101. props: {},
  102. watch: {},
  103. data() {
  104. return {
  105. isDisabled: true,
  106. datetimeStart: null,
  107. datetimeEnd: null,
  108. PageCur: "0",
  109. tabList: [{ name: "实时预警" }, { name: "报警历史" }],
  110. headList: [
  111. { title: "设备名称" },
  112. { title: "报警类型" },
  113. { title: "报警开始时间" },
  114. // { title: '报警持续时间' },
  115. { title: "报警描述" },
  116. ],
  117. headListHis: [
  118. { title: "设备名称" },
  119. { title: "报警类型" },
  120. { title: "开始时间" },
  121. { title: "持续时间" },
  122. { title: "报警描述" },
  123. ],
  124. tableData: [],
  125. tableDataHis: [],
  126. };
  127. },
  128. mounted() {
  129. this.getTableList();
  130. },
  131. methods: {
  132. NavChange: function (item) {
  133. this.PageCur = item.index;
  134. this.isDisabled = item.index ? false : true;
  135. if (item.index) {
  136. (this.datetimeStart = Date.now() - 1 * 24 * 3600 * 1000),
  137. (this.datetimeEnd = Date.now()),
  138. this.getHistoryList();
  139. } else {
  140. this.getTableList();
  141. }
  142. },
  143. //开始时间选项切换
  144. changeStart(date) {
  145. console.log(date, "date------------");
  146. this.datetimeStart = date;
  147. },
  148. //结束时间选项切换
  149. changeEnd(date) {
  150. this.datetimeEnd = date;
  151. },
  152. //获取实时监测列表数据
  153. getTableList() {
  154. new Promise((resolve, reject) => {
  155. api
  156. .warningList({ isok: 0 })
  157. .then((response) => {
  158. if (response.data.code == 200) {
  159. console.log(response.data, "设备详情数据-------");
  160. let data = response.data.result;
  161. this.tableData = data.list;
  162. } else {
  163. reject(response);
  164. }
  165. })
  166. .catch((error) => {
  167. console.log("catch===>response", response);
  168. reject(error);
  169. });
  170. });
  171. },
  172. //获取历史监测列表数据
  173. getHistoryList() {
  174. new Promise((resolve, reject) => {
  175. api
  176. .historyList({
  177. pages: 1,
  178. size: 200,
  179. starttime_begin: this.datetimeStart,
  180. starttime_end: this.datetimeEnd,
  181. })
  182. .then((response) => {
  183. if (response.data.code == 200) {
  184. console.log(response.data, "设备历史详情数据-------");
  185. let data = response.data.result;
  186. this.tableDataHis = data.records;
  187. } else {
  188. reject(response);
  189. }
  190. })
  191. .catch((error) => {
  192. console.log("catch===>response", response);
  193. reject(error);
  194. });
  195. });
  196. },
  197. //查询列表数据
  198. getSearch() {
  199. this.getHistoryList();
  200. },
  201. //重置列表数据
  202. getReset() {
  203. this.datetimeStart = Date.now() - 1 * 24 * 3600 * 1000;
  204. this.datetimeEnd = Date.now();
  205. this.getHistoryList();
  206. },
  207. },
  208. computed: {},
  209. };
  210. </script>
  211. <style lang="scss" scoped>
  212. .device-detail {
  213. position: relative;
  214. box-sizing: border-box;
  215. .devic-box-tab {
  216. padding: 0px 10px !important;
  217. }
  218. .device-content {
  219. height: 704px;
  220. box-sizing: border-box;
  221. overflow-y: auto;
  222. .top-area {
  223. width: 100%;
  224. padding: 10px;
  225. box-sizing: border-box;
  226. background-color: #fff;
  227. margin-bottom: 2px;
  228. .date-box {
  229. width: 100%;
  230. display: flex;
  231. align-items: center;
  232. .date-text {
  233. font-size: 12px;
  234. }
  235. .uni-date {
  236. flex: 2.5;
  237. border: 1px solid #0eb4fc;
  238. border-radius: 5px;
  239. margin: 0px 5px;
  240. }
  241. .u-button {
  242. flex: 1;
  243. font-size: 12px;
  244. }
  245. }
  246. }
  247. .bot-area {
  248. width: 100%;
  249. height: calc(100% - 96px);
  250. padding: 10px;
  251. box-sizing: border-box;
  252. background-color: #fff;
  253. .h-table {
  254. width: 100%;
  255. height: 100%;
  256. border: 1px solid #0eb4fc;
  257. .table-head {
  258. display: flex;
  259. justify-content: space-between;
  260. align-items: center;
  261. height: 36px;
  262. border-bottom: 1px solid #0eb4fc;
  263. padding: 0px 10px;
  264. box-sizing: border-box;
  265. .head-item {
  266. font-size: 12px;
  267. color: #0eb4fc;
  268. display: flex;
  269. justify-content: center;
  270. align-items: center;
  271. font-weight: bold;
  272. &:nth-child(1) {
  273. width: 20%;
  274. }
  275. &:nth-child(2) {
  276. width: 20%;
  277. }
  278. &:nth-child(3) {
  279. width: 35%;
  280. }
  281. &:nth-child(4) {
  282. width: 25%;
  283. }
  284. }
  285. }
  286. .table-headHis {
  287. display: flex;
  288. justify-content: space-between;
  289. align-items: center;
  290. height: 36px;
  291. border-bottom: 1px solid #0eb4fc;
  292. padding: 0px 10px;
  293. box-sizing: border-box;
  294. .head-item {
  295. font-size: 12px;
  296. color: #0eb4fc;
  297. display: flex;
  298. justify-content: center;
  299. align-items: center;
  300. font-weight: bold;
  301. &:nth-child(1) {
  302. width: 15%;
  303. }
  304. &:nth-child(2) {
  305. width: 15%;
  306. }
  307. &:nth-child(3) {
  308. width: 30%;
  309. }
  310. &:nth-child(4) {
  311. width: 20%;
  312. }
  313. &:nth-child(5) {
  314. width: 20%;
  315. }
  316. }
  317. }
  318. .table-content {
  319. height: calc(100% - 36px);
  320. overflow-y: auto;
  321. .content-tr {
  322. height: 32px;
  323. display: flex;
  324. justify-content: space-between;
  325. align-items: center;
  326. padding: 0px 10px;
  327. box-sizing: border-box;
  328. &:nth-child(odd) {
  329. background-color: #f3faff;
  330. }
  331. &:nth-child(even) {
  332. background-color: #e8f5ff;
  333. }
  334. .content-td {
  335. height: 100%;
  336. font-size: 12px;
  337. display: flex;
  338. justify-content: center;
  339. align-items: center;
  340. text-align: center;
  341. }
  342. .td {
  343. width: 20%;
  344. }
  345. .td1 {
  346. width: 20%;
  347. }
  348. .td2 {
  349. width: 35%;
  350. }
  351. .td3 {
  352. width: 25%;
  353. }
  354. }
  355. }
  356. .table-contentHis {
  357. height: calc(100% - 36px);
  358. overflow-y: auto;
  359. .content-tr {
  360. height: 32px;
  361. display: flex;
  362. justify-content: space-between;
  363. align-items: center;
  364. padding: 0px 10px;
  365. box-sizing: border-box;
  366. &:nth-child(odd) {
  367. background-color: #f3faff;
  368. }
  369. &:nth-child(even) {
  370. background-color: #e8f5ff;
  371. }
  372. .content-td {
  373. height: 100%;
  374. font-size: 12px;
  375. display: flex;
  376. justify-content: center;
  377. align-items: center;
  378. text-align: center;
  379. }
  380. .td {
  381. width: 15%;
  382. }
  383. .td1 {
  384. width: 15%;
  385. }
  386. .td2 {
  387. width: 30%;
  388. }
  389. .td3 {
  390. width: 20%;
  391. }
  392. .td4 {
  393. width: 20%;
  394. }
  395. }
  396. }
  397. }
  398. }
  399. }
  400. }
  401. ::v-deep .uni-date__x-input {
  402. height: 28px !important;
  403. line-height: 28px !important;
  404. }
  405. </style>