patrolPlanAddMember.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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. <view class="lab_title_n">
  8. <input type="text" v-model="getData.searchValue" placeholder="请输入巡查组名称" name="search" @confirm='searchBtn' confirm-type='search' maxlength="50" placeholder-style="color: #CCCCCC;font-size:26rpx;">
  9. <view class="lab_title_r_btn" v-if="getData.searchValue>0" @click="clearBtn">
  10. <img src="@/pages_safetyExamine/images/clear.png"/>
  11. </view>
  12. </view>
  13. </view>
  14. <view class="list">
  15. <view class="list_li" v-for="(item,index) in dataList" :key="index" @click="labSelete(index)">
  16. <text :class="item.type?'color_B':'color_A'">{{item.groupName}}</text>
  17. <img v-if="item.type" src="@/pages_safetyExamine/images/icon_xzwt_xz.png">
  18. </view>
  19. </view>
  20. </view>
  21. </scroll-view>
  22. <view class="bottom_btn" @click="submitForm">保存</view>
  23. </view>
  24. </template>
  25. <script>
  26. import { config } from '@/api/request/config.js'
  27. import { checkGroupList,checkGroupDetail} from '@/api/apiDemo/index.js'
  28. export default {
  29. name: "rectifyList",
  30. components: {
  31. },
  32. data() {
  33. return {
  34. pageType:0,
  35. //列表请求参数
  36. getData:{
  37. checkLevel:'0',
  38. searchValue:'',
  39. checkLevel:'',
  40. },
  41. total:0,
  42. dataList:[],
  43. seleteListMember:[],//临时存储选中巡查组
  44. checkMemberDtoList:[],//临时存储选中的
  45. form:{},
  46. }
  47. },
  48. onLoad(option) {
  49. if(option.form){
  50. this.form=JSON.parse(decodeURIComponent(option.form));
  51. if(this.form.seleteListMember.length>0){
  52. this.seleteListMember=this.form.seleteListMember;
  53. }
  54. this.getData.checkLevel=this.form.groupDataType
  55. }
  56. if(option.pageType){//pageType=1添加页面进入2编辑页面进入
  57. this.pageType=option.pageType
  58. }
  59. },
  60. onShow() {
  61. this.dataList=[];
  62. this.getList();
  63. },
  64. mounted(){
  65. },
  66. methods: {
  67. //滚动事件
  68. scrollGet(){
  69. let self=this;
  70. if(self.total<=self.getData.pageNum){
  71. console.log('没有更多数据!')
  72. }else{
  73. setTimeout(function(){
  74. self.getData.pageNum += 1;
  75. self.getList();
  76. },1000)
  77. }
  78. },
  79. //点击选择实验室
  80. labSelete(index){
  81. let _this = this;
  82. this.seleteListMember=[];
  83. this.dataList[index].type = !this.dataList[index].type
  84. if (_this.dataList[index].type == true) {
  85. _this.dataList.forEach(function(item2) {
  86. if (item2.id == _this.dataList[index].id) {
  87. item2.type = true
  88. } else {
  89. item2.type = false
  90. }
  91. })
  92. }
  93. this.seleteListMember.push(this.dataList[index])
  94. // if(this.dataList[index].type){//判断是选中还是取消
  95. // this.seleteListMember.push(this.dataList[index])
  96. // }else{
  97. // this.seleteListMember=[];
  98. // }
  99. },
  100. //实验室搜索
  101. searchBtn(){
  102. this.dataList=[];
  103. this.getList();
  104. },
  105. //清除按钮
  106. clearBtn(){
  107. this.getData.pageNum=1;
  108. this.getData.searchValue= '';
  109. this.dataList=[];
  110. this.getList();
  111. },
  112. handleClick(doType){
  113. let self=this;
  114. if( doType=='subBtn'){//保存数据
  115. }
  116. },
  117. //巡查组-保存
  118. async submitForm(){
  119. let _this = this;
  120. console.log(this.seleteListMember)
  121. let id=this.seleteListMember[0].id
  122. this.form.checkMemberDtoList=[];
  123. this.$set(this.form,'checkGroupId',this.seleteListMember[0].id)
  124. this.$set(this.form,'checkGroupName',this.seleteListMember[0].groupName)
  125. const {data} = await checkGroupDetail({id:id,selectEnable:'1'});
  126. if(data.code == 200){
  127. let obj={};
  128. for(let i=0;i<data.data.checkGroupMemberList.length;i++){
  129. obj={
  130. "deptId":data.data.checkGroupMemberList[i].deptId,
  131. "deptName":data.data.checkGroupMemberList[i].deptName,
  132. "enable":data.data.checkGroupMemberList[i].enable,
  133. "jobNum":data.data.checkGroupMemberList[i].jobNum,
  134. "name":data.data.checkGroupMemberList[i].name,
  135. "userId":data.data.checkGroupMemberList[i].userId,
  136. "userType":data.data.checkGroupMemberList[i].userType
  137. }
  138. this.form.checkMemberDtoList.push(obj)
  139. }
  140. let pages=getCurrentPages();
  141. let prevPage=pages[pages.length-2];//上一个页面
  142. prevPage.onShow(encodeURIComponent(JSON.stringify(this.form)))
  143. uni.navigateBack()
  144. // if(this.pageType==1){
  145. // uni.redirectTo({
  146. // url: '/pages_safetyExamine/patrolPlan/patrolPlanAdd?form='+encodeURIComponent(JSON.stringify(this.form))
  147. // });
  148. // }else if(this.pageType==2){
  149. // uni.redirectTo({
  150. // url: '/pages_safetyExamine/patrolPlan/patrolPlanEdit?form='+encodeURIComponent(JSON.stringify(this.form))
  151. // });
  152. // }
  153. }
  154. },
  155. async getList(){
  156. let _this = this;
  157. const {data} = await checkGroupList(_this.getData);
  158. if(data.code==200){
  159. if(data.data){
  160. data.data.forEach(function(item){
  161. item.type=false
  162. })
  163. }
  164. this.dataList=[...this.dataList,...data.data]
  165. //如果有选中的数据
  166. if(this.seleteListMember.length>0){
  167. for(let i=0;i<this.dataList.length;i++){
  168. if(this.seleteListMember[0].id==this.dataList[i].id){
  169. this.dataList[i].type=true;
  170. }
  171. }
  172. }
  173. this.total=data.data.total;
  174. }
  175. }
  176. }
  177. }
  178. </script>
  179. <style lang="stylus" scoped>
  180. .examine{
  181. height:100%;
  182. display flex;
  183. .info-max-box{
  184. flex: 1;
  185. overflow: scroll;
  186. padding: 120rpx 0rpx 30rpx;
  187. box-sizing: border-box;
  188. }
  189. .lab_title{
  190. width: 750rpx;
  191. height: 100rpx;
  192. background: #FFFFFF;
  193. position: fixed;
  194. top: 0;
  195. padding: 10rpx 30rpx;
  196. box-sizing: border-box;
  197. .lab_title_n{
  198. width: 690rpx;
  199. height: 80rpx;
  200. position:relative;
  201. border-radius: 10rpx;
  202. border: 1rpx solid #E0E0E0;
  203. .lab_title_r_btn{
  204. width: 60rpx;
  205. height: 80rpx
  206. position: absolute;
  207. top: 0rpx;
  208. right: 0rpx;
  209. >img{
  210. width: 20rpx;
  211. height: 20rpx;
  212. position: absolute;
  213. top: 30rpx;
  214. left: 24rpx;
  215. }
  216. }
  217. >input{
  218. width: 360rpx;
  219. height: 80rpx;
  220. position: absolute;
  221. top: 0rpx;
  222. left: 60rpx;
  223. }
  224. }
  225. }
  226. .list{
  227. background: #FFFFFF;
  228. border-radius: 20rpx 20rpx 0rpx 0rpx;
  229. padding: 0 30rpx;
  230. box-sizing: border-box;
  231. margin: 0 30rpx;
  232. .list_li{
  233. display: flex;
  234. justify-content:space-between;
  235. align-items: center;
  236. height: 80rpx;
  237. border-bottom: 1rpx solid #E0E0E0;
  238. >text{
  239. font-size: 28rpx;
  240. font-family: PingFang SC-Medium, PingFang SC;
  241. font-weight: 400;
  242. line-height: 80rpx;
  243. overflow: hidden;
  244. text-overflow:ellipsis;
  245. white-space: nowrap;
  246. }
  247. >img{
  248. width: 24rpx;
  249. height: 16rpx;
  250. margin-right: 14rpx;
  251. }
  252. }
  253. .list_li:last-child{
  254. border: none;
  255. }
  256. .color_A{
  257. color: #333333;
  258. }
  259. .color_B{
  260. color: #0183FA;
  261. }
  262. }
  263. .bottom_btn{
  264. position: fixed;
  265. bottom: 26rpx;
  266. left: 30rpx;
  267. font-size: 30rpx;
  268. font-family: PingFang SC-Medium, PingFang SC;
  269. font-weight: 400;
  270. color: #FFFFFF;
  271. line-height: 90rpx;
  272. width: 690rpx;
  273. height: 90rpx;
  274. background: #0183FA;
  275. border-radius: 20rpx;
  276. text-align: center;
  277. }
  278. }
  279. </style>