device-detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. <template>
  2. <view class="device-detail">
  3. <view class="device-tab">
  4. <u-tabs
  5. class="devic-box-tab"
  6. :current="PageCur"
  7. :list="tabList"
  8. :activeStyle="activeTabStyle"
  9. :inactiveStyle="inactiveTabStyle"
  10. :itemStyle="tabItemStyle"
  11. lineColor="#2b7cff"
  12. :lineWidth="24"
  13. :lineHeight="3"
  14. @click="NavChange"
  15. ></u-tabs>
  16. </view>
  17. <view class="device-content">
  18. <view class="filter-card" v-if="PageCur != 0">
  19. <view class="filter-row">
  20. <view class="filter-label">
  21. <text class="req">*</text>
  22. <text>开始时间</text>
  23. </view>
  24. <uni-datetime-picker
  25. class="filter-picker"
  26. :clear-icon="false"
  27. placeholder="请选择开始时间"
  28. :disabled="isDisabled"
  29. type="datetime"
  30. v-model="datetimeStart"
  31. @change="changeStart"
  32. />
  33. <view
  34. class="filter-btn btn-primary"
  35. :class="{ 'is-disabled': isDisabled }"
  36. @click="getSearch"
  37. >查询</view
  38. >
  39. </view>
  40. <view class="filter-row">
  41. <view class="filter-label">
  42. <text class="req">*</text>
  43. <text>结束时间</text>
  44. </view>
  45. <uni-datetime-picker
  46. class="filter-picker"
  47. :clear-icon="false"
  48. placeholder="请选择结束时间"
  49. :disabled="isDisabled"
  50. type="datetime"
  51. v-model="datetimeEnd"
  52. @change="changeEnd"
  53. />
  54. <view
  55. class="filter-btn btn-plain"
  56. :class="{ 'is-disabled': isDisabled }"
  57. @click="getReset"
  58. >重置</view
  59. >
  60. </view>
  61. </view>
  62. <view class="bot-area">
  63. <view class="h-table">
  64. <view class="table-head">
  65. <view
  66. class="head-item"
  67. v-for="(item, index) in currentHead"
  68. :key="index"
  69. :style="{ width: item.width }"
  70. >{{ item.title }}</view
  71. >
  72. </view>
  73. <view class="table-content">
  74. <view
  75. class="content-tr"
  76. v-for="(ite, ind) in currentData"
  77. :key="ind"
  78. >
  79. <view
  80. class="content-td"
  81. v-for="(col, ci) in currentHead"
  82. :key="ci"
  83. :style="{ width: col.width }"
  84. >{{ cellText(ite, col.key) }}</view
  85. >
  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. tabItemStyle: { height: "46px", padding: "0 24px" },
  111. activeTabStyle: {
  112. color: "#2b7cff",
  113. fontWeight: "600",
  114. fontSize: "15px",
  115. },
  116. inactiveTabStyle: { color: "#666666", fontSize: "15px" },
  117. headList: [
  118. { title: "设备名称", key: "devicename", width: "20%" },
  119. { title: "报警类型", key: "nwartype_dictText", width: "20%" },
  120. { title: "报警开始时间", key: "starttime", width: "34%" },
  121. { title: "报警描述", key: "wardescrip", width: "26%" },
  122. ],
  123. tableData: [],
  124. tableDataHis: [],
  125. };
  126. },
  127. mounted() {
  128. this.getTableList();
  129. },
  130. methods: {
  131. NavChange: function (item) {
  132. this.PageCur = item.index;
  133. this.isDisabled = item.index ? false : true;
  134. if (item.index) {
  135. (this.datetimeStart = Date.now() - 1 * 24 * 3600 * 1000),
  136. (this.datetimeEnd = Date.now()),
  137. this.getHistoryList();
  138. } else {
  139. this.getTableList();
  140. }
  141. },
  142. //开始时间选项切换
  143. changeStart(date) {
  144. console.log(date, "date------------");
  145. this.datetimeStart = date;
  146. },
  147. //结束时间选项切换
  148. changeEnd(date) {
  149. this.datetimeEnd = date;
  150. },
  151. //获取实时监测列表数据
  152. getTableList() {
  153. new Promise((resolve, reject) => {
  154. api
  155. .warningList({ isok: 0 })
  156. .then((response) => {
  157. if (response.data.code == 200) {
  158. console.log(response.data, "设备详情数据-------");
  159. let data = response.data.result;
  160. this.tableData = data.list;
  161. } else {
  162. reject(response);
  163. }
  164. })
  165. .catch((error) => {
  166. console.log("catch===>response", response);
  167. reject(error);
  168. });
  169. });
  170. },
  171. //获取历史监测列表数据
  172. getHistoryList() {
  173. new Promise((resolve, reject) => {
  174. api
  175. .historyList({
  176. pages: 1,
  177. size: 200,
  178. starttime_begin: this.datetimeStart,
  179. starttime_end: this.datetimeEnd,
  180. })
  181. .then((response) => {
  182. if (response.data.code == 200) {
  183. console.log(response.data, "设备历史详情数据-------");
  184. let data = response.data.result;
  185. this.tableDataHis = data.records;
  186. } else {
  187. reject(response);
  188. }
  189. })
  190. .catch((error) => {
  191. console.log("catch===>response", response);
  192. reject(error);
  193. });
  194. });
  195. },
  196. //查询列表数据
  197. getSearch() {
  198. this.getHistoryList();
  199. },
  200. //重置列表数据
  201. getReset() {
  202. this.datetimeStart = Date.now() - 1 * 24 * 3600 * 1000;
  203. this.datetimeEnd = Date.now();
  204. this.getHistoryList();
  205. },
  206. //表格单元格文本
  207. cellText(item, key) {
  208. const value = item ? item[key] : "";
  209. return value === null || value === undefined || value === ""
  210. ? "--"
  211. : value;
  212. },
  213. },
  214. computed: {
  215. //当前表格表头
  216. currentHead() {
  217. return this.headList;
  218. },
  219. //当前表格数据
  220. currentData() {
  221. return this.isDisabled ? this.tableData : this.tableDataHis;
  222. },
  223. },
  224. };
  225. </script>
  226. <style lang="scss" scoped>
  227. .device-detail {
  228. position: relative;
  229. box-sizing: border-box;
  230. .device-tab {
  231. background-color: #fff;
  232. border-bottom: 1px solid #eef2f8;
  233. }
  234. .devic-box-tab {
  235. padding: 0px 10px !important;
  236. }
  237. .device-content {
  238. display: flex;
  239. flex-direction: column;
  240. height: auto;
  241. min-height: 600px;
  242. box-sizing: border-box;
  243. overflow: hidden;
  244. /* 查询条件卡片 */
  245. .filter-card {
  246. flex-shrink: 0;
  247. width: 100%;
  248. padding: 12px 10px;
  249. box-sizing: border-box;
  250. background-color: #fff;
  251. border-radius: 10px;
  252. box-shadow: 0 2px 8px rgba(43, 124, 255, 0.08);
  253. margin-bottom: 10px;
  254. .filter-row {
  255. width: 100%;
  256. display: flex;
  257. align-items: center;
  258. & + .filter-row {
  259. margin-top: 10px;
  260. }
  261. .filter-label {
  262. flex-shrink: 0;
  263. width: 64px;
  264. display: flex;
  265. align-items: center;
  266. font-size: 13px;
  267. color: #333;
  268. .req {
  269. color: #f5222d;
  270. font-size: 13px;
  271. margin-right: 3px;
  272. }
  273. }
  274. .filter-picker {
  275. flex: 1;
  276. min-width: 0;
  277. }
  278. .filter-btn {
  279. flex-shrink: 0;
  280. width: 64px;
  281. height: 32px;
  282. margin-left: 8px;
  283. box-sizing: border-box;
  284. display: flex;
  285. align-items: center;
  286. justify-content: center;
  287. border-radius: 4px;
  288. font-size: 13px;
  289. }
  290. .btn-primary {
  291. color: #fff;
  292. background: linear-gradient(90deg, #3f8cff 0%, #2b7cff 100%);
  293. }
  294. .btn-plain {
  295. color: #2b7cff;
  296. background-color: #fff;
  297. border: 1px solid #2b7cff;
  298. }
  299. .is-disabled {
  300. opacity: 0.6;
  301. }
  302. }
  303. }
  304. .bot-area {
  305. flex: 1;
  306. min-height: 0;
  307. width: 100%;
  308. padding: 10px;
  309. box-sizing: border-box;
  310. background-color: #fff;
  311. border-radius: 10px;
  312. box-shadow: 0 2px 8px rgba(43, 124, 255, 0.08);
  313. .h-table {
  314. display: flex;
  315. flex-direction: column;
  316. width: 100%;
  317. height: 100%;
  318. box-sizing: border-box;
  319. border: 1px solid #bcd7fb;
  320. border-radius: 4px;
  321. overflow: hidden;
  322. .table-head {
  323. flex-shrink: 0;
  324. display: flex;
  325. align-items: center;
  326. height: 38px;
  327. background-color: transparent;
  328. border-bottom: 1px solid #bcd7fb;
  329. box-sizing: border-box;
  330. .head-item {
  331. height: 100%;
  332. display: flex;
  333. justify-content: center;
  334. align-items: center;
  335. box-sizing: border-box;
  336. font-size: 12px;
  337. font-weight: 600;
  338. color: #1a6dff;
  339. text-align: center;
  340. border-right: 1px solid #bcd7fb;
  341. &:last-child {
  342. border-right: none;
  343. }
  344. }
  345. }
  346. .table-content {
  347. flex: 1;
  348. min-height: 0;
  349. overflow-y: auto;
  350. .content-tr {
  351. display: flex;
  352. align-items: stretch;
  353. min-height: 44px;
  354. box-sizing: border-box;
  355. border-bottom: 1px solid #cfe1fa;
  356. &:last-child {
  357. border-bottom: none;
  358. }
  359. &:nth-child(odd) {
  360. background-color: #f5f9ff;
  361. }
  362. &:nth-child(even) {
  363. background-color: #e9f3ff;
  364. }
  365. .content-td {
  366. display: flex;
  367. justify-content: center;
  368. align-items: center;
  369. box-sizing: border-box;
  370. padding: 6px 4px;
  371. font-size: 12px;
  372. color: #333;
  373. text-align: center;
  374. word-break: break-all;
  375. border-right: 1px solid #cfe1fa;
  376. &:last-child {
  377. border-right: none;
  378. }
  379. }
  380. }
  381. }
  382. }
  383. }
  384. }
  385. }
  386. /* 日期选择器样式覆盖 */
  387. ::v-deep .uni-date-editor--x {
  388. box-sizing: border-box;
  389. height: 32px;
  390. border-radius: 4px;
  391. border-color: #dcdfe6;
  392. background-color: #fff;
  393. }
  394. ::v-deep .uni-date-x {
  395. flex-direction: row-reverse;
  396. height: 32px;
  397. background-color: transparent;
  398. }
  399. ::v-deep .uni-date-x .icon-calendar {
  400. padding-left: 0;
  401. padding-right: 6px;
  402. }
  403. ::v-deep .uni-date__x-input {
  404. height: 32px !important;
  405. line-height: 32px !important;
  406. padding-left: 8px !important;
  407. font-size: 12px !important;
  408. color: #333 !important;
  409. text-align: left;
  410. }
  411. </style>