addSubject.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  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:230px;">
  89. <el-option label="无" :value=null />
  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:null,
  214. },
  215. // 表单校验
  216. rules: {
  217. name:[
  218. {required: true, message: '请输实验室名称', trigger: 'blur'},
  219. { required: true, message: "请输实验室名称", validator: this.spaceJudgment, trigger: "blur" }
  220. ],
  221. moldId:[
  222. {required: true, message: '请选择类型', trigger: 'blur'}
  223. ],
  224. typeId:[
  225. {required: true, message: '请选择安全分类', trigger: 'blur'}
  226. ],
  227. level:[
  228. {required: true, message: '请选择安全分级', trigger: 'blur'}
  229. ],
  230. deptId:[
  231. {required: true, message: '请选择学院', trigger: 'blur'}
  232. ],
  233. buildId:[
  234. {required: true, message: '请选择楼栋', trigger: 'blur'}
  235. ],
  236. floorId:[
  237. {required: true, message: '请选择层数', trigger: 'blur'}
  238. ],
  239. room:[
  240. {required: true, message: '请输入房间号', trigger: 'blur'}
  241. ],
  242. layoutId:[
  243. {required: true, message: '请选择详细位置', trigger: 'blur'}
  244. ],
  245. },
  246. labMoldList:[],
  247. }
  248. },
  249. created() {
  250. },
  251. mounted(){
  252. this.getDeptList();
  253. this.getListClassifiedAll();
  254. this.getListClasstypeAll();
  255. this.labMoldQueryOption();
  256. if(!this.subjectData.id){
  257. this.getClassifyBySubId();
  258. }
  259. //安全标识字典
  260. this.getDicts("sys_safety_warning").then(response => {
  261. this.safetyWarning = response.data;
  262. });
  263. //主要危险类别
  264. this.getDicts("sys_hazard_category").then(response => {
  265. this.hazardCategory = response.data;
  266. });
  267. //风险防控措施
  268. this.getDicts("sys_risk_measure").then(response => {
  269. this.riskMeasure = response.data;
  270. });
  271. //灭火要点
  272. this.getDicts("sys_extinguishing_key_points").then(response => {
  273. this.extinguishingKeyPoints = response.data;
  274. });
  275. //编辑数据回填
  276. if(this.subjectData.id){
  277. this.$set(this.form,'id',this.subjectData.id)
  278. this.$set(this.form,'name',this.subjectData.name)
  279. this.$set(this.form,'typeId',this.subjectData.typeId)
  280. this.$set(this.form,'level',this.subjectData.level)
  281. this.$set(this.form,'deptId',this.subjectData.deptId)
  282. this.$set(this.form,'buildId',this.subjectData.buildId)
  283. this.$set(this.form,'floorId',this.subjectData.floorId)
  284. this.$set(this.form,'room',this.subjectData.room)
  285. this.$set(this.form,'hardwareType',this.subjectData.hardwareType)
  286. this.$set(this.form,'details',this.subjectData.details)
  287. this.$refs.UEditor.text=unescape(this.subjectData.details)
  288. // this.$set(this.form,'layoutId',this.subjectData.layoutId)
  289. this.$set(this.form,'moldId',this.subjectData.moldId)
  290. if(this.subjectData.adminId){
  291. this.$set(this.form,'adminId',this.subjectData.adminId)
  292. this.userSelectList(this.subjectData.adminName);
  293. }
  294. if(this.subjectData.safeSigns){
  295. this.$set(this.form,'safeSigns',this.subjectData.safeSigns.split(','))
  296. }
  297. if(this.subjectData.riskMeasure){
  298. this.$set(this.form,'riskMeasure',this.subjectData.riskMeasure.split(','))
  299. }
  300. if(this.subjectData.hazardCategory){
  301. this.$set(this.form,'hazardCategory',this.subjectData.hazardCategory.split(','))
  302. }
  303. if(this.subjectData.outfire){
  304. this.$set(this.form,'outfire',this.subjectData.outfire.split(','))
  305. }
  306. if(this.subjectData.safeUserId){
  307. let list = [];
  308. let safeUserIdList = [];
  309. let nameList = "";
  310. if(this.subjectData.safeUserName){
  311. nameList = this.subjectData.safeUserName.split(",");
  312. }
  313. let idList = "";
  314. if(this.subjectData.safeUserId){
  315. idList = this.subjectData.safeUserId.split(",");
  316. }
  317. for(let i=0;i<nameList.length;i++){
  318. safeUserIdList.push(parseInt(idList[i]))
  319. let obj = {
  320. nickName:nameList[i],
  321. userId:parseInt(idList[i]),
  322. };
  323. list.push(obj)
  324. }
  325. this.optionsUserOne = list;
  326. this.$set(this.form, 'safeUserId', safeUserIdList);
  327. }
  328. //安全信息牌
  329. if(this.subjectData.classifyList){
  330. //循环取安全信息牌信息
  331. let list=this.subjectData.classifyList
  332. for(let i=0;i<list.length;i++){
  333. let list2=[];
  334. if(list[i].privateList.length>0){
  335. for(let b=0;b<list[i].privateList.length;b++){
  336. list2.push(list[i].privateList[b].id)
  337. }
  338. list[i].privateList=list2
  339. }
  340. }
  341. this.safetyInfoList=list
  342. }
  343. //根据学院获取楼栋
  344. listbuildings(this.form.deptId).then(response => {
  345. this.buildings = response.data;
  346. //根据楼栋获取层
  347. listFloorByBuildId(this.form.buildId).then(response=>{
  348. this.floors = response.data;
  349. //根据层获取实验室
  350. // onUselistLayoutByFloorIdTwo(this.form.floorId,this.form.layoutId).then(response=>{
  351. // this.layoutLists = response.data;
  352. // });
  353. });
  354. });
  355. }
  356. },
  357. methods:{
  358. //获取实验室类型列表
  359. labMoldQueryOption(){
  360. labMoldQueryOption({}).then(response => {
  361. this.$set(this,'labMoldList',response.data);
  362. });
  363. },
  364. upData(){
  365. let self = this;
  366. this.$set(this.form,'details',this.$refs.UEditor.text);
  367. this.$refs["form"].validate(valid => {
  368. if (valid) {
  369. self.$confirm('是否确认提交?', "", {
  370. confirmButtonText: "确定",
  371. cancelButtonText: "取消",
  372. type: "warning"
  373. }).then(function() {
  374. if(self.form.hazardCategory) {
  375. self.form.hazardCategory = self.form.hazardCategory.join() ;
  376. }
  377. if(self.form.outfire) {
  378. self.form.outfire = self.form.outfire.join() ;
  379. }
  380. if(self.form.riskMeasure) {
  381. self.form.riskMeasure = self.form.riskMeasure.join() ;
  382. }
  383. if(self.form.safeSigns) {
  384. self.form.safeSigns = self.form.safeSigns.join() ;
  385. }
  386. if(self.form.safeUserId) {
  387. self.form.safeUserId = self.form.safeUserId.join() ;
  388. }
  389. //循环取安全信息牌信息
  390. let list=[]
  391. for(let i=0;i<self.safetyInfoList.length;i++){
  392. let list2=[];
  393. if(self.safetyInfoList[i].privateList && self.safetyInfoList[i].privateList.length>0){
  394. for(let b=0;b<self.safetyInfoList[i].privateList.length;b++){
  395. list2.push({id:self.safetyInfoList[i].privateList[b]})
  396. }
  397. list.push({id:self.safetyInfoList[i].id,privateDetailList:list2})
  398. }
  399. }
  400. self.form.classifyList=list
  401. if(self.form.id){
  402. self.updateSubject();
  403. }else{
  404. self.addSubject();
  405. }
  406. }).then(() => {}).catch(() => {});
  407. }
  408. })
  409. },
  410. //新增实验室
  411. addSubject(){
  412. this.form.details = escape(this.form.details);
  413. addSubject(this.form).then(response => {
  414. this.msgSuccess("新增成功");
  415. this.$parent.clickPage(1);
  416. });
  417. },
  418. //修改实验室
  419. updateSubject(){
  420. this.form.details = escape(this.form.details);
  421. updateSubject(this.form).then(response => {
  422. this.msgSuccess("修改成功");
  423. this.$parent.clickPage(1);
  424. });
  425. },
  426. backPage(){
  427. this.$parent.clickPage(1);
  428. },
  429. /** 查询学院列表 */
  430. getDeptList() {
  431. listDepartments().then(response => {
  432. this.$set(this, 'deptOptions', response.data)
  433. });
  434. },
  435. /** 查询楼栋列表 */
  436. getBuildings(id) {
  437. if(id) {
  438. this.$set(this.form, 'buildId', '');//楼栋
  439. this.buildings = [];
  440. this.$set(this.form, 'floorId', '');//楼层
  441. this.floors = [];
  442. // this.$set(this.form, 'layoutId', '');//房间
  443. this.layoutLists = [];
  444. listbuildings(id).then(response => {
  445. this.buildings = response.data;
  446. });
  447. }
  448. },
  449. //查询楼层
  450. getFloors(id) {
  451. if(id) {
  452. this.$set(this.form, 'floorId', '');//楼层
  453. this.floors = [];
  454. // this.$set(this.form, 'layoutId', '');//房间
  455. this.layoutLists = [];
  456. listFloorByBuildId(id).then(response=>{
  457. this.floors = response.data;
  458. });
  459. }
  460. },
  461. //查询布局信息
  462. getLayouts(id) {
  463. if(id) {
  464. // this.$set(this.form, 'layoutId', '');//房间
  465. this.layoutLists = [];
  466. onUselistLayoutByFloorId(id).then(response=>{
  467. this.layoutLists = response.data;
  468. });
  469. }
  470. },
  471. //获取分级
  472. getListClassifiedAll(){
  473. listClassifiedAll().then(response=>{
  474. if(response.code==200){
  475. this.levelList = response.data
  476. }
  477. })
  478. },
  479. //获取分类
  480. getListClasstypeAll(){
  481. listClasstypeAll().then(response=>{
  482. if(response.code==200){
  483. this.typeList = response.data;
  484. }
  485. });
  486. },
  487. //获取电子信息牌下拉列表数据
  488. getClassifyBySubId(){
  489. getClassifyBySubId().then(response=>{
  490. if(response.code==200){
  491. this.safetyInfoList=response.data;
  492. }
  493. });
  494. },
  495. /** 下列人员-懒加载 */
  496. userSelectList(query) {
  497. if (query !== '' && query.length>1) {
  498. selectTeacherList({"nickName":query}).then(response => {
  499. this.optionsUser = response.data;
  500. });
  501. } else {
  502. this.optionsUser = [];
  503. }
  504. },
  505. userSelectListOne(query) {
  506. if (query !== '' && query.length>1) {
  507. this.userSelectListOne.nickName=query;
  508. selectTeacherList(this.userSelectListOne).then(response => {
  509. this.optionsUserOne = response.data;
  510. });
  511. } else {
  512. this.optionsUserOne = [];
  513. }
  514. },
  515. }
  516. }
  517. </script>
  518. <style scoped lang="scss">
  519. .addSubject{
  520. flex:1;
  521. display: flex;
  522. flex-direction: column;
  523. border-radius:10px!important;
  524. margin:5px 20px 20px 10px!important;
  525. box-shadow: 0 0 8px 1px rgba(0, 0, 0, 0.1) !important;
  526. *{
  527. margin:0;
  528. }
  529. .title-box{
  530. display: flex;
  531. margin:0 20px 30px;
  532. border-bottom:1px solid #E0E0E0;
  533. .left-title{
  534. flex:1;
  535. height:80px;
  536. line-height:80px;
  537. color:#0045AF;
  538. font-size:18px;
  539. }
  540. .right-button{
  541. margin:20px 0;
  542. }
  543. }
  544. .form-item{
  545. display: inline-block;
  546. overflow: hidden;
  547. min-height:70px;
  548. }
  549. .bottom-form-box{
  550. //display: flex;
  551. .left-form-box{
  552. width:650px;
  553. }
  554. .right-form-box{
  555. width:650px;
  556. }
  557. .form-item{
  558. display: inline-block;
  559. overflow: hidden;
  560. min-height:40px;
  561. margin-bottom:30px;
  562. }
  563. }
  564. .rich-text{
  565. margin: 20px;
  566. }
  567. .bottom-button-box{
  568. display: flex;
  569. width:400px;
  570. margin:10px auto 40px;
  571. .null-p{
  572. flex:1;
  573. }
  574. .left-button{
  575. margin-right:20px;
  576. }
  577. }
  578. }
  579. </style>