addSubject.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. <template>
  2. <div class="addSubject scrollbar-box">
  3. <el-form ref="form" :model="form" label-width="120px" :rules="rules" >
  4. <div class="title-box">
  5. <p class="left-title">基本信息</p>
  6. </div>
  7. <el-form-item label="实验室名称" prop="name" class="form-item">
  8. <el-input
  9. style="width:320px;"
  10. maxlength="30"
  11. v-model="form.name"
  12. placeholder="请输实验室名称"
  13. clearable
  14. size="small"
  15. />
  16. </el-form-item>
  17. <el-form-item label="类型" prop="moldId" class="form-item">
  18. <el-select v-model="form.moldId" placeholder="请选择类型" clearable style="width:320px;">
  19. <el-option
  20. v-for="dict in labMoldList"
  21. :key="dict.id"
  22. :label="dict.moldName"
  23. :value="dict.id"
  24. ></el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="安全分类" prop="typeId" class="form-item">
  28. <el-select v-model="form.typeId" placeholder="请选择安全分类" clearable style="width:320px;">
  29. <el-option
  30. v-for="dict in typeList"
  31. :key="dict.id"
  32. :label="dict.typeName"
  33. :value="dict.id"
  34. ></el-option>
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item label="安全分级" prop="level" class="form-item">
  38. <el-select v-model="form.level" placeholder="请选择安全分级" clearable style="width:320px;">
  39. <el-option
  40. v-for="dict in levelList"
  41. :key="dict.id"
  42. :label="dict.classifiedName"
  43. :value="dict.id"
  44. ></el-option>
  45. </el-select>
  46. </el-form-item>
  47. <el-form-item label="学院" prop="deptId" class="form-item">
  48. <el-select v-model="form.deptId" placeholder="请选择学院" @change="getBuildings" style="width:320px;">
  49. <el-option
  50. v-for="dict in deptOptions"
  51. :key="dict.deptId"
  52. :label="dict.deptName"
  53. :value="dict.deptId"
  54. ></el-option>
  55. </el-select>
  56. </el-form-item>
  57. <el-form-item label="楼栋" prop="buildId" class="form-item">
  58. <el-select v-model="form.buildId" placeholder="请选择楼栋" @change="getFloors" style="width:320px;">
  59. <el-option
  60. v-for="dict in buildings"
  61. :key="dict.deptId"
  62. :label="dict.deptName"
  63. :value="dict.deptId"
  64. ></el-option>
  65. </el-select>
  66. </el-form-item>
  67. <el-form-item label="楼层" prop="floorId" class="form-item">
  68. <el-select v-model="form.floorId" placeholder="请选择层数" @change="getLayouts" style="width:320px;">
  69. <el-option
  70. v-for="dict in floors"
  71. :key="dict.id"
  72. :label="dict.name"
  73. :value="dict.id"
  74. ></el-option>
  75. </el-select>
  76. </el-form-item>
  77. <el-form-item label="房间号" prop="room" class="form-item">
  78. <el-input
  79. style="width:320px;"
  80. maxlength="10"
  81. v-model="form.room"
  82. placeholder="请输房间号"
  83. clearable
  84. size="small"
  85. />
  86. </el-form-item>
  87. <el-form-item label="准入设备" class="form-item">
  88. <el-select v-model="form.hardwareType" placeholder="请选择整改类型" style="width:320px;" @change="hardwareTypeFun()" >
  89. <el-option label="无" :value="0" />
  90. <el-option label="海康智能门禁" :value="1" />
  91. <el-option label="电子信息牌" :value="2" />
  92. </el-select>
  93. </el-form-item>
  94. <!--<el-form-item label="详细位置" prop="layoutId" class="form-item">-->
  95. <!--<el-select v-model="form.layoutId" placeholder="请选择详细位置" style="width:320px;">-->
  96. <!--<el-option-->
  97. <!--v-for="dict in layoutLists"-->
  98. <!--:key="dict.id"-->
  99. <!--:label="dict.room"-->
  100. <!--:value="dict.id"-->
  101. <!--&gt;</el-option>-->
  102. <!--</el-select>-->
  103. <!--</el-form-item>-->
  104. <div class="title-box">
  105. <p class="left-title">安全信息牌</p>
  106. </div>
  107. <div class="bottom-form-box">
  108. <div class="top-form-box">
  109. <el-form-item label="实验室负责人" prop="adminId" class="form-item" label-width="180px">
  110. <el-select
  111. style="width:500px;"
  112. v-model="form.adminId"
  113. filterable
  114. remote
  115. clearable
  116. reserve-keyword
  117. placeholder="请输入至少2个字符搜索相关人员"
  118. :remote-method="userSelectList"
  119. :loading="loading">
  120. <el-option
  121. v-for="item in optionsUser"
  122. :key="item.userId"
  123. :label="item.nickName"
  124. :value="item.userId">
  125. </el-option>
  126. </el-select>
  127. </el-form-item>
  128. <el-form-item label="安全责任人" prop="safeUserId" class="form-item" label-width="180px">
  129. <el-select
  130. style="width:500px;"
  131. v-model="form.safeUserId"
  132. :multiple-limit="2"
  133. multiple
  134. filterable
  135. remote
  136. clearable
  137. reserve-keyword
  138. placeholder="请输入至少2个字符搜索相关人员"
  139. :remote-method="userSelectListOne"
  140. :loading="loading">
  141. <el-option
  142. v-for="item in optionsUserOne"
  143. :key="item.userId"
  144. :label="item.nickName"
  145. :value="item.userId">
  146. </el-option>
  147. </el-select>
  148. </el-form-item>
  149. </div>
  150. <div class="bottom-form-box">
  151. <el-form-item v-if="item.publicList.length>0" :label="item.classifyName" prop="safeSigns" class="form-item" v-for="(item,index) in safetyInfoList" label-width="180px">
  152. <el-select v-if="item.publicList.length>0" v-model="item.privateList" multiple placeholder="请选择" style="width:500px;">
  153. <el-option
  154. v-for="dict in item.publicList"
  155. :key="dict.id"
  156. :label="dict.infoName"
  157. :value="dict.id"
  158. ></el-option>
  159. </el-select>
  160. </el-form-item>
  161. </div>
  162. </div>
  163. <div class="title-box">
  164. <p class="left-title">实验室简介</p>
  165. </div>
  166. <div class="rich-text">
  167. <UEditor ref="UEditor" :content="form.details" :min-height="192" />
  168. </div>
  169. <div class="bottom-button-box">
  170. <p class="reset-button-one left-button" @click="backPage">取消</p>
  171. <p class="inquire-button-one right-button" @click="upData">提交</p>
  172. </div>
  173. </el-form>
  174. </div>
  175. </template>
  176. <script>
  177. import { listDepartments,listbuildings } from "@/api/system/dept";
  178. import { listClassifiedAll } from "@/api/laboratory/classified";
  179. import { listClasstypeAll } from "@/api/laboratory/classtype";
  180. import { onUselistLayoutByFloorId,onUselistLayoutByFloorIdTwo } from "@/api/laboratory/layout";
  181. import { listFloorByBuildId } from "@/api/laboratory/building";
  182. import { selectTeacherList } from "@/api/system/user";
  183. import { addSubject, getClassifyBySubId, updateSubject } from '@/api/laboratory/subject'
  184. import { labMoldQueryOption } from "@/api/laboratory/subjectClass";
  185. export default {
  186. name: "addSubject",
  187. props:{
  188. subjectData:{},
  189. },
  190. data() {
  191. return {
  192. loading:false,
  193. levelList:[],
  194. typeList:[],
  195. deptOptions:[],
  196. buildings:[],
  197. floors:[],
  198. layoutLists:[],
  199. optionsUser:[],
  200. optionsUserOne:[],
  201. //安全标识
  202. safetyWarning:[],
  203. //主要危险类别
  204. hazardCategory:[],
  205. //风险防控措施
  206. riskMeasure:[],
  207. //灭火要点
  208. extinguishingKeyPoints:[],
  209. //安全信息牌列表信息存储
  210. safetyInfoList:[],
  211. form:{
  212. details:"",
  213. hardwareType:0,
  214. },
  215. hardwareTypeTow:0,//临时存储准入设备状态
  216. // 表单校验
  217. rules: {
  218. name:[
  219. {required: true, message: '请输实验室名称', trigger: 'blur'},
  220. { required: true, message: "请输实验室名称", validator: this.spaceJudgment, trigger: "blur" }
  221. ],
  222. moldId:[
  223. {required: true, message: '请选择类型', trigger: 'blur'}
  224. ],
  225. typeId:[
  226. {required: true, message: '请选择安全分类', trigger: 'blur'}
  227. ],
  228. level:[
  229. {required: true, message: '请选择安全分级', trigger: 'blur'}
  230. ],
  231. deptId:[
  232. {required: true, message: '请选择学院', trigger: 'blur'}
  233. ],
  234. buildId:[
  235. {required: true, message: '请选择楼栋', trigger: 'blur'}
  236. ],
  237. floorId:[
  238. {required: true, message: '请选择层数', trigger: 'blur'}
  239. ],
  240. room:[
  241. {required: true, message: '请输入房间号', trigger: 'blur'}
  242. ],
  243. layoutId:[
  244. {required: true, message: '请选择详细位置', trigger: 'blur'}
  245. ],
  246. },
  247. labMoldList:[],
  248. }
  249. },
  250. created() {
  251. },
  252. mounted(){
  253. this.getDeptList();
  254. this.getListClassifiedAll();
  255. this.getListClasstypeAll();
  256. this.labMoldQueryOption();
  257. if(!this.subjectData.id){
  258. this.getClassifyBySubId();
  259. }
  260. //安全标识字典
  261. this.getDicts("sys_safety_warning").then(response => {
  262. this.safetyWarning = response.data;
  263. });
  264. //主要危险类别
  265. this.getDicts("sys_hazard_category").then(response => {
  266. this.hazardCategory = response.data;
  267. });
  268. //风险防控措施
  269. this.getDicts("sys_risk_measure").then(response => {
  270. this.riskMeasure = response.data;
  271. });
  272. //灭火要点
  273. this.getDicts("sys_extinguishing_key_points").then(response => {
  274. this.extinguishingKeyPoints = response.data;
  275. });
  276. //编辑数据回填
  277. if(this.subjectData.id){
  278. this.$set(this.form,'id',this.subjectData.id)
  279. this.$set(this.form,'name',this.subjectData.name)
  280. this.$set(this.form,'typeId',this.subjectData.typeId)
  281. this.$set(this.form,'level',this.subjectData.level)
  282. this.$set(this.form,'deptId',this.subjectData.deptId)
  283. this.$set(this.form,'buildId',this.subjectData.buildId)
  284. this.$set(this.form,'floorId',this.subjectData.floorId)
  285. this.$set(this.form,'room',this.subjectData.room)
  286. this.$set(this.form,'hardwareType',this.subjectData.hardwareType==null?0:this.subjectData.hardwareType)
  287. this.$set(this,'hardwareTypeTow',this.subjectData.hardwareType==null?0:this.subjectData.hardwareType)
  288. this.$set(this.form,'details',this.subjectData.details)
  289. this.$refs.UEditor.text=unescape(this.subjectData.details)
  290. this.$set(this.form,'moldId',this.subjectData.moldId)
  291. this.$set(this.form,'room',this.subjectData.room)
  292. this.$set(this.form,'details',this.subjectData.details)
  293. this.$refs.UEditor.text=unescape(this.subjectData.details)
  294. if(this.subjectData.adminId){
  295. this.$set(this.form,'adminId',this.subjectData.adminId)
  296. this.userSelectList(this.subjectData.adminName);
  297. }
  298. if(this.subjectData.safeSigns){
  299. this.$set(this.form,'safeSigns',this.subjectData.safeSigns.split(','))
  300. }
  301. if(this.subjectData.riskMeasure){
  302. this.$set(this.form,'riskMeasure',this.subjectData.riskMeasure.split(','))
  303. }
  304. if(this.subjectData.hazardCategory){
  305. this.$set(this.form,'hazardCategory',this.subjectData.hazardCategory.split(','))
  306. }
  307. if(this.subjectData.outfire){
  308. this.$set(this.form,'outfire',this.subjectData.outfire.split(','))
  309. }
  310. if(this.subjectData.safeUserId){
  311. let list = [];
  312. let safeUserIdList = [];
  313. let nameList = "";
  314. if(this.subjectData.safeUserName){
  315. nameList = this.subjectData.safeUserName.split(",");
  316. }
  317. let idList = "";
  318. if(this.subjectData.safeUserId){
  319. idList = this.subjectData.safeUserId.split(",");
  320. }
  321. for(let i=0;i<nameList.length;i++){
  322. safeUserIdList.push(parseInt(idList[i]))
  323. let obj = {
  324. nickName:nameList[i],
  325. userId:parseInt(idList[i]),
  326. };
  327. list.push(obj)
  328. }
  329. this.optionsUserOne = list;
  330. this.$set(this.form, 'safeUserId', safeUserIdList);
  331. }
  332. //安全信息牌
  333. if(this.subjectData.classifyList){
  334. //循环取安全信息牌信息
  335. let list=this.subjectData.classifyList
  336. for(let i=0;i<list.length;i++){
  337. let list2=[];
  338. if(list[i].privateList.length>0){
  339. for(let b=0;b<list[i].privateList.length;b++){
  340. list2.push(list[i].privateList[b].id)
  341. }
  342. list[i].privateList=list2
  343. }
  344. }
  345. this.safetyInfoList=list
  346. }
  347. //根据学院获取楼栋
  348. listbuildings(this.form.deptId).then(response => {
  349. this.buildings = response.data;
  350. //根据楼栋获取层
  351. listFloorByBuildId(this.form.buildId).then(response=>{
  352. this.floors = response.data;
  353. //根据层获取实验室
  354. // onUselistLayoutByFloorIdTwo(this.form.floorId,this.form.layoutId).then(response=>{
  355. // this.layoutLists = response.data;
  356. // });
  357. });
  358. });
  359. }
  360. },
  361. methods:{
  362. hardwareTypeFun(){
  363. if(this.hardwareTypeTow==1 && this.subjectData.hKCount>0){
  364. this.msgError("删除现有准入设备后,才能更改准入设备类型!");
  365. this.form.hardwareType=this.hardwareTypeTow
  366. }else if(this.hardwareTypeTow==2 && this.subjectData.cardInfoCount>0){
  367. this.msgError("删除现有准入设备后,才能更改准入设备类型!");
  368. this.form.hardwareType=this.hardwareTypeTow
  369. }else{
  370. console.log(this.form.hardwareType)
  371. }
  372. },
  373. //获取实验室类型列表
  374. labMoldQueryOption(){
  375. labMoldQueryOption({}).then(response => {
  376. this.$set(this,'labMoldList',response.data);
  377. });
  378. },
  379. upData(){
  380. let self = this;
  381. this.$set(this.form,'details',this.$refs.UEditor.text);
  382. this.$refs["form"].validate(valid => {
  383. if (valid) {
  384. self.$confirm('是否确认提交?', "", {
  385. confirmButtonText: "确定",
  386. cancelButtonText: "取消",
  387. type: "warning"
  388. }).then(function() {
  389. if(self.form.hazardCategory) {
  390. self.form.hazardCategory = self.form.hazardCategory.join() ;
  391. }
  392. if(self.form.outfire) {
  393. self.form.outfire = self.form.outfire.join() ;
  394. }
  395. if(self.form.riskMeasure) {
  396. self.form.riskMeasure = self.form.riskMeasure.join() ;
  397. }
  398. if(self.form.safeSigns) {
  399. self.form.safeSigns = self.form.safeSigns.join() ;
  400. }
  401. if(self.form.safeUserId) {
  402. self.form.safeUserId = self.form.safeUserId.join() ;
  403. }
  404. //循环取安全信息牌信息
  405. let list=[]
  406. for(let i=0;i<self.safetyInfoList.length;i++){
  407. let list2=[];
  408. if(self.safetyInfoList[i].privateList && self.safetyInfoList[i].privateList.length>0){
  409. for(let b=0;b<self.safetyInfoList[i].privateList.length;b++){
  410. list2.push({id:self.safetyInfoList[i].privateList[b]})
  411. }
  412. list.push({id:self.safetyInfoList[i].id,privateDetailList:list2})
  413. }
  414. }
  415. self.form.classifyList=list
  416. if(self.form.id){
  417. self.updateSubject();
  418. }else{
  419. self.addSubject();
  420. }
  421. }).then(() => {}).catch(() => {});
  422. }
  423. })
  424. },
  425. //新增实验室
  426. addSubject(){
  427. this.form.details = escape(this.form.details);
  428. addSubject(this.form).then(response => {
  429. this.msgSuccess("新增成功");
  430. this.$parent.clickPage(1);
  431. });
  432. },
  433. //修改实验室
  434. updateSubject(){
  435. this.form.details = escape(this.form.details);
  436. updateSubject(this.form).then(response => {
  437. this.msgSuccess("修改成功");
  438. this.$parent.clickPage(1);
  439. });
  440. },
  441. backPage(){
  442. this.$parent.clickPage(1);
  443. },
  444. /** 查询学院列表 */
  445. getDeptList() {
  446. listDepartments().then(response => {
  447. this.$set(this, 'deptOptions', response.data)
  448. });
  449. },
  450. /** 查询楼栋列表 */
  451. getBuildings(id) {
  452. if(id) {
  453. this.$set(this.form, 'buildId', '');//楼栋
  454. this.buildings = [];
  455. this.$set(this.form, 'floorId', '');//楼层
  456. this.floors = [];
  457. // this.$set(this.form, 'layoutId', '');//房间
  458. this.layoutLists = [];
  459. listbuildings(id).then(response => {
  460. this.buildings = response.data;
  461. });
  462. }
  463. },
  464. //查询楼层
  465. getFloors(id) {
  466. if(id) {
  467. this.$set(this.form, 'floorId', '');//楼层
  468. this.floors = [];
  469. // this.$set(this.form, 'layoutId', '');//房间
  470. this.layoutLists = [];
  471. listFloorByBuildId(id).then(response=>{
  472. this.floors = response.data;
  473. });
  474. }
  475. },
  476. //查询布局信息
  477. getLayouts(id) {
  478. if(id) {
  479. // this.$set(this.form, 'layoutId', '');//房间
  480. this.layoutLists = [];
  481. onUselistLayoutByFloorId(id).then(response=>{
  482. this.layoutLists = response.data;
  483. });
  484. }
  485. },
  486. //获取分级
  487. getListClassifiedAll(){
  488. listClassifiedAll().then(response=>{
  489. if(response.code==200){
  490. this.levelList = response.data
  491. }
  492. })
  493. },
  494. //获取分类
  495. getListClasstypeAll(){
  496. listClasstypeAll().then(response=>{
  497. if(response.code==200){
  498. this.typeList = response.data;
  499. }
  500. });
  501. },
  502. //获取电子信息牌下拉列表数据
  503. getClassifyBySubId(){
  504. getClassifyBySubId().then(response=>{
  505. if(response.code==200){
  506. this.safetyInfoList=response.data;
  507. }
  508. });
  509. },
  510. /** 下列人员-懒加载 */
  511. userSelectList(query) {
  512. if (query !== '' && query.length>1) {
  513. selectTeacherList({"nickName":query}).then(response => {
  514. this.optionsUser = response.data;
  515. });
  516. } else {
  517. this.optionsUser = [];
  518. }
  519. },
  520. userSelectListOne(query) {
  521. if (query !== '' && query.length>1) {
  522. this.userSelectListOne.nickName=query;
  523. selectTeacherList(this.userSelectListOne).then(response => {
  524. this.optionsUserOne = response.data;
  525. });
  526. } else {
  527. this.optionsUserOne = [];
  528. }
  529. },
  530. }
  531. }
  532. </script>
  533. <style scoped lang="scss">
  534. .addSubject{
  535. flex:1;
  536. display: flex;
  537. flex-direction: column;
  538. border-radius:10px!important;
  539. margin:5px 20px 20px 10px!important;
  540. box-shadow: 0 0 8px 1px rgba(0, 0, 0, 0.1) !important;
  541. *{
  542. margin:0;
  543. }
  544. .title-box{
  545. display: flex;
  546. margin:0 20px 30px;
  547. border-bottom:1px solid #E0E0E0;
  548. .left-title{
  549. flex:1;
  550. height:80px;
  551. line-height:80px;
  552. color:#0045AF;
  553. font-size:18px;
  554. }
  555. .right-button{
  556. margin:20px 0;
  557. }
  558. }
  559. .form-item{
  560. display: inline-block;
  561. overflow: hidden;
  562. min-height:70px;
  563. }
  564. .bottom-form-box{
  565. //display: flex;
  566. .left-form-box{
  567. width:650px;
  568. }
  569. .right-form-box{
  570. width:650px;
  571. }
  572. .form-item{
  573. display: inline-block;
  574. overflow: hidden;
  575. min-height:40px;
  576. margin-bottom:30px;
  577. }
  578. }
  579. .rich-text{
  580. margin: 20px;
  581. }
  582. .bottom-button-box{
  583. display: flex;
  584. width:400px;
  585. margin:10px auto 40px;
  586. .null-p{
  587. flex:1;
  588. }
  589. .left-button{
  590. margin-right:20px;
  591. }
  592. }
  593. }
  594. </style>