From 749473f9dc52e26963152748272a0bb8d4362e63 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Mon, 23 Oct 2023 00:17:05 +0800 Subject: [PATCH] =?UTF-8?q?form=E8=A7=86=E5=9B=BE=E7=9A=84=E4=B8=A2?= =?UTF-8?q?=E5=BC=83=E6=8C=89=E9=92=AE=E5=A2=9E=E5=8A=A0=E4=BA=8C=E6=AC=A1?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jikimo_frontend/__manifest__.py | 1 + .../src/js/custom_form_status_indicator.js | 49 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 jikimo_frontend/static/src/js/custom_form_status_indicator.js diff --git a/jikimo_frontend/__manifest__.py b/jikimo_frontend/__manifest__.py index f2096eea..4165a503 100644 --- a/jikimo_frontend/__manifest__.py +++ b/jikimo_frontend/__manifest__.py @@ -27,6 +27,7 @@ 'jikimo_frontend/static/src/views/list_nums/list_nums.xml', 'jikimo_frontend/static/src/views/list_nums/list_nums2.xml', 'jikimo_frontend/static/src/views/list_nums/list_nums3.xml', + 'jikimo_frontend/static/src/js/custom_form_status_indicator.js', ], }, diff --git a/jikimo_frontend/static/src/js/custom_form_status_indicator.js b/jikimo_frontend/static/src/js/custom_form_status_indicator.js new file mode 100644 index 00000000..fd06fe75 --- /dev/null +++ b/jikimo_frontend/static/src/js/custom_form_status_indicator.js @@ -0,0 +1,49 @@ +/** @odoo-module */ + +import {patch} from '@web/core/utils/patch'; +// import { Dialog } from "@web/core/dialog/dialog"; +import {_t} from "@web/core/l10n/translation"; +import {FormStatusIndicator} from "@web/views/form/form_status_indicator/form_status_indicator" + +var Dialog = require('web.Dialog'); +// var {patch} = require("web.utils") 这句话也行 + +patch(FormStatusIndicator.prototype, 'jikimo_frontend.FormStatusIndicator', { + // 你可以重写或者添加一些方法和属性 + async _onDiscardChanges() { + var self = this; + Dialog.confirm(this, _t("Are you sure you want to discard changes?"), { + title: _t("Discard Changes"), + + // confirm_callback: function () { + // self.model.discardChanges(self.handle); + // }, + }); + }, + + async discard() { + // if (window.confirm("Are you sure you want to discard changes?")) { + // await this.props.discard(); + // } + const result = await this._confirmDiscardChange(); + await this.props.discard(); + }, + + _confirmDiscardChange(){ + var self = this; + var def = new Promise(function (resolve, reject) { + var message = _t("请确认是否要舍弃之前的更改?"); + var dialog = Dialog.confirm(self, message, { + title: _t("Warning"), + confirm_callback: resolve.bind(self, true), + cancel_callback: reject, + }); + dialog.on('closed', self, reject); + }); + return def; + }, + +} +); + +