Accept Merge Request #1905: (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/1905
This commit is contained in:
黄焱
2025-03-13 16:14:31 +08:00
committed by Coding
2 changed files with 67 additions and 35 deletions

View File

@@ -118,6 +118,17 @@ patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', {
owl.onPatched(() => { owl.onPatched(() => {
this.listherHeaderBodyNum() this.listherHeaderBodyNum()
}) })
const treeModifiers = this.getFieldModifiers(this.props.archInfo.__rawArch);
// console.log('treeModifiers', treeModifiers);
if(treeModifiers) {
this.props.merge_key = treeModifiers.merge_key;
this.props.merge_fields = treeModifiers.merge_fields.split(',');
const data = this.setColumns(this.props.merge_key);
console.log('data', data);
owl.onMounted(() => {
this.mergeColumns(this.props.merge_fields, data)
})
}
return this._super(...arguments); return this._super(...arguments);
}, },
setRequired() { setRequired() {
@@ -163,7 +174,58 @@ patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', {
} catch (e) { } catch (e) {
console.log(e) console.log(e)
} }
},
setColumns( merge_key) {
const data = this.props.list.records
let sourceIndex = 0;
let sourceValue = ''
data.forEach((item, index) => {
if(!item.colspan) {
item.colspan = 1;
}
if(item.data[merge_key] === sourceValue) {
data[sourceIndex].colspan ++ ;
item.colspan = 0;
} else {
sourceIndex = index;
sourceValue = item.data[merge_key];
}
})
return data
},
getFieldModifiers(xmlString) {
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(xmlString, "text/xml");
// 提取 <tree> 的 modifiers
const treeElement = xmlDoc.querySelector("tree");
const treeModifiers = treeElement.getAttribute("modifiers");
if (treeModifiers) {
const parsedTreeModifiers = JSON.parse(treeModifiers);
console.log("Tree Modifiers:", parsedTreeModifiers);
return parsedTreeModifiers;
}
return null;
},
mergeColumns(merge_fields, data) {
const dom = this.tableRef.el
const thead = $(dom).children('thead')
const tbody = $(dom).children('tbody')
tbody.children('tr.o_data_row').each(function () {
const tr = $(this)
const td = tr.children('td')
const index = $(this).index()
td.each(function () {
if(merge_fields.indexOf($(this).attr('name')) >= 0) {
$(this).attr('rowspan', data[index].colspan)
if(data[index].colspan == 0) {
$(this).remove()
}
}
})
})
} }
}) })
patch(FormLabel.prototype, 'jikimo_frontend.FormLabel', { patch(FormLabel.prototype, 'jikimo_frontend.FormLabel', {
get className() { get className() {
@@ -176,7 +238,6 @@ patch(FormLabel.prototype, 'jikimo_frontend.FormLabel', {
); );
const classes = this.props.className ? [this.props.className] : []; const classes = this.props.className ? [this.props.className] : [];
const otherRequired = filedRequiredList[this.props.fieldName] const otherRequired = filedRequiredList[this.props.fieldName]
if(this.props.fieldInfo?.rawAttrs?.class?.indexOf('custom_required') >= 0 || otherRequired) { if(this.props.fieldInfo?.rawAttrs?.class?.indexOf('custom_required') >= 0 || otherRequired) {
classes.push('custom_required_add') classes.push('custom_required_add')
} }
@@ -193,35 +254,6 @@ patch(FormLabel.prototype, 'jikimo_frontend.FormLabel', {
} }
}) })
// 根据进度条设置水印
// const statusbar_params = {
// '已完工': 'bg-primary',
// '完成': 'bg-primary',
// '采购订单': 'bg-primary',
// '作废': 'bg-danger',
// '封存(报废)': 'bg-danger',
// }
// patch(StatusBarField.prototype, 'jikimo_frontend.StatusBarField', {
// setup() {
// owl.onMounted(this.ribbons);
// return this._super(...arguments);
// },
// ribbons() {
// try {
// const dom = $('.o_form_sheet.position-relative')
// const status = statusbar_params[this.currentName]
// if(status && dom.length) {
// dom.prepend(`<div class="o_widget o_widget_web_ribbon">
// <div class="ribbon ribbon-top-right">
// <span class="bg-opacity-75 ${status}" title="">${this.currentName}</span>
// </div>
// </div>`)
// }
// } catch (e) {
// console.log(e)
// }
// }
// })
$(function () { $(function () {

View File

@@ -12,18 +12,18 @@
<div class="alert alert-warning" role="alert"> <div class="alert alert-warning" role="alert">
<field name="display_message" readonly="1" nolabel="1"/> <field name="display_message" readonly="1" nolabel="1"/>
</div> </div>
<field name="related_docs"> <field name="related_docs" >
<tree string="下游单据" create="false" edit="false" delete="false"> <tree string="下游单据" create="false" edit="false" delete="false" attrs="{'merge_fields': 'category,doc_name,operation_type,doc_number,doc_state, cancel_reason', 'merge_key': 'doc_number'}">
<!-- <field name="sequence" string="序号"/> --> <!-- <field name="sequence" string="序号"/> -->
<field name="category" string="大类"/> <field name="category" string="大类"/>
<field name="doc_name" string="单据名称"/> <field name="doc_name" string="单据名称"/>
<field name="operation_type" string="作业类型"/> <field name="operation_type" string="作业类型"/>
<field name="doc_number" string="单据编号"/> <field name="doc_number" string="单据编号"/>
<field name="doc_state" string="单据状态"/>
<field name="cancel_reason" string="禁止取消原因"/>
<field name="line_number" string="行号"/> <field name="line_number" string="行号"/>
<field name="product_name" string="产品名称"/> <field name="product_name" string="产品名称"/>
<field name="quantity_str" string="数量"/> <field name="quantity_str" string="数量"/>
<field name="doc_state" string="单据状态"/>
<field name="cancel_reason" string="禁止取消原因"/>
</tree> </tree>
</field> </field>
<footer> <footer>