patrolPlanAddLab.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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.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. if(this.pageType==1){
  146. uni.redirectTo({
  147. url: '/pages_safetyExamine/patrolPlan/patrolPlanAdd?form='+encodeURIComponent(JSON.stringify(this.form))
  148. });
  149. }else if(this.pageType==2){
  150. uni.redirectTo({
  151. url: '/pages_safetyExamine/patrolPlan/patrolPlanEdit?form='+encodeURIComponent(JSON.stringify(this.form))
  152. });
  153. }
  154. },
  155. //查询学院列表
  156. async conditionCollegeInfo(){
  157. let _this = this;
  158. const {data} = await conditionCollegeInfo();
  159. if(data.code == 200){
  160. for(let i=0;i<data.data.length;i++){
  161. _this.collegeArray.push(data.data[i].deptName)
  162. }
  163. _this.collegeList=data.data;
  164. console.log()
  165. }
  166. },
  167. async getList(){
  168. let _this = this;
  169. const {data} = await conditionSubjectInfo(_this.getData);
  170. if(data.code==200){
  171. data.rows.forEach(function(item){
  172. item.type=false;
  173. })
  174. this.dataList=[...this.dataList,...data.rows]
  175. _this.total=data.total;
  176. if(this.seleteListLab.length>0){//如果有选中的数据
  177. for(let i=0;i<this.dataList.length;i++){
  178. if(this.seleteListLab.findIndex((item)=>item.subId===this.dataList[i].subId) !=-1){//不等于-1说明数组里有当前元素,可以改为选中
  179. this.dataList[i].type=true;
  180. }else{
  181. }
  182. }
  183. }
  184. }
  185. }
  186. }
  187. }
  188. </script>
  189. <style lang="stylus" scoped>
  190. .examine{
  191. height:100%;
  192. display flex;
  193. .info-max-box{
  194. flex: 1;
  195. overflow: scroll;
  196. padding: 120rpx 0rpx 30rpx;
  197. box-sizing: border-box;
  198. }
  199. .lab_title{
  200. width: 750rpx;
  201. height: 100rpx;
  202. background: #FFFFFF;
  203. position: fixed;
  204. top: 0;
  205. padding: 10rpx 30rpx;
  206. box-sizing: border-box;
  207. display: flex;
  208. justify-content: flex-start;
  209. .lab_title_l{
  210. width: 250rpx;
  211. height: 80rpx;
  212. margin-right: 20rpx;
  213. .lab_title_l_n{
  214. width: 250rpx;
  215. height: 80rpx;
  216. border-radius: 10rpx;
  217. border: 1rpx solid #E0E0E0;
  218. display: flex;
  219. justify-content: flex-start;
  220. align-items: center;
  221. >view{
  222. flex:1;
  223. line-height:80rpx;
  224. margin-left:20rpx;
  225. color: #999999;
  226. font-size:28rpx;
  227. white-space: nowrap;
  228. overflow: hidden;
  229. text-overflow: ellipsis;
  230. }
  231. >img{
  232. width: 14rpx;
  233. height: 8rpx;
  234. margin-right: 30rpx;
  235. }
  236. }
  237. }
  238. .lab_title_r{
  239. width: 420rpx;
  240. height: 80rpx;
  241. position:relative;
  242. border-radius: 10rpx;
  243. border: 1rpx solid #E0E0E0;
  244. .lab_title_r_btn{
  245. width: 60rpx;
  246. height: 80rpx
  247. position: absolute;
  248. top: 0rpx;
  249. left:0rpx;
  250. >img{
  251. width: 20rpx;
  252. height: 20rpx;
  253. position: absolute;
  254. top: 30rpx;
  255. left: 24rpx;
  256. }
  257. }
  258. >input{
  259. width: 274rpx;
  260. height: 80rpx;
  261. position: absolute;
  262. top: 0rpx;
  263. left: 60rpx;
  264. }
  265. .clear{
  266. width: 60rpx;
  267. height: 80rpx
  268. position: absolute;
  269. top: 0rpx;
  270. right:20rpx;
  271. font-size: 30rpx;
  272. font-family: PingFang SC-Medium, PingFang SC;
  273. font-weight: 400;
  274. color: #0183FA;
  275. line-height: 80rpx;
  276. }
  277. }
  278. }
  279. .list{
  280. background: #FFFFFF;
  281. border-radius: 20rpx 20rpx 0rpx 0rpx;
  282. padding: 0 30rpx;
  283. box-sizing: border-box;
  284. margin: 0 30rpx;
  285. .list_li{
  286. display: flex;
  287. justify-content:space-between;
  288. align-items: center;
  289. height: 80rpx;
  290. border-bottom: 1rpx solid #E0E0E0;
  291. >text{
  292. font-size: 28rpx;
  293. font-family: PingFang SC-Medium, PingFang SC;
  294. font-weight: 400;
  295. line-height: 80rpx;
  296. overflow: hidden;
  297. text-overflow:ellipsis;
  298. white-space: nowrap;
  299. }
  300. >img{
  301. width: 24rpx;
  302. height: 16rpx;
  303. margin-right: 14rpx;
  304. }
  305. }
  306. .list_li:last-child{
  307. border: none;
  308. }
  309. .color_A{
  310. color: #333333;
  311. }
  312. .color_B{
  313. color: #0183FA;
  314. }
  315. }
  316. .bottom_btn{
  317. position: fixed;
  318. bottom: 26rpx;
  319. left: 30rpx;
  320. font-size: 30rpx;
  321. font-family: PingFang SC-Medium, PingFang SC;
  322. font-weight: 400;
  323. color: #FFFFFF;
  324. line-height: 90rpx;
  325. width: 690rpx;
  326. height: 90rpx;
  327. background: #0183FA;
  328. border-radius: 20rpx;
  329. text-align: center;
  330. }
  331. }
  332. </style>