1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- export function getDyn(col, arr, comp) {
- let str = comp
- let is = true
- let type = ''
- for (let item of arr) {
- for (let itemChild of item.hrChildren) {
- for (let colItem of col) {
- if (itemChild.columnValue) {
- is = false
- }
- if (colItem == itemChild.columnName) {
- if (itemChild.htmlType == "input") {
- type = 1
- str = str.replace(itemChild.columnName, itemChild.columnValue)
- } else if (itemChild.htmlType == "datetime") {
- type = 2
- if(getTime(itemChild.columnValue)){
- str = str.replace(itemChild.columnName, getTime(itemChild.columnValue))
- }else{
- is=true
- }
- }
- }
- }
- }
- }
- if (is) {
- return
- }
- if (type == 2) {
- return setTime(evals(str))
- }
- return evals(str)
- }
- function evals(code) {
- let fun = new Function(`return ${code}`)();
- return fun
- }
- // 时间戳转成天
- function setTime(val) {
- return Number(val) / (1000 * 3600 * 24)
- }
- // 转化成时间戳
- function getTime(val) {
- var date = new Date(val);
- return date.getTime()
- }
- export function setDyn(col, arr, comp) {
- let str = comp
- for (let item of arr) {
- for (let itemChild of item.hrChildren) {
- for (let colItem of col) {
- if (colItem == itemChild.columnName) {
- str = str.replace(itemChild.columnName, itemChild.columnValue)
- }
- }
- }
- }
- return str
- }
|