otherCompleteOrder.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. <template>
  2. <view class="HomeItem">
  3. <view class="goWorkAll">
  4. <view class="goWorkSelect combination" v-if="actionConfirmSwitch">
  5. <view class="goWorkSelect-head">您需要完成以下动作,才可完成工单。如完成请勾选对应项!</view>
  6. <view class="goWorkSelect-list scroll">
  7. <checkbox-group @change="checkboxChange">
  8. <label class="goWorkSelect-item relative" v-for="action in actions" :key="action.value">
  9. <view>
  10. <checkbox :value="action.value" :checked="action.checked" />
  11. </view>
  12. <view>{{action.name}}</view>
  13. </label>
  14. </checkbox-group>
  15. </view>
  16. </view>
  17. <view class="goWorkSelect history" v-if="actionPhotoSwitch">
  18. <view class="goWorkSelect-head">您需要拍摄现场照片才可完成工单!</view>
  19. <view class="goWorkSelect-list">
  20. <uni-file-picker :auto-upload="false" :limit="3" title="最多选择3张图片" v-model="imageValue" fileMediatype="image"
  21. mode="grid" @select="selectFile" @delete="deleteFile"></uni-file-picker>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="foot_btn_spe">
  26. <view class="btn1" @click="photographToOther(order, 'end')">完成工单</view>
  27. <view class="btn3" @click="goBack">返回</view>
  28. </view>
  29. <!-- 填写交接人账号弹窗 -->
  30. <selectAccount v-if="hosModels.disjunctor" :title="hosModels.title" :disjunctor="hosModels.disjunctor" @ok="hosOk"
  31. @cancel="hosCancel">
  32. </selectAccount>
  33. </view>
  34. </template>
  35. <script>
  36. import {
  37. pathUrl
  38. } from "../../tools/photograph.js";
  39. import selectAccount from "../../components/selectAccount/selectAccount.vue";
  40. import {
  41. get,
  42. post,
  43. webHandle
  44. } from "../../http/http.js";
  45. export default {
  46. components: {
  47. selectAccount,
  48. },
  49. data() {
  50. return {
  51. // 填写交接人账号弹窗model
  52. hosModels: {
  53. disjunctor: false,
  54. },
  55. currentCode: '', //当前拍照使用的科室二维码
  56. currentData: {}, //当前小扫描的工单对象
  57. orderId: undefined,
  58. order: {},
  59. // 拍照动作开关
  60. actionPhotoSwitch: false,
  61. // 确认动作开关
  62. actionConfirmSwitch: false,
  63. // 参数
  64. options: {},
  65. //动作列表
  66. actions: [],
  67. //图片列表
  68. imageValue: [],
  69. };
  70. },
  71. methods: {
  72. // 完成工单
  73. postWorkerOrder(data, accountObj){
  74. let isKs = 0;
  75. let ids = [];
  76. let id = data.id;
  77. ids.push(id);
  78. let list = {
  79. code: "",
  80. ids: ids,
  81. };
  82. let code = "";
  83. let type = "";
  84. let gdStateValue = data.gdState.value; //工单状态value
  85. let associationTypeValue = data.taskType.associationType.value; //关联类型value
  86. // 其他临床服务,并且工单状态是待到达||工单状态待送达
  87. if (
  88. (associationTypeValue == "other" &&
  89. gdStateValue == "4") ||
  90. gdStateValue == "5"
  91. ) {
  92. code = this.currentCode;
  93. type = "orderSign/" + code;
  94. list = {
  95. ids
  96. };
  97. if (accountObj) {
  98. list.handover = [accountObj.accountId];
  99. }
  100. isKs = 1;
  101. }
  102. post("/workerOrder/" + type, list).then((res) => {
  103. console.log(res);
  104. uni.hideLoading();
  105. if (res) {
  106. if (res.status == 200) {
  107. if (
  108. gdStateValue == "4" &&
  109. associationTypeValue == "other"
  110. ) {
  111. uni.navigateTo({
  112. url: `../../pages/scanning_code/scanning_code?type=${associationTypeValue}&type1=${res.type}&id=${data.id}&deptCode=${code}&dept=${res.dept}&accountObj=${encodeURIComponent(JSON.stringify(accountObj))}`,
  113. });
  114. }
  115. if (gdStateValue == "5") {
  116. uni.navigateTo({
  117. url: `../../pages/scanning_code/scanning_code?type=${associationTypeValue}&type1=${res.type}&id=${data.id}&deptCode=${code}&dept=${res.dept}&accountObj=${encodeURIComponent(JSON.stringify(accountObj))}`,
  118. });
  119. }
  120. } else {
  121. uni.navigateTo({
  122. url: `../../pages/scanning_Result/scanning_Result?type=${
  123. associationTypeValue
  124. }&type1=${res.type}&id=${data.id}&status=600&msg=${
  125. res.msg
  126. }&isKs=${isKs}&model=${encodeURIComponent(
  127. JSON.stringify(res)
  128. )}&qrcode=${this.currentCode}`,
  129. });
  130. }
  131. } else {
  132. uni.navigateTo({
  133. url: `../../pages/scanning_Result/scanning_Result?id=${data.id}&status=600&msg=扫码失败!请扫描正确的二维码!&isKs=${isKs}&qrcode=${this.currentCode}`,
  134. });
  135. }
  136. });
  137. },
  138. // 如果不是静配,药配,标本配送,标本轮巡
  139. // 科室签到(小扫描)-拍照
  140. nextDeptOrder_ss(data, accountObj) {
  141. console.log(this.currentCode);
  142. if (this.currentCode) {
  143. // 动作
  144. let actions = this.actions.filter(v => v.checked);
  145. let actionRemarks = actions.map(v => v.name).toString();
  146. uni.showLoading({
  147. title: "加载中",
  148. mask: true,
  149. });
  150. if(actionRemarks){
  151. post("/workerOrder/addOtherRemarks", {
  152. orderId: data.id,
  153. actionRemarks: actionRemarks,
  154. }).then((result1) => {
  155. if(result1.state == 200){
  156. this.postWorkerOrder(data, accountObj);
  157. }else{
  158. uni.hideLoading();
  159. uni.showToast({
  160. icon: "none",
  161. title: "请求失败!",
  162. });
  163. }
  164. });
  165. }else{
  166. this.postWorkerOrder(data, accountObj);
  167. }
  168. }
  169. },
  170. // 填写交接人账号-确认
  171. hosOk(data) {
  172. console.log(data);
  173. const {
  174. accountName,
  175. account,
  176. accountId
  177. } = data;
  178. if (!accountName && !account) {
  179. //没有填写交接人
  180. uni.showModal({
  181. title: '提示',
  182. content: "请填写交接人账号!",
  183. showCancel: false,
  184. success: function(res) {
  185. if (res.confirm) {
  186. console.log('用户点击确定');
  187. } else if (res.cancel) {
  188. console.log('用户点击取消');
  189. }
  190. }
  191. });
  192. return;
  193. } else if (!accountName && account || accountName && !account) {
  194. //没有填写交接人
  195. uni.showModal({
  196. title: '提示',
  197. content: "请填写正确的交接人账号!",
  198. showCancel: false,
  199. success: function(res) {
  200. if (res.confirm) {
  201. console.log('用户点击确定');
  202. } else if (res.cancel) {
  203. console.log('用户点击取消');
  204. }
  205. }
  206. });
  207. return;
  208. }
  209. this.hosModels.disjunctor = false;
  210. let associationTypeValue = this.currentData.taskType.associationType.value;
  211. console.log(associationTypeValue)
  212. if(this.actionPhotoSwitch && this.actionConfirmSwitch){
  213. this.uploadToOther(this.currentData, data, 'end');
  214. }else if(this.actionConfirmSwitch){
  215. // 动作
  216. this.nextDeptOrder_ss(this.currentData, data, 'end');
  217. }else if(this.actionPhotoSwitch){
  218. // 拍照
  219. this.uploadToOther(this.currentData, data, 'end');
  220. }
  221. },
  222. // 填写交接人账号-取消
  223. hosCancel() {
  224. this.hosModels.disjunctor = false;
  225. },
  226. // 填写交接人账号弹窗
  227. showSelectAccount() {
  228. this.hosModels = {
  229. title: '填写交接人账号',
  230. disjunctor: true,
  231. }
  232. },
  233. // 拍照-其他
  234. photographToOther(data, type) {
  235. this.currentData = data;
  236. let actions = this.actions.filter(v => v.checked);
  237. let imageValue = this.imageValue;
  238. console.log(actions);
  239. console.log(imageValue);
  240. if(this.actionConfirmSwitch && this.actions.length !== actions.length){
  241. uni.showToast({
  242. icon: "none",
  243. title: '您需要完成以下动作,才可完成功工单!',
  244. duration: 2000
  245. });
  246. return;
  247. }
  248. if(this.actionPhotoSwitch && !imageValue.length){
  249. uni.showToast({
  250. icon: "none",
  251. title: '您需要完成拍照,才可完成功工单!',
  252. duration: 2000
  253. });
  254. return;
  255. }
  256. uni.showLoading({
  257. title: "加载中",
  258. mask: true,
  259. });
  260. // 其他临床服务
  261. //检验二维码的有效性
  262. post("/dept/scanning", {
  263. content: type === 'start' ? data.startDept.qrcode : data.endDepts[0].qrcode,
  264. taskTypeId: data.taskType.id,
  265. gdState: data.gdState.id,
  266. }).then((result) => {
  267. uni.hideLoading();
  268. this.currentCode = result.code;
  269. if (result.state == 200 || result.state == 201) {
  270. let accountObj = undefined;
  271. if (result.account) {
  272. accountObj = {
  273. account: result.account,
  274. accountName: result.name,
  275. accountId: result.id,
  276. };
  277. } else {
  278. accountObj = undefined;
  279. }
  280. if(this.actionPhotoSwitch && this.actionConfirmSwitch){
  281. this.uploadToOther(data, accountObj, type);
  282. }else if(this.actionConfirmSwitch){
  283. // 动作
  284. this.nextDeptOrder_ss(data, accountObj, type);
  285. }else if(this.actionPhotoSwitch){
  286. // 拍照
  287. this.uploadToOther(data, accountObj, type);
  288. }
  289. } else if (result.state == '0000') {
  290. this.showSelectAccount();
  291. } else {
  292. uni.showToast({
  293. icon: "none",
  294. title: "请求失败!",
  295. });
  296. }
  297. });
  298. },
  299. // 完成工单
  300. uploadToOther(data, accountObj, type){
  301. let imageValue = this.imageValue;
  302. // 完成工单
  303. post('/workerOrder/findRecordInfoByOrderId', {
  304. orderId: this.orderId,
  305. gdOperate: 22,
  306. }).then(result => {
  307. if (result.state == 200) {
  308. uni.showLoading({
  309. mask: true,
  310. title: '加载中'
  311. });
  312. let n = 0;
  313. //#ifdef H5
  314. imageValue.forEach((v) => {
  315. // 图片上传 start
  316. console.log("压缩前");
  317. let canvasWidth = v.image.width; //图片原始长宽
  318. let canvasHeight = v.image.height;
  319. let img = new Image();
  320. img.src = v.path;
  321. let canvas = document.createElement("canvas");
  322. let ctx = canvas.getContext("2d");
  323. canvas.width = canvasWidth;
  324. canvas.height = canvasHeight;
  325. ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight);
  326. canvas.toBlob(
  327. (fileSrc) => {
  328. let tp = window.URL.createObjectURL(fileSrc);
  329. console.log("压缩后");
  330. n++;
  331. uni.uploadFile({
  332. url: pathUrl +
  333. "/common/common/uploadAttachment/orderEndPhoto/" +
  334. this.orderId +
  335. "/" + result.recordId,
  336. filePath: tp,
  337. name: "file",
  338. formData: {
  339. filename: v.name,
  340. },
  341. success: (uploadFileRes) => {
  342. console.log(uploadFileRes);
  343. if (--n === 0) {
  344. uni.hideLoading();
  345. this.nextDeptOrder_ss(data, accountObj, type);
  346. }
  347. },
  348. fail: (err) => {
  349. n--;
  350. console.error(err);
  351. uni.hideLoading();
  352. uni.showToast({
  353. icon: "none",
  354. title: "上传失败",
  355. duration: 2000,
  356. });
  357. },
  358. });
  359. },
  360. "image/jpeg",
  361. 0.3
  362. );
  363. // 图片上传 end
  364. });
  365. //#endif
  366. //#ifdef APP-PLUS
  367. imageValue.forEach((v) => {
  368. // 图片上传 start
  369. uni.compressImage({
  370. src: v.path,
  371. quality: 30,
  372. success: (res) => {
  373. console.log('压缩前', res)
  374. let tp = res.tempFilePath;
  375. console.log("压缩后");
  376. n++;
  377. uni.uploadFile({
  378. url: pathUrl +
  379. "/common/common/uploadAttachment/orderEndPhoto/" +
  380. this.orderId +
  381. "/" + result.recordId,
  382. filePath: tp,
  383. name: "file",
  384. formData: {
  385. filename: v.name,
  386. },
  387. success: (uploadFileRes) => {
  388. console.log(uploadFileRes);
  389. if (--n === 0) {
  390. uni.hideLoading();
  391. this.nextDeptOrder_ss(data, accountObj, type);
  392. }
  393. },
  394. fail: (err) => {
  395. n--;
  396. console.error(err);
  397. uni.hideLoading();
  398. uni.showToast({
  399. icon: "none",
  400. title: "上传失败",
  401. duration: 2000,
  402. });
  403. },
  404. });
  405. },
  406. fail: function () {
  407. uni.hideLoading();
  408. uni.showToast({
  409. icon: 'none',
  410. title: '上传失败',
  411. duration: 2000
  412. });
  413. }
  414. })
  415. // 图片上传 end
  416. });
  417. //#endif
  418. }
  419. })
  420. },
  421. // 返回
  422. goBack() {
  423. uni.navigateBack();
  424. },
  425. // 选择动作
  426. checkboxChange: function (e) {
  427. var items = this.actions,
  428. values = e.detail.value;
  429. for (var i = 0, lenI = items.length; i < lenI; ++i) {
  430. const item = items[i]
  431. if(values.includes(item.value)){
  432. this.$set(item,'checked',true)
  433. }else{
  434. this.$set(item,'checked',false)
  435. }
  436. }
  437. },
  438. // 获取上传状态
  439. selectFile(e) {
  440. console.log('选择文件:', e)
  441. this.imageValue = this.imageValue.concat(e.tempFiles);
  442. },
  443. // 移除
  444. deleteFile(e) {
  445. console.log('移除:', e);
  446. },
  447. },
  448. onLoad(options) {
  449. console.log(options);
  450. this.options = options;
  451. if(options.order){
  452. options.order = JSON.parse(options.order);
  453. this.order = options.order;
  454. }
  455. if(options.orderId){
  456. this.orderId = options.orderId;
  457. }
  458. if(options.taskType){
  459. options.taskType = JSON.parse(options.taskType);
  460. this.actionConfirmSwitch = options.taskType.carryingCourses[1].actionConfirmSwitch;
  461. let actions = options.taskType.carryingCourses[1].actionRemarks || "";
  462. this.actions = actions.split('$').map((v, i) => ({
  463. value: i,
  464. name: v,
  465. }));
  466. this.actionPhotoSwitch = options.taskType.carryingCourses[1].actionPhotoSwitch;
  467. }
  468. },
  469. };
  470. </script>
  471. <style lang="less" scoped>
  472. .HomeItem {
  473. .foot_btn_spe {
  474. width: 100%;
  475. position: fixed;
  476. bottom: 30rpx;
  477. left: 0;
  478. line-height: 88rpx;
  479. height: 88rpx;
  480. text-align: center;
  481. display: flex;
  482. justify-content: space-between;
  483. flex-wrap: wrap;
  484. &::after {
  485. content: '';
  486. flex: 1;
  487. }
  488. view {
  489. height: 88rpx;
  490. width: 48%;
  491. margin: 0 1%;
  492. background-image: linear-gradient(to right, #72c172, #3bb197);
  493. color: #fff;
  494. border-radius: 8rpx;
  495. font-size: 32rpx;
  496. margin-top: 16rpx;
  497. }
  498. }
  499. .login {
  500. height: 420rpx;
  501. padding: 0 32rpx;
  502. padding-top: 164rpx;
  503. position: relative;
  504. z-index: 999;
  505. .savePassword {
  506. margin-top: 32rpx;
  507. }
  508. /deep/ uni-checkbox:not([disabled]) .uni-checkbox-input:hover {
  509. border-color: #42b983 !important;
  510. }
  511. .login_input {
  512. margin-top: 32rpx;
  513. background-color: #ffffff;
  514. height: 72rpx;
  515. box-sizing: border-box;
  516. padding: 16rpx;
  517. }
  518. .title {
  519. font-size: 36rpx;
  520. color: #42b983;
  521. text-align: center;
  522. }
  523. .tips {
  524. font-size: 28rpx;
  525. color: red;
  526. margin-top: 16rpx;
  527. }
  528. .page_item_btn {
  529. height: 88rpx;
  530. background-image: linear-gradient(to right, #72c172, #3bb197);
  531. border-radius: 8rpx;
  532. line-height: 88rpx;
  533. color: #fff;
  534. font-size: 36rpx;
  535. font-weight: 700;
  536. margin-top: 64rpx;
  537. text-align: center;
  538. }
  539. }
  540. //上班页面
  541. .goWorkAll {
  542. height: calc(100vh - 118rpx);
  543. overflow-y: auto;
  544. display: flex;
  545. flex-direction: column;
  546. justify-content: space-between;
  547. /deep/ .uni-radio-input-checked {
  548. background-color: #42b983 !important;
  549. border-color: #42b983 !important;
  550. }
  551. /deep/ .uni-checkbox-input-checked {
  552. color: #42b983 !important;
  553. }
  554. .goWorkSelect {
  555. &.history {
  556. height: 356rpx;
  557. padding-bottom: 16rpx;
  558. }
  559. &.combination {
  560. .goWorkSelect-head {}
  561. .goWorkSelect-list {}
  562. }
  563. .goWorkSelect-head {
  564. font-size: 28rpx;
  565. padding: 16rpx 0;
  566. color: #42b983;
  567. border-bottom: 2rpx solid #42b983;
  568. text-align: center;
  569. }
  570. .goWorkSelect-list {
  571. padding: 16rpx;
  572. .goWorkSelect-item {
  573. height: 52rpx;
  574. display: flex;
  575. align-items: center;
  576. border-bottom: 2rpx solid #e5e9ed;
  577. padding: 16rpx;
  578. &.relative {
  579. position: relative;
  580. .picker {
  581. position: absolute;
  582. width: 100%;
  583. padding-left: 64rpx;
  584. }
  585. }
  586. button {
  587. font-size: 32rpx;
  588. height: 52rpx;
  589. line-height: 52rpx;
  590. margin: 0;
  591. margin-left: 16rpx;
  592. color: rgb(7, 134, 60);
  593. font-weight: 700;
  594. }
  595. }
  596. }
  597. }
  598. }
  599. .goWork {
  600. margin: 0 auto 48rpx;
  601. width: 240rpx;
  602. height: 240rpx;
  603. .goWork_btn_E {
  604. width: 100%;
  605. height: 100%;
  606. background: #bee1a7;
  607. border-radius: 30%;
  608. .goWork_btn_W {
  609. width: 75%;
  610. height: 75%;
  611. background-image: linear-gradient(to right, #72c172, #3bb197);
  612. border-radius: 30%;
  613. margin: 0 auto;
  614. position: relative;
  615. top: 12.5%;
  616. line-height: 180rpx;
  617. color: #fff;
  618. font-size: 36rpx;
  619. text-align: center;
  620. }
  621. }
  622. }
  623. .goWork_text {
  624. width: 100%;
  625. view {
  626. text-align: center;
  627. }
  628. .goWork_text-p {
  629. font-size: 36rpx;
  630. margin-bottom: 48rpx;
  631. }
  632. }
  633. .botImg {
  634. height: 600rpx;
  635. width: 100%;
  636. position: fixed;
  637. bottom: 0;
  638. .img {
  639. height: 100%;
  640. background: url("../../static/img/BG.png") no-repeat center center;
  641. background-size: 100% 100%;
  642. }
  643. }
  644. }
  645. </style>