associationPage.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. <template>
  2. <div class="associationPage">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="40px">
  4. <el-form-item label="关键字" prop="searchValue" label-width="60px">
  5. <el-input
  6. maxlength="10"
  7. v-model="queryParams.searchValue"
  8. placeholder="请输入实验室名称/负责人"
  9. style="width:190px;"
  10. />
  11. </el-form-item>
  12. <el-form-item label="学院" prop="type">
  13. <el-select v-model="queryParams.deptId" placeholder="请选择学院" style="width:150px;">
  14. <el-option
  15. v-for="dict in deptOptions"
  16. :key="dict.deptId"
  17. :label="dict.deptName"
  18. :value="dict.deptId"
  19. ></el-option>
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item label="类型" prop="type">
  23. <el-select v-model="queryParams.moldId" placeholder="请选择类型" style="width:150px;">
  24. <el-option
  25. v-for="dict in labMoldList"
  26. :key="dict.id"
  27. :label="dict.moldName"
  28. :value="dict.id"
  29. ></el-option>
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item label="安全分类" prop="typeId" label-width="70px">
  33. <el-select v-model="queryParams.typeId" placeholder="请选择安全分类" style="width:150px;">
  34. <el-option
  35. v-for="dict in typeList"
  36. :key="dict.id"
  37. :label="dict.typeName"
  38. :value="dict.id"
  39. ></el-option>
  40. </el-select>
  41. </el-form-item>
  42. <el-form-item label="安全分级" prop="level" label-width="70px">
  43. <el-select v-model="queryParams.level" placeholder="请选择安全分级" style="width:150px;">
  44. <el-option
  45. v-for="dict in levelList"
  46. :key="dict.id"
  47. :label="dict.classifiedName"
  48. :value="dict.id"
  49. ></el-option>
  50. </el-select>
  51. </el-form-item>
  52. <el-form-item style="float: right;">
  53. <p class="reset-button-one" @click="backPage"><i class="el-icon-arrow-left"></i>返回</p>
  54. </el-form-item>
  55. <el-form-item style="float: right;">
  56. <el-button
  57. style="float: left;width:150px;"
  58. type="primary"
  59. plain
  60. @click="associationButton"
  61. >新增关联实验室</el-button>
  62. </el-form-item>
  63. <el-form-item>
  64. <p class="inquire-button-one" @click="onSearch">查询</p>
  65. <p class="reset-button-one" @click="resetForm">重置</p>
  66. </el-form-item>
  67. </el-form>
  68. <el-table v-loading="loading" border :data="tableData">
  69. <el-table-column label="预案名称" align="left" prop="name" />
  70. <el-table-column label="学院" align="left" prop="deptName" width="200"/>
  71. <el-table-column label="类型" align="left" prop="moldName" width="150"/>
  72. <el-table-column label="安全分类" align="left" prop="typeName" width="150"/>
  73. <el-table-column label="安全分级" align="left" prop="levelName" width="150"/>
  74. <el-table-column label="实验室负责人" align="left" prop="adminName" width="150"/>
  75. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="160">
  76. <template slot-scope="scope">
  77. <div class="button-box">
  78. <p class="table-min-button"
  79. @click="delClick(scope.row)">删除</p>
  80. </div>
  81. </template>
  82. </el-table-column>
  83. </el-table>
  84. <pagination
  85. v-show="total>0"
  86. :total="total"
  87. layout="total, prev, pager, next, sizes, jumper"
  88. :page.sync="queryParams.pageNum"
  89. :limit.sync="queryParams.pageSize"
  90. @pagination="getListPlan"
  91. />
  92. <!--关联实验室-->
  93. <el-dialog title='关联实验室' @close="handleLabClose" v-if="dialogVisible" :visible.sync="dialogVisible" width="80%">
  94. <el-form :model="dialogForm" ref="queryForm" :inline="true">
  95. <el-form-item label="实验室名称" prop="name">
  96. <el-input
  97. style="width:160px;"
  98. v-model="dialogForm.name"
  99. placeholder="请输入实验室名称"
  100. clearable
  101. size="small"
  102. />
  103. </el-form-item>
  104. <el-form-item label="学院" prop="type" >
  105. <el-select v-model="dialogForm.deptId" placeholder="请选择学院" clearable
  106. style="width:160px;">
  107. <el-option
  108. v-for="dict in deptOptions"
  109. :key="dict.deptId"
  110. :label="dict.deptName"
  111. :value="dict.deptId"
  112. ></el-option>
  113. </el-select>
  114. </el-form-item>
  115. <el-form-item label="安全分类" prop="typeId" class="form-item">
  116. <el-select v-model="dialogForm.typeId" placeholder="请选择安全分类" clearable
  117. style="width:160px;">
  118. <el-option
  119. v-for="dict in typeList"
  120. :key="dict.id"
  121. :label="dict.typeName"
  122. :value="dict.id"
  123. ></el-option>
  124. </el-select>
  125. </el-form-item>
  126. <el-form-item label="安全分级" prop="level" class="form-item">
  127. <el-select v-model="dialogForm.level" placeholder="请选择安全分级" clearable
  128. style="width:160px;">
  129. <el-option
  130. v-for="dict in levelList"
  131. :key="dict.id"
  132. :label="dict.classifiedName"
  133. :value="dict.id"
  134. ></el-option>
  135. </el-select>
  136. </el-form-item>
  137. <el-form-item label="实验室负责人" prop="name" >
  138. <el-input
  139. style="width:160px;"
  140. v-model="dialogForm.adminName"
  141. placeholder="请输入实验室负责人"
  142. clearable
  143. size="small"
  144. />
  145. </el-form-item>
  146. <el-form-item>
  147. <p class="inquire-button-one" style="margin-left:20px;" @click="onSearch2">查询</p>
  148. <p class="reset-button-one" @click="resetForm2">重置</p>
  149. </el-form-item>
  150. </el-form>
  151. <div class="btn_list">
  152. <i class="el-icon-warning"></i>
  153. <i>已选择 {{labRiskPlanjoinsubList.length}} 项</i>
  154. <i @click="toggleSelection(dialogTable)">全选本页</i>
  155. <i @click="submitFormAll">选择全部</i>
  156. <i></i>
  157. <i @click="toggleSelection()">清除选项</i>
  158. <div class="bottom-button-box">
  159. <p @click="handleClick">取消</p>
  160. <p @click="submitForm">确定</p>
  161. <!--<el-button class="color_99" @click="handleClick('','','back')">取消</el-button>-->
  162. <!--<el-button class="color_ff back_one" @click="submitForm">确定</el-button>-->
  163. </div>
  164. </div>
  165. <el-table ref="multipleTable" border :data="dialogTable" highlight-current-row @selection-change="handleSelectionChange" :row-key="getRowKeys" style="height:500px;cursor: pointer;">
  166. <el-table-column
  167. :reserve-selection="true"
  168. type="selection"
  169. align="center"
  170. width="55">
  171. </el-table-column>
  172. <el-table-column label="实验室" show-overflow-tooltip align="left" prop="name"/>
  173. <el-table-column label="学院" align="left" prop="deptName" />
  174. <el-table-column label="安全分类" align="left" prop="typeName" />
  175. <el-table-column label="安全分级" align="left" prop="levelName" >
  176. <template slot-scope="scope">
  177. <span :style="'color:'+scope.row.fiedColor+';'">{{scope.row.levelName}}</span>
  178. </template>
  179. </el-table-column>
  180. <el-table-column label="实验室负责人" align="left" prop="adminName" />
  181. </el-table>
  182. <pagination
  183. v-show="total2>0"
  184. :total="total2"
  185. :page.sync="dialogForm.pageNum"
  186. :limit.sync="dialogForm.pageSize"
  187. @pagination="getList"
  188. />
  189. </el-dialog>
  190. </div>
  191. </template>
  192. <script>
  193. import {
  194. addPlan,
  195. updatePlan,
  196. listPlan,
  197. getUserRoleBySub,
  198. getLabRiskPlanRepeat,
  199. getLabRiskPlanJoinSub,
  200. riskPlanJoinSub,
  201. delPlan,
  202. getUserRoleBySubOperation,
  203. getUserRoleBySubBindRisk,
  204. removeByPlanJoinSub,
  205. } from "@/api/laboratory/plan";
  206. import {listDepartments} from "@/api/system/dept";
  207. import {listClassifiedAll} from "@/api/laboratory/classified";
  208. import {listClasstypeAll} from "@/api/laboratory/classtype";
  209. import { queryOption } from "@/api/laboratory/labMold";
  210. export default {
  211. name: "associationPage",
  212. props:{
  213. associationData:{},
  214. },
  215. data() {
  216. return {
  217. loading:true,
  218. deptOptions:[],
  219. typeList:[],
  220. levelList:[],
  221. total:0,
  222. queryParams:{
  223. pageNum:1,
  224. pageSize:20,
  225. },
  226. tableData:[],
  227. //实验室弹框
  228. dialogVisible:false,
  229. dialogSub:{},//关联实验室提交对象
  230. dialogTable:[],
  231. total2:0,
  232. dialogForm:{
  233. pageNum: 1,
  234. pageSize:20,
  235. name: null,
  236. deptId: null,
  237. typeId: null,
  238. level: null,
  239. adminName: null,
  240. },
  241. labRiskPlanjoinsubList:[],//选中实验室
  242. //实验室类型
  243. labMoldList:[],
  244. }
  245. },
  246. mounted(){
  247. this.getListPlan();
  248. this.getDeptListTow();
  249. this.getListClassifiedAll();
  250. this.getListClasstypeAll();
  251. this.getUserRoleBySubOperation();
  252. this.queryOption();
  253. },
  254. methods:{
  255. queryOption(){
  256. queryOption({}).then(response=>{
  257. if(response.code==200){
  258. this.labMoldList=response.data
  259. }
  260. })
  261. },
  262. /** 查询学院列表 */
  263. getDeptListTow() {
  264. listDepartments().then(response => {
  265. // this.deptOptionsTwo = response.data;
  266. this.$set(this, 'deptOptions', response.data)
  267. });
  268. },
  269. /**获取分级*/
  270. getListClassifiedAll(){
  271. listClassifiedAll().then(response=>{
  272. if(response.code==200){
  273. this.levelList = response.data
  274. }
  275. })
  276. },
  277. /**获取分类*/
  278. getListClasstypeAll(){
  279. listClasstypeAll().then(response=>{
  280. if(response.code==200){
  281. this.typeList = response.data;
  282. }
  283. });
  284. },
  285. /** 查询实验室根据实验室管理员用户权限是否有操作权限 */
  286. getUserRoleBySubOperation(){
  287. getUserRoleBySubOperation({}).then(response => {
  288. if(response.code==200){
  289. this.labShow= response.data //返回true是实验室管理员,false不是实验室管理员
  290. this.joinSubOper=response.data;
  291. }
  292. });
  293. },
  294. associationButton(){
  295. let _this = this;
  296. //关联实验室
  297. this.dialogSub.id = _this.associationData.row.id;
  298. this.dialogVisible = true;
  299. this.checkedLabList=[];
  300. console.log('有相同的实验室',_this.associationData.row.labRiskPlanjoinsubList)
  301. //根据列表返回的实验室信息循环匹配相同实验室信息
  302. setTimeout(function(){
  303. let newList = [];
  304. _this.tableData.forEach(function (item2,index){
  305. _this.$refs.multipleTable.toggleRowSelection(item2,true);
  306. newList.push(item2)
  307. })
  308. _this.$set(_this,'checkedLabList',newList)
  309. console.log('newList',newList)
  310. _this.getList();
  311. },100);
  312. },
  313. /** 查询实验室列表 */
  314. getList() {
  315. let _this=this;
  316. getUserRoleBySub(this.dialogForm).then(response => {
  317. this.dialogTable = response.rows;
  318. this.total2 = response.total;
  319. // for(let i=0;i<_this.checkedLabList.length;i++){
  320. // _this.$refs.multipleTable.toggleRowSelection(_this.checkedLabList[i],true)
  321. // console.log("123")
  322. // }
  323. });
  324. },
  325. //选中实验室
  326. handleSelectionChange(val){
  327. let _this=this;
  328. _this.labRiskPlanjoinsubList=[];
  329. console.log("val",val);
  330. let newList = [];
  331. val.forEach(function (item,index){
  332. newList.push({'subjectId':item.id})
  333. })
  334. this.$set(this,'labRiskPlanjoinsubList',newList)
  335. },
  336. /*===记录勾选数据===
  337. 需要再el-table 添加 :row-key="getRowKeys"
  338. 需要在selection 添加 :reserve-selection="true"
  339. */
  340. getRowKeys(row) {
  341. return row.subjectId
  342. },
  343. //查询
  344. onSearch2() {
  345. this.dialogForm.pageNo = 1;
  346. this.getList();
  347. },
  348. //重置
  349. resetForm2() {
  350. this.dialogForm.name = '';
  351. this.dialogForm.deptId = '';
  352. this.dialogForm.typeId = '';
  353. this.dialogForm.level = '';
  354. this.dialogForm.adminName = '';
  355. this.onSearch2();
  356. },
  357. //全部实验室关联
  358. submitFormAll(){
  359. let _this=this;
  360. _this.dialogSub.labRiskPlanjoinsubList=_this.labRiskPlanjoinsubList
  361. _this.dialogSub.joinSubOper=this.joinSubOper;
  362. let obj1 = JSON.parse(JSON.stringify(_this.dialogSub))
  363. obj1.allSelect = true;
  364. getLabRiskPlanJoinSub(obj1).then(response => {
  365. if(response.code = 200){
  366. if(response.data.repeat==true){//:如果为true,就是有重复的,如果为false,就表示没有重复的
  367. this.$confirm(response.data.tipsStr, '提示', {
  368. distinguishCancelAndClose:true,
  369. confirmButtonText: '是',
  370. cancelButtonText: '否',
  371. type: 'warning'
  372. }).then(() => {//确定
  373. _this.dialogSub.yesOrNo=true;//是否覆盖提交,true是,false否
  374. let obj2 = JSON.parse(JSON.stringify(this.dialogSub))
  375. obj2.allSelect = true;
  376. riskPlanJoinSub(obj2).then(response => {
  377. if(response.code = 200){
  378. this.getListPlan();
  379. this.msgSuccess("修改成功");
  380. this.dialogVisible = false;
  381. }
  382. });
  383. }).catch(action => {
  384. if(action === 'cancel'){
  385. _this.dialogSub.yesOrNo=false;//是否覆盖提交,true是,false否
  386. let obj3 = JSON.parse(JSON.stringify(this.dialogSub))
  387. obj3.allSelect = true;
  388. riskPlanJoinSub(obj3).then(response => {
  389. if(response.code = 200){
  390. this.getListPlan();
  391. this.msgSuccess("修改成功");
  392. this.dialogVisible = false;
  393. }
  394. });
  395. }
  396. });
  397. }else if(response.data.repeat==false){//:如果为true,就是有重复的,如果为false,就表示没有重复的
  398. _this.dialogSub.yesOrNo=false;//是否覆盖提交,true是,false否
  399. let obj4 = JSON.parse(JSON.stringify(this.dialogSub))
  400. obj4.allSelect = true;
  401. riskPlanJoinSub(obj4).then(response => {
  402. if(response.code = 200){
  403. this.getListPlan();
  404. this.msgSuccess("修改成功");
  405. this.dialogVisible = false;
  406. }
  407. });
  408. }
  409. }
  410. });
  411. },
  412. /** 关联实验室 */
  413. submitForm() {
  414. let _this=this;
  415. _this.dialogSub.labRiskPlanjoinsubList=_this.labRiskPlanjoinsubList
  416. _this.dialogSub.joinSubOper=this.joinSubOper;
  417. let obj1 = JSON.parse(JSON.stringify(_this.dialogSub))
  418. obj1.allSelect = false;
  419. getLabRiskPlanJoinSub(obj1).then(response => {
  420. if(response.code = 200){
  421. if(response.data.repeat==true){//:如果为true,就是有重复的,如果为false,就表示没有重复的
  422. this.$confirm(response.data.tipsStr, '提示', {
  423. distinguishCancelAndClose:true,
  424. confirmButtonText: '是',
  425. cancelButtonText: '否',
  426. type: 'warning'
  427. }).then(() => {//确定
  428. _this.dialogSub.yesOrNo=true;//是否覆盖提交,true是,false否
  429. let obj2 = JSON.parse(JSON.stringify(this.dialogSub))
  430. obj2.allSelect = false;
  431. riskPlanJoinSub(obj2).then(response => {
  432. if(response.code = 200){
  433. this.msgSuccess("修改成功");
  434. this.getListPlan();
  435. this.dialogVisible = false;
  436. }
  437. });
  438. }).catch(action => {
  439. if(action === 'cancel'){
  440. _this.dialogSub.yesOrNo=false;//是否覆盖提交,true是,false否
  441. let obj3 = JSON.parse(JSON.stringify(this.dialogSub))
  442. obj3.allSelect = false;
  443. riskPlanJoinSub(obj3).then(response => {
  444. if(response.code = 200){
  445. this.msgSuccess("修改成功");
  446. this.getListPlan();
  447. this.dialogVisible = false;
  448. }
  449. });
  450. }
  451. });
  452. }else if(response.data.repeat==false){//:如果为true,就是有重复的,如果为false,就表示没有重复的
  453. _this.dialogSub.yesOrNo=false;//是否覆盖提交,true是,false否
  454. let obj4 = JSON.parse(JSON.stringify(this.dialogSub))
  455. obj4.allSelect = false;
  456. riskPlanJoinSub(obj4).then(response => {
  457. if(response.code = 200){
  458. this.msgSuccess("修改成功");
  459. this.getListPlan();
  460. this.dialogVisible = false;
  461. }
  462. });
  463. }
  464. }
  465. });
  466. },
  467. handleClick() {
  468. this.dialogVisible=false;
  469. this.getListPlan();
  470. this.$forceUpdate();
  471. },
  472. //取消选中
  473. toggleSelection(rows) {
  474. console.log(rows)
  475. if (rows) {
  476. this.$refs.multipleTable.clearSelection();
  477. rows.forEach(row => {
  478. this.$refs.multipleTable.toggleRowSelection(row);
  479. });
  480. } else {
  481. this.$refs.multipleTable.clearSelection();
  482. }
  483. },
  484. //监听实验室弹窗关闭
  485. handleLabClose(){
  486. this.getListPlan();
  487. this.dialogForm.pageNum = 1;
  488. this.$refs.multipleTable.clearSelection()
  489. // if(this.checkedLabList){
  490. // console.log('实验室信息回显')
  491. // this.$nextTick(() => {
  492. // this.checkedLabList.forEach(row => {
  493. // this.$refs.multipleTable.toggleRowSelection(row);
  494. // });
  495. // })
  496. // }
  497. },
  498. backPage(){
  499. this.$parent.handleClose();
  500. },
  501. getListPlan(){
  502. //?pageNum=1&pageSize = 20&pageNo=1&riskId=25
  503. let obj = JSON.parse(JSON.stringify(this.queryParams));
  504. obj.pageNo = '';
  505. obj.riskId = this.associationData.row.id;
  506. getUserRoleBySubBindRisk(obj).then(response => {
  507. this.tableData = response.rows;
  508. this.loading = false;
  509. })
  510. },
  511. //删除
  512. delClick(item){
  513. let self = this;
  514. this.$confirm('是否确认删除?', "警告", {
  515. confirmButtonText: "确定",
  516. cancelButtonText: "取消",
  517. type: "warning"
  518. }).then(function() {
  519. let obj = {
  520. riskPlanId:self.associationData.row.id,
  521. subjectId:item.subjectId
  522. };
  523. removeByPlanJoinSub(obj).then(response => {
  524. self.getListPlan();
  525. self.msgSuccess("删除成功");
  526. })
  527. }).then(() => {
  528. }).catch(() => {});
  529. },
  530. //查询
  531. onSearch() {
  532. this.queryParams.pageNum = 1;
  533. this.getListPlan();
  534. },
  535. //重置
  536. resetForm() {
  537. this.dateRange=[];
  538. this.queryParams.searchValue = '';
  539. this.queryParams.deptId = '';
  540. this.queryParams.moldId = '';
  541. this.queryParams.typeId = '';
  542. this.queryParams.level = '';
  543. this.onSearch();
  544. },
  545. }
  546. }
  547. </script>
  548. <style scoped lang="scss">
  549. .associationPage{
  550. flex:1;
  551. display: flex;
  552. flex-direction: column;
  553. .btn_list{
  554. width: 100%;
  555. height: 40px;
  556. background: rgba(1,131,250,0.1);
  557. border-radius: 6px;
  558. display: flex;
  559. justify-content: flex-start;
  560. align-items: center;
  561. margin-bottom: 32px;
  562. >i{
  563. font-style: normal;
  564. display: inline-block;
  565. cursor: pointer;
  566. }
  567. >i:nth-of-type(1){
  568. font-size: 20px;
  569. color: #0045AF;
  570. margin: 0 16px 0 14px;
  571. }
  572. >i:nth-of-type(2){
  573. font-size: 16px;
  574. font-family: Source Han Sans CN;
  575. font-weight: bold;
  576. color: #999999;
  577. line-height: 16px;
  578. }
  579. >i:nth-of-type(3){
  580. font-size: 16px;
  581. font-family: Source Han Sans CN;
  582. font-weight: bold;
  583. color: #0045AF;
  584. line-height: 16px;
  585. margin: 0 28px 0 46px;
  586. }
  587. >i:nth-of-type(4){
  588. font-size: 16px;
  589. font-family: Source Han Sans CN;
  590. font-weight: bold;
  591. color: #0045AF;
  592. line-height: 16px;
  593. margin: 0 28px 0 46px;
  594. }
  595. >i:nth-of-type(5){
  596. font-size: 16px;
  597. font-family: Source Han Sans CN;
  598. font-weight: bold;
  599. color: #0045AF;
  600. line-height: 16px;
  601. }
  602. >i:nth-of-type(6){
  603. font-size: 16px;
  604. font-family: Source Han Sans CN;
  605. font-weight: bold;
  606. color: #FFA312;
  607. line-height: 16px;
  608. margin: 0 40px 0 28px;
  609. }
  610. .bottom-button-box{
  611. display: flex;
  612. width:220px;
  613. p{
  614. font-size:14px;
  615. height:30px;
  616. width:100px;
  617. line-height:30px;
  618. text-align: center;
  619. border-radius:4px;
  620. cursor: pointer;
  621. }
  622. p:nth-child(1){
  623. border:1px solid #E0E0E0;
  624. margin-right:20px;
  625. color: #666;
  626. }
  627. p:nth-child(2){
  628. background: #0183FA;
  629. border:1px solid #0183FA;
  630. color:#fff;
  631. }
  632. }
  633. }
  634. }
  635. </style>