zhaoxiaohai 2 anos atrás
pai
commit
eda379a49f

+ 3 - 1
app.json

@@ -33,7 +33,9 @@
         "activity/index",
         "activity/detail",
         "tool/index",
-        "invoice/index"
+        "invoice/index",
+        "invoice/update",
+        "invoice/detail"
       ]
     },
     {

+ 38 - 25
components/Yl_Field/index.js

@@ -10,42 +10,44 @@ Component({
         onConfirm: Function,
         interrupt: Function, //打断处理,用于条件判断 把form返回到上个页面处理重新传入
     },
+    data: {
+        temporary: null, //route选择暂存选中项
+    },
     options: {
         multipleSlots: true //允许使用多个slot
     },
     methods: {
-        toOptions(e) {
-            const {
-                item
-            } = e.currentTarget.dataset;
-            wx.navigateTo({
-                url: '/packageA/options/index?data=' + JSON.stringify(item),
-            })
-        },
         route(e) {
             const {
                 item
             } = e.currentTarget.dataset;
-            let param = JSON.stringify(item);
-            param += item.radio ? '&radio=true' : '';
+            getApp().globalData.handleSelect = this.handleRoute.bind(this);
             wx.navigateTo({
-                url: item.url + '?item=' + param,
+                url: item.url + '?params=' + JSON.stringify(item.params) + item.query
+            })
+            this.setData({
+                temporary: {
+                    item: item,
+                    index: this.data.form.findIndex(v => v.valueName == item.valueName)
+                }
             })
         },
         /* 处理路由返回结果 */
         handleRoute(data) {
-            let i = this.data.form.findIndex(v => v.valueName == data.valueName);
-            this.setData({
-                [`form[${i}].value`]: data.value
-            });
-            wx.navigateBack();
-            this.triggerEvent("interrupt", {
-                data,
-                form: this.data.form
-            });
-            setTimeout(() => {
+            let temporary = this.data.temporary;
+            if (temporary.item.interrupt) {
+                this.triggerEvent("interrupt", {
+                    data,
+                    form: this.data.form,
+                    temporary
+                });
+            } else {
+                wx.navigateBack();
+                this.setData({
+                    [`form[${temporary.index}].value`]: data.value
+                });
                 this.confirm()
-            }, 100)
+            }
         },
         /* 改变值 */
         inputChange(e) {
@@ -127,6 +129,14 @@ Component({
             });
             this.confirm();
         },
+        toOptions(e) {
+            const {
+                item
+            } = e.currentTarget.dataset;
+            wx.navigateTo({
+                url: '/packageA/options/index?data=' + JSON.stringify(item),
+            })
+        },
         /* 自定义选项 */
         setOption(item) {
             let i = this.data.form.findIndex(v => v.valueName == item.valueName);
@@ -143,7 +153,10 @@ Component({
                 } else {
                     return v.required && v.value == '';
                 }
-            }))
+            }));
+            this.setData({
+                temporary: null
+            })
         },
         /* 性别 */
         sexChange(e) {
@@ -163,8 +176,8 @@ Component({
                 [`form[${index}].value`]: e.detail,
                 [`form[${index}].error`]: false,
             });
-            if(item.interrupt) this.triggerEvent("interrupt", {
-                data:this.data.form[index],
+            if (item.interrupt) this.triggerEvent("interrupt", {
+                data: this.data.form[index],
                 form: this.data.form
             });
             this.confirm();

+ 1 - 4
components/Yl_Field/index.wxml

@@ -1,6 +1,5 @@
 <view wx:for="{{form}}" wx:key="valueName" data-name="{{item.valueName}}">
     <view hidden="{{ !item.required && !showAll }}">
-        <!-- <van-transition show="{{ item.required || showAll }}" name="fade" custom-class="block"> -->
         <!-- 日期选择器 -->
         <view class="picker" wx:if="{{item.type=='date'}}">
             <view class="label">
@@ -44,7 +43,6 @@
                 <view wx:if="{{item.errMsg}}" class="error-tips">{{item.errMsg}}</view>
             </view>
         </view>
-        
         <!-- 时间选择器 -->
         <view class="picker" wx:elif="{{item.type=='time'}}">
             <view class="label">
@@ -116,7 +114,7 @@
                 <view wx:if="{{item.errMsg}}" class="error-tips">{{item.errMsg}}</view>
             </view>
         </view>
-        <!-- 异步类型选择 -->
+        <!-- 类型选择 -->
         <view class="picker" wx:elif="{{item.type=='option'}}">
             <view class="label">
                 <text class="need" style="color: {{item.required?'#EE0A24':'rgba(0,0,0,0)'}};">*</text>
@@ -151,5 +149,4 @@
             <slot wx:if="{{item.slot}}" name="{{item.slot}}" slot='button' />
         </van-field>
     </view>
-    <!-- </van-transition> -->
 </view>

+ 14 - 0
project.private.config.json

@@ -71,6 +71,20 @@
           "query": "",
           "launchMode": "default",
           "scene": null
+        },
+        {
+          "name": "开票",
+          "pathName": "packageA/invoice/index",
+          "query": "",
+          "launchMode": "default",
+          "scene": null
+        },
+        {
+          "name": "新建开票信息",
+          "pathName": "packageA/invoice/update",
+          "query": "",
+          "launchMode": "default",
+          "scene": null
         }
       ]
     }

