examineAddContent.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <!-- 安全检查-发起巡查计划-选择内容 -->
  2. <template>
  3. <view class="examine">
  4. <view class="lab_title">
  5. <view class="lab_title_r">
  6. <view class="lab_title_r_btn" @click="searchBtn">
  7. <img src="@/pages_safetyExamine/images/icon_aqjc_ss.png"/>
  8. </view>
  9. <input type="text" v-model="getData.searchValue" placeholder="设备名称/型号" maxlength="50" placeholder-style="color: #CCCCCC;font-size:26rpx;">
  10. <!-- <img class="scanBtn" @click="scanBtn" src="@/pages_safetyExamine/images/icon_aqjc_sm.png"/> -->
  11. </view>
  12. </view>
  13. <scroll-view scroll-y @scrolltolower="scrollGet" class="info-max-box">
  14. <view>
  15. <view class="list">
  16. <view class="list_li" v-for="(item,index) in dataList" :key="index" @click="labSelete(index)">
  17. <text :class="item.type?'color_B':'color_A'">{{item.chName}}</text>
  18. <img v-if="item.type" src="@/pages_safetyExamine/images/icon_xzwt_xz.png">
  19. </view>
  20. </view>
  21. </view>
  22. </scroll-view>
  23. <div class="bottom">
  24. <view class="bottom_l" @click="clearForm">取消</view>
  25. <view class="bottom_r" @click="submitForm">确定</view>
  26. </div>
  27. </view>
  28. </template>
  29. <script>
  30. import { config } from '@/api/request/config.js'
  31. import {conditionCollegeInfo,conditionSubjectInfo,findDeviceList,haveHazardInSub,getHazardInfoBySubId} from '@/api/apiDemo/index.js'
  32. export default {
  33. name: "rectifyList",
  34. components: {
  35. },
  36. data() {
  37. return {
  38. pageType:0,
  39. //列表请求参数
  40. getData:{
  41. pageNum:1,
  42. pageSize:200,
  43. searchValue:'',
  44. subId:'',
  45. },
  46. total:0,
  47. collegeIndex :0,
  48. collegeArray:[],
  49. collegeList:[],
  50. dataList:[],
  51. seleteListDevice:[],//临时存储选中的
  52. form:{},
  53. }
  54. },
  55. onLoad(option) {
  56. if(option.form){
  57. this.form=JSON.parse(decodeURIComponent(option.form));
  58. }
  59. if(option.pageType){//pageType=1添加页面进入2编辑页面进入
  60. this.pageType=option.pageType
  61. }
  62. },
  63. onShow() {
  64. },
  65. mounted(){
  66. this.dataList=[];
  67. this.getList();
  68. },
  69. methods: {
  70. //滚动事件
  71. scrollGet(){
  72. // let self=this;
  73. // if(self.total/self.getData.pageSize<=self.getData.pageNum){
  74. // console.log('没有更多数据!')
  75. // }else{
  76. // setTimeout(function(){
  77. // self.getData.pageNum += 1;
  78. // self.getList();
  79. // },1000)
  80. // }
  81. },
  82. //点击选择实验室
  83. labSelete(index){
  84. this.dataList[index].type = !this.dataList[index].type
  85. if(this.dataList[index].type){//判断是选中还是取消
  86. if(this.seleteListDevice.length>0){
  87. if(this.seleteListDevice.findIndex((item)=>item.joinHazardId===this.dataList[index].joinHazardId) ==-1){//等于-1说明数组里没有当前选中元素,可以添加
  88. this.seleteListDevice.push(this.dataList[index])
  89. }
  90. }else{
  91. this.seleteListDevice.push(this.dataList[index])
  92. }
  93. }else{
  94. this.seleteListDevice.splice(this.seleteListDevice.indexOf(this.dataList[index]),1);
  95. }
  96. },
  97. //实验室搜索
  98. searchBtn(){
  99. this.dataList=[];
  100. this.getList();
  101. },
  102. handleClick(doType){
  103. let self=this;
  104. if( doType=='subBtn'){//保存数据
  105. }
  106. },
  107. //扫码
  108. scanBtn(){
  109. uni.redirectTo({
  110. url: '/pages/saoCode/scan?form='+encodeURIComponent(JSON.stringify(this.form))
  111. });
  112. },
  113. //取消
  114. clearForm(){
  115. uni.navigateTo({
  116. url: '/pages_safetyExamine/views/examineManage/examineAdd?form='+encodeURIComponent(JSON.stringify(this.form))
  117. });
  118. },
  119. //设备-保存
  120. async submitForm(){
  121. let _this = this;
  122. let hazardIds=[];
  123. let joinHazardIds=[];
  124. //this.$set(this.form,'hazardNum', this.seleteListDevice.length)
  125. //this.$set(this.form,'seleteListDevice', this.seleteListDevice)
  126. if(this.seleteListDevice.length>0){
  127. this.seleteListDevice.forEach(function(item){
  128. hazardIds.push(item.hazardId)
  129. joinHazardIds.push(item.joinHazardId)
  130. })
  131. this.$set(this.form,'hazardIds', hazardIds.join(','))
  132. this.$set(this.form,'joinHazardIds', joinHazardIds.join(','))
  133. }else{
  134. this.$set(this.form,'hazardIds','')
  135. this.$set(this.form,'joinHazardIds','')
  136. uni.showToast({
  137. title: '请选择检查内容!',
  138. icon:"none",
  139. mask:true,
  140. duration: 2000
  141. });
  142. return
  143. }
  144. uni.redirectTo({
  145. url: '/pages_safetyExamine/examineManage/examineAddTow?form='+encodeURIComponent(JSON.stringify(this.form))+'&joinHazardIds='+this.form.joinHazardIds
  146. });
  147. },
  148. async getList(){
  149. let _this = this;
  150. this.getData.subId=this.form.subIds;
  151. const {data} = await getHazardInfoBySubId(this.getData);
  152. if(data.code==200){
  153. data.data.forEach(function(item){
  154. item.type=false;
  155. })
  156. this.dataList=[...this.dataList,...data.data]
  157. _this.total=data.total;
  158. if(this.form.joinHazardIds){
  159. let joinHazardIds=this.form.joinHazardIds.split(',')
  160. for( let i=0;i<this.dataList.length;i++){
  161. for( let b=0;b<joinHazardIds.length;b++){
  162. if(this.dataList[i].joinHazardId==joinHazardIds[b]){
  163. this.seleteListDevice.push(this.dataList[i]);
  164. this.dataList[i].type=true;
  165. }
  166. }
  167. }
  168. }
  169. }
  170. }
  171. }
  172. }
  173. </script>
  174. <style lang="stylus" scoped>
  175. .examine{
  176. height:100%;
  177. display flex;
  178. .info-max-box{
  179. flex: 1;
  180. overflow: scroll;
  181. padding: 120rpx 0rpx 100rpx;
  182. box-sizing: border-box;
  183. }
  184. .lab_title{
  185. width: 750rpx;
  186. height: 100rpx;
  187. background: #FFFFFF;
  188. position: fixed;
  189. top: 0;
  190. padding: 10rpx 30rpx;
  191. box-sizing: border-box;
  192. display: flex;
  193. justify-content: flex-start;
  194. .lab_title_r{
  195. width: 690rpx;
  196. height: 80rpx;
  197. position:relative;
  198. border-radius: 10rpx;
  199. border: 1rpx solid #E0E0E0;
  200. .lab_title_r_btn{
  201. width: 60rpx;
  202. height: 80rpx
  203. position: absolute;
  204. top: 0rpx;
  205. left:0rpx;
  206. >img{
  207. width: 26rpx;
  208. height: 26rpx;
  209. position: absolute;
  210. top: 30rpx;
  211. left: 24rpx;
  212. }
  213. }
  214. >input{
  215. width: 274rpx;
  216. height: 80rpx;
  217. position: absolute;
  218. top: 0rpx;
  219. left: 60rpx;
  220. }
  221. .scanBtn{
  222. width: 30rpx;
  223. height: 30rpx
  224. position: absolute;
  225. top: 26rpx;
  226. right:26rpx;
  227. }
  228. }
  229. }
  230. .list{
  231. background: #FFFFFF;
  232. border-radius: 20rpx 20rpx 0rpx 0rpx;
  233. padding: 0 30rpx;
  234. box-sizing: border-box;
  235. margin: 0 30rpx;
  236. .list_li{
  237. display: flex;
  238. justify-content:space-between;
  239. align-items: center;
  240. height: 80rpx;
  241. border-bottom: 1rpx solid #E0E0E0;
  242. >text{
  243. font-size: 28rpx;
  244. font-family: PingFang SC-Medium, PingFang SC;
  245. font-weight: 400;
  246. line-height: 80rpx;
  247. overflow: hidden;
  248. text-overflow:ellipsis;
  249. white-space: nowrap;
  250. }
  251. >img{
  252. width: 24rpx;
  253. height: 16rpx;
  254. margin-right: 14rpx;
  255. }
  256. }
  257. .list_li:last-child{
  258. border: none;
  259. }
  260. .color_A{
  261. color: #333333;
  262. }
  263. .color_B{
  264. color: #0183FA;
  265. }
  266. }
  267. .bottom{
  268. width: 750rpx;
  269. height: 90rpx;
  270. background: #FFFFFF;
  271. position: fixed;
  272. left: 0;
  273. bottom: 0;
  274. display: flex;
  275. justify-content: flex-start;
  276. .bottom_l{
  277. font-size: 30rpx;
  278. font-family: PingFang SC-Medium, PingFang SC;
  279. font-weight: 400;
  280. color: #333333;
  281. line-height: 90rpx;
  282. width: 50%;
  283. height: 90rpx;
  284. background: #fff;
  285. text-align: center;
  286. }
  287. .bottom_r{
  288. font-size: 30rpx;
  289. font-family: PingFang SC-Medium, PingFang SC;
  290. font-weight: 400;
  291. color: #FFFFFF;
  292. line-height: 90rpx;
  293. width: 50%;
  294. height: 90rpx;
  295. background: #0183FA;
  296. text-align: center;
  297. }
  298. }
  299. }
  300. </style>