diff --git a/jikimo_frontend/__manifest__.py b/jikimo_frontend/__manifest__.py index e5424c39..5808f8eb 100644 --- a/jikimo_frontend/__manifest__.py +++ b/jikimo_frontend/__manifest__.py @@ -29,6 +29,7 @@ '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', + 'jikimo_frontend/static/src/js/custom_image_temp.js', 'jikimo_frontend/static/src/scss/rowno_in_tree.scss', # 'jikimo_frontend/static/src/views/list_nums/list_render.xml', # 'jikimo_frontend/static/src/list/list_up_down_button.xml', diff --git a/jikimo_frontend/static/src/js/custom_image.js b/jikimo_frontend/static/src/js/custom_image.js new file mode 100644 index 00000000..20d51d2e --- /dev/null +++ b/jikimo_frontend/static/src/js/custom_image.js @@ -0,0 +1,32 @@ +/** @odoo-module **/ + + +import {patch} from '@web/core/utils/patch'; +import { url } from "@web/core/utils/urls"; +import { ImageField, imageCacheKey } from '@web/views/fields/image/image_field'; + +patch(ImageField.prototype, 'jikimo_frontend/static/src/js/custom_image.js', { + // 你可以重写或者添加一些方法和属性 + getUrl(previewFieldName) { + console.log('666666666666666666666666666666666') + if (this.state.isValid && this.props.value) { + if (1) { + if (!this.rawCacheKey) { + this.rawCacheKey = this.props.record.data.__last_update; + } + return url("/web/image", { + model: this.props.record.resModel, + id: this.props.record.resId, + field: previewFieldName, + unique: imageCacheKey(this.rawCacheKey), + }); + } else { + // Use magic-word technique for detecting image type + const magic = fileTypeMagicWordMap[this.props.value[0]] || "png"; + return `data:image/${magic};base64,${this.props.value}`; + } + } + return placeholder; + } +} +); \ No newline at end of file diff --git a/jikimo_frontend/static/src/js/custom_image_temp.js b/jikimo_frontend/static/src/js/custom_image_temp.js new file mode 100644 index 00000000..60cc3425 --- /dev/null +++ b/jikimo_frontend/static/src/js/custom_image_temp.js @@ -0,0 +1,36 @@ +/** @odoo-module **/ + +import { registry } from "@web/core/registry"; +import { url } from "@web/core/utils/urls"; +import { ImageField, imageCacheKey } from '@web/views/fields/image/image_field'; + +export class CustomImageField extends ImageField { + setup() { + super.setup(); + // this.dialog = useService("dialog"); + } + + getUrl(previewFieldName) { + console.log('8888888888886666666666666666666') + if (this.state.isValid && this.props.value) { + if (1) { + if (!this.rawCacheKey) { + this.rawCacheKey = this.props.record.data.__last_update; + } + return url("/web/image", { + model: this.props.record.resModel, + id: this.props.record.resId, + field: previewFieldName, + unique: imageCacheKey(this.rawCacheKey), + }); + } else { + // Use magic-word technique for detecting image type + const magic = fileTypeMagicWordMap[this.props.value[0]] || "png"; + return `data:image/${magic};base64,${this.props.value}`; + } + } + return placeholder; + } +} + +registry.category("fields").add("custom_image", CustomImageField); \ No newline at end of file diff --git a/sf_base/views/tool_views.xml b/sf_base/views/tool_views.xml index 14c5ffd4..c9ea44e7 100644 --- a/sf_base/views/tool_views.xml +++ b/sf_base/views/tool_views.xml @@ -480,7 +480,7 @@ - +