Accept Merge Request #1811: (feature/前端样式修改 -> develop)

Merge Request: 合并销售订单列,修改必填*展示方法,

Created By: @黄焱
Reviewed By: @马广威
Approved By: @马广威 
Accepted By: @黄焱
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1811?initial=true
This commit is contained in:
黄焱
2025-02-17 16:06:47 +08:00
committed by Coding
6 changed files with 66 additions and 16 deletions

View File

@@ -1,3 +1,8 @@
.o_list_renderer .o_list_table tbody > tr > td:not(.o_list_record_selector):not(.o_handle_cell):not(.o_list_button):not(.o_list_record_remove){
border:1px solid #dee2e6 !important;
}
.custom_required_add::before{
content: '*';
color: red;
}

View File

@@ -6,6 +6,8 @@ import {_t} from "@web/core/l10n/translation";
import {FormStatusIndicator} from "@web/views/form/form_status_indicator/form_status_indicator";
import {ListRenderer} from "@web/views/list/list_renderer";
// import {StatusBarField} from "@web/views/fields/statusbar/statusbar_field";
import {FormLabel} from "@web/views/form/form_label";
import { fieldVisualFeedback } from "@web/views/fields/field";
import {Field} from "@web/views/fields/field";
@@ -115,9 +117,6 @@ patch(Field.prototype, 'jikimo_frontend.Field', {
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}]`)
@@ -191,7 +190,31 @@ patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', {
}
}
})
patch(FormLabel.prototype, 'jikimo_frontend.FormLabel', {
get className() {
const { invalid, empty, readonly } = fieldVisualFeedback(
this.props.fieldInfo.FieldComponent,
this.props.record,
this.props.fieldName,
this.props.fieldInfo
);
const classes = this.props.className ? [this.props.className] : [];
if(this.props.fieldInfo?.rawAttrs?.class?.indexOf('custom_required') >= 0) {
classes.push('custom_required_add')
}
if (invalid) {
classes.push("o_field_invalid");
}
if (empty) {
classes.push("o_form_label_empty");
}
if (readonly) {
classes.push("o_form_label_readonly");
}
return classes.join(" ");
}
})
// 根据进度条设置水印
// const statusbar_params = {
@@ -231,7 +254,6 @@ $(function () {
clearInterval(timer)
timer = setInterval(() => {
timer_count++
const dom = $('.custom_required')
let tableDom = $('.table_custom_required')
if (tableDom.length) {
tableDom = tableDom.eq(0).parents('tr').children('.table_custom_required')
@@ -243,17 +265,6 @@ $(function () {
})
clearInterval(timer)
}
if (dom.length) {
dom.each(function () {
const requiredDom = $(this).parent().prev().find('label')
let t = requiredDom.html()
if (t && t.indexOf('c*') < 0) {
t = '<i class="c*" style="color: red;margin-left: -4px">*</i>' + t
}
requiredDom.html(t)
})
clearInterval(timer)
}
if (timer_count == 20) {
clearInterval(timer)
}

View File

@@ -28,6 +28,7 @@
'web.assets_backend': [
'sf_sale/static/js/setTableWidth.js',
'sf_sale/static/src/css/purchase_list.css',
'sf_sale/static/lib/*',
]
},
'demo': [

View File

@@ -0,0 +1,18 @@
/** @odoo-module */
import { Component } from "@odoo/owl";
import { registry } from "@web/core/registry";
export class MergeField extends Component {
get mergeValue() {
const data = this.props.record.data;
const v = data?.product_uom_qty
const unit = data?.product_uom[1]
return `${v} ${unit}`
}
}
MergeField.template = "jikimo_sf.MergeField";
registry.category("fields").add("merge_field", MergeField);

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="jikimo_sf.MergeField" owl="1">
<span t-esc="mergeValue"/>
</t>
</templates>

View File

@@ -123,6 +123,13 @@
<field name="manual_quotation" readonly="1"/>
<field name="is_incoming_material" readonly="1"/>
</xpath>
<xpath expr="//field[@name='order_line']/tree/field[@name='product_uom_qty']" position="replace">
<field name="product_uom_qty" string="数量" widget="merge_field" optional="show" />
</xpath>
<xpath expr="//field[@name='order_line']/tree/field[@name='product_uom']" position="attributes">
<attribute name="optional">hide</attribute>
</xpath>
<field name="user_id" position="attributes">
<attribute name="attrs">{'readonly': [('state', 'in', ['cancel','sale'])]}</attribute>
</field>