| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- const _Http = getApp().globalData.http;
- Page({
- data: {
- "id": 2026030916100201,
- list: [],
- content: {
- nocache: true,
- pageNumber: 1,
- pageSize: 20,
- pageTotal: 1,
- where: {
- condition: "",
- tablefilter: {
- status: null,
- name: null,
- siteid: null,
- storename: null,
- sex: null
- }
- },
- tableid: 2096
- }
- },
- onLoad(options) {
- // 检查是否是选择模式
- this.setData({
- selectMode: options.selectMode === 'true'
- });
- this.getList();
- },
- /* 获取客户列表 */
- getList(init = false) {
- if (init.detail != undefined) init = init.detail;
- if (init) {
- this.setData({
- 'content.pageNumber': 1
- });
- }
- if (this.data.content.pageNumber > this.data.content.pageTotal) return;
- this.setListHeight();
- _Http.basic({
- id: this.data.id,
- content: this.data.content
- }).then(res => {
- console.log("客户列表数据", res);
- this.selectComponent('#ListBox').RefreshToComplete();
- this.setData({
- 'content.pageNumber': res.pageNumber + 1,
- 'content.pageTotal': res.pageTotal,
- list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
- total: res.total
- });
- }).catch(err => {
- console.error("获取客户列表失败", err);
- this.selectComponent('#ListBox').RefreshToComplete();
- });
- },
- /* 设置页面高度 */
- setListHeight() {
- this.selectComponent("#ListBox").setHeight(".header", this);
- },
- /* 搜索 */
- onSearch({
- detail
- }) {
- this.setData({
- 'content.where.condition': detail
- });
- this.getList(true);
- },
- /* 新增客户 */
- addCustomer() {
- if (this.data.selectMode) {
- wx.navigateTo({
- url: '/CRM/customer/create?selectMode=true'
- });
- } else {
- wx.navigateTo({
- url: '/CRM/customer/create'
- });
- }
- },
- /* 选择客户 */
- selectCustomer(e) {
- if (this.data.selectMode) {
- const customerItem = e.currentTarget.dataset.item;
- // 调用全局回调函数,设置客户信息
- if (getApp().globalData.setCustomer) {
- getApp().globalData.setCustomer(customerItem);
- }
- // 返回上一页
- wx.navigateBack();
- }
- }
- });
|