quickCreateOrder.vue 16 KB

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