addPage.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. <!--白名单新增-->
  2. <template>
  3. <div class="add-whitelist">
  4. <div class="top-max-button-title-box">
  5. <p>新增准入白名单</p>
  6. <p class="button-p reset-button-one" @click="backPage">返回</p>
  7. </div>
  8. <div class="form-max-box">
  9. <div class="left">
  10. <el-form :model="form" ref="drawerForm" :rules="rules" >
  11. <el-form-item label="姓名" prop="userIds" style="margin-top:40px;">
  12. <el-select
  13. :disabled="isEdit"
  14. v-model="form.userIds"
  15. filterable
  16. remote
  17. reserve-keyword
  18. placeholder="请输入姓名"
  19. :remote-method="userSelectList"
  20. @change="selectChange"
  21. :loading="loading">
  22. <el-option
  23. v-for="item in optionsUser"
  24. :key="item.userId"
  25. :label="item.nickName"
  26. :value="item.userId">
  27. </el-option>
  28. </el-select>
  29. </el-form-item>
  30. <div class="for-max-box">
  31. <div class="for-box" v-for="(item,index) in userList" :key="index">
  32. <div class="for-min-box">
  33. <p>{{item.deptName ? item.deptName+'-'+item.userName:item.userName}}</p>
  34. <img src="@/assets/newImages/off.png" @click="delItem(index)" v-if="!isEdit">
  35. </div>
  36. </div>
  37. </div>
  38. <p class="inquire-button-one" style="margin:100px 50px;" @click="upButton">提交</p>
  39. </el-form>
  40. </div>
  41. <div class="right">
  42. <div style="text-align: right;margin: 20px;" class="right_t"> <p class="inquire-button-one" style="width: 150px" @click="newAdmittance">新增准入实验室</p></div>
  43. <el-table class="right_b" border v-loading="loading" :data="subjectList">
  44. <el-table-column label="申请实验室" align="left" prop="name" />
  45. <el-table-column label="楼栋" align="left" prop="building" />
  46. <el-table-column label="楼层" align="left" prop="buildName" />
  47. <el-table-column label="学院" align="left" prop="deptName" />
  48. <el-table-column label="实验室负责人" align="left" prop="adminName" />
  49. <el-table-column label="安全分级" align="left" prop="levelName" />
  50. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  51. <template slot-scope="scope">
  52. <div class="button-box">
  53. <p class="table-min-button" @click="handleClick(scope.$index, scope.row,'delete')" ><i class="el-icon-delete"></i>删除</p>
  54. </div>
  55. </template>
  56. </el-table-column>
  57. </el-table>
  58. </div>
  59. </div>
  60. <!--关联实验室弹框-->
  61. <el-dialog title='新增准入实验室' @close="handleClose" :visible.sync="dialogVisible" width="80%">
  62. <el-form :model="dialogForm" ref="dialogForm" :inline="true" label-width="140px">
  63. <el-form-item label="实验室名称" prop="name" >
  64. <el-input
  65. v-model="dialogForm.name"
  66. placeholder="请输入实验室名称"
  67. clearable
  68. size="small"
  69. />
  70. </el-form-item>
  71. <el-form-item label="楼栋" prop="buildId">
  72. <el-select v-model="dialogForm.buildId" placeholder="请选择楼栋" clearable @change="buildChange">
  73. <el-option v-for="(item,index) in buildsDataList" :key="index" :label="item.deptName" :value="item.deptId" />
  74. </el-select>
  75. </el-form-item>
  76. <el-form-item label="楼层" prop="floorId">
  77. <el-select v-model="dialogForm.floorId" placeholder="请选择楼层" >
  78. <el-option
  79. v-for="dict in floorList"
  80. :key="dict.id"
  81. :label="dict.name"
  82. :value="dict.id"
  83. ></el-option>
  84. </el-select>
  85. </el-form-item>
  86. <el-form-item>
  87. <p class="inquire-button-one" style="margin-left:20px;" @click="onSearch">查询</p>
  88. <p class="reset-button-one" style="margin-left:20px;" @click="resetForm">重置</p>
  89. </el-form-item>
  90. </el-form>
  91. <div class="btn_list">
  92. <i class="el-icon-warning"></i>
  93. <i>已选择 {{labWhiteJoinSubList.length}} 项</i>
  94. <i @click="toggleSelection(dialogTable)">全选本页</i>
  95. <!-- <i>选择全部</i>-->
  96. <i></i>
  97. <i @click="toggleSelection()">清除选项</i>
  98. <div class="bottom-button-box">
  99. <el-button class="color_99" @click="closeDialog(1)">关闭</el-button>
  100. <el-button class="color_ff back_one" @click="closeDialog(2)">确定</el-button>
  101. </div>
  102. </div>
  103. <el-table ref="multipleTable" border tooltip-effect="dark" :row-key="getRowKeys" :data="dialogTable"
  104. highlight-current-row @selection-change="handleSelectionChange" style="cursor: pointer;height:500px;">
  105. <el-table-column type="selection" width="55" :reserve-selection="true" align="center"></el-table-column>
  106. <el-table-column label="申请实验室名称" show-overflow-tooltip align="left" prop="name"/>
  107. <el-table-column label="楼栋" align="left" prop="building" />
  108. <el-table-column label="楼层" align="left" prop="buildName" />
  109. <el-table-column label="学院" align="left" prop="deptName" />
  110. <el-table-column label="实验室负责人" align="left" prop="adminName" />
  111. <el-table-column label="安全分级" align="left" prop="levelName" >
  112. <template slot-scope="scope">
  113. <span :style="'color:'+scope.row.fiedColor+';'">{{scope.row.levelName}}</span>
  114. </template>
  115. </el-table-column>
  116. </el-table>
  117. <pagination
  118. v-show="total>0"
  119. :total="total"
  120. :page.sync="dialogForm.pageNum"
  121. :limit.sync="dialogForm.pageSize"
  122. @pagination="getUserRoleBySub"
  123. />
  124. <!-- <div class="bottom-button-box" style="padding-top: 20px;text-align: right;">
  125. <el-button class="color_99" @click="closeDialog()">取消</el-button>
  126. <el-button class="color_ff back_one" @click="confirmDialog()">确定</el-button>
  127. </div>-->
  128. </el-dialog>
  129. </div>
  130. </template>
  131. <script>
  132. import {
  133. getAllSubjectByParame,
  134. selectUserListByName,
  135. whitelistAddList,
  136. whitelistEdit, whitelistEditList,
  137. whitelistList,
  138. whitelistSubListEdit
  139. } from "@/api/laboratory/whitelist";
  140. import {listInfo} from "@/api/laboratory/gradeManage";
  141. import {delPlan, getUserRoleBySub} from "@/api/laboratory/plan";
  142. import {buildsList} from "@/api/laboratory/sparseHardware";
  143. import {listFloorByBuildId} from "@/api/laboratory/building";
  144. export default {
  145. name: "add-whitelist",
  146. props:{
  147. pageData:{},
  148. },
  149. data() {
  150. return {
  151. isEdit:false,
  152. form:{},
  153. loading:false,
  154. // 表单校验
  155. rules: {
  156. userIds: [
  157. { required: true, message: "请输入标题", trigger: "blur" },
  158. { required: true, message: "请输入标题", validator: this.spaceJudgment, trigger: "blur" }
  159. ],
  160. },
  161. //展示数组
  162. userList:[],
  163. //搜索角色数组
  164. optionsUser:[],
  165. queryParams:{
  166. pageNum:1,
  167. pageSize: 10,
  168. },
  169. total:0,
  170. subjectList:[],
  171. dialogVisible:false,
  172. dialogForm:{
  173. pageNum: 1,
  174. pageSize: 10,
  175. name: null,
  176. floorId: null,
  177. whiteUserId:null,
  178. deptId:JSON.parse(localStorage.getItem('user')).deptId,
  179. },
  180. dialogTable:[],
  181. buildsDataList:[],
  182. floorList:[],
  183. labWhiteJoinSubList:[],
  184. arr:[],
  185. };
  186. },
  187. created() {
  188. if(this.pageData.id){
  189. console.log('编辑')
  190. this.isEdit=true;
  191. this.whitelistEdit();
  192. this.whitelistSubListEdit();
  193. this.dialogForm.whiteUserId=this.pageData.userId;
  194. this.getUserRoleBySub();
  195. }else{
  196. this.isEdit=false;
  197. this.getUserRoleBySub();
  198. }
  199. this.buildsList();
  200. },
  201. methods: {
  202. getRowKeys(row) {
  203. return row.subjectId; //指定row-key的一个标识
  204. },
  205. //关闭实验室弹窗
  206. closeDialog(type){
  207. if(type == 1){
  208. this.dialogVisible=false;
  209. }else if(type == 2){
  210. this.subjectList = JSON.parse(JSON.stringify(this.labWhiteJoinSubList));
  211. this.dialogVisible=false;
  212. }
  213. },
  214. //监听关联记录弹窗关闭
  215. handleClose(){
  216. console.log('弹窗关闭');
  217. /*if(this.arr){
  218. console.log('实验室信息回显')
  219. this.$nextTick(() => {
  220. this.arr.forEach(row => {
  221. this.$refs.multipleTable.toggleRowSelection(row,true);
  222. });
  223. })
  224. }*/
  225. },
  226. //取消选中
  227. toggleSelection(rows) {
  228. let _this=this;
  229. if (rows) {
  230. // this.$refs.multipleTable.clearSelection();
  231. rows.forEach(row => {
  232. this.$refs.multipleTable.toggleRowSelection(row,true);
  233. //_this.arr.push(row)
  234. //_this.subjectList.push(row)
  235. });
  236. } else {
  237. this.$refs.multipleTable.clearSelection();
  238. }
  239. },
  240. //选中实验室
  241. handleSelectionChange(val){
  242. console.log(val)
  243. console.log(this.labWhiteJoinSubList)
  244. let _this=this;
  245. this.labWhiteJoinSubList=[];
  246. this.labWhiteJoinSubList=val;
  247. // _this.subjectList=this.labWhiteJoinSubList
  248. _this.arr=this.labWhiteJoinSubList
  249. },
  250. //查询楼栋
  251. buildsList(){
  252. buildsList().then( response => {
  253. this.buildsDataList = response.data;
  254. });
  255. },
  256. //选择楼栋
  257. buildChange(e){
  258. console.log("选择楼栋",e)
  259. //根据学院获取楼栋
  260. listFloorByBuildId(this.dialogForm.buildId).then(response => {
  261. this.$set(this,'floorList', response.data)
  262. this.$set(this.form,'floorId', "")
  263. });
  264. },
  265. //查询
  266. onSearch() {
  267. this.dialogForm.pageNo = 1;
  268. this.getUserRoleBySub();
  269. },
  270. //重置
  271. resetForm() {
  272. this.dialogForm.name = '';
  273. this.dialogForm.floorId = '';
  274. this.dialogForm.buildId = '';
  275. this.onSearch();
  276. },
  277. //新增准入实验室
  278. newAdmittance(){
  279. let _this=this;
  280. this.dialogVisible=true;
  281. if(_this.subjectList[0]){
  282. setTimeout(function(){
  283. _this.$refs.multipleTable.clearSelection();
  284. console.log("============>1")
  285. _this.subjectList.forEach(row => {
  286. console.log("============>2")
  287. _this.$refs.multipleTable.toggleRowSelection(row,true);
  288. });
  289. _this.getUserRoleBySub();
  290. },100);
  291. }else{
  292. if(_this.$refs.multipleTable){
  293. _this.$refs.multipleTable.clearSelection();
  294. }
  295. }
  296. // if(this.arr){
  297. // console.log('实验室信息回显')
  298. // console.log(this.arr)
  299. // if(_this.arr.length==0){
  300. // if(_this.$refs.multipleTable){
  301. // _this.$refs.multipleTable.clearSelection();
  302. // }
  303. // }else{
  304. // _this.$nextTick(() => {
  305. // setTimeout(function(){
  306. // console.log("============>1")
  307. // _this.subjectList.forEach(row => {
  308. // console.log("============>2")
  309. // _this.$refs.multipleTable.toggleRowSelection(row,true);
  310. // });
  311. // },300);
  312. // })
  313. // }
  314. // }
  315. },
  316. //确认按钮
  317. confirmDialog(){
  318. let _this=this;
  319. /*if(_this.labWhiteJoinSubList){
  320. _this.subjectList= _this.labWhiteJoinSubList
  321. _this.arr= _this.labWhiteJoinSubList
  322. _this.dialogVisible=false;
  323. }*/
  324. },
  325. //编辑查询人员信息
  326. whitelistEdit(){
  327. whitelistEdit(this.pageData.id).then(response => {
  328. let data=response.data;
  329. console.log(data)
  330. if(data.userId){
  331. this.$set(this.form,'userIds',data.userName)
  332. this.userSelectList(data.userName);
  333. //this.userList=data
  334. let obj = {
  335. deptId:data.deptId,
  336. deptName:data.deptName,
  337. userId:data.userId,
  338. userName:data.userName,
  339. userNumber:data.userName,
  340. userTelephone:data.phonenumber,
  341. userType:data.userType,
  342. }
  343. this.userList.push(obj);
  344. }
  345. });
  346. },
  347. //编辑-查询实验室信息
  348. whitelistSubListEdit(){
  349. whitelistSubListEdit(this.pageData.userId).then(response => {
  350. if(response.code==200){
  351. let data=response.rows;
  352. this.subjectList=data
  353. }
  354. });
  355. },
  356. /** 查询实验室列表 */
  357. getUserRoleBySub() {
  358. this.loading = true;
  359. let _this=this;
  360. getAllSubjectByParame(this.dialogForm).then(response => {
  361. if(response.code==200){
  362. this.dialogTable = response.rows;
  363. this.total = response.total;
  364. this.loading = false;
  365. console.log(_this.subjectList)
  366. console.log(_this.arr)
  367. if(_this.arr.length==0){
  368. _this.dialogTable.forEach(function (item,index){
  369. _this.subjectList.forEach(function (item2,index2){
  370. if(item.subjectId==item2.subjectId){
  371. _this.arr.push(item)
  372. console.log(_this.arr)
  373. if(_this.$refs.multipleTable){
  374. _this.$nextTick(() => {
  375. _this.$refs.multipleTable.toggleRowSelection(item,true);
  376. })
  377. }
  378. }
  379. })
  380. })
  381. }else{
  382. _this.dialogTable.forEach(function (item,index){
  383. _this.arr.forEach(function (item2,index2){
  384. if(item.subjectId==item2.subjectId){
  385. if(_this.$refs.multipleTable){
  386. _this.$nextTick(() => {
  387. _this.$refs.multipleTable.toggleRowSelection(item,true);
  388. })
  389. }
  390. }
  391. })
  392. })
  393. }
  394. }
  395. });
  396. },
  397. // 上传按钮
  398. upButton(){
  399. let self = this;
  400. if(!this.userList[0]){
  401. this.msgError("请先添加人员")
  402. return
  403. }
  404. this.$confirm('是否确认提交?', "", {
  405. confirmButtonText: "确定",
  406. cancelButtonText: "取消",
  407. type: "warning"
  408. }).then(function() {
  409. console.log(444444)
  410. console.log(self.pageData.id)
  411. if(self.pageData.id){
  412. console.log('编辑提交')
  413. self.whitelistEditList();
  414. }else{
  415. console.log('新增提交')
  416. self.whitelistAddList();
  417. }
  418. }).then(() => {}).catch(() => {});
  419. },
  420. //新增提交
  421. whitelistAddList(){
  422. let labWhiteJoinSubList=[];
  423. this.subjectList.forEach(function (item,index){
  424. labWhiteJoinSubList.push({'subjectId':item.subjectId})
  425. })
  426. let obj = {
  427. labWhitelist:this.userList,
  428. labWhiteJoinSubList:labWhiteJoinSubList
  429. }
  430. whitelistAddList(obj).then(response => {
  431. this.msgSuccess("操作成功")
  432. this.backPage();
  433. });
  434. },
  435. //编辑提交
  436. whitelistEditList(){
  437. console.log(this.subjectList)
  438. let labWhiteJoinSubList=[];
  439. //循环取出实验室id
  440. this.subjectList.forEach(function (item,index){
  441. labWhiteJoinSubList.push({'subjectId':item.subjectId})
  442. })
  443. let obj = {
  444. userId:this.userList[0].userId,
  445. labWhiteJoinSubList:labWhiteJoinSubList
  446. }
  447. whitelistEditList(obj).then(response => {
  448. this.msgSuccess("操作成功")
  449. this.backPage();
  450. });
  451. },
  452. handleClick(index, row, doType){
  453. console.log(this.subjectList)
  454. let _this=this;
  455. if(doType == 'delete'){//定制预案
  456. this.$confirm('是否确认删除?', "警告", {
  457. confirmButtonText: "确定",
  458. cancelButtonText: "取消",
  459. type: "warning"
  460. }).then(() => {
  461. if(_this.$refs.multipleTable){
  462. _this.$refs.multipleTable.toggleRowSelection(row,false);
  463. }
  464. //this.subjectList.splice(this.subjectList.indexOf(row),1);
  465. let index = this.subjectList.indexOf(row);
  466. if(index!=-1){
  467. this.subjectList.splice(index,1);
  468. return
  469. }
  470. _this.arr=[];
  471. _this.subjectList.forEach(function (item,index){
  472. _this.dialogTable.forEach(function (item2,index2){
  473. if(item.subjectId==item2.subjectId){
  474. _this.arr.push(item2)
  475. }else{
  476. }
  477. })
  478. })
  479. this.msgSuccess("删除成功");
  480. }).catch(() => {
  481. this.msgInfo("取消成功");
  482. });
  483. }
  484. },
  485. //删除
  486. delItem(index){
  487. this.userList.splice(index,1);
  488. },
  489. //新增
  490. selectChange(id){
  491. let self = this;
  492. for(let o=0;o<self.optionsUser.length;o++){
  493. if( id == self.optionsUser[o].userId){
  494. let num = 0;
  495. for(let s=0;s<self.userList.length;s++){
  496. if(self.userList[s].userId == self.optionsUser[o].userId){
  497. num++
  498. }
  499. }
  500. if(num == 0){
  501. let obj = {
  502. deptId:self.optionsUser[o].deptId,
  503. deptName:self.optionsUser[o].deptName,
  504. userId:self.optionsUser[o].userId,
  505. userName:self.optionsUser[o].nickName,
  506. userNumber:self.optionsUser[o].userName,
  507. userTelephone:self.optionsUser[o].phonenumber,
  508. userType:self.optionsUser[o].userType,
  509. }
  510. self.userList.push(obj);
  511. }else{
  512. self.msgError(self.optionsUser[o].nickName+'已在列表中')
  513. }
  514. }
  515. }
  516. },
  517. //返回
  518. backPage(){
  519. this.$parent.pageClick(1);
  520. },
  521. //数据懒加载
  522. userSelectList(query) {
  523. if (query !== '' && query.length>1) {
  524. this.loading = true;
  525. this.userSelectList.nickName=query;
  526. selectUserListByName(query).then(response => {
  527. this.optionsUser = response.data;
  528. this.loading = false;
  529. });
  530. } else {
  531. this.optionsUser = [];
  532. }
  533. },
  534. }
  535. };
  536. </script>
  537. <style scoped lang="scss">
  538. .add-whitelist {
  539. display: flex !important;
  540. flex-direction: column;
  541. height: 100%;
  542. /*box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);*/
  543. padding:20px 20px 20px!important;
  544. .top-max-button-title-box{
  545. display: flex;
  546. border-bottom:1px solid #E0E0E0;
  547. p:nth-child(1){
  548. flex:1;
  549. font-size:16px;
  550. color:#0045AF;
  551. }
  552. p:nth-child(2){
  553. margin-right:20px;
  554. }
  555. }
  556. .form-max-box{
  557. height: 100%;
  558. display: flex;
  559. .left{
  560. width: 24%;
  561. .for-max-box{
  562. margin-left:40px;
  563. .for-box{
  564. display: inline-block;
  565. border-radius:6px;
  566. background: rgba(1,131,250,0.2);
  567. margin:0 10px 10px;
  568. .for-min-box{
  569. display: flex;
  570. p{
  571. flex:1;
  572. padding:0 20px;
  573. margin:0;
  574. line-height:40px;
  575. color:#0183FA;
  576. }
  577. img{
  578. width:16px;
  579. height:16px;
  580. margin:12px 12px;
  581. cursor: pointer;
  582. }
  583. }
  584. }
  585. }
  586. }
  587. .right{
  588. display: flex;
  589. width: 76%;
  590. position: relative;
  591. .right_t{
  592. position: absolute;
  593. right: 20px;
  594. }
  595. .right_b{
  596. margin-top: 80px;
  597. }
  598. }
  599. }
  600. }
  601. .btn_list{
  602. width: 100%;
  603. height: 40px;
  604. background: rgba(1,131,250,0.1);
  605. border-radius: 6px;
  606. display: flex;
  607. justify-content: flex-start;
  608. align-items: center;
  609. margin-bottom: 32px;
  610. >i{
  611. font-style: normal;
  612. display: inline-block;
  613. cursor: pointer;
  614. }
  615. >i:nth-of-type(1){
  616. font-size: 20px;
  617. color: #0045AF;
  618. margin: 0 16px 0 14px;
  619. }
  620. >i:nth-of-type(2){
  621. font-size: 16px;
  622. font-family: Source Han Sans CN;
  623. font-weight: bold;
  624. color: #999999;
  625. line-height: 16px;
  626. }
  627. >i:nth-of-type(3){
  628. font-size: 16px;
  629. font-family: Source Han Sans CN;
  630. font-weight: bold;
  631. color: #0045AF;
  632. line-height: 16px;
  633. margin: 0 28px 0 46px;
  634. }
  635. >i:nth-of-type(4){
  636. font-size: 16px;
  637. font-family: Source Han Sans CN;
  638. font-weight: bold;
  639. color: #0045AF;
  640. line-height: 16px;
  641. }
  642. >i:nth-of-type(5){
  643. font-size: 16px;
  644. font-family: Source Han Sans CN;
  645. font-weight: bold;
  646. color: #FFA312;
  647. line-height: 16px;
  648. margin: 0 40px 0 28px;
  649. }
  650. .bottom-button-box{
  651. display: flex;
  652. width:220px;
  653. margin: 0;
  654. p{
  655. font-size:14px;
  656. height:30px;
  657. width:100px;
  658. line-height:30px;
  659. text-align: center;
  660. border-radius:4px;
  661. }
  662. p:nth-child(1){
  663. border:1px solid #E0E0E0;
  664. margin-right:20px;
  665. }
  666. p:nth-child(2){
  667. border:1px solid #0045AF;
  668. }
  669. }
  670. }
  671. </style>