patrolPlanAddLab.vue 8.5 KB

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