index.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861
  1. <!--智能报警器-->
  2. <template>
  3. <div class="app-container smartAlarm">
  4. <el-form :model="queryParamsData" class="form-box" ref="queryForm" :inline="true">
  5. <el-form-item label="关键字" prop="searchValue">
  6. <el-input
  7. maxLength="30"
  8. v-model="queryParamsData.searchValue"
  9. placeholder="设备编号/实验室"
  10. clearable
  11. size="small"
  12. style="width: 240px"/>
  13. </el-form-item>
  14. <el-form-item label="学院" prop="deptId">
  15. <el-select v-model="queryParamsData.deptId" clearable placeholder="请选择学院">
  16. <el-option
  17. v-for="item in optionsListOne"
  18. :key="item.deptId"
  19. :label="item.deptName"
  20. :value="item.deptId">
  21. </el-option>
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item label="状态" prop="deviceStatus">
  25. <el-select v-model="queryParamsData.deviceStatus" clearable placeholder="请选择状态">
  26. <el-option
  27. v-for="item in optionsListTwo"
  28. :key="item.id"
  29. :label="item.name"
  30. :value="item.id">
  31. </el-option>
  32. </el-select>
  33. </el-form-item>
  34. <el-form-item>
  35. <p class="inquire-button-one" @click="handleQuery" style="margin-right:10px;">查询</p>
  36. <p class="reset-button-one" @click="resetQuery">重置</p>
  37. </el-form-item>
  38. <el-form-item style="float: right;">
  39. <el-col :span="1.5" v-hasPermi="['laboratory:hardware8:add']">
  40. <p class="add-button-one-90"
  41. @click="pageToggle(1)"
  42. ><i class="el-icon-plus"></i>新增</p>
  43. </el-col>
  44. </el-form-item>
  45. <el-form-item style="float: right;">
  46. <el-col :span="1.5" v-hasPermi="['chemical:hxpSmartTerminalConfig:edit']">
  47. <p class="add-button-one-90"
  48. @click="pageToggle(4)"
  49. >报警设置</p>
  50. </el-col>
  51. </el-form-item>
  52. <el-form-item style="float: right;">
  53. <el-dropdown @command="importButton" v-hasPermi="['laboratory:hardware8:import']">
  54. <div class="form-dropdown-box">
  55. <img src="@/assets/ZDimages/personnelManagement/icon_jzgxx_dr.png">
  56. <p>导入</p>
  57. <img src="@/assets/ZDimages/personnelManagement/icon_jzggl_xljt.png">
  58. </div>
  59. <el-dropdown-menu slot="dropdown">
  60. <el-dropdown-item style="border-bottom:1px solid #E0E0E0;margin:0 10px;color:#333;" :command="{command:1}">下载模板</el-dropdown-item>
  61. <el-dropdown-item style="margin:0 10px;color:#666;" :command="{command:2}">导入数据</el-dropdown-item>
  62. </el-dropdown-menu>
  63. </el-dropdown>
  64. </el-form-item>
  65. </el-form>
  66. <el-table border :data="tableList" @selection-change="handleSelectionChange" ref="multipleTable" :row-key="getRowKeys">
  67. <el-table-column type="selection" width="50" align="center" :reserve-selection="true"/>
  68. <el-table-column label="智能报警器编号" align="center" prop="hardwareNum"/>
  69. <el-table-column label="学院" align="center" prop="deptName" width="180"/>
  70. <el-table-column label="位置" align="center" prop="posi" width="250" show-overflow-tooltip/>
  71. <el-table-column label="设备状态" align="center" prop="status" width="80">
  72. <template slot-scope="scope">{{scope.row.operate.name}}</template>
  73. </el-table-column>
  74. <el-table-column label="报警时长" align="center" prop="ringTime" width="80">
  75. <template slot-scope="scope">{{scope.row.ringTime?scope.row.ringTime+'秒':'未设置'}}</template>
  76. </el-table-column>
  77. <el-table-column label="处理时长" align="center" prop="dealTime" width="80">
  78. <template slot-scope="scope">{{scope.row.dealTime?scope.row.dealTime+'分钟':'未设置'}}</template>
  79. </el-table-column>
  80. <el-table-column label="创建时间" align="center" prop="createTime" width="180"/>
  81. <el-table-column label="创建人" align="center" prop="createBy" width="150"/>
  82. <el-table-column label="操作" align="center" width="220" class-name="small-padding fixed-width" v-if="tableButtonType">
  83. <template slot-scope="scope">
  84. <div class="table-button-box">
  85. <p class="table-button-null"></p>
  86. <p class="table-button-p">
  87. <el-switch
  88. @click.native="changeIsNeedCaptcha(scope.row)"
  89. class="switch captcha-img"
  90. :active-value="1"
  91. :inactive-value="0"
  92. active-color="#0183FA"
  93. inactive-color="#999"
  94. v-model="scope.row.deviceStatus"
  95. active-text="启用"
  96. inactive-text="停用"
  97. disabled
  98. ></el-switch>
  99. </p>
  100. <p class="table-button-p" v-hasPermi="['laboratory:hardware8:edit']" @click="pageToggle(2,scope.row)">编辑</p>
  101. <p class="table-button-p" v-hasPermi="['laboratory:hardware8:remove']" @click="pageToggle(3,scope.row)">删除</p>
  102. <p class="table-button-null"></p>
  103. </div>
  104. </template>
  105. </el-table-column>
  106. </el-table>
  107. <div style="display: flex;height:32px;margin:15px 0;">
  108. <!--<p style="flex:4;"></p>-->
  109. <p style="text-align: left;margin:0;line-height:32px;margin-right:20px;font-size:14px;color:#999;">
  110. <i class="el-icon-warning" style="color:#0183FA;"></i>
  111. 已选择 {{selectedNum}} 项
  112. </p>
  113. <div style="flex:5;">
  114. <pagination :page-sizes="[20, 30, 40, 50]"
  115. v-show="total>0"
  116. :total="total"
  117. style="margin:0;"
  118. :page.sync="queryParams.pageNum"
  119. :limit.sync="queryParams.pageSize"
  120. @pagination="getList"
  121. />
  122. </div>
  123. </div>
  124. <!--导入窗口-->
  125. <el-dialog title="导入数据" :visible.sync="importOpen" :close-on-click-modal="false" @close="importOpenOff" width="600px" append-to-body class="import-dialog-box">
  126. <div class="el-upload__text" style="margin:0 0 20px 58px;">提示:导入后的数据将覆盖原有数据</div>
  127. <el-upload
  128. class="import-dialog-upLoad-box"
  129. :drag="true"
  130. :data="upImportData"
  131. :action="uploadImgUrl"
  132. :show-file-list="false"
  133. :on-success="handleAvatarSuccess"
  134. :headers="headers"
  135. :before-upload="beforeAvatarUpload">
  136. <i class="el-icon-upload"></i>
  137. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  138. <!--<div class="el-upload__tip" slot="tip">-->
  139. <!--<el-checkbox v-model="upImportData.upDate">是否更新已经存在的数据</el-checkbox>-->
  140. <!--</div>-->
  141. <div class="el-upload__tip" slot="tip">数据导入模板.xlsx<span style="color:#0183FA;cursor: pointer" @click="importTemplate">下载</span></div>
  142. <div class="el-upload-text-box" slot="tip" v-if="getImportData.downFile">
  143. <div class="img-text-box">
  144. <img src="@/assets/ZDimages/personnelManagement/icon_dr_wj.png">
  145. <p>{{getImportData.textName}}</p>
  146. </div>
  147. <p class="text-p">数据导入成功 <span style="color:#0183FA;">{{getImportData.successNum}}</span> 条,失败 <span style="color:#FF6464 ;">{{getImportData.failureNum}}</span> 条</p>
  148. <div class="img-text-box">
  149. <img src="@/assets/ZDimages/personnelManagement/icon_dr_sj.png">
  150. <p style="color:#0183FA;cursor: pointer;" @click="failureExcel">点击下载失败数据报表</p>
  151. </div>
  152. </div>
  153. </el-upload>
  154. <div slot="footer" class="teacher-import-dialog-button-box">
  155. <p class="inquire-button-one" @click="importOpenOff">确定</p>
  156. </div>
  157. <div class="teacher-import-dialog-position-box" v-if="loading"></div>
  158. </el-dialog>
  159. <!--新增/编辑-->
  160. <el-dialog :title="dialogTitle" :visible.sync="addDialogType" :close-on-click-modal="false" v-if="addDialogType" width="550px" append-to-body class="add-dialog-box">
  161. <el-form ref="form" :model="form" :rules="rules" label-width="140px">
  162. <el-form-item label="智能报警器名称:" prop="name">
  163. <el-input v-model="form.name" placeholder="请输入智能报警器名称" maxlength="30" style="width:360px;"/><!--onkeyup="value=value.replace(/[^\w\.\/]/ig,'')"-->
  164. </el-form-item>
  165. <el-form-item label="智能报警器编号:" prop="hardwareNum">
  166. <el-input v-model="form.hardwareNum" placeholder="最大20个字符,包含大小写字母、数字" onkeyup="value=value.replace(/[^\w\.\/]/ig,'')" maxlength="20" style="width:360px;"/>
  167. </el-form-item>
  168. <el-form-item label="实验室:" prop="subjectId">
  169. <el-select
  170. style="width:360px;"
  171. v-model="form.subjectId"
  172. filterable
  173. remote
  174. clearable
  175. reserve-keyword
  176. @focus="selectFocus"
  177. @clear="clearClick"
  178. placeholder="搜索选择实验室"
  179. :remote-method="getSelectList"
  180. :loading="loading">
  181. <el-option
  182. v-for="item in selectList"
  183. :key="item.id"
  184. :label="item.name"
  185. :value="item.id">
  186. </el-option>
  187. </el-select>
  188. </el-form-item>
  189. <el-form-item label="继电器类型">
  190. <el-radio-group v-model="form.hardwareType" style="width:360px;">
  191. <el-radio :label="item.value" :key="item.value" v-for="(item,index) in hardwardTypeList">{{item.label}}</el-radio>
  192. </el-radio-group>
  193. </el-form-item>
  194. <el-form-item label="绑定继电器" prop="relayCode" v-if="form.hardwareType==1">
  195. <el-select v-model="form.relayCode" placeholder="请选择继电器" clearable style="width:360px;">
  196. <el-option v-for="relay in relayList"
  197. :key="relay.code"
  198. :label="relay.code"
  199. :value="relay.code">
  200. </el-option>
  201. </el-select>
  202. </el-form-item>
  203. <el-form-item label="继电器编号" prop="relayCode" v-if="form.hardwareType==2">
  204. <el-input
  205. style="width:360px;"
  206. v-model="form.relayCode"
  207. placeholder="请输入继电器编号"
  208. clearable
  209. size="small"
  210. maxlength="20"
  211. />
  212. </el-form-item>
  213. <el-form-item label="继电器位置" prop="bit" >
  214. <el-select v-model="form.bit" placeholder="请选择继电器位置" clearable style="width:360px;">
  215. <el-option v-for="lab in relayNumList"
  216. :key="lab.name"
  217. :label="lab.name"
  218. :value="lab.name">
  219. </el-option>
  220. </el-select>
  221. </el-form-item>
  222. <el-form-item label="配置名称" prop="relayCode" v-if="form.hardwareType==2">
  223. <el-input
  224. style="width:360px;"
  225. v-model="form.configName"
  226. placeholder="请输入配置名称"
  227. clearable
  228. size="small"
  229. maxLength="15"
  230. />
  231. </el-form-item>
  232. <el-form-item label="配置状态" prop="relayCode" v-if="form.hardwareType==2">
  233. <el-input
  234. style="width:360px;"
  235. v-model="form.configStatus"
  236. placeholder="请输入配置状态"
  237. clearable
  238. size="small"
  239. maxLength="8"
  240. />
  241. </el-form-item>
  242. </el-form>
  243. <div slot="footer" class="dialog-footer">
  244. <el-button type="primary" @click="submitForm">确 定</el-button>
  245. <el-button @click="cancel">取 消</el-button>
  246. </div>
  247. </el-dialog>
  248. <!--报警设置-->
  249. <el-dialog title="报警设置" :visible.sync="setUpType" :close-on-click-modal="false" v-if="setUpType" width="550px" append-to-body class="add-dialog-box">
  250. <el-form ref="setUpForm" :model="setUpForm" :rules="rules" label-width="120px">
  251. <el-form-item label="报警时长:" prop="ringTime">
  252. <el-input v-model="setUpForm.ringTime" placeholder="请输入报警时长" maxlength="3" style="width:360px;">
  253. <template slot="append">秒</template>
  254. </el-input>
  255. </el-form-item>
  256. <el-form-item label="处理时长:" prop="dealTime">
  257. <el-input v-model="setUpForm.dealTime" placeholder="请输入处理时长" maxlength="3" style="width:360px;">
  258. <template slot="append">分钟</template>
  259. </el-input>
  260. </el-form-item>
  261. </el-form>
  262. <div slot="footer" class="dialog-footer">
  263. <el-button type="primary" @click="setUpSubmitForm">确 定</el-button>
  264. <el-button @click="setUpCancel">取 消</el-button>
  265. </div>
  266. </el-dialog>
  267. </div>
  268. </template>
  269. <script>
  270. import { hxpSmartTerminal,filterDept,getSubList,addHxpSmartTerminal,putHxpSmartTerminal,getHxpSmartTerminal,delHxpSmartTerminal,updateStatus,alarmSettings } from "@/api/medicUniversity-3_1/index";
  271. import { listHardware, delHardware, addHardware, updateHardware, hardWareControl } from "@/api/medicUniversity-3_1/index";
  272. import { listRelay } from "@/api/laboratory/relay";
  273. import { listDepartments } from "@/api/system/dept";
  274. import {subjectDictList } from "@/api/laboratory/record";
  275. import { getToken } from "@/utils/auth";
  276. export default {
  277. name: "smartAlarm",
  278. data() {
  279. return {
  280. // table操作按钮校验
  281. tableButtonType:this.hasPermiDom(['laboratory:hardware8:edit','laboratory:hardware8:remove']),
  282. //上传相关配置
  283. uploadImgUrl: window.location.href.split('://')[0]+'://' + this.judgmentNetworkReturnAddress() + "/laboratory/hardware/importData", // 上传地址
  284. headers: {
  285. Authorization: "Bearer " + getToken(),
  286. },
  287. // 遮罩层
  288. loading:false,
  289. //页面状态
  290. pageType:1,
  291. // 搜索数据
  292. queryParamsData:{
  293. pageNum:1,
  294. pageSize:20,
  295. },
  296. // 搜索实际发送数据
  297. queryParams:{
  298. pageNum:1,
  299. pageSize:20,
  300. },
  301. //数据数量
  302. total:0,
  303. //数据数组
  304. tableList:[],
  305. //表格扩展选择器---需要在@selection-change绑定的方法内监控selection数组长度
  306. selectedNum:0,
  307. // 选中数组
  308. ids: [],
  309. // 非单个禁用
  310. single: true,
  311. // 非多个禁用
  312. multiple: true,
  313. //学院列表
  314. optionsListOne:[],
  315. //状态列表
  316. optionsListTwo:[{id:"1",name:"启用"},{id:"0",name:"停用"}],
  317. //导入弹层开关
  318. importOpen:false,
  319. //导入数据
  320. upImportData:{
  321. sysUserEnable:true,
  322. upDate:false,
  323. terminalType:'AI_ALARM',
  324. },
  325. getImportData:{
  326. downFile:false,
  327. successNum:0,
  328. failureNum:0,
  329. textName:"",
  330. },
  331. //编辑新增相关
  332. dialogTitle:"",
  333. addDialogType:false,
  334. form:{},
  335. selectList:[],
  336. selectListData:[],
  337. relayNum: "",
  338. rules:{
  339. name: [
  340. { required: true, message: "请输入智能报警器名称", trigger: "blur" },
  341. { required: true, message: "请输入智能报警器名称", validator: this.spaceJudgment, trigger: "blur" }
  342. ],
  343. hardwareNum: [
  344. { required: true, trigger: "blur", message: "最大20个字符,包含大小写字母、数字" },
  345. { required: true, message: "最大20个字符,包含大小写字母、数字", validator: this.spaceJudgment, trigger: "blur" }
  346. ],
  347. subjectId: [
  348. { required: true, trigger: "blur", message: "搜索选择实验室" },
  349. ],
  350. ringTime: [
  351. { required: true, trigger: "blur", message: "请输入报警时长" },
  352. { required: true, message: "请输入报警时长", validator: this.spaceJudgment, trigger: "blur" },
  353. { required: true, message: "只能输入数字", validator: this.isNum, trigger: "blur" },
  354. ],
  355. dealTime: [
  356. { required: true, trigger: "blur", message: "请输入处理时长" },
  357. { required: true, message: "请输入处理时长", validator: this.spaceJudgment, trigger: "blur" },
  358. { required: true, message: "只能输入数字", validator: this.isNum, trigger: "blur" },
  359. ],
  360. },
  361. //报警设置
  362. setUpType:false,
  363. setUpForm:{},
  364. // 继电器
  365. relayList: [],
  366. relayNumList:[
  367. {name:1},
  368. {name:2},
  369. {name:3},
  370. {name:4},
  371. {name:5},
  372. {name:6},
  373. {name:7},
  374. {name:8},
  375. {name:9},
  376. {name:10},
  377. {name:11},
  378. {name:12}
  379. ],
  380. hardwardTypeList:[
  381. {value:1,label:"老继电器"},
  382. {value:2,label:"新继电器"}
  383. ]
  384. };
  385. },
  386. created() {
  387. },
  388. mounted(){
  389. this.filterDept();
  390. this.listDepartments();
  391. this.getList();
  392. this.getRelayList();
  393. },
  394. methods: {
  395. selectFocus(){
  396. if(!this.selectList[0]){
  397. this.filterDept();
  398. }
  399. },
  400. // 查询继电器列表
  401. getRelayList(){
  402. listRelay({"type": 1}).then(response => {
  403. this.relayList = response.data;
  404. if(this.form.relayCode){
  405. let self = this
  406. let num = ""
  407. for(let i=0;i<self.relayList.length;i++){
  408. if(self.relayList[i].code == this.form.relayCode){
  409. num = self.relayList[i].routeNum
  410. }
  411. }
  412. let list = [];
  413. for(let i=0;i<num;i++){
  414. let obj = {
  415. name:i+1
  416. }
  417. list.push(obj);
  418. }
  419. this.relayNumList = list;
  420. }
  421. });
  422. },
  423. //报警器开启关闭方法
  424. changeIsNeedCaptcha(row){
  425. let self = this;
  426. console.log("row.deviceStatus",row.deviceStatus);
  427. let text = row.deviceStatus==1?'停用':(row.deviceStatus==0?'启用':'')
  428. this.$confirm(`是否`+text+`此设备`, "提示", {
  429. confirmButtonText: "确定",
  430. cancelButtonText: "取消",
  431. type: "warning"
  432. }).then(async () => {
  433. self.switchChange(row)
  434. }).catch(() => {
  435. })
  436. },
  437. //开关按钮
  438. switchChange(row){
  439. //编辑
  440. let obj = {
  441. id:row.id,
  442. deviceStatus:row.deviceStatus == 1?0:1
  443. }
  444. this.form.type = "AI_ALARM";
  445. updateHardware(obj).then(response => {
  446. if (response.code == 200){
  447. row.deviceStatus = row.deviceStatus == 1?0:1;
  448. }
  449. });
  450. },
  451. //获取学院列表
  452. listDepartments(){
  453. listDepartments().then(response => {
  454. this.optionsListOne = response.data;
  455. });
  456. },
  457. pageToggle(type,item){
  458. let self = this;
  459. if(type == 1){
  460. //新增
  461. this.dialogTitle = '新增';
  462. this.$set(this,'form',{
  463. hardwareNum:"",
  464. subjectId:"",
  465. hardwareType:1,
  466. relayCode:"",
  467. bit:"",
  468. configName:"",
  469. configStatus:"",
  470. });
  471. this.clearClick();
  472. this.addDialogType = true;
  473. }else if(type == 2){
  474. // 编辑
  475. this.dialogTitle = '编辑';
  476. let obj = {
  477. name:item.name,
  478. id:item.id,
  479. subjectId:item.subjectId,
  480. hardwareNum:item.hardwareNum,
  481. hardwareType:item.hardwareType,
  482. relayCode:item.relayCode,
  483. bit:item.bit,
  484. configName:item.configName,
  485. configStatus:item.configStatus,
  486. };
  487. this.$set(this,'form',obj);
  488. this.clearClick();
  489. this.addDialogType = true;
  490. }else if(type == 3){
  491. // 删除
  492. this.$confirm('确认要删除吗?', "警告", {
  493. confirmButtonText: "确定",
  494. cancelButtonText: "取消",
  495. type: "warning"
  496. }).then(function() {
  497. delHardware(item.id).then(response => {
  498. if (response.code == 200){
  499. self.msgSuccess(response.msg);
  500. self.getList();
  501. }
  502. });
  503. }).then(() => {
  504. }).catch(() => {});
  505. }else if(type == 4){
  506. //报警设置
  507. if(self.ids.length>0) {
  508. this.setUpForm = {
  509. ringTime:"",
  510. dealTime:""
  511. }
  512. this.setUpType = true;
  513. }else{
  514. this.msgError('请选择要设置的报警器')
  515. }
  516. }
  517. },
  518. //查询当前院系
  519. filterDept(){
  520. filterDept().then(response => {
  521. let idText = "";
  522. for(let i=0;i<response.data.length;i++){
  523. if(i==0){
  524. idText = idText + response.data[i].deptId;
  525. }else{
  526. idText = idText +','+ response.data[i].deptId;
  527. }
  528. }
  529. //查询院系下实验室
  530. subjectDictList(idText).then(response => {
  531. //当前列表
  532. this.selectList = JSON.parse(JSON.stringify(response.data));
  533. //原始列表数据
  534. this.selectListData = JSON.parse(JSON.stringify(response.data));
  535. });
  536. });
  537. },
  538. /** 实验室-本地懒加载 */
  539. getSelectList(val) {
  540. let self = this;
  541. let list = [];
  542. for(let i=0;i<self.selectListData.length;i++){
  543. if(self.selectListData[i].name.indexOf(val) != -1){
  544. list.push(self.selectListData[i]);
  545. }
  546. }
  547. this.selectList = JSON.parse(JSON.stringify(list))
  548. },
  549. //实验室选中清除
  550. clearClick(){
  551. this.selectList = JSON.parse(JSON.stringify(this.selectListData))
  552. },
  553. submitForm(){
  554. this.$refs["form"].validate((valid) => {
  555. if (valid) {
  556. if(this.form.id){
  557. //编辑
  558. this.form.type = "AI_ALARM";
  559. updateHardware(this.form).then(response => {
  560. if (response.code == 200){
  561. this.addDialogType = false;
  562. this.msgSuccess(response.msg);
  563. this.getList();
  564. }
  565. });
  566. }else{
  567. //新增
  568. this.form.type = "AI_ALARM";
  569. addHardware(this.form).then(response => {
  570. if (response.code == 200){
  571. this.addDialogType = false;
  572. this.msgSuccess(response.msg);
  573. this.resetQuery();
  574. }
  575. });
  576. }
  577. }
  578. })
  579. },
  580. cancel(){
  581. this.addDialogType = false;
  582. },
  583. //获取数据列表
  584. getList(){
  585. this.queryParamsData = JSON.parse(JSON.stringify(this.queryParams));
  586. this.queryParamsData.type = 'AI_ALARM';
  587. listHardware(this.queryParamsData).then(response => {
  588. this.total = response.total;
  589. this.tableList = response.rows;
  590. });
  591. },
  592. /** 搜索按钮操作 */
  593. handleQuery() {
  594. this.queryParamsData.pageNum = 1;
  595. this.queryParamsData.pageSize = 20;
  596. this.queryParams = JSON.parse(JSON.stringify(this.queryParamsData));
  597. this.getList();
  598. },
  599. /** 重置按钮操作 */
  600. resetQuery() {
  601. this.$set(this,'queryParamsData',{});
  602. this.$set(this,'queryParams',{});
  603. this.handleQuery();
  604. },
  605. //导入页面关闭
  606. importOpenOff(){
  607. this.importOpen = false;
  608. this.getImportData.downFile = false;
  609. this.getImportData.successNum = 0;
  610. this.getImportData.failureNum = 0;
  611. this.getImportData.textName = "";
  612. },
  613. /** 导入按钮操作 */
  614. importButton(item){
  615. if(item.command == 1){
  616. // 下载模板
  617. this.download('/laboratory/hardware/importTemplate', {}, `导入模板.xlsx`)
  618. }else if(item.command == 2){
  619. // 导入数据
  620. console.log('导入数据');
  621. this.importOpen = true;
  622. }
  623. },
  624. /** 下载模板操作 */
  625. importTemplate() {
  626. this.download('/laboratory/hardware/importTemplate', {}, `导入模板.xlsx`)
  627. },
  628. /*下载失败列表*/
  629. failureExcel(){
  630. this.download('/laboratory/hardware/importErrorData', {}, `失败报表.xlsx`)
  631. },
  632. //****************************************导入功能**************************************
  633. handleAvatarSuccess(res, file) {
  634. if(res.code == 200){
  635. if(res.data.downFile){
  636. this.getImportData.downFile = res.data.downFile
  637. this.getImportData.successNum = res.data.successNum
  638. this.getImportData.failureNum = res.data.failureNum
  639. }else{
  640. this.msgSuccess(res.msg);
  641. this.importOpen = false;
  642. this.resetQuery();
  643. }
  644. // this.getImportData.downFile = res.data.downFile
  645. // this.getImportData.successNum = res.data.successNum
  646. // this.getImportData.failureNum = res.data.failureNum
  647. // this.importOpen = false;
  648. // this.getList();
  649. }else{
  650. this.msgError(res.msg);
  651. }
  652. this.loading = false;
  653. },
  654. beforeAvatarUpload(file) {
  655. let type = false;
  656. console.log('file',file);
  657. if (file.type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.type == 'application/vnd.ms-excel') {
  658. this.getImportData.textName = file.name;
  659. type = true;
  660. this.loading = true;
  661. }else{
  662. this.msgError('只能上传xls/xlsx格式文件')
  663. type = false;
  664. }
  665. return type;
  666. },
  667. //修改报警设置
  668. setUpSubmitForm(){
  669. this.$refs["setUpForm"].validate((valid) => {
  670. if (valid) {
  671. let obj = {
  672. ids:this.ids,
  673. ringTime:parseInt(this.setUpForm.ringTime),
  674. dealTime:parseInt(this.setUpForm.dealTime),
  675. }
  676. alarmSettings(obj).then(response => {
  677. if(response.code == 200){
  678. this.setUpType = false;
  679. this.msgSuccess(response.msg);
  680. this.getList();
  681. }
  682. });
  683. }
  684. })
  685. },
  686. //关闭报警设置页面
  687. setUpCancel(){
  688. this.setUpType = false;
  689. },
  690. // 多选框选中数据
  691. handleSelectionChange(selection) {
  692. this.selectedNum = selection.length;
  693. this.ids = selection.map(item => item.id);
  694. this.single = selection.length != 1;
  695. this.multiple = !selection.length;
  696. },
  697. /*===记录勾选数据===
  698. 需要再el-table 添加 :row-key="getRowKeys"
  699. 需要在selection 添加 :reserve-selection="true"
  700. */
  701. getRowKeys(row) {
  702. return row.id
  703. },
  704. },
  705. }
  706. </script>
  707. <style scoped lang="scss">
  708. .smartAlarm{
  709. flex:1;
  710. display: flex;
  711. flex-direction: column;
  712. overflow: hidden!important;
  713. padding:20px !important;
  714. p{
  715. margin:0;
  716. padding:0;
  717. }
  718. .form-box{
  719. .form-dropdown-box{
  720. display: flex;
  721. margin:0;
  722. padding:0 10px;
  723. cursor: pointer;
  724. height:40px;
  725. img:nth-child(1){
  726. width:16px;
  727. height:16px;
  728. margin-top:12px;
  729. }
  730. p{
  731. width:47px;
  732. text-align: center;
  733. font-size:14px;
  734. margin:0;
  735. line-height:40px;
  736. }
  737. img:nth-child(3){
  738. width:10px;
  739. height:6px;
  740. margin-top:17px;
  741. }
  742. }
  743. }
  744. .button-box{
  745. display: flex;
  746. }
  747. }
  748. </style>
  749. <style lang="scss">
  750. .import-dialog-box{
  751. .import-dialog-upLoad-box{
  752. .el-upload{
  753. width:450px;
  754. margin:0 55px;
  755. .el-upload-dragger{
  756. width:450px;
  757. .el-icon-upload{
  758. font-size:100px;
  759. color:#CBE6FE;
  760. }
  761. .el-upload__text{
  762. margin-top:20px;
  763. }
  764. }
  765. }
  766. .el-upload__tip{
  767. margin-left:60px;
  768. font-size:14px;
  769. margin-top:10px;
  770. }
  771. .el-upload-text-box{
  772. background: #F5F5F5;
  773. border-radius: 10px;
  774. margin:15px 30px 0;
  775. padding:0 20px 15px;
  776. overflow: hidden;
  777. *{
  778. margin:0;
  779. }
  780. .img-text-box{
  781. display: flex;
  782. margin-top:15px;
  783. img{
  784. width:16px;
  785. height:16px;
  786. margin-right:13px;
  787. }
  788. p{
  789. height:16px;
  790. line-height:16px;
  791. font-size:12px;
  792. }
  793. }
  794. .text-p{
  795. margin-top:15px;
  796. margin-left:29px;
  797. height:16px;
  798. line-height:16px;
  799. font-size:12px;
  800. }
  801. }
  802. }
  803. .teacher-import-dialog-button-box{
  804. display: flex;
  805. width:190px;
  806. margin:0 auto;
  807. p{
  808. width:70px;
  809. height:30px;
  810. line-height:30px;
  811. font-size:14px;
  812. margin:0 auto;
  813. }
  814. }
  815. .teacher-import-dialog-position-box{
  816. width:100%;
  817. height:100%;
  818. position: absolute;
  819. top:0;
  820. left:0;
  821. z-index: 999;
  822. background: rgba(255,255,255,0.4);
  823. border-radius:20px;
  824. }
  825. }
  826. </style>
  827. <style lang="scss">
  828. .smartAlarm{
  829. .switch .el-switch__label {
  830. position: absolute;
  831. display: none;
  832. color: #fff !important;
  833. }
  834. .switch .el-switch__label--right {
  835. z-index: 1;
  836. }
  837. .switch .el-switch__label--right span{
  838. margin-right:10px;
  839. }
  840. .switch .el-switch__label--left {
  841. z-index: 1;
  842. }
  843. .switch .el-switch__label--left span{
  844. margin-left: 14px;
  845. }
  846. .switch .el-switch__label.is-active {
  847. display: block;
  848. }
  849. .switch.el-switch .el-switch__core,
  850. .el-switch .el-switch__label {
  851. width: 64px !important;
  852. margin: 0;
  853. }
  854. }
  855. </style>