123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- // miniprogram/checkdesigner/checkdesigner.js
- const utils = require("../../utils/http");
- const util = require("../../utils/util");
- const app = getApp();
- Component({
- /**
- * 组件的属性列表
- */
- properties: {
- multiple: {
- type: Boolean,
- value: true
- },
- filterable: {
- type: Boolean,
- value: false
- },
- title: {
- type: String,
- value: "请选择人员"
- },
- type: {
- type: String,
- value: "1"
- },
- showSelect: {
- type: Boolean,
- value: true
- }
- },
- /**
- * 组件的初始数据
- */
- data: {
- showTime: true,
- result: [],
- itemStr: "",
- pid: "",
- searchVal: "",
- item: {},
- itemArr: [],
- departArr: {},
- departmentObj: {}
- },
- lifetimes: {
- attached: function () {
- // 在组件实例进入页面节点树时执行
- this.getDepart();
- },
- detached: function () {
- // 在组件实例被从页面节点树移除时执行
- },
- },
- /**
- * 组件的方法列表
- */
- methods: {
- doneFunc: function() {},
- closeComponent: function() {
- this.triggerEvent('close');
- },
- onChange: function (e) {
- let itemArr = []
- e.detail.forEach(v => {
- let textStr = v.split('$');
- itemArr.push({name: textStr[0],id: textStr[1]});
- })
- this.setData({
- result: e.detail,
- itemArr: itemArr
- });
- },
- onRadioChange: function(e) {
- let textStr = e.detail.split('$');
- let itemObj = {name: textStr[0],id: textStr[1]}
- this.setData({
- itemStr: e.detail,
- item: itemObj,
- });
- },
- onInputChange: function(e) {
- this.setData({
- searchVal: e.detail
- })
- },
- onSearch: function() {
- this.getDepart();
- },
- getDepart: function () {
- const that = this;
- let apiUrl = "";
- let dataObj = {};
- if (this.data.type == '1') {
- apiUrl = 'api/crm_customer/get_setting';
- dataObj = {
- name: that.data.searchVal
- };
- } else if (this.data.type == '2') {
- apiUrl = "api/designer/list";
- dataObj = {
- keyword: that.data.searchVal,
- org_type: 1
- };
- }
- utils.$post({
- url: app.globalData.webUrl + apiUrl,
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: dataObj,
- success: function (res) {
- if (res.data.code == 0) {
- if (that.data.type == '1') {
- that.setData({
- departArr: res.data.data.employees,
- departmentObj: res.data.data.employees
- })
- }
- if (that.data.type == '2') {
- that.setData({
- departArr: res.data.data,
- departmentObj: res.data.data
- })
- }
- }
- }
- })
- },
- nextDepart: function (e) {
- let item = e.currentTarget.dataset.item;
- if (item.designer_num == 0) {
- wx.showToast({
- title: '此部门人数为0,不能选择!',
- icon: "none",
- duration: 1500
- })
- return;
- }
- this.setData({
- pid: item.pid,
- departmentObj: item,
- showTime: false
- })
- setTimeout(() => {
- this.setData({
- showTime: true,
- })
- },800)
- },
- lastStepFuc: function () {
- if (this.data.pid == 0) {
- this.setData({
- pid: null,
- departmentObj: this.data.departArr,
- showTime: false
- })
- setTimeout(() => {
- this.setData({
- showTime: true,
- })
- },600)
- } else {
- this.getlastItemFunc(this.data.departArr);
- }
- },
- getlastItemFunc: function (obj) {
- let itemObj = {};
- if (obj.child_org && obj.child_org.length) {
- obj.child_org.forEach(item => {
- if (item.id == this.data.pid) {
- this.setData({
- departmentObj: item,
- pid: item.pid,
- showTime: false
- })
- setTimeout(() => {
- this.setData({
- showTime: true,
- })
- },600)
- return;
- }
- if (item.child_org && item.child_org.length) {
- this.getlastItemFunc(item)
- }
- if (this.data.departArr.child_org.length && (this.data.departArr.child_org[0].pid == this.data.pid)) {
- this.setData({
- pid: null,
- departmentObj: this.data.departArr,
- showTime: false
- })
- setTimeout(() => {
- this.setData({
- showTime: true,
- })
- },600)
- }
- })
- }
- },
- submitDataFunc: function () {
- if (this.data.multiple) {
- this.triggerEvent('submit',this.data.itemArr);
- } else {
- this.triggerEvent('submit',this.data.item);
- }
- }
- }
- })
|