ZBLOG

self.getContactInfoGridSettings = ggNamespace.functions.WorkPage_getContactInfoGridSettings; self.lastButton.addClickHandler(function() { if (currentIndexs > 0) { currentIndexs--; } else { currentIndexs = allData.length - 1; } ...

你可以在现有的代码中,调整 self.getContactInfoGridsettings 方法,使其在点击“上一步”和“下一步”按钮时都会重新调用接口并更新参数。以下是修改后的代码示例:

self.getContactInfoGridSettings = ggNamespace.functions.WorkPage_getContactInfoGridSettings;

// 统一的方法来获取联系人信息
function updateContactInfo() {
    self.contactPhones = new ContactPhonePanel({
        custId: allData[currentIndexs].customerId,
        queue: self.queue,
        complaintPhone: self.complaintPhone,
        complaintPhoneNew: self.complaintPhoneNew,
        complaintUsername: self.complaintUsername,
        complaintRelation: self.complaintRelation,
        auto: self.auto,
        callPhone: (phoneNum, customerId) => self.header.callPhone(phoneNum, customerId)
    });
    // 调用获取设置的方法
    self.getContactInfoGridsettings();
}

self.lastButton.addClickHandler(function() {
    if (currentIndexs > 0) {
        currentIndexs--;
    } else {
        currentIndexs = allData.length - 1;
    }
    updateContactInfo(); // 更新联系人信息
});

self.nextButton.addClickHandler(function() {
    if (currentIndexs < allData.length - 1) {
        currentIndexs++;
    } else {
        currentIndexs = 0;
    }
    updateContactInfo(); // 更新联系人信息
});

ggNamespace.functions.WorkPage.getContactInfoGridsettings = function() {
    const me = this;
    let settings;
    const columns = [];
    
    settings = {
        columns: columns,
        processing: true,
        serverSide: true,
        ajax: {
            url: '../d/detail/contacts',
            contentType: 'application/json',
            type: 'POST',
            lang: defLanguage,
            complete: function() {
                me.contacts = {
                    contactPersons: {},
                    contactNumbers: {},
                    contactIndexs: {},
                    ptpCode: 'promiseToPay',
                    callbackCode: 'callbackRequest',
                    contactPersonIds: {}
                };

                me.mobileContacts = {
                    contactPersons: {},
                    contactNumbers: {},
                    contactPersonIds: {}
                };
                
                me.phoneNumbers = {};
                me.detailAddresses = {};
                me.phoneNumberIndexes = {};
                me.phoneNumberIndexesForSms = {};
                me.contactPersonAddresses = {};
                
                const selfPhoneNumberArr = [];
                var result = me.contactPhones.contactInfo.getRecords();
                
            }
        }
    };

    return settings;
};

修改说明:

  • 抽取方法:创建了一个名为 updateContactInfo 的方法,用于处理更新联系人的逻辑,避免代码重复。
  • 按钮事件:在上一步和下一步按钮的点击事件中,调用 updateContactInfo() 来重新赋值参数并触发数据更新。

这样做后,当用户点击“上一步”或“下一步”按钮时,相关的联系人信息将会被重新加载并更新。


内容由零声教学AI助手提供,问题来源于学员提问

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:https://golang.0voice.com/?id=20277

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?