quickCreateOrder.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. <template>
  2. <view class="quickCreateOrder">
  3. <view class="qco_msg" v-html="patientMsg" v-if="qucikCreateOrderType === 'patient'"></view>
  4. <view class="qco_msg" v-html="dataObj.msg" v-else></view>
  5. <!-- 起点科室,终点科室 -->
  6. <block
  7. v-if="(qucikCreateOrderType === 'other' || qucikCreateOrderType === 'patient') && (dataObj.start || dataObj.end)">
  8. <view class="select_block" @click="selectDept('start')"
  9. v-if="qucikCreateOrderType !== 'patient'||(qucikCreateOrderType === 'patient'&&!(dataObj.start.start.departmentStrategy == DEPARTMENT_STRATEGY['默认发起科室'] || dataObj.start.start.departmentStrategy == DEPARTMENT_STRATEGY['固定科室']|| dataObj.start.start.departmentStrategy == DEPARTMENT_STRATEGY['默认患者所在科室']))">
  10. <!-- 默认科室和固定科室和默认患者所在科室 -->
  11. <text class="select_label"
  12. :class="{disableColor:dataObj.start.start.departmentStrategy == DEPARTMENT_STRATEGY['默认发起科室'] || dataObj.start.start.departmentStrategy == DEPARTMENT_STRATEGY['固定科室']}">起点科室</text>
  13. <view class="select_placeholder"
  14. v-if="dataObj.start.start.departmentStrategy == DEPARTMENT_STRATEGY['默认发起科室'] || dataObj.start.start.departmentStrategy == DEPARTMENT_STRATEGY['固定科室']">
  15. {{deptDisplay == 1? startDept.dept: startDept.deptalias}}
  16. </view>
  17. <!-- 固定科室范围,固定科室类型,自主选择 -->
  18. <view class="select_placeholder" v-else>
  19. <text>{{startDept.id?(deptDisplay == 1? startDept.dept: startDept.deptalias):'请选择起点科室'}}</text>
  20. <text class="pda pda-xiangyou"></text>
  21. </view>
  22. </view>
  23. <view class="select_block" @click="selectDept('end')"
  24. v-if="qucikCreateOrderType !== 'patient'||(qucikCreateOrderType === 'patient'&&!(dataObj.end.end.departmentStrategy == DEPARTMENT_STRATEGY['默认发起科室'] || dataObj.end.end.departmentStrategy == DEPARTMENT_STRATEGY['固定科室']|| dataObj.end.end.departmentStrategy == DEPARTMENT_STRATEGY['默认患者所在科室']))">
  25. <!-- 默认科室和固定科室和默认患者所在科室 -->
  26. <text class="select_label"
  27. :class="{disableColor:dataObj.end.end.departmentStrategy == DEPARTMENT_STRATEGY['默认发起科室'] || dataObj.end.end.departmentStrategy == DEPARTMENT_STRATEGY['固定科室']}">终点科室</text>
  28. <view class="select_placeholder"
  29. v-if="dataObj.end.end.departmentStrategy == DEPARTMENT_STRATEGY['默认发起科室'] || dataObj.end.end.departmentStrategy == DEPARTMENT_STRATEGY['固定科室']">
  30. {{deptDisplay == 1? endDept.dept: endDept.deptalias}}
  31. </view>
  32. <!-- 固定科室范围,固定科室类型,自主选择 -->
  33. <view class="select_placeholder" v-else>
  34. <text>{{endDept.id?(deptDisplay == 1? endDept.dept: endDept.deptalias):'请选择终点科室'}}</text>
  35. <text class="pda pda-xiangyou"></text>
  36. </view>
  37. </view>
  38. </block>
  39. <!-- 备注 -->
  40. <view class="remarks" v-if="dataObj.remarksSwitch == 1">
  41. <textarea :focus="remarksFocus" class="remarks_textarea" auto-height :maxlength="100"
  42. placeholder-style="color:#999" :placeholder="
  43. dataObj.remarksPrompts || '请填写工单备注,不超过100个字符'
  44. " v-model="workOrderRemark" :adjust-position="false" />
  45. </view>
  46. <!-- 快捷输入,历史输入 -->
  47. <view class="quickAndHistory" v-if="dataObj.remarksSwitch == 1 && dataObj.customRemarks.length">
  48. <view class="quickAndHistory_header"> 快捷输入 </view>
  49. <view class="quickAndHistory_container">
  50. <view class="quickAndHistory_item" @click="addRemarks(customRemark)"
  51. v-for="(customRemark, i) in dataObj.customRemarks" :key="i">
  52. {{ customRemark }}
  53. </view>
  54. </view>
  55. </view>
  56. <view class="quickAndHistory" v-if="dataObj.remarksSwitch == 1 && historyCustomRemarks.length">
  57. <view class="quickAndHistory_header"> 历史输入 </view>
  58. <view class="quickAndHistory_container">
  59. <view class="quickAndHistory_item" @click="addRemarks(historyCustomRemark)"
  60. v-for="(historyCustomRemark, i) in historyCustomRemarks" :key="i">
  61. {{ historyCustomRemark }}
  62. </view>
  63. </view>
  64. </view>
  65. <!-- 底部 -->
  66. <seiminFooterBtn :btns="btns"></seiminFooterBtn>
  67. <seiminModel ref="seiminModel"></seiminModel>
  68. <seiminPicker ref="sPicker" :title="pickerTitle" titleColor="#808080" titleFontSize="28rpx" confirmColor="#333"
  69. confirmFontSize="38rpx" confirmFontWeight="500" itemFontSize="32rpx" @onClose="closePicker"
  70. @onConfirm="confirmPicker" :pickerList="deptList">
  71. </seiminPicker>
  72. </view>
  73. </template>
  74. <script>
  75. import {
  76. backPress
  77. } from '../../utils/index.js';
  78. import cloneDeep from 'lodash/cloneDeep';
  79. import {
  80. mapState,
  81. mapMutations
  82. } from "vuex";
  83. import {
  84. reqBuildTrip,
  85. reqRecentRemarks,
  86. reqBuildOrder,
  87. } from "../../request/api.js";
  88. import {
  89. SOURCEID
  90. } from "../../utils/enum.sourceid.js";
  91. import {
  92. DEPARTMENT_STRATEGY
  93. } from "../../utils/enum.departmentStrategy.js";
  94. export default {
  95. onBackPress() {
  96. backPress();
  97. },
  98. data() {
  99. return {
  100. reFresh: '',
  101. DEPARTMENT_STRATEGY,
  102. //患者建单信息展示
  103. patientMsg: '',
  104. // 传递过来的参数
  105. queryParams: {},
  106. // 选择的起点科室
  107. startDept: {},
  108. // 选择的终点科室
  109. endDept: {},
  110. // 固定科室范围的科室列表
  111. deptList: [],
  112. //选择起点科室(start)或终点科室(end)
  113. selectdDeptType: '',
  114. //选择院区picker的title
  115. pickerTitle: '',
  116. // 工单备注是否获取焦点
  117. remarksFocus: false,
  118. // 工单备注
  119. workOrderRemark: "",
  120. // 获取到的数据集合对象(历史输入除外)
  121. dataObj: {},
  122. // 历史输入
  123. historyCustomRemarks: [],
  124. //底部按钮
  125. btns: [],
  126. };
  127. },
  128. computed: {
  129. ...mapState('login', ['loginInfo']),
  130. ...mapState('other', [
  131. "qucikCreateOrderType",
  132. "qucikCreateOrderTypeId",
  133. "deptDisplay",
  134. 'searchDeptParams',
  135. 'searchDeptResultList',
  136. 'patientBuildTrip',
  137. 'patientTaskType'
  138. ]),
  139. isWriteDept() {
  140. return {
  141. startDept: this.startDept,
  142. endDept: this.endDept
  143. }
  144. }
  145. },
  146. watch: {
  147. isWriteDept(newVal) {
  148. console.log(newVal);
  149. if (this.qucikCreateOrderType !== 'patient') {
  150. return;
  151. }
  152. if (newVal.startDept.id && newVal.endDept.id) {
  153. this.btns = [{
  154. name: "返回列表",
  155. type: "default",
  156. click: () => {
  157. uni.navigateTo({
  158. url: '/pages/patientList/patientList'
  159. })
  160. },
  161. },
  162. {
  163. name: "下一步",
  164. type: "primary",
  165. click: () => {
  166. this.changePatientBuildData({
  167. key: 'dept',
  168. value: {
  169. startDept: newVal.startDept,
  170. endDept: newVal.endDept,
  171. }
  172. })
  173. uni.navigateTo({
  174. url: "/pages/patientBuild/patientBuild",
  175. });
  176. },
  177. },
  178. ];
  179. } else {
  180. this.btns = [{
  181. name: "返回列表",
  182. type: "default",
  183. click: () => {
  184. uni.navigateTo({
  185. url: '/pages/patientList/patientList'
  186. })
  187. },
  188. }, ];
  189. }
  190. }
  191. },
  192. methods: {
  193. ...mapMutations('other', ['changeSearchDeptParams', 'changeSearchDeptResultList', 'changePatientBuildData']),
  194. // 添加备注
  195. addRemarks(customRemark) {
  196. this.remarksFocus = false;
  197. this.$nextTick(() => {
  198. this.remarksFocus = true;
  199. });
  200. this.workOrderRemark += customRemark;
  201. console.log(this.workOrderRemark.replace(/\s/g, ''))
  202. this.workOrderRemark = this.workOrderRemark.replace(/\s/g, '').slice(0, 100);
  203. },
  204. //获取所有数据
  205. getData(qucikCreateOrderType, qucikCreateOrderTypeId) {
  206. if (qucikCreateOrderType === 'patient') {
  207. //患者建单,则无需请求
  208. this.getBuildTrip(this.patientBuildTrip);
  209. return;
  210. }
  211. uni.showLoading({
  212. title: "加载中",
  213. });
  214. let postData1 = {};
  215. let postData2 = {
  216. taskTypeId: qucikCreateOrderTypeId,
  217. deptId: this.loginInfo.user.dept.id,
  218. };
  219. if (qucikCreateOrderType === "specimen") {
  220. //标本快捷建单
  221. postData1 = {
  222. taskTypeId: qucikCreateOrderTypeId,
  223. deptId: this.loginInfo.user.dept.id,
  224. };
  225. } else if (qucikCreateOrderType === "other") {
  226. //其他临床服务快捷建单
  227. postData1 = {
  228. taskTypeId: qucikCreateOrderTypeId,
  229. };
  230. }
  231. Promise.all([reqBuildTrip(postData1), reqRecentRemarks(postData2)]).then(
  232. (values) => {
  233. uni.hideLoading();
  234. this.getBuildTrip(values[0]);
  235. this.getRecentRemarks(values[1]);
  236. }
  237. );
  238. },
  239. // 获取数据(除历史输入)
  240. getBuildTrip(res) {
  241. res = cloneDeep(res);
  242. if (
  243. res.status == 200 ||
  244. res.status == 100012 ||
  245. res.status == 100013 ||
  246. res.status == 100014 ||
  247. res.status == 100015
  248. ) {
  249. // 处理返回的数据
  250. if (res.customRemarks) {
  251. res.customRemarks = res.customRemarks.split("$");
  252. } else {
  253. res.customRemarks = [];
  254. }
  255. // 处理msg
  256. res.msg = res.msg || '';
  257. if (res.msg.includes("<b>")) {
  258. res.msg = res.msg.replace(/<b>/g, '<text class="green">');
  259. res.msg = res.msg.replace(/<\/b>/g, "</text>");
  260. }
  261. if (res.start) {
  262. //其他服务或患者其他服务业务
  263. if (
  264. res.start.start.departmentStrategy == this.DEPARTMENT_STRATEGY['默认患者所在科室'] ||
  265. res.start.start.departmentStrategy == this.DEPARTMENT_STRATEGY['默认发起科室'] ||
  266. res.start.start.departmentStrategy == this.DEPARTMENT_STRATEGY['固定科室']) {
  267. this.startDept = res.start.start.list[0];
  268. }
  269. if (
  270. res.start.start.departmentStrategy == this.DEPARTMENT_STRATEGY['固定科室范围'] ||
  271. res.start.start.departmentStrategy == this.DEPARTMENT_STRATEGY['自主填写'] ||
  272. res.start.start.departmentStrategy == this.DEPARTMENT_STRATEGY['固定科室类型']
  273. ) {
  274. if (this.queryParams.isShow) {
  275. this.startDept = this.searchDeptResultList.start || {};
  276. } else {
  277. this.changeSearchDeptResultList({});
  278. }
  279. }
  280. }
  281. if (res.end) {
  282. //其他服务或患者其他服务业务
  283. if (
  284. res.end.end.departmentStrategy == this.DEPARTMENT_STRATEGY['默认患者所在科室'] ||
  285. res.end.end.departmentStrategy == this.DEPARTMENT_STRATEGY['默认发起科室'] ||
  286. res.end.end.departmentStrategy == this.DEPARTMENT_STRATEGY['固定科室']) {
  287. this.endDept = res.end.end.list[0];
  288. }
  289. if (
  290. res.end.end.departmentStrategy == this.DEPARTMENT_STRATEGY['固定科室范围'] ||
  291. res.end.end.departmentStrategy == this.DEPARTMENT_STRATEGY['自主填写'] ||
  292. res.end.end.departmentStrategy == this.DEPARTMENT_STRATEGY['固定科室类型']
  293. ) {
  294. if (this.queryParams.isShow) {
  295. this.endDept = this.searchDeptResultList.end || {};
  296. } else {
  297. this.changeSearchDeptResultList({});
  298. }
  299. }
  300. }
  301. this.dataObj = res;
  302. } else {
  303. this.$refs.seiminModel.show({
  304. skin: "toast",
  305. icon: "error",
  306. content: res.msg || "获取数据失败",
  307. });
  308. throw new Error(res.msg || '获取数据失败');
  309. }
  310. },
  311. // 获取历史输入
  312. getRecentRemarks(res) {
  313. if (res.state == 200 || res.state == 201) {
  314. this.historyCustomRemarks = res.data || [];
  315. } else {
  316. this.$refs.seiminModel.show({
  317. skin: "toast",
  318. icon: "error",
  319. content: res.msg || "获取数据失败",
  320. });
  321. throw new Error(res.msg || '获取数据失败');
  322. }
  323. },
  324. // 提交数据,建单
  325. submitData() {
  326. let postData = {};
  327. uni.showLoading({
  328. title: "加载中",
  329. mask: true,
  330. });
  331. if (this.qucikCreateOrderType === "specimen") {
  332. //标本建单
  333. postData = {
  334. urgent: 0,
  335. workOrder: {
  336. sourceId: SOURCEID["PDA"],
  337. workOrderRemark: this.workOrderRemark,
  338. taskType: {
  339. id: this.qucikCreateOrderTypeId,
  340. },
  341. createDept: this.loginInfo.user.dept.id,
  342. startDept: {
  343. id: this.loginInfo.user.dept.id,
  344. },
  345. },
  346. };
  347. } else if (this.qucikCreateOrderType === "other") {
  348. // 其他服务建单
  349. let startDept = {
  350. id: this.startDept.id,
  351. };; //起点科室
  352. let endDepts = [{
  353. id: this.endDept.id,
  354. }]; //终点科室
  355. // 验证起点科室和终点科室必填
  356. if (!startDept.id) {
  357. this.$refs.seiminModel.show({
  358. skin: "toast",
  359. icon: "error",
  360. content: "请选择起点科室",
  361. });
  362. uni.hideLoading();
  363. return;
  364. }
  365. if (!endDepts[0].id) {
  366. this.$refs.seiminModel.show({
  367. skin: "toast",
  368. icon: "error",
  369. content: "请选择终点科室",
  370. });
  371. uni.hideLoading();
  372. return;
  373. }
  374. //请求参数
  375. postData = {
  376. workOrder: {
  377. sourceId: SOURCEID["PDA"],
  378. workOrderRemark: this.workOrderRemark,
  379. taskType: {
  380. id: this.qucikCreateOrderTypeId,
  381. },
  382. createDept: this.loginInfo.user.dept.id,
  383. startDept,
  384. endDepts,
  385. },
  386. };
  387. }
  388. reqBuildOrder(postData).then((res) => {
  389. uni.hideLoading();
  390. if (res.status == 200) {
  391. this.$refs.seiminModel.show({
  392. skin: "toast",
  393. content: "创建成功",
  394. btns: [{
  395. name: "知道了",
  396. textColor: "#49B856",
  397. flex: 1,
  398. click() {
  399. uni.navigateTo({
  400. url: "/pages/index/index",
  401. });
  402. },
  403. }, ],
  404. });
  405. } else {
  406. this.$refs.seiminModel.show({
  407. skin: "toast",
  408. icon: "error",
  409. content: res.msg || "建单失败",
  410. });
  411. throw new Error(res.msg || '建单失败');
  412. }
  413. });
  414. },
  415. //关闭
  416. closePicker() {
  417. this.$refs.sPicker._close();
  418. },
  419. //打开
  420. openPicker() {
  421. this.$refs.sPicker._open();
  422. },
  423. //确定:接收子组件传来的参数
  424. confirmPicker(checkedObj) {
  425. this[this.selectdDeptType + 'Dept'] = {
  426. id: checkedObj.value,
  427. dept: checkedObj.label,
  428. deptalias: checkedObj.labelAlias
  429. };
  430. // 防止后选择不回显
  431. let searchDeptResultList = this.searchDeptResultList;
  432. searchDeptResultList[this.selectdDeptType] = {
  433. id: checkedObj.value,
  434. dept: checkedObj.label,
  435. deptalias: checkedObj.labelAlias
  436. }
  437. this.changeSearchDeptResultList(searchDeptResultList);
  438. },
  439. // 选择起点科室
  440. selectDept(type) {
  441. this.selectdDeptType = type; //存储类型
  442. if (
  443. (this.dataObj.start.start.departmentStrategy == this.DEPARTMENT_STRATEGY['默认发起科室'] ||
  444. this.dataObj.start.start.departmentStrategy == this.DEPARTMENT_STRATEGY['固定科室']) &&
  445. type === 'start') {
  446. //默认科室和固定科室不能选科室
  447. return;
  448. }
  449. if (
  450. (this.dataObj.end.end.departmentStrategy == this.DEPARTMENT_STRATEGY['默认发起科室'] ||
  451. this.dataObj.end.end.departmentStrategy == this.DEPARTMENT_STRATEGY['固定科室']) &&
  452. type === 'end') {
  453. //默认科室和固定科室不能选科室
  454. return;
  455. }
  456. if (this.dataObj[type][type].departmentStrategy == this.DEPARTMENT_STRATEGY['固定科室范围']) {
  457. // 固定科室范围
  458. this.pickerTitle = type === 'start' ? '请选择起点科室' : '请选择终点科室';
  459. this.deptList = this.dataObj[type][type].list.map(v => ({
  460. value: v.id,
  461. label: v.dept,
  462. labelAlias: v.deptalias
  463. }))
  464. console.log(this.deptList, this.pickerTitle)
  465. this.openPicker();
  466. } else if (this.dataObj[type][type].departmentStrategy == this.DEPARTMENT_STRATEGY['自主填写'] || this.dataObj[type]
  467. [type].departmentStrategy ==
  468. this.DEPARTMENT_STRATEGY['固定科室类型']) {
  469. // 固定科室类型,自主选择
  470. let params = {
  471. backUrl: "/pages/quickCreateOrder/quickCreateOrder?isShow=true", //返回的url
  472. type: `selectDept_${type}_qucikCreateOrder`, //快捷建单选择起点科室
  473. ids: this.dataObj[type].deptIds || '',
  474. departmentStrategy: this.dataObj[type][type].departmentStrategy, //固定科室类型,自主选择
  475. };
  476. if (this.dataObj[type][type].departmentStrategy == this.DEPARTMENT_STRATEGY['固定科室类型']) {
  477. //固定科室类型
  478. params.deptType = this.dataObj[type][type][type + 'TypeId']; //科室类型
  479. }
  480. this.changeSearchDeptParams(params);
  481. uni.navigateTo({
  482. url: "/pages/searchDept/searchDept",
  483. });
  484. }
  485. }
  486. },
  487. onLoad(queryParams) {
  488. this.queryParams = queryParams;
  489. if (this.qucikCreateOrderType === 'patient') {
  490. this.patientMsg = `您选择类型为<b class="green">${this.patientTaskType.taskName}</b>,需要填写科室,选择完成后点击下一步`;
  491. //患者建单选科室
  492. this.btns = [{
  493. name: "返回列表",
  494. type: "default",
  495. click: () => {
  496. uni.navigateTo({
  497. url: '/pages/patientList/patientList'
  498. })
  499. },
  500. }, ];
  501. } else {
  502. this.btns = [{
  503. name: "回到首页",
  504. type: "default",
  505. click: () => {
  506. uni.navigateTo({
  507. url: "/pages/index/index",
  508. });
  509. },
  510. },
  511. {
  512. name: "确认",
  513. type: "primary",
  514. click: () => {
  515. this.submitData();
  516. },
  517. },
  518. ]
  519. }
  520. this.getData(this.qucikCreateOrderType, this.qucikCreateOrderTypeId);
  521. },
  522. };
  523. </script>
  524. <style lang="scss" scoped>
  525. .quickCreateOrder {
  526. margin-bottom: 100rpx;
  527. .qco_msg {
  528. min-height: 144rpx;
  529. padding: 32rpx;
  530. color: #999;
  531. line-height: 40rpx;
  532. font-size: 32rpx;
  533. text-align: center;
  534. }
  535. // 起点科室,终点科室
  536. .select_block {
  537. padding: 0 30rpx;
  538. height: 88rpx;
  539. font-size: 34rpx;
  540. background-color: #fff;
  541. @include border(top);
  542. @include flex(space-between, center);
  543. .select_label {
  544. color: #000;
  545. &.disableColor {
  546. color: #999;
  547. }
  548. }
  549. .select_placeholder {
  550. color: #888;
  551. @include flex(flex-start, center);
  552. .pda-xiangyou {
  553. font-size: 24rpx;
  554. margin-left: 30rpx;
  555. }
  556. }
  557. }
  558. // 备注
  559. .remarks {
  560. min-height: 150rpx;
  561. background-color: #fff;
  562. padding: 22rpx 25rpx;
  563. @include border(top);
  564. @include border(bottom);
  565. .remarks_textarea {
  566. width: 100%;
  567. min-height: 100rpx;
  568. }
  569. }
  570. // 快捷输入,历史输入
  571. .quickAndHistory {
  572. padding: 43rpx 25rpx 0;
  573. .quickAndHistory_header {
  574. font-weight: bold;
  575. font-size: 34rpx;
  576. padding-bottom: 24rpx;
  577. color: #333;
  578. }
  579. .quickAndHistory_container {
  580. @include flex;
  581. flex-wrap: wrap;
  582. .quickAndHistory_item {
  583. height: 66rpx;
  584. font-size: 28rpx;
  585. border-radius: 33rpx;
  586. background-color: #fff;
  587. line-height: 66rpx;
  588. padding: 0 24rpx;
  589. color: #666;
  590. margin-bottom: 11rpx;
  591. margin-right: 24rpx;
  592. @include clamp;
  593. }
  594. }
  595. }
  596. }
  597. </style>