patientBuild.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. <template>
  2. <view class="patientBuild">
  3. <view class="qco_msg" v-html="patientMsg"></view>
  4. <view class="select_block_wrap">
  5. <view class="uni-list">
  6. <checkbox-group @change="checkboxChange">
  7. <label class="select_block" v-for="good in goods" :key="good.value">
  8. <checkbox color="#09BB07" :value="good.value" :checked="good.checked" />
  9. <view>{{good.name}}</view>
  10. </label>
  11. </checkbox-group>
  12. </view>
  13. </view>
  14. <!-- 加急 -->
  15. <view class="remarks" v-if="patientTaskType.allowUrgent == 1">
  16. <view class="remarks_nav">
  17. 是否加急
  18. </view>
  19. <view class="remarks_btn">
  20. <text class="remarks_btn_name">加急</text>
  21. <switch class="remarks_btn_value" color="#09BB07" :checked="isUrgent" @change="switchChange" />
  22. </view>
  23. <textarea v-if="isUrgent" class="remarks_textarea" auto-height :maxlength="100" placeholder-style="color:#999;"
  24. placeholder="请填写加急原因" v-model.trim="urgentRemark" />
  25. <view class="remarks_tips" v-if="isYYBuild">
  26. <view class="tips">系统支持提前预约送检服务,您是否需要!</view>
  27. <view class="tips">我不需要预约,希望送检人员立即上门,点击立即建单;</view>
  28. <view class="tips">我需要提前预约送检服务,点击预约建单;</view>
  29. </view>
  30. </view>
  31. <!-- 底部 -->
  32. <seiminFooterBtn :btns="btns"></seiminFooterBtn>
  33. <seiminModel ref="seiminModel" :otherData="{timestamp,date,time}"></seiminModel>
  34. </view>
  35. </template>
  36. <script>
  37. import cloneDeep from 'lodash/cloneDeep';
  38. import {
  39. mapState,
  40. mapMutations,
  41. } from "vuex";
  42. import {
  43. ASSOCIATION_TYPES
  44. } from "../../utils/enum.association_types.js";
  45. export default {
  46. data() {
  47. return {
  48. ASSOCIATION_TYPES,
  49. // 时间戳
  50. timestamp: new Date().getTime(),
  51. // 预约日期
  52. date: false,
  53. // 预约时间
  54. time: false,
  55. // 预约建单按钮是否显示
  56. isYYBuild: false,
  57. // 有预约时间并且是选中的
  58. hasYYtimeChecks: [],
  59. // 是否加急
  60. isUrgent: false,
  61. // 设备
  62. goods: [],
  63. //患者建单信息展示
  64. patientMsg: '',
  65. // 传递过来的参数
  66. queryParams: {},
  67. // 加急原因
  68. urgentRemark: "",
  69. //底部按钮
  70. btns: [],
  71. };
  72. },
  73. computed: {
  74. ...mapState('other', [
  75. 'patientBuildTrip',
  76. 'patientTaskType',
  77. 'selectedPatient',
  78. 'patientBuildData',
  79. ]),
  80. },
  81. methods: {
  82. ...mapMutations('other', ['changePatientBuildData']),
  83. // 切换是否加急
  84. switchChange(e) {
  85. this.isUrgent = e.detail.value;
  86. this.urgentRemark = '';
  87. this.isYYBuild = !this.isUrgent;
  88. this.showBtns(!this.isUrgent);
  89. },
  90. // 选择设备
  91. checkboxChange: function(e) {
  92. console.log(e, this.goods);
  93. var goods = this.goods,
  94. values = e.detail.value;
  95. for (var i = 0, lenI = goods.length; i < lenI; ++i) {
  96. const item = goods[i]
  97. if (values.includes(item.value)) {
  98. this.$set(item, 'checked', true)
  99. } else {
  100. this.$set(item, 'checked', false)
  101. }
  102. }
  103. },
  104. // 立即建单,isYY 是否预约建单
  105. buildOrder(isYY = false) {
  106. console.log(this.urgentRemark)
  107. console.log(this.isUrgent)
  108. console.log(this.goods)
  109. // 加急原因非空
  110. if (this.isUrgent && !this.urgentRemark) {
  111. this.$refs.seiminModel.show({
  112. skin: 'toast',
  113. icon: 'warn',
  114. content: '请填写加急原因',
  115. })
  116. return;
  117. }
  118. // 存储建单数据
  119. // 设备
  120. this.changePatientBuildData({
  121. key: 'goods',
  122. value: this.goods.filter(v => v.checked)
  123. })
  124. // 加急
  125. this.changePatientBuildData({
  126. key: 'urgent',
  127. value: {
  128. isUrgent: this.isUrgent,
  129. urgentRemark: this.urgentRemark,
  130. }
  131. })
  132. // 预约时间
  133. this.changePatientBuildData({
  134. key: 'yyTime',
  135. value: isYY ? `${this.$refs.seiminModel.dateVal} ${this.$refs.seiminModel.timeVal}:00` : ''
  136. })
  137. // 是否预约建单
  138. this.changePatientBuildData({
  139. key: 'isYY',
  140. value: isYY
  141. })
  142. // 跳转
  143. uni.navigateTo({
  144. url: '/pages/patientBuildConfirm/patientBuildConfirm'
  145. })
  146. },
  147. // 需要预约建单-事件
  148. yyInspectChange() {
  149. if (this.patientTaskType.associationType.value === this.ASSOCIATION_TYPES['患者陪检业务']) {
  150. //陪检
  151. let obj = this.hasYYtimeChecks.find((item) => {
  152. return (
  153. new Date(item.yyTime).getTime() - new Date().getTime() >
  154. this.patientTaskType.appointmentTime * 60 * 1000
  155. );
  156. });
  157. if (obj) {
  158. this.showDateTime();
  159. } else {
  160. this.date = true;
  161. this.time = false;
  162. this.timestamp = new Date().getTime();
  163. }
  164. } else {
  165. //转运
  166. this.date = true;
  167. this.time = false;
  168. this.timestamp = new Date().getTime();
  169. }
  170. },
  171. // 是否加急
  172. allowUrgentChange(isUrgent) {
  173. console.log(isUrgent,this.isYYBuild)
  174. if (this.isYYBuild) {
  175. this.isYYBuild = !isUrgent;
  176. if (!this.isYYBuild) {
  177. this.date = false;
  178. this.time = false;
  179. this.timestamp = new Date().getTime();
  180. }
  181. } else {
  182. this.date = false;
  183. this.time = false;
  184. this.timestamp = new Date().getTime();
  185. }
  186. },
  187. //回显时间日期
  188. showDateTime() {
  189. //当前时间要大于生效时间
  190. let isYYBuild = this.hasYYtimeChecks.every((item) => {
  191. return (
  192. new Date(item.yyTime).getTime() - new Date().getTime() >
  193. this.patientTaskType.appointmentTime * 60 * 1000
  194. );
  195. });
  196. //如果勾选需要预约检查
  197. if (isYYBuild) {
  198. //筛选离当前时间最近的
  199. let timeList = this.hasYYtimeChecks
  200. .map((item) => new Date(item.yyTime).getTime())
  201. .sort();
  202. this.date = true;
  203. this.time = true;
  204. this.timestamp = new Date(timeList[0] - this.patientTaskType.appointmentTime * 60 * 1000);
  205. } else {
  206. this.date = false;
  207. this.time = false;
  208. this.timestamp = new Date().getTime();
  209. }
  210. },
  211. // 初始化
  212. init() {
  213. // 提示文字
  214. this.patientMsg = `患者<b class="green">${this.selectedPatient.patientName}</b>即将出科,请您选择送检人员需携带哪些设备!`;
  215. let goods = this.patientBuildTrip.goods ? cloneDeep(this.patientBuildTrip.goods) : []; // 设备
  216. let checks = this.patientBuildData.checks ? cloneDeep(this.patientBuildData.checks) : []; // 检查
  217. this.goods = goods;
  218. // 患者陪检业务和患者其他服务业务相关处理
  219. this.hasYYtimeChecks = checks.filter((v) => Boolean(v.yyTime));
  220. let isPriority = checks.some(v => v.priority == 1);
  221. // 检查有紧急度,则加急
  222. if (isPriority) {
  223. this.isUrgent = true;
  224. this.urgentRemark = '系统根据检查信息,自动进行加急';
  225. } else {
  226. this.isUrgent = false;
  227. this.urgentRemark = '';
  228. }
  229. //判断预约建单按钮
  230. console.log(this.patientBuildTrip)
  231. if (
  232. (this.patientTaskType.associationType.value === this.ASSOCIATION_TYPES['患者陪检业务'] &&
  233. checks.length && this.patientTaskType.appointmentSwitch == 1) ||
  234. (this.patientTaskType.associationType.value === this.ASSOCIATION_TYPES['患者其他服务业务'] &&
  235. this.patientTaskType.appointmentOtherSwitch == 1)
  236. ) {
  237. //选中的检查数组都有预约时间并且允许预约建单
  238. this.isYYBuild = true;
  239. this.allowUrgentChange(this.isUrgent);
  240. if (!this.isUrgent) {
  241. //不加急状态下,回显时间
  242. this.showDateTime();
  243. }
  244. this.yyInspectChange();
  245. } else {
  246. //不允许预约建单
  247. this.isYYBuild = false;
  248. this.date = false;
  249. this.time = false;
  250. this.timestamp = new Date().getTime();
  251. this.yyInspectChange();
  252. }
  253. // 底部按钮展示
  254. this.showBtns(this.isYYBuild);
  255. },
  256. // 底部按钮展示
  257. showBtns(flag) {
  258. console.log(flag,this.isYYBuild)
  259. if (flag && this.isYYBuild) {
  260. //患者陪检业务或患者其他服务业务,并且预约建单开关打开的情况下
  261. this.btns = [{
  262. name: "上一步",
  263. type: "primary",
  264. click: () => {
  265. uni.navigateBack();
  266. },
  267. }, {
  268. name: "预约建单",
  269. type: "primary",
  270. click: () => {
  271. this.$refs.seiminModel.show({
  272. skin: 'yyDate',
  273. title: '',
  274. content: '请您选择希望陪检人员上门的时间',
  275. btns: [{
  276. name: '取消'
  277. },
  278. {
  279. name: '预约建单',
  280. click: () => {
  281. if (this.$refs.seiminModel.dateVal && this.$refs.seiminModel.timeVal) {
  282. this.buildOrder(true);
  283. }
  284. }
  285. }
  286. ]
  287. })
  288. },
  289. }, {
  290. name: "立即建单",
  291. type: "primary",
  292. click: () => {
  293. this.buildOrder();
  294. },
  295. }, ];
  296. } else {
  297. this.btns = [{
  298. name: "上一步",
  299. type: "primary",
  300. click: () => {
  301. uni.navigateBack();
  302. },
  303. }, {
  304. name: "立即建单",
  305. type: "primary",
  306. click: () => {
  307. this.buildOrder();
  308. },
  309. }, ];
  310. }
  311. },
  312. },
  313. onLoad(queryParams) {
  314. this.queryParams = queryParams;
  315. this.init();
  316. },
  317. };
  318. </script>
  319. <style lang="scss" scoped>
  320. .patientBuild {
  321. margin-bottom: 100rpx;
  322. ::v-deep .uni-checkbox-input {
  323. border-radius: 50%;
  324. }
  325. ::v-deep .uni-checkbox-input-checked {
  326. background-color: #09BB07;
  327. &:before {
  328. color: #fff;
  329. }
  330. }
  331. ::v-deep uni-checkbox:not([disabled]) .uni-checkbox-input:hover {
  332. border-color: #09BB07;
  333. }
  334. .qco_msg {
  335. min-height: 144rpx;
  336. padding: 32rpx;
  337. color: #999;
  338. line-height: 40rpx;
  339. font-size: 28rpx;
  340. text-align: center;
  341. }
  342. .select_block_wrap {
  343. @include border(top);
  344. // 设备
  345. .select_block {
  346. padding: 0 30rpx;
  347. height: 88rpx;
  348. font-size: 34rpx;
  349. background-color: #fff;
  350. position: relative;
  351. @include flex(flex-start, center);
  352. &:last-of-type {
  353. &::after {
  354. opacity: 0;
  355. }
  356. }
  357. &::after {
  358. content: '';
  359. height: 1px;
  360. width: calc(100vw - 30rpx);
  361. background-color: #E5E5E5;
  362. position: absolute;
  363. right: 0;
  364. bottom: 0;
  365. }
  366. .select_label {
  367. color: #000;
  368. }
  369. }
  370. }
  371. // 备注
  372. .remarks {
  373. min-height: 150rpx;
  374. background-color: #f9fafb;
  375. @include border(top);
  376. .remarks_nav {
  377. padding: 0 25rpx;
  378. height: 66rpx;
  379. font-size: 28rpx;
  380. color: #666;
  381. @include flex(flex-start, center);
  382. @include border(bottom);
  383. }
  384. .remarks_btn {
  385. padding: 0 25rpx;
  386. font-size: 34rpx;
  387. height: 88rpx;
  388. background-color: #fff;
  389. @include border(bottom);
  390. @include flex(space-between, center);
  391. }
  392. .remarks_textarea {
  393. padding: 22rpx 25rpx;
  394. width: 100%;
  395. min-height: 150rpx;
  396. background-color: #fff;
  397. @include border(bottom);
  398. }
  399. .remarks_tips {
  400. padding: 32rpx 25rpx;
  401. color: #999;
  402. font-size: 28rpx;
  403. line-height: 40rpx;
  404. }
  405. }
  406. }
  407. </style>