zhaoxiaohai 2 роки тому
батько
коміт
6a959d7d7d

+ 50 - 12
packageA/setclient/modules/financing/add/index.js

@@ -65,10 +65,14 @@ Page({
         "content": {
             "sys_enterprise_financeid": 0,
             "remarks": "",
-            "isdefault": 0
+            "isdefault": 0,
+            sys_enterpriseid: 0
         },
     },
     onLoad(options) {
+        if (options.sys_enterpriseid) this.setData({
+            "content.sys_enterpriseid": options.sys_enterpriseid
+        });
         if (options.data) {
             let item = JSON.parse(options.data)
             this.setData({
@@ -77,11 +81,12 @@ Page({
                     return v
                 }),
                 "content.sys_enterprise_financeid": item.sys_enterprise_financeid,
+                "content.sys_enterpriseid": item.sys_enterpriseid,
                 "content.remarks": item.remarks,
                 "content.isdefault": item.isdefault,
                 disabled: false
             })
-        }
+        };
     },
     /* 提交数据 */
     submit() {
@@ -91,10 +96,6 @@ Page({
             ...this.data.content,
             ...data
         };
-
-        let fast = getCurrentPages().find(v => v.__route__ == 'packageA/setclient/detail');
-        content.sys_enterpriseid = fast.data.detail.sys_enterpriseid;
-
         _Http.basic({
             "id": "20221013160402",
             content
@@ -109,12 +110,49 @@ Page({
                 icon: "none"
             });
             setTimeout(() => {
-                let fast = getCurrentPages().find(v => v.__route__ == 'packageA/setclient/detail');
-                if (fast) fast.partialRenewal(true);
-                let detail = getCurrentPages().find(v => v.__route__ == 'packageA/setclient/modules/financing/detail/index');
-                if (detail) detail.initList(content)
-                wx.navigateBack();
-            }, 300)
+                getCurrentPages().forEach(v => {
+                    switch (v.__route__) {
+                        //详情界面更新数据
+                        case 'packageA/setclient/modules/financing/detail/index':
+                            v.getDetail();
+                            break;
+                            //列表页更新数据
+                        case 'packageA/setclient/detail':
+                            let page = v.selectComponent("#Financing"),
+                                list = res.data.isdefault == 0 ? page.data.list : page.data.list.map(v => {
+                                    v.isdefault = 0;
+                                    return v
+                                }),
+                                index = list.findIndex(value => value.sys_enterprise_financeid == res.data.sys_enterprise_financeid);
+                            if (index != -1) {
+                                //列表中存在说明是编辑,返回上一级页面并更新数据
+                                list[index] = res.data;
+                                page.setData({
+                                    list
+                                });
+                                wx.navigateBack();
+                            } else {
+                                //列表中不存在说明是新增,返回上一级页面更新数据 并进入详情
+                                list.push(res.data);
+                                page.setData({
+                                    list,
+                                    "content.total": page.data.content.total + 1
+                                });
+                                wx.navigateBack();
+                                wx.navigateTo({
+                                    url: '/packageA/setclient/modules/financing/detail/index?sys_enterprise_financeid=' + res.data.sys_enterprise_financeid
+                                })
+                            };
+                            if (res.data.isdefault == 1) setTimeout(() => {
+                                page.selectComponent("#List").queryDefault()
+                            }, 300)
+                            break;
+                    }
+                });
+            }, 500)
+
+
+
         })
     },
     /* 设置默认 */

+ 94 - 82
packageA/setclient/modules/financing/detail/index.js

