courseOfDisease.vue 18KB

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