index.vue 30 KB

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