This commit is contained in:
Eric 1549169735@qq.com
2026-09-13 20:08:13 +08:00
parent 7cc06976ab
commit da3f16e6db
65 changed files with 3855 additions and 2153 deletions

View File

@@ -43,9 +43,19 @@ var IqudooSalesScenario = (() => {
if (!this.state) throw new Error("SDK has not started");
return this.state;
}
getStage() {
const stage = this.getState().node.stage;
if (!stage) throw new Error("current node is not a script stage");
return stage;
}
async getCurrentNode() {
return this.update(`/public/runs/${this.getState().run_id}/current`);
}
/** Answer stage questions without advancing. Answer locally on the client and submit the whole stage once: pass every answered script in scriptAnswers together with dimensionSelects and the content form in answers. */
async answer(options = {}) {
const state = await this.update(`/public/runs/${this.getState().run_id}/answer`, { method: "POST", body: JSON.stringify({ node_key: this.getState().node.node_key, script_key: options.scriptKey || "", option_keys: options.optionKeys || [], value: options.value || "", script_answers: options.scriptAnswers || [], dimension_selects: options.dimensionSelects || {}, answers: options.answers || {}, dimension_value_key: options.dimensionValueKey || "", selected: options.selected ?? false }) });
return state;
}
async submit(values) {
const state = await this.update(`/public/runs/${this.getState().run_id}/submit`, { method: "POST", body: JSON.stringify({ node_key: this.getState().node.node_key, answers: values }) });
this.emit("form_submit", { values, state });
@@ -54,6 +64,13 @@ var IqudooSalesScenario = (() => {
async next() {
return this.update(`/public/runs/${this.getState().run_id}/next`, { method: "POST" });
}
async back() {
return this.update(`/public/runs/${this.getState().run_id}/back`, { method: "POST" });
}
async feedback(scriptKey, feedbackType, note = "") {
await this.request(`/public/runs/${this.getState().run_id}/feedback`, { method: "POST", body: JSON.stringify({ node_key: this.getState().node.node_key, script_key: scriptKey, feedback_type: feedbackType, note }) });
return true;
}
async finish(options = {}) {
const state = await this.update(`/public/runs/${this.getState().run_id}/finish`, { method: "POST", body: JSON.stringify({ result: options.result || "", final_result: options.finalResult ?? null }) });
this.emit("finish", state);