patrolPlanAddContent.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  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. page: 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.page) {
  90. console.log('没有更多数据!')
  91. } else {
  92. setTimeout(function() {
  93. self.getData.page += 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].value
  102. this.getData.hazardTypeModeName = this.collegeList[e.target.value].label
  103. this.getData.page = 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.hazardId === this.dataList[index].hazardId) == -
  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.page = 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.hazardId)
  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. }
  179. },
  180. //检查类型
  181. async dangerList() {
  182. let self = this;
  183. const {
  184. data
  185. } = await getDicts('lab_hazard_type');
  186. if (data.code == 200) {
  187. for (let i = 0; i < data.data.length; i++) {
  188. self.collegeArray.push(data.data[i].label)
  189. }
  190. self.collegeList = data.data;
  191. }
  192. },
  193. async getList() {
  194. let self = this;
  195. const {
  196. data
  197. } = await findDeviceList(self.getData);
  198. if (data.code == 200) {
  199. data.data.records.forEach(function(item) {
  200. item.type = false;
  201. })
  202. this.dataList = [...this.dataList, ...data.data.records]
  203. self.total = data.total;
  204. if (this.seleteListDevice.length > 0) { //如果有选中的数据
  205. for (let i = 0; i < this.dataList.length; i++) {
  206. if (this.seleteListDevice.findIndex((item) => item.hazardId === this.dataList[i].hazardId) != -
  207. 1) { //不等于-1说明数组里有当前元素,可以改为选中
  208. this.dataList[i].type = true;
  209. } else {
  210. }
  211. }
  212. }
  213. }
  214. }
  215. }
  216. }
  217. </script>
  218. <style lang="stylus" scoped>
  219. .examine {
  220. height: 100%;
  221. display flex;
  222. .info-max-box {
  223. flex: 1;
  224. overflow: scroll;
  225. padding: 120rpx 0rpx 30rpx;
  226. box-sizing: border-box;
  227. }
  228. .lab_title {
  229. width: 750rpx;
  230. height: 100rpx;
  231. background: #FFFFFF;
  232. position: fixed;
  233. top: 0;
  234. padding: 10rpx 30rpx;
  235. box-sizing: border-box;
  236. display: flex;
  237. justify-content: flex-start;
  238. .lab_title_l {
  239. width: 250rpx;
  240. height: 80rpx;
  241. margin-right: 20rpx;
  242. .lab_title_l_n {
  243. width: 250rpx;
  244. height: 80rpx;
  245. border-radius: 10rpx;
  246. border: 1rpx solid #E0E0E0;
  247. display: flex;
  248. justify-content: flex-start;
  249. align-items: center;
  250. >view {
  251. flex: 1;
  252. line-height: 80rpx;
  253. margin-left: 20rpx;
  254. color: #999999;
  255. font-size: 28rpx;
  256. white-space: nowrap;
  257. overflow: hidden;
  258. text-overflow: ellipsis;
  259. }
  260. >img {
  261. width: 14rpx;
  262. height: 8rpx;
  263. margin-right: 30rpx;
  264. }
  265. }
  266. }
  267. .lab_title_r {
  268. width: 420rpx;
  269. height: 80rpx;
  270. position: relative;
  271. border-radius: 10rpx;
  272. border: 1rpx solid #E0E0E0;
  273. .lab_title_r_btn {
  274. width: 60rpx;
  275. height: 80rpx;
  276. position: absolute;
  277. top: 0rpx;
  278. right: 0rpx;
  279. >img {
  280. width: 20rpx;
  281. height: 20rpx;
  282. position: absolute;
  283. top: 30rpx;
  284. left: 24rpx;
  285. }
  286. }
  287. >input {
  288. width: 274rpx;
  289. height: 80rpx;
  290. position: absolute;
  291. top: 0rpx;
  292. left: 60rpx;
  293. }
  294. .clear {
  295. width: 60rpx;
  296. height: 80rpx;
  297. position: absolute;
  298. top: 0rpx;
  299. right: 20rpx;
  300. font-size: 30rpx;
  301. font-family: PingFang SC-Medium, PingFang SC;
  302. font-weight: 400;
  303. color: #0183FA;
  304. line-height: 80rpx;
  305. }
  306. }
  307. }
  308. .list {
  309. background: #FFFFFF;
  310. border-radius: 20rpx 20rpx 0rpx 0rpx;
  311. padding: 0 30rpx;
  312. box-sizing: border-box;
  313. margin: 0 30rpx;
  314. .list_li {
  315. display: flex;
  316. justify-content: space-between;
  317. align-items: center;
  318. height: 80rpx;
  319. border-bottom: 1rpx solid #E0E0E0;
  320. >text {
  321. font-size: 28rpx;
  322. font-family: PingFang SC-Medium, PingFang SC;
  323. font-weight: 400;
  324. line-height: 80rpx;
  325. overflow: hidden;
  326. text-overflow: ellipsis;
  327. white-space: nowrap;
  328. }
  329. >img {
  330. width: 24rpx;
  331. height: 16rpx;
  332. margin-right: 14rpx;
  333. }
  334. }
  335. .list_li:last-child {
  336. border: none;
  337. }
  338. .color_A {
  339. color: #333333;
  340. }
  341. .color_B {
  342. color: #0183FA;
  343. }
  344. }
  345. .bottom_btn {
  346. position: fixed;
  347. bottom: 26rpx;
  348. left: 30rpx;
  349. font-size: 30rpx;
  350. font-family: PingFang SC-Medium, PingFang SC;
  351. font-weight: 400;
  352. color: #FFFFFF;
  353. line-height: 90rpx;
  354. width: 690rpx;
  355. height: 90rpx;
  356. background: #0183FA;
  357. border-radius: 20rpx;
  358. text-align: center;
  359. }
  360. }
  361. </style>