rescueRecord.vue 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. <template>
  2. <div class="patient-container">
  3. <patient-sidebar :id="patient_id" defaultActive="1-5"></patient-sidebar>
  4. <div v-loading="loading">
  5. <div class="patient-app-container advice-container app-container">
  6. <div>
  7. <span style="margin-left: 10px;float:right;">
  8. <el-button
  9. size="small"
  10. icon="el-icon-circle-plus-outline"
  11. type="primary"
  12. @click="show_dialog = true"
  13. >新增</el-button
  14. >
  15. <el-button
  16. size="small"
  17. icon="el-icon-circle-plus-outline"
  18. type="primary"
  19. v-if="id>0"
  20. @click="UpdateRecord"
  21. >修改</el-button
  22. >
  23. <el-button
  24. size="small"
  25. icon="el-icon-delete"
  26. v-show="selectingRows.length > 0"
  27. type="danger"
  28. @click="deleteAction"
  29. >删除</el-button
  30. >
  31. <el-button
  32. size="small"
  33. type="primary"
  34. v-if="id>0"
  35. @click="printAction"
  36. >打印</el-button
  37. >
  38. </span>
  39. <!--<span class="filter_title">日期查询</span>-->
  40. <!--<el-date-picker size="small" v-model="date" type="daterange" range-separator="至" start-placeholde="开始日期" end-placeholde="结束日期" value-format="timestamp" :clearable="false" @change="requestRescueRecords()"></el-date-picker>-->
  41. </div>
  42. <div class="cell clearfix">
  43. <label class="title"><span class="name">日期查询</span> : </label>
  44. <el-date-picker
  45. v-model="start_time"
  46. prefix-icon="el-icon-date"
  47. :editable="false"
  48. style="width: 196px;"
  49. type="date"
  50. placeholder="选择日期时间"
  51. align="right"
  52. format="yyyy-MM-dd"
  53. value-format="yyyy-MM-dd"
  54. @change="startTimeChange"
  55. ></el-date-picker>
  56. <span class="">-</span>
  57. <el-date-picker
  58. v-model="end_time"
  59. prefix-icon="el-icon-date"
  60. :editable="false"
  61. style="width: 196px;"
  62. type="date"
  63. placeholder="选择日期时间"
  64. align="right"
  65. format="yyyy-MM-dd"
  66. value-format="yyyy-MM-dd"
  67. @change="endTimeChange"
  68. ></el-date-picker>
  69. </div>
  70. <div class="record">
  71. <el-row :gutter="15">
  72. <el-col :span="10">
  73. <el-table
  74. :header-cell-style="{
  75. backgroundColor: 'rgb(245, 247, 250)',
  76. color: '#606266'
  77. }"
  78. :row-style="{ color: '#303133' }"
  79. ref="record_table"
  80. :data="records"
  81. border
  82. highlight-current-row
  83. @current-change="didChangeCurrentRecord"
  84. @selection-change="didSelectionChange"
  85. >
  86. <el-table-column
  87. type="selection"
  88. width="55">
  89. </el-table-column>
  90. <el-table-column label="记录时间" align="center">
  91. <template slot-scope="scope">
  92. {{ recordTime(scope.row.record_time) }}
  93. </template>
  94. </el-table-column>
  95. <el-table-column label="记录医生" align="center">
  96. <template slot-scope="scope">
  97. {{ doctorName(scope.row.recorder) }}
  98. </template>
  99. </el-table-column>
  100. </el-table>
  101. </el-col>
  102. <el-col :span="14">
  103. <div class="record_content_panel">
  104. <div class="title">抢救内容</div>
  105. <div class="content" style="word-break: break-all;word-wrap: break-word">
  106. {{
  107. current_select_record == null
  108. ? ""
  109. : current_select_record.content
  110. }}
  111. </div>
  112. </div>
  113. </el-col>
  114. </el-row>
  115. </div>
  116. </div>
  117. <el-dialog
  118. title="新增抢救记录"
  119. width="40%"
  120. top="5vh"
  121. :visible.sync="show_dialog"
  122. >
  123. <div>
  124. <div class="new_record_form">
  125. <diV>
  126. <span class="filter_title">日常抢救:</span>
  127. <el-select
  128. v-model="select_template"
  129. placeholder="可选择抢救模板"
  130. @change="didSelectTemplate"
  131. >
  132. <el-option
  133. v-for="(option, index) in templates"
  134. :key="index"
  135. :label="option.title"
  136. :value="option.content"
  137. ></el-option>
  138. </el-select>
  139. </diV>
  140. <div class="textarea_panel">
  141. <el-input
  142. v-model="new_content"
  143. type="textarea"
  144. rows="6"
  145. resize="none"
  146. ></el-input>
  147. </div>
  148. <div
  149. style="text-align: right; padding-right: 0px; padding-top: 10px; padding-bottom: 10px;"
  150. >
  151. <el-button @click="show_dialog = false">取消</el-button>
  152. <el-button
  153. :disabled="
  154. $store.getters.xt_user.subscibe.state == 3 ? true : false
  155. "
  156. type="primary"
  157. @click="createAction"
  158. :loading="uploading_new_record"
  159. >确定
  160. </el-button>
  161. </div>
  162. </div>
  163. </div>
  164. </el-dialog>
  165. <el-dialog
  166. title="修改抢救记录"
  167. width="40%"
  168. top="5vh"
  169. :visible.sync="edit_show_dialog"
  170. >
  171. <div>
  172. <div class="new_record_form">
  173. <diV>
  174. <span class="filter_title">日常抢救:</span>
  175. <el-select
  176. v-model="select_template"
  177. placeholder="可选择抢救模板"
  178. @change="didSelectTemplate"
  179. >
  180. <el-option
  181. v-for="(option, index) in templates"
  182. :key="index"
  183. :label="option.title"
  184. :value="option.content"
  185. ></el-option>
  186. </el-select>
  187. </diV>
  188. <div class="textarea_panel">
  189. <el-input
  190. v-model="new_content"
  191. type="textarea"
  192. rows="6"
  193. resize="none"
  194. ></el-input>
  195. </div>
  196. <div
  197. style="text-align: right; padding-right: 0px; padding-top: 10px; padding-bottom: 10px;"
  198. >
  199. <el-button @click="edit_show_dialog = false">取消</el-button>
  200. <el-button
  201. :disabled="
  202. $store.getters.xt_user.subscibe.state == 3 ? true : false
  203. "
  204. type="primary"
  205. @click="updateAction"
  206. :loading="uploading_new_record"
  207. >确定
  208. </el-button>
  209. </div>
  210. </div>
  211. </div>
  212. </el-dialog>
  213. </div>
  214. </div>
  215. </template>
  216. <script>
  217. import PatientSidebar from "./components/PatientSidebar";
  218. import {
  219. createRescueRecord,
  220. deleteRescueRecords,
  221. getRescueRecords,
  222. getPatientRescueRecord,
  223. modifyCoursePrint
  224. } from "@/api/patient";
  225. import { parseTime } from "@/utils";
  226. const moment = require('moment')
  227. export default {
  228. name: "RescueRecord",
  229. components: {
  230. PatientSidebar
  231. },
  232. data() {
  233. return {
  234. loading: false,
  235. edit_show_dialog:false,
  236. patient_id: 0,
  237. date: [],
  238. start_time: "",
  239. end_time: "",
  240. records: [],
  241. doctors: [],
  242. current_select_record: null,
  243. show_dialog: false,
  244. uploading_new_record: false,
  245. templates: this.$store.getters.configlist.rescue_record,
  246. select_template: [],
  247. new_content: "",
  248. selectingRows: [],
  249. id:0,
  250. };
  251. },
  252. created() {
  253. this.patient_id = parseInt(this.$route.query.id);
  254. if (isNaN(this.patient_id) || this.patient_id <= 0) {
  255. this.$notify.error({
  256. title: "错误",
  257. message: "无效的id"
  258. });
  259. this.$router.push("/patients/patients");
  260. return;
  261. }
  262. // var nowDate = new Date();
  263. // var nowYear = nowDate.getFullYear();
  264. // var nowMonth = nowDate.getMonth() + 1;
  265. // var nowDay = nowDate.getDate();
  266. // this.end_time =
  267. // nowYear +
  268. // "-" +
  269. // (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  270. // "-" +
  271. // (nowDay < 10 ? "0" + nowDay : nowDay);
  272. // nowDate.setMonth(nowDate.getMonth() - 1);
  273. // nowYear = nowDate.getFullYear()-1;
  274. // nowMonth = nowDate.getMonth() + 1;
  275. // nowDay = nowDate.getDate();
  276. // this.start_time =
  277. // nowYear +
  278. // "-" +
  279. // (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  280. // "-" +
  281. // (nowDay < 10 ? "0" + nowDay : nowDay);
  282. this.start_time = moment().month(moment().month() - 1).startOf('month').format('YYYY-MM-DD');
  283. console.log("start_time",this.start_time)
  284. this.end_time = moment().endOf('month').format('YYYY-MM-DD');
  285. console.log("end_time",this.end_time)
  286. this.requestRescueRecords();
  287. },
  288. methods: {
  289. requestRescueRecords: function() {
  290. var startTime = new Date(this.date[0]);
  291. var endTime = new Date(this.date[1]);
  292. this.loading = true;
  293. getRescueRecords(this.patient_id, this.start_time, this.end_time)
  294. .then(rs => {
  295. this.loading = false;
  296. var resp = rs.data;
  297. if (resp.state == 1) {
  298. this.current_select_record = null;
  299. this.records = resp.data.records;
  300. this.doctors = resp.data.doctors;
  301. } else {
  302. this.$message.error(resp.msg);
  303. }
  304. })
  305. .catch(error => {
  306. this.loading = false;
  307. this.$message.error(error);
  308. });
  309. },
  310. didChangeCurrentRecord: function(record) {
  311. this.current_select_record = record;
  312. this.id = record.id
  313. },
  314. recordTime: function(timestamp) {
  315. var time = new Date(timestamp * 1000);
  316. return parseTime(time, "{y}-{m}-{d}");
  317. },
  318. doctorName: function(doctor_id) {
  319. for (let index = 0; index < this.doctors.length; index++) {
  320. const doctor = this.doctors[index];
  321. if (doctor.id == doctor_id) {
  322. return doctor.name;
  323. }
  324. }
  325. return "";
  326. },
  327. createAction: function() {
  328. if (this.new_content.length == 0) {
  329. this.$message.error("请填写抢救内容");
  330. return;
  331. }
  332. this.uploading_new_record = true;
  333. createRescueRecord(this.patient_id, this.new_content)
  334. .then(rs => {
  335. this.uploading_new_record = false;
  336. var resp = rs.data;
  337. if (resp.state == 1) {
  338. this.records.unshift(resp.data.record);
  339. // this.$refs.record_table.setCurrentRow()
  340. this.$refs.record_table.setCurrentRow(this.records[0]);
  341. // this.current_select_record = this.records[0]
  342. this.show_dialog = false;
  343. this.new_content = "";
  344. } else {
  345. this.$message.error(resp.msg);
  346. }
  347. })
  348. .catch(error => {
  349. this.uploading_new_record = false;
  350. this.$message.error(error);
  351. });
  352. },
  353. UpdateRecord(){
  354. getPatientRescueRecord(this.id).then(response=>{
  355. if(response.data.state == 1){
  356. var rescueRecord = response.data.data.rescueRecord
  357. console.log("rescueRecord",rescueRecord)
  358. this.new_content = rescueRecord.content
  359. this.edit_show_dialog = true
  360. }
  361. })
  362. },
  363. didSelectTemplate: function(templateContent) {
  364. this.new_content =
  365. this.new_content.length > 0
  366. ? this.new_content + templateContent
  367. : templateContent;
  368. },
  369. didSelectionChange: function(selectRows) {
  370. this.selectingRows = selectRows;
  371. },
  372. deleteAction: function() {
  373. if (this.selectingRows.length == 0) {
  374. return;
  375. }
  376. var ids = [];
  377. for (let index = 0; index < this.selectingRows.length; index++) {
  378. const row = this.selectingRows[index];
  379. ids.push(row.id);
  380. }
  381. var ids_str = ids.join(",");
  382. this.loading = true;
  383. deleteRescueRecords(this.patient_id, ids_str)
  384. .then(rs => {
  385. var resp = rs.data;
  386. if (resp.state == 1) {
  387. for (let id_index = 0; id_index < ids.length; id_index++) {
  388. for (
  389. let record_index = 0;
  390. record_index < this.records.length;
  391. record_index++
  392. ) {
  393. if (ids[id_index] == this.records[record_index].id) {
  394. this.records.splice(record_index, 1);
  395. break;
  396. }
  397. }
  398. }
  399. this.selectingRows = [];
  400. this.$message.success("已删除");
  401. } else {
  402. this.$message.error(resp.msg);
  403. }
  404. this.loading = false;
  405. })
  406. .catch(err => {
  407. this.loading = false;
  408. this.$message.error(err);
  409. });
  410. },
  411. startTimeChange(val) {
  412. this.requestRescueRecords();
  413. },
  414. endTimeChange(val) {
  415. this.requestRescueRecords();
  416. },
  417. updateAction(){
  418. this.edit_show_dialog = true
  419. var params = {
  420. id:this.id,
  421. content:this.new_content,
  422. }
  423. modifyCoursePrint(params).then(response=>{
  424. if(response.data.state == 1){
  425. var coursePrint = response.data.data.coursePrint
  426. this.selectingRows = coursePrint
  427. this.requestRescueRecords();
  428. this.$message.success("更新成功!")
  429. this.edit_show_dialog = false
  430. }
  431. })
  432. },
  433. printAction(){
  434. if(this.id == 0){
  435. this.$message.error('请选择要打印的病程')
  436. return
  437. }
  438. this.$router.push({ path: "/rescue/record/print?id="+this.id+"&patient_id="+this.patient_id});
  439. }
  440. }
  441. };
  442. </script>
  443. <style rel="stylesheet/css" lang="scss" scoped>
  444. .container {
  445. margin-left: 180px;
  446. padding: 20px;
  447. background: #fff;
  448. min-height: calc(100vh - 173px);
  449. margin-bottom: 15px;
  450. .record {
  451. padding-top: 20px;
  452. }
  453. }
  454. .record_content_panel {
  455. border-width: 1px;
  456. border-style: solid;
  457. border-color: #ebeef5;
  458. min-height: 200px;
  459. .title {
  460. font-size: 14px;
  461. font-weight: 500;
  462. color: #909399;
  463. line-height: 44px;
  464. height: 44px;
  465. text-align: center;
  466. border-bottom-width: 1px;
  467. border-bottom-style: solid;
  468. border-bottom-color: #ebeef5;
  469. background-color: rgb(245, 247, 250);
  470. }
  471. .content {
  472. padding: 12px 15px;
  473. font-size: 15px;
  474. color: gray;
  475. line-height: 22px;
  476. }
  477. }
  478. .new_record_form {
  479. .textarea_panel {
  480. margin-top: 10px;
  481. }
  482. }
  483. </style>
  484. <style>
  485. .el-table td,
  486. .el-table th.is-leaf,
  487. .el-table--border,
  488. .el-table--group {
  489. border-color: #d0d3da;
  490. }
  491. .el-table--border::after,
  492. .el-table--group::after,
  493. .el-table::before {
  494. background-color: #d0d3da;
  495. }
  496. </style>