Преглед изворни кода

用户选择器回显组织树搜索高级搜索

cyy пре 2 година
родитељ
комит
ba7ce226f2

+ 1 - 1
src/business/platform/form/constants/fieldOptions.js

@@ -225,7 +225,7 @@ export const selectorTypeOptions = [{
 },
 {
   value: 'position',
-  label: '岗位'
+  label: '部门'
 },
 {
   value: 'role',

+ 142 - 43
src/business/platform/org/selector/employee.vue

@@ -19,6 +19,7 @@
           <!-- 搜索框 -->
           <van-search
             v-model="search"
+            :disabled="currentOrgIdValue===''?false:$store.getters.isSuper?false:!isUseScope"
             :placeholder="searchPlaceholder"
             show-action
             @search="onSearch"
@@ -164,9 +165,9 @@
     />
     <!--左树-->
     <tree-popup
+      ref="elTree"
       :visible="treeVisible"
       :range.sync="partyType"
-
       :script="script"
       :is-use-scope="isUseScope"
       :party-type-id="partyTypeId"
@@ -182,7 +183,9 @@
 </template>
 <script>
 import { query } from '@/api/platform/org/user'
+import { queryWoutOrg, queryPageList, queryWithOrg4Position } from '@/api/platform/org/employee'
 import { get as getUserById } from '@/api/platform/org/employee'
+import panelTree from './popup-tree/mixins/otherTreeEven'
 // import { getScriptValue as getTreeDataByScriptValue } from '@/api/platform/form/common'
 import ActionUtils from '@/utils/action'
 import i18n from '@/utils/i18n' // Internationalization 国际化
@@ -201,6 +204,7 @@ export default {
     IbpsMoreSearch,
     TreePopup
   },
+  mixins: [panelTree],
   props: {
     showPopup: Boolean,
     multiple: Boolean,
@@ -241,6 +245,7 @@ export default {
       type: Boolean,
       default: false
     },
+    seetingSearchPartyType: String, // 设置查询用户类型
     partyTypeScope: String,
     script: String,
     partyTypeId: [String, Number],
@@ -252,13 +257,20 @@ export default {
 
   },
   data() {
+    const { first = '', second = '' } = this.$store.getters.level
+    const { isSuper = false } = this.$store.getters
+    let level = second || first
+    if (isSuper) {
+      level = null
+    }
     return {
+      level,
       search: '',
       partyId: '',
       moreParams: {},
       moreSearchPopup: false,
       treeVisible: false,
-      partyType: 'org',
+      partyType: 'position',
 
       listData: [],
       pagination: {},
@@ -276,10 +288,11 @@ export default {
       searchForms: {
         forms: [
           { prop: 'Q^ACCOUNT_^SL', label: '账号' },
-          { prop: 'Q^EMAIL_^SL', label: '邮箱' },
-          { prop: 'Q^WC_ACCOUNT_^SL', label: '微信账户' },
-          { prop: 'Q^QQ_^SL', label: 'QQ' },
-          { prop: 'Q^MOBILE_^SL', label: '电话' },
+          // { prop: 'Q^PARTY_ALIAS_^SL', label: ''}
+          // { prop: 'Q^EMAIL_^SL', label: '邮箱' },
+          // { prop: 'Q^WC_ACCOUNT_^SL', label: '微信账户' },
+          // { prop: 'Q^QQ_^SL', label: 'QQ' },
+          // { prop: 'Q^MOBILE_^SL', label: '电话' },
           {
             prop: 'Q^GENDER_^S',
             label: '性别',
@@ -296,7 +309,10 @@ export default {
       initPage: false,
       showSelectorPopup: false,
       showDetailPopup: false,
-
+      partyTypeIdValue: '',
+      currentOrgIdValue: '',
+      scriptValue: '',
+      moreSearchParams: {},
       currentFilterOption: []
 
     }
@@ -311,7 +327,8 @@ export default {
           return ''
         }
         const checked = this.checkbox[0]
-        return this.$utils.isNotEmpty(checked) ? this.cacheData[checked] ? this.cacheData[checked][this.labelKey] : '' : ''
+        const cuser = this.listData.find(i => i.id === checked)
+        return this.$utils.isNotEmpty(checked) ? this.cacheData[checked] ? this.cacheData[checked][this.labelKey] ? this.cacheData[checked][this.labelKey] : '' : cuser.name : ''
       }
     },
     selectedData() {
@@ -322,6 +339,16 @@ export default {
     listDatas() {
       return this.listData
     }
+    // changeParams() {
+    //   const { partyTypeId, currentOrgId, isUseScope, script, partyTypeScope } = this
+    //   return {
+    //     partyTypeId,
+    //     currentOrgId,
+    //     isUseScope,
+    //     script,
+    //     partyTypeScope
+    //   }
+    // }
   },
   watch: {
     value(val, oldVal) {
@@ -413,48 +440,108 @@ export default {
      */
     loadData() {
       this.loading = true
-      const partyType = this.partyType
-      query(partyType, this.getFormatParams()).then(response => {
-        ActionUtils.handleListData(this, response.data)
-        // 缓存
-        if (this.$utils.isNotEmpty(this.listData)) {
-          this.listData.forEach((d) => {
-            this.cacheData[d[this.valueKey]] = d
-          })
+      let type = this.partyType
+      // query(partyType, this.getFormatParams()).then(response => {
+      //   ActionUtils.handleListData(this, response.data)
+      //   console.log(response.data, 'response.dataresponse.dataresponse.data')
+      //   // 缓存
+      //   if (this.$utils.isNotEmpty(this.listData
+      //     this.listData.forEach((d) => {
+      //       this.cacheData[d[this.valueKey]] = d
+      //     })
+      //   }
+      // }).catch((e) => {
+      //   ActionUtils.handleErrorData(this, e)
+      // })
+      console.log(this.treeVisible, '|', this.partyType, '|', this.partyId, '|', this.isUseScope, '|', this.currentOrgIdValue, '|', this.partyTypeIdValue, '|', this.seetingSearchPartyType, 'dddddddddddddd')
+      if (!this.treeVisible) {
+        if (this.$utils.isNotEmpty(this.partyId) || this.isUseScope) {
+          type = this.partyType
+        } else if (this.currentOrgIdValue && this.currentOrgIdValue !== '') {
+          type = 'org'
         }
-      }).catch((e) => {
-        ActionUtils.handleErrorData(this, e)
-      })
+        let flag = 0
+        if (type === 'position' && !this.partyId && this.partyTypeIdValue === '1') {
+          type = 'user'
+          flag = '1'
+        }
+        query(type, this.getFormatParams(flag)).then(response => {
+          this.loading = false
+          ActionUtils.handleListData(this, response.data)
+          this.setSelectRow()
+        }).catch(() => {
+          this.loading = false
+        })
+      } else if (this.seetingSearchPartyType === 'position') {
+        queryWithOrg4Position(this.getFormatParams()).then(response => {
+          this.loading = false
+          ActionUtils.handleListData(this, response.data)
+          this.setSelectRow()
+        }).catch(() => {
+          this.loading = false
+        })
+      } else if (this.$utils.isNotEmpty(this.currentOrgIdValue)) {
+        queryWoutOrg(this.getFormatParams()).then(response => {
+          this.loading = false
+          ActionUtils.handleListData(this, response.data)
+          this.setSelectRow()
+        }).catch(() => {
+          this.loading = false
+        })
+      } else {
+        queryPageList(this.getFormatParams('1')).then(response => {
+          this.loading = false
+          ActionUtils.handleListData(this, response.data)
+          this.setSelectRow()
+        }).catch(() => {
+          this.loading = false
+        })
+      }
     },
     /**
      * 获取查询条件格式化参数
      */
-    getFormatParams() {
-      const params = {}
-      const key = this.partyType === 'org' ? 'orgId'
-        : this.partyType === 'position' ? 'positionId'
-          : this.partyType === 'role' ? 'roleId'
-            : this.partyType === 'group' ? 'groupId' : ''
-
-      if (this.$utils.isNotEmpty(this.partyId) || this.currentOrgId !== '') {
-        if (this.partyId !== 0 && this.partyId !== '0') {
-          params[key] = this.partyId === '' ? this.currentOrgId : this.partyId
+    getFormatParams(flag = '0') {
+      const storeGetters = this.$store.getters
+      const params = this.$refs['crud'] ? this.$refs['crud'].getSearcFormData() : {}
+      const key = this.partyType === 'org' ? 'orgId' : this.partyType === 'position' ? 'positionId' : this.partyType === 'role' ? 'roleId' : this.partyType === 'group' ? 'groupId' : ''
+      const deptLists = storeGetters.deptList.map((m) => {
+        return m.positionId
+      })
+      if (!this.treeVisible) {
+        if (this.$utils.isNotEmpty(this.partyId) || this.currentOrgIdValue !== '') {
+          if (this.partyId !== 0 && this.partyId !== '0') {
+            params[key] = this.partyId === '' ? this.currentOrgIdValue : this.partyId
+          }
+          if (!this.partyId && this.partyTypeId === '2' && this.partyType === 'position') {
+            const position = storeGetters.userInfo.employee.positions
+            params.positionId = position
+          }
+        } else {
+          if (this.partyType === 'position') {
+            params[key] = this.partyTypeId ? (this.partyTypeId === '1' ? '' : this.partyTypeId) : deptLists.join(',')
+          } else {
+            params[key] = this.partyTypeId === '1' ? '' : this.partyTypeId
+          }
         }
-      } else {
-        params[key] = this.partyTypeId === '1' ? '' : this.partyTypeId
       }
-      if (this.$utils.isNotEmpty(this.search)) {
-        params['Q^FULL_NAME_^SL'] = this.search
+      if (this.seetingSearchPartyType === 'position') {
+        params['positionId'] = this.partyTypeId
       }
-
-      if (this.moreParams) {
-        Object.assign(params, this.moreParams)
+      if (this.moreSearchParams && Object.keys(this.moreSearchParams).length !== 0) {
+        Object.assign(params, this.moreSearchParams)
       }
-
-      return ActionUtils.formatParams(
-        params,
-        this.pagination,
-        this.sorts)
+      // if (this.$utils.isNotEmpty(this.currentOrgId)) {
+      //   params['orgId'] = this.partyId || this.currentOrgId
+      // }
+      const res = ActionUtils.formatParams(params, this.pagination, this.sorts)
+      // 数据过滤
+      if (this.level && (flag === '1' || this.partyType === 'role')) {
+        res.customs = {
+          position: this.level
+        }
+      }
+      return res
     },
     /**
      * 下拉刷新
@@ -470,6 +557,12 @@ export default {
      */
     onSearch() {
       this.stateActive = false
+      this.moreSearchParams = this.search === '' ? {} : { 'Q^NAME_^SL': this.search }
+      if (this.moreParams && Object.keys(this.moreParams).length !== 0) {
+        Object.keys(this.moreParams).forEach(key => {
+          this.moreSearchParams[key] = this.moreParams[key]
+        })
+      }
       ActionUtils.initListData(this)
       this.loadData()
     },
@@ -478,6 +571,7 @@ export default {
      */
     onMoreSearch(params) {
       this.moreParams = params
+      console.log(params, '.....params,,,,,')
       this.onSearch()
       if (this.$utils.isNotEmpty(params)) {
         this.stateActive = true
@@ -504,6 +598,7 @@ export default {
       }
     },
     toggle(data, index) {
+      console.log(this.multiple, '2222222222')
       if (!this.multiple) {
         this.$refs.checkboxGroup.toggleAll(false)
       }
@@ -537,7 +632,10 @@ export default {
       this.$emit('cancel')
     },
     onConfirm() {
-      const data = this.multiple ? this.checkbox : [this.radio]
+      // const data = this.multiple ? this.checkbox : [this.radio]
+      const data = this.checkbox
+
+      console.log(this.multiple, this.listData, this.checkbox, data, this.radio, 'this.multiplethis.multiple')
       const arr = []
       if (this.multiple) {
         for (let i = 0; i < this.listData.length; i++) {
@@ -550,11 +648,12 @@ export default {
         }
       } else {
         for (let j = 0; j < this.listData.length; j++) {
-          if (this.listData[j].id === this.radio) {
+          if (data.length > 0 && this.listData[j].id === data[0]) {
             arr.push(this.listData[j])
             break
           }
         }
+        console.log(arr, 'arrrrrrrr')
       }
       this.$emit('confirm', arr)
       this.$emit('callbackData', arr)

+ 3 - 1
src/business/platform/org/selector/index.vue

@@ -426,6 +426,7 @@ export default {
     },
     getStoreValue(value) {
       const res = []
+      console.log(this.valueKey, value, this.store, this.storeSeparator)
       if (this.store === 'json') { // json
         if (this.$utils.isEmpty(value)) {
           return ''
@@ -518,14 +519,15 @@ export default {
       this._setInputValue()
     },
     removeData(index) {
-      console.log(this.selectedData, this.selectedValue, index, '11212121212')
       this.selectedData.splice(index, 1)
+      console.log(this.selectedData, this.selectedValue, index, '11212121212')
       const mid = []
       this.selectedData.forEach((it, i) => {
         mid.push(it.id)
       })
       this.selectedValue.length = 0
       this.selectedValue = mid
+      console.log(this.getStoreValue(this.selectedData))
       this.$emit('input', this.getStoreValue(this.selectedData))
     },
 

+ 1 - 1
src/business/platform/org/selector/popup-tree/index.vue

@@ -114,7 +114,7 @@ export default {
         label: 'name',
         isLeaf: 'leaf'
       },
-      partyType: 'org',
+      partyType: 'position',
 
       partyOptions: this.partyTypeOptions,
       lazyTree: true,

+ 81 - 16
src/business/platform/org/selector/popup-tree/mixins/otherTreeEven.js

@@ -57,13 +57,14 @@ export default {
       }).then(response => {
         const data = JSON.parse(response.data)
         this.treeData = TreeUtils.transformToTreeFormat(data.data)
-        this.setTree(this.partyType === 'org', this.treeData)
+        this.setTree(this.partyType === 'position', this.treeData)
         this.scriptExecuteTime = once
       })
     },
     // 树属性方法动态调整
     setTree(lazy, data) {
-      const ref = this.$refs.ibpsTree
+      console.log(data, 'datadata')
+      const ref = this.$refs.elTree
       ref.store.lazy = lazy
       ref.store.defaultExpandAll = !lazy
       ref.store.defaultExpandedKeys = lazy ? ['0'] : null
@@ -85,22 +86,21 @@ export default {
       // this.inclueChild = true
       this.partyId = ''
       this.treeData = []
-
       if (this.partyType === 'org') {
         this.lazyTree = true
         this.defaultExpandedKeys = ['0']
         this.defaultExpandAll = false
         this.loadOrgTreeData(init, resetParams)
+      } else if (this.partyType === 'position') {
+        this.lazyTree = true
+        this.defaultExpandedKeys = ['0']
+        this.defaultExpandAll = true
+        this.loadPositionTreeData(init, resetParams)
       } else {
         this.lazyTree = false
         this.defaultExpandedKeys = null
         this.defaultExpandAll = true
-        if (this.partyType === 'position') {
-          this.lazyTree = true
-          this.defaultExpandedKeys = ['0']
-          this.defaultExpandAll = false
-          this.loadPositionTreeData(init, resetParams)
-        } else if (this.partyType === 'role') {
+        if (this.partyType === 'role') {
         // this.inclueChild = false
           this.loadRoleTreeData()
         } else if (this.partyType === 'group') {
@@ -108,6 +108,7 @@ export default {
           this.loadGroupTreeData()
         }
       }
+      // this.loadData()
     },
     // 加载机构树
     loadOrgTreeData(init) {
@@ -198,7 +199,7 @@ export default {
       })
     },
     // 加载岗位树
-    loadPositionTreeData(init, resetParams) {
+    loadPositionTreeData(init, resetParams = false) {
       const type = this.partyTypeIdValue !== '' ? this.partyTypeIdValue : '1'
       this.loadingTree = true
       this.hiddenTree = true
@@ -214,12 +215,19 @@ export default {
         params.includeSub = false
       }
       getPositionTreeData(params).then(response => {
+        const data = response.data
+        data.forEach((item) => {
+          if (item.name === '岗位树') {
+            item.name = '部门树'
+            item.title = '部门树'
+          }
+        })
         this.loadingTree = false
         this.hiddenTree = false
         // 普通模式
         if (!this.isUseScope) {
           if (!init) {
-            const data = response.data
+            // const data = response.data
             this.treeData = TreeUtils.transformToTreeFormat(data)
             this.setTree(true, this.treeData)
           }
@@ -227,12 +235,12 @@ export default {
         } else {
         // 选择器范围模式
           if (resetParams) {
-            const data = response.data
+            // const data = response.data
             this.treeData = TreeUtils.transformToTreeFormat(data)
             this.setTree(true, this.treeData)
           } else {
             if (!init) {
-              const data = response.data
+              // const data = response.data
               this.treeData = TreeUtils.transformToTreeFormat(data)
               this.setTree(true, this.treeData)
             }
@@ -249,6 +257,7 @@ export default {
     },
     // 岗位树节点函数
     loadPosTreeNode(node, resolve) {
+      console.log(node, 'nodenodenodenode')
       let params = {}
       const type = this.partyTypeIdValue !== '' ? this.partyTypeIdValue : '1'
       if (this.isUseScope) {
@@ -280,12 +289,27 @@ export default {
         getPositionTreeData(params).then(res => {
           this.loadingTree = false
           const arr = JSON.parse(JSON.stringify(res.data))
+          let arrList
+          const frist = this.$store.getters.level.first || ''
+          if ((type === '1' || type === '2') && this.filtrate && frist) {
+            const showBoo = arr.some((item) => item.id === frist)
+            if (showBoo) {
+              arrList = arr.filter((item) => item.id === frist)
+            } else {
+              arrList = arr
+            }
+          } else {
+            arrList = arr
+          }
+          if (type === '2') {
+            this.getPosiData(arrList, true)
+          }
           let treeData
           if (this.$utils.isEmpty(node.data)) {
-            treeData = arr
+            treeData = arrList
             resolve(this.toTree(treeData))
           } else {
-            treeData = type !== '2' ? arr : this.filterPositionTreeChildren(arr, 'root')
+            treeData = type !== '2' ? arrList : this.filterPositionTreeChildren(arrList, 'root')
             resolve(this.toTree(treeData))
           }
         }).catch(res => {
@@ -301,13 +325,54 @@ export default {
         getPositionTreeData(params).then(res => {
           this.loadingTree = false
           const arr = JSON.parse(JSON.stringify(res.data))
-          resolve(this.toTree(arr))
+          let arrList = []
+          const second = this.$store.getters.level.second || ''
+          if ((type === '1' || type === '2') && this.filtrate && second) {
+            const showBoo = arr.some((item) => item.id === second)
+            if (showBoo) {
+              arrList = arr.filter((item) => item.id === second)
+            } else {
+              arrList = arr
+            }
+          } else {
+            arrList = arr
+          }
+          if (type === '2') {
+            this.getPosiData(arrList, node.data.disabled)
+          }
+          resolve(this.toTree(arrList))
         }).catch(res => {
           this.loadingTree = false
           resolve([])
         })
       }
     },
+    getPosiData(arrList, disabled) {
+      const positions = this.$store.getters.userInfo.employee.positions
+      if (positions) {
+        const positionsList = positions.split(',')
+        positionsList.forEach(item => {
+          const index = arrList.findIndex(it => it.id === item)
+          if (index >= 0) {
+            arrList[index].disabled = true
+          }
+        })
+      }
+      // 如果上级可以选择 也就是 disabled false,下级一定是false
+      if (!disabled) {
+        arrList.forEach(item => {
+          item.disabled = false
+        })
+      } else {
+        arrList.forEach(item => {
+          if (item.disabled) {
+            item.disabled = false
+          } else {
+            item.disabled = true
+          }
+        })
+      }
+    },
     // 加载角色树
     loadRoleTreeData() {
       if (this.isUseScope) {

+ 2 - 2
src/business/platform/org/selector/tree.vue

@@ -75,7 +75,7 @@ export default {
             text: '组织',
             value: 'org'
           }, {
-            text: '岗位',
+            text: '部门',
             value: 'position'
           }, {
             text: '角色',
@@ -97,7 +97,7 @@ export default {
         children: 'children',
         label: 'name'
       },
-      partyType: 'org',
+      partyType: 'position',
 
       lazyTree: true,
       defaultExpandedKeys: ['0'],

+ 98 - 98
src/utils/common.js

@@ -1,51 +1,51 @@
 // 通用工具类,定义通用函数及常用接口
-import { mapValues } from "lodash";
-import { encryptByAes } from "@/utils/encrypt";
+import { mapValues } from 'lodash'
+import { encryptByAes } from '@/utils/encrypt'
 // import { preview } from '@/business/platform/form/utils/custom/preview'
-import request from "./joinCURD";
-import pinyin4js from "pinyin4js";
-import { snapshoot } from "@/api/platform/file/attachment";
-import { getNextIdByAlias } from "@/api/platform/system/identity";
-import { save as sendMsg } from "@/api/platform/message/innerMessage";
-import { save as saveNews } from "@/api/platform/system/news";
-import { bpmTaskSave } from "@/api/platform/bpmn/bpmTask";
+import request from './joinCURD'
+import pinyin4js from 'pinyin4js'
+// import { snapshoot } from "@/api/platform/file/attachment";
+import { getNextIdByAlias } from '@/api/platform/system/identity'
+import { save as sendMsg } from '@/api/platform/message/innerMessage'
+import { save as saveNews } from '@/api/platform/system/news'
+import { bpmTaskSave } from '@/api/platform/bpmn/bpmTask'
 // import { onlyOfficeToPdf } from '@/api/platform/form/seal'
-import { downloadFile as download } from "@/business/platform/file/utils";
+import { downloadFile as download } from '@/business/platform/file/utils'
 // import { removeFormData } from '@/api/platform/data/dataTemplate'
 // 引入工具类
-import Utils from "@/utils/util";
-import ActionUtils from "@/utils/action";
+import Utils from '@/utils/util'
+import ActionUtils from '@/utils/action'
 
 // base64解码
 const decode = str =>
   decodeURIComponent(
     window
       .atob(str)
-      .split("")
+      .split('')
       .map(c => `%${`00${c.charCodeAt(0).toString(16)}`.slice(-2)}`)
-      .join("")
-  );
+      .join('')
+  )
 
 // 下载
 export const downloadByBlob = (o, name) => {
   if (!(o instanceof Blob)) {
-    return;
+    return
   }
 
   if (window.navigator.msSaveBlob) {
-    window.navigator.msSaveBlob(o, name);
+    window.navigator.msSaveBlob(o, name)
   } else {
-    const URL = window.URL || window.webkitURL || window;
-    const e = document.createElementNS("http://www.w3.org/1999/xhtml", "a");
-    e.href = URL.createObjectURL(o);
-    e.download = name;
+    const URL = window.URL || window.webkitURL || window
+    const e = document.createElementNS('http://www.w3.org/1999/xhtml', 'a')
+    e.href = URL.createObjectURL(o)
+    e.download = name
 
     if (document.all) {
-      e.click();
+      e.click()
     } else {
-      const ev = document.createEvent("MouseEvents");
+      const ev = document.createEvent('MouseEvents')
       ev.initMouseEvent(
-        "click",
+        'click',
         true,
         false,
         window,
@@ -59,54 +59,54 @@ export const downloadByBlob = (o, name) => {
         false,
         0,
         null
-      );
-      e.dispatchEvent(ev);
+      )
+      e.dispatchEvent(ev)
     }
   }
-};
+}
 
 // 获取当前时间
 export const getDateNow = (length = 10, formatType) => {
-  if (formatType === "string") {
+  if (formatType === 'string') {
     return new Date(new Date().getTime() + 28800000)
       .toJSON()
       .slice(0, length)
-      .replace(/[-:T]/g, "");
+      .replace(/[-:T]/g, '')
   }
   return new Date(new Date().getTime() + 28800000)
     .toJSON()
     .slice(0, length)
-    .replace("T", " ");
-};
+    .replace('T', ' ')
+}
 
 // 获取指定值后的日期
 export const getDate = (type, value, date) => {
-  const d = date || getDateNow(19);
+  const d = date || getDateNow(19)
   if (
-    typeof type !== "string" ||
+    typeof type !== 'string' ||
     !Number.isInteger(value) ||
-    typeof d !== "string"
+    typeof d !== 'string'
   ) {
-    console.log("参数类型错误");
-    return null;
+    console.log('参数类型错误')
+    return null
   }
-  const now = new Date(d);
+  const now = new Date(d)
   const D = {
     day: value * 24 * 60 * 60 * 1000,
     hour: value * 60 * 60 * 1000,
     minute: value * 60 * 1000,
     second: value * 1000
-  };
-  const year = now.getFullYear();
-  const month = now.getMonth();
-  const day = now.getDate();
-  const hour = now.getHours();
-  const minute = now.getMinutes();
-  const second = now.getSeconds();
+  }
+  const year = now.getFullYear()
+  const month = now.getMonth()
+  const day = now.getDate()
+  const hour = now.getHours()
+  const minute = now.getMinutes()
+  const second = now.getSeconds()
 
   switch (type) {
-    case "year": {
-      const isLeapYear = new Date(year + value, 1, 29).getDate() === 29;
+    case 'year': {
+      const isLeapYear = new Date(year + value, 1, 29).getDate() === 29
       return new Date(
         year + value,
         isLeapYear && month === 1 && day === 29 ? 1 : month,
@@ -114,19 +114,19 @@ export const getDate = (type, value, date) => {
         hour,
         minute,
         second
-      );
+      )
     }
-    case "month": {
-      let newYear = year;
-      let newMonth = month + value;
+    case 'month': {
+      let newYear = year
+      let newMonth = month + value
       if (newMonth < 0) {
-        newYear -= Math.ceil(Math.abs(newMonth) / 12);
-        newMonth = 12 - (Math.abs(newMonth) % 12);
+        newYear -= Math.ceil(Math.abs(newMonth) / 12)
+        newMonth = 12 - (Math.abs(newMonth) % 12)
       } else if (newMonth > 11) {
-        newYear += Math.floor(newMonth / 12);
-        newMonth = newMonth % 12;
+        newYear += Math.floor(newMonth / 12)
+        newMonth = newMonth % 12
       }
-      const isLeapMonth = new Date(newYear, newMonth + 1, 0).getDate() === 29;
+      const isLeapMonth = new Date(newYear, newMonth + 1, 0).getDate() === 29
       return new Date(
         newYear,
         isLeapMonth && month === 1 && day === 29 ? 1 : newMonth,
@@ -134,62 +134,62 @@ export const getDate = (type, value, date) => {
         hour,
         minute,
         second
-      );
+      )
     }
-    case "day":
-    case "hour":
-    case "minute":
-    case "second":
-      return new Date(now.getTime() + D[type]);
+    case 'day':
+    case 'hour':
+    case 'minute':
+    case 'second':
+      return new Date(now.getTime() + D[type])
     default:
-      console.log("无效的日期类型");
-      return null;
+      console.log('无效的日期类型')
+      return null
   }
-};
+}
 
 // 时间格式化
 export const getFormatDate = (type, length, date = new Date()) => {
-  const now = new Date(new Date(date).getTime());
+  const now = new Date(new Date(date).getTime())
   // eslint-disable-next-line
-  if (now == "Invalid Date") {
-    console.log("非法日期,无法格式化");
-    return date;
+  if (now == 'Invalid Date') {
+    console.log('非法日期,无法格式化')
+    return date
   }
-  const year = now.getFullYear();
-  const month = now.getMonth() + 1;
-  const day = now.getDate();
-  const hours = now.getHours();
-  const minutes = now.getMinutes();
-  const seconds = now.getSeconds();
+  const year = now.getFullYear()
+  const month = now.getMonth() + 1
+  const day = now.getDate()
+  const hours = now.getHours()
+  const minutes = now.getMinutes()
+  const seconds = now.getSeconds()
   // 补零
   const padZero = num => {
-    return num.toString().padStart(2, "0");
-  };
+    return num.toString().padStart(2, '0')
+  }
   // 默认返回String类型
   let result = `${year}-${padZero(month)}-${padZero(day)} ${padZero(
     hours
-  )}:${padZero(minutes)}:${padZero(seconds)}`;
+  )}:${padZero(minutes)}:${padZero(seconds)}`
   switch (type) {
-    case "string":
+    case 'string':
       result = `${year}-${padZero(month)}-${padZero(day)} ${padZero(
         hours
-      )}:${padZero(minutes)}:${padZero(seconds)}`;
-      break;
-    case "cn":
+      )}:${padZero(minutes)}:${padZero(seconds)}`
+      break
+    case 'cn':
       result = `${year}年${padZero(month)}月${padZero(day)}日 ${padZero(
         hours
-      )}时${padZero(minutes)}分${padZero(seconds)}秒`;
-      break;
-    case "number":
+      )}时${padZero(minutes)}分${padZero(seconds)}秒`
+      break
+    case 'number':
       result = `${year}${padZero(month)}${padZero(day)}${padZero(
         hours
-      )}${padZero(minutes)}${padZero(seconds)}`;
-      break;
+      )}${padZero(minutes)}${padZero(seconds)}`
+      break
     default:
-      break;
+      break
   }
-  return result.slice(0, length || result.length);
-};
+  return result.slice(0, length || result.length)
+}
 
 /**
  * 替换对象中的null为空字符串
@@ -198,25 +198,25 @@ export const getFormatDate = (type, length, date = new Date()) => {
 export const replaceNullWithEmpty = obj => {
   function replaceValue(value) {
     if (value === null) {
-      return "";
-    } else if (typeof value === "object") {
+      return ''
+    } else if (typeof value === 'object') {
       if (Array.isArray(value)) {
-        return value.map(item => replaceValue(item));
+        return value.map(item => replaceValue(item))
       } else {
-        return mapValues(value, v => replaceValue(v));
+        return mapValues(value, v => replaceValue(v))
       }
     } else {
-      return value;
+      return value
     }
   }
-  return replaceValue(obj);
-};
+  return replaceValue(obj)
+}
 
 export default {
   // preview,
   request,
   pinyin4js,
-  snapshoot,
+  //   snapshoot,
   getNextIdByAlias,
   decode,
   encryptByAes,
@@ -234,4 +234,4 @@ export default {
   replaceNullWithEmpty,
   Utils,
   ActionUtils
-};
+}