device-detail.vue 10 KB

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