lookImpower.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. <!--供应商管理-->
  2. <template>
  3. <div class="supplier">
  4. <div class="supplier-title">
  5. <P>实验室名称-已授权列表 </P>
  6. <p class="button-p reset-button-one" @click="backPage">返回</p>
  7. </div>
  8. <div class="supplier-page">
  9. <el-form :model="queryParams" ref="queryForm" style="margin-top:20px;" :inline="true" label-width="120">
  10. <el-form-item label="关键字" prop="name">
  11. <el-input
  12. v-model="queryParams.searchValue"
  13. placeholder="请输入姓名/工号/学号"
  14. clearable
  15. maxLength="30"
  16. size="small"
  17. />
  18. </el-form-item>
  19. <el-form-item label="类别" prop="zgType" label-width="80px">
  20. <el-select v-model="queryParams.userType" placeholder="请选择" clearable size="small">
  21. <el-option label="学生" value="22" />
  22. <el-option label="教师" value="11" />
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item label="授权时间段" prop="dateRange" style="margin-left:10px;">
  26. <el-date-picker
  27. :clearable="false"
  28. v-model="dateRange"
  29. size="small"
  30. style="width: 240px"
  31. value-format="yyyy-MM-dd HH:mm:ss"
  32. type="daterange"
  33. range-separator="-"
  34. start-placeholder="开始日期"
  35. end-placeholder="结束日期"
  36. ></el-date-picker>
  37. </el-form-item>
  38. <el-form-item>
  39. <p class="inquire-button-one" @click="handleQuery">查询</p>
  40. <p class="reset-button-one" @click="resetQuery">重置</p>
  41. </el-form-item>
  42. <el-form-item label="" prop="title" style="float: right">
  43. <p class="inquire-button-one"
  44. style="width: 120px;margin-left: 10px;"
  45. v-if="!admittance"
  46. @click="handleClick('','','addStudent')"
  47. ><i class="el-icon-plus"></i>新增学生授权</p>
  48. <p class="inquire-button-one"
  49. style="width: 120px;margin-left: 10px;"
  50. v-if="!whiteList"
  51. @click="handleClick('','','addTeacher')"
  52. ><i class="el-icon-plus"></i>新增教职工授权</p>
  53. </el-form-item>
  54. </el-form>
  55. <el-table border v-loading="loading" :data="tableData">
  56. <el-table-column label="所属单位" align="left" prop="deptName"/>
  57. <el-table-column label="姓名" align="left" prop="nickName"></el-table-column>
  58. <el-table-column label="验证方式" align="left" prop="verifyMode"></el-table-column>
  59. <el-table-column label="类别" align="left" prop="userType"></el-table-column>
  60. <el-table-column label="授权时间" align="left" prop="verifyTime"></el-table-column>
  61. <el-table-column label="授权人" align="left" prop="verifyUser"></el-table-column>
  62. <el-table-column label="失效时间" align="left" prop="invalidTime" width="250">
  63. <template slot-scope="scope">
  64. <el-date-picker
  65. :disabled="(scope.row.userType=='学生' && admittance) || (scope.row.userType=='教师' && whiteList)"
  66. :picker-options="pickerOptions0"
  67. v-model="scope.row.invalidTime"
  68. value-format="yyyy-MM-dd"
  69. type="date"
  70. placeholder="请选择失效时间">
  71. </el-date-picker>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="120">
  75. <template slot-scope="scope">
  76. <div class="button-box">
  77. <p class="table-min-button"
  78. v-if="(scope.row.userType=='学生' && !admittance) || (scope.row.userType=='教师' && !whiteList)"
  79. @click="handleClick('',scope.row,'delete')"
  80. >删除</p>
  81. <p class="table-min-button" v-if="scope.row.userType=='学生' && admittance">安全准入</p>
  82. <p class="table-min-button" v-if="scope.row.userType=='教师' && whiteList">白名单</p>
  83. </div>
  84. </template>
  85. </el-table-column>
  86. </el-table>
  87. <div style="display: flex;height:32px;margin-top:15px;">
  88. <div style="flex:5;">
  89. <pagination :page-sizes="[20, 30, 40, 50]"
  90. v-show="total>0"
  91. :total="total"
  92. style="margin:0;"
  93. :page.sync="queryParams.pageNum"
  94. :limit.sync="queryParams.pageSize"
  95. @pagination="getList"
  96. />
  97. </div>
  98. </div>
  99. <div style="text-align: center;">
  100. <el-button class="color_ff back_one" style="width: 300px;" @click="loseTimeSubmitForm()">确定</el-button>
  101. </div>
  102. </div>
  103. <!--关联实验室弹框-->
  104. <el-dialog :title=dialogTitle @close="handleClose" :visible.sync="dialogVisible" width="80%">
  105. <el-form :model="dialogForm" ref="dialogForm" :inline="true" label-width="140px">
  106. <el-form-item label="关键字" prop="name" >
  107. <el-input
  108. v-model="dialogForm.searchValue"
  109. placeholder="请输入名称/联系方式"
  110. clearable
  111. size="small"
  112. />
  113. </el-form-item>
  114. <el-form-item label="所属单位" prop="deptId" label-width="80px">
  115. <el-select v-model="dialogForm.deptId" clearable placeholder="请选择学院">
  116. <el-option
  117. v-for="item in collegeOptions"
  118. :key="item.deptId"
  119. :label="item.deptName"
  120. :value="item.deptId">
  121. </el-option>
  122. </el-select>
  123. </el-form-item>
  124. <el-form-item>
  125. <p class="inquire-button-one" style="margin-left:20px;" @click="onSearch">查询</p>
  126. <p class="reset-button-one" style="margin-left:20px;" @click="resetForm">重置</p>
  127. </el-form-item>
  128. </el-form>
  129. <div class="btn_list">
  130. <i class="el-icon-warning"></i>
  131. <i>已选择 {{labWhiteJoinSubList.length}} 项目</i>
  132. <i @click="toggleSelection(dialogTable)">全选本页</i>
  133. <i></i>
  134. <i @click="toggleSelection()">清除选项</i>
  135. </div>
  136. <el-table ref="multipleTable" border tooltip-effect="dark" :row-key="getRowKeys" :data="dialogTable"
  137. highlight-current-row @selection-change="handleSelectionChange" style="cursor: pointer;height:500px;">
  138. <el-table-column type="selection" width="55" :reserve-selection="true" align="center"></el-table-column>
  139. <el-table-column label="所属单位" align="left" prop="deptName"/>
  140. <el-table-column label="姓名" align="left" prop="nickName" />
  141. <el-table-column label="导师" align="left" prop="tutorUserName" v-if="userType==1"/>
  142. <el-table-column label="专业" align="left" prop="major" v-if="userType==1"/>
  143. <el-table-column label="身份" align="left" prop="positionName" v-if="userType==2"/>
  144. <el-table-column label="验证方式" align="left" prop="verifyMode">
  145. <template slot-scope="scope">
  146. <el-select v-model="scope.row.verifyMode" @change="verifyModeFun()" clearable >
  147. <el-option
  148. v-for="item in verifyWayList"
  149. :key="item.key"
  150. :label="item.value"
  151. :value="item.key">
  152. </el-option>
  153. </el-select>
  154. </template>
  155. </el-table-column>
  156. <el-table-column label="失效时间" align="left" prop="invalidTime">
  157. <template slot-scope="scope">
  158. <el-date-picker
  159. @blur="invalidTimeFun(scope.row,$event)"
  160. :picker-options="pickerOptions0"
  161. v-model="scope.row.invalidTime"
  162. value-format="yyyy-MM-dd"
  163. type="date"
  164. placeholder="请选择失效时间">
  165. </el-date-picker>
  166. </template>
  167. </el-table-column>
  168. </el-table>
  169. <pagination :page-sizes="[20, 30, 40, 50]"
  170. v-show="total>0"
  171. :total="total"
  172. :page.sync="dialogForm.pageNum"
  173. :limit.sync="dialogForm.pageSize"
  174. @pagination="getUserList"
  175. />
  176. <div class="configuration">
  177. <el-form :model="configuration" ref="queryForm" :inline="true" v-if="unifyDeploy">
  178. <el-form-item label="验证方式:" prop="name">
  179. <el-select v-model="configuration.verifyMode" clearable >
  180. <el-option
  181. v-for="item in verifyWayList"
  182. :key="item.key"
  183. :label="item.value"
  184. :value="item.key">
  185. </el-option>
  186. </el-select>
  187. </el-form-item>
  188. <el-form-item label="失效时间:" prop="name">
  189. <el-date-picker
  190. :picker-options="pickerOptions0"
  191. v-model="configuration.invalidTime"
  192. value-format="yyyy-MM-dd"
  193. type="date"
  194. placeholder="请选择失效时间">
  195. </el-date-picker>
  196. </el-form-item>
  197. </el-form>
  198. <p :class="unifyDeploy?'add-button-one-120':'inquire-button-one'" @click="unifyDeployFun()">{{unifyDeploy?'取消统一配置':'统一配置'}}</p>
  199. <el-button class="color_ff back_one" @click="submitForm()">确定</el-button>
  200. </div>
  201. </el-dialog>
  202. </div>
  203. </template>
  204. <script>
  205. import { listStudentUser, listTeacherUser } from '@/api/system/user_student'
  206. import { listDepartments } from '@/api/system/dept'
  207. import {
  208. AddImpowerHaikang,
  209. delUserHaikang,
  210. editImpowerHaikang,
  211. getHaikangQueryTypes,
  212. getHaikangUserList
  213. } from '@/api/laboratory/subject'
  214. export default {
  215. name: "Approval",
  216. components: {
  217. },
  218. props:{
  219. pageData:{},
  220. },
  221. data() {
  222. return {
  223. loading:false,
  224. // 查询参数
  225. queryParams: {
  226. pageNum: 1,
  227. pageSize:20,
  228. searchValue:'',
  229. userType:'',
  230. hardId:'',
  231. startTime:'',
  232. endTime:'',
  233. },
  234. total:0,
  235. tableData:[],
  236. oldTableData:[],
  237. dateRange:[],
  238. dialogForm:{
  239. pageNum: 1,
  240. pageSize: 20,
  241. searchValue:'',
  242. deptId:'',
  243. },
  244. dialogTitle:'选择学生',
  245. dialogVisible:false,
  246. collegeOptions:[],//学院
  247. labWhiteJoinSubList:[],
  248. dialogTable:[],
  249. radioList:[],
  250. userType:1,//判断是学生 1 教职工2
  251. verifyWayList:[],
  252. configuration:{
  253. invalidTime:'',
  254. verifyMode:'',
  255. },
  256. unifyDeploy:false,
  257. //提交
  258. form:{},
  259. // 设置只能选择当前日期及之后的日期
  260. pickerOptions0: {
  261. disabledDate(time) {
  262. return time.getTime() < Date.now();//如果没有后面的-8.64e7就是不可以选择今天的
  263. }
  264. },
  265. admittance:false,//智能门禁有没有勾选安全准入
  266. whiteList:false,//智能门禁有没有勾选白名单
  267. };
  268. },
  269. methods: {
  270. //弹出层表格里验证方式改变重新赋值
  271. verifyModeFun(){
  272. //通过改变数组数据刷新视图
  273. this.dialogTable.pop()
  274. },
  275. //弹出层表格里失效时间改变重新赋值
  276. invalidTimeFun(item,e){
  277. this.dialogTable.splice(1,0);
  278. },
  279. //获取当前日期
  280. getdate() {
  281. const dates = new Date()
  282. dates.setMonth(dates.getMonth() + 1)
  283. var pastMonth = dates.getMonth() + 1
  284. var pastDay = dates.getDate()
  285. if (pastMonth >= 1 && pastMonth <= 9) {
  286. pastMonth = '0' + pastMonth
  287. }
  288. if (pastDay >= 0 && pastDay <= 9) {
  289. pastDay = '0' + pastDay
  290. }
  291. const endDate = dates.getFullYear() + '-' + pastMonth + '-' + pastDay
  292. return endDate
  293. },
  294. //查询
  295. onSearch() {
  296. this.dialogForm.pageNo = 1;
  297. this.getUserList();
  298. },
  299. //重置
  300. resetForm() {
  301. this.dialogForm.searchValue = '';
  302. this.dialogForm.deptId = '';
  303. this.onSearch();
  304. },
  305. //统一配置
  306. unifyDeployFun(){
  307. this.unifyDeploy=!this.unifyDeploy
  308. if(this.unifyDeploy==false){
  309. this.configuration.invalidTime='';
  310. this.configuration.verifyMode='';
  311. }
  312. },
  313. getRowKeys(row) {
  314. return row.userId; //指定row-key的一个标识
  315. },
  316. //监听关联记录弹窗关闭
  317. handleClose(){
  318. console.log('弹窗关闭');
  319. this.$refs.multipleTable.clearSelection();
  320. this.dialogForm.searchValue='';
  321. this.dialogForm.pageNum=1;
  322. this.dialogForm.deptId='';
  323. this.configuration.invalidTime='';
  324. this.configuration.verifyMode='';
  325. },
  326. //取消选中
  327. toggleSelection(rows) {
  328. let _this=this;
  329. if (rows) {
  330. rows.forEach(row => {
  331. this.$refs.multipleTable.toggleRowSelection(row,true);
  332. });
  333. } else {
  334. this.$refs.multipleTable.clearSelection();
  335. }
  336. },
  337. //选中实验室
  338. handleSelectionChange(val){
  339. let _this=this;
  340. this.labWhiteJoinSubList=[];
  341. this.labWhiteJoinSubList=val;
  342. },
  343. handleClick(index,row,doType){
  344. let _this=this;
  345. if(doType=='addStudent'){//新增学生授权
  346. _this.unifyDeploy=false;
  347. _this.dialogVisible=true;
  348. _this.dialogTitle='选择学生';
  349. _this.userType=1;
  350. this.getUserList();
  351. }else if(doType=='addTeacher'){//新增教职工授权
  352. _this.unifyDeploy=false;
  353. _this.dialogVisible=true;
  354. _this.dialogTitle='选择教职工';
  355. _this.userType=2;
  356. this.getUserList();
  357. }else if(doType=='delete'){//删除
  358. let _this=this
  359. console.log(row)
  360. this.$confirm('是否确认删除['+row.nickName+']门禁授权?', "警告", {
  361. confirmButtonText: "确定",
  362. cancelButtonText: "取消",
  363. type: "warning"
  364. }).then(function() {
  365. delUserHaikang(row.id).then( response => {
  366. _this.msgSuccess("删除成功");
  367. _this.getList();
  368. });
  369. }).then(() => {
  370. _this.getList();
  371. }).catch(() => {});
  372. }
  373. },
  374. //获取学院列表
  375. listDepartments(){
  376. listDepartments().then(response => {
  377. this.collegeOptions = response.data;
  378. });
  379. },
  380. /** 弹框查询列表 */
  381. getUserList() {//type 1学生 2教职工
  382. let _this=this;
  383. this.loading = true;
  384. if(_this.userType==1){
  385. listStudentUser(this.addDateRange(this.dialogForm, this.dateRange)).then(response => {
  386. this.dialogTable = response.rows;
  387. this.total = response.total;
  388. this.loading = false;
  389. this.dialogTable.forEach(function(item) {
  390. item.verifyMode='cardOrfaceOrPw'
  391. item.invalidTime=_this.getdate()
  392. })
  393. }
  394. );
  395. }else if(_this.userType==2){
  396. listTeacherUser(this.addDateRange(this.dialogForm, this.dateRange)).then(response => {
  397. this.dialogTable = response.rows;
  398. this.total = response.total;
  399. this.loading = false;
  400. this.dialogTable.forEach(function(item) {
  401. item.verifyMode='cardOrfaceOrPw'
  402. item.invalidTime=_this.getdate()
  403. })
  404. }
  405. );
  406. }
  407. },
  408. /** 查询门禁授权类型 */
  409. getHaikangQueryTypes(){
  410. getHaikangQueryTypes().then(response => {
  411. if(response.code==200){
  412. this.verifyWayList=response.data
  413. }
  414. });
  415. },
  416. /** 弹框搜索按钮操作 */
  417. handleQuery() {
  418. this.queryParams.pageNum = 1;
  419. this.getList();
  420. },
  421. /** 弹框重置按钮操作 */
  422. resetQuery() {
  423. this.dateRange=[];
  424. this.queryParams.searchValue = "";
  425. this.queryParams.userType = "";
  426. this.queryParams.startTime = "";
  427. this.queryParams.endTime = "";
  428. this.handleQuery();
  429. },
  430. //返回
  431. backPage(){
  432. this.$parent.handleClick('','','back');
  433. this.$parent.getList();
  434. },
  435. getList(){
  436. let _this=this;
  437. if(this.dateRange&&this.dateRange.length>0) {
  438. this.queryParams.startTime=this.dateRange[0]
  439. this.queryParams.endTime=this.dateRange[1]
  440. } else {
  441. this.queryParams.startTime=null;
  442. this.queryParams.endTime=null
  443. }
  444. getHaikangUserList(_this.queryParams).then( response => {
  445. let res=response.rows;
  446. _this.tableData=res;
  447. _this.oldTableData=res;
  448. _this.total=response.total;
  449. });
  450. },
  451. //失效时间修改后提交
  452. loseTimeSubmitForm(){
  453. let _this=this;
  454. let arr=[];
  455. _this.tableData.forEach(function(item2) {
  456. arr.push({'invalidTime':item2.invalidTime,'userId':item2.userId,'verifyMode':item2.verifyMode,id:item2.id})
  457. })
  458. _this.form.detailList=arr;
  459. setTimeout(function () {
  460. editImpowerHaikang(_this.form).then(response => {
  461. if(response.code==200){
  462. _this.msgSuccess("修改成功");
  463. _this.getList();
  464. }
  465. });
  466. },100)
  467. },
  468. /* 新增授权*/
  469. submitForm(){
  470. let _this=this;
  471. let arr=[];
  472. if(this.labWhiteJoinSubList.length>0){
  473. if(_this.configuration.invalidTime && _this.configuration.verifyMode){//统一配置
  474. this.labWhiteJoinSubList.forEach(function(item){
  475. arr.push({'invalidTime':_this.configuration.invalidTime,'userId':item.userId,'verifyMode':_this.configuration.verifyMode})
  476. })
  477. }else{
  478. this.labWhiteJoinSubList.forEach(function(item){
  479. arr.push({'invalidTime':item.invalidTime,'userId':item.userId,'verifyMode':item.verifyMode})
  480. })
  481. }
  482. _this.form.detailList=arr;
  483. setTimeout(function () {
  484. AddImpowerHaikang(_this.form).then(response => {
  485. if(response.code==200){
  486. setTimeout(function () {
  487. _this.msgSuccess("新增成功");
  488. _this.dialogVisible=false;
  489. _this.getList();
  490. },1000)
  491. }
  492. });
  493. },100)
  494. }else{
  495. this.msgError("请先选择人员!");
  496. }
  497. },
  498. },
  499. mounted() {
  500. this.queryParams.hardId=this.pageData.hardId;
  501. this.form.hardId=this.pageData.hardId;
  502. this.admittance=this.pageData.controlScope.search("1") != -1
  503. this.whiteList=this.pageData.controlScope.search("2") != -1
  504. console.log('安全准入'+this.admittance)
  505. console.log('白名单'+this.whiteList)
  506. this.listDepartments();
  507. this.getHaikangQueryTypes()
  508. this.getList()
  509. }
  510. };
  511. </script>
  512. <style lang="scss">
  513. .supplier{
  514. flex:1;
  515. display: flex;
  516. flex-direction: column;
  517. /*顶部*/
  518. .supplier-title{
  519. display: flex;
  520. justify-content: space-between;
  521. align-items: center;
  522. border-bottom: 1px solid #E0E0E0;
  523. height: 90px;
  524. p:nth-child(1){
  525. line-height:60px;
  526. color: #0045AF;
  527. font-size:14px;
  528. margin:0 12px 0 20px;
  529. }
  530. p:nth-child(2){
  531. margin-right:20px;
  532. }
  533. }
  534. .supplier-page{
  535. flex:1;
  536. display: flex!important;
  537. flex-direction: column;
  538. // box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  539. padding:20px 20px 20px!important;
  540. border-radius:10px;
  541. }
  542. /*弹框*/
  543. .btn_list{
  544. width: 100%;
  545. height: 40px;
  546. background: rgba(1,131,250,0.1);
  547. border-radius: 6px;
  548. display: flex;
  549. justify-content: flex-start;
  550. align-items: center;
  551. margin-bottom: 32px;
  552. >i{
  553. font-style: normal;
  554. display: inline-block;
  555. cursor: pointer;
  556. }
  557. >i:nth-of-type(1){
  558. font-size: 20px;
  559. color: #0045AF;
  560. margin: 0 16px 0 14px;
  561. }
  562. >i:nth-of-type(2){
  563. font-size: 16px;
  564. font-family: Source Han Sans CN;
  565. font-weight: bold;
  566. color: #999999;
  567. line-height: 16px;
  568. }
  569. >i:nth-of-type(3){
  570. font-size: 16px;
  571. font-family: Source Han Sans CN;
  572. font-weight: bold;
  573. color: #0045AF;
  574. line-height: 16px;
  575. margin: 0 28px 0 46px;
  576. }
  577. >i:nth-of-type(4){
  578. font-size: 16px;
  579. font-family: Source Han Sans CN;
  580. font-weight: bold;
  581. color: #0045AF;
  582. line-height: 16px;
  583. }
  584. >i:nth-of-type(5){
  585. font-size: 16px;
  586. font-family: Source Han Sans CN;
  587. font-weight: bold;
  588. color: #FFA312;
  589. line-height: 16px;
  590. margin: 0 40px 0 28px;
  591. }
  592. .bottom-button-box{
  593. display: flex;
  594. width:220px;
  595. margin: 0;
  596. p{
  597. font-size:14px;
  598. height:30px;
  599. width:100px;
  600. line-height:30px;
  601. text-align: center;
  602. border-radius:4px;
  603. }
  604. p:nth-child(1){
  605. border:1px solid #E0E0E0;
  606. margin-right:20px;
  607. }
  608. p:nth-child(2){
  609. border:1px solid #0045AF;
  610. }
  611. }
  612. }
  613. .configuration{
  614. height: 70px;
  615. display: flex;
  616. justify-content: flex-end;
  617. align-items: center;
  618. border-top: 1px solid #D8D8D8;
  619. .el-form-item{
  620. margin-bottom: 0!important;
  621. }
  622. }
  623. }
  624. </style>