R/uiGen.R

Defines functions uiTemplate uiScrollX uiGen3 uiGen

Documented in uiGen uiGen3 uiScrollX uiTemplate

#' ui界面生成器
#'
#' @param tabTitle  页面标题 
#' @param colTitles 分栏标题
#' @param widthRates 两栏左右比
#' @param func_left 左边函数
#' @param func_right 右边函数
#'
#' @return 返回数据
#' @export
#'
#' @examples
#' uiGen()
uiGen <- function(tabTitle ='物料编码生成器',
                  colTitles =c('操作区域','报表区域'),
                  widthRates=c(6,6),
                  func_left,
                  func_right) {
  res = tabPanel(tabTitle,tagList(
    fluidRow(column(widthRates[1],box(
      title = colTitles[1], width = NULL, solidHeader = TRUE, status = "primary",
      func_left()
    )),
    column(widthRates[2], box(
      title = colTitles[2], width = NULL, solidHeader = TRUE, status = "primary",
      func_right()
    )
    ))
    
  ))
  return(res)
  
}

#' ui界面生成器
#'
#' @param tabTitle  页面标题 
#' @param colTitles 分栏标题
#' @param widthRates 两栏左右比
#' @param func_left 左边函数
#' @param func_right 右边函数
#'
#' @return 返回数据
#' @export
#'
#' @examples
#' uiGen3()
uiGen3 <- function(tabTitle ='物料编码生成器',
                  colTitles =c('操作区域','报表区域','结果区域'),
                  widthRates=c(6,6,12),
                  func_left,
                  func_right,
                  func_bottom) {
  res = tabPanel(tabTitle,tagList(
    fluidRow(column(widthRates[1],box(
      title = colTitles[1], width = NULL, solidHeader = TRUE, status = "primary",
      func_left()
    )),
    column(widthRates[2], box(
      title = colTitles[2], width = NULL, solidHeader = TRUE, status = "primary",
      func_right()
    )
    )),
    fluidRow(column(widthRates[3],box(
      title = colTitles[3], width = NULL, solidHeader = TRUE, status = "primary",
      func_bottom()
    ))
    )
    
  ))
  return(res)
  
}


#' 添加相应的滚动功能
#'
#' @param uiElement 
#'
#' @return 返回值
#' @import shiny
#' @export
#'
#' @examples
#' uiScrollX()
uiScrollX <- function(uiElement) {
  
  res <- div(style = 'overflow-x: scroll', uiElement)
  return(res)
  
}



#' 设置下载模板
#'
#' @param templateName 模板名称
#'
#' @return 返回值
#' @export
#'
#' @examples
#' uiTemplate()
uiTemplate <- function(templateName='abc') {
  url = paste0(templateName,".xlsx")
  tip = paste0("第一次使用,请下载",templateName)
  
  res = tags$a(href=url,tip)
  return(res)
  
}
takewiki/tsui documentation built on July 5, 2023, 10:59 p.m.