血透系统PC前端

inspection.vue 21KB

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