addSubject.vue 19 KB

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