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 9825eeec..2bed0804 100644 --- a/jikimo_frontend/static/src/js/custom_form_status_indicator.js +++ b/jikimo_frontend/static/src/js/custom_form_status_indicator.js @@ -5,9 +5,44 @@ import {patch} from '@web/core/utils/patch'; import {_t} from "@web/core/l10n/translation"; import {FormStatusIndicator} from "@web/views/form/form_status_indicator/form_status_indicator"; +import {Field} from "@web/views/fields/field"; + var Dialog = require('web.Dialog'); // var {patch} = require("web.utils") 这句话也行 +const filedRequiredList = { + // 设备大模块 + 'control_system_id': { multiple: false, noLabel: false }, + 'workbench_L': { multiple: true, noLabel: false }, + 'number_of_axles': { multiple: true, noLabel: false }, + 'x_axis': { multiple: true, noLabel: false }, + 'number_of_knife_library': { multiple: false, noLabel: false }, + 'brand_id': { multiple: false, noLabel: false }, + 'type_id': { multiple: false, noLabel: false }, + 'taper_type_id': { multiple: false, noLabel: false }, + 'eq_maintenance_id': { multiple: false, noLabel: false }, + 'overhaul_id': { multiple: false, noLabel: false }, + 'overhaul_period': { multiple: false, noLabel: false }, + 'maintenance_equipment_category_id': { multiple: false, noLabel: false }, + 'maintenance_type': { multiple: false, noLabel: false }, + // 销售大模块 + 'partner_id': { multiple: false, noLabel: false }, + 'validity_date': { multiple: false, noLabel: false }, + 'vat': { multiple: false, noLabel: false }, + 'phone': { multiple: false, noLabel: false }, + 'mobile': { multiple: false, noLabel: false }, + 'email': { multiple: false, noLabel: false }, + 'category_id': { multiple: false, noLabel: false }, + 'radio_field_1_person': { multiple: false, noLabel: true }, + + // 采购大模块 + 'date_order': { multiple: false, noLabel: false }, + 'picking_type_id': { multiple: false, noLabel: false }, + + // 制造大模块 + 'production_line_id': { multiple: false, noLabel: false }, + 'date_approve': { multiple: false, noLabel: false }, +} patch(FormStatusIndicator.prototype, 'jikimo_frontend.FormStatusIndicator', { // 你可以重写或者添加一些方法和属性 async _onDiscardChanges() { @@ -46,6 +81,38 @@ 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); + }, + setRequired() { + const id = this.props.id + const isRequired = filedRequiredList[id] + if(id == 'number_of_axles') { + console.log(isRequired) + } + if(isRequired) { + let dom; + dom = $(`label[for=${id}]`) + if(isRequired.multiple && dom.length > 1) { + dom = dom.eq(-1) + dom = dom.parent().parent().next().find('label') + } + if(isRequired.noLabel) { + dom = dom.parent().parent() + } + let t = dom.html() + t = '*' + t + dom.html(t) + } + } +}) + $(function () { document.addEventListener('click', function () { @@ -82,7 +149,7 @@ $(function () { dom.each(function () { const requiredDom = $(this).parent().prev().find('label') let t = requiredDom.html() - if (t.indexOf('c*') < 0) { + if (t && t.indexOf('c*') < 0) { t = '*' + t } requiredDom.html(t) @@ -104,16 +171,7 @@ $(function () { const lint = $('.o_form_view_container') if (lint.length) { clearInterval(domTimer) - const {label, table} = dom - if (label.length) { - $(dom.label.join(',')).each(function () { - let t = $(this).html() - if (t.indexOf('c*') < 0) { - t = '*' + t - } - $(this).html(t) - }) - } + const { table} = dom if (table.length) { table.forEach(_ => { @@ -133,8 +191,7 @@ $(function () { var currentUrl = location.href const customRequiredDom = { - label: ['label[for=production_line_id]','label[for=date_approve]','label[for=partner_id]', 'label[for=validity_date]', '.o_horizontal[role=radiogroup][aria-label="公司类别"]', 'label[for=vat]', 'label[for=phone]', 'label[for=mobile]', 'label[for=email]', 'label[for=category_id]','label[for=date_order]','label[for=picking_type_id]'], - table: ['product_template_id', 'product_uom_qty', 'price_unit','product_id','product_qty'] + table: ['product_template_id', 'product_uom_qty', 'price_unit','product_id','product_qty', 'name', 'fault_type', 'maintenance_standards', 'Period'] } const listenerUrl = setInterval(() => { const isChange = currentUrl != location.href @@ -143,9 +200,6 @@ $(function () { customRequired() setRequired(customRequiredDom) } - if($('label[for=production_line_id]')) { - setRequired({table: [], label: ['label[for=production_line_id]']}) - } }, 500) customRequired() setRequired(customRequiredDom) diff --git a/sf_maintenance/views/equipment_maintenance_standards_views.xml b/sf_maintenance/views/equipment_maintenance_standards_views.xml index 413a863e..1af9bfc5 100644 --- a/sf_maintenance/views/equipment_maintenance_standards_views.xml +++ b/sf_maintenance/views/equipment_maintenance_standards_views.xml @@ -12,14 +12,14 @@ - + - + @@ -32,11 +32,11 @@ - - - - - + + + + + diff --git a/sf_maintenance/views/maintenance_views.xml b/sf_maintenance/views/maintenance_views.xml index c1e13d34..9233c7c9 100644 --- a/sf_maintenance/views/maintenance_views.xml +++ b/sf_maintenance/views/maintenance_views.xml @@ -60,9 +60,9 @@ - + + domain="[('brand_id', '=', brand_id)]" /> @@ -73,9 +73,9 @@ + options="{'no_create': True}" />