inspection.vue 43KB

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