血透系统PC前端

rescueRecord.vue 9.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <div class="patient-container">
  3. <patient-sidebar :id="patient_id" defaultActive="1-5"></patient-sidebar>
  4. <div class="container" v-loading="loading">
  5. <div>
  6. <span class="filter_title">日期查询</span>
  7. <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>
  8. <span style="margin-left: 10px;">
  9. <el-button size="small" icon="el-icon-circle-plus-outline" type="primary" @click="show_dialog = true">新增</el-button>
  10. <el-button size="small" icon="el-icon-delete" v-show="selectingRows.length > 0" type="danger" @click="deleteAction">删除</el-button>
  11. </span>
  12. </div>
  13. <div class="record">
  14. <el-row :gutter="15">
  15. <el-col :span="10">
  16. <el-table :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)'}" ref="record_table" :data="records" border highlight-current-row @current-change="didChangeCurrentRecord" @selection-change="didSelectionChange">
  17. <el-table-column type="selection" width="40" align="center"></el-table-column>
  18. <el-table-column label="记录时间" align="center">
  19. <template slot-scope="scope">
  20. {{ recordTime(scope.row.record_time) }}
  21. </template>
  22. </el-table-column>
  23. <el-table-column label="记录医生" align="center">
  24. <template slot-scope="scope">
  25. {{ doctorName(scope.row.recorder) }}
  26. </template>
  27. </el-table-column>
  28. </el-table>
  29. </el-col>
  30. <el-col :span="14">
  31. <div class="record_content_panel">
  32. <div class="title">抢救内容</div>
  33. <div class="content">
  34. {{ current_select_record == null ? "" : current_select_record.content }}
  35. </div>
  36. </div>
  37. </el-col>
  38. </el-row>
  39. </div>
  40. </div>
  41. <el-dialog title="新增抢救记录" width="40%" top="5vh" :visible.sync="show_dialog">
  42. <div>
  43. <div class="new_record_form">
  44. <diV>
  45. <span class="filter_title">日常抢救:</span>
  46. <el-select v-model="select_template" placeholder="可选择抢救模板" @change="didSelectTemplate">
  47. <el-option v-for="(option, index) in templates" :key="index" :label="option.title" :value="option.content"></el-option>
  48. </el-select>
  49. </diV>
  50. <div class="textarea_panel">
  51. <el-input v-model="new_content" type="textarea" rows="6" resize="none"></el-input>
  52. </div>
  53. <div style="text-align: right; padding-right: 0px; padding-top: 10px; padding-bottom: 10px;">
  54. <el-button @click="show_dialog = false">取消</el-button>
  55. <el-button :disabled="$store.getters.xt_user.subscibe.state==3?true:false" type="primary" @click="createAction" :loading="uploading_new_record">确定</el-button>
  56. </div>
  57. </div>
  58. </div>
  59. </el-dialog>
  60. </div>
  61. </template>
  62. <script>
  63. import PatientSidebar from "./components/PatientSidebar"
  64. import { getRescueRecords, createRescueRecord, deleteRescueRecords } from "@/api/patient"
  65. import { parseTime } from "@/utils"
  66. export default {
  67. name: "RescueRecord",
  68. components: {
  69. PatientSidebar
  70. },
  71. data() {
  72. return {
  73. loading: false,
  74. patient_id: 0,
  75. date: [],
  76. records: [],
  77. doctors: [],
  78. current_select_record: null,
  79. show_dialog: false,
  80. uploading_new_record: false,
  81. templates: this.$store.getters.configlist.rescue_record,
  82. select_template: [],
  83. new_content: "",
  84. selectingRows: [],
  85. }
  86. },
  87. created() {
  88. this.patient_id = parseInt(this.$route.query.id)
  89. if (isNaN(this.patient_id) || this.patient_id <= 0) {
  90. this.$notify.error({
  91. title: "错误",
  92. message: "无效的id"
  93. })
  94. this.$router.push("/patients/patients")
  95. return
  96. }
  97. var now = new Date()
  98. this.date = [now.getTime() - (7 * 24 * 60 * 60 * 1000), now.getTime()]
  99. this.requestRescueRecords()
  100. },
  101. methods: {
  102. requestRescueRecords: function() {
  103. var startTime = new Date(this.date[0])
  104. var endTime = new Date(this.date[1])
  105. this.loading = true
  106. getRescueRecords(this.patient_id, parseTime(startTime, "{y}-{m}-{d}"), parseTime(endTime, "{y}-{m}-{d}")).then(rs => {
  107. this.loading = false
  108. var resp = rs.data
  109. if (resp.state == 1) {
  110. this.current_select_record = null
  111. this.records = resp.data.records
  112. this.doctors = resp.data.doctors
  113. } else {
  114. this.$message.error(resp.msg)
  115. }
  116. }).catch(error => {
  117. this.loading = false
  118. this.$message.error(error)
  119. })
  120. },
  121. didChangeCurrentRecord: function(record) {
  122. this.current_select_record = record
  123. },
  124. recordTime: function(timestamp) {
  125. var time = new Date(timestamp * 1000)
  126. return parseTime(time, "{y}-{m}-{d}")
  127. },
  128. doctorName: function(doctor_id) {
  129. for (let index = 0; index < this.doctors.length; index++) {
  130. const doctor = this.doctors[index];
  131. if (doctor.id == doctor_id) {
  132. return doctor.name
  133. }
  134. }
  135. return ""
  136. },
  137. createAction: function() {
  138. if (this.new_content.length == 0) {
  139. this.$message.error("请填写抢救内容")
  140. return
  141. }
  142. this.uploading_new_record = true
  143. createRescueRecord(this.patient_id, this.new_content).then(rs => {
  144. this.uploading_new_record = false
  145. var resp = rs.data
  146. if (resp.state == 1) {
  147. this.records.unshift(resp.data.record)
  148. // this.$refs.record_table.setCurrentRow()
  149. this.$refs.record_table.setCurrentRow(this.records[0])
  150. // this.current_select_record = this.records[0]
  151. this.show_dialog = false
  152. this.new_content = ""
  153. } else {
  154. this.$message.error(resp.msg)
  155. }
  156. }).catch(error => {
  157. this.uploading_new_record = false
  158. this.$message.error(error)
  159. })
  160. },
  161. didSelectTemplate: function(templateContent) {
  162. this.new_content = this.new_content.length > 0 ? (this.new_content + templateContent) : templateContent
  163. this.select_template = ""
  164. },
  165. didSelectionChange: function(selectRows) {
  166. this.selectingRows = selectRows
  167. },
  168. deleteAction: function() {
  169. if (this.selectingRows.length == 0) {
  170. return
  171. }
  172. var ids = []
  173. for (let index = 0; index < this.selectingRows.length; index++) {
  174. const row = this.selectingRows[index];
  175. ids.push(row.id)
  176. }
  177. var ids_str = ids.join(",")
  178. this.loading = true
  179. deleteRescueRecords(this.patient_id, ids_str).then(rs => {
  180. var resp = rs.data
  181. if (resp.state == 1) {
  182. for (let id_index = 0; id_index < ids.length; id_index++) {
  183. for (let record_index = 0; record_index < this.records.length; record_index++) {
  184. if (ids[id_index] == this.records[record_index].id) {
  185. this.records.splice(record_index, 1)
  186. break
  187. }
  188. }
  189. }
  190. this.selectingRows = []
  191. this.$message.success("已删除")
  192. } else {
  193. this.$message.error(resp.msg)
  194. }
  195. this.loading = false
  196. }).catch(err => {
  197. this.loading = false
  198. this.$message.error(err)
  199. })
  200. },
  201. },
  202. }
  203. </script>
  204. <style rel="stylesheet/css" lang="scss" scoped>
  205. .container {
  206. margin-left: 180px;
  207. padding: 20px;
  208. background: #fff;
  209. min-height: calc(100vh - 173px);
  210. margin-bottom: 15px;
  211. .record {
  212. padding-top: 20px;
  213. }
  214. }
  215. .record_content_panel {
  216. border-width: 1px;
  217. border-style: solid;
  218. border-color: #ebeef5;
  219. min-height: 200px;
  220. .title {
  221. font-size: 14px;
  222. font-weight: 500;
  223. color: #909399;
  224. line-height: 44px;
  225. height: 44px;
  226. text-align: center;
  227. border-bottom-width: 1px;
  228. border-bottom-style: solid;
  229. border-bottom-color: #ebeef5;
  230. }
  231. .content {
  232. padding: 12px 15px;
  233. font-size: 15px;
  234. color: gray;
  235. line-height: 22px;
  236. }
  237. }
  238. .new_record_form {
  239. // padding: 10px, 25px;
  240. .textarea_panel {
  241. margin-top: 10px;
  242. }
  243. }
  244. </style>