index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. <!--智能门禁-->
  2. <template>
  3. <div class="app-container SmartAccessControl">
  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. />
  14. </el-form-item>
  15. <el-form-item label="学院" prop="deptId">
  16. <el-select v-model="queryParamsData.deptId" clearable placeholder="请选择学院">
  17. <el-option
  18. v-for="item in optionsListOne"
  19. :key="item.deptId"
  20. :label="item.deptName"
  21. :value="item.deptId">
  22. </el-option>
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item label="状态" prop="useStatus">
  26. <el-select v-model="queryParamsData.operate" clearable placeholder="请选择状态">
  27. <el-option
  28. v-for="item in optionsListTwo"
  29. :key="item.id"
  30. :label="item.name"
  31. :value="item.id">
  32. </el-option>
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item>
  36. <p class="inquire-button-one" @click="handleQuery" style="margin-right:10px;">查询</p>
  37. <p class="reset-button-one" @click="resetQuery">重置</p>
  38. </el-form-item>
  39. <el-form-item style="float: right;">
  40. <el-col :span="1.5" v-hasPermi="['laboratory:hardware6:add']">
  41. <p class="add-button-one-90"
  42. @click="pageToggle(1)"
  43. ><i class="el-icon-plus"></i>新增</p>
  44. </el-col>
  45. </el-form-item>
  46. <el-form-item style="float: right;">
  47. <el-dropdown @command="importButton" v-hasPermi="['laboratory:hardware6:import']">
  48. <div class="form-dropdown-box">
  49. <img src="@/assets/ZDimages/personnelManagement/icon_jzgxx_dr.png">
  50. <p>导入</p>
  51. <img src="@/assets/ZDimages/personnelManagement/icon_jzggl_xljt.png">
  52. </div>
  53. <el-dropdown-menu slot="dropdown">
  54. <el-dropdown-item style="border-bottom:1px solid #E0E0E0;margin:0 10px;color:#333;" :command="{command:1}">下载模板</el-dropdown-item>
  55. <el-dropdown-item style="margin:0 10px;color:#666;" :command="{command:2}">导入数据</el-dropdown-item>
  56. </el-dropdown-menu>
  57. </el-dropdown>
  58. </el-form-item>
  59. </el-form>
  60. <el-table border :data="tableList" ref="multipleTable">
  61. <el-table-column label="门禁锁编号" align="center" prop="hardwareNum"/>
  62. <el-table-column label="学院" align="center" prop="deptName" width="250"/>
  63. <el-table-column label="位置" align="center" prop="posi" width="250" show-overflow-tooltip/>
  64. <el-table-column label="设备状态" align="center" prop="status" width="100">
  65. <template slot-scope="scope">{{scope.row.operate.name}}</template>
  66. </el-table-column>
  67. <el-table-column label="创建时间" align="center" prop="createTime" width="250"/>
  68. <el-table-column label="创建人" align="center" prop="createBy" width="150"/>
  69. <el-table-column label="操作" align="center" width="140" class-name="small-padding fixed-width" v-if="tableButtonType">
  70. <template slot-scope="scope">
  71. <div class="button-box">
  72. <p class="table-min-button" style="margin-right:10px;" v-hasPermi="['laboratory:hardware6:edit']" @click="pageToggle(2,scope.row)">编辑</p>
  73. <p class="table-min-button" v-hasPermi="['laboratory:hardware6:remove']" @click="pageToggle(3,scope.row)">删除</p>
  74. </div>
  75. </template>
  76. </el-table-column>
  77. </el-table>
  78. <pagination :page-sizes="[20, 30, 40, 50]"
  79. v-show="total>0"
  80. :total="total"
  81. :page.sync="queryParams.pageNum"
  82. :limit.sync="queryParams.pageSize"
  83. @pagination="getList"
  84. />
  85. <!--导入窗口-->
  86. <el-dialog title="导入数据" :visible.sync="importOpen" @close="importOpenOff" width="600px" append-to-body class="import-dialog-box">
  87. <div class="el-upload__text" style="margin:0 0 20px 58px;">提示:导入后的数据将覆盖原有数据</div>
  88. <el-upload
  89. class="import-dialog-upLoad-box"
  90. :drag="true"
  91. :data="upImportData"
  92. :action="uploadImgUrl"
  93. :show-file-list="false"
  94. :on-success="handleAvatarSuccess"
  95. :headers="headers"
  96. :before-upload="beforeAvatarUpload">
  97. <i class="el-icon-upload"></i>
  98. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  99. <!--<div class="el-upload__tip" slot="tip">-->
  100. <!--<el-checkbox v-model="upImportData.upDate">是否更新已经存在的数据</el-checkbox>-->
  101. <!--</div>-->
  102. <div class="el-upload__tip" slot="tip">数据导入模板.xlsx<span style="color:#0183FA;cursor: pointer" @click="importTemplate">下载</span></div>
  103. <div class="el-upload-text-box" slot="tip" v-if="getImportData.downFile">
  104. <div class="img-text-box">
  105. <img src="@/assets/ZDimages/personnelManagement/icon_dr_wj.png">
  106. <p>{{getImportData.textName}}</p>
  107. </div>
  108. <p class="text-p">数据导入成功 <span style="color:#0183FA;">{{getImportData.successNum}}</span> 条,失败 <span style="color:#FF6464 ;">{{getImportData.failureNum}}</span> 条</p>
  109. <div class="img-text-box">
  110. <img src="@/assets/ZDimages/personnelManagement/icon_dr_sj.png">
  111. <p style="color:#0183FA;cursor: pointer;" @click="failureExcel">点击下载失败数据报表</p>
  112. </div>
  113. </div>
  114. </el-upload>
  115. <div slot="footer" class="teacher-import-dialog-button-box">
  116. <p class="inquire-button-one" @click="importOpenOff">确定</p>
  117. </div>
  118. <div class="teacher-import-dialog-position-box" v-if="loading"></div>
  119. </el-dialog>
  120. <!--新增/编辑-->
  121. <el-dialog :title="dialogTitle" :visible.sync="addDialogType" v-if="addDialogType" width="520px" append-to-body class="add-dialog-box">
  122. <el-form ref="form" :model="form" :rules="rules" label-width="110px">
  123. <el-form-item label="门禁锁编号:" prop="hardwareNum">
  124. <el-input v-model="form.hardwareNum" placeholder="最大20个字符,包含大小写字母、数字" onkeyup="value=value.replace(/[^\w\.\/]/ig,'')" maxlength="30" style="width:360px;"/>
  125. </el-form-item>
  126. <el-form-item label="实验室:" prop="subjectId">
  127. <el-select
  128. style="width:360px;"
  129. v-model="form.subjectId"
  130. filterable
  131. remote
  132. clearable
  133. @focus="selectFocus"
  134. reserve-keyword
  135. @clear="clearClick"
  136. placeholder="搜索选择实验室"
  137. :remote-method="getSelectList"
  138. :loading="loading">
  139. <el-option
  140. v-for="item in selectList"
  141. :key="item.id"
  142. :label="item.name"
  143. :value="item.id">
  144. </el-option>
  145. </el-select>
  146. </el-form-item>
  147. </el-form>
  148. <div slot="footer" class="dialog-footer">
  149. <el-button type="primary" @click="submitForm">确 定</el-button>
  150. <el-button @click="cancel">取 消</el-button>
  151. </div>
  152. </el-dialog>
  153. </div>
  154. </template>
  155. <script>
  156. import { hxpSmartTerminal,filterDept,getSubList,addHxpSmartTerminal,putHxpSmartTerminal,getHxpSmartTerminal,delHxpSmartTerminal } from "@/api/medicUniversity-3_1/index";
  157. import { listHardware, delHardware, addHardware, updateHardware } from "@/api/medicUniversity-3_1/index";
  158. import { listDepartments } from "@/api/system/dept";
  159. import { getToken } from "@/utils/auth";
  160. export default {
  161. name: "SmartAccessControl",
  162. data() {
  163. return {
  164. // table操作按钮校验
  165. tableButtonType:this.hasPermiDom(['laboratory:hardware6:edit','laboratory:hardware6:remove']),
  166. //上传相关配置
  167. uploadImgUrl: window.location.href.split('://')[0]+'://' + process.env.VUE_APP_BASE_API + "/laboratory/hardware/importData", // 上传地址
  168. headers: {
  169. Authorization: "Bearer " + getToken(),
  170. },
  171. // 遮罩层
  172. loading:false,
  173. //页面状态
  174. pageType:1,
  175. // 搜索数据
  176. queryParamsData:{
  177. pageNum:1,
  178. pageSize:20,
  179. },
  180. // 搜索实际发送数据
  181. queryParams:{
  182. pageNum:1,
  183. pageSize:20,
  184. },
  185. //数据数量
  186. total:0,
  187. //数据数组
  188. tableList:[],
  189. //学院列表
  190. optionsListOne:[],
  191. //状态列表
  192. optionsListTwo:[{id:"ONLINE",name:"在线"},{id:"OFFLINE",name:"离线"}],
  193. //导入弹层开关
  194. importOpen:false,
  195. //导入数据
  196. upImportData:{
  197. sysUserEnable:true,
  198. upDate:false,
  199. terminalType:'AI_DOORLOCK',
  200. },
  201. getImportData:{
  202. downFile:false,
  203. successNum:0,
  204. failureNum:0,
  205. textName:"",
  206. },
  207. //编辑新增相关
  208. dialogTitle:"",
  209. addDialogType:false,
  210. form:{},
  211. selectList:[],
  212. selectListData:[],
  213. rules:{
  214. hardwareNum: [
  215. { required: true, trigger: "blur", message: "最大20个字符,包含大小写字母、数字" },
  216. { required: true, message: "最大20个字符,包含大小写字母、数字", validator: this.spaceJudgment, trigger: "blur" }
  217. ],
  218. subjectId: [
  219. { required: true, trigger: "blur", message: "搜索选择实验室" },
  220. ],
  221. },
  222. };
  223. },
  224. created() {
  225. },
  226. mounted(){
  227. this.filterDept();
  228. this.listDepartments();
  229. this.getList();
  230. },
  231. methods: {
  232. selectFocus(){
  233. if(!this.selectList[0]){
  234. this.filterDept();
  235. }
  236. },
  237. //获取学院列表
  238. listDepartments(){
  239. listDepartments().then(response => {
  240. this.optionsListOne = response.data;
  241. });
  242. },
  243. pageToggle(type,item){
  244. let self = this;
  245. if(type == 1){
  246. //新增
  247. this.dialogTitle = '新增';
  248. this.$set(this,'form',{
  249. hardwareNum:"",
  250. subjectId:""
  251. });
  252. this.clearClick();
  253. this.addDialogType = true;
  254. }else if(type == 2){
  255. // 编辑
  256. this.dialogTitle = '编辑';
  257. let obj = {
  258. id:item.id,
  259. subjectId:item.subjectId,
  260. hardwareNum:item.hardwareNum,
  261. };
  262. this.$set(this,'form',obj);
  263. this.clearClick();
  264. this.addDialogType = true;
  265. }else if(type == 3){
  266. // 删除
  267. this.$confirm('确认要删除吗?', "警告", {
  268. confirmButtonText: "确定",
  269. cancelButtonText: "取消",
  270. type: "warning"
  271. }).then(function() {
  272. delHardware(item.id).then(response => {
  273. if (response.code == 200){
  274. self.msgSuccess(response.msg);
  275. self.getList();
  276. }
  277. });
  278. }).then(() => {
  279. }).catch(() => {});
  280. }
  281. },
  282. //查询当前院系
  283. filterDept(){
  284. filterDept().then(response => {
  285. let idText = "";
  286. for(let i=0;i<response.data.length;i++){
  287. if(i==0){
  288. idText = idText + response.data[i].deptId;
  289. }else{
  290. idText = idText +','+ response.data[i].deptId;
  291. }
  292. }
  293. //查询院系下实验室
  294. getSubList(idText).then(response => {
  295. //当前列表
  296. this.selectList = JSON.parse(JSON.stringify(response.data));
  297. //原始列表数据
  298. this.selectListData = JSON.parse(JSON.stringify(response.data));
  299. });
  300. });
  301. },
  302. /** 实验室-本地懒加载 */
  303. getSelectList(val) {
  304. let self = this;
  305. let list = [];
  306. for(let i=0;i<self.selectListData.length;i++){
  307. if(self.selectListData[i].name.indexOf(val) != -1){
  308. list.push(self.selectListData[i]);
  309. }
  310. }
  311. this.selectList = JSON.parse(JSON.stringify(list))
  312. },
  313. //实验室选中清除
  314. clearClick(){
  315. this.selectList = JSON.parse(JSON.stringify(this.selectListData))
  316. },
  317. submitForm(){
  318. this.$refs["form"].validate((valid) => {
  319. if (valid) {
  320. if(this.form.id){
  321. //编辑
  322. this.form.type = "AI_DOORLOCK";
  323. updateHardware(this.form).then(response => {
  324. if (response.code == 200){
  325. this.addDialogType = false;
  326. this.msgSuccess(response.msg);
  327. this.getList();
  328. }
  329. });
  330. }else{
  331. //新增
  332. this.form.type = "AI_DOORLOCK";
  333. addHardware(this.form).then(response => {
  334. if (response.code == 200){
  335. this.addDialogType = false;
  336. this.msgSuccess(response.msg);
  337. this.resetQuery();
  338. }
  339. });
  340. }
  341. }
  342. })
  343. },
  344. cancel(){
  345. this.addDialogType = false;
  346. },
  347. //获取数据列表
  348. getList(){
  349. this.queryParamsData = JSON.parse(JSON.stringify(this.queryParams));
  350. this.queryParamsData.type = 'AI_DOORLOCK';
  351. listHardware(this.queryParamsData).then(response => {
  352. this.total = response.total;
  353. this.tableList = response.rows;
  354. });
  355. },
  356. /** 搜索按钮操作 */
  357. handleQuery() {
  358. this.queryParamsData.pageNum = 1;
  359. this.queryParamsData.pageSize = 20;
  360. this.queryParams = JSON.parse(JSON.stringify(this.queryParamsData));
  361. this.getList();
  362. },
  363. /** 重置按钮操作 */
  364. resetQuery() {
  365. this.$set(this,'queryParamsData',{});
  366. this.$set(this,'queryParams',{});
  367. this.handleQuery();
  368. },
  369. //导入页面关闭
  370. importOpenOff(){
  371. this.importOpen = false;
  372. this.getImportData.downFile = false;
  373. this.getImportData.successNum = 0;
  374. this.getImportData.failureNum = 0;
  375. this.getImportData.textName = "";
  376. },
  377. /** 导入按钮操作 */
  378. importButton(item){
  379. if(item.command == 1){
  380. // 下载模板
  381. this.download('/laboratory/hardware/importTemplate', {}, `导入模板.xlsx`)
  382. }else if(item.command == 2){
  383. // 导入数据
  384. console.log('导入数据');
  385. this.importOpen = true;
  386. }
  387. },
  388. /** 下载模板操作 */
  389. importTemplate() {
  390. this.download('/laboratory/hardware/importTemplate', {}, `导入模板.xlsx`)
  391. },
  392. /*下载失败列表*/
  393. failureExcel(){
  394. this.download('/laboratory/hardware/importErrorData', {}, `失败报表.xlsx`)
  395. },
  396. //****************************************导入功能**************************************
  397. handleAvatarSuccess(res, file) {
  398. if(res.code == 200){
  399. if(res.data.downFile){
  400. this.getImportData.downFile = res.data.downFile
  401. this.getImportData.successNum = res.data.successNum
  402. this.getImportData.failureNum = res.data.failureNum
  403. }else{
  404. this.msgSuccess(res.msg);
  405. this.importOpen = false;
  406. this.resetQuery();
  407. }
  408. // this.getImportData.downFile = res.data.downFile
  409. // this.getImportData.successNum = res.data.successNum
  410. // this.getImportData.failureNum = res.data.failureNum
  411. // this.importOpen = false;
  412. // this.getList();
  413. }else{
  414. this.msgError(res.msg);
  415. }
  416. this.loading = false;
  417. },
  418. beforeAvatarUpload(file) {
  419. let type = false;
  420. console.log('file',file);
  421. if (file.type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.type == 'application/vnd.ms-excel') {
  422. this.getImportData.textName = file.name;
  423. type = true;
  424. this.loading = true;
  425. }else{
  426. this.msgError('只能上传xls/xlsx格式文件')
  427. type = false;
  428. }
  429. return type;
  430. },
  431. },
  432. }
  433. </script>
  434. <style scoped lang="scss">
  435. .SmartAccessControl{
  436. flex:1;
  437. display: flex;
  438. flex-direction: column;
  439. overflow: hidden!important;
  440. padding:20px !important;
  441. p{
  442. margin:0;
  443. padding:0;
  444. }
  445. .form-box{
  446. .form-dropdown-box{
  447. display: flex;
  448. margin:0;
  449. padding:0 10px;
  450. cursor: pointer;
  451. height:40px;
  452. img:nth-child(1){
  453. width:16px;
  454. height:16px;
  455. margin-top:12px;
  456. }
  457. p{
  458. width:47px;
  459. text-align: center;
  460. font-size:14px;
  461. margin:0;
  462. line-height:40px;
  463. }
  464. img:nth-child(3){
  465. width:10px;
  466. height:6px;
  467. margin-top:17px;
  468. }
  469. }
  470. }
  471. .button-box{
  472. display: flex;
  473. }
  474. }
  475. </style>
  476. <style lang="scss">
  477. .import-dialog-box{
  478. .import-dialog-upLoad-box{
  479. .el-upload{
  480. width:450px;
  481. margin:0 55px;
  482. .el-upload-dragger{
  483. width:450px;
  484. .el-icon-upload{
  485. font-size:100px;
  486. color:#CBE6FE;
  487. }
  488. .el-upload__text{
  489. margin-top:20px;
  490. }
  491. }
  492. }
  493. .el-upload__tip{
  494. margin-left:60px;
  495. font-size:14px;
  496. margin-top:10px;
  497. }
  498. .el-upload-text-box{
  499. background: #F5F5F5;
  500. border-radius: 10px;
  501. margin:15px 30px 0;
  502. padding:0 20px 15px;
  503. overflow: hidden;
  504. *{
  505. margin:0;
  506. }
  507. .img-text-box{
  508. display: flex;
  509. margin-top:15px;
  510. img{
  511. width:16px;
  512. height:16px;
  513. margin-right:13px;
  514. }
  515. p{
  516. height:16px;
  517. line-height:16px;
  518. font-size:12px;
  519. }
  520. }
  521. .text-p{
  522. margin-top:15px;
  523. margin-left:29px;
  524. height:16px;
  525. line-height:16px;
  526. font-size:12px;
  527. }
  528. }
  529. }
  530. .teacher-import-dialog-button-box{
  531. display: flex;
  532. width:190px;
  533. margin:0 auto;
  534. p{
  535. width:70px;
  536. height:30px;
  537. line-height:30px;
  538. font-size:14px;
  539. margin:0 auto;
  540. }
  541. }
  542. .teacher-import-dialog-position-box{
  543. width:100%;
  544. height:100%;
  545. position: absolute;
  546. top:0;
  547. left:0;
  548. z-index: 999;
  549. background: rgba(255,255,255,0.4);
  550. border-radius:20px;
  551. }
  552. }
  553. </style>