quickCreateOrder.vue 17 KB

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