Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/前端样式修改

# Conflicts:
#	sf_maintenance/views/equipment_maintenance_standards_views.xml

增加owl监听必填标识功能
This commit is contained in:
黄焱
2024-03-14 16:47:20 +08:00
18 changed files with 494 additions and 343 deletions

View File

@@ -5,9 +5,42 @@ 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 },
'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 +79,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 () {
@@ -104,16 +169,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,7 +189,6 @@ $(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', 'name', 'fault_type', 'maintenance_standards', 'Period']
}
const listenerUrl = setInterval(() => {
@@ -143,9 +198,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

@@ -4,6 +4,8 @@ import { registry } from "@web/core/registry";
import { url } from "@web/core/utils/urls";
import { ImageField, imageCacheKey } from '@web/views/fields/image/image_field';
const placeholder = "/web/static/img/placeholder.png";
export class CustomImageField extends ImageField {
setup() {
super.setup();