inspection.vue 44KB

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