commonFun.js 7.3 KB

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