血透系统pad前端

PlaneDialog.vue 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. <template>
  2. <div>
  3. <div class="Dialog" v-show="!selecting">
  4. <div class="DialogTit">
  5. <span @click="close()" class="iconfont">&#xe6e9;</span>
  6. <h1 class="name">透析下机</h1>
  7. <span
  8. class="success"
  9. v-if="
  10. this.record.state == 1 ||
  11. this.$store.getters.user.user.id != this.creator
  12. "
  13. ></span>
  14. <span
  15. class="success"
  16. @click="modify()"
  17. v-if="isPremission || this.$store.getters.user.user.id == this.creator"
  18. >修改</span
  19. >
  20. </div>
  21. <div class="DialogContent">
  22. <div class="item" @click="select_nurse">
  23. <h2 class="name">下机护士</h2>
  24. <div class="content">
  25. <span class="text" style="width: 100px">{{
  26. nurse_id == 0 ? "" : admin_map[nurse_id].name
  27. }}</span>
  28. <span class="iconfont">&#xe6f9;</span>
  29. </div>
  30. </div>
  31. <div class="item">
  32. <h2 class="name">下机时间</h2>
  33. <div class="content">
  34. <span
  35. class="text"
  36. style="width: 100px"
  37. @click="selectStartTimeAction"
  38. >{{ end_time_str }}</span
  39. >
  40. <span class="iconfont">&#xe6f9;</span>
  41. </div>
  42. </div>
  43. <div class="perform">
  44. <button
  45. @click="commitInfo"
  46. v-show="record != null && record.id != '' && record.stage == 1"
  47. >
  48. 执行下机
  49. </button>
  50. <button
  51. :disabled="true"
  52. style="background-color:lightgray;"
  53. v-show="record != null && record.id != '' && record.stage == 2"
  54. >
  55. 已下机
  56. </button>
  57. <button
  58. :disabled="true"
  59. style="background-color:lightgray;"
  60. v-show="record == null || record.id == ''"
  61. >
  62. 未上机
  63. </button>
  64. </div>
  65. </div>
  66. </div>
  67. <two-menu ref="selector"></two-menu>
  68. <mt-datetime-picker
  69. ref="start_time_picker"
  70. type="datetime"
  71. @confirm="didSelectStartTime"
  72. v-model="end_time"
  73. ></mt-datetime-picker>
  74. </div>
  75. </template>
  76. <script>
  77. import { finish, PostModifyEndDialysis } from "@/api/dialysis";
  78. import { Toast } from "vant";
  79. import TwoMenu from "./TwoMenu";
  80. import { parseTime } from "@/utils";
  81. export default {
  82. name: "PlaneDialog",
  83. components: {
  84. TwoMenu
  85. },
  86. data() {
  87. return {
  88. selecting: false,
  89. end_time_str: "",
  90. end_time: new Date(),
  91. nurse_id: 0,
  92. isPremission: false,
  93. creator: 0
  94. };
  95. },
  96. props: {
  97. prescription_prop: {
  98. type: Object
  99. },
  100. patient_prop: {
  101. type: Object
  102. },
  103. record: {
  104. type: Object
  105. },
  106. admins: {
  107. type: Array
  108. },
  109. admin_map: {
  110. type: Object
  111. },
  112. special_premission: {
  113. type: Array
  114. },
  115. last_monitor_record: {
  116. type: Object
  117. }
  118. },
  119. mounted() {
  120. if (this.record.id == "") {
  121. //没有上下机记录
  122. this.end_time_str =
  123. parseTime(Date.parse(new Date()) / 1000, "{y}-{m}-{d} {h}:{i}") + ":00";
  124. } else {
  125. if (this.record.start_time > 0) {
  126. if (this.prescription_prop.id != "") {
  127. let endTime = 0;
  128. endTime =
  129. this.record.start_time +
  130. this.prescription_prop.dialysis_duration_hour * 3600 +
  131. this.prescription_prop.dialysis_duration_minute * 60;
  132. this.end_time_str = parseTime(endTime, "{y}-{m}-{d} {h}:{i}") + ":00";
  133. } else {
  134. this.end_time_str =
  135. parseTime(Date.parse(new Date()) / 1000, "{y}-{m}-{d} {h}:{i}") +
  136. ":00";
  137. }
  138. if (this.record.end_time > 0) {
  139. this.end_time_str =
  140. parseTime(this.record.end_time, "{y}-{m}-{d} {h}:{i}") + ":00";
  141. }
  142. } else {
  143. this.end_time_str =
  144. parseTime(Date.parse(new Date()) / 1000, "{y}-{m}-{d} {h}:{i}") +
  145. ":00";
  146. }
  147. }
  148. this.end_time = this.end_time_str;
  149. // if(this.record.idthis.record.end_time == 0)
  150. // if(this.last_monitor_record.id == 0){
  151. //
  152. // this.end_time_str = parseTime(this.last_monitor_record.operate_time, "{y}-{m}-{d} {h}:{i}") + ":00";
  153. // }else{
  154. // this.end_time_str = parseTime(this.end_time, "{y}-{m}-{d} {h}:{i}") + ":00";
  155. //
  156. // }
  157. },
  158. created() {
  159. var date = this.$route.query && this.$route.query.date;
  160. date *= 1000;
  161. var newDate = new Date(date);
  162. var y = newDate.getFullYear();
  163. var m = newDate.getMonth() + 1;
  164. var d = newDate.getDate();
  165. if (isNaN(y) || isNaN(m) || isNaN(d)) {
  166. newDate = new Date();
  167. y = newDate.getFullYear();
  168. m = newDate.getMonth() + 1;
  169. d = newDate.getDate();
  170. }
  171. this.record_date =
  172. y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d);
  173. if (this.record == null || this.record.id == "") {
  174. this.nurse_id = 0;
  175. } else if (this.record.stage == 1) {
  176. this.nurse_id = this.$store.getters.user.user.id;
  177. } else {
  178. this.nurse_id = this.record.finish_nurse;
  179. }
  180. if (this.record.id > 0) {
  181. for (let i = 0; i < this.special_premission.length; i++) {
  182. if (
  183. this.$store.getters.user.user.id ==
  184. this.special_premission[i].admin_user_id
  185. ) {
  186. this.isPremission = true;
  187. }
  188. }
  189. }
  190. if (this.record.id > 0) {
  191. if (this.record.finish_creator == 0) {
  192. this.creator = this.record.finish_nurse;
  193. } else {
  194. this.creator = this.record.finish_creator;
  195. }
  196. }
  197. },
  198. methods: {
  199. set_last_monitor_record(monitor) {
  200. this.last_monitor_record = monitor;
  201. this.end_time_str =
  202. parseTime(
  203. this.last_monitor_record.operate_time,
  204. "{y}-{m}-{d} {h}:{i}"
  205. ) + ":00";
  206. },
  207. modify() {
  208. let ParamsQuery = {};
  209. ParamsQuery["id"] = this.record.id;
  210. ParamsQuery["nurse"] = this.nurse_id;
  211. ParamsQuery["end_time"] = this.end_time_str;
  212. PostModifyEndDialysis(ParamsQuery).then(response => {
  213. if (response.data.state == 0) {
  214. Toast.fail(response.data.msg);
  215. return false;
  216. } else {
  217. Toast.success("修改成功");
  218. this.$emit("did_off", response.data.data.dialysis_order);
  219. var record = this.record;
  220. for (const key in response.data.data.dialysis_order) {
  221. this.$set(record, key, response.data.data.dialysis_order[key]);
  222. }
  223. }
  224. }).catch(err => {
  225. Toast.fail(err)
  226. });
  227. },
  228. didSelectStartTime: function(time) {
  229. this.end_time_str = parseTime(time, "{y}-{m}-{d} {h}:{i}") + ":00";
  230. },
  231. selectStartTimeAction: function() {
  232. if (this.record.id != 0) {
  233. if (this.record.end_time > 0) {
  234. var creator = 0;
  235. if (this.record.finish_creator == 0) {
  236. creator = this.record.finish_nurse;
  237. } else {
  238. creator = this.record.finish_creator;
  239. }
  240. if (
  241. this.$store.getters.user.user.id == creator ||
  242. this.isPremission
  243. ) {
  244. this.$refs.start_time_picker.open();
  245. } else {
  246. return;
  247. }
  248. } else {
  249. this.$refs.start_time_picker.open();
  250. }
  251. } else {
  252. this.$refs.start_time_picker.open();
  253. }
  254. },
  255. commitInfo: function() {
  256. Toast.loading({ forbidClick: true, duration: 0 });
  257. let ParamsQuery = {};
  258. ParamsQuery["patient"] = this.patient_prop.id;
  259. ParamsQuery["record_date"] = this.record_date;
  260. ParamsQuery["nurse"] = this.nurse_id;
  261. ParamsQuery["end_time"] = this.end_time_str;
  262. finish(ParamsQuery).then(response => {
  263. if (response.data.state == 0) {
  264. Toast.fail(response.data.msg);
  265. return false;
  266. } else {
  267. Toast.success("下机成功");
  268. this.$emit("did_off", response.data.data.assessmentAfterDislysis);
  269. var record = this.record;
  270. for (const key in response.data.data.dialysisOrder) {
  271. this.$set(record, key, response.data.data.dialysisOrder[key]);
  272. // record[key] = response.data.data.dialysisOrder[key]
  273. }
  274. // console.log(this.record)
  275. }
  276. }).catch(err => {
  277. Toast.fail(err)
  278. });
  279. },
  280. close: function() {
  281. this.$emit("close");
  282. },
  283. select_nurse: function() {
  284. if (this.record != null && this.record.id != "") {
  285. if (this.record.stage == 1) {
  286. this.selecting = true;
  287. var t = this;
  288. this.$refs.selector.showSingleSelect(
  289. this.admins,
  290. this.nurse_id,
  291. "选择下机护士",
  292. "name",
  293. "id",
  294. function(select_id) {
  295. console.log("nurse id: ", select_id);
  296. t.nurse_id = select_id;
  297. },
  298. function() {
  299. t.selecting = false;
  300. }
  301. );
  302. } else {
  303. var creator = 0;
  304. if (this.record.finish_creator == 0) {
  305. creator = this.record.finish_nurse;
  306. } else {
  307. creator = this.record.finish_creator;
  308. }
  309. if (
  310. this.$store.getters.user.user.id == creator ||
  311. this.isPremission
  312. ) {
  313. this.selecting = true;
  314. var t = this;
  315. this.$refs.selector.showSingleSelect(
  316. this.admins,
  317. this.nurse_id,
  318. "选择下机护士",
  319. "name",
  320. "id",
  321. function(select_id) {
  322. console.log("nurse id: ", select_id);
  323. t.nurse_id = select_id;
  324. },
  325. function() {
  326. t.selecting = false;
  327. }
  328. );
  329. } else {
  330. return;
  331. }
  332. }
  333. }
  334. },
  335. open: function() {
  336. this.selecting = false;
  337. this.$refs.selector.hide();
  338. }
  339. },
  340. watch: {
  341. "record.stage": function(val) {
  342. if (val == 2) {
  343. for (let i = 0; i < this.special_premission.length; i++) {
  344. if (
  345. this.$store.getters.user.user.id ==
  346. this.special_premission[i].admin_user_id
  347. ) {
  348. this.isPremission = true;
  349. }
  350. }
  351. if (this.record.finish_nurse == 0) {
  352. this.creator = this.record.finish_nurse;
  353. } else {
  354. this.creator = this.record.finish_creator;
  355. }
  356. }
  357. console.log(this.creator);
  358. console.log(this.$store.getters.user.user.id);
  359. }
  360. }
  361. };
  362. </script>
  363. <style style="stylesheet/scss" lang="scss" scoped>
  364. .perform {
  365. text-align: center;
  366. font-size: 0.3rem;
  367. padding-top: 2rem;
  368. .crew {
  369. color: $pgh-color;
  370. }
  371. button {
  372. background: $main-color;
  373. color: #fff;
  374. font-size: 0.45rem;
  375. text-align: center;
  376. width: 3rem;
  377. height: 1.2rem;
  378. line-height: 1.2rem;
  379. border-radius: 4px;
  380. margin-top: 10px;
  381. }
  382. }
  383. </style>