12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- 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") {
- console.log(3)
- type = 1
- str = str.replace(itemChild.columnName, itemChild.columnValue)
- } else if (itemChild.htmlType == "datetime") {
- console.log(4)
- type = 2
- if(getTime(itemChild.columnValue)){
-
- str = str.replace(itemChild.columnName, itemChild.columnValue)
-
- // str = itemChild.columnValue
- // console.log(itemChild.columnValue, itemChild.columnName,19)
- console.log(str)
- }else{
- is=true
- }
- }else if(itemChild.htmlType == "datetime-date") {
- console.log(5)
- type = 3
- if (getTime(itemChild.columnValue)) {
- str = str.replace(itemChild.columnName, getTime(itemChild.columnValue))
- console.log(str,29)
- } else {
- is = true
- }
- }
- }
- }
- }
- }
- if (is) {
- return
- }
- if (type == 2) {
- // return setTimeH(evals(str))
- return str
- }
- if(type==3){
- return setTime(evals(str))
- }
- return evals(str)
- }
- function evals(code) {
- let fun = new Function(`return ${code}`)();
- return fun
- }
- // 时间戳转成天
- function setTime(val) {
- return Math.round(Number(val) / (1000 * 3600 * 24))
- }
- // 时间戳转成小时
- function setTimeH(val) {
- return Math.round(Number(val) / (1000 * 3600))
- }
- // 转化成时间戳
- 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
- }
|