photoInspection.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  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. }
  178. for (let i = 0; i < self.outCheckData.list.length; i++) {
  179. obj.photoList.push({
  180. passOutId: self.subList[self.subListIndex].passOutId,
  181. checkOut: self.outCheckData.list[i].checkOut,
  182. checkOutName: self.outCheckData.list[i].checkOutName,
  183. subUrl: self.outCheckData.isUpload ? self.outCheckData.list[i].subUrl : ''
  184. })
  185. }
  186. const {
  187. data
  188. } = await laboratoryAppletAddPhotoInspect(obj);
  189. if (data.code == 200) {
  190. uni.showToast({
  191. title: '提交成功',
  192. icon: "none",
  193. mask: true,
  194. duration: 2000
  195. });
  196. setTimeout(function() {
  197. uni.navigateBack();
  198. }, 2000);
  199. }
  200. },
  201. //直接离开
  202. async laboratoryAppletSignOutSubmit() {
  203. let self = this;
  204. let obj = {
  205. subId:this.subId,
  206. isotope:this.isotope,
  207. }
  208. const {
  209. data
  210. } = await laboratoryAppletSignOutSubmit(obj);
  211. if (data.code == 200) {
  212. uni.showToast({
  213. title: '签退成功!',
  214. icon: "none",
  215. mask: true,
  216. duration: 2000
  217. });
  218. setTimeout(function() {
  219. uni.navigateBack();
  220. }, 2000);
  221. }
  222. },
  223. upImg(index) {
  224. let self = this;
  225. wx.chooseImage({
  226. count: 1,
  227. sizeType: ["original", "compressed"],
  228. sourceType: ["album", "camera"],
  229. success: function(res) {
  230. self.compress(res.tempFilePaths, index);
  231. }
  232. });
  233. },
  234. //图片压缩
  235. compress(tempFilePaths, index) {
  236. let self = this;
  237. uni.showLoading({
  238. title: '压缩中',
  239. mask: true
  240. });
  241. this.$refs.helangCompress.compress({
  242. src: tempFilePaths[0],
  243. maxSize: this.params.maxSize,
  244. fileType: this.params.fileType,
  245. quality: this.params.quality,
  246. minSize: this.params.minSize
  247. }).then((res) => {
  248. uni.hideLoading();
  249. console.log('压缩成功-res', res)
  250. console.log('压缩成功-name', index)
  251. self.uploadImg(res, index);
  252. }).catch((err) => {
  253. uni.hideLoading();
  254. uni.showToast({
  255. title: "压缩失败,请重新上传",
  256. icon: "none"
  257. })
  258. })
  259. },
  260. async uploadImg(tempFilePaths, index) {
  261. var self = this;
  262. uni.showLoading({
  263. title: '上传中',
  264. mask: true
  265. });
  266. uni.uploadFile({
  267. url: config.base_url + '/system/file/upload', //仅为示例,非真实的接口地址
  268. header: {
  269. 'Authorization': uni.getStorageSync('token')
  270. },
  271. filePath: tempFilePaths,
  272. name: 'file',
  273. formData: {
  274. 'user': 'test'
  275. },
  276. success: (uploadFileRes) => {
  277. let res = JSON.parse(uploadFileRes.data);
  278. if (res.code == 200) {
  279. self.$set(this.outCheckData.list[index], 'subUrl', res.data.url);
  280. } else {
  281. uni.showToast({
  282. title: res.msg,
  283. icon: "none",
  284. mask: true,
  285. duration: 2000
  286. });
  287. }
  288. },
  289. fail: err => {},
  290. complete: () => {
  291. uni.hideLoading()
  292. }
  293. });
  294. },
  295. }
  296. }
  297. </script>
  298. <style lang="stylus" scoped>
  299. #photoInspection {
  300. height: 100%;
  301. width: 100%;
  302. display: flex;
  303. flex-direction: column;
  304. overflow: hidden;
  305. .null-p {
  306. text-align: center;
  307. font-size: 28rpx;
  308. line-height: 100rpx;
  309. color: #999;
  310. }
  311. .picker-max-box {
  312. width: 100%;
  313. padding: 20rpx 0;
  314. display: flex;
  315. background: #FFFFFF;
  316. z-index: 100;
  317. .picker-title-box {
  318. padding: 0 20rpx;
  319. display flex;
  320. view {
  321. line-height: 80rpx;
  322. font-size: 28rpx;
  323. }
  324. view:nth-child(1) {
  325. color: red;
  326. }
  327. view:nth-child(2) {}
  328. view:nth-child(3) {
  329. color: #999;
  330. }
  331. }
  332. .picker-min-box {
  333. display flex;
  334. height: 80rpx;
  335. width: 556rpx;
  336. border: 1rpx solid #a2a2a2;
  337. border-radius: 10rpx;
  338. margin: 0 20rpx;
  339. view {
  340. flex: 1;
  341. line-height: 80rpx;
  342. padding: 0 20rpx;
  343. color: #999;
  344. font-size: 28rpx;
  345. overflow: hidden;
  346. text-overflow: ellipsis;
  347. white-space: nowrap;
  348. }
  349. img {
  350. width: 24rpx;
  351. height: 12rpx;
  352. margin: 35rpx 23rpx;
  353. }
  354. }
  355. }
  356. .outCheckList-max-box {
  357. margin-top: 30rpx;
  358. flex: 1;
  359. overflow-y: scroll;
  360. .for-add-max-box {
  361. margin: 0 30rpx;
  362. padding-bottom: 40rpx;
  363. position: relative;
  364. .for-add-img-box {
  365. background: #fff;
  366. overflow: hidden;
  367. border: 1px dashed #dedede;
  368. border-top-left-radius: 20rpx;
  369. border-top-right-radius: 20rpx;
  370. p {
  371. width: 690rpx;
  372. height: 250rpx;
  373. line-height: 250rpx;
  374. text-align: center;
  375. color: #0183FA;
  376. }
  377. img {
  378. width: 690rpx;
  379. height: 250rpx;
  380. }
  381. }
  382. .for-add-name-p {
  383. background: #fff;
  384. text-align: center;
  385. line-height: 80rpx;
  386. font-size: 30rpx;
  387. padding: 0 30rpx;
  388. display: block;
  389. overflow: hidden;
  390. text-overflow: ellipsis;
  391. white-space: nowrap;
  392. }
  393. .for-add-name-p-one {
  394. border: 1px dashed #dedede;
  395. border-top: none;
  396. border-bottom-left-radius: 20rpx;
  397. border-bottom-right-radius: 20rpx
  398. }
  399. .for-add-name-p-two {
  400. border: 1px dashed #dedede;
  401. border-radius: 20rpx
  402. }
  403. .for-add-icon {
  404. position: absolute;
  405. right: 0;
  406. bottom: 40rpx;
  407. background-color: #0183FA;
  408. border-top-left-radius: 20rpx;
  409. border-bottom-right-radius: 20rpx;
  410. }
  411. }
  412. }
  413. .up-data-button {
  414. margin:25rpx;
  415. width: 700rpx;
  416. height: 90rpx;
  417. background: #0183FA;
  418. line-height: 90rpx;
  419. border-radius:10rpx;
  420. text-align center;
  421. color: #fff;
  422. font-size: 30rpx;
  423. bottom: 0;
  424. }
  425. }
  426. </style>