snapshotAdd.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. <!-- 随手拍-添加 -->
  2. <template>
  3. <view class="examine">
  4. <view class="header" @click="handleClick('manage')">
  5. <text>随手拍管理</text>
  6. <img src="@/pages_safetyExamine/images/icon_04.png">
  7. </view>
  8. <scroll-view scroll-y @scrolltolower="scrollGet" class="info-max-box">
  9. <view class="basics">
  10. <view class="basics_li">
  11. <view class="basics_li_l">学院</view>
  12. <picker @change="collegeChange" :value="collegeIndex" :range="collegeArray" class="scope_r">
  13. <view class="basics_li_r college_r">
  14. <view>{{form.deptName?form.deptName:'选择学院'}}</view>
  15. <img src="@/pages_safetyExamine/images/icon_06.png">
  16. </view>
  17. </picker>
  18. </view>
  19. <view class="basics_li">
  20. <view class="basics_li_l">实验室</view>
  21. <view class="basics_li_r lab_r">
  22. <input class="picker-text" @click="popupClick(1)" type="text" disabled v-model="form.subName" placeholder="请输入实验室关键词查询" placeholder-style="font-size: 30rpx;color:#333;">
  23. <view class="img-box" @click.stop="saoCode">
  24. <img src="@/pages_safetyExamine/images/icon_aqjc_sm.png">
  25. </view>
  26. </view>
  27. </view>
  28. <view class="check-for-input-max-box">
  29. <view class="left-title-p">隐患描述:</view>
  30. <textarea type="text" v-model="form.hazardDescribe" maxlength="50" placeholder="请输入隐患描述" placeholder-style="font-size:28rpx;color:#999;"></textarea>
  31. </view>
  32. <view class="check-for-img-max-box">
  33. <view class="left-title-p">隐患照片(最多上传5张):</view>
  34. <view class="right-img-box">
  35. <view class="img-box" v-for="(imgUrl,imgIndex) in form.imgDtoList" :key="imgIndex">
  36. <img class="img-data" :src="configURL+imgUrl.fileUrl">
  37. <img class="position-img" src="@/pages_manage/images/icon_ssp_closure.png" @click="delImg(imgIndex)">
  38. </view>
  39. <img class="add-button" src="@/pages_manage/images/icon_07.png" @click="selectImage()" v-if="form.imgDtoList.length<5">
  40. </view>
  41. </view>
  42. </view>
  43. <view class="record" ><text @click="handleClick('self')">随手拍上报记录</text></view>
  44. </scroll-view>
  45. <!-- 房间选择弹出层 -->
  46. <view class="popup-max-box" v-if="popupType">
  47. <view class="popup-null" @click="popupClick(2)"></view>
  48. <view class="popup-big-box">
  49. <view class="popup-input-box">
  50. <input type="text" maxlength="10" v-model="room" placeholder="请输入关键字">
  51. <view @click="buildBySub">搜索</view>
  52. </view>
  53. <view class="popup-for-max-box">
  54. <view class="popup-for-null" v-if="!roomList[0]">暂无数据</view>
  55. <view class="popup-for-box" v-for="(item,index) in roomList" :key="index">
  56. <view class="name-p">{{item.name}} ({{item.room}})</view>
  57. <view class="button-p" @click="popupClickItem(item)">确定</view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="bottom_btn" @click="submitForm()">提交</view>
  63. </view>
  64. </template>
  65. <script>
  66. import { config } from '@/api/request/config.js'
  67. import { buildBySub,conditionCollegeInfo,checkClapAdd,subjectList,getUserCollegCheck,listDepartments} from '@/api/index.js'
  68. export default {
  69. name: "rectifyList",
  70. components: {
  71. },
  72. data() {
  73. return {
  74. configURL:config.base_url,
  75. pageType:0,
  76. //列表请求参数
  77. getData:{
  78. pageNum:1,
  79. pageSize:20,
  80. },
  81. form:{
  82. deptId:'',
  83. deptName:'',
  84. subId:'',
  85. subName:'',
  86. hazardDescribe:'',
  87. imgDtoList:[],
  88. },
  89. collegeIndex :0,
  90. collegeArray:[],
  91. categoryIndex :0,
  92. collegeList:[],
  93. categoryArray:['校级巡查','院级巡查'],
  94. planIndex :0,
  95. planArray:['请选择巡查计划标题','2023年3月份校级督导检查','2023年4月份校级督导检查'],
  96. resultIndex :0,
  97. resultArray:['不符合','符合'],
  98. informIndex:0,
  99. informArray:['整改告知书','整改通知书'],
  100. //房间弹层 状态
  101. popupType:false,
  102. //房间搜索字段
  103. room:"",
  104. roomList:[],
  105. }
  106. },
  107. onLoad(option) {
  108. },
  109. onShow() {
  110. },
  111. mounted(){
  112. this.listDepartments();
  113. // this.getUserCollegCheck();
  114. },
  115. methods: {
  116. //滚动事件
  117. scrollGet(){},
  118. handleClick(doType){
  119. let self=this;
  120. if( doType=='manage'){//随手拍管理
  121. uni.redirectTo({
  122. url: '/pages_safetyExamine/snapshotManage/snapshotList?pageType=1'
  123. });
  124. }else if(doType=='self'){//随手拍上报记录
  125. uni.redirectTo({
  126. url: '/pages_safetyExamine/snapshotManage/snapshotList?pageType=2'
  127. });
  128. }else if(doType=='subBtn'){//提交
  129. }
  130. },
  131. collegeChange(e){
  132. this.collegeIndex = e.target.value;
  133. this.form.deptId=this.collegeList[e.target.value].deptId
  134. this.form.deptName=this.collegeList[e.target.value].deptName
  135. },
  136. // 图片上传
  137. selectImage() {
  138. let self = this;
  139. if(this.form.imgDtoList.length>4){
  140. uni.showToast({
  141. title: '最多上传5张图片',
  142. icon:"none",
  143. mask:true,
  144. duration: 2000
  145. });
  146. return
  147. }
  148. wx.chooseImage({
  149. count: 5,
  150. sizeType: ["original", "compressed"],
  151. sourceType: ["album", "camera"],
  152. success: function(res) {
  153. //let tempFilePaths = res.tempFilePaths[0];
  154. self.uploadImg(res.tempFilePaths);
  155. }
  156. });
  157. },
  158. async uploadImg(tempFilePaths){
  159. var self = this;
  160. uni.showLoading({
  161. title: '上传中',
  162. mask: true
  163. });
  164. for(let i=0;i<tempFilePaths.length;i++){
  165. console.log(tempFilePaths[i])
  166. uni.uploadFile({
  167. url: config.base_url+'/base/file/upload', //仅为示例,非真实的接口地址
  168. header:{'Authorization':uni.getStorageSync('token')},
  169. filePath: tempFilePaths[i],
  170. name: 'file',
  171. formData: {
  172. 'user': 'test'
  173. },
  174. success: (uploadFileRes) => {
  175. let res = JSON.parse(uploadFileRes.data);
  176. console.log(res.data)
  177. if(res.code == 200){
  178. this.form.imgDtoList.push({'fileUrl':res.data.url,'fileName':res.data.name});
  179. }else{
  180. uni.showToast({
  181. title: res.msg,
  182. icon:"none",
  183. mask:true,
  184. duration: 2000
  185. });
  186. }
  187. },
  188. fail: err => {},
  189. complete: () => {
  190. uni.hideLoading()
  191. }
  192. });
  193. }
  194. },
  195. //删除图片
  196. delImg(minIndex){
  197. this.form.imgDtoList.splice(minIndex,1);
  198. this.$forceUpdate();
  199. },
  200. //搜索房间弹层开关
  201. popupClick(type){
  202. if(type == 1){
  203. this.room = "";
  204. this.roomList = [];
  205. this.popupType = true;
  206. this.buildBySub();
  207. }else if(type == 2){
  208. this.popupType = false;
  209. }
  210. },
  211. //搜索房间接口
  212. async buildBySub(){
  213. let self = this;
  214. const {data} = await buildBySub({'searchValue':this.room,'deptId':this.form.deptId});
  215. if(data.code==200){
  216. if(data.data[0]){
  217. this.roomList = data.data;
  218. }else{
  219. uni.showToast({
  220. title: '未找到相关实验室',
  221. icon:"none",
  222. mask:true,
  223. duration: 2000
  224. });
  225. }
  226. }
  227. },
  228. //确认搜索房间
  229. popupClickItem(item){
  230. console.log(item)
  231. this.$set(this.form,"subId",item.id)
  232. this.$set(this.form,"subName",item.name)
  233. this.$set(this.form,"deptId",item.deptId)
  234. for(let i=0;i<this.collegeList.length;i++){
  235. if(item.deptId==this.collegeList[i].deptId){
  236. this.$set(this.form,"deptName",this.collegeList[i].deptName)
  237. }
  238. }
  239. this.popupType = false;
  240. },
  241. //调用摄像头
  242. saoCode(){
  243. let self = this;
  244. uni.scanCode({
  245. onlyFromCamera: true,
  246. success: function (res) {
  247. if(res.result.indexOf("code") != -1 && res.result.indexOf("-") != -1 && res.result.indexOf("&") != -1){
  248. let codeRoom = "";
  249. let newList = res.result.split("?")[1].split("&")
  250. let list = newList[0].split("=")[1].split("-")
  251. codeRoom = list[1];
  252. if(codeRoom){
  253. self.roomList = [];
  254. self.room = codeRoom;
  255. self.buildBySub();
  256. self.popupType = true;
  257. }else{
  258. uni.showToast({
  259. title: '请扫描正确的二维码',
  260. icon:"none",
  261. mask:true,
  262. duration: 2000
  263. });
  264. }
  265. }else{
  266. uni.showToast({
  267. title: '请扫描正确的二维码',
  268. icon:"none",
  269. mask:true,
  270. duration: 2000
  271. });
  272. }
  273. }
  274. });
  275. },
  276. //查询用户身份信息
  277. async getUserCollegCheck(){
  278. let _this = this;
  279. const {data} = await getUserCollegCheck();
  280. if(data.code == 200){
  281. this.form.deptId=data.data.dept.deptId;
  282. this.form.deptName=data.data.dept.deptName;
  283. }
  284. },
  285. //查询学院列表
  286. async listDepartments(){
  287. let _this = this;
  288. const {data} = await listDepartments();
  289. if(data.code == 200){
  290. for(let i=0;i<data.data.length;i++){
  291. _this.collegeArray.push(data.data[i].deptName)
  292. }
  293. _this.collegeList=data.data;
  294. }
  295. },
  296. //添加
  297. async submitForm(){
  298. let _this = this;
  299. const {data} = await checkClapAdd(_this.form);
  300. if(data.code == 200){
  301. uni.showToast({
  302. title: '提交成功',
  303. icon:"none",
  304. mask:true,
  305. duration: 2000
  306. });
  307. uni.redirectTo({
  308. url: '/pages_safetyExamine/snapshotManage/snapshotList?pageType=2'
  309. });
  310. }
  311. },
  312. }
  313. }
  314. </script>
  315. <style lang="stylus" scoped>
  316. .examine{
  317. height:100%;
  318. display flex;
  319. box-sizing: border-box;
  320. .info-max-box{
  321. flex: 1;
  322. overflow: scroll;
  323. padding: 120rpx 0rpx 128rpx;
  324. box-sizing: border-box;
  325. }
  326. .header{
  327. width: 749rpx;
  328. height: 100rpx;
  329. background: #FFFFFF;
  330. padding:0 40rpx 0 30rpx;
  331. box-sizing: border-box;
  332. display: flex;
  333. justify-content: space-between;
  334. align-items: center;
  335. position: fixed;
  336. left: 0;
  337. top: 0;
  338. >text{
  339. font-size: 30rpx;
  340. font-family: PingFang SC-Medium, PingFang SC;
  341. font-weight: 400;
  342. color: #333333;
  343. line-height: 42rpx;
  344. }
  345. >img{
  346. width: 8rpx;
  347. height: 14rpx;
  348. }
  349. }
  350. .basics{
  351. margin: 0 30rpx;
  352. width: 690rpx;
  353. background: #FFFFFF;
  354. border-radius: 20rpx;
  355. padding: 30rpx 28rpx 30rpx;
  356. box-sizing: border-box;
  357. .basics_li{
  358. display: flex;
  359. justify-content: flex-start;
  360. margin-bottom: 24rpx;
  361. .basics_li_l{
  362. width: 146rpx;
  363. text-align: left;
  364. font-size: 30rpx;
  365. font-family: PingFang SC-Medium, PingFang SC;
  366. font-weight: 400;
  367. color: #333333;
  368. line-height: 80rpx;
  369. }
  370. .basics_li_r{
  371. width: 486rpx;
  372. height: 80rpx;
  373. border-radius: 10rpx;
  374. opacity: 1;
  375. border: 1rpx solid #E0E0E0;
  376. padding-left: 20rpx;
  377. box-sizing: border-box;
  378. }
  379. /* 学院 */
  380. .college_r{
  381. width: 486rpx;
  382. height: 80rpx;
  383. border-radius: 10rpx;
  384. border: 1rpx solid #E0E0E0;
  385. display: flex;
  386. justify-content: flex-start;
  387. align-items: center;
  388. >view{
  389. flex:1;
  390. line-height:80rpx;
  391. font-size: 30rpx;
  392. font-family: PingFang SC-Medium, PingFang SC;
  393. font-weight: 400;
  394. color: #333333;
  395. line-height: 80rpx;
  396. }
  397. >img{
  398. width: 14rpx;
  399. height: 8rpx;
  400. margin-right: 30rpx;
  401. }
  402. }
  403. /* 实验室 */
  404. .lab_r{
  405. width: 486rpx;
  406. height: 80rpx;
  407. display: flex;
  408. justify-content: flex-start;
  409. .picker-text{
  410. width: 438rpx;
  411. height: 80rpx;
  412. }
  413. .img-box{
  414. width: 48rpx;
  415. >img{
  416. width:30rpx;
  417. height:28rpx;
  418. margin:26rpx 18rpx 0 0;
  419. }
  420. }
  421. }
  422. }
  423. /* 隐患描述 */
  424. .check-for-input-max-box{
  425. .left-title-p{
  426. width:150rpx;
  427. line-height:80rpx;
  428. text-align right
  429. font-size:30rpx;
  430. }
  431. textarea{
  432. width: 630rpx;
  433. height: 158rpx;
  434. border-radius: 20rpx 20rpx 20rpx 20rpx;
  435. border: 1rpx solid #E0E0E0;
  436. padding: 20rpx 14rpx;
  437. box-sizing: border-box;
  438. font-size: 30rpx;
  439. font-family: PingFang SC-Medium, PingFang SC;
  440. font-weight: 400;
  441. color: #333333;
  442. line-height: 34rpx;
  443. }
  444. }
  445. /* 隐患照片 */
  446. .check-for-img-max-box{
  447. .left-title-p{
  448. width: 100%;
  449. text-align: left;
  450. font-size: 30rpx;
  451. font-family: PingFang SC-Medium, PingFang SC;
  452. font-weight: 400;
  453. color: #333333;
  454. line-height: 80rpx;
  455. }
  456. .right-img-box{
  457. .img-box{
  458. display inline-block;
  459. height:200rpx;
  460. width:200rpx;
  461. position relative
  462. margin:0 14rpx 20rpx 0;
  463. border-radius 10rpx;
  464. overflow hidden;
  465. .img-data{
  466. height:200rpx;
  467. width:200rpx;
  468. }
  469. .position-img{
  470. position absolute
  471. right:0;
  472. top:0;
  473. width:36rpx;
  474. height:36rpx;
  475. }
  476. }
  477. .img-box:nth-of-type(3n+3){
  478. margin-right: 0rpx;
  479. }
  480. .add-button{
  481. margin:0 0rpx 20rpx 0;
  482. border-radius 10rpx;
  483. overflow hidden;
  484. display inline-block
  485. height:200rpx;
  486. width:200rpx;
  487. }
  488. }
  489. }
  490. }
  491. .record{
  492. overflow: hidden;
  493. >text{
  494. display: block;
  495. width: 220rpx;
  496. height: 40rpx;
  497. background: #E0E0E0;
  498. border-radius: 60rpx 60rpx 60rpx 60rpx;
  499. margin: 122rpx 0 90rpx 266rpx;
  500. font-size: 26rpx;
  501. font-family: PingFang SC-Medium, PingFang SC;
  502. font-weight: 400;
  503. color: #0183FA;
  504. line-height: 40rpx;
  505. text-align: center;
  506. }
  507. }
  508. .popup-max-box{
  509. z-index:10;
  510. height:100%;
  511. width:100%;
  512. position fixed;
  513. background rgba(0,0,0,0.2)
  514. display flex;
  515. flex-direction column
  516. .popup-null{
  517. flex:1;
  518. }
  519. .popup-big-box{
  520. border-top-left-radius:20rpx;
  521. border-top-right-radius:20rpx;
  522. background #fff
  523. .popup-input-box{
  524. padding:30rpx 20rpx;
  525. display:flex;
  526. input{
  527. flex:1;
  528. height:70rpx;
  529. border:1rpx solid #e0e0e0;
  530. border-radius:10rpx;
  531. margin-right:20rpx;
  532. padding:0 20rpx;
  533. }
  534. view{
  535. background #0183FA
  536. color:#fff;
  537. border-radius:10rpx;
  538. width:140rpx;
  539. line-height:70rpx;
  540. text-align center;
  541. font-size:28rpx;
  542. }
  543. }
  544. .popup-for-max-box{
  545. margin:0 20rpx 30rpx;
  546. height:600rpx;
  547. overflow-y scroll;
  548. .popup-for-null{
  549. line-height:100rpx;
  550. text-align center
  551. color:#999;
  552. }
  553. .popup-for-box{
  554. display:flex;
  555. padding:10px 0;
  556. .name-p{
  557. flex:1;
  558. line-height:60rpx;
  559. }
  560. .button-p{
  561. background #0183FA
  562. color:#fff;
  563. text-align center
  564. width:100rpx;
  565. line-height:60rpx;
  566. height:60rpx;
  567. border-radius:10rpx;
  568. }
  569. }
  570. }
  571. }
  572. }
  573. .bottom_btn{
  574. position: fixed;
  575. bottom: 26rpx;
  576. left: 30rpx;
  577. font-size: 30rpx;
  578. font-family: PingFang SC-Medium, PingFang SC;
  579. font-weight: 400;
  580. color: #FFFFFF;
  581. line-height: 90rpx;
  582. width: 690rpx;
  583. height: 90rpx;
  584. background: #0183FA;
  585. border-radius: 20rpx;
  586. text-align: center;
  587. }
  588. }
  589. </style>