血透系统PC前端

weight.vue 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <div class="patient-container">
  3. <patient-sidebar :id="patientID" defaultActive="2-3"></patient-sidebar>
  4. <div class="patient-app-container app-container ">
  5. <table-title title="干体重调整记录"></table-title>
  6. <div class="sum" :inline="true" >
  7. <span>当前时间 : <el-input style="width:180px" v-model="current_date" disabled></el-input></span>
  8. <span class="weight">干体重 : <el-input v-model="current_weight" style="width:180px;" disabled></el-input></span>
  9. <el-button class="Adjust" type="primary" icon="el-icon-refresh" size="medium" @click="dialogFormVisible = true">调整</el-button>
  10. </div>
  11. <el-table
  12. :data="weightList"
  13. border
  14. :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)'}"
  15. style="width: 100%">
  16. <el-table-column
  17. prop="date"
  18. label="日期"
  19. align="center"
  20. min-width="120">
  21. <template slot-scope="scope">
  22. <span >{{scope.row.created_time | parseTime('{y}-{m}-{d}')}}</span>
  23. </template>
  24. </el-table-column>
  25. <el-table-column
  26. prop="Adjust"
  27. label="调整值"
  28. align="center"
  29. min-width="120">
  30. <template slot-scope="scope">
  31. <span >{{calculateAdjustedValue(scope.row.adjusted_value)}}</span>
  32. </template>
  33. </el-table-column>
  34. <el-table-column
  35. prop="weight"
  36. align="center"
  37. min-width="120"
  38. label="干体重">
  39. </el-table-column>
  40. <el-table-column
  41. prop="doctor"
  42. align="center"
  43. min-width="180"
  44. label="医生">
  45. </el-table-column>
  46. <el-table-column
  47. prop="remark"
  48. align="center"
  49. min-width="180"
  50. label="备注">
  51. </el-table-column>
  52. </el-table>
  53. </div>
  54. <el-dialog title="调整干体重 " :visible.sync="dialogFormVisible" width="30%" >
  55. <el-form :model="weight_adjust" ref="weight_adjust" :rules="rules">
  56. <el-form-item label="干体重 :" :label-width="formLabelWidth" prop="weight" >
  57. <el-input v-model="weight_adjust.weight" auto-complete="off" style="width:200px;"></el-input>
  58. </el-form-item>
  59. <el-form-item label="医生 : " :label-width="formLabelWidth" prop="doctor">
  60. <el-select v-model="weight_adjust.doctor" placeholder="请选择医生" >
  61. <el-option v-for="item in doctorOptions" :label="item.name" :value="item.id" :key="item.id"></el-option>
  62. </el-select>
  63. </el-form-item>
  64. <el-form-item label="备注 : " :label-width="formLabelWidth" >
  65. <el-input
  66. type="textarea"
  67. :rows="2"
  68. style="width:280px;"
  69. placeholder="请输入内容"
  70. v-model="weight_adjust.remark">
  71. </el-input>
  72. </el-form-item>
  73. </el-form>
  74. <div slot="footer" class="dialog-footer">
  75. <el-button @click="dialogFormVisible = false">取 消</el-button>
  76. <el-button type="primary" @click="submitDryWeight('weight_adjust')">保 存</el-button>
  77. </div>
  78. </el-dialog>
  79. </div>
  80. </template>
  81. <script>
  82. import tableTitle from './components/tableTitle';
  83. import PatientSidebar from './components/PatientSidebar';
  84. import { fetchAllDoctorAndNurse } from "@/api/doctor";
  85. import {isPositiveNumber, uParseTime} from "@/utils/tools";
  86. import {createDryWeight,getDryWeights} from "@/api/patient";
  87. export default {
  88. name:'weight',
  89. data(){
  90. var checkWeight = (rule, value, callback)=>{
  91. if (!isPositiveNumber(value)) {
  92. return callback(new Error('干体重请填写大于0的数字(eg:70.5)'));
  93. }
  94. if(value.indexOf('.')>-1) {
  95. var t = value.split('.');
  96. if (t[1].length>2) {
  97. return callback(new Error('干体重小数位请保留不大于两位'));
  98. }
  99. }
  100. if (value.length>10) {
  101. return callback(new Error('干体重太大了,长度不能超过10位'));
  102. }
  103. callback();
  104. };
  105. return{
  106. total:0,
  107. patientID:0,
  108. dialogFormVisible: false,
  109. formLabelWidth: '80px',
  110. current_date:"",
  111. current_weight:"",
  112. weight_adjust:{
  113. weight:'',
  114. remark:'',
  115. doctor:''
  116. },
  117. doctorOptions:null,
  118. weightList: null,
  119. rules:{
  120. weight:[
  121. { required: true, message: "请填写干体重", trigger: "blur" },
  122. { validator: checkWeight, trigger: "blur" },
  123. ],
  124. doctor:[{ required: true, message: "请选择医生", trigger: "blur" }],
  125. },
  126. listQuery: {
  127. page: 0,
  128. limit: 0,
  129. id:0,
  130. },
  131. }
  132. },
  133. methods:{
  134. calculateAdjustedValue(value){
  135. if (value>0){
  136. return value + '(上调)';
  137. }else if (value<0) {
  138. return Math.abs(value) + '(下调)';
  139. }
  140. return value;
  141. },
  142. submitDryWeight(formName){
  143. this.$refs[formName].validate(valid=>{
  144. if(valid) {
  145. createDryWeight(this.patientID, this.weight_adjust).then(response=>{
  146. if (response.data.state == 0) {
  147. this.$message.error(response.data.msg);
  148. return false;
  149. }else{
  150. this.$notify({
  151. title: "成功",
  152. message: "新增成功",
  153. type: "success",
  154. duration: 2000
  155. });
  156. this.weightList.unshift(response.data.data.weight);
  157. if (this.weightList.length>10) {
  158. this.weightList.pop();
  159. }
  160. this.$refs[formName].resetFields();
  161. this.dialogFormVisible = false;
  162. this.current_date = uParseTime(response.data.data.weight.created_time, '{y}-{m}-{d}');
  163. this.current_weight = response.data.data.weight.weight;
  164. this.total +=1;
  165. }
  166. });
  167. }
  168. });
  169. },
  170. fetchAllDoctorAndNurse() {
  171. fetchAllDoctorAndNurse().then(response => {
  172. if (response.data.state == 1) {
  173. this.doctorOptions = response.data.data.doctors;
  174. }
  175. });
  176. },
  177. fetchAllWeights() {
  178. getDryWeights(this.listQuery).then(response => {
  179. if (response.data.state == 1) {
  180. this.weightList = response.data.data.weights;
  181. this.total = response.data.data.total;
  182. if (this.weightList.length>0) {
  183. this.current_date = uParseTime(this.weightList[0].created_time, '{y}-{m}-{d}');
  184. this.current_weight = this.weightList[0].weight;
  185. }
  186. }
  187. });
  188. },
  189. },
  190. components:{
  191. tableTitle,
  192. PatientSidebar
  193. },
  194. created(){
  195. const id = this.$route.params && this.$route.params.id;
  196. this.patientID = parseInt(id);
  197. if (isNaN(this.patientID) || this.patientID <= 0) {
  198. this.$notify.error({
  199. title: "错误",
  200. message: "无效的id"
  201. });
  202. this.$router.push('/patients/patients');
  203. }
  204. this.listQuery.id = this.patientID;
  205. this.fetchAllDoctorAndNurse();
  206. this.fetchAllWeights();
  207. },
  208. }
  209. </script>
  210. <style rel="stylesheet/css" lang="scss" scoped>
  211. .sum{
  212. .weight,
  213. .Adjust{
  214. margin: 0 0 0 4px;
  215. }
  216. }
  217. </style>