Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/优化cnc程序和检测文件
This commit is contained in:
@@ -9,67 +9,68 @@ var Dialog = require('web.Dialog');
|
|||||||
// var {patch} = require("web.utils") 这句话也行
|
// var {patch} = require("web.utils") 这句话也行
|
||||||
|
|
||||||
patch(FormStatusIndicator.prototype, 'jikimo_frontend.FormStatusIndicator', {
|
patch(FormStatusIndicator.prototype, 'jikimo_frontend.FormStatusIndicator', {
|
||||||
// 你可以重写或者添加一些方法和属性
|
// 你可以重写或者添加一些方法和属性
|
||||||
async _onDiscardChanges() {
|
async _onDiscardChanges() {
|
||||||
// var self = this;
|
// var self = this;
|
||||||
Dialog.confirm(this, _t("Are you sure you want to discard changes?"), {
|
Dialog.confirm(this, _t("Are you sure you want to discard changes?"), {
|
||||||
title: _t("Discard Changes"),
|
title: _t("Discard Changes"),
|
||||||
|
|
||||||
// confirm_callback: function () {
|
// confirm_callback: function () {
|
||||||
// self.model.discardChanges(self.handle);
|
// self.model.discardChanges(self.handle);
|
||||||
// },
|
// },
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
async discard() {
|
async discard() {
|
||||||
// if (window.confirm("Are you sure you want to discard changes?")) {
|
// if (window.confirm("Are you sure you want to discard changes?")) {
|
||||||
// await this.props.discard();
|
// await this.props.discard();
|
||||||
// }
|
// }
|
||||||
// const result = await this._confirmDiscardChange();
|
// const result = await this._confirmDiscardChange();
|
||||||
await this._confirmDiscardChange();
|
await this._confirmDiscardChange();
|
||||||
await this.props.discard();
|
await this.props.discard();
|
||||||
},
|
},
|
||||||
|
|
||||||
_confirmDiscardChange(){
|
_confirmDiscardChange() {
|
||||||
var self = this;
|
var self = this;
|
||||||
var def = new Promise(function (resolve, reject) {
|
var def = new Promise(function (resolve, reject) {
|
||||||
var message = _t("请确认是否要舍弃之前的更改?");
|
var message = _t("请确认是否要舍弃之前的更改?");
|
||||||
var dialog = Dialog.confirm(self, message, {
|
var dialog = Dialog.confirm(self, message, {
|
||||||
title: _t("Warning"),
|
title: _t("Warning"),
|
||||||
confirm_callback: resolve.bind(self, true),
|
confirm_callback: resolve.bind(self, true),
|
||||||
cancel_callback: reject,
|
cancel_callback: reject,
|
||||||
});
|
});
|
||||||
dialog.on('closed', self, reject);
|
dialog.on('closed', self, reject);
|
||||||
});
|
});
|
||||||
return def;
|
return def;
|
||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
$(function (){
|
$(function () {
|
||||||
document.addEventListener('click', function () {
|
document.addEventListener('click', function () {
|
||||||
const dom = $('.o_form_status_indicator_buttons ')
|
const dom = $('.o_form_status_indicator_buttons ')
|
||||||
if(dom) {
|
if (dom) {
|
||||||
const dom1 = dom.children().eq(0)
|
const dom1 = dom.children().eq(0)
|
||||||
const dom2 = dom.children().eq(1)
|
const dom2 = dom.children().eq(1)
|
||||||
if(!dom1.text()) {
|
if (!dom1.text()) {
|
||||||
dom1.append('保存')
|
dom1.append('保存')
|
||||||
dom2.append('取消')
|
dom2.append('取消')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
function customRequired() {
|
|
||||||
|
function customRequired() {
|
||||||
let timer = null
|
let timer = null
|
||||||
let timer_count = 0
|
let timer_count = 0
|
||||||
clearInterval(timer)
|
clearInterval(timer)
|
||||||
timer = setInterval(() => {
|
timer = setInterval(() => {
|
||||||
timer_count ++
|
timer_count++
|
||||||
const dom = $('.custom_required')
|
const dom = $('.custom_required')
|
||||||
let tableDom = $('.table_custom_required')
|
let tableDom = $('.table_custom_required')
|
||||||
if(tableDom.length) {
|
if (tableDom.length) {
|
||||||
tableDom = tableDom.eq(0).parents('tr').children('.table_custom_required')
|
tableDom = tableDom.eq(0).parents('tr').children('.table_custom_required')
|
||||||
tableDom.each(function (){
|
tableDom.each(function () {
|
||||||
const i = $(this).index()
|
const i = $(this).index()
|
||||||
const requiredDom = $(this).parents('table').find('thead').find('th').eq(i).find('span').eq(0)
|
const requiredDom = $(this).parents('table').find('thead').find('th').eq(i).find('span').eq(0)
|
||||||
const t = requiredDom.text().replace('*', '')
|
const t = requiredDom.text().replace('*', '')
|
||||||
@@ -77,29 +78,75 @@ $(function (){
|
|||||||
})
|
})
|
||||||
clearInterval(timer)
|
clearInterval(timer)
|
||||||
}
|
}
|
||||||
if(dom.length) {
|
if (dom.length) {
|
||||||
dom.each(function (){
|
dom.each(function () {
|
||||||
const requiredDom = $(this).parent().prev().find('label')
|
const requiredDom = $(this).parent().prev().find('label')
|
||||||
let t = requiredDom.html()
|
let t = requiredDom.html()
|
||||||
if(t.indexOf('c*') < 0) {
|
if (t.indexOf('c*') < 0) {
|
||||||
t = '<i class="c*" style="color: red;margin-left: -4px">*</i>' + t
|
t = '<i class="c*" style="color: red;margin-left: -4px">*</i>' + t
|
||||||
}
|
}
|
||||||
requiredDom.html(t)
|
requiredDom.html(t)
|
||||||
})
|
})
|
||||||
clearInterval(timer)
|
clearInterval(timer)
|
||||||
}
|
}
|
||||||
if(timer_count == 20) {
|
if (timer_count == 20) {
|
||||||
clearInterval(timer)
|
clearInterval(timer)
|
||||||
}
|
}
|
||||||
},500)
|
}, 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
|
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 listenerUrl = setInterval(() => {
|
||||||
const isChange = currentUrl != location.href
|
const isChange = currentUrl != location.href
|
||||||
if(isChange) {
|
if (isChange) {
|
||||||
currentUrl = location.href
|
currentUrl = location.href
|
||||||
customRequired()
|
customRequired()
|
||||||
|
setRequired(customRequiredDom)
|
||||||
|
}
|
||||||
|
if($('label[for=production_line_id]')) {
|
||||||
|
setRequired({table: [], label: ['label[for=production_line_id]']})
|
||||||
}
|
}
|
||||||
}, 500)
|
}, 500)
|
||||||
customRequired()
|
customRequired()
|
||||||
|
setRequired(customRequiredDom)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user