alarmRecord.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <!--报警记录-->
  2. <template>
  3. <div class="apply">
  4. <div class="apply_page" v-if="pageType == 1">
  5. <el-form :model="queryParams" ref="queryForm" style="margin-top:20px;" :inline="true">
  6. <el-form-item label="关键字">
  7. <el-input
  8. v-model="queryParams.searchValue"
  9. placeholder="姓名/联系方式/实验地点"
  10. clearable
  11. maxLength="30"
  12. size="small"
  13. />
  14. </el-form-item>
  15. <el-form-item label="报警时间" prop="dateRange">
  16. <el-date-picker
  17. :clearable="false"
  18. v-model="dateRange"
  19. size="small"
  20. style="width: 240px"
  21. value-format="yyyy-MM-dd"
  22. type="daterange"
  23. range-separator="-"
  24. start-placeholder="开始日期"
  25. end-placeholder="结束日期"
  26. ></el-date-picker>
  27. </el-form-item>
  28. <el-form-item>
  29. <p class="inquire-button-one" @click="handleQuery">查询</p>
  30. <p class="reset-button-one" @click="resetQuery">重置</p>
  31. </el-form-item>
  32. <el-form-item label="" prop="title" style="float: right">
  33. <el-dropdown @command="exportButton" style="float: left" v-hasPermi="['airbottle:alarm:record:export']">
  34. <div class="form-dropdown-box">
  35. <img src="@/assets/ZDimages/personnelManagement/icon_jzgxx_sc.png">
  36. <p>导出</p>
  37. <img src="@/assets/ZDimages/personnelManagement/icon_jzggl_xljt.png">
  38. </div>
  39. <el-dropdown-menu slot="dropdown">
  40. <el-dropdown-item style="border-bottom:1px solid #E0E0E0;margin:0 10px;color:#333;" :command="{command:1}">导出全部数据</el-dropdown-item>
  41. <el-dropdown-item style="margin:0 10px;color:#666;" :command="{command:2}">导出选中数据</el-dropdown-item>
  42. </el-dropdown-menu>
  43. </el-dropdown>
  44. <p class="reset-button-one" style="margin-left: 12px;" @click="backPage">返回</p>
  45. </el-form-item>
  46. </el-form>
  47. <el-table border v-loading="loading" :data="tableData" @selection-change="handleSelectionChange" ref="multipleTable" :row-key="getRowKeys">
  48. <el-table-column type="selection" width="50" align="center"/>
  49. <el-table-column label="标签码" align="left" prop=""></el-table-column>
  50. <el-table-column label="气瓶编号" align="left" prop=""></el-table-column>
  51. <el-table-column label="气体名称" align="left" prop="airName"></el-table-column>
  52. <el-table-column label="气瓶规格" align="left" prop=""></el-table-column>
  53. <el-table-column label="气体余量" align="left" prop="currentPressure">
  54. <template slot-scope="scope">
  55. <span >{{scope.row.currentPressure}}Mpa</span>
  56. </template>
  57. </el-table-column>
  58. <el-table-column label="报警时间" align="left" prop="alarmTime"></el-table-column>
  59. </el-table>
  60. <div style="display: flex;height:32px;margin-top:15px;">
  61. <!--<p style="flex:4;"></p>-->
  62. <p style="text-align: left;margin:0;line-height:32px;margin-right:20px;font-size:14px;color:#999;">
  63. <i class="el-icon-warning" style="color:#0183FA;"></i>
  64. 已选择 {{selectedNum}} 项
  65. </p>
  66. <div style="flex:5;">
  67. <pagination :page-sizes="[20, 30, 40, 50]"
  68. v-show="total>0"
  69. :total="total"
  70. style="margin:0;"
  71. :page.sync="queryParams.pageNum"
  72. :limit.sync="queryParams.pageSize"
  73. @pagination="getList"
  74. />
  75. </div>
  76. </div>
  77. </div>
  78. <!--详情页面-->
  79. <detail-page v-if="pageType==2" :pageData2="pageData2"></detail-page>
  80. </div>
  81. </template>
  82. <script>
  83. import { alarmRecordList, useRecordList } from '@/api/gasManage3_0/gasManage'
  84. import { getToken } from "@/utils/auth";
  85. import detailPage from "./abnormalRecordDetail.vue"
  86. export default {
  87. name: "Approval",
  88. components: {
  89. detailPage
  90. },
  91. data() {
  92. return {
  93. //页面状态
  94. pageType:1,
  95. loading:false,
  96. headers: {
  97. Authorization: "Bearer " + getToken()
  98. },
  99. // 查询参数
  100. queryParams: {
  101. pageNum: 1,
  102. pageSize:20,
  103. searchValue:'',
  104. },
  105. total:0,
  106. tableData:[],
  107. dateRange:[],
  108. pageData2:{},
  109. //导出
  110. //表格扩展选择器---需要在@selection-change绑定的方法内监控selection数组长度
  111. selectedNum:0,
  112. // 选中数组
  113. ids: [],
  114. // 非单个禁用
  115. single: true,
  116. // 非多个禁用
  117. multiple: true,
  118. };
  119. },
  120. methods: {
  121. handleClick(index,row,doType){
  122. let _this=this;
  123. if(doType=='detail'){//查看
  124. _this.pageData2.item=row;
  125. _this.pageType=2;
  126. }else if(doType=='back'){//返回
  127. _this.pageType=1;
  128. }else if(doType=='export'){//导出
  129. this.download('airbottle/alarm/record/export', {
  130. ...this.queryParams
  131. }, `报警记录导出.xlsx`)
  132. }
  133. },
  134. /** 当前时间 */
  135. getCurrentTime () {
  136. const yy = new Date().getFullYear()
  137. const mm = new Date().getMonth() + 1
  138. const dd = new Date().getDate()
  139. const hh = new Date().getHours()
  140. const mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes()
  141. const ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds()
  142. return yy + '-' + mm + '-' + dd
  143. },
  144. /** 导出按钮操作 */
  145. exportButton(item) {
  146. let self = this;
  147. let currentDate = this.getCurrentTime()
  148. if(item.command == 1){
  149. self.$confirm(`确认导出全部数据?`, "提示", {
  150. confirmButtonText: "确定",
  151. cancelButtonText: "取消",
  152. type: "warning"
  153. }).then(async () => {
  154. self.download('/airbottle/alarm/record/export/', {...self.queryParamsData}, '报警记录导出-'+currentDate+'.xlsx')
  155. }).catch(() => {})
  156. }else if(item.command == 2){
  157. if(self.ids.length>0) {
  158. self.$confirm(`确认导出选中数据?`, "提示", {
  159. confirmButtonText: "确定",
  160. cancelButtonText: "取消",
  161. type: "warning"
  162. }).then(async () => {
  163. let ids = self.ids.join(',');
  164. let obj = {
  165. ids :ids
  166. }
  167. console.log("obj",obj)
  168. self.download(`/airbottle/alarm/record/export/`,obj, '报警记录导出-'+currentDate+'.xlsx')
  169. }).catch(() => {})
  170. }else {
  171. this.msgError('请选择要导出的数据')
  172. }
  173. }
  174. },
  175. // 多选框选中数据
  176. handleSelectionChange(selection) {
  177. this.selectedNum = selection.length;
  178. this.ids = selection.map(item => item.id);
  179. this.single = selection.length != 1;
  180. this.multiple = !selection.length;
  181. },
  182. /*===记录勾选数据===
  183. 需要再el-table 添加 :row-key="getRowKeys"
  184. 需要在selection 添加 :reserve-selection="true"
  185. */
  186. getRowKeys(row) {
  187. return row.id
  188. },
  189. //返回
  190. backPage(){
  191. this.$parent.handleClick('','','back');
  192. this.$parent.outStatistics()
  193. this.$parent.gasApplyStatistics()
  194. this.$parent.useGasStatistics()
  195. },
  196. /** 搜索按钮操作 */
  197. handleQuery() {
  198. this.queryParams.pageNum = 1;
  199. this.getList();
  200. },
  201. /** 重置按钮操作 */
  202. resetQuery() {
  203. this.queryParams.searchValue = "";
  204. this.dateRange=[];
  205. this.queryParams.startTime=null;
  206. this.queryParams.endTime=null
  207. this.handleQuery();
  208. },
  209. getList(){
  210. let _this=this;
  211. if(this.dateRange&&this.dateRange.length>0) {
  212. this.queryParams.startTime=this.dateRange[0]
  213. this.queryParams.endTime=this.dateRange[1]
  214. } else {
  215. this.queryParams.startTime=null;
  216. this.queryParams.endTime=null
  217. }
  218. alarmRecordList(_this.queryParams).then( response => {
  219. let res=response.rows;
  220. _this.tableData=res;
  221. _this.total=response.total;
  222. });
  223. },
  224. },
  225. mounted() {
  226. this.getList();
  227. }
  228. };
  229. </script>
  230. <style scoped lang="scss">
  231. /*导出按钮样式*/
  232. .form-dropdown-box{
  233. display: flex;
  234. margin:0;
  235. padding:0 10px;
  236. cursor: pointer;
  237. height:40px;
  238. img:nth-child(1){
  239. width:16px;
  240. height:16px;
  241. margin-top:12px;
  242. }
  243. p{
  244. width:47px;
  245. text-align: center;
  246. font-size:14px;
  247. margin:0;
  248. line-height:40px;
  249. }
  250. img:nth-child(3){
  251. width:10px;
  252. height:6px;
  253. margin-top:17px;
  254. }
  255. }
  256. .apply {
  257. flex:1;
  258. display: flex!important;
  259. flex-direction: column;
  260. .apply_page{
  261. flex:1;
  262. display: flex!important;
  263. flex-direction: column;
  264. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  265. padding:20px 20px 20px!important;
  266. border-radius:10px;
  267. .button-box{
  268. width:200px;
  269. display: flex;
  270. }
  271. }
  272. }
  273. </style>