| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- const _Http = getApp().globalData.http;
- Component({
- properties: {
- isdep: {
- type: Boolean,
- value: true
- },
- isusers: {
- type: Boolean,
- value: true
- },
- defaultMy: {
- type: Boolean,
- value: true
- },
- exclution: {
- type: Boolean,
- value: true
- },
- dimissionF: {
- type: Boolean
- },
- defaultIsleave: {
- type: [Number, String], // 0 在职 1离职 空全部
- value: "0"
- }
- },
- data: {
- takeEffect: "", //生效筛选项
- result: {
- name: ""
- },
- users: {
- label: "业务员",
- active: {}
- },
- isleave: "0",
- tabs: [{
- value: "",
- name: "全部"
- }, {
- value: "0",
- name: "在职"
- }, {
- value: "1",
- name: "离职"
- }],
- searchValue: "",
- depGroud: [],
- userObj: {}
- },
- lifetimes: {
- attached: function () {}
- },
- methods: {
- searchChange({
- detail
- }) {
- if (detail.length == 0) return this.searchClear()
- let list = JSON.parse(JSON.stringify(this.data.users.copyList));
- this.setData({
- 'users.list': list.filter(v => v.name.includes(detail) || v.accountno.includes(detail))
- })
- },
- searchClear() {
- this.setData({
- 'users.list': JSON.parse(JSON.stringify(this.data.users.copyList))
- })
- },
- changLeave(e) {
- this.setData({
- isleave: e.currentTarget.dataset.value,
- 'result.isleave': e.currentTarget.dataset.value
- })
- this.getUsers()
- },
- initDepAndUser(init = true) {
- if (init) this.setData({
- takeEffect: "", //生效筛选项
- result: {},
- })
- return new Promise((resolve) => {
- _Http.basic({
- "classname": "webmanage.sale.salearea.salearea",
- "method": "query_area",
- "content": {},
- }).then(res => {
- console.log("获取区域", res)
- if (this.data.isdep && this.data.depGroud.length == 0) this.setData({
- depGroud: [{
- label: "营销区域",
- list: res.data,
- active: ""
- }]
- })
- if (init) {
- this.setData({
- isleave: this.data.defaultIsleave
- })
- if (res.data.length) {
- this.selectDep({
- currentTarget: {
- dataset: {
- item: res.data[0],
- index: 0
- }
- }
- })
- }
- }
- resolve(res.data.length ? res.data[0] : {
- sa_saleareaid: 0
- })
- })
- })
- },
- async getUsers(sa_saleareaid) {
- let list = [],
- userObj = this.data.userObj;
- try {
- if (sa_saleareaid && userObj['user' + sa_saleareaid].length) list = userObj['user' + sa_saleareaid];
- } catch (error) {
- }
- if (!sa_saleareaid) sa_saleareaid = this.data.result.sa_saleareaid;
- let res = {}
- if (list.length == 0) res = await _Http.basic({
- id: 20221011144603,
- "content": {
- isExport: 0,
- isHasSub: 1,
- "pageNumber": 1,
- "pageSize": 999,
- "where": {
- "condition": "",
- status: this.data.isleave
- },
- sa_saleareaid
- },
- })
- if (res.code == 1) {
- res.data.filter(v => {
- if (!list.some(s => s.userid == v.userid)) list.push(v)
- })
- userObj['user' + sa_saleareaid] = list;
- }
- this.setData({
- "users.list": list,
- "users.copyList": JSON.parse(JSON.stringify(list)),
- "users.active": {},
- userObj
- })
- },
- selectDep(e) {
- const {
- item,
- index
- } = e.currentTarget.dataset;
- let depGroud = this.data.depGroud.slice(0, index + 1);
- depGroud[index].active = item.sa_saleareaid;
- if (item.subarea.length) {
- if (item.subarea[0].areaname != '全部') {
- item.subarea.unshift(JSON.parse(JSON.stringify(item)))
- item.subarea[0].areaname = '全部';
- item.subarea[0].subarea = [];
- }
- depGroud.push({
- label: item.areaname + '下级区域',
- list: item.subarea,
- active: item.sa_saleareaid
- })
- }
- item.name = item.areaname
- item.isleave = this.data.isleave;
- this.getUsers(item.sa_saleareaid)
- this.setData({
- depGroud,
- takeEffect: "dep",
- result: item,
- selectDepObj: item
- })
- },
- selectUser(e) {
- const {
- item
- } = e.currentTarget.dataset;
- this.setData({
- 'users.active': item.userid,
- takeEffect: "user",
- result: item
- })
- },
- }
- })
|