patrolPlanAddLab.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <!-- 安全检查-发起巡查计划-选择实验室 -->
  2. <template>
  3. <view class="examine">
  4. <view class="lab_title">
  5. <picker @change="collegeChange" :value="collegeIndex" :range="collegeArray" class="lab_title_l">
  6. <view class="lab_title_l_n">
  7. <view>{{getData.deptName?getData.deptName:'选择学院'}}</view>
  8. <img src="@/pages_safetyExamine/images/icon_06.png">
  9. </view>
  10. </picker>
  11. <view class="lab_title_r">
  12. <input type="text" v-model="getData.searchValue" placeholder="请输入实验室名称" name="search" @confirm='searchBtn' confirm-type='search' maxlength="50" placeholder-style="color: #CCCCCC;font-size:26rpx;">
  13. <view v-if="getData.searchValue>0" class="lab_title_r_btn" @click="clearBtn">
  14. <img src="@/pages_safetyExamine/images/clear.png"/>
  15. </view>
  16. </view>
  17. </view>
  18. <scroll-view scroll-y @scrolltolower="scrollGet" class="info-max-box">
  19. <view>
  20. <view class="list">
  21. <view class="list_li" v-for="(item,index) in dataList" :key="index" @click="labSelete(index)">
  22. <text :class="item.type?'color_B':'color_A'">{{item.subjectName}}-{{item.roomNumber}}</text>
  23. <img v-if="item.type" src="@/pages_safetyExamine/images/icon_xzwt_xz.png">
  24. </view>
  25. </view>
  26. </view>
  27. </scroll-view>
  28. <view class="bottom_btn" @click="submitForm">保存</view>
  29. </view>
  30. </template>
  31. <script>
  32. import { config } from '@/api/request/config.js'
  33. import {conditionCollegeInfo,conditionSubjectInfo} from '@/api/apiDemo/index.js'
  34. export default {
  35. name: "rectifyList",
  36. components: {
  37. },
  38. data() {
  39. return {
  40. pageType:0,
  41. //列表请求参数
  42. getData:{
  43. pageNum:1,
  44. pageSize:20,
  45. deptId:'',//学院id
  46. deptName:'',
  47. searchValue:'',
  48. selectedSubIds:[],
  49. subIds:[],
  50. },
  51. total:0,
  52. collegeIndex :0,
  53. collegeArray:[],
  54. collegeList:[],
  55. dataList:[],
  56. seleteListLab:[],//临时存储选中的
  57. form:{},
  58. }
  59. },
  60. onLoad(option) {
  61. this.form=JSON.parse(decodeURIComponent(option.form));
  62. if(this.form.seleteListLab.length>0){
  63. this.seleteListLab=this.form.seleteListLab;
  64. }
  65. if(option.pageType){//pageType=1添加页面进入2编辑页面进入
  66. this.pageType=option.pageType
  67. }
  68. },
  69. onShow() {
  70. },
  71. mounted(){
  72. this.dataList=[];
  73. this.conditionCollegeInfo();
  74. this.getList();
  75. },
  76. methods: {
  77. //滚动事件
  78. scrollGet(){
  79. let self=this;
  80. if(self.total/self.getData.pageSize<=self.getData.pageNum){
  81. console.log('没有更多数据!')
  82. }else{
  83. setTimeout(function(){
  84. self.getData.pageNum += 1;
  85. self.getList();
  86. },1000)
  87. }
  88. },
  89. //选择学院
  90. collegeChange(e){
  91. this.collegeIndex = e.target.value;
  92. this.getData.deptId=this.collegeList[e.target.value].deptId
  93. this.getData.deptName=this.collegeList[e.target.value].deptName
  94. this.getData.pageNum=1;
  95. this.dataList=[];
  96. this.getList();
  97. },
  98. //点击选择实验室
  99. labSelete(index){
  100. this.dataList[index].type = !this.dataList[index].type
  101. if(this.dataList[index].type){//判断是选中还是取消
  102. if(this.seleteListLab.length>0){
  103. if(this.seleteListLab.findIndex((item)=>item.subId===this.dataList[index].subId) ==-1){//等于-1说明数组里没有当前选中元素,可以添加
  104. this.seleteListLab.push(this.dataList[index])
  105. }
  106. }else{
  107. this.seleteListLab.push(this.dataList[index])
  108. }
  109. }else{
  110. this.seleteListLab.splice(this.seleteListLab.indexOf(this.dataList[index]),1);
  111. }
  112. },
  113. //实验室搜索
  114. searchBtn(){
  115. this.dataList=[];
  116. this.getList();
  117. },
  118. //清除
  119. clearBtn(){
  120. this.getData.pageNum=1;
  121. this.collegeIndex=0;
  122. this.getData.deptId='';
  123. this.getData.deptName='';
  124. this.getData.searchValue='';
  125. this.dataList=[];
  126. this.getList();
  127. },
  128. handleClick(doType){
  129. let self=this;
  130. if( doType=='subBtn'){//保存数据
  131. }
  132. },
  133. //实验室-保存
  134. async submitForm(){
  135. let _this = this;
  136. let subIds=[];
  137. this.$set(this.form,'subjectNum', this.seleteListLab.length)
  138. this.$set(this.form,'seleteListLab', this.seleteListLab)
  139. if(this.seleteListLab.length>0){
  140. this.seleteListLab.forEach(function(item){
  141. subIds.push(item.subId)
  142. })
  143. this.$set(this.form,'subIds', subIds.join(','))
  144. }
  145. let pages=getCurrentPages();
  146. let prevPage=pages[pages.length-2];//上一个页面
  147. prevPage.onShow(encodeURIComponent(JSON.stringify(this.form)))
  148. uni.navigateBack()
  149. // if(this.pageType==1){
  150. // uni.redirectTo({
  151. // url: '/pages_safetyExamine/patrolPlan/patrolPlanAdd?form='+encodeURIComponent(JSON.stringify(this.form))
  152. // });
  153. // }else if(this.pageType==2){
  154. // uni.redirectTo({
  155. // url: '/pages_safetyExamine/patrolPlan/patrolPlanEdit?form='+encodeURIComponent(JSON.stringify(this.form))
  156. // });
  157. // }
  158. },
  159. //查询学院列表
  160. async conditionCollegeInfo(){
  161. let _this = this;
  162. const {data} = await conditionCollegeInfo();
  163. if(data.code == 200){
  164. for(let i=0;i<data.data.length;i++){
  165. _this.collegeArray.push(data.data[i].deptName)
  166. }
  167. _this.collegeList=data.data;
  168. }
  169. },
  170. async getList(){
  171. let _this = this;
  172. const {data} = await conditionSubjectInfo(_this.getData);
  173. if(data.code==200){
  174. data.rows.forEach(function(item){
  175. item.type=false;
  176. })
  177. this.dataList=[...this.dataList,...data.rows]
  178. _this.total=data.total;
  179. if(this.seleteListLab.length>0){//如果有选中的数据
  180. for(let i=0;i<this.dataList.length;i++){
  181. if(this.seleteListLab.findIndex((item)=>item.subId===this.dataList[i].subId) !=-1){//不等于-1说明数组里有当前元素,可以改为选中
  182. this.dataList[i].type=true;
  183. }else{
  184. }
  185. }
  186. }
  187. }
  188. }
  189. }
  190. }
  191. </script>
  192. <style lang="stylus" scoped>
  193. .examine{
  194. height:100%;
  195. display flex;
  196. .info-max-box{
  197. flex: 1;
  198. overflow: scroll;
  199. padding: 120rpx 0rpx 30rpx;
  200. box-sizing: border-box;
  201. }
  202. .lab_title{
  203. width: 750rpx;
  204. height: 100rpx;
  205. background: #FFFFFF;
  206. position: fixed;
  207. top: 0;
  208. padding: 10rpx 30rpx;
  209. box-sizing: border-box;
  210. display: flex;
  211. justify-content: flex-start;
  212. .lab_title_l{
  213. width: 250rpx;
  214. height: 80rpx;
  215. margin-right: 20rpx;
  216. .lab_title_l_n{
  217. width: 250rpx;
  218. height: 80rpx;
  219. border-radius: 10rpx;
  220. border: 1rpx solid #E0E0E0;
  221. display: flex;
  222. justify-content: flex-start;
  223. align-items: center;
  224. >view{
  225. flex:1;
  226. line-height:80rpx;
  227. margin-left:20rpx;
  228. color: #999999;
  229. font-size:28rpx;
  230. white-space: nowrap;
  231. overflow: hidden;
  232. text-overflow: ellipsis;
  233. }
  234. >img{
  235. width: 14rpx;
  236. height: 8rpx;
  237. margin-right: 30rpx;
  238. }
  239. }
  240. }
  241. .lab_title_r{
  242. width: 420rpx;
  243. height: 80rpx;
  244. position:relative;
  245. border-radius: 10rpx;
  246. border: 1rpx solid #E0E0E0;
  247. .lab_title_r_btn{
  248. width: 60rpx;
  249. height: 80rpx
  250. position: absolute;
  251. top: 0rpx;
  252. right:0rpx;
  253. >img{
  254. width: 20rpx;
  255. height: 20rpx;
  256. position: absolute;
  257. top: 30rpx;
  258. left: 24rpx;
  259. }
  260. }
  261. >input{
  262. width: 274rpx;
  263. height: 80rpx;
  264. position: absolute;
  265. top: 0rpx;
  266. left: 60rpx;
  267. }
  268. .clear{
  269. width: 60rpx;
  270. height: 80rpx
  271. position: absolute;
  272. top: 0rpx;
  273. right:20rpx;
  274. font-size: 30rpx;
  275. font-family: PingFang SC-Medium, PingFang SC;
  276. font-weight: 400;
  277. color: #0183FA;
  278. line-height: 80rpx;
  279. }
  280. }
  281. }
  282. .list{
  283. background: #FFFFFF;
  284. border-radius: 20rpx 20rpx 0rpx 0rpx;
  285. padding: 0 30rpx;
  286. box-sizing: border-box;
  287. margin: 0 30rpx;
  288. .list_li{
  289. display: flex;
  290. justify-content:space-between;
  291. align-items: center;
  292. height: 80rpx;
  293. border-bottom: 1rpx solid #E0E0E0;
  294. >text{
  295. font-size: 28rpx;
  296. font-family: PingFang SC-Medium, PingFang SC;
  297. font-weight: 400;
  298. line-height: 80rpx;
  299. overflow: hidden;
  300. text-overflow:ellipsis;
  301. white-space: nowrap;
  302. }
  303. >img{
  304. width: 24rpx;
  305. height: 16rpx;
  306. margin-right: 14rpx;
  307. }
  308. }
  309. .list_li:last-child{
  310. border: none;
  311. }
  312. .color_A{
  313. color: #333333;
  314. }
  315. .color_B{
  316. color: #0183FA;
  317. }
  318. }
  319. .bottom_btn{
  320. position: fixed;
  321. bottom: 26rpx;
  322. left: 30rpx;
  323. font-size: 30rpx;
  324. font-family: PingFang SC-Medium, PingFang SC;
  325. font-weight: 400;
  326. color: #FFFFFF;
  327. line-height: 90rpx;
  328. width: 690rpx;
  329. height: 90rpx;
  330. background: #0183FA;
  331. border-radius: 20rpx;
  332. text-align: center;
  333. }
  334. }
  335. </style>