123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- import request from '../../../util/http'
- import apiUrl from '../../../util/apiUrl'
- var app = getApp();
- Page({
- data: {
- listShow:false,//是否有多个客户
- noCustomerList:false,
- unSetModal:false,//未设置服务者提醒
- unSetBtn: [
- { text: '现在关联', extClass: 'buttonBold' },
- { text: '暂不' },
- ],
- editModalShow:false,//编辑弹框
- customerName:'',//编辑客户姓名输入
- buttonFooter:[
- { text: '取消' },
- { text: '确定', extClass: 'buttonBold' },
- ],
- bindModalShow:false,//关联雇主弹框
- bindCode:'',
- bindName:'',
- customerList:[
- ],
- emReNo:''//编辑信息的雇佣关系编号
- },
- onLoad() {
- // this.initCustomerList();
- },
- onShow(){
- this.initCustomerList();
- },
- initCustomerList(){
- let params={
- "servantId":app.globalData.userInfo.id,
- "pageNo": 1,
- "pageSize": 100,
- }
- request.httpServicePost(apiUrl.findByServantIdListPath,params).then(data=>{
- console.log(data);
- if(data.dataList.length==0){
- this.setData({
- listShow:false,
- noCustomerList:true,
- unSetModal:true,
- });
- }else{
- this.setData({
- listShow:true,
- noCustomerList:false,
- unSetModal:false,
- customerList:data.dataList
- });
- // my.alert({
- // content:JSON.stringify(data.dataList)
- // });
- }
- }).catch(e=>{
- console.log(e);
-
- })
- },
- editCustomer(e){
- console.log(e);
- this.setData({
- editModalShow:true,
- // customerName:e.target.dataset.emName,
- emReNo:e.target.dataset.emReNo,
- });
-
- },
- onModalClose(e){
- console.log(e.target);
- if(e.target.dataset.index==0){
- this.setData({
- editModalShow: false,
- });
- }else{
- // 保存客户姓名
- this.editEmployerSubmit();
-
- }
-
- },
- // 编辑雇主提交
- editEmployerSubmit(){
- let params={
- "employerName":this.data.customerName,
- "employRelationNo": this.data.emReNo,
- }
- request.httpServicePost(apiUrl.updateEmployerNamePath,params).then(data=>{
- console.log(data);
- this.setData({
- editModalShow: false,
- });
- my.showToast({
- content: '修改成功',
- });
- // 修改成功后刷新页面
- this.initCustomerList();
- }).catch(e=>{
- console.log(e);
-
- })
- },
- bindKeyInput(e) {
- this.setData({
- customerName: e.detail.value,
- });
- console.log(this.data.customerName);
- },
- bindCodeInput(e) {
- this.setData({
- bindCode: e.detail.value,
- });
- console.log(this.data.bindCode);
- },
- bindNameInput(e) {
- this.setData({
- bindName: e.detail.value,
- });
- },
- // 添加新客户
- bindNewCustomer(){
- this.setData({
- bindModalShow: true,
- bindCode:'',
- bindName:''
- });
- },
- onBindModalClose(e){
- console.log(e.target);
- if(e.target.dataset.index==0){
- this.setData({
- bindModalShow: false,
- });
- }else{
- // 关联雇主
- if(this.data.bindCode==''){
- my.alert({
- content:'请输入关联码'
- });
- }else if(this.data.bindName==''){
- my.alert({
- content:'请输入雇主称呼'
- });
- }else{
- this.bindNow();
- }
- }
-
- },
- // 进入工作台
- enterServantCenter(e){
- let emReNo=e.target.dataset.emReNo;
- my.navigateTo({
- url: '../servantCenter/servantCenter?emReNo='+emReNo
- });
- },
- bindNow(){
-
- let params={
- "servantId":app.globalData.userInfo.id,
- "employerName":this.data.bindName,
- "employIdentifier": this.data.bindCode,
- }
- request.httpServicePost(apiUrl.relationEmployerPath,params).then(data=>{
- console.log(data);
- this.setData({
- bindModalShow: false,
- });
- my.showToast({
- content: '关联成功',
- });
- // 关联成功后刷新页面
- this.initCustomerList();
- }).catch(e=>{
- console.log(e);
-
- })
- },
- enterServantCenter(e){
- let emReNo=e.target.dataset.emReNo;
- my.navigateTo({ url: '../servantCenter/servantCenter?emReNo='+emReNo });
- },
- // 点击设置按钮
- onSetButtonClick(e){
- console.log(e.target);
- if(e.target.dataset.index==0){
- this.setData({
- unSetModal: false,
- bindModalShow:true,
- bindCode:'',
- bindName:''
- });
-
- }else{
- this.setData({
- unSetModal: false
-
- });
- }
- },
- // 切换角色
- switchRole(){
- my.navigateTo({ url: '../../common/selectRole/selectRole' });
- }
- });
|