123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- const _Http = getApp().globalData.http;
- Page({
- data: {
- radio: false, //是否为单选
- obj: false, //是否返回数组对象
- model: "", //提交上一级组件中的事件
- principal: false, //是否为更换负责人
- content: {
- nocache: true,
- ownertable: null,
- ownerid: null,
- pageSize: 20,
- pageNumber: 1,
- pageTotal: 1,
- "where": {
- "condition": ""
- }
- },
- list: [],
- result: []
- },
- async onLoad(options) {
- //是否为单选
- if (options.radio) this.setData({
- radio: true
- });
- //是否返回数组对象
- if (options.obj) this.setData({
- obj: true
- });
- //调用上一级组件中的提交事件
- if (options.model) this.setData({
- model: options.model
- });
- //是否为更换负责人
- if (options.principal) {
- this.setData({
- principal: true
- })
- wx.setNavigationBarTitle({
- title: '更换负责人'
- })
- }
- if (options.data) {
- let {
- ownertable,
- ownerid
- } = JSON.parse(options.data);
- this.setData({
- "content.ownertable": ownertable,
- "content.ownerid": ownerid,
- });
- await this.getList();
- //是否有默认选项
- if (options.result) {
- this.setData({
- result: [options.result]
- });
- }
- };
- },
- submit() {
- let result = this.data.result;
- if (result.length == 0) return;
- let pages = getCurrentPages();
- let list = this.data.obj ? result.map(id => this.data.list.find(v => v.userid == id)) : result;
- if (this.data.model) {
- pages[pages.length - 2].selectComponent("#" + this.data.model).handelSubmit(list);
- } else {
- pages[pages.length - 2].handelSubmit(list);
- }
- },
- /* 选中 */
- onChange(e) {
- const userid = e.currentTarget.dataset.item.userid + "";
- if (!userid) return;
- if (this.data.radio) {
- this.setData({
- result: [userid]
- })
- } else {
- let result = this.data.result;
- if (result.some(v => v == userid)) {
- result = result.filter(v => v != userid)
- } else {
- result.push(userid)
- }
- this.setData({
- result
- })
- }
- },
- //获取列表
- getList(init = false) {
- let content = this.data.content;
- if (init) {
- content.pageTotal = 1
- content.pageNumber = 1
- }
- if (content.pageNumber > content.pageTotal) return;
- if (this.data.principal) {
- _Http.basic({
- "id": 20220930103501,
- content
- }).then(res => {
- console.log("团队成员列表", res)
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- })
- let data = res.data.find(v => v.ismyteam == 1);
- this.setData({
- list: data.team.filter(v => v.userid != data.teamleader[0].userid)
- })
- })
- } else {
- _Http.basic({
- "id": 20221018122201,
- content
- }).then(res => {
- console.log("数据团队列表", res)
- this.setData({
- list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
- "content.pageTotal": res.pageTotal,
- "content.pageNumber": res.pageNumber + 1,
- })
- })
- }
- },
- onReachBottom() {
- this.getList();
- }
- })
|