addSubject.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  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" v-if="versionField() != 'xiBeiNongLinDaXue'">
  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. if(this.subjectData.adminId){
  292. this.$set(this.form,'adminId',this.subjectData.adminId)
  293. this.userSelectList(this.subjectData.adminName);
  294. }
  295. if(this.subjectData.safeSigns){
  296. this.$set(this.form,'safeSigns',this.subjectData.safeSigns.split(','))
  297. }
  298. if(this.subjectData.riskMeasure){
  299. this.$set(this.form,'riskMeasure',this.subjectData.riskMeasure.split(','))
  300. }
  301. if(this.subjectData.hazardCategory){
  302. this.$set(this.form,'hazardCategory',this.subjectData.hazardCategory.split(','))
  303. }
  304. if(this.subjectData.outfire){
  305. this.$set(this.form,'outfire',this.subjectData.outfire.split(','))
  306. }
  307. if(this.subjectData.safeUserId){
  308. let list = [];
  309. let safeUserIdList = [];
  310. let nameList = "";
  311. if(this.subjectData.safeUserName){
  312. nameList = this.subjectData.safeUserName.split(",");
  313. }
  314. let idList = "";
  315. if(this.subjectData.safeUserId){
  316. idList = this.subjectData.safeUserId.split(",");
  317. }
  318. for(let i=0;i<nameList.length;i++){
  319. safeUserIdList.push(parseInt(idList[i]))
  320. let obj = {
  321. nickName:nameList[i],
  322. userId:parseInt(idList[i]),
  323. };
  324. list.push(obj)
  325. }
  326. this.optionsUserOne = list;
  327. this.$set(this.form, 'safeUserId', safeUserIdList);
  328. }
  329. //安全信息牌
  330. if(this.subjectData.classifyList){
  331. //循环取安全信息牌信息
  332. let list=this.subjectData.classifyList
  333. for(let i=0;i<list.length;i++){
  334. let list2=[];
  335. if(list[i].privateList.length>0){
  336. for(let b=0;b<list[i].privateList.length;b++){
  337. list2.push(list[i].privateList[b].id)
  338. }
  339. list[i].privateList=list2
  340. }
  341. }
  342. this.safetyInfoList=list
  343. }
  344. //根据学院获取楼栋
  345. listbuildings(this.form.deptId).then(response => {
  346. this.buildings = response.data;
  347. //根据楼栋获取层
  348. listFloorByBuildId(this.form.buildId).then(response=>{
  349. this.floors = response.data;
  350. //根据层获取实验室
  351. // onUselistLayoutByFloorIdTwo(this.form.floorId,this.form.layoutId).then(response=>{
  352. // this.layoutLists = response.data;
  353. // });
  354. });
  355. });
  356. }
  357. },
  358. methods:{
  359. hardwareTypeFun(){
  360. if(this.hardwareTypeTow==1 && this.subjectData.hKCount>0){
  361. this.msgError("删除现有准入设备后,才能更改准入设备类型!");
  362. this.form.hardwareType=this.hardwareTypeTow
  363. }else if(this.hardwareTypeTow==2 && this.subjectData.cardInfoCount>0){
  364. this.msgError("删除现有准入设备后,才能更改准入设备类型!");
  365. this.form.hardwareType=this.hardwareTypeTow
  366. }else{
  367. console.log(this.form.hardwareType)
  368. }
  369. },
  370. //获取实验室类型列表
  371. labMoldQueryOption(){
  372. labMoldQueryOption({}).then(response => {
  373. this.$set(this,'labMoldList',response.data);
  374. });
  375. },
  376. upData(){
  377. let self = this;
  378. this.$set(this.form,'details',this.$refs.UEditor.text);
  379. this.$refs["form"].validate(valid => {
  380. if (valid) {
  381. self.$confirm('是否确认提交?', "", {
  382. confirmButtonText: "确定",
  383. cancelButtonText: "取消",
  384. type: "warning"
  385. }).then(function() {
  386. if(self.form.hazardCategory) {
  387. self.form.hazardCategory = self.form.hazardCategory.join() ;
  388. }
  389. if(self.form.outfire) {
  390. self.form.outfire = self.form.outfire.join() ;
  391. }
  392. if(self.form.riskMeasure) {
  393. self.form.riskMeasure = self.form.riskMeasure.join() ;
  394. }
  395. if(self.form.safeSigns) {
  396. self.form.safeSigns = self.form.safeSigns.join() ;
  397. }
  398. if(self.form.safeUserId) {
  399. self.form.safeUserId = self.form.safeUserId.join() ;
  400. }
  401. //循环取安全信息牌信息
  402. let list=[]
  403. for(let i=0;i<self.safetyInfoList.length;i++){
  404. let list2=[];
  405. if(self.safetyInfoList[i].privateList && self.safetyInfoList[i].privateList.length>0){
  406. for(let b=0;b<self.safetyInfoList[i].privateList.length;b++){
  407. list2.push({id:self.safetyInfoList[i].privateList[b]})
  408. }
  409. list.push({id:self.safetyInfoList[i].id,privateDetailList:list2})
  410. }
  411. }
  412. self.form.classifyList=list
  413. if(self.form.id){
  414. self.updateSubject();
  415. }else{
  416. self.addSubject();
  417. }
  418. }).then(() => {}).catch(() => {});
  419. }
  420. })
  421. },
  422. //新增实验室
  423. addSubject(){
  424. this.form.details = escape(this.form.details);
  425. addSubject(this.form).then(response => {
  426. this.msgSuccess("新增成功");
  427. this.$parent.clickPage(1);
  428. });
  429. },
  430. //修改实验室
  431. updateSubject(){
  432. this.form.details = escape(this.form.details);
  433. updateSubject(this.form).then(response => {
  434. this.msgSuccess("修改成功");
  435. this.$parent.clickPage(1);
  436. });
  437. },
  438. backPage(){
  439. this.$parent.clickPage(1);
  440. },
  441. /** 查询学院列表 */
  442. getDeptList() {
  443. listDepartments().then(response => {
  444. this.$set(this, 'deptOptions', response.data)
  445. });
  446. },
  447. /** 查询楼栋列表 */
  448. getBuildings(id) {
  449. if(id) {
  450. this.$set(this.form, 'buildId', '');//楼栋
  451. this.buildings = [];
  452. this.$set(this.form, 'floorId', '');//楼层
  453. this.floors = [];
  454. // this.$set(this.form, 'layoutId', '');//房间
  455. this.layoutLists = [];
  456. listbuildings(id).then(response => {
  457. this.buildings = response.data;
  458. });
  459. }
  460. },
  461. //查询楼层
  462. getFloors(id) {
  463. if(id) {
  464. this.$set(this.form, 'floorId', '');//楼层
  465. this.floors = [];
  466. // this.$set(this.form, 'layoutId', '');//房间
  467. this.layoutLists = [];
  468. listFloorByBuildId(id).then(response=>{
  469. this.floors = response.data;
  470. });
  471. }
  472. },
  473. //查询布局信息
  474. getLayouts(id) {
  475. if(id) {
  476. // this.$set(this.form, 'layoutId', '');//房间
  477. this.layoutLists = [];
  478. onUselistLayoutByFloorId(id).then(response=>{
  479. this.layoutLists = response.data;
  480. });
  481. }
  482. },
  483. //获取分级
  484. getListClassifiedAll(){
  485. listClassifiedAll().then(response=>{
  486. if(response.code==200){
  487. this.levelList = response.data
  488. }
  489. })
  490. },
  491. //获取分类
  492. getListClasstypeAll(){
  493. listClasstypeAll().then(response=>{
  494. if(response.code==200){
  495. this.typeList = response.data;
  496. }
  497. });
  498. },
  499. //获取电子信息牌下拉列表数据
  500. getClassifyBySubId(){
  501. getClassifyBySubId().then(response=>{
  502. if(response.code==200){
  503. this.safetyInfoList=response.data;
  504. }
  505. });
  506. },
  507. /** 下列人员-懒加载 */
  508. userSelectList(query) {
  509. if (query !== '' && query.length>1) {
  510. selectTeacherList({"nickName":query}).then(response => {
  511. this.optionsUser = response.data;
  512. });
  513. } else {
  514. this.optionsUser = [];
  515. }
  516. },
  517. userSelectListOne(query) {
  518. if (query !== '' && query.length>1) {
  519. this.userSelectListOne.nickName=query;
  520. selectTeacherList(this.userSelectListOne).then(response => {
  521. this.optionsUserOne = response.data;
  522. });
  523. } else {
  524. this.optionsUserOne = [];
  525. }
  526. },
  527. }
  528. }
  529. </script>
  530. <style scoped lang="scss">
  531. .addSubject{
  532. flex:1;
  533. display: flex;
  534. flex-direction: column;
  535. border-radius:10px!important;
  536. margin:5px 20px 20px 10px!important;
  537. box-shadow: 0 0 8px 1px rgba(0, 0, 0, 0.1) !important;
  538. *{
  539. margin:0;
  540. }
  541. .title-box{
  542. display: flex;
  543. margin:0 20px 30px;
  544. border-bottom:1px solid #E0E0E0;
  545. .left-title{
  546. flex:1;
  547. height:80px;
  548. line-height:80px;
  549. color:#0045AF;
  550. font-size:18px;
  551. }
  552. .right-button{
  553. margin:20px 0;
  554. }
  555. }
  556. .form-item{
  557. display: inline-block;
  558. overflow: hidden;
  559. min-height:70px;
  560. }
  561. .bottom-form-box{
  562. //display: flex;
  563. .left-form-box{
  564. width:650px;
  565. }
  566. .right-form-box{
  567. width:650px;
  568. }
  569. .form-item{
  570. display: inline-block;
  571. overflow: hidden;
  572. min-height:40px;
  573. margin-bottom:30px;
  574. }
  575. }
  576. .rich-text{
  577. margin: 20px;
  578. }
  579. .bottom-button-box{
  580. display: flex;
  581. width:400px;
  582. margin:10px auto 40px;
  583. .null-p{
  584. flex:1;
  585. }
  586. .left-button{
  587. margin-right:20px;
  588. }
  589. }
  590. }
  591. </style>