patrolPlanAddLab.vue 7.5 KB

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