patrolPlanAddContent.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  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.hazardTypeModeName?getData.hazardTypeModeName:'选择类型'}}</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.chName}}</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,dangerList,findDeviceList,haveHazardInSub} 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. hazardTypeMode:'',//类型id
  46. hazardTypeModeName:'',
  47. searchValue:'',
  48. filtType:'',
  49. hazardIds:[],
  50. selectedHazardIds:[],
  51. },
  52. total:0,
  53. collegeIndex :0,
  54. collegeArray:[],
  55. collegeList:[],
  56. dataList:[],
  57. seleteListDevice:[],//临时存储选中的
  58. form:{},
  59. }
  60. },
  61. onLoad(option) {
  62. this.form=JSON.parse(decodeURIComponent(option.form));
  63. if(this.form.seleteListDevice.length>0){
  64. this.seleteListDevice=this.form.seleteListDevice;
  65. }
  66. if(option.pageType){//pageType=1添加页面进入2编辑页面进入
  67. this.pageType=option.pageType
  68. }
  69. },
  70. onShow() {
  71. },
  72. mounted(){
  73. this.dataList=[];
  74. this.dangerList();
  75. this.getList();
  76. },
  77. methods: {
  78. //滚动事件
  79. scrollGet(){
  80. let self=this;
  81. if(self.total/self.getData.pageSize<=self.getData.pageNum){
  82. console.log('没有更多数据!')
  83. }else{
  84. setTimeout(function(){
  85. self.getData.pageNum += 1;
  86. self.getList();
  87. },1000)
  88. }
  89. },
  90. //选择学院
  91. collegeChange(e){
  92. this.collegeIndex = e.target.value;
  93. this.getData.hazardTypeMode=this.collegeList[e.target.value].dictValue
  94. this.getData.hazardTypeModeName=this.collegeList[e.target.value].dictLabel
  95. this.getData.pageNum=1;
  96. this.dataList=[];
  97. this.getList();
  98. },
  99. //点击选择实验室
  100. labSelete(index){
  101. this.dataList[index].type = !this.dataList[index].type
  102. if(this.dataList[index].type){//判断是选中还是取消
  103. if(this.seleteListDevice.length>0){
  104. if(this.seleteListDevice.findIndex((item)=>item.id===this.dataList[index].id) ==-1){//等于-1说明数组里没有当前选中元素,可以添加
  105. this.seleteListDevice.push(this.dataList[index])
  106. }
  107. }else{
  108. this.seleteListDevice.push(this.dataList[index])
  109. }
  110. }else{
  111. this.seleteListDevice.splice(this.seleteListDevice.indexOf(this.dataList[index]),1);
  112. }
  113. },
  114. //实验室搜索
  115. searchBtn(){
  116. this.dataList=[];
  117. this.getList();
  118. },
  119. //清除
  120. clearBtn(){
  121. this.getData.pageNum=1;
  122. this.collegeIndex=0;
  123. this.getData.deptId='';
  124. this.getData.deptName='';
  125. this.getData.searchValue='';
  126. this.dataList=[];
  127. this.getList();
  128. },
  129. handleClick(doType){
  130. let self=this;
  131. if( doType=='subBtn'){//保存数据
  132. }
  133. },
  134. //设备-保存
  135. async submitForm(){
  136. let _this = this;
  137. let hazardIds=[];
  138. this.$set(this.form,'hazardNum', this.seleteListDevice.length)
  139. this.$set(this.form,'seleteListDevice', this.seleteListDevice)
  140. if(this.seleteListDevice.length>0){
  141. this.seleteListDevice.forEach(function(item){
  142. hazardIds.push(item.id)
  143. })
  144. this.$set(this.form,'hazardIds', hazardIds.join(','))
  145. }else{
  146. uni.showToast({
  147. title: '请选择检查内容!',
  148. icon:"none",
  149. mask:true,
  150. duration: 2000
  151. });
  152. return;
  153. }
  154. //实验室是否有当前设备
  155. let obj={
  156. "checkRange":this.form.checkRange,
  157. "collegeIds":this.form.checkRange==2?this.form.collegeIds+'':'',//学院ID转换字符串
  158. "subIds":this.form.checkRange == 3?this.form.subIds+'':'',//实验室ID
  159. "hazardIds":this.form.hazardIds,
  160. }
  161. const {data} = await haveHazardInSub(obj);
  162. if(data.code == 200){
  163. let pages=getCurrentPages();
  164. let prevPage=pages[pages.length-2];//上一个页面
  165. prevPage.onShow(encodeURIComponent(JSON.stringify(this.form)))
  166. uni.navigateBack()
  167. // if(this.pageType==1){
  168. // uni.redirectTo({
  169. // url: '/pages_safetyExamine/patrolPlan/patrolPlanAdd?form='+encodeURIComponent(JSON.stringify(this.form))
  170. // });
  171. // }else if(this.pageType==2){
  172. // uni.redirectTo({
  173. // url: '/pages_safetyExamine/patrolPlan/patrolPlanEdit?form='+encodeURIComponent(JSON.stringify(this.form))
  174. // });
  175. // }
  176. }
  177. },
  178. //查询学院列表
  179. async dangerList(){
  180. let _this = this;
  181. const {data} = await dangerList();
  182. if(data.code == 200){
  183. for(let i=0;i<data.rows.length;i++){
  184. _this.collegeArray.push(data.rows[i].dictLabel)
  185. }
  186. _this.collegeList=data.rows;
  187. }
  188. },
  189. async getList(){
  190. let _this = this;
  191. const {data} = await findDeviceList(_this.getData);
  192. if(data.code==200){
  193. data.rows.forEach(function(item){
  194. item.type=false;
  195. })
  196. this.dataList=[...this.dataList,...data.rows]
  197. _this.total=data.total;
  198. if(this.seleteListDevice.length>0){//如果有选中的数据
  199. for(let i=0;i<this.dataList.length;i++){
  200. if(this.seleteListDevice.findIndex((item)=>item.id===this.dataList[i].id) !=-1){//不等于-1说明数组里有当前元素,可以改为选中
  201. this.dataList[i].type=true;
  202. }else{
  203. }
  204. }
  205. }
  206. }
  207. }
  208. }
  209. }
  210. </script>
  211. <style lang="stylus" scoped>
  212. .examine{
  213. height:100%;
  214. display flex;
  215. .info-max-box{
  216. flex: 1;
  217. overflow: scroll;
  218. padding: 120rpx 0rpx 30rpx;
  219. box-sizing: border-box;
  220. }
  221. .lab_title{
  222. width: 750rpx;
  223. height: 100rpx;
  224. background: #FFFFFF;
  225. position: fixed;
  226. top: 0;
  227. padding: 10rpx 30rpx;
  228. box-sizing: border-box;
  229. display: flex;
  230. justify-content: flex-start;
  231. .lab_title_l{
  232. width: 250rpx;
  233. height: 80rpx;
  234. margin-right: 20rpx;
  235. .lab_title_l_n{
  236. width: 250rpx;
  237. height: 80rpx;
  238. border-radius: 10rpx;
  239. border: 1rpx solid #E0E0E0;
  240. display: flex;
  241. justify-content: flex-start;
  242. align-items: center;
  243. >view{
  244. flex:1;
  245. line-height:80rpx;
  246. margin-left:20rpx;
  247. color: #999999;
  248. font-size:28rpx;
  249. white-space: nowrap;
  250. overflow: hidden;
  251. text-overflow: ellipsis;
  252. }
  253. >img{
  254. width: 14rpx;
  255. height: 8rpx;
  256. margin-right: 30rpx;
  257. }
  258. }
  259. }
  260. .lab_title_r{
  261. width: 420rpx;
  262. height: 80rpx;
  263. position:relative;
  264. border-radius: 10rpx;
  265. border: 1rpx solid #E0E0E0;
  266. .lab_title_r_btn{
  267. width: 60rpx;
  268. height: 80rpx
  269. position: absolute;
  270. top: 0rpx;
  271. right:0rpx;
  272. >img{
  273. width: 20rpx;
  274. height: 20rpx;
  275. position: absolute;
  276. top: 30rpx;
  277. left: 24rpx;
  278. }
  279. }
  280. >input{
  281. width: 274rpx;
  282. height: 80rpx;
  283. position: absolute;
  284. top: 0rpx;
  285. left: 60rpx;
  286. }
  287. .clear{
  288. width: 60rpx;
  289. height: 80rpx
  290. position: absolute;
  291. top: 0rpx;
  292. right:20rpx;
  293. font-size: 30rpx;
  294. font-family: PingFang SC-Medium, PingFang SC;
  295. font-weight: 400;
  296. color: #0183FA;
  297. line-height: 80rpx;
  298. }
  299. }
  300. }
  301. .list{
  302. background: #FFFFFF;
  303. border-radius: 20rpx 20rpx 0rpx 0rpx;
  304. padding: 0 30rpx;
  305. box-sizing: border-box;
  306. margin: 0 30rpx;
  307. .list_li{
  308. display: flex;
  309. justify-content:space-between;
  310. align-items: center;
  311. height: 80rpx;
  312. border-bottom: 1rpx solid #E0E0E0;
  313. >text{
  314. font-size: 28rpx;
  315. font-family: PingFang SC-Medium, PingFang SC;
  316. font-weight: 400;
  317. line-height: 80rpx;
  318. overflow: hidden;
  319. text-overflow:ellipsis;
  320. white-space: nowrap;
  321. }
  322. >img{
  323. width: 24rpx;
  324. height: 16rpx;
  325. margin-right: 14rpx;
  326. }
  327. }
  328. .list_li:last-child{
  329. border: none;
  330. }
  331. .color_A{
  332. color: #333333;
  333. }
  334. .color_B{
  335. color: #0183FA;
  336. }
  337. }
  338. .bottom_btn{
  339. position: fixed;
  340. bottom: 26rpx;
  341. left: 30rpx;
  342. font-size: 30rpx;
  343. font-family: PingFang SC-Medium, PingFang SC;
  344. font-weight: 400;
  345. color: #FFFFFF;
  346. line-height: 90rpx;
  347. width: 690rpx;
  348. height: 90rpx;
  349. background: #0183FA;
  350. border-radius: 20rpx;
  351. text-align: center;
  352. }
  353. }
  354. </style>