import moment from 'moment'
import { sdLocalStorage } from '@/common/services/storage-service'
import { getUserInfo } from '@/common/store-mixin'
class SystemManage {
  // 审批表单和正文附件水印是否显示可分开配置
  getFormWaterMark() {
    return getWaterMarkContent('handleConfig')
  }

  getAttachmentWaterMark() {
    return getWaterMarkContent('attachmentConfig')
  }

  getPrintWaterMark() {
    return getWaterMarkContent('printConfig')
  }
}
function getWaterMarkContent(type) {
  const waterConfig = JSON.parse(sdLocalStorage.getItem('commonConfig') || '{}').oaWatermark
  if (waterConfig && waterConfig[type]) {
    let watermarkText = ''
    switch (waterConfig.waterContent) {
      case 'DEPTNAMEDATA':
        watermarkText =
          getUserInfo().deptName + ' ' + getUserInfo().name + ' ' + moment().format('YYYY-MM-DD')
        break
      case 'DEPTNAMETIME':
        watermarkText =
          getUserInfo().deptName + ' ' + getUserInfo().name + ' ' + moment().format('HH:mm:ss')
        break
      case 'NAMEDATE':
        watermarkText = getUserInfo().name + ' ' + moment().format('YYYY-MM-DD')
        break
      case 'NAMETIME':
        watermarkText = getUserInfo().name + ' ' + moment().format('HH:mm:ss')
        break
    }
    return watermarkText
  }
  return ''
}
export default new SystemManage()
