device-detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  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. box-sizing: border-box;
  220. overflow-y: auto;
  221. .top-area {
  222. width: 100%;
  223. padding: 10px;
  224. box-sizing: border-box;
  225. background-color: #fff;
  226. margin-bottom: 2px;
  227. .date-box {
  228. width: 100%;
  229. display: flex;
  230. align-items: center;
  231. .date-text {
  232. font-size: 12px;
  233. }
  234. .uni-date {
  235. flex: 2.5;
  236. border: 1px solid #0eb4fc;
  237. border-radius: 5px;
  238. margin: 0px 5px;
  239. }
  240. .u-button {
  241. flex: 1;
  242. font-size: 12px;
  243. }
  244. }
  245. }
  246. .bot-area {
  247. width: 100%;
  248. height: calc(100% - 96px);
  249. padding: 10px;
  250. box-sizing: border-box;
  251. background-color: #fff;
  252. .h-table {
  253. width: 100%;
  254. height: 100%;
  255. border: 1px solid #0eb4fc;
  256. .table-head {
  257. display: flex;
  258. justify-content: space-between;
  259. align-items: center;
  260. height: 36px;
  261. border-bottom: 1px solid #0eb4fc;
  262. padding: 0px 10px;
  263. box-sizing: border-box;
  264. .head-item {
  265. font-size: 12px;
  266. color: #0eb4fc;
  267. display: flex;
  268. justify-content: center;
  269. align-items: center;
  270. font-weight: bold;
  271. &:nth-child(1) {
  272. width: 20%;
  273. }
  274. &:nth-child(2) {
  275. width: 20%;
  276. }
  277. &:nth-child(3) {
  278. width: 35%;
  279. }
  280. &:nth-child(4) {
  281. width: 25%;
  282. }
  283. }
  284. }
  285. .table-headHis {
  286. display: flex;
  287. justify-content: space-between;
  288. align-items: center;
  289. height: 36px;
  290. border-bottom: 1px solid #0eb4fc;
  291. padding: 0px 10px;
  292. box-sizing: border-box;
  293. .head-item {
  294. font-size: 12px;
  295. color: #0eb4fc;
  296. display: flex;
  297. justify-content: center;
  298. align-items: center;
  299. font-weight: bold;
  300. &:nth-child(1) {
  301. width: 15%;
  302. }
  303. &:nth-child(2) {
  304. width: 15%;
  305. }
  306. &:nth-child(3) {
  307. width: 30%;
  308. }
  309. &:nth-child(4) {
  310. width: 20%;
  311. }
  312. &:nth-child(5) {
  313. width: 20%;
  314. }
  315. }
  316. }
  317. .table-content {
  318. height: calc(100% - 36px);
  319. overflow-y: auto;
  320. .content-tr {
  321. height: 32px;
  322. display: flex;
  323. justify-content: space-between;
  324. align-items: center;
  325. padding: 0px 10px;
  326. box-sizing: border-box;
  327. &:nth-child(odd) {
  328. background-color: #f3faff;
  329. }
  330. &:nth-child(even) {
  331. background-color: #e8f5ff;
  332. }
  333. .content-td {
  334. height: 100%;
  335. font-size: 12px;
  336. display: flex;
  337. justify-content: center;
  338. align-items: center;
  339. text-align: center;
  340. }
  341. .td {
  342. width: 20%;
  343. }
  344. .td1 {
  345. width: 20%;
  346. }
  347. .td2 {
  348. width: 35%;
  349. }
  350. .td3 {
  351. width: 25%;
  352. }
  353. }
  354. }
  355. .table-contentHis {
  356. height: calc(100% - 36px);
  357. overflow-y: auto;
  358. .content-tr {
  359. height: 32px;
  360. display: flex;
  361. justify-content: space-between;
  362. align-items: center;
  363. padding: 0px 10px;
  364. box-sizing: border-box;
  365. &:nth-child(odd) {
  366. background-color: #f3faff;
  367. }
  368. &:nth-child(even) {
  369. background-color: #e8f5ff;
  370. }
  371. .content-td {
  372. height: 100%;
  373. font-size: 12px;
  374. display: flex;
  375. justify-content: center;
  376. align-items: center;
  377. text-align: center;
  378. }
  379. .td {
  380. width: 15%;
  381. }
  382. .td1 {
  383. width: 15%;
  384. }
  385. .td2 {
  386. width: 30%;
  387. }
  388. .td3 {
  389. width: 20%;
  390. }
  391. .td4 {
  392. width: 20%;
  393. }
  394. }
  395. }
  396. }
  397. }
  398. }
  399. }
  400. ::v-deep .uni-date__x-input {
  401. height: 28px !important;
  402. line-height: 28px !important;
  403. }
  404. </style>