patrolPlanAddLab.vue 8.4 KB

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