photograph.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. import {
  2. get,
  3. post
  4. } from "./../http/http.js";
  5. export const pathUrl = uni.getStorageSync('path');
  6. export function photographTool(data, deptObj) {
  7. console.log(data, deptObj, 1111);
  8. let id_seimin;
  9. let asTypeValue_seimin;
  10. let gdStateValue_seimin;
  11. if (data.status != 200 && data.status !== undefined) {
  12. id_seimin = data.id;
  13. asTypeValue_seimin = data.type;
  14. gdStateValue_seimin = JSON.parse(data.model).gdstate2; //type改成gdstate
  15. } else {
  16. id_seimin = data.id;
  17. asTypeValue_seimin = data.taskType.associationType.value;
  18. gdStateValue_seimin = data.gdState.value;
  19. }
  20. //#ifdef H5
  21. uni.chooseImage({
  22. sourceType: ['camera'],
  23. success: (chooseImageRes) => {
  24. console.log(chooseImageRes, pathUrl)
  25. const tempFilePaths = chooseImageRes.tempFilePaths;
  26. const tempFiles = chooseImageRes.tempFiles;
  27. let tp = tempFilePaths[0];
  28. uni.showLoading({
  29. title: '上传中'
  30. });
  31. post('/workerOrder/findPatientCodeByWorkOrderId', {
  32. WorkOrderId: id_seimin
  33. }).then(result => {
  34. console.log(result)
  35. if (result.state == 200) {
  36. uni.getImageInfo({
  37. src: tp,
  38. success(res) {
  39. console.log('压缩前', res)
  40. let canvasWidth = res.width //图片原始长宽
  41. let canvasHeight = res.height
  42. let img = new Image()
  43. img.src = res.path
  44. let canvas = document.createElement('canvas');
  45. let ctx = canvas.getContext('2d')
  46. canvas.width = canvasWidth
  47. canvas.height = canvasHeight
  48. ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight)
  49. canvas.toBlob(function (fileSrc) {
  50. tp = window.URL.createObjectURL(fileSrc)
  51. console.log('压缩后', tp);
  52. uni.uploadFile({
  53. url: pathUrl + '/common/common/uploadAttachment/inspectAndPatient/' + id_seimin + '/' + result.recordId,
  54. filePath: tp,
  55. name: 'file',
  56. formData: {
  57. 'filename': tempFiles[0].name ? tempFiles[0].name.split('.')[0] + '.jpg' : tempFiles[
  58. 0].path.split(
  59. /[\\/]/).reverse()[0].split('.')[0] + '.jpg'
  60. },
  61. success: (uploadFileRes) => {
  62. console.log(uploadFileRes, 10086, asTypeValue_seimin);
  63. if (asTypeValue_seimin === "patientTransport") {
  64. // 转运,扫描患者腕带码
  65. if (gdStateValue_seimin == 4) { //转运待到达
  66. post('/workerOrder/handleTrans', {
  67. "code": result.patientBarCode,
  68. "ids": [id_seimin]
  69. }).then(result1 => {
  70. console.log(result1);
  71. uni.hideLoading();
  72. if (result1.status == 200) {
  73. uni.showToast({
  74. title: '上传成功',
  75. duration: 2000
  76. });
  77. // 小扫描
  78. uni.navigateTo({
  79. url: `../scanning_Result/scanning_Result?type=${asTypeValue_seimin
  80. }&type1=${result1.type}&id=${id_seimin}&deptCode=${result.patientCode
  81. }&patient=${result1.patient}&patientCode=${result1.patientCode
  82. }&deptName=${result1.deptName}&bedNum=${result1.bedNum
  83. }&status=${result1.status}&msg=${result1.msg
  84. }&model=${encodeURIComponent(JSON.stringify(result1))}`,
  85. });
  86. } else {
  87. uni.showToast({
  88. icon: "none",
  89. title: "请求失败!",
  90. });
  91. }
  92. })
  93. } else if (gdStateValue_seimin == 5) { //转运待送达
  94. post('/workerOrder/handleTrans', {
  95. "code": result.patientBarCode,
  96. "ids": [id_seimin],
  97. "type": deptObj.infoType,
  98. "deptCode": deptObj.DEPTCode,
  99. }).then(result1 => {
  100. console.log(result1);
  101. uni.hideLoading();
  102. if (result1.status == 200) {
  103. uni.showToast({
  104. title: '上传成功',
  105. duration: 2000
  106. });
  107. // 小扫描
  108. uni.navigateTo({
  109. url: `../scanning_Result/scanning_Result?type=${asTypeValue_seimin}&type1=${result1.type1}&infoData=${encodeURIComponent(JSON.stringify(result1.data))}&status=${result1.status}&msg=${result1.msg}&patient=${result1.patient}&patientCode=${result1.patientCode}&deptName=${result1.deptName}&bedNum=${result1.bedNum}&deptCode=${deptObj.DEPTCode}&dept=${deptObj.DEPT}&id=${id_seimin}&model=${encodeURIComponent(JSON.stringify(result1))}`
  110. });
  111. } else {
  112. uni.showToast({
  113. icon: "none",
  114. title: "请求失败!",
  115. });
  116. }
  117. })
  118. }
  119. } else if (asTypeValue_seimin === "inspect") {
  120. // 陪检,扫描患者腕带码
  121. if (gdStateValue_seimin == 4) { //陪检待到达
  122. console.log('怎么了')
  123. post('/workerOrder/handleIns', {
  124. "code": result.patientBarCode,
  125. "ids": [id_seimin]
  126. }).then(result1 => {
  127. console.log(result1);
  128. uni.hideLoading();
  129. if (result1.status == 200) {
  130. uni.showToast({
  131. title: '上传成功',
  132. duration: 2000
  133. });
  134. // 小扫描
  135. uni.navigateTo({
  136. url: `../scanning_Result/scanning_Result?type=${asTypeValue_seimin
  137. }&type1=${result1.type}&id=${id_seimin}&deptCode=${result.patientCode
  138. }&patient=${result1.patient}&patientCode=${result1.patientCode
  139. }&deptName=${result1.deptName}&bedNum=${result1.bedNum
  140. }&status=${result1.status}&msg=${result1.msg
  141. }&model=${encodeURIComponent(JSON.stringify(result1))}`,
  142. });
  143. } else {
  144. uni.showToast({
  145. icon: "none",
  146. title: "请求失败!",
  147. });
  148. }
  149. })
  150. } else if (gdStateValue_seimin == 5 || gdStateValue_seimin == 8) { //陪检待送达,执行中
  151. post('/workerOrder/handleIns', {
  152. "code": result.patientBarCode,
  153. "ids": [id_seimin],
  154. "type": deptObj.infoType,
  155. "deptCode": deptObj.DEPTCode,
  156. }).then(result1 => {
  157. console.log(result1);
  158. uni.hideLoading();
  159. if (result1.status == 200) {
  160. uni.showToast({
  161. title: '上传成功',
  162. duration: 2000
  163. });
  164. // 小扫描
  165. uni.navigateTo({
  166. url: `../scanning_Result/scanning_Result?type=${asTypeValue_seimin}&type1=${result1.type1}&infoData=${encodeURIComponent(JSON.stringify(result1.data))}&status=${result1.status}&msg=${result1.msg}&patient=${result1.patient}&patientCode=${result1.patientCode}&deptName=${result1.deptName}&bedNum=${result1.bedNum}&deptCode=${deptObj.DEPTCode}&dept=${deptObj.DEPT}&id=${id_seimin}&model=${encodeURIComponent(JSON.stringify(result1))}`
  167. });
  168. } else {
  169. uni.showToast({
  170. icon: "none",
  171. title: "请求失败!",
  172. });
  173. }
  174. })
  175. }
  176. }
  177. },
  178. fail: err => {
  179. console.error(err);
  180. uni.hideLoading();
  181. uni.showToast({
  182. icon: 'none',
  183. title: '上传失败',
  184. duration: 2000
  185. });
  186. }
  187. });
  188. }, 'image/jpeg', 0.3)
  189. },
  190. fail: function () {
  191. uni.hideLoading();
  192. uni.showToast({
  193. icon: 'none',
  194. title: '上传失败',
  195. duration: 2000
  196. });
  197. }
  198. })
  199. } else {
  200. uni.hideLoading();
  201. uni.showToast({
  202. icon: "none",
  203. title: "请求失败!",
  204. });
  205. }
  206. })
  207. }
  208. });
  209. //#endif
  210. // #ifdef APP-PLUS
  211. uni.chooseImage({
  212. sourceType: ['camera'],
  213. sizeType: ['compressed'],
  214. success: (chooseImageRes) => {
  215. console.log(chooseImageRes, pathUrl)
  216. const tempFilePaths = chooseImageRes.tempFilePaths;
  217. const tempFiles = chooseImageRes.tempFiles;
  218. let tp = tempFilePaths[0];
  219. uni.showLoading({
  220. title: '上传中'
  221. });
  222. post('/workerOrder/findPatientCodeByWorkOrderId', {
  223. WorkOrderId: id_seimin
  224. }).then(result => {
  225. console.log(result)
  226. if (result.state == 200) {
  227. uni.uploadFile({
  228. url: pathUrl + '/common/common/uploadAttachment/inspectAndPatient/' + id_seimin + '/' + result.recordId,
  229. filePath: tp,
  230. name: 'file',
  231. formData: {
  232. 'filename': tempFiles[0].name ? tempFiles[0].name.split('.')[0] + '.jpg' : tempFiles[0].path
  233. .split(
  234. /[\\/]/).reverse()[0].split('.')[0] + '.jpg'
  235. },
  236. success: (uploadFileRes) => {
  237. console.log(uploadFileRes, 10086, asTypeValue_seimin);
  238. if (asTypeValue_seimin === "patientTransport") {
  239. // 转运,扫描患者腕带码
  240. if (gdStateValue_seimin == 4) { //转运待到达
  241. post('/workerOrder/handleTrans', {
  242. "code": result.patientBarCode,
  243. "ids": [id_seimin]
  244. }).then(result1 => {
  245. console.log(result1);
  246. uni.hideLoading();
  247. if (result1.status == 200) {
  248. uni.showToast({
  249. title: '上传成功',
  250. duration: 2000
  251. });
  252. // 小扫描
  253. uni.navigateTo({
  254. url: `../scanning_Result/scanning_Result?type=${asTypeValue_seimin
  255. }&type1=${result1.type}&id=${id_seimin}&deptCode=${result.patientCode
  256. }&patient=${result1.patient}&patientCode=${result1.patientCode
  257. }&deptName=${result1.deptName}&bedNum=${result1.bedNum
  258. }&status=${result1.status}&msg=${result1.msg
  259. }&model=${encodeURIComponent(JSON.stringify(result1))}`,
  260. });
  261. } else {
  262. uni.showToast({
  263. icon: "none",
  264. title: "请求失败!",
  265. });
  266. }
  267. })
  268. } else if (gdStateValue_seimin == 5) { //转运待送达
  269. post('/workerOrder/handleTrans', {
  270. "code": result.patientBarCode,
  271. "ids": [id_seimin],
  272. "type": deptObj.infoType,
  273. "deptCode": deptObj.DEPTCode,
  274. }).then(result1 => {
  275. console.log(result1);
  276. uni.hideLoading();
  277. if (result1.status == 200) {
  278. uni.showToast({
  279. title: '上传成功',
  280. duration: 2000
  281. });
  282. // 小扫描
  283. uni.navigateTo({
  284. url: `../scanning_Result/scanning_Result?type=${asTypeValue_seimin}&type1=${result1.type1}&infoData=${encodeURIComponent(JSON.stringify(result1.data))}&status=${result1.status}&msg=${result1.msg}&patient=${result1.patient}&patientCode=${result1.patientCode}&deptName=${result1.deptName}&bedNum=${result1.bedNum}&deptCode=${deptObj.DEPTCode}&dept=${deptObj.DEPT}&id=${id_seimin}&model=${encodeURIComponent(JSON.stringify(result1))}`
  285. });
  286. } else {
  287. uni.showToast({
  288. icon: "none",
  289. title: "请求失败!",
  290. });
  291. }
  292. })
  293. }
  294. } else if (asTypeValue_seimin === "inspect") {
  295. // 陪检,扫描患者腕带码
  296. if (gdStateValue_seimin == 4) { //陪检待到达
  297. console.log('怎么了')
  298. post('/workerOrder/handleIns', {
  299. "code": result.patientBarCode,
  300. "ids": [id_seimin]
  301. }).then(result1 => {
  302. console.log(result1);
  303. uni.hideLoading();
  304. if (result1.status == 200) {
  305. uni.showToast({
  306. title: '上传成功',
  307. duration: 2000
  308. });
  309. // 小扫描
  310. uni.navigateTo({
  311. url: `../scanning_Result/scanning_Result?type=${asTypeValue_seimin
  312. }&type1=${result1.type}&id=${id_seimin}&deptCode=${result.patientCode
  313. }&patient=${result1.patient}&patientCode=${result1.patientCode
  314. }&deptName=${result1.deptName}&bedNum=${result1.bedNum
  315. }&status=${result1.status}&msg=${result1.msg
  316. }&model=${encodeURIComponent(JSON.stringify(result1))}`,
  317. });
  318. } else {
  319. uni.showToast({
  320. icon: "none",
  321. title: "请求失败!",
  322. });
  323. }
  324. })
  325. } else if (gdStateValue_seimin == 5 || gdStateValue_seimin == 8) { //陪检待送达,执行中
  326. post('/workerOrder/handleIns', {
  327. "code": result.patientBarCode,
  328. "ids": [id_seimin],
  329. "type": deptObj.infoType,
  330. "deptCode": deptObj.DEPTCode,
  331. }).then(result1 => {
  332. console.log(result1);
  333. uni.hideLoading();
  334. if (result1.status == 200) {
  335. uni.showToast({
  336. title: '上传成功',
  337. duration: 2000
  338. });
  339. // 小扫描
  340. uni.navigateTo({
  341. url: `../scanning_Result/scanning_Result?type=${asTypeValue_seimin}&type1=${result1.type1}&infoData=${encodeURIComponent(JSON.stringify(result1.data))}&status=${result1.status}&msg=${result1.msg}&patient=${result1.patient}&patientCode=${result1.patientCode}&deptName=${result1.deptName}&bedNum=${result1.bedNum}&deptCode=${deptObj.DEPTCode}&dept=${deptObj.DEPT}&id=${id_seimin}&model=${encodeURIComponent(JSON.stringify(result1))}`
  342. });
  343. } else {
  344. uni.showToast({
  345. icon: "none",
  346. title: "请求失败!",
  347. });
  348. }
  349. })
  350. }
  351. }
  352. },
  353. fail: err => {
  354. console.error(err);
  355. uni.hideLoading();
  356. uni.showToast({
  357. icon: 'none',
  358. title: '上传失败',
  359. duration: 2000
  360. });
  361. }
  362. });
  363. } else {
  364. uni.hideLoading();
  365. uni.showToast({
  366. icon: "none",
  367. title: "请求失败!",
  368. });
  369. }
  370. })
  371. }
  372. });
  373. // #endif
  374. }