photoInspection.vue 10 KB

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