photoInspection.vue 10 KB

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