优化label文本统一,编辑按钮增加经办人逻辑判断

This commit is contained in:
夜未央
2025-07-17 12:08:18 +08:00
parent c6e09dcdbd
commit ad06e1e245
2 changed files with 46 additions and 36 deletions
@@ -21,23 +21,28 @@
.o_action_manager .o_form_view_container .o_content .o_form_renderer .o_form_sheet_bg {
max-width: 80%;
margin: 0 auto;
}
.o_action_manager .o_form_view_container .o_content .o_form_renderer .o_form_sheet_bg .o_wrap_field .o_form_label {
width: 100px;
/* 固定宽度 */
text-align: justify;
/* 启用两端对齐 */
text-align-last: justify;
font-weight:700 !important;
opacity: 1 !important;
/* 最后一行也对齐 */
/* 解决单行文本需触发对齐的问题 */
&::after {
content: '';
display: inline-block;
width: 100%;
/* 撑满宽度,触发对齐 */
.o_form_sheet {
box-shadow: 0px 2px 11px 0px black;
}
.o_wrap_field .o_form_label {
/* 固定宽度 */
width: 100px;
/* 启用两端对齐 */
text-align: justify;
/* 最后一行也对齐 */
text-align-last: justify;
// 统一透明度
opacity: 1 !important;
font-weight: 600;
}
}
/* 添加红色星号在 label 后 */
.o_wrap_field:has(.o_required_modifier) label.o_form_label::after {
content: "*";
color: red;
}
//add end
@@ -95,26 +95,31 @@ patch(FormController.prototype, {
// }
// return true;
// }
etitButtonState() {
const hasWorkEnd = this.model.config.fields.work_end ? this.model.config.fields.work_end : this.props.fields.work_end;
if (hasWorkEnd) {
const redModel = this.model.config.resModel ? this.model.config.resModel : this.props.resModel;
const resId = this.model.config.resId ? this.model.config.resId : this.props.resId;
if (redModel && resId) {
this.orm.read(redModel, [resId], ["work_end"]).then((records) => {
const record = records[0];
if (record && record.work_end === true) {
this.buttonState.showEditButton = false;
} else {
this.buttonState.showEditButton = true;
}
})
} else {
this.buttonState.showEditButton = true;
async etitButtonState() {
const fields = this.model.config.fields || this.props.fields;
const resModel = this.model.config.resModel || this.props.resModel;
const resId = this.model.config.resId || this.props.resId;
const currentUserId = this.env.services.user.userId;
// 默认显示按钮
this.buttonState.showEditButton = true;
if (resModel && resId) {
// 1. 判断是否存在 self_users_ids(经办人)字段
if (fields.self_users_ids) {
const result = await this.orm.read(resModel, [resId], ["self_users_ids"]);
const selfUsers = result[0]?.self_users_ids || [];
if (!selfUsers.includes(currentUserId)) {
this.buttonState.showEditButton = false;
return; // 如果不是经办人,直接返回
}
}
// 2. 判断 work_end 字段是否存在,且是否为 true
if (fields.work_end) {
const result = await this.orm.read(resModel, [resId], ["work_end"]);
const record = result[0];
if (record && record.work_end === true) {
this.buttonState.showEditButton = false;
}
}
} else {
this.buttonState.showEditButton = true;
}
}
})
})