Commit 1dc89a32 authored by ztf's avatar ztf

修改dee-archives模块

parent c0ebf567
......@@ -41,5 +41,6 @@ const subMicroModules = [
'dee-quality',
'dee-equipment',
'dee-performance',
'dee-plan'
'dee-plan',
'dee-archives'
]
\ No newline at end of file
......@@ -41,5 +41,6 @@ export const microModules = [
'dee-quality',
'dee-equipment',
'dee-performance',
'dee-plan'
'dee-plan',
'dee-archives'
]
......@@ -13,8 +13,10 @@
"moment": "^2.26.0",
"vue": "^2.6.10",
"vue-router": "^3.1.3",
"vuedraggable": "2.23.0",
"vuex": "^3.1.2",
"vuedraggable": "2.23.0"
"xlsx": "^0.18.5",
"xlsx-js-style": "^1.2.0"
},
"devDependencies": {
"@babel/core": "7.0.0",
......
import { get, post, put } from '../utils/http'
export function addComponents(params) {
return post(`/SystemComponent`, params)
}
export function updateComponents(params) {
return put(`/SystemComponent`, params)
}
export function getComponents(typeKey) {
return get(`/SystemComponent/query/typekey?typeKey=${typeKey}`)
}
export function updateLayouts(layoutModel) {
return put(`/model/systems/layouts`, layoutModel)
}
export function componentBindFun(layoutModel) {
return put(`/SystemComponent/all`, layoutModel)
}
import {
get, post
// del
} from '../utils/http'
// 根据keyName 查询
export function getAppLayoutByKey(keyName) {
return get(`/AppLayout/find/${keyName}`)
}
// 查询模型配置信息
export function getLayouts(typeKey, layoutType) {
return new Promise(async(resolve, reject) => {
get('/DxModelComponent/findModelComponent', { modelDefName: typeKey, layoutType }).then(res => {
if (res.items && res.items.content) {
resolve({
items: res.items.content
})
}
})
})
}
// 查询所有基本属性
export function getappLayout(params) {
return get('/AppLayout/' + params)
}
// // 查询所有基本属性
// export function postappLayout(params) {
// return post('/AppLayout/', params)
// }
// // 查询所有基本属性
// export function putappLayout(params) {
// return put('/AppLayout/', params)
// }
// 库房查询接口
export function getTreeData(params) {
return post('/DxPbWorkCenter/search', params)
}
// 库房新增编辑接口
export function subTreeData(params) {
return post('/ DxPbWorkCenter/recursion', params)
}
// 库区查询接口
export function getAreaTreeData(params) {
return post('/DxPbArea/search', params)
}
// 库区新增编辑接口
export function subTreeAreaData(params) {
return post('/DxPbArea/recursion', params)
}
// 库位查询接口
export function getWorkTreeData(params) {
return post('/DxPbWorkUnit/search', params)
}
// 库位新增编辑接口
export function subWorkTreeData(params) {
return post('/DxPbWorkUnit/recursion', params)
}
import {
get
// post,
// put
// del
} from '../utils/http'
// 查询模型配置信息
export function getModelTree(params) {
return get('/ModelDefinition/all/base/tree', params)
}
import {
get
// del
} from '../utils/http'
export function getPermissions(appId, keyName, appName) {
return get('/perm/PageResource/childrenKeyNames', { appId, keyName, appName })
}
import { get } from '../utils/http'
// 出入库单据状态状态统计
export function getDxStRdBaseAF() {
return get('/DxStRdBaseAF/statistical')
}
// 出入库概览
export function getDxStRdRecords() {
return get('/DxStRdRecords/statistical')
}
// 物料库存状态统计饼图
export function getDxStInvAccountStatus() {
return get('/DxStInvAccountStatus/statistical')
}
import {
get,
post
} from '../utils/http'
// 查询入库库房
export function getStHouseForInCome(dxResClassId) {
return post(`/DxPbWorkCenter/getStHouseForInCome?dxResClassId=${dxResClassId}`)
}
// 查询库区
export function findAreaListWithHouseId(houseId, dxResClassId) {
return post(`DxStOrgArea/findAreaListWithHouseId?houseId=${houseId}&dxResClassId=${dxResClassId}`)
}
// 出入库登账
export function saveAllocate(afId, params) {
return post(`/DxStRdBaseAFD/batchSaveAllocate?afId=${afId}`, params)
}
// 查询库内信息
export function getDxStInventoryAccount(type, locationId) {
return get(`DxStInventoryAccount/getStockQuantity?modelName=${type}&locationId=${locationId}`)
}
// 根据资源id查库房-出库登账
export function getStHouseForSendOut(dxResId) {
return post(`/DxPbWorkCenter/getStHouseForSendOut?dxResId=${dxResId}`)
}
// 根据资源id和库房id查库区-出库登账
export function getStAreaForSendOut(dxResId, houseId) {
return post(`/DxPbArea/getStAreaForSendOut?dxResId=${dxResId}&houseId=${houseId}`)
}
// 根据资源id和库区id查库位-出库登账
export function getStLocationForSendOut(dxResId, areaId) {
return post(`/DxPbWorkUnit/getStLocationForSendOut?dxResId=${dxResId}&areaId=${areaId}`)
}
// 查询会计期段树
export function getDxStAccountingConfigTree(params) {
return post(`/DxStAccountingConfig/metrics`, params)
}
// 查询库房下可用的物料分类
export function findResClassByHouse(houseId) {
return post(`/DxStOrgHouse/findResClassByHouse?houseId=${houseId}`)
}
// 查询库区下的库位
export function getStLocationForInCome(areaId, dxResClassId) {
return post(`/DxStOrgLocation/getStLocationForInCome?areaId=${areaId}&dxResClassId=${dxResClassId}`)
}
// 获取三期时间
export function getExpDay() {
return post('/DxStInvExpire/getExpDay')
}
// 获取入库登账的分配结果
export function getDxStInComeAFRecord(params) {
return get('/DxStInComeAF/autoAllocate', params)
}
// 取消出库单占用
export function cancelOccupyDetail(params) {
return post(`/DxStSendOutAFRD/cancelOccupyDetail?afrdId=${params}`)
}
// 出库单占用接口
export function occupyDetail(params) {
return post(`/DxStSendOutAFRD/occupyDetail?afId=${params.afId}&afdId=${params.afdId}`, params.dList)
}
// 出库单占用接口
export function batchSaveAllocate(params) {
return post(`/DxStRdBaseAFD/batchSaveAllocate?afId=${params.afId}`, params.dList)
}
// 三期物料预警占比
export function getExpireWarningRatio() {
return post('/DxStInvAccountDetail/expireWarningRatio')
}
// 三期物料所占库房情况
export function getExpireWarningInHouseRatio() {
return post('/DxStInvAccountDetail/expireWarningRatio/house')
}
import { get } from '../utils/http'
// 通过用户名或账号模糊匹配查询存在账号的用户
export function getUsersByAccount(params) {
return get('/DxUserInfo/byAccount', params)
import { post } from '@/utils/http'
// 查询所有用户列表
export function getAllUsers(params) {
return post('/User/search', params)
}
import {
get,
del,
post,
put
} from '../utils/http'
import $store from '@/store'
// 获取我的收藏数据
export function getCollectData(params) {
return get('/ObjectFavoriteLog/findLogPage', params)
}
// 获取最近访问数据和经常访问
export function getRecentlyVisitData(params) {
return get('/ObjectVisitedLog/findLogPage', params)
}
// 清除最近访问和经常访问
export function delRecentlyAndCommonVisitData() {
return del('/ObjectVisitedLog/clear')
}
// 清除经常访问
export function delCommonVisitData() {
return del('/ObjectFavoriteLog/delSession')
}
// 取消收藏对象
export function cancelCollect(params) {
return post('/ObjectFavoriteLog/unCollect', params)
}
// 修改密码
export function revisePassword(params) {
return post('/DxUserAccount/password/revise', params)
}
// 用户定制APP
export function collectUserApp(params) {
return post(`/userApplication/collect?dxApplicationId=${params}`, true)
}
// 获取用户定制的APP
export function getUserAppList() {
// return get('/userApplication/findCollections')
return $store.dispatch('apiCache/getRequestCache', { url: '/userApplication/findCollections' })
}
// 用户取消定制APP
export function unCollectUserApp(params) {
return post(`/userApplication/unCollect?dxApplicationId=${params}`)
}
// 更新用户信息
export function updateUserInfo(params) {
return put('/DxUserInfo', params)
}
// 获取存储库id
export function getBucketByAppID(params) {
return get('/RepoBucket/getBucketByAppID', params)
}
// 用户上传头像时获取桶
export function getBucketIdByAppName(innerName) {
return post('/userPicture/findBucketId', innerName)
}
// 文件下载
export function downloadFileById(id) {
return get(`/dfs/fileManager/download?fileId=${id}`, null, true)
}
// 查询用户数据
export function getUserInfo(id) {
return get(`/DxUserInfo/${id}`)
}
// 查询用户模块
export function getUserModule() {
// return get('/userModel/findCollections')
return $store.dispatch('apiCache/getRequestCache', { url: '/userModel/findCollections' })
}
// 根据模块id查询模块信息
export function getModuleById(ids) {
// return get(`/DxAppModule/byIds?ids=${ids}`)
return $store.dispatch('apiCache/getRequestCache', { url: `/DxAppModule/byIds?ids=${ids}` })
}
// 用户添加模块
export function collectUserModel(params) {
// const ids = params.map(x => `modelCardIdS=${x}`).join('&')
// const str = ids ? ('?' + ids) : ''
// return post(`/userModel/collect${str}`)
return post(`/userModel/collect`, params)
}
// 用户删除模块
export function unCollectUserModel(id) {
return post(`/userModel/unCollect?modelCode=${id}`)
}
// 根据工作空间id获取首页排序后的数据
export function getPageByWorkspaceId(params) {
return get('/DxWorkspace/findWorkspaceListById', params)
}
export function getUserByScope(params) {
return post('/workflow/inst/participants/scope', params)
}
export function userSearch(params) {
return post('/DxUserInfo/search', params)
}
import {
get
} from '../utils/http'
// 根据pbo查询流程实例列表
export function getWFInsts(params) {
return get('/workflow/inst', params)
}
// 查询流程实例详情
export function instDetail(instId) {
return get(`/workflow/inst/${instId}/simple`)
}
This source diff could not be displayed because it is too large. You can view the blob instead.
import Vue from 'vue'
let resultComps = []
const requireComponent = require.context(
'./', // 在当前目录下查找
true, // 遍历子文件夹
/\.vue$/ // 正则匹配 以 .vue结尾的文件
)
resultComps = handleData(requireComponent.keys())
function findKey(data) {
const allkey = []
const finalData = []
const obj = {}
data.forEach(el => {
const comp = requireComponent(el)
const item = comp.default
if (!(item.modelRelationObjs.length === 0 || (item.modelRelationObjs.length === 1 && item.modelRelationObjs[0] === ''))) {
item.modelRelationObjs.forEach(key => {
if (allkey.indexOf(key) <= -1) {
allkey.push(key)
finalData.push({
[key]: []
})
obj[key] = []
}
})
}
})
return { finalData, allkey, obj }
}
function handleData(data) {
if (!data) return
const { finalData, obj } = findKey(data)
data.forEach(el => {
const comp = requireComponent(el)
const item = comp.default
const mfileName = el.split('/')[el.split('/').length - 1]
Vue.component(mfileName.slice(0, -4), comp.default)
if (item.modelRelationObjs.length === 0 || (item.modelRelationObjs.length === 1 && item.modelRelationObjs[0] === '')) {
if (!obj['commonComponent']) {
obj['commonComponent'] = []
}
obj['commonComponent'].push({
name: mfileName.slice(0, -4),
displayName: item.displayName,
modelRelationObjs: item.modelRelationObjs,
codePath: el.slice(1)
})
} else {
item.modelRelationObjs.forEach(key => {
const index = finalData.findIndex(y => y[key])
if (index > -1) {
finalData[index][key].push({
name: mfileName.slice(0, -4),
displayName: item.displayName,
modelRelationObjs: item.modelRelationObjs,
codePath: el.slice(1)
})
obj[key] = finalData[index][key]
}
})
}
})
return obj
}
export default resultComps
import Vue from 'vue'
// https://webpack.js.org/guides/dependency-management/#requirecontext
const modulesFiles = require.context('./', true, /\.vue$/)
// it will auto require all vuex module from modules file
modulesFiles.keys().reduce((modules, modulePath) => {
Vue.component(modulePath.replace(/^\.\/(.*)\.\w+$/, '$1'), modulePath)
}, {})
<?xml version="1.0" encoding="UTF-8"?>
<svg width="67px" height="57px" viewBox="0 0 67 57" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 64 (93537) - https://sketch.com -->
<title>文件</title>
<desc>Created with Sketch.</desc>
<defs>
<polygon id="path-1" points="0 0.20027027 66.7083977 0.20027027 66.7083977 57 0 57"></polygon>
</defs>
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="通用2" transform="translate(-1177.000000, -524.000000)">
<g id="文件" transform="translate(1177.000000, 524.000000)">
<g id="编组">
<mask id="mask-2" fill="white">
<use xlink:href="#path-1"></use>
</mask>
<g id="Clip-2"></g>
<path d="M59.6748443,52.1858108 L7.03378182,52.1858108 C5.77715114,52.1858108 4.75844659,51.1551892 4.75844659,49.8838581 L4.75844659,26.3470946 L61.9425659,26.3470946 L61.9425659,49.8838581 C61.9425659,51.1478716 60.9238614,52.1858108 59.6748443,52.1858108 M7.03378182,5.01445946 L27.3911227,5.01445946 C28.3131341,5.01445946 29.1384523,5.57097973 29.4879182,6.42829054 L29.5400716,6.55615541 L31.9638727,10.9343716 C33.0865034,13.5143919 35.5997648,15.1693176 38.395492,15.1693176 L59.6672307,15.1693176 C60.9238614,15.1693176 61.9425659,16.1995541 61.9425659,17.4708851 L61.9425659,21.5329054 L4.75844659,21.5329054 L4.75844659,7.31602703 C4.75844659,6.04469595 5.77715114,5.01445946 7.03378182,5.01445946 M59.6748443,10.3551284 L38.395492,10.3551284 C37.4734807,10.3551284 36.6481625,9.79822297 36.2986966,8.94091216 L36.2465432,8.8130473 L33.822742,4.43521622 C32.7001114,1.85481081 30.18685,0.20027027 27.3911227,0.20027027 L7.03378182,0.20027027 C3.15996364,0.20027027 -7.61363636e-05,3.38957432 -7.61363636e-05,7.31602703 L-7.61363636e-05,49.8838581 C-7.61363636e-05,53.8029932 3.15235,57 7.03378182,57 L59.6748443,57 C63.5486625,57 66.7087023,53.8106959 66.7087023,49.8838581 L66.7087023,17.4708851 C66.7010886,13.5444324 63.5486625,10.3551284 59.6748443,10.3551284" id="Fill-1" fill="#000000" mask="url(#mask-2)"></path>
</g>
<line x1="4.75844659" y1="24" x2="62" y2="24" id="路径-3" stroke="#4A90E2" stroke-width="5" fill="#4A90E2"></line>
</g>
</g>
</g>
</svg>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<svg width="18px" height="13px" viewBox="0 0 18 13" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>关闭</title>
<defs>
<linearGradient x1="50%" y1="0%" x2="50%" y2="100%" id="linearGradient-1">
<stop stop-color="#EDBD44" offset="0%"></stop>
<stop stop-color="#DDB043" offset="100%"></stop>
</linearGradient>
<linearGradient x1="50%" y1="0%" x2="50%" y2="100%" id="linearGradient-2">
<stop stop-color="#F4D781" offset="0%"></stop>
<stop stop-color="#E0AD33" offset="100%"></stop>
</linearGradient>
</defs>
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="综合查询" transform="translate(-150.000000, -648.000000)" fill-rule="nonzero">
<g id="Group-66" transform="translate(90.000000, 329.000000)">
<g id="Rectangle-Copy-38" transform="translate(20.000000, 153.000000)">
<g id="tree_1" transform="translate(6.886486, 156.000000)">
<g id="关闭" transform="translate(34.000000, 10.000000)">
<path d="M16.0839948,2.92151172 C16.0656914,2.4215957 15.9010392,2.29662305 15.4528084,2.29662305 L8.48864326,2.29662305 C7.58304948,2.29662305 7.47328133,1.30554785 6.78722386,0.591385742 C6.2200537,-0.00672851562 6.43960302,0.00130761719 5.25957585,0.00130761719 L1.12198623,0.00130761719 C0.399348048,0.00130761719 0.143205009,-0.0611914062 0.0700305755,0.679757813 C0.00600132015,1.3582207 0.0183033649,4.18211984 1.4033219e-13,4.44100265 L15.9864023,4.33357347 L16.0839948,2.92151172 Z" id="Path" fill="url(#linearGradient-1)"></path>
<path d="M0.74987129,3.90332617 C0.00891673412,3.90332617 -0.0276639782,4.27825684 0.0180619122,4.73353613 L0.554115046,12.1697773 C0.590695758,12.6250693 0.700463913,13 1.43226028,13 L14.5955018,13 C15.3455885,13 15.4279341,12.6250693 15.47366,12.1697773 L15.9767749,4.6442627 C16.0133686,4.1889834 15.9804304,3.90332617 15.2394888,3.90332617 L0.74987129,3.90332617 Z" id="Path" fill="url(#linearGradient-2)"></path>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<svg width="17px" height="13px" viewBox="0 0 17 13" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>wenjianjia-3</title>
<defs>
<linearGradient x1="50%" y1="0%" x2="50%" y2="100%" id="linearGradient-1">
<stop stop-color="#F4D781" offset="0%"></stop>
<stop stop-color="#E0AD33" offset="100%"></stop>
</linearGradient>
<linearGradient x1="50%" y1="0%" x2="50%" y2="100%" id="linearGradient-2">
<stop stop-color="#EDBD44" offset="0%"></stop>
<stop stop-color="#CA9E36" offset="100%"></stop>
</linearGradient>
</defs>
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="综合查询" transform="translate(-150.000000, -616.000000)" fill-rule="nonzero">
<g id="Group-66" transform="translate(90.000000, 329.000000)">
<g id="Rectangle-Copy-38" transform="translate(20.000000, 153.000000)">
<g id="tree_1" transform="translate(6.886486, 124.000000)">
<g id="wenjianjia-3" transform="translate(34.000000, 10.000000)">
<path d="M15.2395018,3.90332617 L0.74987129,3.90332617 C0.00891673412,3.90332617 -0.0276639782,4.27825684 0.0180619122,4.73353613 L0.554115046,12.1697773 C0.590695758,12.6250693 0.700463913,13 1.43226028,13 L14.5955018,13 C15.3455885,13 15.4279341,12.6250693 15.47366,12.1697773 L15.9767749,4.6442627 C16.0133686,4.1889834 15.9804304,3.90332617 15.2394888,3.90332617 L15.2395018,3.90332617 Z" id="Path" fill="url(#linearGradient-1)"></path>
<path d="M15.0839948,1.92151172 C15.0656914,1.4215957 14.9010392,1.29662305 14.4528084,1.29662305 L8.48864326,1.29662305 C7.58304948,1.29662305 7.47328133,1.30554785 6.78722386,0.591385742 C6.2200537,-0.00672851562 6.43960302,0.00130761719 5.25957585,0.00130761719 L2.12198623,0.00130761719 C1.39934805,0.00130761719 1.14320501,-0.0611914062 1.07003058,0.679757813 C1.00600132,1.3582207 0.859639445,3.00079102 0.84133608,3.25967383 L15.148011,3.25967383 L15.0839948,1.92151172 Z" id="Path" fill="url(#linearGradient-2)"></path>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>
\ No newline at end of file
......@@ -4,30 +4,19 @@
// const sharePool = (Vue.__share_pool__ = Vue.__share_pool__ || {})
// const store = (sharePool.store = sharePool.store || {})
import asyncComponents from './asyncCompontents/index'
import privateComponents from './privateComponents/index'
import signConfig from './privateComponents/signConfig'
function loadComponent(comName, type) {
let resolveComponent
if (!type) {
resolveComponent = resolve => { require([`@/asyncCompontents${comName}`], resolve) }
} else if (type === 'customComponent') {
resolveComponent = resolve => { require([`@/customComponent${comName}`], resolve) }
} else if (type === 'privateComponents') {
if (type === 'privateComponents') {
resolveComponent = resolve => { require([`@/privateComponents/${'components' + comName}`], resolve) }
} else if (type === 'view') {
resolveComponent = resolve => { require([`@/views/${comName}`], resolve) }
}
return resolveComponent
}
require('./business-components/tabCom/index.js')
export default {
name: 'dee-storage',
name: 'dee-archives',
privateComponents,
signConfig,
asyncComponents,
loadComponent,
beforeEach(from, to, next) {
next()
......
<template>
<div class="dee-model">
<el-select
v-if="informativeUser"
v-model="cloneValue"
:disabled="disabled"
:read-only="readOnly"
:size="size"
:multiple="multiple"
placeholder="请选择"
>
<el-option
v-for="item in userListOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
<DxUserSelect
v-else
:user="user"
:value="value"
:disabled="disabled"
:read-only="readOnly"
:is-remote="isRemote"
:size="size"
:input-attr="inputAttr"
:async-attr="asyncAttr"
:form="form"
:multiple="multiple"
@input="(val)=>{update(val)}"
/>
</div>
</template>
<script>
import { getAllUsers } from '@/api/user'
export default {
name: 'DistributeReceiveUser',
componentName: '人员选择',
props: {
user: {
type: [Number, String, Object],
default: ''
},
value: {
type: [Number, String, Object, Array],
default: ''
},
disabled: {
type: Boolean,
default: false
},
readOnly: {
type: Boolean,
default: false
},
isRemote: {
type: Boolean,
default: true
},
size: {
type: String,
default: () => ''
},
inputAttr: {
type: String,
default: () => ''
},
// eslint-disable-next-line vue/require-default-prop
asyncAttr: {
type: Object,
defalut: () => {}
},
// eslint-disable-next-line vue/require-default-prop
form: {
type: Object,
defalut: () => {}
},
multiple: {
type: Boolean,
default: false
},
basicData: {
type: Object,
default: () => {}
}
},
data() {
return {
userListOptions: [],
cloneValue: ''
}
},
computed: {
informativeUser() {
return this.form && this.form.informativeUser
}
},
watch: {
cloneValue() {
this.update(this.cloneValue)
},
informativeUser: {
immediate: true,
deep: true,
handler: function(val) {
val && this.initOptions()
}
}
},
// 生命周期 - 创建完成(访问当前this实例)
created() {},
// 生命周期 - 挂载完成(访问DOM元素)
mounted() {
console.log('basicData', this.basicData)
this.cloneValue = this.value
},
methods: {
initOptions() {
this.getAllUsers()
},
getAllUsers() {
const params = {
'pageFrom': 1,
'searchItems': {
'items': [
{
'fieldName': 'id',
'operator': 'IN',
'value': this.informativeUser
}
],
'operator': 'AND'
},
'pageSize': 9999
}
getAllUsers(params).then(res => {
if (res.items && res.items.content) {
this.userListOptions = res.items.content.map(n => {
return {
label: `${n.userName}(${n.userAccount})`,
value: n.id,
data: n
}
})
} else {
this.userListOptions = []
}
})
},
update(val) {
this.$emit('input', val)
}
}
}
</script>
<style lang="scss">
/* @import url(); 引入css类 */
</style>
<template>
<div class="dee-model foreign-unit-mode">
<div v-show="editState||value"><span>{{ value }}</span>
<el-button type="text" @click="showDialogFlag=true">{{ editState?'设置':'查看' }}</el-button>
</div>
<dee-dialog
:dialog-visible="showDialogFlag"
:title="editState?'外单位选择':'外单位查看'"
width="800px"
class="foreign-unit-dialog"
:dialog-bttons="editState?dialogBttons:[]"
@on-submit="submit"
@on-cancel="showDialogFlag=false"
@handleClose="showDialogFlag=false"
>
<div v-for="(units,index) in unitLists" :key="index" class="rows">
<div class="sub-title">
{{ units.title }}
</div>
<div class="checkbox">
<el-checkbox
v-for="(unit) in units.children"
:key="unit.key"
:checked="unit.checked"
:disabled="unit.disabled"
@change="(val)=>{unit.checked = val}"
>{{ unit.title }}</el-checkbox>
</div>
</div>
</dee-dialog>
</div>
</template>
<script>
export default {
name: 'InternalUnit',
componentName: '外单位选择或查看',
props: {
disabled: {
type: Boolean,
default: false
},
readOnly: {
type: Boolean,
default: false
},
value: {
type: [String, Object],
default: () => ''
}
},
data() {
return {
dictOptions: [],
dialogBttons: [{
type: 'submit',
text: '提交',
component: {
type: 'primary'
}
}, {
type: 'cancel',
text: '取消',
component: {}
}],
showDialogFlag: false,
checkedValue: []
}
},
computed: {
editState() {
return !this.disabled && !this.readOnly
},
serviceApi() {
return this.$getService('DictData', { versionControl: false }).baseQuery().orderByDesc('modifyTime')
},
unitLists() {
if (!this.dictOptions || this.dictOptions.length === 0) { return [] }
return this.setChecked(this.dictOptions, this.value)
}
},
watch: {},
// 生命周期 - 创建完成(访问当前this实例)
created() {},
// 生命周期 - 挂载完成(访问DOM元素)
mounted() {
this.init()
},
methods: {
init() {
this.serviceApi
.page(1, 1000)
.search({
data: {
items: [{
fieldName: 'dictCode',
operator: 'EQ',
value: 'ExternalParties'
}, {
fieldName: 'dictState',
operator: 'EQ',
value: 'ENABLE'
}],
operator: 'AND'
}
}).then(res => {
this.dictOptions = res.content
})
},
submit() {
const checked = []
this.unitLists.forEach(items => {
if (items.children && items.children.length) {
items.children.forEach(unit => {
if (unit.checked) {
checked.push(unit.title)
}
})
}
})
this.$emit('input', checked.join())
this.showDialogFlag = false
},
setChecked(options, checkedStr) {
const checked = checkedStr ? checkedStr.split(',') : []
// 数据洗澡
const list = options.map(r => {
return {
title: r.dictValue,
key: r.dictKey,
parentKey: r.parentKey,
disabled: !this.editState,
checked: checked.includes(r.dictValue)
}
})
// 分类
const parent = list.filter(r => !r.parentKey)
parent.forEach(item => {
item.children = list.filter(r => r.parentKey === item.key)
})
return parent
}
}
}
</script>
<style lang="scss">
/* @import url(); 引入css类 */
.foreign-unit-dialog{
.rows{
margin-bottom: 20px;
}
.title-bar{
margin-bottom: 6px;
font-weight: 700;
&:before{
content: "";
width: 4px;
height: 13px;
-ms-flex-item-align: center;
align-self: center;
margin-right: 12px;
}
}
}
</style>
<!-- -->
<template>
<div />
</template>
<script>
export default {
name: 'Demo',
componentName: '测试',
props: {
},
data() {
return {
}
},
mounted() {
},
methods: {
}
}
</script>
<style lang='scss' scoped>
</style>
<!--
* @Author: zhangtianfeng 3232807530@qq.com
* @Date: 2024-09-03 16:02:46
* @LastEditors: zhangtianfeng 3232807530@qq.com
* @LastEditTime: 2024-09-09 14:05:46
-->
<template>
<el-tabs type="card">
<el-tab-pane label="收入合同">
<div class="content">
<dee-as-page
:key="incomeContractPageKey"
:page-key="incomeContractPageKey"
/>
</div>
</el-tab-pane>
<el-tab-pane label="支出合同">
<div class="content">
<dee-as-page
:key="spendingContractPageKey"
:page-key="spendingContractPageKey"
/>
</div>
</el-tab-pane>
</el-tabs>
</template>
<script>
export default {
name: 'Funds',
componentName: '经费管理页面',
props: {
basicData: {
type: Object,
default: () => {}
}
},
data() {
return {
spendingContractPageKey: '87b4f333-5f0e-4055-b215-f66b5d45f919',
incomeContractPageKey: '80bff7f2-0038-4ca6-9544-1496ce0b6459'
}
},
watch: {
basicData(val) {
console.log('val', val)
// 监听传进来的数据,如果是项目的话都展示
// 如果是子项的话只能看到支出合同
// 可以通过传进来的id,调用接口,获取到该项目的详情,通过详情得知是项目还是子项
// 进行判断,以及这个的显示与隐藏
}
}
}
</script>
<style lang="scss" scoped>
.content{
height: calc(100vh - 200px);
}
</style>
......@@ -27,3 +27,4 @@ requireComponent.keys().forEach(fileName => {
}
})
export default privateComponents
const containerComponents = [
'demo'
'AppendDoc'
]
const formListComponents = [
'demo'
'AppendDoc'
]
const tabComponents = [
'demo'
'AppendDoc'
]
const tableListComponents = [
'demo'
'AppendDoc'
]
export default {
containerComponents,
......
......@@ -7,17 +7,32 @@
const App = () => import('./App.vue')
export default [
{
path: '/storageCenter',
name: 'storageCenter',
component: () => import('@/views/storage/center'),
meta: { title: '仓储中心', alive: true }
path: '/docCenter',
name: 'docCenter',
component: () => import('@/views/doc/center'),
meta: { title: '文档中心', alive: true }
},
{
path: '/storage',
path: '/doc',
component: App,
name: 'storage',
meta: { title: '仓储中心', icon: 'xitong' },
redirect: '',
children: []
name: 'doc',
meta: { title: '文档中心', icon: 'xitong' },
redirect: '/doc/add',
children: [
{
hidden: true,
path: 'add',
name: 'docAdd',
component: () => import('@/views/doc/add'),
meta: { title: '新建文档', alive: false }
},
{
hidden: true,
path: 'edit',
name: 'docEdit',
component: () => import('@/views/doc/edit'),
meta: { title: '编辑文档' }
}
]
}
]
const DEABaseService = window.top.mainVue.$store.getters.baseService
const ACTIONS = {
// // 获取子结构
// GET_LAYOUT: {
// path: '{{$modelPath}}/form/config/layout?layoutType={{layoutType}}&typeKey={{typeKey}}',
// method: 'GET'
// }
GET: {
path: '{{$modelPath}}',
method: 'GET'
},
ADD: {
path: '{{$modelPath}}',
method: 'POST'
},
EDIT: {
path: '{{$modelPath}}',
method: 'PUT'
},
GET_BY_NAME: {
path: '{{$modelPath}}/name/{{modelName}}',
method: 'GET'
}
}
class ModelDefinitionService extends DEABaseService {
// eslint-disable-next-line no-useless-constructor
constructor() {
super('/ModelDefinition')
}
// // 获取Layout
// getLayout(layoutType, typeKey) {
// return this.apply(ACTIONS.GET_LAYOUT, { layoutType, typeKey })
// }
async get(appId, modelId) {
return await this.apply(ACTIONS.GET, null, {
appId,
modelId
}).items
}
async getByName(modelName) {
return await this.apply(ACTIONS.GET_BY_NAME, null, {
modelName
})
}
}
export default {
install() {
window.top.mainVue.$setService('ModelDefinition', ModelDefinitionService)
}
}
/**
* @Description: 样式统一位置
* @author arvin
* @date 2021/2/25
*/
/* */
.porcess-history-record-com{
margin-top: 10px;
}
/* */
.preview-com{
height: 100%;
overflow: auto;
.preview-box{
padding: 8px;
height: 100%;
overflow: auto;
background-color: #DEE1E7;
.preview-form{
padding:8px;
background: #FFF
}
}
}
.prop-tree-com{
height: 100%;
.model-icon{
border-width: 0;
color: #2A75CE;
}
}
.intermediate-region-com{
.left-s-box{
display: flex;
align-items: center
}
.more-info{
color: #2A75CE;
padding: 0 10px;
font-size: 16px;
cursor: pointer;
}
}
.add-page{
height: 100%;
box-sizing: border-box;
.scroll-container{
.el-scrollbar__wrap {
margin-bottom: 0 !important;
overflow-x: hidden;
.task-name{
font-weight: bold;
margin-bottom: 20px;
margin-top: 4px;
}
}
.is-horizontal{
display: none;
}
}
}
.storage-center{
height: 100%;
box-sizing: border-box;
display: flex;
justify-content: flex-start;
.detail-pane {
width: 100%;
height: 100%;
}
.left-box{
height: 100%;
box-sizing: border-box;
border: 1px solid #d9d9d9;
background-color: #fff;
.dee-panel{
height: calc(100% - 13px) !important;
width: 99%;
}
.el-tabs__content {
height: calc(100% - 68px) !important;
overflow: auto;
}
.el-tab-pane {
height: calc(100% - 13px) !important;
}
.el-tabs__nav-prev{
left: 4px;
}
.el-tabs__nav-next{
right: 4px;
}
.el-tabs__nav {
width: 100%;
}
.is-active:after {
position: absolute;
border-top: 4px solid transparent;
border-left: 4px solid transparent;
border-bottom: 4px solid #3281DE;
border-right: 4px solid transparent;
content: " ";
display: block;
bottom: 0;
left: 50%;
transform: translateX(-50%);
}
.el-tabs__nav-scroll{
border-left: none;
}
.el-tabs__item{
width: 25%;
background-color: #ffffff;
height: auto;
font-weight: bold;
border-left: 0;
border-right: 0;
border-top: 0;
span {
display: flex;
flex-direction: column;
align-items: center;
.imgStyle {
margin: 0;
}
}
}
.el-tabs__item.is-active {
border-bottom: 2px solid #3281DE;
background-color: #f3f3f3;
}
.slot{
height: 100%;
padding: 10px;
box-sizing: border-box;
}
}
.right-pane{
height: 100%;
background-color: #fff;
border: 1px solid #d9d9d9;
box-sizing: border-box;
.splitter-pane-resizer.horizontal {
opacity: 1;
background-color: #F1F4F5;
height: 8px;
border-bottom: 1px solid #e0e0e0;
border-top: 1px solid #e0e0e0;
}
.table-box{
height: calc(100% - 22px);
overflow: hidden;
background-color: #fff;
padding: 10px 16px;
.dee-table{
height: calc(100% - 32px);
.dee-table-body{
height: calc(100% - 96px);
overflow: auto;
}
}
}
.down-pic{
position: absolute;
left:0;
right: 0;
top: 5px;
z-index: 10;
margin:0 auto;
cursor: pointer;
}
.detail{
height: 100%;
}
.dee-table-pagination {
padding: 0;
}
}
}
.integratedQuery{
height: 100%;
}
export const layoutExtendOptions = []
export const verificationMethods = {}
export const formateExtendOptions = [
// 参考格式 views\config\typePropManage\layoutConfig\config\formateOptions.js 格式
]
export const layout = {
'创建': '0',
'编辑': '1',
'详情信息': '2',
'流程任务': '3',
'主题': '4',
'查看': '5',
'列表查看': '6'
}
export const logicalRelationshipMap = {
SF: {
number: '3',
text: 'start_to_finish'
},
SS: {
number: '1',
text: 'start_to_start'
},
FF: {
number: '2',
text: 'finish_to_finish'
},
FS: {
number: '0',
text: 'finish_to_start'
}
}
export const gantFieldMap = {
text: 'name',
start_date: 'startDate',
'finishDate': 'finishDate',
progress: 'percentWorkComplete'
}
export const userOrgMap = {
managedBy: 'managedOrg',
ownedBy: 'ownedOrg'
}
const YesNoOptions = [
{
key: true,
label: '是'
},
{
key: false,
label: '否'
}
]
const PriorityOptions = [
{ key: '紧急', label: '紧急' },
{ key: '高', label: '高' },
{ key: '中', label: '中' },
{ key: '低', label: '低' }
]
// const StateOptions = [
// { key: 'NotStarted', label: '未开始' },
// { key: 'InProgress', label: '进行中' },
// { key: 'Shelve', label: '搁置中' },
// { key: 'Complete', label: '已完成' },
// { key: 'Closed', label: '已关闭' },
// { key: 'Repulse', label: '打回' }
// ]
export const speColumnMap = {
name: {
name: 'text',
editor: { type: 'text', map_to: 'text' },
align: 'left',
min_width: 200
},
state: {
name: 'state'
// editor: { type: 'select', map_to: 'state', options: StateOptions }
},
'manager.userName': {
name: 'manager'
},
planStartDate: {
name: 'start_date',
editor: { type: 'date', map_to: 'start_date' }
},
planEndDate: {
name: 'end_date',
editor: { type: 'date', map_to: 'end_date' }
},
actualStartDate: {
name: 'actualStartDate',
editor: { type: 'date', map_to: 'actualStartDate' }
},
actualEndDate: {
name: 'actualEndDate',
editor: { type: 'date', map_to: 'actualEndDate' }
},
milepost: {
name: 'milepost',
editor: { type: 'select', map_to: 'milepost', options: YesNoOptions }
},
priority: {
name: 'priority',
editor: { type: 'select', map_to: 'priority', options: PriorityOptions }
},
completionRate: {
name: 'completionRate',
editor: { type: 'text', map_to: 'completionRate' }
},
workDuration: {
name: 'workDuration', // 避免和内置关键字冲突
editor: { type: 'text', map_to: 'workDuration' }
}
}
/** 工作空间--不同项目任务颜色枚举 */
export const taskColorMap = {
'计划': '#f17a72',
'督查': '#6e9bf6',
'会议': '#3ca7ea',
'经费': '#6e9bf6',
'风险': '#a07bef',
'信息': '#3ca7ea'
}
/** 计划任务,可更改的状态*/
export const taskChangeStateOptions = [
{
label: '进行中',
value: '进行中'
},
{
label: '已完成',
value: '已完成'
},
{
label: '已暂停',
value: '已暂停'
}
]
/** 风险严重程度说明 */
export const riskSeverityObject = [
{
value: 'A',
label: 'A',
description: '轻微',
remark: {
a: '基本不影响型号任务目标实现',
b: '无人员伤害'
}
},
{
value: 'B',
label: 'B',
description: '轻度',
remark: {
a: '型号产品系统极轻微损坏或仅次要功能丧失且可以立即修复',
b: '人员轻微伤害'
}
},
{
value: 'C',
label: 'C',
description: '重度',
remark: {
a: '阶段主要任务完成或达到的目标仅为型号任务的主要考核目标',
b: '型号产品轻度损坏或主要功能丧失且可以修复',
c: '人员轻度伤害'
}
},
{
value: 'D',
label: 'D',
description: '严重',
remark: {
a: '型号任务不能达到主要试验目的',
b: '主要性能指标、可靠性指标不能实现',
c: '影响型号任务转场、发射窗口推迟等重大节点',
d: '阶段任务部分完成或仅达到部分任务目标,且未达到的目标是型号任务的主要考核目标',
e: '型号产品或组件技术方案出现颠覆或重大反复',
f: '型号产品系统毁坏或主要功能丧失且无法修复',
g: '人员严重伤害'
}
},
{
value: 'E',
label: 'E',
description: '灾难',
remark: {
a: '型号任务失败'
}
}
]
/** 风险发生可能性说明 */
export const riskPossibilityList = [
{
value: 'a',
label: 'a',
description: '极少',
remark: '几乎不发生,发生概率 p<0.01%'
},
{
value: 'b',
label: 'b',
description: '很少',
remark: '很少发生,发生概率 0.01%≤p<0.1%'
},
{
value: 'c',
label: 'c',
description: '少',
remark: '偶尔发生,发生概率 0.1%<p≤1%'
},
{
value: 'd',
label: 'd',
description: '可能',
remark: '频繁发生,发生概率 1%≤p<10%'
},
{
value: 'e',
label: 'e',
description: '很可能',
remark: '很可能发生,发生概率 p≥10%'
}
]
/** 风险等级计算 */
export const riskLevelMap = {
A: {
a: { label: '极低-I', value: 'I' },
b: { label: '极低-I', value: 'I' },
c: { label: '极低-I', value: 'I' },
d: { label: '低-II', value: 'II' },
e: { label: '中等-III', value: 'III' }
},
B: {
a: { label: '极低-I', value: 'I' },
b: { label: '极低-I', value: 'I' },
c: { label: '低-II', value: 'II' },
d: { label: '中等-III', value: 'III' },
e: { label: '中等-III', value: 'III' }
},
C: {
a: { label: '极低-I', value: 'I' },
b: { label: '低-II', value: 'II' },
c: { label: '中等-III', value: 'III' },
d: { label: '中等-III', value: 'III' },
e: { label: '高-IV', value: 'IV' }
},
D: {
a: { label: '中等-III', value: 'III' },
b: { label: '中等-III', value: 'III' },
c: { label: '中等-III', value: 'III' },
d: { label: '高-IV', value: 'IV' },
e: { label: '极高-V', value: 'V' }
},
E: {
a: { label: '中等-III', value: 'III' },
b: { label: '中等-III', value: 'III' },
c: { label: '高-IV', value: 'IV' },
d: { label: '极高-V', value: 'V' },
e: { label: '极高-V', value: 'V' }
}
}
/** 排会管理图例信息 */
export const meetingExplainList = [
{
color: 'rgba(93, 187, 106, 1)',
className: 'published',
text: '已发放'
},
{
color: 'rgba(67, 162, 235, 1)',
className: 'not_published',
text: '未发放'
},
{
color: 'rgba(229, 105, 105, 1)',
className: 'people_time_conclusion',
text: '人员时间冲突'
},
{
color: 'rgba(243, 182, 75, 1)',
className: 'time_meeting_room_conclusion',
text: '时间会议室冲突'
},
{
color: 'rgba(152, 172, 182, 1)',
className: 'history_meeting',
text: '历史会议'
}
]
export const integralDistribution = {
'动态信息': {
'一周要览': 1,
'集团公司': 2,
'上级部门': 4
},
'专报信息': {
'一周要览': 4,
'集团公司': 8,
'上级部门': 15
},
'综合信息': {
'一周要览': 10,
'集团公司': 20,
'上级部门': 40
}
}
export const taskTypeMap = {
'SupervisionAndInspection': 'SIActivity',
'PPDeptPlan': 'PPActivity',
'WholeCyclePlan': 'WholeCycleActivity'
}
export const reportToList = ['上级部门', '集团公司', '一周要览']
export const assessmentResultMap = {
confirmResult: {
label: '厂所领导',
formKey: ['confirmClassify', 'confirmType', 'confirmDescription']
},
confirmResult2: {
label: '领域办',
formKey: ['confirmClassify2', 'confirmType2', 'confirmDescription2']
},
confirmResult3: {
label: '型号处',
formKey: ['confirmClassify3', 'confirmType3', 'confirmDescription3']
}
}
/** 督查评分部分 */
// 部门总体工作效率评分说明
export const deptWorkEfficiencyExplain = [
{
description: '任务按期或调整一次完成',
score: 40
},
{
description: '调整2次(含)完成',
score: 35
},
{
description: '调整3次(含)及以上完成或延期完成',
score: 30
},
{
description: '统计周期内未完成',
score: '不得分'
}
]
// 部门总体工作质量评分说明
export const deptWorkQualityExplain = [
{
description: '对完成质量非常满意,或在计划时间内高质量完成任务并按时完成办结流程',
score: '30-40'
},
{
description: '对完成质量满意,或在计划时间内基本完成任务',
score: '20-30'
},
{
description: '完成质量一般,或在计划时间内初步完成任务',
score: '10-20'
},
{
description: '完成质量较差',
score: '0-10'
}
]
// 部门总体任务量评分说明
export const deptTaskVolumeExplain = [
{
description: 'x≤3',
score: '10'
},
{
description: '3<x≤5',
score: '8'
},
{
description: '5<x≤7',
score: '5'
},
{
description: '7<x≤10',
score: '3'
},
{
description: 'x>10',
score: '0'
}
]
// 部门总体协调配合评分说明
export const deptCoordinationAndCooperationExplain = [
{
description: '工作质量满足总体工作要求',
score: '4'
},
{
description: '工作效率满足整体工作要求',
score: '4'
},
{
description: '积极协调配合,沟通流畅',
score: '2'
}
]
// 部门总体约束性评分说明
export const deptBindingExplain = [
{
description: '未按时完成事项办结或调整申请流程,或未按要求对督查工作进行阶段目标分解',
score: '-2'
},
{
description: '未按时完成交付物的送审流程,或交付物与要求不符',
score: '-3'
},
{
description: '对督查工作事项落实情况进行结果验证,督查结果与反馈内容差异较大',
score: '-5'
}
]
// 项目任务--不同状态的任务显示不同颜色
export const taskStateAndColorClassMap = {
'编制': 'gantt_task_edit',
'待审核': 'gantt_task_waiting',
'待审批': 'gantt_task_waiting',
'进行中': 'gantt_task_waiting',
'变更申请': 'gantt_task_waiting',
'已暂停': 'gantt_task_stop',
'驳回': 'gantt_task_stop',
'变更中': 'gantt_task_waiting',
'待校对': 'gantt_task_waiting',
'已完成': 'gantt_task_finish',
'完成待确认': 'gantt_task_waiting',
'父项完成待确认': 'gantt_task_waiting'
}
import moment from 'moment'
export function formatDate({ params: formatPattern, row, column, cellValue, index }) {
const date = 'YYYY-MM-DD'
return moment(cellValue).format(formatPattern || date)
}
export default {
formatDate
}
export const formateOptions = [
{
label: '年-月-日',
value: 'data1',
params: 'YYYY-MM-DD',
formate: 'formatDate'
}, {
label: '年-月-日 时:分:秒',
value: 'data2',
params: 'YYYY-MM-DD HH:mm:ss',
formate: 'formatDate'
}
]
......@@ -19,8 +19,11 @@ function del(url, params) {
function downloadFile(url, type) {
return http.downloadFile(url, type)
}
function downloadFileWithParams(url, type, params) {
return http.downloadFile(url, type, params)
}
function downloadZip(url, type) {
return http.downloadZip(url, type)
}
export { get, post, put, del, patch, downloadFile, downloadZip }
export { get, post, put, del, patch, downloadFile, downloadZip, downloadFileWithParams }
export const forEach = (arr, fn) => {
if (!arr.length || !fn) return
let i = -1
const len = arr.length
while (++i < len) {
const item = arr[i]
fn(item, i, arr)
}
}
/**
* @param {Array} arr1
* @param {Array} arr2
* @description 得到两个数组的交集, 两个数组的元素为数值或字符串
*/
export const getIntersection = (arr1, arr2) => {
const len = Math.min(arr1.length, arr2.length)
let i = -1
const res = []
while (++i < len) {
const item = arr2[i]
if (arr1.indexOf(item) > -1) res.push(item)
}
return res
}
/**
* @param {Array} arr1
* @param {Array} arr2
* @description 得到两个数组的并集, 两个数组的元素为数值或字符串
*/
export const getUnion = (arr1, arr2) => {
return Array.from(new Set([...arr1, ...arr2]))
}
/**
* @param {Array} target 目标数组
* @param {Array} arr 需要查询的数组
* @description 判断要查询的数组是否至少有一个元素包含在目标数组中
*/
export const hasOneOf = (targetarr, arr) => {
return targetarr.some(_ => arr.indexOf(_) > -1)
}
/**
* @param {String|Number} value 要验证的字符串或数值
* @param {*} validList 用来验证的列表
*/
export function oneOf(value, validList) {
for (let i = 0; i < validList.length; i++) {
if (value === validList[i]) {
return true
}
}
return false
}
/**
* @param {Number} timeStamp 判断时间戳格式是否是毫秒
* @returns {Boolean}
*/
const isMillisecond = timeStamp => {
const timeStr = String(timeStamp)
return timeStr.length > 10
}
/**
* @param {Number} timeStamp 传入的时间戳
* @param {Number} currentTime 当前时间时间戳
* @returns {Boolean} 传入的时间戳是否早于当前时间戳
*/
const isEarly = (timeStamp, currentTime) => {
return timeStamp < currentTime
}
/**
* @param {Number} num 数值
* @returns {String} 处理后的字符串
* @description 如果传入的数值小于10,即位数只有1位,则在前面补充0
*/
const getHandledValue = num => {
return num < 10 ? '0' + num : num
}
/**
* @param {Number} timeStamp 传入的时间戳
* @param {Number} startType 要返回的时间字符串的格式类型,传入'year'则返回年开头的完整时间
*/
const getDate = (timeStamp, startType) => {
const d = new Date(timeStamp * 1000)
const year = d.getFullYear()
const month = getHandledValue(d.getMonth() + 1)
const date = getHandledValue(d.getDate())
const hours = getHandledValue(d.getHours())
const minutes = getHandledValue(d.getMinutes())
const second = getHandledValue(d.getSeconds())
let resStr = ''
if (startType === 'year') resStr = year + '-' + month + '-' + date + ' ' + hours + ':' + minutes + ':' + second
else resStr = month + '-' + date + ' ' + hours + ':' + minutes
return resStr
}
/**
* @param {String|Number} timeStamp 时间戳
* @returns {String} 相对时间字符串
*/
export const getRelativeTime = timeStamp => {
// 判断当前传入的时间戳是秒格式还是毫秒
const IS_MILLISECOND = isMillisecond(timeStamp)
// 如果是毫秒格式则转为秒格式
if (IS_MILLISECOND) Math.floor(timeStamp /= 1000)
// 传入的时间戳可以是数值或字符串类型,这里统一转为数值类型
timeStamp = Number(timeStamp)
// 获取当前时间时间戳
const currentTime = Math.floor(Date.parse(new Date()) / 1000)
// 判断传入时间戳是否早于当前时间戳
const IS_EARLY = isEarly(timeStamp, currentTime)
// 获取两个时间戳差值
let diff = currentTime - timeStamp
// 如果IS_EARLY为false则差值取反
if (!IS_EARLY) diff = -diff
let resStr = ''
const dirStr = IS_EARLY ? '前' : '后'
// 少于等于59秒
if (diff <= 59) resStr = diff + '秒' + dirStr
// 多于59秒,少于等于59分钟59秒
else if (diff > 59 && diff <= 3599) resStr = Math.floor(diff / 60) + '分钟' + dirStr
// 多于59分钟59秒,少于等于23小时59分钟59秒
else if (diff > 3599 && diff <= 86399) resStr = Math.floor(diff / 3600) + '小时' + dirStr
// 多于23小时59分钟59秒,少于等于29天59分钟59秒
else if (diff > 86399 && diff <= 2623859) resStr = Math.floor(diff / 86400) + '天' + dirStr
// 多于29天59分钟59秒,少于364天23小时59分钟59秒,且传入的时间戳早于当前
else if (diff > 2623859 && diff <= 31567859 && IS_EARLY) resStr = getDate(timeStamp)
else resStr = getDate(timeStamp, 'year')
return resStr
}
/**
* @returns {String} 当前浏览器名称
*/
export const getExplorer = () => {
const ua = window.navigator.userAgent
const isExplorer = (exp) => {
return ua.indexOf(exp) > -1
}
if (isExplorer('MSIE')) return 'IE'
else if (isExplorer('Firefox')) return 'Firefox'
else if (isExplorer('Chrome')) return 'Chrome'
else if (isExplorer('Opera')) return 'Opera'
else if (isExplorer('Safari')) return 'Safari'
}
/**
* @description 绑定事件 on(element, event, handler)
*/
export const on = (function() {
if (document.addEventListener) {
return function(element, event, handler) {
if (element && event && handler) {
element.addEventListener(event, handler, false)
}
}
} else {
return function(element, event, handler) {
if (element && event && handler) {
element.attachEvent('on' + event, handler)
}
}
}
})()
/**
* @description 解绑事件 off(element, event, handler)
*/
export const off = (function() {
if (document.removeEventListener) {
return function(element, event, handler) {
if (element && event) {
element.removeEventListener(event, handler, false)
}
}
} else {
return function(element, event, handler) {
if (element && event) {
element.detachEvent('on' + event, handler)
}
}
}
})()
/**
* 判断一个对象是否存在key,如果传入第二个参数key,则是判断这个obj对象是否存在key这个属性
* 如果没有传入key这个参数,则判断obj对象是否有键值对
*/
export const hasKey = (obj, key) => {
if (key) return key in obj
else {
const keysArr = Object.keys(obj)
return keysArr.length
}
}
/**
* @param {*} obj1 对象
* @param {*} obj2 对象
* @description 判断两个对象是否相等,这两个对象的值只能是数字或字符串
*/
export const objEqual = (obj1, obj2) => {
const keysArr1 = Object.keys(obj1)
const keysArr2 = Object.keys(obj2)
if (keysArr1.length !== keysArr2.length) return false
else if (keysArr1.length === 0 && keysArr2.length === 0) return true
/* eslint-disable-next-line */
else return !keysArr1.some(key => obj1[key] != obj2[key])
}
/**
* Created by PanJiaChen on 16/11/18.
*/
/**
* @param {string} path
* @returns {Boolean}
*/
export function isExternal(path) {
return /^(https?:|mailto:|tel:)/.test(path)
}
/**
* @param {string} str
* @returns {Boolean}
*/
export function validUsername(str) {
const valid_map = ['admin', 'editor']
return valid_map.indexOf(str.trim()) >= 0
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment