Accept Merge Request #868: (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/868?initial=true
This commit is contained in:
黄焱
2024-02-28 14:45:54 +08:00
committed by Coding

View File

@@ -59,6 +59,7 @@ $(function (){
}
}
})
function customRequired() {
let timer = null
let timer_count = 0
@@ -93,13 +94,59 @@ $(function (){
}
}, 500)
}
function setRequired(dom = {label: [], table: []}) {
let domTimer = null
let timer_count = 0
clearInterval(domTimer)
domTimer = setInterval(() => {
timer_count++
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)
})
}
if (table.length) {
table.forEach(_ => {
const th = $(`th[data-name=${_}]`)
const t = th.find('span').eq(0).text().replace('*','')
th.find('span').eq(0).html('<i style="color: red">*</i>' + t)
})
}
}
if (timer_count == 20) {
clearInterval(domTimer)
}
}, 500)
}
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]', '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']
}
const listenerUrl = setInterval(() => {
const isChange = currentUrl != location.href
if (isChange) {
currentUrl = location.href
customRequired()
setRequired(customRequiredDom)
}
if($('label[for=production_line_id]')) {
setRequired({table: [], label: ['label[for=production_line_id]']})
}
}, 500)
customRequired()
setRequired(customRequiredDom)
})