patrolPlanAddContent.vue 9.3 KB

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