patrolPlanAddLab.vue 7.9 KB

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