根据你的需求,想要在点击“上一步”和“下一步”按钮时重新调用接口以更新参数。你可以在 self.getContactInfoGridSettings()
中添加对接口的调用,确保每次点击按钮时都能获取到最新的数据。
下面是如何修改你的代码,以确保在按钮点击时都会调用相应的接口:
self.getContactInfoGridSettings = ggNamespace.functions.WorkPage_getContactInfoGridSettings;
self.lastButton.addClickHandler(function() {
if (currentIndexs > 0) {
currentIndexs--;
} else {
currentIndexs = allData.length - 1;
}
updateContactPhonePanel();
});
self.nextButton.addClickHandler(function() {
if (currentIndexs < allData.length - 1) {
currentIndexs++;
} else {
currentIndexs = 0;
}
updateContactPhonePanel();
});
function updateContactPhonePanel() {
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();
}
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;
};
修改说明:
- 将重复代码提取到一个名为
updateContactPhonePanel
的函数中,以便在“上一步”和“下一步”按钮的事件处理程序中都可以调用。 - 确保每次更新联系人面板后,都调用
getContactInfoGridSettings
方法,这样就会触发 AJAX 请求来获取最新数据。
希望这些修改能够满足你的需求!如果有其他问题,请随时告诉我。
内容由零声教学AI助手提供,问题来源于学员提问