photoInspection.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <!-- 拍照检查 -->
  2. <template>
  3. <view id="photoInspection">
  4. <view class="picker-max-box">
  5. <view class="picker-title-box">
  6. <view>*</view>
  7. <view>实验室:</view>
  8. </view>
  9. <picker @change="buttonChange" :range-key="'subName'" :value="subId" :range="subList">
  10. <view class="picker-min-box">
  11. <view>{{subListIndex?subList[subListIndex].subName:'请选择'}}</view>
  12. <img src="@/pages_basics/images/icon_06.png">
  13. </view>
  14. </picker>
  15. </view>
  16. <view class="null-p" v-if="!subList[0]">当前无正在进行中的打卡记录</view>
  17. <view class="null-p" v-if="subList[0]&&subListIndex!=''">请选择实验</view>
  18. <view class="outCheckList-max-box">
  19. <view class="for-add-max-box" v-for="(item,index) in outCheckData.list" :key="index">
  20. <view class="for-add-img-box" v-if="outCheckData.isUpload">
  21. <p v-if="!item.subUrl" @click="upImg(index)">+添加</p>
  22. <img v-else :src="baseUrl+item.subUrl" @click="upImg(index)">
  23. </view>
  24. <view @click="checkItem(index)" :class="outCheckData.isUpload?'for-add-name-p-one':'for-add-name-p-two'"
  25. class="for-add-name-p">
  26. {{item.checkOutName}}
  27. </view>
  28. <uni-icons v-if="item.checkType" class="for-add-icon" type="checkmarkempty" color='#fff' size="24"></uni-icons>
  29. </view>
  30. </view>
  31. <view class="up-data-button" @click="upButton">离开</view>
  32. <helang-compress ref="helangCompress"></helang-compress>
  33. </view>
  34. </template>
  35. <script>
  36. import helangCompress from '@/pages_basics/component/compress.vue';
  37. import {
  38. config
  39. } from '@/api/request/config.js'
  40. import {
  41. laboratoryAppletSignSubList,
  42. laboratoryAppletOutCheckList,
  43. laboratoryAppletAddPhotoInspect,
  44. laboratoryAppletSignOutSubmit
  45. } from '@/pages_basics/api/index.js'
  46. export default {
  47. components: {
  48. helangCompress
  49. },
  50. data() {
  51. return {
  52. baseUrl: config.base_url,
  53. newData: {},
  54. subList: [],
  55. subListIndex: "",
  56. subId:'',
  57. pageType: 2,
  58. outCheckData: {
  59. list: [],
  60. },
  61. params: {
  62. maxSize: 400,
  63. fileType: 'png',
  64. quality: 0.85,
  65. minSize: 320
  66. }
  67. }
  68. },
  69. onLoad(option) {
  70. // this.newData = JSON.parse(decodeURIComponent(option.newData));
  71. // console.log(this.newData)
  72. },
  73. onShow() {
  74. this.laboratoryAppletSignSubList();
  75. },
  76. methods: {
  77. buttonChange(e) {
  78. this.subListIndex = e.mp.detail.value;
  79. this.subId=this.subList[this.subListIndex].subId;
  80. this.laboratoryAppletOutCheckList()
  81. },
  82. //获取实验室
  83. async laboratoryAppletSignSubList() {
  84. const {
  85. data
  86. } = await laboratoryAppletSignSubList();
  87. if (data.code == 200) {
  88. this.subList = data.data;
  89. }
  90. },
  91. //获取实验室-检查项
  92. async laboratoryAppletOutCheckList() {
  93. const {
  94. data
  95. } = await laboratoryAppletOutCheckList({
  96. subId: this.subList[this.subListIndex].subId
  97. });
  98. if (data.code == 200) {
  99. if(data.data.list[0]){
  100. this.outCheckData = data.data;
  101. }else{
  102. this.laboratoryAppletSignOutSubmit()
  103. }
  104. }
  105. },
  106. checkItem(index) {
  107. if (!this.outCheckData.isUpload) {
  108. this.$set(this.outCheckData.list[index], 'checkType', !this.outCheckData.list[index].checkType);
  109. }
  110. },
  111. upButton() {
  112. let self = this;
  113. if (!this.subListIndex) {
  114. uni.showToast({
  115. title: '请选择实验室',
  116. icon: "none",
  117. mask: true,
  118. duration: 2000
  119. });
  120. return
  121. }
  122. if (self.outCheckData.isUpload) {
  123. for (let i = 0; i < self.outCheckData.list.length; i++) {
  124. if (!self.outCheckData.list[i].subUrl) {
  125. uni.showToast({
  126. title: self.outCheckData.list[i].checkOutName + '-检查照片未上传',
  127. icon: "none",
  128. mask: true,
  129. duration: 2000
  130. });
  131. return
  132. }
  133. }
  134. } else {
  135. for (let i = 0; i < self.outCheckData.list.length; i++) {
  136. if (!self.outCheckData.list[i].checkType) {
  137. uni.showToast({
  138. title: '请点击确认' + self.outCheckData.list[i].checkOutName,
  139. icon: "none",
  140. mask: true,
  141. duration: 2000
  142. });
  143. return
  144. }
  145. }
  146. }
  147. uni.showModal({
  148. // title: '确认要退出吗?',
  149. content: '确认提交吗?',
  150. cancelColor: "#999",
  151. confirmColor: "#0183FA",
  152. success: function(res) {
  153. if (res.confirm) {
  154. self.laboratoryAppletAddPhotoInspect();
  155. console.log('用户点击确定');
  156. } else if (res.cancel) {
  157. console.log('用户点击取消');
  158. }
  159. }
  160. });
  161. },
  162. //拍照检查提交
  163. async laboratoryAppletAddPhotoInspect() {
  164. let self = this;
  165. let obj = {
  166. photoList: [],
  167. }
  168. for (let i = 0; i < self.outCheckData.list.length; i++) {
  169. obj.photoList.push({
  170. passOutId: self.subList[self.subListIndex].passOutId,
  171. checkOut: self.outCheckData.list[i].checkOut,
  172. checkOutName: self.outCheckData.list[i].checkOutName,
  173. subUrl: self.outCheckData.isUpload ? self.outCheckData.list[i].subUrl : ''
  174. })
  175. }
  176. const {
  177. data
  178. } = await laboratoryAppletAddPhotoInspect(obj);
  179. if (data.code == 200) {
  180. uni.showToast({
  181. title: '提交成功',
  182. icon: "none",
  183. mask: true,
  184. duration: 2000
  185. });
  186. setTimeout(function() {
  187. uni.navigateBack();
  188. }, 2000);
  189. }
  190. },
  191. //直接离开
  192. async laboratoryAppletSignOutSubmit() {
  193. let self = this;
  194. const {
  195. data
  196. } = await laboratoryAppletSignOutSubmit({subId:this.subId});
  197. if (data.code == 200) {
  198. uni.showToast({
  199. title: '签退成功!',
  200. icon: "none",
  201. mask: true,
  202. duration: 2000
  203. });
  204. setTimeout(function() {
  205. uni.navigateBack();
  206. }, 2000);
  207. }
  208. },
  209. upImg(index) {
  210. let self = this;
  211. wx.chooseImage({
  212. count: 1,
  213. sizeType: ["original", "compressed"],
  214. sourceType: ["album", "camera"],
  215. success: function(res) {
  216. self.compress(res.tempFilePaths, index);
  217. }
  218. });
  219. },
  220. //图片压缩
  221. compress(tempFilePaths, index) {
  222. let self = this;
  223. uni.showLoading({
  224. title: '压缩中',
  225. mask: true
  226. });
  227. this.$refs.helangCompress.compress({
  228. src: tempFilePaths[0],
  229. maxSize: this.params.maxSize,
  230. fileType: this.params.fileType,
  231. quality: this.params.quality,
  232. minSize: this.params.minSize
  233. }).then((res) => {
  234. uni.hideLoading();
  235. console.log('压缩成功-res', res)
  236. console.log('压缩成功-name', index)
  237. self.uploadImg(res, index);
  238. }).catch((err) => {
  239. uni.hideLoading();
  240. uni.showToast({
  241. title: "压缩失败,请重新上传",
  242. icon: "none"
  243. })
  244. })
  245. },
  246. async uploadImg(tempFilePaths, index) {
  247. var self = this;
  248. uni.showLoading({
  249. title: '上传中',
  250. mask: true
  251. });
  252. uni.uploadFile({
  253. url: config.base_url + '/system/file/upload', //仅为示例,非真实的接口地址
  254. header: {
  255. 'Authorization': uni.getStorageSync('token')
  256. },
  257. filePath: tempFilePaths,
  258. name: 'file',
  259. formData: {
  260. 'user': 'test'
  261. },
  262. success: (uploadFileRes) => {
  263. let res = JSON.parse(uploadFileRes.data);
  264. if (res.code == 200) {
  265. self.$set(this.outCheckData.list[index], 'subUrl', res.data.url);
  266. } else {
  267. uni.showToast({
  268. title: res.msg,
  269. icon: "none",
  270. mask: true,
  271. duration: 2000
  272. });
  273. }
  274. },
  275. fail: err => {},
  276. complete: () => {
  277. uni.hideLoading()
  278. }
  279. });
  280. },
  281. }
  282. }
  283. </script>
  284. <style lang="stylus" scoped>
  285. #photoInspection {
  286. height: 100%;
  287. width: 100%;
  288. display: flex;
  289. flex-direction: column;
  290. overflow: hidden;
  291. .null-p {
  292. text-align: center;
  293. font-size: 28rpx;
  294. line-height: 100rpx;
  295. color: #999;
  296. }
  297. .picker-max-box {
  298. width: 100%;
  299. padding: 20rpx 0;
  300. display: flex;
  301. background: #FFFFFF;
  302. z-index: 100;
  303. .picker-title-box {
  304. padding: 0 20rpx;
  305. display flex;
  306. view {
  307. line-height: 80rpx;
  308. font-size: 28rpx;
  309. }
  310. view:nth-child(1) {
  311. color: red;
  312. }
  313. view:nth-child(2) {}
  314. view:nth-child(3) {
  315. color: #999;
  316. }
  317. }
  318. .picker-min-box {
  319. display flex;
  320. height: 80rpx;
  321. width: 556rpx;
  322. border: 1rpx solid #a2a2a2;
  323. border-radius: 10rpx;
  324. margin: 0 20rpx;
  325. view {
  326. flex: 1;
  327. line-height: 80rpx;
  328. padding: 0 20rpx;
  329. color: #999;
  330. font-size: 28rpx;
  331. overflow: hidden;
  332. text-overflow: ellipsis;
  333. white-space: nowrap;
  334. }
  335. img {
  336. width: 24rpx;
  337. height: 12rpx;
  338. margin: 35rpx 23rpx;
  339. }
  340. }
  341. }
  342. .outCheckList-max-box {
  343. margin-top: 30rpx;
  344. flex: 1;
  345. overflow-y: scroll;
  346. .for-add-max-box {
  347. margin: 0 30rpx;
  348. padding-bottom: 40rpx;
  349. position: relative;
  350. .for-add-img-box {
  351. background: #fff;
  352. overflow: hidden;
  353. border: 1px dashed #dedede;
  354. border-top-left-radius: 20rpx;
  355. border-top-right-radius: 20rpx;
  356. p {
  357. width: 690rpx;
  358. height: 250rpx;
  359. line-height: 250rpx;
  360. text-align: center;
  361. color: #0183FA;
  362. }
  363. img {
  364. width: 690rpx;
  365. height: 250rpx;
  366. }
  367. }
  368. .for-add-name-p {
  369. background: #fff;
  370. text-align: center;
  371. line-height: 80rpx;
  372. font-size: 30rpx;
  373. padding: 0 30rpx;
  374. display: block;
  375. overflow: hidden;
  376. text-overflow: ellipsis;
  377. white-space: nowrap;
  378. }
  379. .for-add-name-p-one {
  380. border: 1px dashed #dedede;
  381. border-top: none;
  382. border-bottom-left-radius: 20rpx;
  383. border-bottom-right-radius: 20rpx
  384. }
  385. .for-add-name-p-two {
  386. border: 1px dashed #dedede;
  387. border-radius: 20rpx
  388. }
  389. .for-add-icon {
  390. position: absolute;
  391. right: 0;
  392. bottom: 40rpx;
  393. background-color: #0183FA;
  394. border-top-left-radius: 20rpx;
  395. border-bottom-right-radius: 20rpx;
  396. }
  397. }
  398. }
  399. .up-data-button {
  400. margin:25rpx;
  401. width: 700rpx;
  402. height: 90rpx;
  403. background: #0183FA;
  404. line-height: 90rpx;
  405. border-radius:10rpx;
  406. text-align center;
  407. color: #fff;
  408. font-size: 30rpx;
  409. bottom: 0;
  410. }
  411. }
  412. </style>