snapshotAdd.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  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_safetyExamine/images/icon_ssp_closure.png" @click="delImg(imgIndex)">
  38. </view>
  39. <img class="add-button" src="@/pages_safetyExamine/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/apiDemo/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.navigateTo({
  122. url: '/pages_safetyExamine/views/snapshotManage/snapshotList?pageType=1'
  123. });
  124. }else if(doType=='self'){//随手拍上报记录
  125. uni.navigateTo({
  126. url: '/pages_safetyExamine/views/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 + '/system/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. if(!this.form.deptId){
  300. uni.showToast({
  301. title: '请选择学院!',
  302. icon:"none",
  303. mask:true,
  304. duration: 2000
  305. });
  306. return
  307. }
  308. if(!this.form.subId){
  309. uni.showToast({
  310. title: '请选择实验室!',
  311. icon:"none",
  312. mask:true,
  313. duration: 2000
  314. });
  315. return
  316. }
  317. if(this.form.imgDtoList.length==0){
  318. uni.showToast({
  319. title: '请上传隐患照片!',
  320. icon:"none",
  321. mask:true,
  322. duration: 2000
  323. });
  324. return
  325. }
  326. const {data} = await checkClapAdd(_this.form);
  327. if(data.code == 200){
  328. uni.showToast({
  329. title: '提交成功',
  330. icon:"none",
  331. mask:true,
  332. duration: 2000
  333. });
  334. uni.navigateTo({
  335. url: '/pages_safetyExamine/views/snapshotManage/snapshotList?pageType=2'
  336. });
  337. }
  338. },
  339. }
  340. }
  341. </script>
  342. <style lang="stylus" scoped>
  343. .examine{
  344. height:100%;
  345. display flex;
  346. box-sizing: border-box;
  347. .info-max-box{
  348. flex: 1;
  349. overflow: scroll;
  350. padding: 120rpx 0rpx 128rpx;
  351. box-sizing: border-box;
  352. }
  353. .header{
  354. width: 749rpx;
  355. height: 100rpx;
  356. background: #FFFFFF;
  357. padding:0 40rpx 0 30rpx;
  358. box-sizing: border-box;
  359. display: flex;
  360. justify-content: space-between;
  361. align-items: center;
  362. position: fixed;
  363. left: 0;
  364. top: 0;
  365. >text{
  366. font-size: 30rpx;
  367. font-family: PingFang SC-Medium, PingFang SC;
  368. font-weight: 400;
  369. color: #333333;
  370. line-height: 42rpx;
  371. }
  372. >img{
  373. width: 8rpx;
  374. height: 14rpx;
  375. }
  376. }
  377. .basics{
  378. margin: 0 30rpx;
  379. width: 690rpx;
  380. background: #FFFFFF;
  381. border-radius: 20rpx;
  382. padding: 30rpx 28rpx 30rpx;
  383. box-sizing: border-box;
  384. .basics_li{
  385. display: flex;
  386. justify-content: flex-start;
  387. margin-bottom: 24rpx;
  388. .basics_li_l{
  389. width: 146rpx;
  390. text-align: left;
  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. .basics_li_r{
  398. width: 486rpx;
  399. height: 80rpx;
  400. border-radius: 10rpx;
  401. opacity: 1;
  402. border: 1rpx solid #E0E0E0;
  403. padding-left: 20rpx;
  404. box-sizing: border-box;
  405. }
  406. /* 学院 */
  407. .college_r{
  408. width: 486rpx;
  409. height: 80rpx;
  410. border-radius: 10rpx;
  411. border: 1rpx solid #E0E0E0;
  412. display: flex;
  413. justify-content: flex-start;
  414. align-items: center;
  415. >view{
  416. flex:1;
  417. line-height:80rpx;
  418. font-size: 30rpx;
  419. font-family: PingFang SC-Medium, PingFang SC;
  420. font-weight: 400;
  421. color: #333333;
  422. line-height: 80rpx;
  423. }
  424. >img{
  425. width: 14rpx;
  426. height: 8rpx;
  427. margin-right: 30rpx;
  428. }
  429. }
  430. /* 实验室 */
  431. .lab_r{
  432. width: 486rpx;
  433. height: 80rpx;
  434. display: flex;
  435. justify-content: flex-start;
  436. .picker-text{
  437. width: 438rpx;
  438. height: 80rpx;
  439. }
  440. .img-box{
  441. width: 48rpx;
  442. >img{
  443. width:30rpx;
  444. height:28rpx;
  445. margin:26rpx 18rpx 0 0;
  446. }
  447. }
  448. }
  449. }
  450. /* 隐患描述 */
  451. .check-for-input-max-box{
  452. .left-title-p{
  453. width:150rpx;
  454. line-height:80rpx;
  455. text-align right
  456. font-size:30rpx;
  457. }
  458. textarea{
  459. width: 630rpx;
  460. height: 158rpx;
  461. border-radius: 20rpx 20rpx 20rpx 20rpx;
  462. border: 1rpx solid #E0E0E0;
  463. padding: 20rpx 14rpx;
  464. box-sizing: border-box;
  465. font-size: 30rpx;
  466. font-family: PingFang SC-Medium, PingFang SC;
  467. font-weight: 400;
  468. color: #333333;
  469. line-height: 34rpx;
  470. }
  471. }
  472. /* 隐患照片 */
  473. .check-for-img-max-box{
  474. .left-title-p{
  475. width: 100%;
  476. text-align: left;
  477. font-size: 30rpx;
  478. font-family: PingFang SC-Medium, PingFang SC;
  479. font-weight: 400;
  480. color: #333333;
  481. line-height: 80rpx;
  482. }
  483. .right-img-box{
  484. .img-box{
  485. display inline-block;
  486. height:200rpx;
  487. width:200rpx;
  488. position relative
  489. margin:0 14rpx 20rpx 0;
  490. border-radius 10rpx;
  491. overflow hidden;
  492. .img-data{
  493. height:200rpx;
  494. width:200rpx;
  495. }
  496. .position-img{
  497. position absolute
  498. right:0;
  499. top:0;
  500. width:36rpx;
  501. height:36rpx;
  502. }
  503. }
  504. .img-box:nth-of-type(3n+3){
  505. margin-right: 0rpx;
  506. }
  507. .add-button{
  508. margin:0 0rpx 20rpx 0;
  509. border-radius 10rpx;
  510. overflow hidden;
  511. display inline-block
  512. height:200rpx;
  513. width:200rpx;
  514. }
  515. }
  516. }
  517. }
  518. .record{
  519. overflow: hidden;
  520. >text{
  521. display: block;
  522. width: 220rpx;
  523. height: 40rpx;
  524. background: #E0E0E0;
  525. border-radius: 60rpx 60rpx 60rpx 60rpx;
  526. margin: 122rpx 0 90rpx 266rpx;
  527. font-size: 26rpx;
  528. font-family: PingFang SC-Medium, PingFang SC;
  529. font-weight: 400;
  530. color: #0183FA;
  531. line-height: 40rpx;
  532. text-align: center;
  533. }
  534. }
  535. .popup-max-box{
  536. z-index:10;
  537. height:100%;
  538. width:100%;
  539. position fixed;
  540. background rgba(0,0,0,0.2)
  541. display flex;
  542. flex-direction column
  543. .popup-null{
  544. flex:1;
  545. }
  546. .popup-big-box{
  547. border-top-left-radius:20rpx;
  548. border-top-right-radius:20rpx;
  549. background #fff
  550. .popup-input-box{
  551. padding:30rpx 20rpx;
  552. display:flex;
  553. input{
  554. flex:1;
  555. height:70rpx;
  556. border:1rpx solid #e0e0e0;
  557. border-radius:10rpx;
  558. margin-right:20rpx;
  559. padding:0 20rpx;
  560. }
  561. view{
  562. background #0183FA
  563. color:#fff;
  564. border-radius:10rpx;
  565. width:140rpx;
  566. line-height:70rpx;
  567. text-align center;
  568. font-size:28rpx;
  569. }
  570. }
  571. .popup-for-max-box{
  572. margin:0 20rpx 30rpx;
  573. height:600rpx;
  574. overflow-y scroll;
  575. .popup-for-null{
  576. line-height:100rpx;
  577. text-align center
  578. color:#999;
  579. }
  580. .popup-for-box{
  581. display:flex;
  582. padding:10px 0;
  583. .name-p{
  584. flex:1;
  585. line-height:60rpx;
  586. }
  587. .button-p{
  588. background #0183FA
  589. color:#fff;
  590. text-align center
  591. width:100rpx;
  592. line-height:60rpx;
  593. height:60rpx;
  594. border-radius:10rpx;
  595. }
  596. }
  597. }
  598. }
  599. }
  600. .bottom_btn{
  601. position: fixed;
  602. bottom: 26rpx;
  603. left: 30rpx;
  604. font-size: 30rpx;
  605. font-family: PingFang SC-Medium, PingFang SC;
  606. font-weight: 400;
  607. color: #FFFFFF;
  608. line-height: 90rpx;
  609. width: 690rpx;
  610. height: 90rpx;
  611. background: #0183FA;
  612. border-radius: 20rpx;
  613. text-align: center;
  614. }
  615. }
  616. </style>