inspectionInfectious.vue 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. <template>
  2. <div class="patient-container">
  3. <patient-sidebar :id="patientID" defaultActive="1-8"></patient-sidebar>
  4. <div
  5. class="patient-app-container app-container"
  6. v-loading="pageLoading"
  7. element-loading-text="拼命加载中"
  8. >
  9. <div class="filter-container" style="display: flex;justify-content: space-between;align-items: center;margin-bottom: 10px;">
  10. <div>
  11. {{ itemName }}
  12. <span v-if="itemDate">(检查日期:{{ itemDate }})</span>
  13. <span>次数:{{total}}</span>
  14. </div>
  15. <div>
  16. <el-button
  17. size="small"
  18. type="primary"
  19. @click="openNew()"
  20. icon="el-icon-circle-plus-outline"
  21. :disabled="project ? false : true"
  22. >新增</el-button
  23. >
  24. <el-button
  25. size="small"
  26. type="primary"
  27. icon="el-icon-edit-outline"
  28. @click="openEdit()"
  29. :disabled="itemDate ? false : true"
  30. >修改</el-button
  31. >
  32. <el-button
  33. size="small"
  34. type="danger"
  35. icon="el-icon-delete"
  36. @click="deleteInspection()"
  37. :disabled="itemDate ? false : true"
  38. >删除</el-button
  39. >
  40. </div>
  41. </div>
  42. <el-table
  43. :header-cell-style="{
  44. backgroundColor: 'rgb(245, 247, 250)',
  45. color: '#606266'
  46. }"
  47. :row-style="{ color: '#303133' }"
  48. :data="items"
  49. border
  50. style="width: 100%"
  51. id="user-inspection-order"
  52. >
  53. <el-table-column
  54. prop="item_name"
  55. label="检验项目"
  56. align="center"
  57. min-width="180"
  58. >
  59. <template slot-scope="scope">
  60. {{ scope.row.item_name }} {{ scope.row.item_name_addition }}
  61. </template>
  62. </el-table-column>
  63. <el-table-column
  64. prop="name"
  65. label="结果"
  66. align="center"
  67. min-width="80"
  68. >
  69. <template slot-scope="scope">
  70. <span v-if="scope.row.value =='阳性'" style="color:red">{{ scope.row.value }}</span>
  71. <span v-else>{{ scope.row.value }}</span>
  72. <span v-if="scope.row.range_type == 1">
  73. {{scope.row.value_direction}}
  74. </span>
  75. </template>
  76. </el-table-column>
  77. <el-table-column
  78. prop="address"
  79. label="参考值"
  80. align="center"
  81. min-width="120"
  82. >
  83. <template slot-scope="scope">
  84. <span v-if="scope.row.range_type == 1"
  85. >{{ scope.row.range_min }}~{{ scope.row.range_max }}</span
  86. >
  87. <span v-else>{{ scope.row.range_value }}</span>
  88. </template>
  89. </el-table-column>
  90. <el-table-column
  91. prop="unit"
  92. label="单位"
  93. align="center"
  94. min-width="200"
  95. >
  96. </el-table-column>
  97. </el-table>
  98. <el-pagination
  99. align="right"
  100. @current-change="handleCurrentChangePage"
  101. :current-page="queryParams.page"
  102. :page-size="1"
  103. background
  104. style="margin-top:20px;"
  105. layout="total, prev, pager, next, jumper"
  106. :total="total"
  107. >
  108. </el-pagination>
  109. </div>
  110. <el-dialog
  111. :title="formTitle"
  112. :visible.sync="dialogFormVisible"
  113. width="1000px"
  114. id="user-inspection-form"
  115. v-loading="formLoading"
  116. >
  117. <el-form :model="form" ref="form" label-position="top">
  118. <el-row>
  119. <el-col :span="24" v-if="form.formItem[0].project_id == 14">
  120. <el-form-item label="传染病周期提醒: ">
  121. <el-radio-group v-model="form.remind_cycle">
  122. <el-radio :label="1">一月一次</el-radio>
  123. <el-radio :label="2">两月一次</el-radio>
  124. <el-radio :label="3">三月一次</el-radio>
  125. <el-radio :label="4">半年一次</el-radio>
  126. <el-radio :label="5">一年一次</el-radio>
  127. </el-radio-group>
  128. </el-form-item>
  129. </el-col>
  130. <el-col :span="7">
  131. <el-form-item
  132. label="检验日期"
  133. prop="inspect_date"
  134. :rules="[
  135. { required: true, message: '请输入检验日期', trigger: 'blur' }
  136. ]"
  137. >
  138. <el-date-picker
  139. style="width:95%"
  140. v-model="form.inspect_date"
  141. type="datetime"
  142. value-format="yyyy-MM-dd HH:mm"
  143. format="yyyy-MM-dd HH:mm"
  144. placeholder="选择日期"
  145. >
  146. </el-date-picker>
  147. </el-form-item>
  148. </el-col>
  149. <el-col :span="1">&nbsp;</el-col>
  150. <template v-for="(item, index) in form.formItem">
  151. <el-col :span="7" :key="index">
  152. <el-form-item
  153. :label="item.item_name"
  154. v-if="item.range_type == 1"
  155. :key="item.item_id"
  156. :prop="'formItem.' + index + '.value'"
  157. >
  158. <el-input
  159. placeholder="请填入"
  160. v-model="item.value"
  161. style="width:95%"
  162. type="number"
  163. >
  164. <template slot="append">{{ item.unit }}</template>
  165. </el-input>
  166. </el-form-item>
  167. <el-form-item
  168. :label="item.item_name"
  169. v-else
  170. :key="item.item_id"
  171. :prop="'formItem.' + index + '.value'"
  172. >
  173. <el-select
  174. v-model="item.value"
  175. placeholder="请选择"
  176. style="width:95%"
  177. >
  178. <el-option
  179. v-for="(optionItem, oidex) in item.select_options"
  180. :key="oidex"
  181. :label="optionItem"
  182. :value="optionItem"
  183. >
  184. </el-option>
  185. </el-select>
  186. </el-form-item>
  187. </el-col>
  188. <el-col :span="1" :key="'form-col' + index">&nbsp;</el-col>
  189. </template>
  190. </el-row>
  191. </el-form>
  192. <div slot="footer" class="dialog-footer">
  193. <el-button @click="dialogFormVisible = false">取 消</el-button>
  194. <el-button
  195. type="primary"
  196. v-if="form.method == 'add'"
  197. @click="submitNew('form')"
  198. >保 存</el-button
  199. >
  200. <el-button type="primary" v-else @click="submitEdit('form')"
  201. >保 存</el-button
  202. >
  203. </div>
  204. </el-dialog>
  205. </div>
  206. </template>
  207. <script>
  208. import PatientSidebar from './components/PatientSidebar'
  209. import {
  210. fetchInspectionReference,
  211. CreatePatientInspection,
  212. fetchPatientInspections,
  213. EditPatientInspection,
  214. DeletePatientInspection
  215. } from '@/api/inspection'
  216. import { uParseTime, isPositiveNumber } from '@/utils/tools'
  217. export default {
  218. name: 'Inspection',
  219. components: { PatientSidebar },
  220. data() {
  221. return {
  222. total: 0,
  223. pageLoading: true,
  224. itemLoading: false,
  225. formLoading: false,
  226. itemDate: '',
  227. patientID: 0,
  228. panelClass: 'patient-app-container',
  229. patientInfo: {
  230. id: 0
  231. },
  232. itemName: '请选择项目',
  233. formTitle: '',
  234. dialogFormVisible: false,
  235. patient_info: null,
  236. form: {
  237. remind_cycle: '',
  238. method: 'add',
  239. project_id: 0,
  240. inspect_date: '',
  241. old_inspect_date: '',
  242. formItem: [{ id: 0, value: '' }]
  243. },
  244. formItem: [],
  245. items: [],
  246. inspections: [],
  247. inspectionsMap: {},
  248. projects: [],
  249. project: null,
  250. queryParams: {
  251. patient: 0,
  252. project_id: 0,
  253. page: 1
  254. },
  255. total:""
  256. }
  257. },
  258. methods: {
  259. deleteInspection() {
  260. if (this.project == null || this.itemDate == '') {
  261. this.$message.error('请先选择删除删除的记录')
  262. return false
  263. }
  264. this.$confirm('确认删除此记录?', '删除', {
  265. confirmButtonText: '确定',
  266. cancelButtonText: '取消',
  267. type: 'warning'
  268. })
  269. .then(() => {
  270. var params = {
  271. patient: this.patientID,
  272. date: this.itemDate,
  273. project_id: 14
  274. }
  275. DeletePatientInspection(params).then(response => {
  276. if (response.data.state == 0) {
  277. this.$message.error(response.data.msg)
  278. return false
  279. } else {
  280. this.$notify({
  281. title: '成功',
  282. message: '删除成功',
  283. type: 'success',
  284. duration: 2000
  285. })
  286. for (var index in this.projects) {
  287. if (this.projects[index].project_id == params.project_id) {
  288. this.projects[index].count--
  289. break
  290. }
  291. }
  292. this.total -= 1
  293. this.itemDate = ''
  294. this.items = []
  295. if (this.total > 0) {
  296. this.queryParams.page = 1
  297. this.fetchPatientInspections(this.queryParams)
  298. }
  299. }
  300. })
  301. })
  302. .catch(() => {})
  303. },
  304. openEdit() {
  305. if (this.project == null) {
  306. this.$message.error('请先选择项目')
  307. return false
  308. }
  309. this.form.method = 'edit'
  310. this.formTitle = '修改'
  311. this.form.project_id = 14
  312. this.form.inspect_date = this.itemDate
  313. this.form.old_inspect_date = this.itemDate
  314. this.form.remind_cycle = this.patient_info.remind_cycle
  315. console.log(this.form.remind_cycle)
  316. this.form.formItem = []
  317. for (var index in this.project) {
  318. this.form.formItem.push({
  319. id: this.project[index].id in this.inspectionsMap ? this.inspectionsMap[this.project[index].id].id : 0,
  320. project_id: this.project[index].project_id,
  321. project_name: this.project[index].project_name,
  322. item_id: this.project[index].id,
  323. item: this.project[index].item,
  324. item_name: this.project[index].item_name,
  325. range_type: this.project[index].range_type,
  326. value: this.project[index].id in this.inspectionsMap ? this.inspectionsMap[this.project[index].id].inspect_value : '',
  327. select_options: this.project[index].range_options.split(','),
  328. unit: this.project[index].unit
  329. })
  330. }
  331. console.log(this.form.formItem)
  332. this.dialogFormVisible = true
  333. },
  334. openNew() {
  335. if (this.project == null) {
  336. this.$message.error('请先选择项目')
  337. return false
  338. }
  339. this.form.method = 'add'
  340. this.formTitle = '新增' + this.project.project_name
  341. this.form.project_id = 14
  342. this.form.remind_cycle = this.patient_info.remind_cycle
  343. var today = new Date()
  344. this.form.inspect_date = uParseTime(today, '{y}-{m}-{d} {h}:{i}')
  345. this.form.formItem = []
  346. for(let i=0;i<this.project.length;i++){
  347. this.form.formItem.push({
  348. id:0,
  349. project_id: 14,
  350. project_name: this.project[i].project_name,
  351. item_id: this.project[i].id,
  352. item: this.project[i].item,
  353. item_name: this.project[i].item_name,
  354. range_type: this.project[i].range_type,
  355. value: '',
  356. select_options: (this.project[i].range_options).split(','),
  357. unit: this.project[i].unit
  358. })
  359. }
  360. this.dialogFormVisible = true
  361. },
  362. submitEdit(formName) {
  363. this.$refs[formName].validate(valid => {
  364. if (valid) {
  365. this.formLoading = true
  366. if (this.form.formItem.length == 0) {
  367. this.$message.error('未填写项目')
  368. return false
  369. }
  370. for (var index in this.form.formItem) {
  371. this.form.formItem[index].value = '' + this.form.formItem[index].value
  372. }
  373. EditPatientInspection(this.patientID, this.form, this.form.remind_cycle, this.form.inspect_date, this.form.project_id).then(response => {
  374. if (response.data.state == 1) {
  375. this.$notify({
  376. title: '成功',
  377. message: '修改成功',
  378. type: 'success',
  379. duration: 2000
  380. })
  381. this.patient_info.remind_cycle = response.data.data.remind_cycle
  382. this.itemDate = this.form.inspect_date
  383. this.items = []
  384. var inspections = response.data.data.inspections
  385. this.inspections = response.data.data.inspections
  386. if (inspections == null) {
  387. this.inspections = []
  388. return false
  389. }
  390. var inspectionsMap = {}
  391. this.inspectionsMap = {}
  392. for (var index in inspections) {
  393. inspectionsMap[inspections[index].item_id] =
  394. inspections[index]
  395. this.inspectionsMap[inspections[index].item_id] =
  396. inspections[index]
  397. }
  398. var items = this.project
  399. console.log("items",items)
  400. for (var index in items) {
  401. if (items[index].id in inspectionsMap) {
  402. var item = {}
  403. for (var key in items[index]) {
  404. item[key] = items[index][key]
  405. }
  406. item.value = inspectionsMap[items[index].id].inspect_value
  407. item.value_direction = ''
  408. if (item.range_type == 1) {
  409. var value = parseFloat(item.value)
  410. var range_min = parseFloat(item.range_min)
  411. var range_max = parseFloat(item.range_max)
  412. if (value < range_min) {
  413. item.value_direction = '↓'
  414. } else if (value > range_max) {
  415. item.value_direction = '↑'
  416. }
  417. }
  418. this.items.push(item)
  419. }
  420. }
  421. this.resetForm(formName)
  422. // this.total = 4
  423. // console.log("222",this.total)
  424. this.dialogFormVisible = false
  425. } else {
  426. this.$message.error(response.data.msg)
  427. return false
  428. }
  429. })
  430. .catch(v => {
  431. this.$message.error(v)
  432. return false
  433. })
  434. this.formLoading = false
  435. return false
  436. } else {
  437. return false
  438. }
  439. })
  440. },
  441. submitNew(formName) {
  442. this.$refs[formName].validate(valid => {
  443. if (valid) {
  444. this.formLoading = true
  445. if (this.form.formItem.length == 0) {
  446. this.$message.error('未填写项目')
  447. return false
  448. }
  449. for (var index in this.form.formItem) {
  450. this.form.formItem[index].value =
  451. '' + this.form.formItem[index].value
  452. }
  453. console.log("22222",this.form)
  454. console.log("33333",this.patientID)
  455. console.log("444444",this.form.remind_cycle)
  456. CreatePatientInspection(
  457. this.patientID,
  458. this.form,
  459. this.form.remind_cycle
  460. )
  461. .then(response => {
  462. if (response.data.state == 1) {
  463. this.$notify({
  464. title: '成功',
  465. message: '新增成功',
  466. type: 'success',
  467. duration: 2000
  468. })
  469. // this.form.remind_reycle = response.data.data.remind_reycc
  470. this.patient_info.remind_cycle =
  471. response.data.data.remind_cycle
  472. console.log(this.patient_info.remind_cycle)
  473. this.itemDate = this.form.inspect_date
  474. this.items = []
  475. for(let i=0;i<this.projects.length;i++){
  476. if(this.projects[i].project_id == this.form.project_id){
  477. this.projects[i].count ++
  478. break
  479. }
  480. }
  481. this.total += 1
  482. var inspections = response.data.data.inspections
  483. this.inspections = response.data.data.inspections
  484. if (inspections == null) {
  485. this.inspections = []
  486. return false
  487. }
  488. var inspectionsMap = {}
  489. this.inspectionsMap = {}
  490. for (var index in inspections) {
  491. inspectionsMap[inspections[index].item_id] =
  492. inspections[index]
  493. this.inspectionsMap[inspections[index].item_id] =
  494. inspections[index]
  495. }
  496. var items = this.project
  497. for (var index in items) {
  498. if (items[index].id in inspectionsMap) {
  499. var item = {}
  500. for (var key in items[index]) {
  501. item[key] = items[index][key]
  502. }
  503. item.value = inspectionsMap[items[index].id].inspect_value
  504. item.value_direction = ''
  505. if (item.range_type == 1) {
  506. var value = parseFloat(item.value)
  507. var range_min = parseFloat(item.range_min)
  508. var range_max = parseFloat(item.range_max)
  509. if (value < range_min) {
  510. item.value_direction = '↓'
  511. } else if (value > range_max) {
  512. item.value_direction = '↑'
  513. }
  514. }
  515. this.items.push(item)
  516. }
  517. }
  518. this.resetForm(formName)
  519. this.dialogFormVisible = false
  520. this.queryParams.patient = this.patientID
  521. this.queryParams.project_id = 14
  522. this.queryParams.page = 1
  523. this.total = 0
  524. this.fetchPatientInspections(this.queryParams)
  525. } else {
  526. this.$message.error(response.data.msg)
  527. return false
  528. }
  529. })
  530. .catch(v => {
  531. this.$message.error(v)
  532. return false
  533. })
  534. this.formLoading = false
  535. return false
  536. } else {
  537. return false
  538. }
  539. })
  540. },
  541. fetchInspectionReference() {
  542. fetchInspectionReference(this.patientID)
  543. .then(response => {
  544. if (response.data.state == 1) {
  545. // var reference = response.data.data.reference
  546. // console.log("reference22222",reference)
  547. var list = response.data.data.list
  548. console.log("list2222",list)
  549. var patient_info = response.data.data.patient_info
  550. this.projects = list
  551. this.patient_info = patient_info
  552. var project_id = 0
  553. for(let i=0;i<list.length;i++){
  554. project_id = 14
  555. this.project = list
  556. this.itemLoading = true
  557. this.items = list
  558. this.itemName =list[i].project_name
  559. }
  560. this.queryParams.patient = this.patientID
  561. this.queryParams.project_id = project_id
  562. this.queryParams.page = 1
  563. this.total = 0
  564. console.log("pras2222222",this.queryParams)
  565. this.fetchPatientInspections(this.queryParams)
  566. this.pageLoading = false
  567. this.form.remind_cycle = this.patient_info.remind_cycle
  568. } else {
  569. this.$message.error(response.data.msg)
  570. return false
  571. }
  572. })
  573. .catch(v => {})
  574. },
  575. setCurrent(row) {
  576. this.$refs.singleTable.setCurrentRow(row)
  577. },
  578. resetForm(formName) {
  579. this.$refs[formName].resetFields()
  580. },
  581. handleCurrentChangePage(val) {
  582. this.itemLoading = true
  583. this.queryParams.page = val
  584. this.fetchPatientInspections(this.queryParams)
  585. },
  586. fetchPatientInspections(params) {
  587. this.items = []
  588. fetchPatientInspections(params)
  589. .then(response => {
  590. if (response.data.state == 1) {
  591. var inspections = response.data.data.inspections
  592. console.log("inspectons",inspections)
  593. this.total = response.data.data.total
  594. this.itemDate = response.data.data.date
  595. this.inspections = response.data.data.inspections
  596. if (inspections == null) {
  597. this.inspections = []
  598. return false
  599. }
  600. var inspectionsMap = {}
  601. this.inspectionsMap = {}
  602. for (var index in inspections) {
  603. inspectionsMap[inspections[index].item_id] = inspections[index]
  604. this.inspectionsMap[inspections[index].item_id] = inspections[index]
  605. }
  606. var items = this.project
  607. console.log("items222222222",items)
  608. for (var index in items) {
  609. if (items[index].id in inspectionsMap || items[index].item_id in inspectionsMap) {
  610. var item = {}
  611. for (var key in items[index]) {
  612. item[key] = items[index][key]
  613. }
  614. if (item.item_id > 0) {
  615. if (inspectionsMap[items[index].item_id] == undefined) {
  616. item.value = inspectionsMap[items[index].id].inspect_value
  617. } else {
  618. item.value = inspectionsMap[items[index].item_id].inspect_value
  619. }
  620. } else {
  621. item.value = inspectionsMap[items[index].id].inspect_value
  622. }
  623. item.value_direction = ''
  624. if (item.range_type == 1) {
  625. var value = parseFloat(item.value)
  626. var range_min = parseFloat(item.range_min)
  627. var range_max = parseFloat(item.range_max)
  628. if (value < range_min) {
  629. item.value_direction = '↓'
  630. } else if (value > range_max) {
  631. item.value_direction = '↑'
  632. }
  633. }
  634. this.items.push(item)
  635. }
  636. }
  637. console.log(this.items)
  638. }
  639. })
  640. .catch(v => {})
  641. setTimeout(() => {
  642. this.itemLoading = false
  643. }, 1000)
  644. }
  645. },
  646. created() {
  647. const id = this.$route.params && this.$route.params.id
  648. console.log('id是设么', id)
  649. this.patientID = parseInt(id)
  650. if (isNaN(this.patientID) || this.patientID <= 0) {
  651. this.$notify.error({
  652. title: '错误',
  653. message: '无效的id'
  654. })
  655. this.$router.push('/patients/patients')
  656. }
  657. this.fetchInspectionReference()
  658. }
  659. }
  660. </script>
  661. <style>
  662. #oictable ::-webkit-scrollbar {
  663. height: 15px;
  664. }
  665. </style>
  666. <style>
  667. #user-inspection-order td {
  668. border-bottom: 0px !important;
  669. border-right: 0px !important;
  670. }
  671. #user-inspection-order th {
  672. border-right: 0px !important;
  673. }
  674. #user-inspection-form .el-form-item__content {
  675. line-height: 0 !important;
  676. }
  677. .el-table td,
  678. .el-table th.is-leaf,
  679. .el-table--border,
  680. .el-table--group {
  681. border-color: #d0d3da;
  682. }
  683. .el-table--border::after,
  684. .el-table--group::after,
  685. .el-table::before {
  686. background-color: #d0d3da;
  687. }
  688. </style>