123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- const _Http = getApp().globalData.http;
- let ownertable = '',
- ownerid = '',
- id = "1";
- Page({
- data: {
- isleader: false,
- manage: "管理",
- result: []
- },
- onLoad(options) {
- ownertable = options.ownertable;
- ownerid = options.ownerid;
- if (options.ownertable == "sa_workorder") id = "3";
- this.getList();
- },
- getList() {
- _Http.basic({
- "id": 2022093010350 + id,
- content: {
- ownertable,
- ownerid,
- }
- }).then(res => {
- console.log(`数据团队${ownertable+ownerid}`, res)
- if (res.msg != '成功') {
- wx.showToast({
- title: res.msg,
- icon: "none",
- mask: true
- });
- return setTimeout(wx.navigateBack, 1500);
- } else {
- this.setData({
- list: res.data[0].team,
- isleader: res.data[0].teamleader[0].userid == wx.getStorageSync('userMsg').userid
- })
- }
- })
- },
- /* 添加成员 */
- insert() {
- let params = id == 3 ? {
- "id": "20230213143003",
- "version": 1,
- "content": {
- nocache: true,
- "where": {
- "condition": "",
- "isleader": 0
- }
- }
- } : {
- "id": 20221018122201,
- "content": {
- "ownertable": ownertable,
- "ownerid": ownerid,
- nocache: true,
- "where": {
- "condition": "",
- "withoutselect": 1
- }
- }
- };
- wx.navigateTo({
- url: `/select/contacts/index?params=${JSON.stringify(params)}`,
- })
- getApp().globalData.handleSelect = this.insertUser.bind(this);
- },
- insertUser({
- value
- }) {
- let that = this;
- wx.showModal({
- title: '提示',
- content: `是否确认添加${value[0]+value[0].length}位成员`,
- complete: ({
- confirm
- }) => {
- if (confirm) _Http.basic({
- "accesstoken": "7eb155cb0a9ed5895056afc151af7d7f",
- "id": 20220930103601,
- "content": {
- ownertable,
- ownerid,
- "userids": value[1],
- "justuserids": 1
- }
- }).then(res => {
- console.log("添加成员", res)
- wx.showToast({
- title: res.msg == '成功' ? '添加成功' : res.msg,
- icon: "none",
- mask: true
- });
- if (res.msg == '成功') {
- that.getList()
- setTimeout(wx.navigateBack, 1000)
- }
- })
- }
- })
- },
- /* 设置负责人 */
- setLeader(e) {
- const {
- item
- } = e.currentTarget.dataset,
- that = this;
- wx.showModal({
- title: '提示',
- content: `是否确认将负责人转让到“${item.name}”`,
- complete: ({
- confirm
- }) => {
- if (confirm) _Http.basic({
- "id": 2022093010370 + id,
- "content": {
- ownertable,
- ownerid,
- "userid": item.userid
- }
- }).then(res => {
- wx.showToast({
- title: res.msg == '成功' ? '转让成功' : res.msg,
- icon: "none",
- mask: true
- });
- if (res.msg == '成功') that.getList()
- })
- }
- })
- },
- /* 开启设置 */
- setTeam() {
- this.setData({
- manage: this.data.manage == '管理' ? '取消' : "管理"
- })
- },
- /* 选中成员 */
- toggle(event) {
- const {
- name
- } = event.currentTarget.dataset;
- let result = this.data.result;
- result.some(v => v == name) ? result = result.filter(v => v != name) : result.push(name);
- this.setData({
- result
- })
- },
- /* 移除成员 */
- onRemove() {
- let result = this.data.result,
- that = this;
- wx.showModal({
- title: '提示',
- content: `是否确认移除${result.length}位成员`,
- complete: ({
- confirm
- }) => {
- if (confirm) _Http.basic({
- "id": 2022093010380 + id,
- "content": {
- ownertable,
- ownerid,
- "userids": result
- }
- }).then(res => {
- wx.showToast({
- title: res.msg == '成功' ? '移除成功' : res.msg,
- icon: "none",
- mask: true
- });
- if (res.msg == '成功') {
- that.setData({
- result: []
- });
- that.getList()
- }
- })
- }
- })
- }
- })
|