diff --git a/jikimo_frontend/static/src/js/custom_form_status_indicator.js b/jikimo_frontend/static/src/js/custom_form_status_indicator.js index 5d8b2fbf..3296b127 100644 --- a/jikimo_frontend/static/src/js/custom_form_status_indicator.js +++ b/jikimo_frontend/static/src/js/custom_form_status_indicator.js @@ -115,9 +115,20 @@ patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', { this.setRequired() this.listherHeaderBodyNum() }) - owl.onPatched(() => { + owl.onPatched(() => { 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); }, setRequired() { @@ -163,7 +174,58 @@ patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', { } catch (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"); + + // 提取 的 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', { get className() { @@ -176,7 +238,6 @@ patch(FormLabel.prototype, 'jikimo_frontend.FormLabel', { ); const classes = this.props.className ? [this.props.className] : []; const otherRequired = filedRequiredList[this.props.fieldName] - if(this.props.fieldInfo?.rawAttrs?.class?.indexOf('custom_required') >= 0 || otherRequired) { 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(`
-//
-// ${this.currentName} -//
-//
`) -// } -// } catch (e) { -// console.log(e) -// } -// } -// }) $(function () { diff --git a/sf_manufacturing/wizard/sale_order_cancel_views.xml b/sf_manufacturing/wizard/sale_order_cancel_views.xml index 134c524b..6848faf6 100644 --- a/sf_manufacturing/wizard/sale_order_cancel_views.xml +++ b/sf_manufacturing/wizard/sale_order_cancel_views.xml @@ -12,18 +12,18 @@ - - + + + + - -