smartLock.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. <template>
  2. <div class="smartLock">
  3. <div class="smartLock-min-page" v-if="pageType == 1">
  4. <div class="title-box">
  5. <p>智能锁</p>
  6. <p class="reset-button-one" @click="backPage"><i class="el-icon-arrow-left"></i>返回</p>
  7. </div>
  8. <div class="smartLock-min-page-min">
  9. <el-form :model="queryParamsData" class="form-box" ref="queryForm" :inline="true">
  10. <el-form-item label="关键字" prop="searchValue">
  11. <el-input
  12. maxLength="30"
  13. v-model="queryParamsData.searchValue"
  14. placeholder="设备编号/名称"
  15. clearable
  16. size="small"
  17. style="width: 240px"
  18. />
  19. </el-form-item>
  20. <el-form-item label="设备状态" prop="useStatus">
  21. <el-select v-model="queryParamsData.operate" clearable placeholder="请选择状态">
  22. <el-option
  23. v-for="item in optionsList"
  24. :key="item.id"
  25. :label="item.name"
  26. :value="item.id">
  27. </el-option>
  28. </el-select>
  29. </el-form-item>
  30. <el-form-item>
  31. <p class="inquire-button-one" @click="handleQuery" style="margin-right:10px;">查询</p>
  32. <p class="reset-button-one" @click="resetQuery">重置</p>
  33. </el-form-item>
  34. <!--<el-form-item style="float: right;">-->
  35. <!--<el-col :span="1.5" v-hasPermi="['']">-->
  36. <!--<p class="add-button-one-90"-->
  37. <!--@click="pageToggle(4)"-->
  38. <!--&gt;柜锁设置</p>-->
  39. <!--</el-col>-->
  40. <!--</el-form-item>-->
  41. </el-form>
  42. <el-table border :data="tableList" @selection-change="handleSelectionChange" ref="multipleTable" :row-key="getRowKeys">
  43. <!--<el-table-column type="selection" width="50" align="center"/>-->
  44. <el-table-column label="智能柜锁编号" align="center" prop="hardwareNum"/>
  45. <el-table-column label="柜锁名称" align="center" prop="name" width="150"/>
  46. <el-table-column label="位置" align="center" prop="posi" width="400"/>
  47. <!--sass后放开-->
  48. <!--<el-table-column label="设备状态" align="center" prop="status" width="100">-->
  49. <!--<template slot-scope="scope">{{scope.row.status == 3||scope.row.status == 4?'在线':'离线'}}</template>-->
  50. <!--</el-table-column>-->
  51. <el-table-column label="关联时间" align="center" prop="joinCabinetTime" width="160"/>
  52. <el-table-column label="操作人" align="center" prop="createBy" width="120"/>
  53. <el-table-column label="操作" align="center" width="180" class-name="small-padding fixed-width" v-if="tableButtonType">
  54. <template slot-scope="scope">
  55. <div class="button-box">
  56. <p class="table-min-button" v-hasPermi="['chemical:locklog2:list']" @click="pageToggle(3,scope.row)">操作记录</p>
  57. <el-dropdown @command="moreClick" v-hasPermi="['laboratory:hardware10:edit','laboratory:hardware10:remove']">
  58. <p class="table-min-button">更多>></p>
  59. <el-dropdown-menu slot="dropdown">
  60. <el-dropdown-item style="border-bottom:1px solid #E0E0E0;margin:0 10px;" :command="{row:scope.row,command:1}" v-hasPermi="['laboratory:hardware10:edit']">编辑</el-dropdown-item>
  61. <el-dropdown-item style="margin:0 10px;" :command="{row:scope.row,command:2}" v-hasPermi="['laboratory:hardware10:remove']">删除</el-dropdown-item>
  62. </el-dropdown-menu>
  63. </el-dropdown>
  64. </div>
  65. </template>
  66. </el-table-column>
  67. </el-table>
  68. <div style="display: flex;height:32px;margin:15px 0;">
  69. <!--<p style="flex:4;"></p>-->
  70. <p style="text-align: left;margin:0;line-height:32px;margin-right:20px;font-size:14px;color:#999;">
  71. <i class="el-icon-warning" style="color:#0183FA;"></i>
  72. 已选择 {{selectedNum}} 项
  73. </p>
  74. <div style="flex:5;">
  75. <pagination :page-sizes="[20, 30, 40, 50]"
  76. v-show="total>0"
  77. :total="total"
  78. style="margin:0;"
  79. :page.sync="queryParams.pageNum"
  80. :limit.sync="queryParams.pageSize"
  81. @pagination="getList"
  82. />
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. <!--新增/编辑-->
  88. <el-dialog :title="dialogTitle" :visible.sync="addDialogType" v-if="addDialogType" width="520px" append-to-body class="add-dialog-box">
  89. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  90. <el-form-item label="智能终端编号:" prop="hardwareNum">
  91. <el-input v-model="form.hardwareNum" placeholder="最大20个字符,包含大小写字母、数字" onkeyup="value=value.replace(/[^\w\.\/]/ig,'')" maxlength="30" style="width:360px;"/>
  92. </el-form-item>
  93. <el-form-item label="智能柜锁名称:" prop="name">
  94. <el-input v-model="form.name" placeholder="最大10个字符,包含汉字、大小写字母、数字、符号" maxlength="10" style="width:360px;"/>
  95. </el-form-item>
  96. <el-form-item label="实验室:" prop="subjectId">
  97. <el-select
  98. style="width:360px;"
  99. v-model="form.subjectId"
  100. filterable
  101. remote
  102. clearable
  103. @focus="selectFocus"
  104. reserve-keyword
  105. @clear="clearClick"
  106. placeholder="搜索选择实验室"
  107. :remote-method="getSelectList">
  108. <el-option
  109. v-for="item in selectList"
  110. :key="item.id"
  111. :label="item.name"
  112. :value="item.id">
  113. </el-option>
  114. </el-select>
  115. </el-form-item>
  116. <el-form-item label="锁柜ID:" prop="lockId">
  117. <el-input v-model="form.lockId" placeholder="0-253" maxlength="3" style="width:360px;" onkeyup="value=value.replace(/[^\d]/g,'')"/>
  118. </el-form-item>
  119. <el-form-item label="摄像头ip:" prop="ipAddress">
  120. <el-input v-model="form.ipAddress" placeholder="请输入摄像头ip" maxlength="20" style="width:360px;"/>
  121. </el-form-item>
  122. <el-form-item label="采集器编号:" prop="relayCode">
  123. <el-input v-model="form.relayCode" placeholder="请输入采集器编号" maxlength="20" onkeyup="value=value.replace(/[^\w\.\/]/ig,'')" style="width:360px;"/>
  124. </el-form-item>
  125. </el-form>
  126. <div slot="footer" class="dialog-footer">
  127. <el-button type="primary" @click="submitForm">确 定</el-button>
  128. <el-button @click="cancel">取 消</el-button>
  129. </div>
  130. </el-dialog>
  131. <!--柜锁设置-->
  132. <el-dialog title="柜锁设置" :visible.sync="setUpType" v-if="setUpType" width="520px" append-to-body class="add-dialog-box">
  133. <el-form ref="setUpForm" :model="setUpForm" :rules="rules" label-width="100px">
  134. <el-form-item label="操作时长:" prop="operateTime">
  135. <el-input v-model="setUpForm.operateTime" placeholder="请输入操作时长" min="1" max="999" maxlength="3" style="width:360px;">
  136. <template slot="append">分钟</template>
  137. </el-input>
  138. </el-form-item>
  139. <p style="font-size:14px;line-height:20px;color:#999;">
  140. <i class="el-icon-warning" style="color:#FFA312;font-size:16px;margin-left:100px;"></i>
  141. 设置开锁后操作的最大有效时长
  142. </p>
  143. </el-form>
  144. <div slot="footer" class="dialog-footer">
  145. <el-button type="primary" @click="setUpFormSubmitForm">确 定</el-button>
  146. <el-button @click="setUpFormCancel">取 消</el-button>
  147. </div>
  148. </el-dialog>
  149. <!--操作记录-->
  150. <operation-record v-if="pageType == 3" :operationRecordPropsData="operationRecordPropsData"></operation-record>
  151. </div>
  152. </template>
  153. <script>
  154. import { filterDept,getSubList, delHardware, addHardware, updateHardware,setLock,hardwareList } from "@/api/medicUniversity-3_1/index";
  155. import operationRecord from "./operationRecord.vue"
  156. export default {
  157. name: "smartLock",
  158. props:{
  159. smartLockPropsData:{},
  160. },
  161. components: {
  162. operationRecord
  163. },
  164. data() {
  165. let digitalJudgment = (rule, value, callback) => {
  166. if(value>253||value<0){
  167. return callback(new Error(''));
  168. }else{
  169. callback()
  170. }
  171. }
  172. return {
  173. // table操作按钮校验
  174. tableButtonType:this.hasPermiDom(['chemical:locklog2:list','laboratory:hardware10:edit','laboratory:hardware10:remove']),
  175. pageType:1,
  176. //操作方式
  177. optionsList:[{id:"ONLINE",name:"在线"},{id:"OFFLINE",name:"离线"}],
  178. //表格扩展选择器---需要在@selection-change绑定的方法内监控selection数组长度
  179. selectedNum:0,
  180. // 选中数组
  181. ids: [],
  182. // 非单个禁用
  183. single: true,
  184. // 非多个禁用
  185. multiple: true,
  186. // 搜索数据
  187. queryParamsData:{
  188. pageNum:1,
  189. pageSize:20,
  190. },
  191. // 搜索实际发送数据
  192. queryParams:{
  193. pageNum:1,
  194. pageSize:20,
  195. },
  196. tableList:[],
  197. total:0,
  198. //锁柜设置
  199. setUpType:false,
  200. setUpForm:{},
  201. rules:{
  202. hardwareNum: [
  203. { required: true, trigger: "blur", message: "最大20个字符,包含大小写字母、数字" },
  204. { required: true, message: "最大20个字符,包含大小写字母、数字", validator: this.spaceJudgment, trigger: "blur" }
  205. ],
  206. name: [
  207. { required: true, trigger: "blur", message: "最大10个字符,包含汉字、大小写字母、数字、符号" },
  208. { required: true, message: "最大10个字符,包含汉字、大小写字母、数字、符号", validator: this.spaceJudgment, trigger: "blur" }
  209. ],
  210. subjectId: [
  211. { required: true, trigger: "blur", message: "搜索选择实验室" },
  212. ],
  213. operateTime: [
  214. { required: true, trigger: "blur", message: "请输入操作时长" },
  215. { required: true, message: "请输入操作时长", validator: this.spaceJudgment, trigger: "blur" },
  216. { required: true, message: "只能输入数字", validator: this.isNum, trigger: "blur" },
  217. ],
  218. lockId: [
  219. { required: true, trigger: "blur", message: "请输入0-253之间的数字" },
  220. { required: true, message: "请输入0-253之间的数字", validator: this.spaceJudgment, trigger: "blur" },
  221. { required: true, message: "请输入0-253之间的数字", validator: digitalJudgment, trigger: "blur" }
  222. ],
  223. ipAddress: [
  224. { required: true, trigger: "blur", message: "请输入摄像头ip" },
  225. { required: true, message: "请输入摄像头ip", validator: this.spaceJudgment, trigger: "blur" }
  226. ],
  227. relayCode: [
  228. { required: true, trigger: "blur", message: "请输入采集器编号" },
  229. { required: true, message: "请输入采集器编号", validator: this.spaceJudgment, trigger: "blur" }
  230. ],
  231. },
  232. //操作记录传参
  233. operationRecordPropsData:{},
  234. //编辑新增相关
  235. dialogTitle:"",
  236. addDialogType:false,
  237. form:{},
  238. selectList:[],
  239. selectListData:[],
  240. }
  241. },
  242. created() {
  243. },
  244. mounted(){
  245. this.filterDept();
  246. this.getList();
  247. },
  248. methods:{
  249. selectFocus(){
  250. if(!this.selectList[0]){
  251. this.filterDept();
  252. }
  253. },
  254. getList(){
  255. this.queryParamsData = JSON.parse(JSON.stringify(this.queryParams));
  256. this.queryParamsData.joinCabinet = this.smartLockPropsData.id;
  257. this.queryParamsData.type = "AI_CABINETLOCK";
  258. hardwareList(this.queryParamsData).then(response => {
  259. this.selectedNum = 0;
  260. this.ids = [];
  261. this.tableList = response.rows;
  262. });
  263. },
  264. /** 搜索按钮操作 */
  265. handleQuery() {
  266. this.queryParamsData.pageNum = 1;
  267. this.queryParamsData.pageSize = 20;
  268. this.queryParams = JSON.parse(JSON.stringify(this.queryParamsData));
  269. this.getList();
  270. },
  271. /** 重置按钮操作 */
  272. resetQuery() {
  273. this.$set(this,'queryParamsData',{});
  274. this.$set(this,'queryParams',{});
  275. this.handleQuery();
  276. },
  277. //更多按钮
  278. moreClick(data){
  279. let self = this;
  280. if(data.command == 1){
  281. this.pageToggle(1,data.row);
  282. }else if(data.command == 2){
  283. this.pageToggle(2,data.row);
  284. }
  285. },
  286. pageToggle(type,item){
  287. let self = this;
  288. if(type == 0){
  289. this.pageType = 1;
  290. this.getList();
  291. }else if(type == 1){
  292. // 编辑
  293. this.dialogTitle = '编辑';
  294. let obj = {
  295. id:item.id,
  296. subjectId:item.subjectId,
  297. name:item.name,
  298. hardwareNum:item.hardwareNum,
  299. lockId:item.lockId,
  300. ipAddress:item.ipAddress,
  301. relayCode:item.relayCode,
  302. };
  303. this.$set(this,'form',obj);
  304. this.clearClick();
  305. this.addDialogType = true;
  306. }else if(type == 2){
  307. // 删除
  308. if(item.joinCabinetId){
  309. this.msgError('已关联化学品柜,无法删除')
  310. return
  311. }
  312. this.$confirm('确认要删除吗?', "警告", {
  313. confirmButtonText: "确定",
  314. cancelButtonText: "取消",
  315. type: "warning"
  316. }).then(function() {
  317. delHardware(item.id).then(response => {
  318. if (response.code == 200){
  319. self.msgSuccess(response.msg);
  320. self.getList();
  321. }
  322. });
  323. }).then(() => {
  324. }).catch(() => {});
  325. }else if (type == 3){
  326. //操作记录
  327. this.operationRecordPropsData = item;
  328. this.pageType = 3;
  329. }else if (type == 4){
  330. //锁柜设置
  331. if(self.ids.length>0) {
  332. this.setUpForm = {
  333. operateTime:"",
  334. }
  335. this.setUpType = true;
  336. }else{
  337. this.msgError('请选择要设置的锁柜')
  338. }
  339. }
  340. },
  341. //查询当前院系
  342. filterDept(){
  343. filterDept().then(response => {
  344. let idText = "";
  345. for(let i=0;i<response.data.length;i++){
  346. if(i==0){
  347. idText = idText + response.data[i].deptId;
  348. }else{
  349. idText = idText +','+ response.data[i].deptId;
  350. }
  351. }
  352. //查询院系下实验室
  353. getSubList(idText).then(response => {
  354. //当前列表
  355. this.selectList = JSON.parse(JSON.stringify(response.data));
  356. //原始列表数据
  357. this.selectListData = JSON.parse(JSON.stringify(response.data));
  358. });
  359. });
  360. },
  361. /** 实验室-本地懒加载 */
  362. getSelectList(val) {
  363. let self = this;
  364. let list = [];
  365. for(let i=0;i<self.selectListData.length;i++){
  366. if(self.selectListData[i].name.indexOf(val) != -1){
  367. list.push(self.selectListData[i]);
  368. }
  369. }
  370. this.selectList = JSON.parse(JSON.stringify(list))
  371. },
  372. //实验室选中清除
  373. clearClick(){
  374. this.selectList = JSON.parse(JSON.stringify(this.selectListData))
  375. },
  376. submitForm(){
  377. this.$refs["form"].validate((valid) => {
  378. if (valid) {
  379. if(this.form.id){
  380. //编辑
  381. this.form.type = "AI_CABINETLOCK";
  382. updateHardware(this.form).then(response => {
  383. if (response.code == 200){
  384. this.addDialogType = false;
  385. this.msgSuccess(response.msg);
  386. this.getList();
  387. }
  388. });
  389. }else{
  390. //新增
  391. this.form.type = "AI_CABINETLOCK";
  392. addHardware(this.form).then(response => {
  393. if (response.code == 200){
  394. this.addDialogType = false;
  395. this.msgSuccess(response.msg);
  396. this.resetQuery();
  397. }
  398. });
  399. }
  400. }
  401. })
  402. },
  403. cancel(){
  404. this.addDialogType = false;
  405. },
  406. //柜锁设置
  407. setUpFormSubmitForm(){
  408. this.$refs["setUpForm"].validate((valid) => {
  409. if (valid) {
  410. let obj = {
  411. ids:this.ids,
  412. operateTime:parseInt(this.setUpForm.operateTime),
  413. }
  414. setLock(obj).then(response => {
  415. if(response.code == 200){
  416. this.setUpType = false;
  417. this.msgSuccess(response.msg);
  418. this.getList();
  419. }
  420. });
  421. }
  422. })
  423. },
  424. setUpFormCancel(){
  425. this.setUpType = false;
  426. },
  427. backPage(){
  428. this.$parent.pageToggle(1);
  429. },
  430. // 多选框选中数据
  431. handleSelectionChange(selection) {
  432. this.selectedNum = selection.length;
  433. this.ids = selection.map(item => item.id);
  434. this.single = selection.length != 1;
  435. this.multiple = !selection.length;
  436. },
  437. /*===记录勾选数据===
  438. 需要再el-table 添加 :row-key="getRowKeys"
  439. 需要在selection 添加 :reserve-selection="true"
  440. */
  441. getRowKeys(row) {
  442. return row.id
  443. },
  444. }
  445. }
  446. </script>
  447. <style scoped lang="scss">
  448. .smartLock{
  449. flex: 1;
  450. display: flex;
  451. flex-direction: column;
  452. overflow: hidden;
  453. p{
  454. margin:0;
  455. }
  456. .button-box{
  457. display: flex;
  458. }
  459. .smartLock-min-page{
  460. flex: 1;
  461. display: flex;
  462. flex-direction: column;
  463. overflow: hidden;
  464. .title-box{
  465. display: flex;
  466. height:90px;
  467. border-bottom: 1px solid #D8D8D8;
  468. p:nth-child(1){
  469. flex:1;
  470. font-size:16px;
  471. line-height:90px;
  472. margin-left:18px;
  473. color:#0045AF;
  474. }
  475. p:nth-child(2){
  476. margin:25px 25px 0 0;
  477. }
  478. }
  479. .smartLock-min-page-min{
  480. flex: 1;
  481. display: flex;
  482. flex-direction: column;
  483. overflow: hidden;
  484. padding:20px;
  485. }
  486. }
  487. }
  488. </style>