| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- const _Http = getApp().globalData.http;
- Page({
- data: {
- result: [],
- content: {
- "nocache": true,
- "pageNumber": 1,
- "pageSize": 20,
- "total": null,
- "where": {
- "condition": "",
- "type": 11,
- "sa_projectid": null
- }
- },
- radio: false,
- },
- onLoad(options) {
- this.setData({
- "content.where.sa_projectid": options.sa_projectid ? options.sa_projectid : null,
- radio: options.radio ? true : false
- })
- this.getList();
- },
- tabChange(e) {
- this.data.content.where.type = e.detail.title == '客户' ? 11 : 12;
- this.getList(true)
- },
- submit() {
- let pages = getCurrentPages();
- let list = this.data.result.map(v => this.data.list.find(value => value.sys_enterpriseid == v));
- try {
- setTimeout(() => {
- pages[pages.length - 2].getTags();
- }, 300)
- pages[pages.length - 2].selectComponent("#Treaty").submit({
- "sa_projectid": this.data.content.where.sa_projectid,
- "sys_enterpriseids": this.data.result,
- "remarks": ""
- }, list)
- } catch (e) {
- pages[pages.length - 2].submit({
- "sa_projectid": this.data.content.where.sa_projectid,
- "sys_enterpriseids": this.data.result,
- "remarks": ""
- }, list);
- }
- },
- /* 获取列表 */
- 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;
- _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();
- })
- },
- /* 选中 */
- changeResult(e) {
- const {
- id
- } = e.currentTarget.dataset;
- let result = this.data.result;
- if (this.data.radio) {
- result = [id]
- } else {
- if (result.some(v => v == id)) {
- result = result.filter(v => v != id);
- } else {
- result.push(id)
- };
- }
- this.setData({
- result
- })
- },
- /* 开始搜索 */
- startSearch({
- detail
- }) {
- if (detail == this.data.content.where.condition) return;
- this.setData({
- 'content.where.condition': detail
- });
- this.getList(true);
- },
- /* 取消搜索 */
- onClear() {
- this.setData({
- 'content.where.condition': ""
- });
- this.getList(true);
- },
- /* 获取标签 */
- getTags() {
- let list = this.data.list,
- ownerids = list.map(v => v.sa_customersid);
- _Http.basic({
- "id": 20221018102001,
- "content": {
- "ownertable": "sa_customers",
- ownerids
- }
- }).then(res => {
- console.log("标签", res)
- if (res.msg != '成功') return;
- for (let key in res.data) {
- let index = list.findIndex(v => v.sa_customersid == key);
- if (index != -1) list[index].tags = res.data[key]
- };
- this.setData({
- list
- })
- })
- },
- onReady() {
- this.selectComponent("#ListBox").setHeight(".search", this);
- },
- })
|