@@ -1,86 +1,98 @@
+const _Http = getApp().globalData.http;
 Page({
-  data: {
-    item: {},
-
-    tabbarList: [{
-      icon: "icon-bodadianhua",
-      label: "呼叫",
-      alias: "call"
-    }, {
-      icon: "icon-a-yingxiaowuliaofuzhi",
-      label: "复制",
-      alias: "copy"
-    }, {
-      icon: "icon-bianji",
-      label: "编辑",
-      alias: "edit"
-    }, {
-      icon: "icon-shanchu",
-      label: "删除",
-      alias: "delete"
-    }]
-  },
-  onLoad(options) {
-    console.log(options)
-    if (options.data) {
-      let item = JSON.parse(options.data);
-      this.initList(item)
-      this.setData({
-        item
-      })
-    }
-  },
-  /* 初始化列表 */
-  initList(item) {
-    this.setData({
-      list: [{
-        label: "名称",
-        value: item.enterprisename
-      }, {
-        label: "纳税人识别号",
-        value: item.taxno
-      }, {
-        label: "地址",
-        value: item.address
-      }, {
-        label: "开户行",
-        value: item.bank
-      }, {
-        label: "账号",
-        value: item.bankcardno
-      }, {
-        label: "联系人号码",
-        value: item.phonenumber
-      }],
-    })
-  },
-  //详情按钮回调
-  tabbarOnClick({
-    detail
-  }) {
-    let pages = getCurrentPages();
-    pages[pages.length - 2].selectComponent('#Financing').selectComponent('#List').handleItem({
-      target: {
-        dataset: {
-          name: detail.alias,
-          item: this.data.item
+    data: {
+        sys_enterprise_financeid: 0,
+        item: {},
+        tabbarList: [{
+            icon: "icon-bodadianhua",
+            label: "呼叫",
+            alias: "call"
+        }, {
+            icon: "icon-a-yingxiaowuliaofuzhi",
+            label: "复制",
+            alias: "copy"
+        }, {
+            icon: "icon-bianji",
+            label: "编辑",
+            alias: "edit"
+        }, {
+            icon: "icon-shanchu",
+            label: "作废",
+            alias: "delete"
+        }]
+    },
+    onLoad(options) {
+        if (options.sys_enterprise_financeid) {
+            this.setData({
+                sys_enterprise_financeid: options.sys_enterprise_financeid
+            });
+            this.getDetail();
         }
-      }
-    });
-  },
-  //详情单元格单击复制
-  clickItem({
-    detail
-  }) {
-    wx.setClipboardData({
-      data: detail.value,
-      success: () => {
-        wx.hideToast();
-        wx.showToast({
-          title: `已复制${detail.label}`,
-          icon: "none"
+    },
+    //获取详情
+    getDetail() {
+        _Http.basic({
+            "id": 20221026105702,
+            "content": {
+                "sys_enterprise_financeid": this.data.sys_enterprise_financeid
+            },
+        }).then(res => {
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            })
+            const item = res.data;
+            this.setData({
+                list: [{
+                    label: "名称",
+                    value: item.enterprisename
+                }, {
+                    label: "纳税人识别号",
+                    value: item.taxno
+                }, {
+                    label: "地址",
+                    value: item.address
+                }, {
+                    label: "开户行",
+                    value: item.bank
+                }, {
+                    label: "账号",
+                    value: item.bankcardno
+                }, {
+                    label: "联系人号码",
+                    value: item.phonenumber
+                }],
+                item: res.data
+            })
         })
-      }
-    })
-  },
+    },
+    //详情按钮回调
+    tabbarOnClick({
+        detail
+    }) {
+        let page = getCurrentPages().find(v => v.__route__ == "packageA/setclient/detail");
+        if (page) page.selectComponent('#Financing').selectComponent('#List').handleItem({
+            target: {
+                dataset: {
+                    name: detail.alias,
+                    item: this.data.item
+                }
+            }
+        });
+    },
+    //详情单元格单击复制
+    clickItem({
+        detail
+    }) {
+        wx.setClipboardData({
+            data: detail.value,
+            success: () => {
+                wx.hideToast();
+                wx.showToast({
+                    title: `已复制${detail.label}`,
+                    icon: "none"
+                })
+            }
+        })
+    },
 })

+ 1 - 0
packageA/setclient/modules/financing/index.js

@@ -8,6 +8,7 @@ Component({
 
     },
     data: {
+        sys_enterpriseid: 0,
         content: {
             "nacache": true,
             "pageNumber": 1,

+ 1 - 1
packageA/setclient/modules/financing/index.wxml

@@ -6,7 +6,7 @@
         <navigator url="#" class="but">
             <van-icon name="search" />
         </navigator>
-        <navigator url="/packageA/setclient/modules/financing/add/index" class="but">
+        <navigator url="/packageA/setclient/modules/financing/add/index?sys_enterpriseid={{sys_enterpriseid}}" class="but">
             <van-icon name="plus" />
         </navigator>
     </view>

+ 113 - 115
packageA/setclient/modules/financing/list/index.js

@@ -1,123 +1,121 @@
 const _Http = getApp().globalData.http;
 Component({
-  options: {
-    addGlobalClass: true
-  },
-  properties: {
-    list: Array,
-    changeTotal: Function
-  },
-  data: {
-    radio: 0,
-    detailItem: {},
-  },
-  methods: {
-    //打开详情
-    onClick(e) {
-      const {
-        item
-      } = e.currentTarget.dataset;
-      this.setData({
-        "detailItem": item
-      })
-      wx.navigateTo({
-        url: '/packageA/setclient/modules/financing/detail/index?data=' + JSON.stringify(item),
-      })
+    options: {
+        addGlobalClass: true
     },
-    /* 处理快捷小按钮 */
-    handleItem(e) {
-      const {
-        name,
-        item
-      } = e.target.dataset,
-        that = this;
-      if (!name) return;
-      switch (name) {
-        case "call":
-          wx.makePhoneCall({
-            phoneNumber: item.phonenumber,
-          })
-          break;
-        case "copy":
-          wx.setClipboardData({
-            data: `名称:${item.enterprisename}\n纳税人识别号:${item.taxno}\n地址:${item.address}\n开户行:${item.bank}\n账号:${item.bankcardno}`,
-          })
-          break;
-        case "delete":
-          wx.showModal({
-            title: '提示',
-            content: '是否确认删除',
-            complete: (res) => {
-              if (res.confirm) {
-                _Http.basic({
-                  "id": 20221013160502,
-                  "content": {
-                    "sys_enterprise_financeids": [item.sys_enterprise_financeid]
-                  },
-                }).then(res => {
-                  if (res.msg != '成功') return wx.showToast({
+    properties: {
+        list: Array,
+        changeTotal: Function
+    },
+    data: {
+        radio: 0
+    },
+    methods: {
+        //打开详情
+        onClick(e) {
+            const {
+                item
+            } = e.currentTarget.dataset;
+            wx.navigateTo({
+                url: '/packageA/setclient/modules/financing/detail/index?sys_enterprise_financeid=' + item.sys_enterprise_financeid,
+            })
+        },
+        /* 处理快捷小按钮 */
+        handleItem(e) {
+            const {
+                name,
+                item
+            } = e.target.dataset,
+                that = this;
+            if (!name) return;
+            switch (name) {
+                case "call":
+                    wx.makePhoneCall({
+                        phoneNumber: item.phonenumber,
+                    })
+                    break;
+                case "copy":
+                    wx.setClipboardData({
+                        data: `名称:${item.enterprisename}\n纳税人识别号:${item.taxno}\n地址:${item.address}\n开户行:${item.bank}\n账号:${item.bankcardno}`,
+                    })
+                    break;
+                case "delete":
+                    wx.showModal({
+                        title: '提示',
+                        content: '是否确认作废',
+                        complete: (res) => {
+                            if (res.confirm) {
+                                _Http.basic({
+                                    "id": 20221013160502,
+                                    "content": {
+                                        "sys_enterprise_financeids": [item.sys_enterprise_financeid]
+                                    },
+                                }).then(res => {
+                                    if (res.msg != '成功') return wx.showToast({
+                                        title: res.msg,
+                                        icon: "none"
+                                    });
+                                    that.triggerEvent("changeTotal");
+                                    getCurrentPages().forEach(v => {
+                                        switch (v.__route__) {
+                                            //退出详情界面
+                                            case 'packageA/setclient/modules/financing/detail/index':
+                                                wx.navigateBack()
+                                                break;
+                                                //列表页更新数据
+                                            case 'packageA/setclient/detail':
+                                                that.setData({
+                                                    list: that.data.list.filter(v => v.sys_enterprise_financeid != item.sys_enterprise_financeid)
+                                                });
+                                                break;
+                                        }
+                                    });
+                                    wx.showToast({
+                                        title: '作废成功',
+                                        icon: "none"
+                                    });
+                                });
+                            }
+                        }
+                    })
+                    break;
+                case "edit":
+                    wx.navigateTo({
+                        url: '/packageA/setclient/modules/financing/add/index?data=' + JSON.stringify(item),
+                    });
+                    break;
+            }
+        },
+        /* 查询默认项目 */
+        queryDefault() {
+            const item = this.data.list.find(v => v.isdefault == 1);
+            if (!item) return;
+            this.setData({
+                radio: item.sys_enterprise_financeid
+            })
+        },
+        /* 修改默认项 */
+        onChange({
+            detail
+        }) {
+            _Http.basic({
+                "id": 20221013160702,
+                "content": {
+                    "sys_enterprise_financeid": detail
+                },
+            }).then(res => {
+                if (res.msg != '成功') return wx.showToast({
                     title: res.data,
                     icon: "none"
-                  });
-                  that.setData({
-                    list: that.data.list.filter(v => v.sys_enterprise_financeid != item.sys_enterprise_financeid)
-                  });
-                  that.triggerEvent("changeTotal");
-                  that.setData({
-                    detailItem: {}
-                  })
-                  let pages = getCurrentPages();
-                  if (pages[pages.length - 1].__route__ == 'packageA/setclient/modules/financing/detail/index') wx.navigateBack()
-                    wx.showToast({
-                      title: '删除成功',
-                      icon: "none"
-                    });
                 });
-              }
-            }
-          })
-          break;
-        case "edit":
-          wx.navigateTo({
-            url: '/packageA/setclient/modules/financing/add/index?data=' + JSON.stringify(item),
-          });
-          that.setData({
-            detailItem: {}
-          })
-          break;
-      }
-    },
-    /* 查询默认项目 */
-    queryDefault() {
-      const item = this.data.list.find(v => v.isdefault == 1);
-      if (!item) return;
-      this.setData({
-        radio: item.sys_enterprise_financeid
-      })
-    },
-    /* 修改默认项 */
-    onChange({
-      detail
-    }) {
-      _Http.basic({
-        "id": 20221013160702,
-        "content": {
-          "sys_enterprise_financeid": detail
+                this.setData({
+                    list: this.data.list.map(v => {
+                        v.isdefault = v.sys_enterprise_financeid == detail ? 1 : 0
+                        return v
+                    }),
+                    radio: detail
+                })
+            })
         },
-      }).then(res => {
-        if (res.msg != '成功') return wx.showToast({
-          title: res.data,
-          icon: "none"
-        });
-        this.setData({
-          list: this.data.list.map(v => {
-            v.isdefault = v.sys_enterprise_financeid == detail ? 1 : 0
-            return v
-          }),
-          radio: detail
-        })
-      })
-    },
-
-  }
+    }
 })

+ 23 - 11
packageA/setclient/modules/financing/list/index.scss

@@ -1,16 +1,28 @@
 @import "../../address/index.scss";
 
-.exp {
-  margin-top: 8rpx;
-  font-size: 24rpx;
-  font-family: PingFang SC-Regular, PingFang SC;
-  color: #333333;
+.add-box {
+    width: 100vw !important;
+    padding-left: 0 !important;
+    padding-top: 0 !important;
+    overflow: hidden;
+
+    .detail {
+        width: 100%;
+        padding-left: 30rpx;
+        padding-top: 20rpx;
+        box-sizing: border-box;
+        border-bottom: 0;
+    }
+
+    .editor {
+        margin-left: 30rpx;
+        border-top: 1px solid #ddd;
+    }
 }
 
-.pop-title {
-  height: 90rpx;
-  line-height: 90rpx;
-  text-align: center;
-  border-bottom: 1px solid #dddddd;
-  font-weight: bold;
+.exp {
+    margin-top: 8rpx;
+    font-size: 24rpx;
+    font-family: PingFang SC-Regular, PingFang SC;
+    color: #333333;
 }

+ 1 - 7
packageA/setclient/modules/financing/list/index.wxml

@@ -25,10 +25,4 @@
     </view>
   </view>
 </van-radio-group>
-<My_empty wx:if="{{list.length==0}}" />
-
-
-<van-popup show="{{  detail.show }}" position="bottom" custom-style="height: 100%" round closeable safe-area-inset-bottom='{{false}}' bind:close='onClose' bind:cancel='onClose'>
-  <view class="pop-title">财务信息</view>
-
-</van-popup>
+<My_empty wx:if="{{list.length==0}}" />