ktv.vue 38KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196
  1. <template>
  2. <div class="patient-container">
  3. <patient-sidebar :id="patientID" defaultActive="4-3"></patient-sidebar>
  4. <div
  5. class="patient-app-container app-container"
  6. v-loading="pageLoading"
  7. element-loading-text="拼命加载中"
  8. >
  9. <el-row :gutter="20">
  10. <el-col :span="7">
  11. <el-table
  12. :header-cell-style="{
  13. backgroundColor: 'rgb(245, 247, 250)',
  14. color: '#606266'
  15. }"
  16. :row-style="{ color: '#303133' }"
  17. :data="projects"
  18. border
  19. style="width: 100%"
  20. highlight-current-row
  21. @current-change="handleCurrentChange"
  22. ref="singleTable"
  23. >
  24. <el-table-column label="检查项目" align="center">
  25. <el-table-column
  26. prop="project_name"
  27. label="检查项目"
  28. align="center"
  29. >
  30. </el-table-column>
  31. <el-table-column
  32. prop="count"
  33. label="次数"
  34. width="80"
  35. align="center"
  36. >
  37. </el-table-column>
  38. </el-table-column>
  39. </el-table>
  40. </el-col>
  41. <el-col :span="17" v-loading="itemLoading">
  42. <div class="filter-container" style="float:right">
  43. <el-button
  44. size="small"
  45. class="filter-item"
  46. type="primary"
  47. @click="openNew()"
  48. icon="el-icon-circle-plus-outline"
  49. :disabled="project ? false : true"
  50. >新增
  51. </el-button
  52. >
  53. <el-button
  54. size="small"
  55. class="filter-item"
  56. type="primary"
  57. icon="el-icon-edit-outline"
  58. @click="openEdit()"
  59. :disabled="itemDate ? false : true"
  60. >修改
  61. </el-button
  62. >
  63. <el-button
  64. size="small"
  65. class="filter-item"
  66. type="danger"
  67. icon="el-icon-delete"
  68. @click="deleteInspection()"
  69. :disabled="itemDate ? false : true"
  70. >删除
  71. </el-button
  72. >
  73. </div>
  74. <div class="filter-container">
  75. <el-button class="filter-item" type="text" style="color:#000"
  76. >{{ itemName }}
  77. <span v-if="itemDate"
  78. >(检查日期:{{ itemDate }})</span
  79. ></el-button
  80. >
  81. </div>
  82. <div v-if="!isPic">
  83. <el-col :span="7">
  84. <div style="width: 400px">
  85. <el-row>
  86. <div>KT/V</div>
  87. </el-row>
  88. <el-row>
  89. <div v-if="check_content.length > 0">{{check_content}}</div>
  90. <div v-if="check_content.length == 0">{{"当前项目暂无数据"}}</div>
  91. </el-row>
  92. </div>
  93. </el-col>
  94. </div>
  95. <div v-else>
  96. <el-row>
  97. <template v-for="(item, index) in items">
  98. <el-col :span="7" :key="index">
  99. <div style="width: 400px">
  100. <el-row>
  101. <img :src="item.value" alt="">
  102. </el-row>
  103. <el-row>
  104. <div>{{item.item_name}}</div>
  105. </el-row>
  106. </div>
  107. </el-col>
  108. </template>
  109. </el-row>
  110. </div>
  111. <el-pagination
  112. align="right"
  113. @current-change="handleCurrentChangePage"
  114. :current-page="queryParams.page"
  115. :page-size="1"
  116. background
  117. style="margin-top:20px;"
  118. layout="total, prev, pager, next, jumper"
  119. :total="total"
  120. >
  121. </el-pagination>
  122. </el-col>
  123. </el-row>
  124. </div>
  125. <el-dialog
  126. :title="formTitle"
  127. :visible.sync="dialogFormVisible"
  128. width="1000px"
  129. id="user-inspection-form"
  130. v-loading="formLoading"
  131. >
  132. <el-form :model="form" ref="form" label-position="top">
  133. <el-row>
  134. <el-col :span="7">
  135. <el-form-item
  136. label="检验日期"
  137. prop="inspect_date"
  138. :rules="[
  139. { required: true, message: '请输入检验日期', trigger: 'blur' }
  140. ]"
  141. >
  142. <el-date-picker
  143. style="width:95%"
  144. v-model="form.inspect_date"
  145. type="datetime"
  146. value-format="yyyy-MM-dd HH:mm"
  147. format="yyyy-MM-dd HH:mm"
  148. placeholder="选择日期"
  149. >
  150. </el-date-picker>
  151. </el-form-item>
  152. </el-col>
  153. <el-col :span="1">&nbsp;</el-col>
  154. <template v-for="(item, index) in form.formItem">
  155. <el-col :span="7" :key="index">
  156. <el-form-item
  157. :label="item.item_name"
  158. :key="item.item_id"
  159. :rules="item.item_name != 'URR(%)' || item.item_name != 'KT/V' ?[
  160. { required: true, message: '请输入数值', trigger: 'blur' }
  161. ]:[]"
  162. :prop="'formItem.' + index + '.value'"
  163. >
  164. <el-input
  165. placeholder="请填入"
  166. v-model="item.value"
  167. style="width:95%"
  168. type="number"
  169. :disabled="item.item_name == 'URR(%)' || item.item_name == 'KT/V'"
  170. @input='changeInput(item)'
  171. >
  172. <template slot="append" v-if="item.item_name == 'URR(%)'"><el-button style="background-color: #409eff; color: #000;" type="primary" @click="calURR(form.formItem,item.value)">点击计算URR</el-button></template>
  173. <template slot="append" v-if="item.item_name == 'KT/V'"><el-button style="background-color: #409eff; color: #000;" type="primary" @click="calKTV(form.formItem,item.value)">点击计算KT/V</el-button></template>
  174. <template slot="append" v-else>{{ item.unit }}</template>
  175. </el-input>
  176. </el-form-item>
  177. </el-col>
  178. <el-col :span="1" :key="'form-col' + index">&nbsp;</el-col>
  179. </template>
  180. </el-row>
  181. </el-form>
  182. <div slot="footer" class="dialog-footer">
  183. <el-button @click="dialogFormVisible = false">取 消</el-button>
  184. <el-button
  185. type="primary"
  186. v-if="form.method == 'add'"
  187. @click="submitNew('form')"
  188. >保 存
  189. </el-button
  190. >
  191. <el-button type="primary" v-else @click="submitEdit('form')"
  192. >保 存
  193. </el-button
  194. >
  195. </div>
  196. </el-dialog>
  197. <el-dialog
  198. :title="formTitle"
  199. :visible.sync="dialogPicFormVisible"
  200. width="1000px"
  201. id="user-inspection-form"
  202. >
  203. <el-form :model="form" ref="form" label-position="top">
  204. <el-row>
  205. <el-col :span="7">
  206. <el-form-item
  207. label="检验日期"
  208. prop="inspect_date"
  209. :rules="[
  210. { required: true, message: '请输入检验日期', trigger: 'blur' }
  211. ]"
  212. >
  213. <el-date-picker
  214. style="width:95%"
  215. v-model="form.inspect_date"
  216. type="datetime"
  217. value-format="yyyy-MM-dd HH:mm"
  218. format="yyyy-MM-dd HH:mm"
  219. placeholder="选择日期"
  220. >
  221. </el-date-picker>
  222. </el-form-item>
  223. </el-col>
  224. </el-row>
  225. <el-row>
  226. <template v-for="(item, index) in form.imgs">
  227. <el-col :span="5" :key="index">
  228. <div>
  229. <el-row>
  230. <img width="100px" :src="item.img_url" alt="">
  231. </el-row>
  232. <el-row>
  233. <el-input v-model="item.desc" style="width: 100px"></el-input>
  234. </el-row>
  235. <el-row>
  236. <el-button
  237. type="danger"
  238. @click="deletePic(item,index)"
  239. >删除
  240. </el-button>
  241. </el-row>
  242. </div>
  243. </el-col>
  244. <el-col :span="1" :key="'form-col' + index">&nbsp;</el-col>
  245. </template>
  246. </el-row>
  247. </el-form>
  248. <div slot="footer" class="dialog-footer">
  249. <el-upload
  250. :data="uploadData"
  251. :multiple="false"
  252. action="https://upload.qiniup.com"
  253. :show-file-list="false"
  254. :on-error="handleAvatarError"
  255. :on-success="handleAvatarSuccess"
  256. :before-upload="beforeAvatarUpload">
  257. <el-button type="primary">选择文件</el-button>
  258. </el-upload>
  259. <el-button @click="dialogPicFormVisible = false">取 消</el-button>
  260. <el-button
  261. type="primary"
  262. v-if="this.form.pic_method== 'add'"
  263. @click="submitPicNew()"
  264. >保 存
  265. </el-button>
  266. <el-button
  267. type="primary"
  268. v-if="this.form.pic_method == 'edit'"
  269. @click="submitEditPicNew()"
  270. >修 改
  271. </el-button>
  272. </div>
  273. </el-dialog>
  274. </div>
  275. </template>
  276. <script>
  277. import PatientSidebar from './components/PatientSidebar'
  278. import { getToken } from '@/api/qiniu'
  279. import {
  280. CreatePatientInspection,
  281. CreatePatientPICInspection,
  282. editPatientPICInspection,
  283. DeletePatientInspection,
  284. EditPatientInspection,
  285. fetchInspectionReference,
  286. fetchPatientInspections
  287. } from '@/api/inspection'
  288. import { getFileExtension, uParseTime } from '@/utils/tools'
  289. export default {
  290. name: 'Inspection',
  291. components: { PatientSidebar },
  292. data() {
  293. return {
  294. total: 0,
  295. check_content:"",
  296. qiniuDomain: 'https://images.shengws.com/',
  297. isPic:false,
  298. uploadData: { token: '', key: '' },
  299. pageLoading: true,
  300. itemLoading: false,
  301. formLoading: false,
  302. itemDate: '',
  303. patientID: 0,
  304. panelClass: 'patient-app-container',
  305. patientInfo: {
  306. id: 0
  307. },
  308. itemName: '请选择项目',
  309. formTitle: '',
  310. dialogPicFormVisible: false,
  311. dialogFormVisible: false,
  312. patient_info: null,
  313. form: {
  314. remind_cycle: '',
  315. method: 'add',
  316. pic_method:'add',
  317. project_id: 0,
  318. inspect_date: '',
  319. old_inspect_date: '',
  320. formItem: [{ id: 0, value: '' }],
  321. imgs: [],
  322. delete_imgs:[],
  323. },
  324. formItem: [],
  325. items: [],
  326. inspections: [],
  327. inspectionsMap: {},
  328. projects: [],
  329. project: null,
  330. queryParams: {
  331. patient: 0,
  332. project_id: 0,
  333. page: 1
  334. }
  335. }
  336. },
  337. methods: {
  338. beforeAvatarUpload(file) {
  339. // const isJPG = file.type === "image/jpeg";
  340. var fileType = file.type
  341. const isJPG = fileType.indexOf('image') > -1
  342. const isLt2M = file.size / 1024 / 1024 < 5
  343. if (!isJPG) {
  344. this.$message.error('只能上传图片')
  345. return false
  346. }
  347. if (!isLt2M) {
  348. this.$message.error('上传头像图片大小不能超过 5MB!')
  349. return false
  350. }
  351. var date = new Date()
  352. var ext = getFileExtension(file.name)
  353. var key =
  354. date.getFullYear() +
  355. '/' +
  356. (date.getMonth() + 1) +
  357. '/' +
  358. date.getDate() +
  359. '/' +
  360. date.getHours() +
  361. '/' +
  362. date.getMinutes() +
  363. '/' +
  364. date.getSeconds() +
  365. '/' +
  366. '_s_' +
  367. file.uid +
  368. '.' +
  369. ext
  370. this.loading = this.$loading({
  371. lock: true,
  372. text: '上传中...',
  373. spinner: 'el-icon-loading',
  374. background: 'rgba(0, 0, 0, 0.7)'
  375. })
  376. const _self = this
  377. return new Promise((resolve, reject) => {
  378. getToken()
  379. .then(response => {
  380. const token = response.data.data.uptoken
  381. _self._data.uploadData.token = token
  382. _self._data.uploadData.key = key
  383. resolve(true)
  384. })
  385. .catch(err => {
  386. console.log(err)
  387. reject(false)
  388. this.loading.close()
  389. })
  390. })
  391. },
  392. handleAvatarError(err, file, fileList) {
  393. this.$message.error(err)
  394. this.loading.close()
  395. return false
  396. },
  397. handleAvatarSuccess(res, file) {
  398. this.form.imgs.push({
  399. img_url: this.qiniuDomain + res.url + '?imageView2/2/w/500/h/500/q/90',
  400. desc: '',
  401. id: 0
  402. })
  403. this.loading.close()
  404. },
  405. changeInput(item) {
  406. if (item.item_name == '血清铁' || item.item_name == '总铁结合力') {
  407. let index1 = ''
  408. let index2 = ''
  409. this.form.formItem.map((it, index) => {
  410. if (this.form.formItem[index].item_name == '血清铁') {
  411. index1 = index
  412. }
  413. if (this.form.formItem[index].item_name == '总铁结合力') {
  414. index2 = index
  415. }
  416. if (it.item_name == '转铁蛋白饱和度(计算)') {
  417. it.value = (parseFloat(this.form.formItem[index1].value) / parseFloat(this.form.formItem[index2].value)) * 100
  418. }
  419. })
  420. }
  421. },
  422. deleteInspection() {
  423. if (this.project == null || this.itemDate == '') {
  424. this.$message.error('请先选择删除删除的记录')
  425. return false
  426. }
  427. this.$confirm('确认删除此记录?', '删除', {
  428. confirmButtonText: '确定',
  429. cancelButtonText: '取消',
  430. type: 'warning'
  431. })
  432. .then(() => {
  433. var params = {
  434. patient: this.patientID,
  435. date: this.itemDate,
  436. project_id: this.project.project_id
  437. }
  438. DeletePatientInspection(params).then(response => {
  439. if (response.data.state == 0) {
  440. this.$message.error(response.data.msg)
  441. return false
  442. } else {
  443. this.$notify({
  444. title: '成功',
  445. message: '删除成功',
  446. type: 'success',
  447. duration: 2000
  448. })
  449. for (var index in this.projects) {
  450. if (this.projects[index].project_id == params.project_id) {
  451. this.projects[index].count--
  452. break
  453. }
  454. }
  455. this.total -= 1
  456. this.itemDate = ''
  457. this.items = []
  458. if (this.total > 0) {
  459. this.queryParams.page = 1
  460. this.fetchPatientInspections(this.queryParams)
  461. }
  462. }
  463. })
  464. })
  465. .catch(() => {
  466. })
  467. },
  468. openEdit() {
  469. if (this.project == null) {
  470. this.$message.error('请先选择项目')
  471. return false
  472. }
  473. if(this.isPic){
  474. this.form.pic_method = 'edit'
  475. this.formTitle = '修改' + this.project.project_name
  476. this.form.project_id = this.project.project_id
  477. this.form.inspect_date = this.itemDate
  478. this.form.old_inspect_date = this.itemDate
  479. this.form.imgs = []
  480. this.form.delete_imgs = []
  481. for(var index in this.inspections){
  482. this.form.imgs.push({
  483. id: this.inspections[index].id,
  484. img_url: this.inspections[index].inspect_value,
  485. desc: this.inspections[index].item_name
  486. })
  487. }
  488. console.log(this.form.imgs)
  489. this.dialogPicFormVisible = true
  490. }else{
  491. console.log("22222")
  492. this.form.method = 'edit'
  493. this.formTitle = '修改' + this.project.project_name
  494. this.form.project_id = this.project.project_id
  495. this.form.inspect_date = this.itemDate
  496. this.form.old_inspect_date = this.itemDate
  497. this.form.remind_cycle = this.patient_info.remind_cycle
  498. console.log(this.form.remind_cycle)
  499. this.form.formItem = []
  500. for (var index in this.project.inspection_reference) {
  501. this.form.formItem.push({
  502. id: this.project.inspection_reference[index].id in this.inspectionsMap ? this.inspectionsMap[this.project.inspection_reference[index].id].id : 0,
  503. project_id: this.project.inspection_reference[index].project_id,
  504. project_name: this.project.inspection_reference[index].project_name,
  505. item_id: this.project.inspection_reference[index].id,
  506. item: this.project.inspection_reference[index].item,
  507. item_name: this.project.inspection_reference[index].item_name,
  508. range_type: this.project.inspection_reference[index].range_type,
  509. value: this.project.inspection_reference[index].id in this.inspectionsMap ? this.inspectionsMap[this.project.inspection_reference[index].id].inspect_value : '',
  510. select_options: this.project.inspection_reference[index].range_options.split(','),
  511. unit: this.project.inspection_reference[index].unit
  512. })
  513. }
  514. console.log(this.form.formItem)
  515. this.dialogFormVisible = true
  516. }
  517. }, openPic() {
  518. if (this.project == null) {
  519. this.$message.error('请先选择项目')
  520. return false
  521. }
  522. this.form.pic_method = 'add'
  523. this.formTitle = '新增' + this.project.project_name
  524. this.form.project_id = this.project.project_id
  525. this.form.imgs=[]
  526. this.form.delete_imgs=[]
  527. this.form.remind_cycle = this.patient_info.remind_cycle
  528. var today = new Date()
  529. this.form.inspect_date = uParseTime(today, '{y}-{m}-{d} {h}:{i}')
  530. this.form.formItem = []
  531. for (var index in this.project.inspection_reference) {
  532. // var formItem = this.project.inspection_reference[index];
  533. // formItem["value"] = '';
  534. // if (formItem.range_type==2) {
  535. // formItem["select_options"] = formItem.range_options.split(",");
  536. // }
  537. this.form.formItem.push({
  538. id: 0,
  539. project_id: this.project.inspection_reference[index].project_id,
  540. project_name: this.project.inspection_reference[index].project_name,
  541. item_id: this.project.inspection_reference[index].id,
  542. item: this.project.inspection_reference[index].item,
  543. item_name: this.project.inspection_reference[index].item_name,
  544. range_type: this.project.inspection_reference[index].range_type,
  545. value: '',
  546. select_options: this.project.inspection_reference[
  547. index
  548. ].range_options.split(','),
  549. unit: this.project.inspection_reference[index].unit
  550. })
  551. }
  552. console.log('form.formItem', this.form.formItem)
  553. this.dialogPicFormVisible = true
  554. },
  555. openNew() {
  556. if (this.project == null) {
  557. this.$message.error('请先选择项目')
  558. return false
  559. }
  560. this.form.method = 'add'
  561. this.formTitle = '新增' + this.project.project_name
  562. this.form.project_id = this.project.project_id
  563. this.form.remind_cycle = this.patient_info.remind_cycle
  564. var today = new Date()
  565. this.form.inspect_date = uParseTime(today, '{y}-{m}-{d} {h}:{i}')
  566. this.form.formItem = []
  567. for (var index in this.project.inspection_reference) {
  568. // var formItem = this.project.inspection_reference[index];
  569. // formItem["value"] = '';
  570. // if (formItem.range_type==2) {
  571. // formItem["select_options"] = formItem.range_options.split(",");
  572. // }
  573. this.form.formItem.push({
  574. id: 0,
  575. project_id: this.project.inspection_reference[index].project_id,
  576. project_name: this.project.inspection_reference[index].project_name,
  577. item_id: this.project.inspection_reference[index].id,
  578. item: this.project.inspection_reference[index].item,
  579. item_name: this.project.inspection_reference[index].item_name,
  580. range_type: this.project.inspection_reference[index].range_type,
  581. value: '',
  582. select_options: this.project.inspection_reference[
  583. index
  584. ].range_options.split(','),
  585. unit: this.project.inspection_reference[index].unit
  586. })
  587. }
  588. console.log('form.formItem', this.form.formItem)
  589. this.dialogFormVisible = true
  590. },
  591. calURR(items, value){
  592. let valueOne = 0
  593. let valueTwo = 0
  594. for(let i = 0; i < items.length; i++){
  595. if(items[i].item_name == "透析前尿素氮"){
  596. valueOne = items[i].value
  597. }
  598. if(items[i].item_name == "透析后尿素氮"){
  599. valueTwo = items[i].value
  600. }
  601. }
  602. if(valueOne.length == 0){
  603. this.$message.error("透析前尿素氮不能为空")
  604. return
  605. }
  606. if(valueTwo.length == 0){
  607. this.$message.error("透析后尿素氮不能为空")
  608. return
  609. }
  610. value = (((valueOne - valueTwo) / valueOne) * 100).toFixed(2)
  611. for(let i = 0; i < items.length; i++){
  612. if(items[i].item_name == "URR(%)"){
  613. items[i].value = value
  614. }
  615. }
  616. },
  617. calKTV(items, value){
  618. let valueOne = 0
  619. let valueTwo = 0
  620. let valueThree = 0
  621. let valueFour = 0
  622. let valueSix = 0
  623. for(let i = 0; i < items.length; i++){
  624. if(items[i].item_name == "透析前尿素氮"){
  625. valueOne = items[i].value
  626. }
  627. if(items[i].item_name == "透析后尿素氮"){
  628. valueTwo = items[i].value
  629. }
  630. if(items[i].item_name == "透析时间"){
  631. valueThree = items[i].value
  632. }
  633. if(items[i].item_name == "实际超滤量"){
  634. valueFour = items[i].value
  635. }
  636. if(items[i].item_name == "透后体重"){
  637. valueSix = items[i].value
  638. }
  639. }
  640. if(valueOne.length == 0){
  641. this.$message.error("透析前尿素氮不能为空")
  642. return
  643. }
  644. if(valueTwo.length == 0){
  645. this.$message.error("透析后尿素氮不能为空")
  646. return
  647. }
  648. if(valueThree.length == 0){
  649. this.$message.error("透析时间不能为空")
  650. return
  651. }
  652. if(valueFour.length == 0){
  653. this.$message.error("实际超滤量不能为空")
  654. return
  655. }
  656. if(valueSix.length == 0){
  657. this.$message.error("透后体重不能为空")
  658. return
  659. }
  660. console.log((-Math.log((valueTwo / valueOne - (0.008 * valueThree)))) )
  661. console.log((4-3.5*(valueTwo/valueOne)))
  662. console.log((4-3.5*(valueTwo/valueOne)) * valueFour/valueSix)
  663. value = ((-Math.log((valueTwo / valueOne - (0.008 * valueThree)))) + (4-3.5*(valueTwo/valueOne)) * valueFour/valueSix).toFixed(5)
  664. for(let i = 0; i < items.length; i++){
  665. if(items[i].item_name == "KT/V"){
  666. items[i].value = value
  667. }
  668. }
  669. },
  670. submitEdit(formName) {
  671. this.$refs[formName].validate(valid => {
  672. if (valid) {
  673. this.formLoading = true
  674. if (this.form.formItem.length == 0) {
  675. this.$message.error('未填写项目')
  676. return false
  677. }
  678. for (var index in this.form.formItem) {
  679. this.form.formItem[index].value = '' + this.form.formItem[index].value
  680. }
  681. EditPatientInspection(this.patientID, this.form, this.form.remind_cycle, this.form.inspect_date, this.form.project_id).then(response => {
  682. if (response.data.state == 1) {
  683. this.$notify({
  684. title: '成功',
  685. message: '修改成功',
  686. type: 'success',
  687. duration: 2000
  688. })
  689. this.patient_info.remind_cycle =
  690. response.data.data.remind_cycle
  691. this.itemDate = this.form.inspect_date
  692. this.items = []
  693. var inspections = response.data.data.inspections
  694. this.inspections = response.data.data.inspections
  695. if (inspections == null) {
  696. this.inspections = []
  697. return false
  698. }
  699. var inspectionsMap = {}
  700. this.inspectionsMap = {}
  701. for (var index in inspections) {
  702. inspectionsMap[inspections[index].item_id] =
  703. inspections[index]
  704. this.inspectionsMap[inspections[index].item_id] =
  705. inspections[index]
  706. }
  707. var items = this.project.inspection_reference
  708. console.log('itmes', items)
  709. for (var index in items) {
  710. if (items[index].id in inspectionsMap) {
  711. var item = {}
  712. for (var key in items[index]) {
  713. item[key] = items[index][key]
  714. }
  715. item.value = inspectionsMap[items[index].id].inspect_value
  716. item.value_direction = ''
  717. if (item.range_type == 1) {
  718. var value = parseFloat(item.value)
  719. var range_min = parseFloat(item.range_min)
  720. var range_max = parseFloat(item.range_max)
  721. if (value < range_min) {
  722. item.value_direction = '↓'
  723. } else if (value > range_max) {
  724. item.value_direction = '↑'
  725. }
  726. }
  727. this.items.push(item)
  728. }
  729. }
  730. this.resetForm(formName)
  731. this.dialogFormVisible = false
  732. } else {
  733. this.$message.error(response.data.msg)
  734. return false
  735. }
  736. })
  737. .catch(v => {
  738. this.$message.error(v)
  739. return false
  740. })
  741. this.formLoading = false
  742. return false
  743. } else {
  744. return false
  745. }
  746. })
  747. },
  748. submitNew(formName) {
  749. let valueSix = 0
  750. for(let i = 0; i < this.items.length; i++){
  751. if(this.items[i].item_name == "KT/V"){
  752. valueSix = this.items[i].value
  753. }
  754. }
  755. if(valueSix.length == 0){
  756. this.$message.error("KT/V不能为空")
  757. return
  758. }
  759. this.$refs[formName].validate(valid => {
  760. if (valid) {
  761. this.formLoading = true
  762. if (this.form.formItem.length == 0) {
  763. this.$message.error('未填写项目')
  764. return false
  765. }
  766. for (var index in this.form.formItem) {
  767. this.form.formItem[index].value =
  768. '' + this.form.formItem[index].value
  769. }
  770. CreatePatientInspection(
  771. this.patientID,
  772. this.form,
  773. this.form.remind_cycle
  774. )
  775. .then(response => {
  776. if (response.data.state == 1) {
  777. this.$notify({
  778. title: '成功',
  779. message: '新增成功',
  780. type: 'success',
  781. duration: 2000
  782. })
  783. // this.form.remind_reycle = response.data.data.remind_reycc
  784. this.patient_info.remind_cycle =
  785. response.data.data.remind_cycle
  786. console.log(this.patient_info.remind_cycle)
  787. this.itemDate = this.form.inspect_date
  788. this.items = []
  789. for (var index in this.projects) {
  790. if (this.projects[index].project_id == this.form.project_id) {
  791. this.projects[index].count++
  792. break
  793. }
  794. }
  795. this.total += 1
  796. var inspections = response.data.data.inspections
  797. this.inspections = response.data.data.inspections
  798. if (inspections == null) {
  799. this.inspections = []
  800. return false
  801. }
  802. var inspectionsMap = {}
  803. this.inspectionsMap = {}
  804. for (var index in inspections) {
  805. inspectionsMap[inspections[index].item_id] =
  806. inspections[index]
  807. this.inspectionsMap[inspections[index].item_id] =
  808. inspections[index]
  809. }
  810. var items = this.project.inspection_reference
  811. for (var index in items) {
  812. if (items[index].id in inspectionsMap) {
  813. var item = {}
  814. for (var key in items[index]) {
  815. item[key] = items[index][key]
  816. }
  817. item.value = inspectionsMap[items[index].id].inspect_value
  818. item.value_direction = ''
  819. if (item.range_type == 1) {
  820. var value = parseFloat(item.value)
  821. var range_min = parseFloat(item.range_min)
  822. var range_max = parseFloat(item.range_max)
  823. if (value < range_min) {
  824. item.value_direction = '↓'
  825. } else if (value > range_max) {
  826. item.value_direction = '↑'
  827. }
  828. }
  829. this.items.push(item)
  830. }
  831. }
  832. this.resetForm(formName)
  833. this.dialogFormVisible = false
  834. this.queryParams.patient = this.patientID
  835. this.queryParams.project_id = this.project.project_id
  836. this.queryParams.page = 1
  837. this.total = 0
  838. this.fetchPatientInspections(this.queryParams)
  839. } else {
  840. this.$message.error(response.data.msg)
  841. return false
  842. }
  843. })
  844. .catch(v => {
  845. this.$message.error(v)
  846. return false
  847. })
  848. this.formLoading = false
  849. return false
  850. } else {
  851. return false
  852. }
  853. })
  854. }, submitEditPicNew() {
  855. if (this.form.imgs.length == 0) {
  856. this.$message.error('未上传图片')
  857. return false
  858. }
  859. this.formLoading = true
  860. editPatientPICInspection(
  861. this.patientID,
  862. this.form
  863. )
  864. .then(response => {
  865. if (response.data.state === 1) {
  866. this.$notify({
  867. title: '成功',
  868. message: '修改成功',
  869. type: 'success',
  870. duration: 2000
  871. })
  872. this.itemDate = this.form.inspect_date
  873. this.items = []
  874. this.dialogPicFormVisible = false
  875. this.queryParams.patient = this.patientID
  876. this.queryParams.project_id = this.project.project_id
  877. this.queryParams.page = 1
  878. this.total = 0
  879. this.fetchPatientInspections(this.queryParams)
  880. } else {
  881. this.$message.error(response.data.msg)
  882. return false
  883. }
  884. })
  885. .catch(v => {
  886. this.$message.error(v)
  887. return false
  888. })
  889. this.formLoading = false
  890. },deletePic(item,index){
  891. if(item.id == 0){
  892. this.form.imgs.splice(index,1)
  893. }else{
  894. for(let index in this.form.imgs){
  895. if(item.id == this.form.imgs[index].id){
  896. this.form.imgs.splice(index,1)
  897. this.form.delete_imgs.push({
  898. id:item.id,
  899. })
  900. }
  901. }
  902. }
  903. },
  904. submitPicNew() {
  905. this.formLoading = true
  906. if (this.form.imgs.length == 0) {
  907. this.$message.error('未上传图片')
  908. return false
  909. }
  910. CreatePatientPICInspection(
  911. this.patientID,
  912. this.form
  913. )
  914. .then(response => {
  915. if (response.data.state === 1) {
  916. this.$notify({
  917. title: '成功',
  918. message: '新增成功',
  919. type: 'success',
  920. duration: 2000
  921. })
  922. this.itemDate = this.form.inspect_date
  923. this.items = []
  924. for (var index in this.projects) {
  925. if (this.projects[index].project_id == this.form.project_id) {
  926. this.projects[index].count++
  927. break
  928. }
  929. }
  930. this.total += 1
  931. // var inspections = response.data.data.inspections
  932. // this.inspections = response.data.data.inspections
  933. // if (inspections == null) {
  934. // this.inspections = []
  935. // return false
  936. // }
  937. // var inspectionsMap = {}
  938. // this.inspectionsMap = {}
  939. //
  940. // var items = this.project.inspection_reference
  941. // for (var index in items) {
  942. // if (items[index].id in inspectionsMap) {
  943. // var item = {}
  944. // for (var key in items[index]) {
  945. // item[key] = items[index][key]
  946. // }
  947. // item.value = inspectionsMap[items[index].id].inspect_value
  948. // item.value_direction = ''
  949. // this.items.push(item)
  950. // }
  951. // }
  952. this.dialogPicFormVisible = false
  953. this.queryParams.patient = this.patientID
  954. this.queryParams.project_id = this.project.project_id
  955. this.queryParams.page = 1
  956. this.total = 0
  957. this.fetchPatientInspections(this.queryParams)
  958. } else {
  959. this.$message.error(response.data.msg)
  960. return false
  961. }
  962. })
  963. .catch(v => {
  964. this.$message.error(v)
  965. return false
  966. })
  967. this.formLoading = false
  968. },
  969. fetchInspectionReference() {
  970. fetchInspectionReference(this.patientID,3)
  971. .then(response => {
  972. if (response.data.state == 1) {
  973. var reference = response.data.data.reference
  974. var patient_info = response.data.data.patient_info
  975. this.projects = reference
  976. this.patient_info = patient_info
  977. this.pageLoading = false
  978. this.form.remind_cycle = this.patient_info.remind_cycle
  979. } else {
  980. this.$message.error(response.data.msg)
  981. return false
  982. }
  983. })
  984. .catch(v => {
  985. })
  986. },
  987. setCurrent(row) {
  988. this.$refs.singleTable.setCurrentRow(row)
  989. },
  990. resetForm(formName) {
  991. this.$refs[formName].resetFields()
  992. },
  993. handleCurrentChange(row) {
  994. this.itemDate = ''
  995. this.form.method = 'add'
  996. if (typeof row === 'undefined' || row == null) {
  997. this.project = null
  998. this.items = []
  999. this.itemName = '请选择项目'
  1000. } else {
  1001. this.itemLoading = true
  1002. this.project = row
  1003. this.items = row.inspection_reference
  1004. this.itemName = row.project_name
  1005. this.queryParams.patient = this.patientID
  1006. this.queryParams.project_id = this.project.project_id
  1007. this.queryParams.page = 1
  1008. this.total = 0
  1009. this.fetchPatientInspections(this.queryParams)
  1010. }
  1011. },
  1012. handleCurrentChangePage(val) {
  1013. this.itemLoading = true
  1014. this.queryParams.page = val
  1015. this.fetchPatientInspections(this.queryParams)
  1016. },
  1017. fetchPatientInspections(params) {
  1018. this.items = []
  1019. this.isPic = false
  1020. this.check_content = ""
  1021. fetchPatientInspections(params)
  1022. .then(response => {
  1023. if (response.data.state == 1) {
  1024. var inspections = response.data.data.inspections
  1025. this.total = response.data.data.total
  1026. this.itemDate = response.data.data.date
  1027. this.inspections = response.data.data.inspections
  1028. if (inspections == null) {
  1029. this.inspections = []
  1030. return false
  1031. }
  1032. var inspectionsMap = {}
  1033. this.inspectionsMap = {}
  1034. for (var index in inspections) {
  1035. inspectionsMap[inspections[index].item_id] = inspections[index]
  1036. this.inspectionsMap[inspections[index].item_id] = inspections[index]
  1037. }
  1038. var items = this.project.inspection_reference
  1039. for (var index in items) {
  1040. var item = {}
  1041. for (var key in items[index]) {
  1042. item[key] = items[index][key]
  1043. }
  1044. if (item.item_id > 0) {
  1045. if (inspectionsMap[items[index].item_id] == undefined) {
  1046. item.value = inspectionsMap[items[index].id].inspect_value
  1047. item.item_name = inspectionsMap[items[index].id].item_name
  1048. } else {
  1049. item.value = inspectionsMap[items[index].item_id].inspect_value
  1050. item.item_name = inspectionsMap[items[index].item_id].item_name
  1051. }
  1052. } else {
  1053. item.value = inspectionsMap[items[index].id].inspect_value
  1054. item.item_name = inspectionsMap[items[index].id].item_name
  1055. }
  1056. // item["inspect_desc"] = inspectionsMap[items[index].id].inspect_desc
  1057. // item["inspect_type"] = inspectionsMap[items[index].id].inspect_type
  1058. item.value_direction = ''
  1059. if (item.range_type == 1) {
  1060. var value = parseFloat(item.value)
  1061. var range_min = parseFloat(item.range_min)
  1062. var range_max = parseFloat(item.range_max)
  1063. if (value < range_min) {
  1064. item.value_direction = '↓'
  1065. } else if (value > range_max) {
  1066. item.value_direction = '↑'
  1067. }
  1068. }
  1069. this.items.push(item)
  1070. if(item.value.indexOf("http") >= 0){
  1071. this.isPic = true
  1072. }
  1073. }
  1074. for(let i = 0;i < this.items.length; i++){
  1075. this.check_content = this.check_content + "\n" + this.items[i].item_name+":"+this.items[i].value +this.items[i].unit +"\n"
  1076. }
  1077. }
  1078. })
  1079. .catch(v => {
  1080. })
  1081. setTimeout(() => {
  1082. this.itemLoading = false
  1083. }, 1000)
  1084. }
  1085. },
  1086. created() {
  1087. const id = this.$route.query && this.$route.query.id
  1088. this.patientID = parseInt(id)
  1089. if (isNaN(this.patientID) || this.patientID <= 0) {
  1090. this.$notify.error({
  1091. title: '错误',
  1092. message: '无效的id'
  1093. })
  1094. this.$router.push('/patients/patients')
  1095. }
  1096. this.fetchInspectionReference()
  1097. }
  1098. }
  1099. </script>
  1100. <style>
  1101. #oictable ::-webkit-scrollbar {
  1102. height: 15px;
  1103. }
  1104. </style>
  1105. <style>
  1106. #user-inspection-order td {
  1107. border-bottom: 0px !important;
  1108. border-right: 0px !important;
  1109. }
  1110. #user-inspection-order th {
  1111. border-right: 0px !important;
  1112. }
  1113. #user-inspection-form .el-form-item__content {
  1114. line-height: 0 !important;
  1115. }
  1116. .el-table td,
  1117. .el-table th.is-leaf,
  1118. .el-table--border,
  1119. .el-table--group {
  1120. border-color: #d0d3da;
  1121. }
  1122. .el-table--border::after,
  1123. .el-table--group::after,
  1124. .el-table::before {
  1125. background-color: #d0d3da;
  1126. }
  1127. </style>