zhaoxiaohai 3 лет назад
Родитель
Сommit
ee1b8bc746
2 измененных файлов с 44 добавлено и 28 удалено
  1. 42 26
      packageA/select/project/select.js
  2. 2 2
      packageA/select/project/select.wxml

+ 42 - 26
packageA/select/project/select.js

@@ -2,39 +2,55 @@ const _Http = getApp().globalData.http,
     getHeight = require("../../../utils/getRheRemainingHeight");
 Page({
     data: {
-        content: {
-            nocache: true,
-            "type": 0,
-            "pageNumber": 1,
-            "pageSize": 20,
-            "isExport": 0,
-            "where": {
-                "condition": "",
-            }
-        },
+        item: {},
         result: [],
-        radio: true,
+        params: {},
+        radio: false,
     },
     onLoad(options) {
+        console.log(options)
+        if (options.item) {
+            let item = JSON.parse(options.item);
+            this.setData({
+                item,
+                params: item.params
+            });
+        }
+        if (options.params) this.setData({
+            params: JSON.parse(options.params)
+        })
+        this.setData({
+            radio: options.radio ? true : false
+        })
         this.getList()
     },
     submit() {
-        let pages = getCurrentPages();
-        let list = this.data.result.map(v => this.data.list.find(value => value.sa_projectid == v));
-        console.log(this.data.result)
-        console.log(list)
+        let pages = getCurrentPages(),
+            item = this.data.item,
+            result = this.data.result,
+            list = this.data.result.map(v => this.data.list.find(value => value.sa_projectid == v));
+        try {
+            let page = pages[pages.length - 2].selectComponent(item.model || "#Form");
+            if (page) {
+                item.value = this.data.radio ? [list[0].projectname, result] : [list.map(v => v.projectname), result];
+                page.handleRoute(item);
+            } else {
+                pages[pages.length - 2].handleSelectProject(this.data.result, list)
+            }
+        } catch (e) {
+            wx.showToast({
+                title: '操作失败',
+                icon: "none"
+            })
+        }
     },
     getList(init = false) {
         //init 用于初始化分页
         if (init.detail != undefined) init = init.detail;
-        if (init) this.setData({
-            ['content.pageNumber']: 1
-        })
-        if (this.data.content.pageNumber > this.data.content.pageTotal) return;
-        _Http.basic({
-            "id": 20221020143502,
-            content: this.data.content
-        }).then(res => {
+        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({
@@ -42,9 +58,9 @@ Page({
                 icon: "none"
             })
             this.setData({
-                'content.pageNumber': res.pageNumber + 1,
-                'content.pageTotal': res.pageTotal,
-                'content.total': res.total,
+                '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)
             })
             this.getTags();

+ 2 - 2
packageA/select/project/select.wxml

@@ -1,6 +1,6 @@
-<van-search class="search" value="{{ content.where.condition }}" shape="round" placeholder="请输入搜索关键词" bind:search='startSearch' bind:clear='onClear' />
+<van-search class="search" value="{{ params.content.where.condition }}" shape="round" placeholder="请输入搜索关键词" bind:search='startSearch' bind:clear='onClear' />
 <My_listBox id='ListBox' height="{{listHeight}}" bind:getlist='getList'>
-    <view class="total">共{{content.total}}个</view>
+    <view class="total">共{{params.content.total}}个</view>
     <navigator class="setclient-list-item" url="#" wx:for="{{list}}" wx:key="item.sa_projectid" data-id="{{item.sa_projectid}}" bindtap="changeResult">
         <view class="con">
             <view class="mian">