| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- const _Http = getApp().globalData.http,
- getHeight = require("../../../../../utils/getRheRemainingHeight");
- Page({
- data: {
- active: 0,
- item: null,
- radio: true,
- content: {
- pageNumber: 1,
- pageTotal: 1,
- total: null,
- where: {
- condition: "",
- type: 5,
- sa_projectid: 1
- }
- }
- },
- onLoad(options) {
- /* 从表单组件进入进入 */
- if (options.item) {
- let item = JSON.parse(options.item);
- this.setData({
- item
- })
- };
- this.getList()
- },
- onChange(e) {
- this.setData({
- active: e.detail.index
- });
- this.getList(true);
- },
- getList(init = false) {
- //init 用于初始化分页
- if (init.detail != undefined) init = init.detail;
- let content = this.data.content;
- if (init) content.pageNumber = 1;
- if (content.pageNumber > content.pageTotal) return;
- content.where.type = this.data.active == 0 ? 6 : 5
- if (this.data)
- _Http.basic({
- id: 20220920083901,
- content
- }).then(res => {
- console.log("选择客户列表", res)
- this.selectComponent('#ListBox').RefreshToComplete();
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- })
- this.setData({
- 'content.pageNumber': res.pageNumber + 1,
- 'content.pageTotal': res.pageTotal,
- 'content.total': res.total,
- list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
- })
- this.getTags();
- })
- },
- /* 获取列表标签 */
- getTags() {
- let list = this.data.list,
- ownerids = list.map(v => v.sys_enterpriseid)
- _Http.basic({
- "id": 20221018102001,
- "content": {
- "ownertable": "sa_customers",
- ownerids
- }
- }).then(res => {
- for (let key in res.data) {
- let index = list.findIndex(v => v.sys_enterpriseid == key);
- list[index].tags = res.data[key]
- };
- this.setData({
- list
- })
- })
- },
- /* 选中 */
- changeResult(e) {
- const {
- id
- } = e.currentTarget.dataset;
- let pages = getCurrentPages();
- let page = pages[pages.length - 2].selectComponent("#Form"),
- item = this.data.item,
- data = this.data.list.find(v => v.sys_enterpriseid == id);
- item.value = [data.enterprisename, [id]];
- page.handleRoute(item, [data]);
- },
- /* 开始搜索 */
- startSearch({
- detail
- }) {
- let condition = this.data.content ? this.data.content.where.condition : this.data.content.where.condition;
- if (detail == condition) return;
- this.setData({
- 'content.where.condition': detail
- });
- this.getList(true);
- },
- /* 取消搜索 */
- onClear() {
- this.setData({
- 'content.where.condition': ""
- });
- this.getList(true);
- },
- onReady() {
- getHeight.getHeight('.total', this).then(res => this.setData({
- listHeight: res
- }));
- }
- })
|