修复image小组件图片路径拼接失败的问题
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
'jikimo_frontend/static/src/views/list_nums/list_nums2.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/views/list_nums/list_nums3.xml',
|
||||||
'jikimo_frontend/static/src/js/custom_form_status_indicator.js',
|
'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/scss/rowno_in_tree.scss',
|
||||||
# 'jikimo_frontend/static/src/views/list_nums/list_render.xml',
|
# 'jikimo_frontend/static/src/views/list_nums/list_render.xml',
|
||||||
# 'jikimo_frontend/static/src/list/list_up_down_button.xml',
|
# 'jikimo_frontend/static/src/list/list_up_down_button.xml',
|
||||||
|
|||||||
32
jikimo_frontend/static/src/js/custom_image.js
Normal file
32
jikimo_frontend/static/src/js/custom_image.js
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
36
jikimo_frontend/static/src/js/custom_image_temp.js
Normal file
36
jikimo_frontend/static/src/js/custom_image_temp.js
Normal file
@@ -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);
|
||||||
@@ -480,7 +480,7 @@
|
|||||||
<tree string="能力特征库" editable="bottom" delete="0" create="0">
|
<tree string="能力特征库" editable="bottom" delete="0" create="0">
|
||||||
<field name="name" readonly="1"/>
|
<field name="name" readonly="1"/>
|
||||||
<field name="type" readonly="1"/>
|
<field name="type" readonly="1"/>
|
||||||
<field name="image" widget="image" readonly="1"/>
|
<field name="image" widget="custom_image" readonly="1"/>
|
||||||
<field name="equipment_id"/>
|
<field name="equipment_id"/>
|
||||||
<field name="active" invisible="1"/>
|
<field name="active" invisible="1"/>
|
||||||
</tree>
|
</tree>
|
||||||
|
|||||||
Reference in New Issue
Block a user