examineAddContent.vue 7.3 KB

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