index.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862
  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 || form.hardwareType==3">
  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. {value:3,label:"泥人继电器"}
  384. ]
  385. };
  386. },
  387. created() {
  388. },
  389. mounted(){
  390. this.filterDept();
  391. this.listDepartments();
  392. this.getList();
  393. this.getRelayList();
  394. },
  395. methods: {
  396. selectFocus(){
  397. if(!this.selectList[0]){
  398. this.filterDept();
  399. }
  400. },
  401. // 查询继电器列表
  402. getRelayList(){
  403. listRelay({"type": 1}).then(response => {
  404. this.relayList = response.data;
  405. if(this.form.relayCode){
  406. let self = this
  407. let num = ""
  408. for(let i=0;i<self.relayList.length;i++){
  409. if(self.relayList[i].code == this.form.relayCode){
  410. num = self.relayList[i].routeNum
  411. }
  412. }
  413. let list = [];
  414. for(let i=0;i<num;i++){
  415. let obj = {
  416. name:i+1
  417. }
  418. list.push(obj);
  419. }
  420. this.relayNumList = list;
  421. }
  422. });
  423. },
  424. //报警器开启关闭方法
  425. changeIsNeedCaptcha(row){
  426. let self = this;
  427. console.log("row.deviceStatus",row.deviceStatus);
  428. let text = row.deviceStatus==1?'停用':(row.deviceStatus==0?'启用':'')
  429. this.$confirm(`是否`+text+`此设备`, "提示", {
  430. confirmButtonText: "确定",
  431. cancelButtonText: "取消",
  432. type: "warning"
  433. }).then(async () => {
  434. self.switchChange(row)
  435. }).catch(() => {
  436. })
  437. },
  438. //开关按钮
  439. switchChange(row){
  440. //编辑
  441. let obj = {
  442. id:row.id,
  443. deviceStatus:row.deviceStatus == 1?0:1
  444. }
  445. this.form.type = "AI_ALARM";
  446. updateHardware(obj).then(response => {
  447. if (response.code == 200){
  448. row.deviceStatus = row.deviceStatus == 1?0:1;
  449. }
  450. });
  451. },
  452. //获取学院列表
  453. listDepartments(){
  454. listDepartments().then(response => {
  455. this.optionsListOne = response.data;
  456. });
  457. },
  458. pageToggle(type,item){
  459. let self = this;
  460. if(type == 1){
  461. //新增
  462. this.dialogTitle = '新增';
  463. this.$set(this,'form',{
  464. hardwareNum:"",
  465. subjectId:"",
  466. hardwareType:1,
  467. relayCode:"",
  468. bit:"",
  469. configName:"",
  470. configStatus:"",
  471. });
  472. this.clearClick();
  473. this.addDialogType = true;
  474. }else if(type == 2){
  475. // 编辑
  476. this.dialogTitle = '编辑';
  477. let obj = {
  478. name:item.name,
  479. id:item.id,
  480. subjectId:item.subjectId,
  481. hardwareNum:item.hardwareNum,
  482. hardwareType:item.hardwareType,
  483. relayCode:item.relayCode,
  484. bit:item.bit,
  485. configName:item.configName,
  486. configStatus:item.configStatus,
  487. };
  488. this.$set(this,'form',obj);
  489. this.clearClick();
  490. this.addDialogType = true;
  491. }else if(type == 3){
  492. // 删除
  493. this.$confirm('确认要删除吗?', "警告", {
  494. confirmButtonText: "确定",
  495. cancelButtonText: "取消",
  496. type: "warning"
  497. }).then(function() {
  498. delHardware(item.id).then(response => {
  499. if (response.code == 200){
  500. self.msgSuccess(response.msg);
  501. self.getList();
  502. }
  503. });
  504. }).then(() => {
  505. }).catch(() => {});
  506. }else if(type == 4){
  507. //报警设置
  508. if(self.ids.length>0) {
  509. this.setUpForm = {
  510. ringTime:"",
  511. dealTime:""
  512. }
  513. this.setUpType = true;
  514. }else{
  515. this.msgError('请选择要设置的报警器')
  516. }
  517. }
  518. },
  519. //查询当前院系
  520. filterDept(){
  521. filterDept().then(response => {
  522. let idText = "";
  523. for(let i=0;i<response.data.length;i++){
  524. if(i==0){
  525. idText = idText + response.data[i].deptId;
  526. }else{
  527. idText = idText +','+ response.data[i].deptId;
  528. }
  529. }
  530. //查询院系下实验室
  531. subjectDictList(idText).then(response => {
  532. //当前列表
  533. this.selectList = JSON.parse(JSON.stringify(response.data));
  534. //原始列表数据
  535. this.selectListData = JSON.parse(JSON.stringify(response.data));
  536. });
  537. });
  538. },
  539. /** 实验室-本地懒加载 */
  540. getSelectList(val) {
  541. let self = this;
  542. let list = [];
  543. for(let i=0;i<self.selectListData.length;i++){
  544. if(self.selectListData[i].name.indexOf(val) != -1){
  545. list.push(self.selectListData[i]);
  546. }
  547. }
  548. this.selectList = JSON.parse(JSON.stringify(list))
  549. },
  550. //实验室选中清除
  551. clearClick(){
  552. this.selectList = JSON.parse(JSON.stringify(this.selectListData))
  553. },
  554. submitForm(){
  555. this.$refs["form"].validate((valid) => {
  556. if (valid) {
  557. if(this.form.id){
  558. //编辑
  559. this.form.type = "AI_ALARM";
  560. updateHardware(this.form).then(response => {
  561. if (response.code == 200){
  562. this.addDialogType = false;
  563. this.msgSuccess(response.msg);
  564. this.getList();
  565. }
  566. });
  567. }else{
  568. //新增
  569. this.form.type = "AI_ALARM";
  570. addHardware(this.form).then(response => {
  571. if (response.code == 200){
  572. this.addDialogType = false;
  573. this.msgSuccess(response.msg);
  574. this.resetQuery();
  575. }
  576. });
  577. }
  578. }
  579. })
  580. },
  581. cancel(){
  582. this.addDialogType = false;
  583. },
  584. //获取数据列表
  585. getList(){
  586. this.queryParamsData = JSON.parse(JSON.stringify(this.queryParams));
  587. this.queryParamsData.type = 'AI_ALARM';
  588. listHardware(this.queryParamsData).then(response => {
  589. this.total = response.total;
  590. this.tableList = response.rows;
  591. });
  592. },
  593. /** 搜索按钮操作 */
  594. handleQuery() {
  595. this.queryParamsData.pageNum = 1;
  596. this.queryParamsData.pageSize = 20;
  597. this.queryParams = JSON.parse(JSON.stringify(this.queryParamsData));
  598. this.getList();
  599. },
  600. /** 重置按钮操作 */
  601. resetQuery() {
  602. this.$set(this,'queryParamsData',{});
  603. this.$set(this,'queryParams',{});
  604. this.handleQuery();
  605. },
  606. //导入页面关闭
  607. importOpenOff(){
  608. this.importOpen = false;
  609. this.getImportData.downFile = false;
  610. this.getImportData.successNum = 0;
  611. this.getImportData.failureNum = 0;
  612. this.getImportData.textName = "";
  613. },
  614. /** 导入按钮操作 */
  615. importButton(item){
  616. if(item.command == 1){
  617. // 下载模板
  618. this.download('/laboratory/hardware/importTemplate', {}, `导入模板.xlsx`)
  619. }else if(item.command == 2){
  620. // 导入数据
  621. console.log('导入数据');
  622. this.importOpen = true;
  623. }
  624. },
  625. /** 下载模板操作 */
  626. importTemplate() {
  627. this.download('/laboratory/hardware/importTemplate', {}, `导入模板.xlsx`)
  628. },
  629. /*下载失败列表*/
  630. failureExcel(){
  631. this.download('/laboratory/hardware/importErrorData', {}, `失败报表.xlsx`)
  632. },
  633. //****************************************导入功能**************************************
  634. handleAvatarSuccess(res, file) {
  635. if(res.code == 200){
  636. if(res.data.downFile){
  637. this.getImportData.downFile = res.data.downFile
  638. this.getImportData.successNum = res.data.successNum
  639. this.getImportData.failureNum = res.data.failureNum
  640. }else{
  641. this.msgSuccess(res.msg);
  642. this.importOpen = false;
  643. this.resetQuery();
  644. }
  645. // this.getImportData.downFile = res.data.downFile
  646. // this.getImportData.successNum = res.data.successNum
  647. // this.getImportData.failureNum = res.data.failureNum
  648. // this.importOpen = false;
  649. // this.getList();
  650. }else{
  651. this.msgError(res.msg);
  652. }
  653. this.loading = false;
  654. },
  655. beforeAvatarUpload(file) {
  656. let type = false;
  657. console.log('file',file);
  658. if (file.type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.type == 'application/vnd.ms-excel') {
  659. this.getImportData.textName = file.name;
  660. type = true;
  661. this.loading = true;
  662. }else{
  663. this.msgError('只能上传xls/xlsx格式文件')
  664. type = false;
  665. }
  666. return type;
  667. },
  668. //修改报警设置
  669. setUpSubmitForm(){
  670. this.$refs["setUpForm"].validate((valid) => {
  671. if (valid) {
  672. let obj = {
  673. ids:this.ids,
  674. ringTime:parseInt(this.setUpForm.ringTime),
  675. dealTime:parseInt(this.setUpForm.dealTime),
  676. }
  677. alarmSettings(obj).then(response => {
  678. if(response.code == 200){
  679. this.setUpType = false;
  680. this.msgSuccess(response.msg);
  681. this.getList();
  682. }
  683. });
  684. }
  685. })
  686. },
  687. //关闭报警设置页面
  688. setUpCancel(){
  689. this.setUpType = false;
  690. },
  691. // 多选框选中数据
  692. handleSelectionChange(selection) {
  693. this.selectedNum = selection.length;
  694. this.ids = selection.map(item => item.id);
  695. this.single = selection.length != 1;
  696. this.multiple = !selection.length;
  697. },
  698. /*===记录勾选数据===
  699. 需要再el-table 添加 :row-key="getRowKeys"
  700. 需要在selection 添加 :reserve-selection="true"
  701. */
  702. getRowKeys(row) {
  703. return row.id
  704. },
  705. },
  706. }
  707. </script>
  708. <style scoped lang="scss">
  709. .smartAlarm{
  710. flex:1;
  711. display: flex;
  712. flex-direction: column;
  713. overflow: hidden!important;
  714. padding:20px !important;
  715. p{
  716. margin:0;
  717. padding:0;
  718. }
  719. .form-box{
  720. .form-dropdown-box{
  721. display: flex;
  722. margin:0;
  723. padding:0 10px;
  724. cursor: pointer;
  725. height:40px;
  726. img:nth-child(1){
  727. width:16px;
  728. height:16px;
  729. margin-top:12px;
  730. }
  731. p{
  732. width:47px;
  733. text-align: center;
  734. font-size:14px;
  735. margin:0;
  736. line-height:40px;
  737. }
  738. img:nth-child(3){
  739. width:10px;
  740. height:6px;
  741. margin-top:17px;
  742. }
  743. }
  744. }
  745. .button-box{
  746. display: flex;
  747. }
  748. }
  749. </style>
  750. <style lang="scss">
  751. .import-dialog-box{
  752. .import-dialog-upLoad-box{
  753. .el-upload{
  754. width:450px;
  755. margin:0 55px;
  756. .el-upload-dragger{
  757. width:450px;
  758. .el-icon-upload{
  759. font-size:100px;
  760. color:#CBE6FE;
  761. }
  762. .el-upload__text{
  763. margin-top:20px;
  764. }
  765. }
  766. }
  767. .el-upload__tip{
  768. margin-left:60px;
  769. font-size:14px;
  770. margin-top:10px;
  771. }
  772. .el-upload-text-box{
  773. background: #F5F5F5;
  774. border-radius: 10px;
  775. margin:15px 30px 0;
  776. padding:0 20px 15px;
  777. overflow: hidden;
  778. *{
  779. margin:0;
  780. }
  781. .img-text-box{
  782. display: flex;
  783. margin-top:15px;
  784. img{
  785. width:16px;
  786. height:16px;
  787. margin-right:13px;
  788. }
  789. p{
  790. height:16px;
  791. line-height:16px;
  792. font-size:12px;
  793. }
  794. }
  795. .text-p{
  796. margin-top:15px;
  797. margin-left:29px;
  798. height:16px;
  799. line-height:16px;
  800. font-size:12px;
  801. }
  802. }
  803. }
  804. .teacher-import-dialog-button-box{
  805. display: flex;
  806. width:190px;
  807. margin:0 auto;
  808. p{
  809. width:70px;
  810. height:30px;
  811. line-height:30px;
  812. font-size:14px;
  813. margin:0 auto;
  814. }
  815. }
  816. .teacher-import-dialog-position-box{
  817. width:100%;
  818. height:100%;
  819. position: absolute;
  820. top:0;
  821. left:0;
  822. z-index: 999;
  823. background: rgba(255,255,255,0.4);
  824. border-radius:20px;
  825. }
  826. }
  827. </style>
  828. <style lang="scss">
  829. .smartAlarm{
  830. .switch .el-switch__label {
  831. position: absolute;
  832. display: none;
  833. color: #fff !important;
  834. }
  835. .switch .el-switch__label--right {
  836. z-index: 1;
  837. }
  838. .switch .el-switch__label--right span{
  839. margin-right:10px;
  840. }
  841. .switch .el-switch__label--left {
  842. z-index: 1;
  843. }
  844. .switch .el-switch__label--left span{
  845. margin-left: 14px;
  846. }
  847. .switch .el-switch__label.is-active {
  848. display: block;
  849. }
  850. .switch.el-switch .el-switch__core,
  851. .el-switch .el-switch__label {
  852. width: 64px !important;
  853. margin: 0;
  854. }
  855. }
  856. </style>