superviseModule.vue 11 KB

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