superviseLog.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. <!-- -->
  2. <template>
  3. <div class="superviseLog_box">
  4. <el-card :style="'height:' + fullHeight + 'px'">
  5. <el-row>
  6. <el-col>
  7. <div class="search_box">
  8. <!-- 监测人员 -->
  9. <el-select
  10. filterable
  11. v-model="input"
  12. clearable
  13. @change="searchData"
  14. placeholder="请选择监测人员"
  15. size="mini"
  16. >
  17. <el-option
  18. v-for="item in conductorList"
  19. :key="item.value"
  20. :label="item.label"
  21. :value="item.value"
  22. >
  23. </el-option>
  24. </el-select>
  25. <!-- 时间筛选 -->
  26. <el-date-picker
  27. size="mini"
  28. v-model="value"
  29. @change="searchData"
  30. type="daterange"
  31. range-separator="至"
  32. start-placeholder="开始日期"
  33. end-placeholder="结束日期"
  34. align="right"
  35. :editable="false"
  36. >
  37. </el-date-picker>
  38. <div class="btn_box">
  39. <el-button type="primary" size="mini" @click="searchData"
  40. >搜索</el-button
  41. >
  42. <el-button size="mini" @click="reset">重置</el-button>
  43. <el-button type="primary" size="mini" @click="exportData">
  44. <i v-if="loadingShow" class="el-icon-loading"></i>
  45. 导出数据</el-button
  46. >
  47. </div>
  48. </div>
  49. </el-col>
  50. </el-row>
  51. <!-- 表格 -->
  52. <el-table
  53. :data="tableData"
  54. v-loading="loading"
  55. stripe
  56. style="width: 100%"
  57. >
  58. <el-table-column prop="ind" label="序号" width="100"> </el-table-column>
  59. <el-table-column prop="owner_user" label="监测人员" width="200">
  60. </el-table-column>
  61. <el-table-column prop="monitor_time" label="监测时间" width="250">
  62. </el-table-column>
  63. <el-table-column prop="weather" label="天气" width="200">
  64. </el-table-column>
  65. <el-table-column prop="temperature" label="温度" width="200">
  66. </el-table-column>
  67. <el-table-column prop="address" label="地点" width="280">
  68. </el-table-column>
  69. <el-table-column prop="monitor_time" label="提交时间" width="180">
  70. </el-table-column>
  71. <el-table-column label="操作" width="180" fixed="right">
  72. <template slot-scope="scope">
  73. <a
  74. href="javascript:;"
  75. class="reset"
  76. @click="examineDetail(scope.row)"
  77. >查看</a
  78. >
  79. </template>
  80. </el-table-column>
  81. </el-table>
  82. <!-- 分页 -->
  83. <el-pagination
  84. style="margin: 60px 0 0 0"
  85. :page-size="10"
  86. @current-change="newPage"
  87. :current-page="page"
  88. v-if="tableData.length > 0"
  89. background
  90. layout="prev, pager, next, jumper"
  91. :total="tableSum"
  92. >
  93. </el-pagination>
  94. </el-card>
  95. </div>
  96. </template>
  97. <script>
  98. export default {
  99. //import引入的组件需要注入到对象中才能使用
  100. components: {},
  101. data() {
  102. //这里存放数据
  103. return {
  104. fullHeight: document.documentElement.clientHeight - 116, //
  105. // 筛选
  106. conductorList: [], // 监测人员 - 筛选列表
  107. input: "", // 监测人员
  108. value: "", // 时间筛选
  109. startTime: "", //开始时间
  110. endTime: "", // 结束时间
  111. loadingShow: false, // 导出加载
  112. // 表格
  113. tableData: [],
  114. loading: false, // 加载
  115. // 分页
  116. page: 1, // 当前页码
  117. tableSum: 0 // 总页码
  118. };
  119. },
  120. //监听属性 类似于data概念
  121. computed: {},
  122. //监控data中的数据变化
  123. watch: {
  124. fullHeight(val) {
  125. //监控浏览器高度变化
  126. if (!this.timer) {
  127. this.fullHeight = val;
  128. this.timer = true;
  129. let that = this;
  130. setTimeout(function() {
  131. //防止过度调用监测事件,导致卡顿
  132. that.timer = false;
  133. }, 400);
  134. }
  135. }
  136. },
  137. //方法集合
  138. methods: {
  139. //动态获取浏览器高度
  140. get_boderHeight() {
  141. const that = this;
  142. window.onresize = () => {
  143. return (() => {
  144. window.fullHeight = document.documentElement.clientHeight;
  145. that.fullHeight = window.fullHeight;
  146. })();
  147. };
  148. },
  149. // 表格列表
  150. tableList() {
  151. this.$axios({
  152. method: "POST",
  153. url: "/api/api_gateway?method=control_center.task.monitor_log_list",
  154. data: this.qs.stringify({
  155. page: this.page, // 当前页码
  156. page_item: "10", //
  157. monitor_user_id: "", // 监测人id
  158. start_time: this.startTime, // 开始时间
  159. end_time: this.endTime // 结束时间
  160. })
  161. })
  162. .then(res => {
  163. if (res.data.data.total_item !== 0) {
  164. var data = res.data.data.page_list;
  165. this.tableSum = res.data.data.total_item;
  166. var list = [];
  167. data.forEach((item, index) => {
  168. item.ind = index + 1;
  169. item.temperature =
  170. item.temperature !== "" || item.temperature !== undefined
  171. ? item.temperature + "°C"
  172. : "暂无";
  173. list.push(item);
  174. });
  175. this.tableData = list;
  176. }
  177. this.loading = false;
  178. })
  179. .catch(err => {
  180. this.loading = false;
  181. });
  182. },
  183. // 筛选列表 - 监测人员
  184. conductorAxios() {
  185. this.$axios({
  186. method: "POST",
  187. url: "/api/api_gateway?method=control_center.task.task_user_list",
  188. data: this.qs.stringify({
  189. user_type: "supervisor", // 用户类型,operator(任务处理人), supervisor(任务监督人), owner(任务发布人)
  190. operator_id: "", // 已经选择的任务处理人id
  191. supervisor_id: "", // 已经选择的任务监督人id
  192. owner_id: "" // 已经选择的任务发布人id
  193. })
  194. })
  195. .then(res => {
  196. if (res.data.data.length !== 0) {
  197. var data = res.data.data;
  198. var list = [];
  199. data.forEach(item => {
  200. var obj = {};
  201. obj["value"] = item.user_id;
  202. obj["label"] = item.real_name;
  203. list.push(obj);
  204. });
  205. this.conductorList = list;
  206. }
  207. })
  208. .catch(err => {});
  209. },
  210. // 筛选
  211. searchData() {
  212. if (this.value) {
  213. this.startTime = this.formatTime(this.value[0], "yyyy-MM-dd");
  214. this.endTime = this.formatTime(this.value[1], "yyyy-MM-dd");
  215. } else {
  216. this.startTime = "";
  217. this.endTime = "";
  218. }
  219. this.loading = true;
  220. this.tableData = [];
  221. this.tableList();
  222. },
  223. // 重置
  224. reset() {
  225. this.input = ""; // 监测人员
  226. this.value = ""; // 时间筛选
  227. this.startTime = ""; // 开始时间
  228. this.endTime = ""; // 结束时间
  229. this.tableData = [];
  230. this.loading = true;
  231. this.tableList();
  232. },
  233. // 下页
  234. newPage(page) {
  235. this.page = page;
  236. this.tableList();
  237. },
  238. // 查看
  239. examineDetail(data) {
  240. this.$router.push({
  241. path: "/index/superviseLogDetails",
  242. query: {
  243. id: data.id
  244. }
  245. });
  246. },
  247. // 导出数据
  248. exportData() {
  249. this.loadingShow = true;
  250. this.$axios({
  251. method: "POST",
  252. url: "/api/api_gateway?method=control_center.task.monitor_log_export",
  253. responseType: "blob"
  254. })
  255. .then(res => {
  256. this.downloadFile(res, "监测日志.xls");
  257. this.loadingShow = false;
  258. })
  259. .catch(err => {
  260. this.loadingShow = false;
  261. // console.log(err);
  262. });
  263. },
  264. // 流文件下载
  265. downloadFile(res, name) {
  266. let link = document.createElement("a");
  267. link.href = window.URL.createObjectURL(new Blob([res.data]));
  268. link.target = "_blank";
  269. // 文件名和格式
  270. link.download = name;
  271. document.body.appendChild(link);
  272. link.click();
  273. document.body.removeChild(link);
  274. }
  275. },
  276. //生命周期 - 创建完成(可以访问当前this实例)
  277. created() {},
  278. //生命周期 - 挂载完成(可以访问DOM元素)
  279. mounted() {
  280. this.loading = true;
  281. this.get_boderHeight(); // 动态获取浏览器高度
  282. this.tableList(); // 表格列表数据
  283. this.conductorAxios(); // 筛选 - 监测人员列表
  284. },
  285. beforeCreate() {}, //生命周期 - 创建之前
  286. beforeMount() {}, //生命周期 - 挂载之前
  287. beforeUpdate() {}, //生命周期 - 更新之前
  288. updated() {}, //生命周期 - 更新之后
  289. beforeDestroy() {}, //生命周期 - 销毁之前
  290. destroyed() {}, //生命周期 - 销毁完成
  291. activated() {} //如果页面有keep-alive缓存功能,这个函数会触发
  292. };
  293. </script>
  294. <style lang="less" scoped>
  295. .superviseLog_box {
  296. // 搜索
  297. .search_box {
  298. display: flex;
  299. /deep/.el-select {
  300. margin: 0 15px 0 0;
  301. }
  302. /deep/.el-input {
  303. margin: 0 15px 0 0;
  304. }
  305. .btn_box {
  306. margin: 0 0 0 15px;
  307. // width: 50%;
  308. display: flex;
  309. justify-content: start;
  310. }
  311. /deep/.el-range-editor--mini.el-input__inner {
  312. width: 20%;
  313. }
  314. }
  315. a {
  316. text-decoration: none;
  317. }
  318. .reset {
  319. color: #1890ff;
  320. }
  321. /deep/.el-card {
  322. overflow: hidden;
  323. overflow-y: auto;
  324. }
  325. }
  326. /deep/.el-date-editor{
  327. cursor: pointer;
  328. .el-range-input{
  329. cursor: pointer;
  330. }
  331. }
  332. </style>