otherCompleteOrder.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  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. }else{
  169. uni.hideLoading();
  170. }
  171. },
  172. // 填写交接人账号-确认
  173. hosOk(data) {
  174. console.log(data);
  175. const {
  176. accountName,
  177. account,
  178. accountId
  179. } = data;
  180. if (!accountName && !account) {
  181. //没有填写交接人
  182. uni.showModal({
  183. title: '提示',
  184. content: "请填写交接人账号!",
  185. showCancel: false,
  186. success: function(res) {
  187. if (res.confirm) {
  188. console.log('用户点击确定');
  189. } else if (res.cancel) {
  190. console.log('用户点击取消');
  191. }
  192. }
  193. });
  194. return;
  195. } else if (!accountName && account || accountName && !account) {
  196. //没有填写交接人
  197. uni.showModal({
  198. title: '提示',
  199. content: "请填写正确的交接人账号!",
  200. showCancel: false,
  201. success: function(res) {
  202. if (res.confirm) {
  203. console.log('用户点击确定');
  204. } else if (res.cancel) {
  205. console.log('用户点击取消');
  206. }
  207. }
  208. });
  209. return;
  210. }
  211. this.hosModels.disjunctor = false;
  212. let associationTypeValue = this.currentData.taskType.associationType.value;
  213. console.log(associationTypeValue)
  214. if(this.actionPhotoSwitch && this.actionConfirmSwitch){
  215. this.uploadToOther(this.currentData, data, 'end');
  216. }else if(this.actionConfirmSwitch){
  217. // 动作
  218. this.nextDeptOrder_ss(this.currentData, data, 'end');
  219. }else if(this.actionPhotoSwitch){
  220. // 拍照
  221. this.uploadToOther(this.currentData, data, 'end');
  222. }
  223. },
  224. // 填写交接人账号-取消
  225. hosCancel() {
  226. this.hosModels.disjunctor = false;
  227. },
  228. // 填写交接人账号弹窗
  229. showSelectAccount() {
  230. this.hosModels = {
  231. title: '填写交接人账号',
  232. disjunctor: true,
  233. }
  234. },
  235. // 拍照-其他
  236. photographToOther(data, type) {
  237. this.currentData = data;
  238. let actions = this.actions.filter(v => v.checked);
  239. let imageValue = this.imageValue;
  240. console.log(actions);
  241. console.log(imageValue);
  242. if(this.actionConfirmSwitch && this.actions.length !== actions.length){
  243. uni.showToast({
  244. icon: "none",
  245. title: '您需要完成以下动作,才可完成功工单!',
  246. duration: 2000
  247. });
  248. return;
  249. }
  250. if(this.actionPhotoSwitch && !imageValue.length){
  251. uni.showToast({
  252. icon: "none",
  253. title: '您需要完成拍照,才可完成功工单!',
  254. duration: 2000
  255. });
  256. return;
  257. }
  258. uni.showLoading({
  259. title: "加载中",
  260. mask: true,
  261. });
  262. // 其他临床服务
  263. //检验二维码的有效性
  264. post("/dept/scanning", {
  265. content: type === 'start' ? data.startDept.qrcode : data.endDepts[0].qrcode,
  266. taskTypeId: data.taskType.id,
  267. gdState: data.gdState.id,
  268. }).then((result) => {
  269. this.currentCode = result.code;
  270. if (result.state == 200 || result.state == 201) {
  271. let accountObj = undefined;
  272. if (result.account) {
  273. accountObj = {
  274. account: result.account,
  275. accountName: result.name,
  276. accountId: result.id,
  277. };
  278. } else {
  279. accountObj = undefined;
  280. }
  281. if(this.actionPhotoSwitch && this.actionConfirmSwitch){
  282. this.uploadToOther(data, accountObj, type);
  283. }else if(this.actionConfirmSwitch){
  284. // 动作
  285. this.nextDeptOrder_ss(data, accountObj, type);
  286. }else if(this.actionPhotoSwitch){
  287. // 拍照
  288. this.uploadToOther(data, accountObj, type);
  289. }
  290. } else if (result.state == '0000') {
  291. uni.hideLoading();
  292. this.showSelectAccount();
  293. } else {
  294. uni.hideLoading();
  295. uni.showToast({
  296. icon: "none",
  297. title: "请求失败!",
  298. });
  299. }
  300. });
  301. },
  302. // 完成工单
  303. uploadToOther(data, accountObj, type){
  304. let imageValue = this.imageValue;
  305. // 完成工单
  306. post('/workerOrder/findRecordInfoByOrderId', {
  307. orderId: this.orderId,
  308. gdOperate: 22,
  309. }).then(result => {
  310. if (result.state == 200) {
  311. uni.showLoading({
  312. mask: true,
  313. title: '加载中'
  314. });
  315. let n = 0;
  316. //#ifdef H5
  317. imageValue.forEach((v) => {
  318. // 图片上传 start
  319. console.log("压缩前");
  320. let canvasWidth = v.image.width; //图片原始长宽
  321. let canvasHeight = v.image.height;
  322. let img = new Image();
  323. img.src = v.path;
  324. let canvas = document.createElement("canvas");
  325. let ctx = canvas.getContext("2d");
  326. canvas.width = canvasWidth;
  327. canvas.height = canvasHeight;
  328. ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight);
  329. canvas.toBlob(
  330. (fileSrc) => {
  331. let tp = window.URL.createObjectURL(fileSrc);
  332. console.log("压缩后");
  333. n++;
  334. uni.uploadFile({
  335. url: pathUrl +
  336. "/common/common/uploadAttachment/orderEndPhoto/" +
  337. this.orderId +
  338. "/" + result.recordId,
  339. filePath: tp,
  340. name: "file",
  341. formData: {
  342. filename: v.name,
  343. },
  344. success: (uploadFileRes) => {
  345. console.log(uploadFileRes);
  346. if (--n === 0) {
  347. this.nextDeptOrder_ss(data, accountObj, type);
  348. }
  349. },
  350. fail: (err) => {
  351. n--;
  352. console.error(err);
  353. uni.showToast({
  354. icon: "none",
  355. title: "上传失败",
  356. duration: 2000,
  357. });
  358. },
  359. });
  360. },
  361. "image/jpeg",
  362. 0.1
  363. );
  364. // 图片上传 end
  365. });
  366. //#endif
  367. //#ifdef APP-PLUS
  368. imageValue.forEach((v) => {
  369. // 图片上传 start
  370. uni.compressImage({
  371. src: v.path,
  372. quality: 30,
  373. success: (res) => {
  374. console.log('压缩前', res)
  375. let tp = res.tempFilePath;
  376. console.log("压缩后");
  377. n++;
  378. uni.uploadFile({
  379. url: pathUrl +
  380. "/common/common/uploadAttachment/orderEndPhoto/" +
  381. this.orderId +
  382. "/" + result.recordId,
  383. filePath: tp,
  384. name: "file",
  385. formData: {
  386. filename: v.name,
  387. },
  388. success: (uploadFileRes) => {
  389. console.log(uploadFileRes);
  390. if (--n === 0) {
  391. this.nextDeptOrder_ss(data, accountObj, type);
  392. }
  393. },
  394. fail: (err) => {
  395. n--;
  396. console.error(err);
  397. uni.showToast({
  398. icon: "none",
  399. title: "上传失败",
  400. duration: 2000,
  401. });
  402. },
  403. });
  404. },
  405. fail: function () {
  406. uni.hideLoading();
  407. uni.showToast({
  408. icon: 'none',
  409. title: '上传失败',
  410. duration: 2000
  411. });
  412. }
  413. })
  414. // 图片上传 end
  415. });
  416. //#endif
  417. }else{
  418. uni.hideLoading();
  419. }
  420. })
  421. },
  422. // 返回
  423. goBack() {
  424. uni.navigateBack();
  425. },
  426. // 选择动作
  427. checkboxChange: function (e) {
  428. var items = this.actions,
  429. values = e.detail.value;
  430. for (var i = 0, lenI = items.length; i < lenI; ++i) {
  431. const item = items[i]
  432. if(values.includes(item.value)){
  433. this.$set(item,'checked',true)
  434. }else{
  435. this.$set(item,'checked',false)
  436. }
  437. }
  438. },
  439. // 获取上传状态
  440. selectFile(e) {
  441. console.log('选择文件:', e)
  442. this.imageValue = this.imageValue.concat(e.tempFiles);
  443. },
  444. // 移除
  445. deleteFile(e) {
  446. console.log('移除:', e);
  447. },
  448. },
  449. onLoad(options) {
  450. console.log(options);
  451. this.options = options;
  452. if(options.order){
  453. options.order = JSON.parse(options.order);
  454. this.order = options.order;
  455. }
  456. if(options.orderId){
  457. this.orderId = options.orderId;
  458. }
  459. if(options.taskType){
  460. options.taskType = JSON.parse(options.taskType);
  461. this.actionConfirmSwitch = options.taskType.carryingCourses[1].actionConfirmSwitch;
  462. let actions = options.taskType.carryingCourses[1].actionRemarks || "";
  463. this.actions = actions.split('$').map((v, i) => ({
  464. value: i,
  465. name: v,
  466. }));
  467. this.actionPhotoSwitch = options.taskType.carryingCourses[1].actionPhotoSwitch;
  468. }
  469. },
  470. };
  471. </script>
  472. <style lang="less" scoped>
  473. .HomeItem {
  474. .foot_btn_spe {
  475. width: 100%;
  476. position: fixed;
  477. bottom: 30rpx;
  478. left: 0;
  479. line-height: 88rpx;
  480. height: 88rpx;
  481. text-align: center;
  482. display: flex;
  483. justify-content: space-between;
  484. flex-wrap: wrap;
  485. &::after {
  486. content: '';
  487. flex: 1;
  488. }
  489. view {
  490. height: 88rpx;
  491. width: 48%;
  492. margin: 0 1%;
  493. background-image: linear-gradient(to right, #72c172, #3bb197);
  494. color: #fff;
  495. border-radius: 8rpx;
  496. font-size: 32rpx;
  497. margin-top: 16rpx;
  498. }
  499. }
  500. .login {
  501. height: 420rpx;
  502. padding: 0 32rpx;
  503. padding-top: 164rpx;
  504. position: relative;
  505. z-index: 999;
  506. .savePassword {
  507. margin-top: 32rpx;
  508. }
  509. /deep/ uni-checkbox:not([disabled]) .uni-checkbox-input:hover {
  510. border-color: #42b983 !important;
  511. }
  512. .login_input {
  513. margin-top: 32rpx;
  514. background-color: #ffffff;
  515. height: 72rpx;
  516. box-sizing: border-box;
  517. padding: 16rpx;
  518. }
  519. .title {
  520. font-size: 36rpx;
  521. color: #42b983;
  522. text-align: center;
  523. }
  524. .tips {
  525. font-size: 28rpx;
  526. color: red;
  527. margin-top: 16rpx;
  528. }
  529. .page_item_btn {
  530. height: 88rpx;
  531. background-image: linear-gradient(to right, #72c172, #3bb197);
  532. border-radius: 8rpx;
  533. line-height: 88rpx;
  534. color: #fff;
  535. font-size: 36rpx;
  536. font-weight: 700;
  537. margin-top: 64rpx;
  538. text-align: center;
  539. }
  540. }
  541. //上班页面
  542. .goWorkAll {
  543. height: calc(100vh - 118rpx);
  544. overflow-y: auto;
  545. display: flex;
  546. flex-direction: column;
  547. justify-content: space-between;
  548. /deep/ .uni-radio-input-checked {
  549. background-color: #42b983 !important;
  550. border-color: #42b983 !important;
  551. }
  552. /deep/ .uni-checkbox-input-checked {
  553. color: #42b983 !important;
  554. }
  555. .goWorkSelect {
  556. &.history {
  557. height: 356rpx;
  558. padding-bottom: 16rpx;
  559. }
  560. &.combination {
  561. .goWorkSelect-head {}
  562. .goWorkSelect-list {}
  563. }
  564. .goWorkSelect-head {
  565. font-size: 28rpx;
  566. padding: 16rpx 0;
  567. color: #42b983;
  568. border-bottom: 2rpx solid #42b983;
  569. text-align: center;
  570. }
  571. .goWorkSelect-list {
  572. padding: 16rpx;
  573. .goWorkSelect-item {
  574. height: 52rpx;
  575. display: flex;
  576. align-items: center;
  577. border-bottom: 2rpx solid #e5e9ed;
  578. padding: 16rpx;
  579. &.relative {
  580. position: relative;
  581. .picker {
  582. position: absolute;
  583. width: 100%;
  584. padding-left: 64rpx;
  585. }
  586. }
  587. button {
  588. font-size: 32rpx;
  589. height: 52rpx;
  590. line-height: 52rpx;
  591. margin: 0;
  592. margin-left: 16rpx;
  593. color: rgb(7, 134, 60);
  594. font-weight: 700;
  595. }
  596. }
  597. }
  598. }
  599. }
  600. .goWork {
  601. margin: 0 auto 48rpx;
  602. width: 240rpx;
  603. height: 240rpx;
  604. .goWork_btn_E {
  605. width: 100%;
  606. height: 100%;
  607. background: #bee1a7;
  608. border-radius: 30%;
  609. .goWork_btn_W {
  610. width: 75%;
  611. height: 75%;
  612. background-image: linear-gradient(to right, #72c172, #3bb197);
  613. border-radius: 30%;
  614. margin: 0 auto;
  615. position: relative;
  616. top: 12.5%;
  617. line-height: 180rpx;
  618. color: #fff;
  619. font-size: 36rpx;
  620. text-align: center;
  621. }
  622. }
  623. }
  624. .goWork_text {
  625. width: 100%;
  626. view {
  627. text-align: center;
  628. }
  629. .goWork_text-p {
  630. font-size: 36rpx;
  631. margin-bottom: 48rpx;
  632. }
  633. }
  634. .botImg {
  635. height: 600rpx;
  636. width: 100%;
  637. position: fixed;
  638. bottom: 0;
  639. .img {
  640. height: 100%;
  641. background: url("../../static/img/BG.png") no-repeat center center;
  642. background-size: 100% 100%;
  643. }
  644. }
  645. }
  646. </style>