inspectionCheck.vue 38KB

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