addSubject.vue 18 KB

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