| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- const _Http = getApp().globalData.http;
- Page({
- data: {
- item: null,
- radio: true,
- content: {
- sys_phonebookid: 0,
- "nocache": true,
- "pageNumber": 1,
- "pageTotal": 1,
- "pageSize": 20,
- "where": {
- "condition": ""
- }
- }
- },
- onLoad(options) {
- console.log(options)
- if (options.sys_phonebookid) this.data.content.sys_phonebookid = options.sys_phonebookid;
- this.data.content.sa_projectid = getCurrentPages().find(v => v.__route__ == 'packageA/project/detail').data.sa_projectid
- /* 从表单组件进入进入 */
- this.getList()
- },
- 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": "20231215134204",
- content
- }).then(res => {
- console.log("选择客户列表", res)
- this.selectComponent('#ListBox').RefreshToComplete();
- if (res.code != '1') return getApp().globalData.Language.showToast(res.msg)
- })
- },
- /* 获取列表标签 */
- 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) {
- 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
- });
- this.submit();
- },
- /* 提交 */
- submit() {
- let result = this.data.result,
- obj = this.data.radio ? {
- id: result,
- item: this.data.list.find(value => value.contactsid == result),
- value: [this.data.list.find(value => value.contactsid == result).enterprisename, result]
- } : {
- result,
- list: result.map(v => this.data.list.find(value => value.contactsid == v)),
- value: [result.map(v => {
- let data = this.data.list.find(value => value.contactsid == v);
- return data ? data.enterprisename : ""
- }), result]
- }
- getApp().globalData.handleSelect && getApp().globalData.handleSelect(obj)
- },
- /* 开始搜索 */
- 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);
- }
- })
|