Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/优化表面工艺可选参数

This commit is contained in:
jinling.yang
2024-03-15 10:48:58 +08:00
3 changed files with 87 additions and 34 deletions

View File

@@ -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 = '<i class="c* r" style="color: red;margin-left: -4px">*</i>' + 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 = '<i class="c*" style="color: red;margin-left: -4px">*</i>' + 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 = '<i class="c*" style="color: red;margin-left: -6px;margin-right: 2px">*</i>' + 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)

View File

@@ -12,14 +12,14 @@
<group>
<field name="code" readonly="1" force_save="1"/>
<field name="name" readonly="1" force_save="1"/>
<field name="maintenance_equipment_category_id" required="1" class="custom_required"/>
<field name="maintenance_equipment_category_id" required="1" />
<field name="eq_maintenance_ids" invisible='1'/>
<field name="overhaul_ids" invisible='1'/>
</group>
<group>
<field name="maintenance_type" required="1" class="custom_required"/>
<field name="maintenance_type" required="1"/>
<field name="created_user_id"/>
<field name="remark"/>
</group>
@@ -32,11 +32,11 @@
<page string="维保项目">
<field name="maintenance_standards_ids" delete="1">
<tree editable="bottom">
<field name="name" class="table_custom_required"/>
<field name="fault_type" class="table_custom_required"/>
<field name="maintenance_standards" class="table_custom_required"/>
<field name="Period" class="table_custom_required"/>
<tree editable="bottom" >
<field name="name" />
<field name="fault_type" />
<field name="maintenance_standards" />
<field name="Period" />
</tree>
</field>
</page>

View File

@@ -60,9 +60,9 @@
<field name="function_type"/>
<field name="code" readonly="1"/>
<field name="equipment_type" invisible="1"/>
<field name="brand_id" force_save="1" class="custom_required"/>
<field name="brand_id" force_save="1" />
<field name="type_id" attrs="{'required': [('equipment_type', '=', '机床')]}"
domain="[('brand_id', '=', brand_id)]" class="custom_required"/>
domain="[('brand_id', '=', brand_id)]" />
<field name="machine_tool_category" readonly="1" attrs="{'invisible': [('type_id', '=', False)]}"
force_save="1"/>
<field name="run_time" force_save="1"/>
@@ -73,9 +73,9 @@
<group>
<group string="基础参数">
<field name="control_system_id" attrs="{'required': [('equipment_type', '=', '机床')]}"
options="{'no_create': True}" class="custom_required"/>
options="{'no_create': True}" />
<label for="workbench_L" string="工作台尺寸(mm)"/>
<div class="test_model custom_required">
<div class="test_model">
<label for="workbench_L" string="长"/>
<field name="workbench_L" class="o_address_zip"
attrs="{'required': [('equipment_type', '=', '机床')]}"
@@ -134,7 +134,7 @@
<!-- <field name="guide_rail" required="1"/>-->
<field name="number_of_axles" attrs="{'required': [('equipment_type', '=', '机床')]}"
widget="radio"
options="{'horizontal': true}" class="custom_required"/>
options="{'horizontal': true}" />
<label for="x_axis" string="加工行程(mm)"
attrs="{'invisible': [('number_of_axles', '=', False)]}"/>
<div class="test_model"
@@ -177,8 +177,7 @@
<group string="刀具">
<!-- <field name="knife_type" required="1"/>-->
<field name="number_of_knife_library"
attrs="{'required': [('equipment_type', '=', '机床')]}"
class="custom_required"/>
attrs="{'required': [('equipment_type', '=', '机床')]}"/>
<!-- <field name="tool_speed" required="1"/>-->
<field name="tool_full_diameter_max"/>
<field name="tool_perimeter_diameter_max"/>
@@ -198,7 +197,7 @@
<field name="C_tool_time"/>
</group>
<group string="主轴">
<field name="taper_type_id" attrs="{'required': [('equipment_type', '=', '机床')]}" class="custom_required"/>
<field name="taper_type_id" attrs="{'required': [('equipment_type', '=', '机床')]}" />
<label for="distance_min" string="主轴端面-工作台距离(mm)"/>
<div class="test_model">
<label for="distance_min" string="最小(min)"/>
@@ -982,16 +981,16 @@
<xpath expr="//field[@name='next_action_date']" position="before">
<field name='eq_maintenance_id' force_save="1" widget="many2one" class="custom_required"/>
<field name='eq_maintenance_id' force_save="1" widget="many2one"/>
</xpath>
<xpath expr="//div[hasclass('o_row')][field[@name='maintenance_duration']]" position="after">
<field name='overhaul_id' class="custom_required"/>
<field name='overhaul_id'/>
<field name="overhaul_date" string="下次预防检修"/>
<label for="overhaul_period" string="预防检修频次" class="custom_required"/>
<label for="overhaul_period" string="预防检修频次"/>
<div class="o_row">
<field name="overhaul_period"/>
days