Browse Source

家庭信息列表新增修改功能开发

nanMing 1 năm trước cách đây
mục cha
commit
2e47b9d644
4 tập tin đã thay đổi với 258 bổ sung176 xóa
  1. 68 14
      api/lr.js
  2. 2 2
      common/common.js
  3. 5 6
      pages/index/index.vue
  4. 183 154
      pages/lr/index.vue

+ 68 - 14
api/lr.js

@@ -3,23 +3,28 @@ import request from '@/common/request.js'
 
 // 添加客户
 export function Save(data) {
-	return request({
-		url: '/organization/khjbxx',
-		method: 'post',
-		data: data
-	})
+  return request({
+    url: '/organization/khjbxx',
+    method: 'post',
+    data: data
+  })
 }
 
 
 // 客户列表
 export function List(data) {
-	return request({
-		url: '/organization/khjbxx/list',
-		method: 'get',
-		data: data
-	})
+  return request({
+    url: '/organization/khjbxx/list',
+    method: 'get',
+    data: data
+  })
 }
 
+/**
+ * 客户基本信息相关接口
+ * ---------------------------------------------------------------------------------------------------------------
+ */
+
 // 查询养老机构_客户_基本信息列表
 export function listKhjbxx(data) {
   return request({
@@ -64,15 +69,16 @@ export function getKhjbxx(id) {
 }
 
 /**
+ * 客户家庭成员信息相关接口
  * ---------------------------------------------------------------------------------------------------------------
-*/
+ */
 
 // 查询养老机构_客户_家庭信息列表
-export function listJtxx(query) {
+export function listJtxx(data) {
   return request({
     url: '/organization/jtxx/list',
     method: 'get',
-    params: query
+    data,
   })
 }
 
@@ -110,6 +116,54 @@ export function getJtxx(id) {
   })
 }
 
+/**
+ * 客户病患记录相关接口
+ * ---------------------------------------------------------------------------------------------------------------
+ */
+
+// 查询养老机构_客户_病患历史列表
+export function listKhbhls(data) {
+  return request({
+    url: '/organization/khbhls/list',
+    method: 'get',
+    data
+  })
+}
+
+// 新增养老机构_客户_病患历史
+export function addKhbhls(data) {
+  return request({
+    url: '/organization/khbhls',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改养老机构_客户_病患历史
+export function updateKhbhls(data) {
+  return request({
+    url: '/organization/khbhls',
+    method: 'put',
+    data: data
+  })
+}
+
+// 删除养老机构_客户_病患历史
+export function delKhbhls(id) {
+  return request({
+    url: '/organization/khbhls/' + id,
+    method: 'delete'
+  })
+}
+
+// 查询养老机构_客户_病患历史详细
+export function getKhbhls(id) {
+  return request({
+    url: '/organization/khbhls/' + id,
+    method: 'get'
+  })
+}
+
 /**
  * ---------------------------------------------------------------------------------------------------------------
-*/
+ */

+ 2 - 2
common/common.js

@@ -76,8 +76,8 @@ export function transDictLabel(datas, value) {
   }
   var actions = [];
   Object.keys(datas).some((key) => {
-    if (datas[key].dictValue == ('' + value)) {
-      actions.push(datas[key].dictLabel);
+    if (datas[key].value == ('' + value)) {
+      actions.push(datas[key].text);
       return true;
     }
   })

+ 5 - 6
pages/index/index.vue

@@ -29,9 +29,9 @@
       return {
         status: 'more',
         contentText: {
-          contentdown: '查看更多',
-          contentrefresh: '加载中',
-          contentnomore: '没有更多'
+          contentdown: '查看更多>',
+          contentrefresh: '加载中...',
+          contentnomore: '没有更多'
         },
         form: {
           pageNum: 1,
@@ -46,6 +46,7 @@
       this.getList()
     },
     onPullDownRefresh() {
+      this.form.pageNum = 1
       this.getList(true)
     },
     onLoad() {},
@@ -53,9 +54,7 @@
       getList(isClear) {
         isClear ? this.dataList = [] : ''
         listKhjbxx(this.form).then(res => {
-          let list = decryptRowData_ECB(res.rows, ['xm', 'zjhm', 'sjhm', 'jhrsjhm', 'xjd'], [1, 2,
-						3, 3, 4
-					])
+          let list = decryptRowData_ECB(res.rows, ['xm', 'zjhm', 'sjhm', 'jhrsjhm', 'xjd'], [1, 2, 3, 3, 4])
           list.forEach(item => {
             item.tx = item.tx ? config.baseUrl + item.tx : config.baseUrl + config.head;
           });

+ 183 - 154
pages/lr/index.vue

@@ -119,52 +119,34 @@
             </view>
           </view>
           <view v-else-if="active==2">
-            <button type="primary" size="mini" @click="addFamily" style="width: 160rpx;">新增</button>
-            <uni-table>
-              <uni-tr>
-                <uni-th width="100" align="center">与老人关系</uni-th>
-                <uni-th width="48" align="center">姓名</uni-th>
-                <uni-th width="48" align="center">性别</uni-th>
-                <uni-th width="100" align="center">联系电话</uni-th>
-                <uni-th width="48" align="center">设置</uni-th>
-              </uni-tr>
-              <uni-tr v-for="(item, index) in tableData" :key="index">
-                <uni-td>{{ item.jtcygx }}</uni-td>
-                <uni-td>
-                  <view>{{ item.jtcyxm }}</view>
-                </uni-td>
-                <uni-td align="center">{{ item.jtcyxb }}</uni-td>
-                <uni-td align="center">{{ item.jtcylxdh }}</uni-td>
-                <uni-td>
-                  <view class="uni-group">
-                    <button class="uni-button" size="mini" type="primary">修改</button>
-                    <button class="uni-button" size="mini" type="warn">删除</button>
-                  </view>
-                </uni-td>
-              </uni-tr>
-            </uni-table>
+            <button type="primary" size="mini" @click="editFamily"
+              style="width: 100rpx;padding: 0 5px;line-height: 2;">新增</button>
+            <uni-list>
+              <uni-list-item :title="item.jtcyxm" :note="item.jtcylxdh"
+                :rightText="transDictLabel(dicts.C0032,item.jtcygx)" v-for="(item,idx) in familyList" :key="idx"
+                showArrow clickable @click="editFamily(item)" />
+            </uni-list>
 
             <!-- 输入框示例 -->
             <uni-popup ref="inputDialog" type="dialog">
               <uni-popup-dialog ref="inputClose" mode="input" title="添加家庭成员信息" before-close="true"
-                @confirm="dialogInputConfirm" @close="cance">
+                @confirm="submitFamilyForm" @close="cance">
 
-                <uni-forms ref="familyForm" :modelValue="familyFormData" :rules="familyRules" label-align="right"
-                  padding>
+                <uni-forms ref="familyForm" :modelValue="familyForm" :rules="familyRules" label-align="right" padding>
                   <uni-forms-item label="关系" required name="jtcygx">
-                    <uni-data-select v-model="familyFormData.jtcygx" placeholder="请选择与老人关系" :localdata="dicts.C0032" />
+                    <uni-data-select v-model="familyForm.jtcygx" placeholder="请选择与老人关系" :localdata="dicts.C0032" />
                   </uni-forms-item>
                   <uni-forms-item label="姓名" required name="jtcyxm">
-                    <uni-easyinput v-model="familyFormData.jtcyxm" placeholder="请输入姓名" />
+                    <uni-easyinput v-model="familyForm.jtcyxm" placeholder="请输入姓名" />
                   </uni-forms-item>
                   <uni-forms-item label="性别" required name="jtcyxb">
-                    <uni-data-select v-model="familyFormData.jtcyxb" placeholder="请选择性别" :localdata="dicts.C0007" />
+                    <uni-data-select v-model="familyForm.jtcyxb" placeholder="请选择性别" :localdata="dicts.C0007" />
                   </uni-forms-item>
                   <uni-forms-item label="手机号" required name="jtcylxdh">
-                    <uni-easyinput v-model="familyFormData.jtcylxdh" placeholder="请输入手机号" />
+                    <uni-easyinput v-model="familyForm.jtcylxdh" placeholder="请输入手机号" />
                   </uni-forms-item>
                   <uni-forms-item label="地址" required name="jtcyjzd">
-                    <uni-easyinput v-model="familyFormData.jtcyjzd" placeholder="请输入居住地址" />
+                    <uni-easyinput v-model="familyForm.jtcyjzd" placeholder="请输入居住地址" />
                   </uni-forms-item>
                 </uni-forms>
 
@@ -175,7 +157,7 @@
           </view>
           <view v-else-if="active==3">
             <navigator url="/pages/lr/bhAdd">
-              <button type="primary" size="mini" style="width: 160rpx;">新增</button>
+              <button type="primary" size="mini" style="width: 100rpx;padding: 0 5px;line-height: 2;">新增</button>
             </navigator>
             <uni-table>
               <uni-tr>
@@ -211,7 +193,8 @@
   import amapFile from "@/libs/amap-wx.130.js";
   import config from "../../config.js";
   import { UploadOne } from '@/api/upload.js';
-  import { addKhjbxx, listJtxx, addJtxx, updateJtxx, updateKhjbxx } from '@/api/lr.js'
+  import { addKhjbxx, updateKhjbxx, listJtxx, addJtxx, updateJtxx, } from '@/api/lr.js'
+  import { decryptRowData_ECB } from '@/common/sm4.js'
   import { decimalToBinary } from '@/common/num.js'
 
   export default {
@@ -280,47 +263,6 @@
 						]
           }
         },
-        familyRules: {
-          jtcygx: {
-            rules: [{
-              required: true,
-              errorMessage: '请选择与老年人关系'
-						}]
-          },
-          jtcyxb: {
-            rules: [{
-              required: true,
-              errorMessage: '请选择性别'
-						}]
-          },
-          jtcyxm: {
-            rules: [{
-              required: true,
-              errorMessage: '请输入姓名'
-						}]
-          },
-          jtcyjzd: {
-            rules: [{
-              required: true,
-              errorMessage: '请输入地址'
-						}]
-          },
-          jtcylxdh: {
-            rules: [{
-                required: true,
-                errorMessage: '请输入手机号'
-							},
-              {
-                format: 'number',
-                errorMessage: '请输入正确的手机号',
-							},
-              {
-                pattern: '^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\\d{8})$',
-                errorMessage: '请输入正确的手机号',
-							}
-						]
-          },
-        },
         baseData: {},
         baseFormData: {
           xm: '',
@@ -572,7 +514,7 @@
             text: "痛风病史"
 					}
 				],
-        tableData: [],
+
         bhList: [],
         myAmapFunT: '',
         startPoint: {
@@ -580,25 +522,73 @@
           longitude: 125.289036
         },
 
-
         // 家庭信息列表请求参数
-        jtxxParams: {
+        familyParams: {
           pageNum: 1,
           pageSize: 10,
-        }
+          khId: null,
+        },
+        familyList: [],
+        familyForm: {
+          jtcygx: null,
+          jtcyxm: null,
+          jtcyxb: null,
+          jtcylxdh: null,
+          jtcyjzd: null,
+        },
+        familyRules: {
+          jtcygx: {
+            rules: [{
+              required: true,
+              errorMessage: '请选择与老年人关系'
+        		}]
+          },
+          jtcyxb: {
+            rules: [{
+              required: true,
+              errorMessage: '请选择性别'
+        		}]
+          },
+          jtcyxm: {
+            rules: [{
+              required: true,
+              errorMessage: '请输入姓名'
+        		}]
+          },
+          jtcyjzd: {
+            rules: [{
+              required: true,
+              errorMessage: '请输入地址'
+        		}]
+          },
+          jtcylxdh: {
+            rules: [{
+                required: true,
+                errorMessage: '请输入手机号'
+        			},
+              {
+                format: 'number',
+                errorMessage: '请输入正确的手机号',
+        			},
+              {
+                pattern: '^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\\d{8})$',
+                errorMessage: '请输入正确的手机号',
+        			}
+        		]
+          },
+        },
       }
 
     },
     created() {
       this.getDictList(Object.keys(this.dicts), this.dicts)
-      listJtxx(this.jtxxParams).then(res => {
-
-      })
     },
     onLoad(option) {
       if (Object.keys(option).length !== 0) {
         this.baseFormData = JSON.parse(option.item)
         if (this.baseFormData.xm) {
+          this.familyParams.khId = this.baseFormData.id
+          this.getFamilyList()
           uni.setNavigationBarTitle({
             title: '修改客户信息'
           });
@@ -618,16 +608,56 @@
       addbhxx() {
 
       },
-      addFamily() {
+      getFamilyList() {
+        listJtxx(this.familyParams).then(res => {
+          if (res.code !== 200) return
+          this.familyList = decryptRowData_ECB(res.rows, ['jtcyxm', 'jtcyzjhm', 'jtcylxdh', 'jtcyjzd'], [1, 2, 3,
+            4])
+        })
+      },
+      editFamily(data = {}) {
+        if (data) {
+          this.familyForm = data
+        }
         this.$refs.inputDialog.open()
       },
-      dialogInputConfirm(val) {
+      submitFamilyForm(val) {
         this.$refs['familyForm'].validate().then(() => {
-          addJtxx(this.familyFormData).then(res => {
-            console.log('success', res);
-            // 关闭窗口后,恢复默认内容
-            this.$refs.inputDialog.close()
-          })
+          const submitForm = {
+            ...this.familyForm,
+            khId: this.familyParams.khId,
+            // 接口补充数据,不添加无法提交
+            jtcyzjhm: "420101196302161908",
+            jtcyzjlx: "01"
+          };
+          if (this.familyForm.id) {
+            updateJtxx(submitForm).then(res => {
+              if (res.code !== 200) return
+              // 关闭窗口后,恢复默认内容
+              uni.showToast({
+                title: `修改成功!`,
+                duration: 2000,
+                success: (res) => {
+                  this.$refs.inputDialog.close()
+                }
+              })
+            })
+          } else {
+            addJtxx(submitForm).then(res => {
+              if (res.code !== 200) return
+              // 关闭窗口后,恢复默认内容
+              uni.showToast({
+                title: `新增成功!`,
+                duration: 2000,
+                success: (res) => {
+                  this.getFamilyList()
+                  this.$refs.inputDialog.close()
+                }
+              })
+
+            })
+          }
+
         }).catch(err => {
           console.log('err', err);
         })
@@ -642,6 +672,66 @@
         this.active = this.list.indexOf(e.tab)
         this.activeName = e.tab
       },
+      next(isSave) {
+        this.$refs['baseForm'].validate().then(res => {
+          if (isSave) {
+            this.bsFormatFrom()
+            if (this.baseFormData.id) {
+              // 修改
+              updateKhjbxx(this.baseFormData).then(r => {
+                if (r.code !== 200) return
+                uni.showToast({
+                  title: `修改成功!`,
+                  duration: 2000,
+                  success: function(res) {
+                    setTimeout(function() {
+                      uni.switchTab({
+                        url: '/pages/index/index'
+                      });
+                    }, 2000)
+                  }
+                })
+              })
+            } else {
+              // 新增
+              addKhjbxx(this.baseFormData).then(r => {
+                if (r.code !== 200) return
+                uni.showToast({
+                  title: `新增成功!`,
+                  duration: 2000,
+                  success: function(res) {
+                    setTimeout(function() {
+                      uni.switchTab({
+                        url: '/pages/index/index'
+                      });
+                    }, 2000)
+                  }
+                })
+              })
+            }
+
+          } else {
+            this.active = 1
+          }
+        }).catch(err => {
+          console.log("err", err)
+          uni.showModal({
+            title: '错误提示',
+            content: err[0].errorMessage,
+            showCancel: false,
+            success: function(res) {
+              if (res.confirm) {
+                console.log('用户点击确定');
+              } else if (res.cancel) {
+                console.log('用户点击取消');
+              }
+            }
+          });
+
+        })
+      },
+
+
       // 地图弹出
       async openChooseLocation(opt) {
         let that = this
@@ -650,11 +740,6 @@
           longitude: opt?.longitude || that.startPoint.longitude,
           success: function(res) {
             // console.log(res)
-            // console.log('位置名称:' + res.name);
-            // console.log('详细地址:' + res.address);
-            // console.log('纬度:' + res.latitude);
-            // console.log('经度:' + res.longitude);
-
             that.baseFormData.dw = res.name
             that.baseFormData.lng = res.longitude
             that.baseFormData.lat = res.latitude
@@ -710,64 +795,7 @@
         }
         return result
       },
-      next(isSave) {
-        this.$refs['baseForm'].validate().then(res => {
-          if (isSave) {
-            this.bsFormatFrom()
-            if (this.baseFormData.id) {
-              // 修改
-              updateKhjbxx(this.baseFormData).then(r => {
-                if (r.code !== 200) return
-                uni.showToast({
-                  title: `修改成功!`,
-                  duration: 2000,
-                  success: function(res) {
-                    setTimeout(function() {
-                      uni.switchTab({
-                        url: '/pages/index/index'
-                      });
-                    }, 2000)
-                  }
-                })
-              })
-            } else {
-              // 新增
-              addKhjbxx(this.baseFormData).then(r => {
-                if (r.code !== 200) return
-                uni.showToast({
-                  title: `新增成功!`,
-                  duration: 2000,
-                  success: function(res) {
-                    setTimeout(function() {
-                      uni.switchTab({
-                        url: '/pages/index/index'
-                      });
-                    }, 2000)
-                  }
-                })
-              })
-            }
-
-          } else {
-            this.active = 1
-          }
-        }).catch(err => {
-          console.log("err", err)
-          uni.showModal({
-            title: '错误提示',
-            content: err[0].errorMessage,
-            showCancel: false,
-            success: function(res) {
-              if (res.confirm) {
-                console.log('用户点击确定');
-              } else if (res.cancel) {
-                console.log('用户点击取消');
-              }
-            }
-          });
 
-        })
-      },
       bsFormatFrom() {
         this.baseFormData.tkfl = this.formatInt10(this.baseFormData.tkflData, '00000000')
         this.baseFormData.xqah = this.formatInt10(this.baseFormData.xqahData, '000000000')
@@ -869,9 +897,6 @@
   }
 </script>
 
-
-
-
 <style lang="scss" scoped>
   .line {
     border-bottom: 10px solid #f0f0f0;
@@ -905,4 +930,8 @@
       }
     }
   }
+
+  /deep/ .uni-section .uni-section-header {
+    padding: 0;
+  }
 </style>