From ed8c39d005df6d7b408d768ac4797c44cd24fbd8 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Mon, 25 Mar 2024 16:17:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=91=98=E5=B7=A5=E6=A8=A1?= =?UTF-8?q?=E5=9D=97js=E9=97=AE=E9=A2=98=E3=80=81=E8=83=BD=E5=8A=9B?= =?UTF-8?q?=E7=89=B9=E5=BE=81=E5=93=ADjs=E9=97=AE=E9=A2=98=E3=80=81?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=A4=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../static/src/js/custom_form_status_indicator.js | 10 +++------- jikimo_frontend/static/src/js/custom_image_temp.js | 9 ++++++++- sf_maintenance/models/sf_maintenance.py | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/jikimo_frontend/static/src/js/custom_form_status_indicator.js b/jikimo_frontend/static/src/js/custom_form_status_indicator.js index 2bed0804..9ff98ca2 100644 --- a/jikimo_frontend/static/src/js/custom_form_status_indicator.js +++ b/jikimo_frontend/static/src/js/custom_form_status_indicator.js @@ -83,13 +83,9 @@ patch(FormStatusIndicator.prototype, 'jikimo_frontend.FormStatusIndicator', { ); patch(Field.prototype, 'jikimo_frontend.Field', { setup() { - this.FieldComponent = this.props.fieldInfo.FieldComponent; - if (!this.FieldComponent) { - const fieldType = this.props.record.fields[this.props.name].type; - this.FieldComponent = getFieldClassFromRegistry(fieldType, this.props.type); - } - owl.onMounted(this.setRequired); - }, + owl.onMounted(this.setRequired); + return this._super(...arguments); + }, setRequired() { const id = this.props.id const isRequired = filedRequiredList[id] diff --git a/jikimo_frontend/static/src/js/custom_image_temp.js b/jikimo_frontend/static/src/js/custom_image_temp.js index fba97121..16f7dab0 100644 --- a/jikimo_frontend/static/src/js/custom_image_temp.js +++ b/jikimo_frontend/static/src/js/custom_image_temp.js @@ -3,6 +3,13 @@ import { registry } from "@web/core/registry"; import { url } from "@web/core/utils/urls"; import { ImageField, imageCacheKey } from '@web/views/fields/image/image_field'; +import { isBinarySize } from "@web/core/utils/binary"; +export const fileTypeMagicWordMap = { + "/": "jpg", + R: "gif", + i: "png", + P: "svg+xml", +}; const placeholder = "/web/static/img/placeholder.png"; @@ -15,7 +22,7 @@ export class CustomImageField extends ImageField { getUrl(previewFieldName) { console.log('8888888888886666666666666666666') if (this.state.isValid && this.props.value) { - if (1) { + if (isBinarySize(this.props.value) || this.props.value.length < 50) { if (!this.rawCacheKey) { this.rawCacheKey = this.props.record.data.__last_update; } diff --git a/sf_maintenance/models/sf_maintenance.py b/sf_maintenance/models/sf_maintenance.py index 5b0db796..74da7742 100644 --- a/sf_maintenance/models/sf_maintenance.py +++ b/sf_maintenance/models/sf_maintenance.py @@ -148,7 +148,7 @@ class SfMaintenanceEquipment(models.Model): MTcode = fields.Char("机台编码") created_user = fields.Many2one('res.users', string='创建人', default=lambda self: self.env.user) equipment_type = fields.Selection([('机床', '机床'), ('机器人', '机器人'), ('AGV小车', 'AGV小车'), - ('检测设备', '检测设备')], compute='_compute_category_id') + ('检测设备', '检测设备'), ('其他', '其他')], compute='_compute_category_id') @api.depends('category_id') def _compute_category_id(self):