commonFun.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. import { get, post } from '../http/http.js'
  2. import { pathUrl } from "../tools/photograph.js";
  3. // 如果不是静配,药配,标本配送,标本轮巡
  4. // 科室签到(小扫描)-拍照
  5. export function nextDeptOrder_ss(_this, data, accountObj) {
  6. uni.showLoading({
  7. title: "加载中",
  8. mask: true,
  9. });
  10. _this.actions = _this.actions || [];
  11. console.log(_this.currentCode);
  12. if (_this.currentCode) {
  13. // 动作
  14. let actions = _this.actions.filter(v => v.checked);
  15. let actionRemarks = actions.map(v => v.name).toString();
  16. if(actionRemarks){
  17. post("/workerOrder/addOtherRemarks", {
  18. orderId: data.id,
  19. actionRemarks: actionRemarks,
  20. }).then((result1) => {
  21. if(result1.state == 200){
  22. postWorkerOrder(_this, data, accountObj);
  23. }else{
  24. uni.hideLoading();
  25. uni.showToast({
  26. icon: "none",
  27. title: "请求失败!",
  28. });
  29. }
  30. });
  31. }else{
  32. postWorkerOrder(_this, data, accountObj);
  33. }
  34. }else{
  35. uni.hideLoading();
  36. }
  37. }
  38. // 完成工单
  39. export function uploadToOther(_this, data, accountObj){
  40. uni.showLoading({
  41. mask: true,
  42. title: '加载中'
  43. });
  44. _this.imageValue = _this.imageValue || [];
  45. let imageValue = _this.imageValue;
  46. // 完成工单
  47. post('/workerOrder/findRecordInfoByOrderId', {
  48. orderId: data.id,
  49. gdOperate: 22,
  50. }).then(result => {
  51. if (result.state == 200) {
  52. let n = 0;
  53. //#ifdef H5
  54. imageValue.forEach((v) => {
  55. // 图片上传 start
  56. console.log("压缩前");
  57. let canvasWidth = v.image.width; //图片原始长宽
  58. let canvasHeight = v.image.height;
  59. let img = new Image();
  60. img.src = v.path;
  61. let canvas = document.createElement("canvas");
  62. let ctx = canvas.getContext("2d");
  63. canvas.width = canvasWidth;
  64. canvas.height = canvasHeight;
  65. ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight);
  66. canvas.toBlob(
  67. (fileSrc) => {
  68. let tp = window.URL.createObjectURL(fileSrc);
  69. console.log("压缩后");
  70. n++;
  71. uni.uploadFile({
  72. url: pathUrl +
  73. "/common/common/uploadAttachment/orderEndPhoto/" +
  74. data.id +
  75. "/" + result.recordId,
  76. filePath: tp,
  77. name: "file",
  78. formData: {
  79. filename: v.name,
  80. },
  81. success: (uploadFileRes) => {
  82. console.log(uploadFileRes);
  83. if (--n === 0) {
  84. nextDeptOrder_ss(_this, data, accountObj);
  85. }
  86. },
  87. fail: (err) => {
  88. n--;
  89. console.error(err);
  90. uni.showToast({
  91. icon: "none",
  92. title: "上传失败",
  93. duration: 2000,
  94. });
  95. },
  96. });
  97. },
  98. "image/jpeg",
  99. 0.1
  100. );
  101. // 图片上传 end
  102. });
  103. //#endif
  104. //#ifdef APP-PLUS
  105. imageValue.forEach((v) => {
  106. // 图片上传 start
  107. uni.compressImage({
  108. src: v.path,
  109. quality: 30,
  110. success: (res) => {
  111. console.log('压缩前', res)
  112. let tp = res.tempFilePath;
  113. console.log("压缩后");
  114. n++;
  115. uni.uploadFile({
  116. url: pathUrl +
  117. "/common/common/uploadAttachment/orderEndPhoto/" +
  118. data.id +
  119. "/" + result.recordId,
  120. filePath: tp,
  121. name: "file",
  122. formData: {
  123. filename: v.name,
  124. },
  125. success: (uploadFileRes) => {
  126. console.log(uploadFileRes);
  127. if (--n === 0) {
  128. nextDeptOrder_ss(_this, data, accountObj);
  129. }
  130. },
  131. fail: (err) => {
  132. n--;
  133. console.error(err);
  134. uni.showToast({
  135. icon: "none",
  136. title: "上传失败",
  137. duration: 2000,
  138. });
  139. },
  140. });
  141. },
  142. fail: function () {
  143. uni.hideLoading();
  144. uni.showToast({
  145. icon: 'none',
  146. title: '上传失败',
  147. duration: 2000
  148. });
  149. }
  150. })
  151. // 图片上传 end
  152. });
  153. //#endif
  154. }else{
  155. uni.hideLoading();
  156. }
  157. })
  158. }
  159. // 完成工单
  160. export function postWorkerOrder(_this, data, accountObj){
  161. uni.showLoading({
  162. title: "加载中",
  163. mask: true,
  164. });
  165. let isKs = 0;
  166. let ids = [];
  167. let id = data.id;
  168. ids.push(id);
  169. let list = {
  170. code: "",
  171. ids: ids,
  172. };
  173. let code = "";
  174. let type = "";
  175. let gdStateValue = data.gdState.value; //工单状态value
  176. let associationTypeValue = data.taskType.associationType.value; //关联类型value
  177. // 其他临床服务,并且工单状态是待到达||工单状态待送达
  178. if (
  179. (associationTypeValue == "other" &&
  180. gdStateValue == "4") ||
  181. gdStateValue == "5"
  182. ) {
  183. code = _this.currentCode;
  184. type = "orderSign/" + code;
  185. list = {
  186. ids
  187. };
  188. if (accountObj) {
  189. list.handover = [accountObj.accountId];
  190. }
  191. if (_this.logRemarks) {
  192. list.logRemarks = _this.logRemarks;
  193. }
  194. isKs = 1;
  195. }
  196. post("/workerOrder/" + type, list).then((res) => {
  197. console.log(res);
  198. uni.hideLoading();
  199. if (res) {
  200. if (res.status == 200) {
  201. if (
  202. gdStateValue == "4" &&
  203. associationTypeValue == "other"
  204. ) {
  205. uni.navigateTo({
  206. url: `../../pages/scanning_code/scanning_code?type=${associationTypeValue}&type1=${res.type}&id=${data.id}&deptCode=${code}&dept=${res.dept}&accountObj=${encodeURIComponent(JSON.stringify(accountObj))}`,
  207. });
  208. }
  209. if (gdStateValue == "5") {
  210. uni.navigateTo({
  211. url: `../../pages/scanning_code/scanning_code?type=${associationTypeValue}&type1=${res.type}&id=${data.id}&deptCode=${code}&dept=${res.dept}&accountObj=${encodeURIComponent(JSON.stringify(accountObj))}`,
  212. });
  213. }
  214. } else {
  215. uni.navigateTo({
  216. url: `../../pages/scanning_Result/scanning_Result?type=${
  217. associationTypeValue
  218. }&type1=${res.type}&id=${data.id}&status=600&msg=${
  219. res.msg
  220. }&isKs=${isKs}&model=${encodeURIComponent(
  221. JSON.stringify(res)
  222. )}&qrcode=${_this.currentCode}`,
  223. });
  224. }
  225. } else {
  226. uni.navigateTo({
  227. url: `../../pages/scanning_Result/scanning_Result?id=${data.id}&status=600&msg=扫码失败!请扫描正确的二维码!&isKs=${isKs}&qrcode=${_this.currentCode}`,
  228. });
  229. }
  230. });
  231. }