photoInspection.vue 10 KB

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