smartLock.vue 19 KB

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