forked from ezreal/BI-FR-MIX-FRONT
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
4.2 KiB
106 lines
4.2 KiB
;!(function () { |
|
BI.Front = BI.Front || {}; |
|
BI.Front = BI.extend(BI.Front, { |
|
utils: { |
|
injectionFunc: function (o, configs) { |
|
if (BI.isNotEmptyArray(configs)) { |
|
BI.each(configs, function (index, item) { |
|
let functionName = item.functionName; |
|
if (functionName) { |
|
let oldFunction = o[functionName]; |
|
let beforeFunc = item.beforeFunc;//执行前的函数 |
|
let afterFunc = item.afterFunc;//执行后函数 |
|
let returnValue = item.returnValue;//是否返回值 |
|
let replaceFunc = item.replaceFunc;//替换函数,如果不传递那么就会执行下默认的 |
|
|
|
o[functionName] = function () { |
|
let para = []; |
|
let len = arguments.length; |
|
for (let i = 0; i < len; i++) { |
|
para.push(arguments[i]); |
|
} |
|
if (BI.isFunction(beforeFunc)) { |
|
beforeFunc.apply(o, para); |
|
} |
|
if (returnValue) { |
|
let value = null; |
|
if (BI.isFunction(replaceFunc)) { |
|
value = replaceFunc.apply(o, para); |
|
} else { |
|
value = oldFunction.apply(o, para); |
|
} |
|
if (BI.isFunction(afterFunc)) { |
|
para.unshift(value) |
|
value = afterFunc.apply(o, para); |
|
} |
|
return value; |
|
} else { |
|
if (BI.isFunction(replaceFunc)) { |
|
replaceFunc.apply(o, para); |
|
} else { |
|
oldFunction.apply(o, para); |
|
} |
|
if (BI.isFunction(afterFunc)) { |
|
afterFunc.apply(o, para); |
|
} |
|
} |
|
} |
|
} |
|
|
|
}) |
|
} |
|
} |
|
} |
|
}); |
|
$.extend(BI.Msg, { |
|
/** |
|
* 弹出框然后有个输入,确认返回输入的值 |
|
* @param title 标题 |
|
* @param content 标签 |
|
* @param callback 回调函数 |
|
* @param validationChecker 文本框的校验 |
|
*/ |
|
prompt: function (title, content, callback, config) { |
|
BI.Popovers.removeAll(); |
|
var id = BI.UUID(); |
|
var textEditor = { |
|
type: "bi.text_editor", |
|
ref: function (_ref) { |
|
BI[id] = _ref; |
|
}, |
|
width: 200, |
|
} |
|
textEditor = BI.extend(textEditor, config ? config : {}); |
|
|
|
var widget = BI.Popovers.create(id, { |
|
type: "bi.bar_popover", |
|
// String或者是json都行 |
|
header: title, |
|
size: "small", |
|
body: { |
|
type: "bi.horizontal", |
|
horizontalAlign: "center", |
|
verticalAlign: "middle", |
|
hgap: 10, |
|
items: [{ |
|
type: "bi.label", |
|
text: content, |
|
}, textEditor] |
|
}, |
|
listeners: [{ |
|
eventName: "EVENT_CANCEL", |
|
action: function () { |
|
|
|
} |
|
}, { |
|
eventName: "EVENT_CONFIRM", |
|
action: function () { |
|
BI.isFunction(callback) && callback(BI[id].getValue()); |
|
} |
|
}] |
|
}); |
|
widget.show(id); |
|
} |
|
}) |
|
|
|
})(); |