+ 107 - 109
select/finance/index.js

@@ -1,114 +1,112 @@
 const _Http = getApp().globalData.http;
 
 Page({
-  data: {
-    loading: true,
-    params: {}, //请求体
-    result: [], //返回结果
-    radio: false, //是否为单选
-    idname: "sys_enterprise_financeid", //idkey
-    showName: "enterprisename"
-  },
-  onLoad(options) {
-    if (options.item) {
-      let item = JSON.parse(options.item);
-      this.setData({
-        item,
-        params: item.params
-      });
+    data: {
+        loading: true,
+        params: {}, //请求体
+        result: [], //返回结果
+        radio: false, //是否为单选
+        idname: "sys_enterprise_financeid", //idkey
+        showName: "enterprisename"
+    },
+    onLoad(options) {
+        if (options.params) {
+            let params = JSON.parse(options.params);
+            if (!params.content.pageNumber || !params.content.pageTotal) {
+                params.content.pageNumber = 1;
+                params.content.pageTotal = 1;
+            }
+            this.setData({
+                params
+            });
+        }
+        this.setData({
+            radio: options.radio ? true : false,
+            idname: options.idname || this.data.idname,
+            showName: options.showName || this.data.showName,
+        });
+        this.getList()
+    },
+    getList(init = false) {
+        //init 用于初始化分页
+        if (init.detail != undefined) init = init.detail;
+        let params = this.data.params;
+        if (init) params.content.pageNumber = 1;
+        if (params.content.pageNumber > params.content.pageTotal) return;
+        _Http.basic(params).then(res => {
+            console.log("财务信息列表", res)
+            this.selectComponent('#ListBox').RefreshToComplete();
+            if (res.msg != '成功') return wx.showToast({
+                title: res.msg,
+                icon: "none"
+            })
+            this.setData({
+                'params.content.pageNumber': res.pageNumber + 1,
+                'params.content.pageTotal': res.pageTotal,
+                'params.content.total': res.total,
+                list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
+                loading: false
+            })
+        })
+    },
+    /* 选中 */
+    changeResult(e) {
+        let {
+            id
+        } = e.currentTarget.dataset, result = this.data.result;
+        if (this.data.radio) {
+            result = [id];
+        } else {
+            result.some(v => v == id) ? result = result.filter(v => v != id) : result.push(id)
+        }
+        this.setData({
+            result
+        });
+        if (this.data.radio) this.submit();
+    },
+    /* 提交 */
+    submit() {
+        let result = this.data.result,
+            obj = this.data.radio ? {
+                id: result,
+                item: this.data.list.find(value => value[this.data.idname] == result),
+                value: [this.data.list.find(value => value[this.data.idname] == result)[this.data.showName], result]
+            } : {
+                result,
+                list: result.map(v => this.data.list.find(value => value[this.data.idname] == v)),
+                value: [result.map(v => {
+                    let data = this.data.list.find(value => value[this.data.idname] == v);
+                    return data ? data[this.data.showName] : ""
+                }), result]
+            }
+        getApp().globalData.handleSelect && getApp().globalData.handleSelect(obj)
+    },
+    /* 开始搜索 */
+    startSearch({
+        detail
+    }) {
+        let condition = this.data.content ? this.data.content.where.condition : this.data.params.content.where.condition;
+        if (detail == condition) return;
+        this.setData({
+            'content.where.condition': detail,
+            'params.content.where.condition': detail
+        });
+        this.getList(true);
+    },
+    /* 取消搜索 */
+    onClear() {
+        this.setData({
+            'content.where.condition': "",
+            'params.content.where.condition': ""
+        });
+        this.getList(true);
+    },
+    onReady() {
+        this.selectComponent("#ListBox").setHeight(".total", this);
+    },
+    onUnload() {
+        //回收数据
+        getApp().globalData.handleSelect = null;
+        getApp().globalData.savePage = null;
     }
-    if (options.params) this.setData({
-      params: JSON.parse(options.params)
-    });
-    this.setData({
-      radio: options.radio ? true : false,
-      idname: options.idname || this.data.idname,
-      showName: options.showName || this.data.showName,
-    });
-    this.getList()
-  },
-  getList(init = false) {
-    //init 用于初始化分页
-    if (init.detail != undefined) init = init.detail;
-    let params = this.data.params;
-    if (init) params.content.pageNumber = 1
-    if (params.content.pageNumber > params.content.pageTotal) return;
-
-    _Http.basic(params).then(res => {
-      console.log("财务信息列表", res)
-      this.selectComponent('#ListBox').RefreshToComplete();
-      if (res.msg != '成功') return wx.showToast({
-        title: res.msg,
-        icon: "none"
-      })
-
-      this.setData({
-        'params.content.pageNumber': res.pageNumber + 1,
-        'params.content.pageTotal': res.pageTotal,
-        'params.content.total': res.total,
-        list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
-        loading: false
-      })
-    })
-  },
-  /* 选中 */
-  changeResult(e) {
-    let {
-      id
-    } = e.currentTarget.dataset, result = this.data.result;
-    if (this.data.radio) {
-      result = [id];
-    } else {
-      result.some(v => v == id) ? result = result.filter(v => v != id) : result.push(id)
-    }
-    this.setData({
-      result
-    });
-    if (this.data.radio) this.submit();
-  },
-  /* 提交 */
-  submit() {
-    let result = this.data.result,
-      obj = this.data.radio ? {
-        id: result,
-        item: this.data.list.find(value => value[this.data.idname] == result),
-        value: [this.data.list.find(value => value[this.data.idname] == result)[this.data.showName], result]
-      } : {
-        result,
-        list: result.map(v => this.data.list.find(value => value[this.data.idname] == v)),
-        value: [result.map(v => {
-          let data = this.data.list.find(value => value[this.data.idname] == v);
-          return data ? data[this.data.showName] : ""
-        }), result]
-      }
-    getApp().globalData.handleSelect && getApp().globalData.handleSelect(obj)
-  },
-  /* 开始搜索 */
-  startSearch({
-    detail
-  }) {
-    let condition = this.data.content ? this.data.content.where.condition : this.data.params.content.where.condition;
-    if (detail == condition) return;
-    this.setData({
-      'content.where.condition': detail,
-      'params.content.where.condition': detail
-    });
-    this.getList(true);
-  },
-  /* 取消搜索 */
-  onClear() {
-    this.setData({
-      'content.where.condition': "",
-      'params.content.where.condition': ""
-    });
-    this.getList(true);
-  },
-  onReady() {
-    this.selectComponent("#ListBox").setHeight(".total", this);
-  },
-  onUnload() {
-    //回收数据
-    getApp().globalData.handleSelect = null;
-    getApp().globalData.savePage = null;
-  }
 })