quickCreateOrder.vue 21 KB

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