index.vue 29 KB

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