index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <!--布局管理-->
  2. <template>
  3. <div class="app-container building">
  4. <div class="left-max-box">
  5. <el-tree :data="deptOptions" :props="defaultProps"
  6. accordion @node-click="handleNodeClick">
  7. </el-tree>
  8. </div>
  9. <div class="right-max-box">
  10. <p class="right-top-title color_33" v-if="rightDataList[0]">{{rightTitle}}</p>
  11. <div class="map-img-box border-solid-color-99" v-if="rightDataList[0]">
  12. <div class="map-max-box map-one-max-box" v-for="(item,index) in rightDataList" :key="index" v-if="index == fatherIndex">
  13. <!--<div class="map-max-box map-seven-max-box" v-for="(item,index) in rightDataList" :key="index" v-if="index == fatherIndex">-->
  14. <div class="map-min-box for-box" v-for="(minItem,minIndex) in item.list" :key="minIndex">
  15. <p>{{minItem.isSubject == 1?minItem.room:minItem.room}}</p>
  16. <p @click.stop="shadeClick(minItem)">点击编辑</p>
  17. </div>
  18. </div>
  19. </div>
  20. <div class="carousel" v-if="rightDataList[0]">
  21. <p class="button-box el-icon-arrow-left cursor_hover" @click="minMapButton('left')" v-if="rightDataList[1]"></p>
  22. <div class="for-max-box">
  23. <div class="for-min-box" v-for="(item,index) in rightDataList" :key="index" @click="">
  24. <div class="img-box" :class="fatherIndex==index?'border-solid-color-one':'border-solid-color-99'" @click="minMapClick(index)">
  25. <img src="@/assets/ZDimages/icon_bj_syspmtcy_jinan.png">
  26. </div>
  27. <p>{{item.name}}</p>
  28. </div>
  29. </div>
  30. <p class="button-box el-icon-arrow-right cursor_hover" @click="minMapButton('right')" v-if="rightDataList[1]"></p>
  31. </div>
  32. <img class="null-p-img" src="@/assets/ZDimages/null-data.png" v-if="!rightDataList[0]">
  33. <p class="null-p-text" v-if="!rightDataList[0]">暂无数据</p>
  34. </div>
  35. <el-dialog title="修改房间信息" :visible.sync="open" width="500px" append-to-body>
  36. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  37. <el-form-item label="房间编号" prop="joinUserId">
  38. <el-input v-model="form.room" placeholder="请输入房间编号" />
  39. </el-form-item>
  40. <el-form-item label="房间类型">
  41. <el-radio-group v-model="form.isSubject">
  42. <el-radio label="0">非实验室</el-radio>
  43. <el-radio label="1">实验室</el-radio>
  44. </el-radio-group>
  45. </el-form-item>
  46. </el-form>
  47. <div slot="footer" class="dialog-footer">
  48. <el-button @click="cancel">取 消</el-button>
  49. <el-button type="primary" @click="submitForm">确 定</el-button>
  50. </div>
  51. </el-dialog>
  52. </div>
  53. </template>
  54. <script>
  55. import { getBuilding,listBuilding, updateSubject } from "@/api/laboratory/building";
  56. import { treeselect } from "@/api/system/dept";
  57. export default {
  58. name: "Building",
  59. data() {
  60. return {
  61. // 遮罩层
  62. loading: true,
  63. // 选中数组
  64. ids: [],
  65. // 非单个禁用
  66. single: true,
  67. // 非多个禁用
  68. multiple: true,
  69. // 显示搜索条件
  70. showSearch: true,
  71. // 总条数
  72. total: 0,
  73. // 楼栋表格数据
  74. buildingList: [],
  75. // 弹出层标题
  76. title: "",
  77. // 是否显示弹出层
  78. open: false,
  79. // 查询参数
  80. queryParams: {
  81. pageNum: 1,
  82. pageSize:20,
  83. name: null,
  84. type: null,
  85. parentId: null,
  86. deptId: null,
  87. deptName: null,
  88. userId: null,
  89. },
  90. // 表单参数
  91. form: {
  92. room:"",
  93. isSubject:"",
  94. },
  95. // 表单校验
  96. rules: {
  97. room:[
  98. {required: true, message: '请输入房间编号', trigger: 'blur'},
  99. { required: true, message: "请输入房间编号", validator: this.spaceJudgment, trigger: "blur" }
  100. ],
  101. isSubject:[
  102. {required: true, message: '请选择实验室类型', trigger: 'blur'}
  103. ],
  104. },
  105. //左侧列表数据
  106. deptOptions:[],
  107. defaultProps:{
  108. children: 'children',
  109. label: 'label'
  110. },
  111. //右侧数据
  112. rightDataList:[],
  113. //左侧列表选装状态
  114. fatherIndex:0,
  115. // 楼宇id
  116. buildingId:"",
  117. //名称
  118. rightTitle:"",
  119. };
  120. },
  121. created() {
  122. this.getList();
  123. this.getTreeselect();
  124. },
  125. methods: {
  126. //点击修改
  127. shadeClick(item){
  128. if(item){
  129. this.form = {...item};
  130. this.form.isSubject = ''+item.isSubject;
  131. this.$forceUpdate();
  132. this.open = true;
  133. console.log("item",item)
  134. }
  135. },
  136. /** 查询部门下拉树结构 */
  137. getTreeselect() {
  138. this.loading = true;
  139. treeselect().then(response => {
  140. this.deptOptions = response.data;
  141. if(this.deptOptions[0].children){
  142. if(this.deptOptions[0].children[0].children){
  143. this.buildingId = this.deptOptions[0].children[0].children[0].id;
  144. }else{
  145. this.buildingId = this.deptOptions[0].children[0].id;
  146. }
  147. }else{
  148. this.buildingId = this.deptOptions[0].id;
  149. }
  150. this.getBuilding();
  151. this.loading = false;
  152. });
  153. },
  154. //树结构选中
  155. handleNodeClick(data) {
  156. if(!data.children){
  157. console.log(data);
  158. this.buildingId = data.id;
  159. this.getBuilding();
  160. }
  161. },
  162. //获取楼宇数据
  163. getBuilding(){
  164. this.loading = true;
  165. getBuilding(this.buildingId).then(response => {
  166. this.rightDataList = response.data;
  167. this.rightTitle = this.rightDataList[this.fatherIndex].remark +' '+ this.rightDataList[this.fatherIndex].name;
  168. this.loading = false;
  169. });
  170. },
  171. minMapClick(index){
  172. if (this.fatherIndex!=index){
  173. this.fatherIndex = index;
  174. this.rightTitle = this.rightDataList[index].remark +' '+ this.rightDataList[index].name;
  175. }
  176. },
  177. minMapButton(type){
  178. if(type=='left'){
  179. if (this.fatherIndex>0){
  180. this.fatherIndex--
  181. }
  182. }else if(type=='right'){
  183. if (this.fatherIndex<this.rightDataList.length-1){
  184. this.fatherIndex++
  185. }
  186. }
  187. this.rightTitle = this.rightDataList[this.fatherIndex].remark +' '+ this.rightDataList[this.fatherIndex].name;
  188. this.$forceUpdate();
  189. },
  190. /** 查询楼栋列表 */
  191. getList() {
  192. this.loading = true;
  193. listBuilding(this.queryParams).then(response => {
  194. this.buildingList = response.rows;
  195. this.total = response.total;
  196. this.loading = false;
  197. });
  198. },
  199. // 取消按钮
  200. cancel() {
  201. this.open = false;
  202. this.reset();
  203. },
  204. // 表单重置
  205. reset() {
  206. this.form = {
  207. room: null,
  208. isSubject: null,
  209. id: null,
  210. };
  211. this.resetForm("form");
  212. },
  213. /** 提交按钮 */
  214. submitForm() {
  215. this.$refs["form"].validate(valid => {
  216. if (valid) {
  217. if (this.form.id != null) {
  218. let obj = {
  219. id:this.form.id,
  220. room: this.form.room,
  221. isSubject: this.form.isSubject,
  222. };
  223. updateSubject(obj).then(response => {
  224. this.msgSuccess("修改成功");
  225. this.open = false;
  226. this.reset();
  227. this.getBuilding();
  228. });
  229. }
  230. }
  231. });
  232. },
  233. }
  234. };
  235. </script>
  236. <style scoped lang="scss">
  237. .building {
  238. display: flex!important;
  239. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  240. padding:11px 20px!important;
  241. .el-row{
  242. margin-bottom:20px;
  243. }
  244. .left-max-box{
  245. width:245px;
  246. }
  247. .right-max-box{
  248. flex:1;
  249. display: flex;
  250. flex-direction: column;
  251. .right-top-title{
  252. text-align: center;
  253. font-size:18px;
  254. margin:17px 0 0 0;
  255. line-height:109px;
  256. }
  257. .map-img-box{
  258. flex:1;
  259. margin:0 30px;
  260. position: relative;
  261. .map-max-box{
  262. position: absolute;
  263. top:50%;
  264. left:50%;
  265. display: block;
  266. width:806px;
  267. height:360px;
  268. margin-left:-395px;
  269. margin-top:-180px;
  270. }
  271. }
  272. .carousel{
  273. height:184px;
  274. display: flex;
  275. /*width: 1030px;*/
  276. margin: 0 auto;
  277. .button-box{
  278. width:40px;
  279. height:40px;
  280. margin:66px 50px 0;
  281. background: #cce6fd;
  282. color: #fff;
  283. text-align: center;
  284. line-height:40px;
  285. font-size:14px;
  286. -webkit-border-radius: 50%;
  287. -moz-border-radius: 50%;
  288. border-radius: 50%;
  289. }
  290. .button-box:hover{
  291. background: #0183FA;
  292. color: #fff;
  293. }
  294. .for-max-box{
  295. display: flex;
  296. flex:1;
  297. cursor:pointer;
  298. .for-min-box{
  299. margin:0 20px;
  300. div{
  301. padding:10px;
  302. width:210px;
  303. height:109px;
  304. margin-top:29px;
  305. img{
  306. width:190px;
  307. height:89px;
  308. }
  309. }
  310. p{
  311. line-height:45px;
  312. font-size:16px;
  313. text-align: center;
  314. margin:0;
  315. }
  316. }
  317. }
  318. }
  319. .null-p-img{
  320. width:276px;
  321. height:274px;
  322. margin:200px auto 0;
  323. }
  324. .null-p-text{
  325. text-align:center;
  326. font-size:16px;
  327. color:#999;
  328. line-height:40px;
  329. margin-right:70px;
  330. }
  331. }
  332. }
  333. </style>