code init

This commit is contained in:
chenxiaoxi
2021-05-25 18:06:45 +08:00
parent 02698d6dab
commit f54a8d4fa1
1367 changed files with 540755 additions and 21713 deletions
@@ -0,0 +1,213 @@
<template>
<!-- <div>-->
<el-col :span="24">
<el-form-item
:label="config.attrName"
:prop="config.attrField"
label-width="150px"
class="add-form-item"
:class="{'form-item-disabled': disabled}"
>
<el-button size="small" @click="clickButtonToUpload('opinionFileList')" icon="el-icon-upload"
class="form-upload-btn">
{{ (value === 'null' || value === '' || value == null) ? '点击上传' : '查看已上传的文件' }}
</el-button>
<el-dialog
width='400px'
:visible.sync="importModalshowflagtemp"
title="导入文件"
:footer-hide="true"
append-to-body
>
<el-upload
multiple
drag
:show-file-list="showUploadlist"
:on-success="uploadSuccess"
:before-upload="beforeUpload"
:on-remove="removeOneFile"
:action="uploadPath"
accept=".PDF, .pdf, .doc, .DOC, .docx, .DOCX, .xls, .xlsx, .ppt, .pptx, .PPT, .PPTX, .JPG, .JPEG, .PNG, .jpg, .jpeg, .png"
name="file"
:file-list="defaultFileList"
ref="importFileAboutStand">
<i class="el-icon-upload"></i>
<div class="el-upload__text">点击或拖拽上传文件</div>
</el-upload>
</el-dialog>
</el-form-item>
</el-col>
<!-- </div>-->
</template>
<script>
export default {
name: 'CustomFile',
data () {
return {
showUploadlist: true, // 导入过程中新增数据时,如果数据错误,不出现导入列表
uploadPath: 'api/att/attFile/upload',
defaultFileList: [], // 默认显示
importModalshowflagtemp: false
}
},
props: {
config: {
type: Object,
required: true
},
value: {
required: true
},
disabled: {
type: Boolean,
default: false
},
// 指定允许上传的类型
allowType: {
type: Array
}
},
computed: {
placeholder () {
return `请输入${this.config.attrName}`
},
showMessage () {
return `${this.config.attrName}不能为空`
},
isRequired () {
return !!this.config.isMust
}
},
methods: {
beforeUpload (file) {
var filename = file.name
var index1 = filename.lastIndexOf('.')
var index2 = filename.length
var fileSuffix = filename.substring(index1, index2)
// 判断上传文件格式
if (!this.allowType) {
if (fileSuffix === '.pdf' || fileSuffix === '.PDF' || fileSuffix === '.doc' || fileSuffix === '.docx' || fileSuffix === '.ppt' || fileSuffix === '.pptx') {
// if (fileSuffix === 'xlsx' || fileSuffix === 'xls') {
return true
} else {
this.$message.error('文件' + file.name + '格式不正确,请上传pdf、PDF、doc、docx、ppt、pptx文件')
// this.$message.error('文件' + file.name + '格式不正确,请上传xls文件')
return false
}
} else {
if (!this.allowType.includes(fileSuffix)) {
this.$message.error(`文件${file.name}格式不正确,请上传${this.allowType.join('、')}文件`)
return false
}
}
// 判断文件上传大小
if (file.size <= 1024 * 1024 * 5) {// eslint-disable-line
return true
} else {
this.$message.error('文件' + file.name + '大小不超过5M')
return false
}
return true
},
handleChange (event) {
const value = event.target.value
this.$emit('input', value)
},
clickButtonToUpload (current) {
this.importModalshowflagtemp = true
this.$refs.importFileAboutStand && this.$refs.importFileAboutStand.clearFiles()
this.defaultFileList = []
if (this.value === 'null' || this.value == null) {
// this.value = ''
this.$emit('input', '')
}
let fileList
if (this.value != null && this.value !== '') {
let paramefile = this.value
if (paramefile.charAt(paramefile.length - 1) === ',') {
paramefile = paramefile.substring(0, paramefile.length - 1)
}
this.$http.get('att/attFile/getMultiFileInfos', {
fileIds: paramefile
}, {
_this: this
}, res => {
fileList = res.data
if (fileList != null && fileList.length > 0) {
for (let i = 0; i < fileList.length; i++) {
let obj = {name: '', response: {}}
obj.name = fileList[i].oldFileName
obj.response.data = fileList[i]
this.defaultFileList.push(obj)
}
}
}, e => {
})
}
},
uploadSuccess (res, file, fileList) {
if (res.ok) {
this.$emit('input', this.value + res.data.id + ',')
this.$message({
message: '文件上传成功',
type: 'success'
})
} else {
this.$message({
message: '文件上传失败',
type: 'error'
})
}
},
removeOneFile (file, fileList) {
const value = this.value
let ids = value.split(',')
let fileIds = file.response.data.id
let newIdList = this.removeArray(ids, fileIds)
let newStr = ''
if (newIdList != null && newIdList.length > 0) {
for (let i = 0; i < newIdList.length; i++) {
if (newIdList[i] !== '') {
newStr += newIdList[i] + ','
}
}
this.$emit('input', newStr)
} else {
this.$emit('input', '')
}
},
handleAddFormatError (file) {
this.$Message.error('文件' + file.name + '格式不正确,请上传pdf、PDF、doc、docx、ppt、pptx文件')
},
// 导入文件大小超出范围
handleSizeError (file) {
// this.spinShow = false
this.$Message.error('文件' + file.name + '大小不超过200M')
},
// 删除数组中的某个对象
removeArray (_arr, _obj) {
var length = _arr.length
for (var i = 0; i < length; i++) {
if (_arr[i] === _obj) {
if (i === 0) {
_arr.shift() // 删除并返回数组的第一个元素
return _arr
} else if (i === length - 1) {
_arr.pop() // 删除并返回数组的最后一个元素
return _arr
} else {
_arr.splice(i, 1) // 删除下标为i的元素
return _arr
}
}
}
}
}
}
</script>
<style scoped>
</style>
@@ -0,0 +1,299 @@
<template>
<div ref="wrap">
<div id="container"></div>
</div>
</template>
<script>
import G6 from '@antv/g6';
export default {
name: 'knowledgeGraph',
props: {
data: {
type: Object,
default: {}
}
},
data() {
return {
graphData: {},
graph: null,
}
},
watch: {
// data:{
// immediate: true,
// handler: (val, newVal) => {
// }
// }
data(val, newVal) {
this.graphData = val
this.changeGraphData(val)
}
},
methods: {
renderGraph() {
G6.registerNode(
'tree-node',
{
drawShape: function drawShape(cfg, group) {
const level = parseInt(cfg.level)
const nodeType = cfg.nodeType
if (nodeType === 'ROOT') {
const circle = group.addShape('circle', {
attrs: {
fill: '#CD7326'
// stroke: '#666',
},
name: 'circle-shape',
});
const content = cfg.name ? cfg.name.replace(/(.{19})/g, '$1\n') : ''
const text = group.addShape('text', {
attrs: {
text: content,
x: 0,
y: 0,
textAlign: 'center',
textBaseline: 'middle',
fill: '#fff',
},
name: 'text-shape',
});
const bbox = text.getBBox();
const hasChildren = cfg.children && cfg.children.length > 0;
let marker
if (hasChildren) {
marker = group.addShape('marker', {
attrs: {
x: bbox.maxX + 16,
y: 0,
r: 6,
symbol: cfg.collapsed ? G6.Marker.expand : G6.Marker.collapse,
stroke: '#666',
lineWidth: 2,
},
name: 'collapse-icon',
});
}
circle.attr({
x: 0,
y: 0,
r: (bbox.width + 12) / 2,
});
} else {
const rect = group.addShape('rect', {
attrs: {
fill: '#fff',
// stroke: '#666',
},
name: 'rect-shape',
});
const content = cfg.name ? cfg.name.replace(/(.{19})/g, '$1\n') : ''
const text = group.addShape('text', {
attrs: {
text: content,
x: 0,
y: 0,
textAlign: 'center',
textBaseline: 'middle',
fill: '#fff',
},
name: 'text-shape',
});
const bbox = text.getBBox();
const hasChildren = cfg.children && cfg.children.length > 0;
let marker
if (hasChildren) {
marker = group.addShape('marker', {
attrs: {
x: bbox.maxX + 16,
y: 0,
r: 6,
symbol: cfg.collapsed ? G6.Marker.expand : G6.Marker.collapse,
stroke: '#666',
lineWidth: 2,
},
name: 'collapse-icon',
nodeStateStyles: {
selected: {
fill: 'steelblue'
}
}
});
}
rect.attr({
x: bbox.minX - 6,
y: bbox.minY - 6,
width: bbox.width + 12,
height: bbox.height + 12,
radius: (bbox.height + 12) / 2
});
// 自定义层级颜色
if (nodeType === 'BWH') {
rect.attr({
fill: '#1C98B8'
});
} else if (nodeType === 'FBW') {
rect.attr({
fill: '#5165D4'
});
} else if (nodeType === 'GROUP') {
rect.attr({
fill: '#E23335'
});
} else if (nodeType === 'STAND') {
rect.attr({
fill: '#ADAAA1'
});
}
}
return group;
},
},
'single-node',
);
this.graph = new G6.TreeGraph({
container: 'container',
width: this.$refs['wrap'].scrollWidth,
height: this.$refs['wrap'].scrollHeight,
modes: {
default: [
{
type: 'collapse-expand',
onChange: function onChange(item, collapsed) {
const data = item.get('model');
const icon = item.get('group').find((element) => element.get('name') === 'collapse-icon');
if (collapsed) {
icon.attr('symbol', G6.Marker.expand);
} else {
icon.attr('symbol', G6.Marker.collapse);
}
data.collapsed = collapsed;
return true;
},
shouldBegin: (e) => {
const target = e.target
const nodeType = target.cfg.name
if (nodeType === 'collapse-icon') return true;
return false;
}
},
'drag-canvas',
'zoom-canvas',
],
},
defaultNode: {
type: 'tree-node',
anchorPoints: [
[0, 0.5],
[1, 0.5],
],
},
defaultEdge: {
type: 'cubic-horizontal',
style: {
stroke: '#A3B1BF',
},
},
layout: {
type: 'compactBox',
direction: 'LR',
getId: function getId(d) {
return d.id;
},
getHeight: function getHeight() {
return 16;
},
getWidth: function getWidth() {
return 16;
},
getVGap: function getVGap() {
return 20;
},
getHGap: function getHGap() {
return 80;
},
},
});
let graphData = this.graphData
G6.Util.traverseTree(graphData, function(item) {
// console.log(item)
const data = item.data || {}
item.id = item.nodeId;
item.name = item.nodeName
item.nodeType = data.menuType
});
this.graph.data(graphData);
this.graph.render();
this.graph.fitView();
this.handleGraphNodeClickEvent(this.graph)
this.handleGraphEdgeClickEvent(this.graph)
this.handleGraphDraw(this.graph)
},
changeGraphData(val) {
let graphData = val
G6.Util.traverseTree(graphData, function(item) {
const data = item.data || {}
item.id = item.nodeId;
item.name = item.nodeName
item.nodeType = data.menuType
});
this.graph.changeData(graphData)
this.graph.fitView();
},
handleGraphNodeClickEvent(graph) {
// 点击节点
graph.on('node:click', (e) => {
// 先将所有当前是 click 状态的节点置为非 click 状态
const clickNodes = graph.findAllByState('node', 'click');
clickNodes.forEach((cn) => {
graph.setItemState(cn, 'click', false);
});
const nodeItem = e.item; // 获取被点击的节点元素对象
this.$emit('nodeClick', nodeItem)
graph.setItemState(nodeItem, 'click', true); // 设置当前节点的 click 状态为 true
});
},
handleGraphDraw(graph) {
// graph.on('beforelayout', (cfg, group) => {
// this.$nextTick(() => {
// this.graph.zoom(0.5);
// })
// })
},
handleGraphEdgeClickEvent(graph) {
// 点击边
graph.on('edge:click', (e) => {
// 先将所有当前是 click 状态的边置为非 click 状态
const clickEdges = graph.findAllByState('edge', 'click');
clickEdges.forEach((ce) => {
graph.setItemState(ce, 'click', false);
});
const edgeItem = e.item; // 获取被点击的边元素对象
console.log('EdgeClick', edgeItem)
graph.setItemState(edgeItem, 'click', true); // 设置当前边的 click 状态为 true
this.$emit('edgeClick', edgeItem)
});
},
destoryGraph() {
this.graph.destroy()
}
},
mounted() {
this.renderGraph()
},
beforeDestroy() {
this.destoryGraph()
}
}
</script>
<style lang="less" scoped>
#container {
width: 100%;
height: 100%;
}
</style>
@@ -0,0 +1,191 @@
<template>
<el-popover
placement="bottom"
trigger="click"
v-model="participantsPopover"
>
<div class="api">
<dept-tree treeDivId="entrustTree"
ref="entrustDeptTree"
@treeDblClick="handleUserNodeDbClick"
showUser
allDept
:editable="false"
style="width: 200px;height: 500px;overflow: auto">
</dept-tree>
</div>
<div
slot="reference"
class="el-select"
>
<div
class="el-select__tags"
ref="tags"
:style="{ 'max-width': inputWidth - 32 + 'px', width: '100%' }">
<transition-group @after-leave="resetInputHeight">
<el-tag
v-for="item in selected"
:key="item.id"
:closable="true"
:hit="false"
type="info"
@close="deleteTag($event, item)"
disable-transitions>
<span class="el-select__tags-text">{{ item.name }}</span>
</el-tag>
</transition-group>
</div>
<el-input
ref="reference"
:placeholder="placeholder"
>
<template slot="suffix">
<i :class="['el-select__caret', 'el-input__icon', 'el-icon-' + iconClass]"></i>
</template>
</el-input>
</div>
</el-popover>
</template>
<script>
import eventHub from '@/common/eventHub'
import {valueEquals} from './util'
export default {
name: "personSelect",
props: {
value: {
type: [String, Array],
default: []
},
placeholder: {
type: String,
default: ''
}
},
data() {
return {
inputWidth: 0,
participantsPopover: false,
selected: [],
deptUser: []
}
},
computed: {
iconClass() {
return this.participantsPopover ? 'arrow-up is-reverse' : 'arrow-up'
},
},
watch: {
value(val, oldVal) {
this.resetInputHeight();
this.setSelected();
}
},
methods: {
resetInputHeight() {
this.$nextTick(() => {
if (!this.$refs.reference) return;
let inputChildNodes = this.$refs.reference.$el.childNodes;
let input = [].filter.call(inputChildNodes, item => item.tagName === 'INPUT')[0];
const tags = this.$refs.tags;
const sizeInMap = this.initialInputHeight || 40;
input.style.height = this.selected.length === 0
? sizeInMap + 'px'
: Math.max(
tags ? (tags.clientHeight + (tags.clientHeight > sizeInMap ? 6 : 0)) : 0,
sizeInMap
) + 'px';
if (this.visible && this.emptyText !== false) {
this.broadcast('ElSelectDropdown', 'updatePopper');
}
});
},
resetInputWidth() {
this.inputWidth = this.$refs.reference.$el.getBoundingClientRect().width;
},
setSelected() {
let result = [];
if (Array.isArray(this.value)) {
this.value.forEach(value => {
result.push(this.getOption(value));
});
}
this.selected = result;
this.$nextTick(() => {
this.resetInputHeight();
});
},
setDeptUser(data) {
if (!data) {
data = []
}
this.deptUser = [...data]
this.setSelected()
},
getOption(value) {
const option = this.deptUser.find(item => item.id === value)
if (option) return option
const newOption = {
id: value,
name: value,
shortName: value
}
return newOption
},
deleteTag(event, tag) {
let index = this.selected.indexOf(tag);
if (index > -1) {
const value = this.value.slice();
value.splice(index, 1);
this.$emit('input', value);
this.emitChange(value);
this.$emit('remove-tag', tag.value);
}
event.stopPropagation();
},
emitChange(val) {
if (!valueEquals(this.value, val)) {
this.$emit('change', val);
}
},
handleUserNodeDbClick(nodeId, node) {
this.$refs['entrustDeptTree'].cancelSelectedNode()
const id = node.id
if (this.value.includes(id)) {
return
}
let value = []
if (this.value.length) {
value = [].concat(this.value, node.id)
} else {
value = [].concat(node.id)
}
this.$emit('input', value)
},
},
created() {
eventHub.$on('deptUser', this.setDeptUser)
},
mounted() {
const reference = this.$refs.reference;
this.$nextTick(() => {
if (reference && reference.$el) {
this.inputWidth = reference.$el.getBoundingClientRect().width;
}
});
},
beforeDestroy() {
eventHub.$off('deptUser', this.setDeptUser)
}
}
</script>
<style scoped>
</style>
@@ -0,0 +1,114 @@
<template>
<div style="display: inline-block;">
<el-button type="primary" size="small" @click="openStandSelectDialog">手动查找</el-button>
<el-dialog title="相关标准" :visible.sync="replaceStandNumModel" width="875px" :close-on-click-modal="false" @close="replaceStandNumModelCancel = false">
<el-form :modal="replaceStandNumForm" :inline="true" class="label-input-form">
<el-form-item label="标准号/名称" class="serch-form-item">
<el-input v-model="replaceStandNumForm.standNumber" placeholder="根据标准号/名称查找" clearable :maxlength="100"
@keyup.enter.native="getDomesticStandardTableBtn(standCommonlySearch)"></el-input>
</el-form-item>
<el-button
:loading="searching"
icon="el-icon-search"
type="primary"
size="mini"
class="searchAngNewBtn"
@click="getReplaceStandNumRow(1,replaceStandNumForm.pageSize, 'search')">
</el-button>
<el-button type="primary" size="small" @click="getReplaceStandNumRow('')">清空查询</el-button>
</el-form>
<el-table
ref="selections"
:data="replaceStandNumRow"
:loading="lawsExplainQuoteFormLoading"
tooltip-effect="dark"
style="width: 100%;overflow-y: auto;overflow-x: hidden;"
border
:header-cell-style="{background: '#f8f8f9', color: '#515a6e'}"
@selection-change="selectReplaceStandNumRowChange"
@select-all="(selection) =>selectReplaceStandNumRowSelect(selection, 'all')"
@select="(selection, row) =>selectReplaceStandNumRowSelect(selection,'select', row )">
<el-table-column
type="selection"
width="55"
align="center">
</el-table-column>
<el-table-column
label="标准号"
width="130"
align="center">
<template slot-scope="scope">
<a v-if="scope.row.standYear" @click="handlePreview(scope.row)">{{ scope.row.standSortShow }} {{ scope.row.standNumber }}-{{ scope.row.standYear }}</a>
<a v-else @click="handlePreview(scope.row)">{{ scope.row.standSortShow }} {{ scope.row.standNumber }}</a>
</template>
</el-table-column>
<el-table-column
prop="standName"
label="标准名称"
width="130"
align="center">
</el-table-column>
<el-table-column
prop="issueTime"
label="发布日期"
width="130"
align="center">
</el-table-column>
<el-table-column
prop="putTime"
label="实施日期"
width="130"
align="center">
</el-table-column>
<el-table-column
prop="standNatureShow"
label="标准性质"
width="130"
align="center">
</el-table-column>
<el-table-column
prop="standStateShow"
label="标准状态"
width="130"
align="center">
</el-table-column>
</el-table>
<pagination
:page="replacePage"
:total="replaceTotal"
@pageChange="pageChangeReplace"
@pageSizeChange="pageSizeChangeReplace"></pagination>
<!-- <el-divider></el-divider>-->
<div slot="footer" class="demo-drawer-footer">
<el-button round class="common-button-primary" icon="el-icon-check" @click="replaceStandNumModelCancel">取消</el-button>
<el-button type="primary" round class="common-button-default" icon="el-icon-close" @click="replaceStandNumModelBt">提交</el-button>
<!-- <el-button size="mini" type="primary" @click="replaceStandNumModelCancel">取消</el-button>-->
<!-- <el-button size="mini" type="primary" @click="replaceStandNumModelBt">确定</el-button>-->
</div>
</el-dialog>
</div>
</template>
<script>
export default {
name: 'standSelect',
methods: {
/**
* 打开标准号选择弹框
*/
openStandSelectDialog () {
if (this.standNumFlag === 1) {
this.$refs.selections.selectAll(false)
}
// this.sarStandardsInfoEO.replaceStandNum = ''
this.replaceStandNumModel = true
this.getReplaceStandNumRow('')
},
}
}
</script>
<style scoped>
</style>
@@ -0,0 +1,194 @@
<template>
<div id="tableFile">
<el-button size="small" @click="clickButtonToUpload('opinionFileList')" icon="el-icon-upload"
class="form-upload-btn">
{{ (value === 'null' || value === '' || value == null) ? '点击上传' : '查看已上传的文件' }}
</el-button>
<el-dialog
width='400px'
:visible.sync="importModalshowflagtemp"
title="导入文件"
:footer-hide="true"
append-to-body
>
<el-upload
multiple
drag
:show-file-list="showUploadlist"
:on-success="uploadSuccess"
:before-upload="beforeUpload"
:on-remove="removeOneFile"
:action="uploadPath"
accept=".PDF, .doc, .docx, .ppt, .pptx"
name="file"
:file-list="defaultFileList"
ref="importFileAboutStand">
<i class="el-icon-upload"></i>
<div class="el-upload__text">点击或拖拽上传文件</div>
</el-upload>
</el-dialog>
</div>
</template>
<script>
export default {
name: 'CustomFile',
data () {
return {
showUploadlist: true, // 导入过程中新增数据时,如果数据错误,不出现导入列表
uploadPath: 'api/att/attFile/upload',
defaultFileList: [], // 默认显示
importModalshowflagtemp: false
}
},
props: {
value: {
required: true
},
disabled: {
type: Boolean,
default: false
},
// 指定允许上传的类型
allowType: {
type: Array
}
},
computed: {},
methods: {
beforeUpload (file) {
var filename = file.name
var index1 = filename.lastIndexOf('.')
var index2 = filename.length
var fileSuffix = filename.substring(index1, index2)
// 判断上传文件格式
if (!this.allowType) {
if (fileSuffix === '.pdf' || fileSuffix === '.PDF' || fileSuffix === '.doc' || fileSuffix === '.docx' || fileSuffix === '.ppt' || fileSuffix === '.pptx') {
// if (fileSuffix === 'xlsx' || fileSuffix === 'xls') {
return true
} else {
this.$message.error('文件' + file.name + '格式不正确,请上传pdf、PDF、doc、docx、ppt、pptx文件')
// this.$message.error('文件' + file.name + '格式不正确,请上传xls文件')
return false
}
} else {
if (!this.allowType.includes(fileSuffix)) {
this.$message.error(`文件${file.name}格式不正确,请上传${this.allowType.join('、')}文件`)
return false
}
}
// 判断文件上传大小
if (file.size <= 1024 * 1024 * 300) {// eslint-disable-line
return true
} else {
this.$message.error('文件' + file.name + '大小不超过300M')
return false
}
},
handleChange (event) {
const value = event.target.value
this.$emit('input', value)
},
clickButtonToUpload (current) {
this.importModalshowflagtemp = true
this.$refs.importFileAboutStand && this.$refs.importFileAboutStand.clearFiles()
this.defaultFileList = []
if (this.value === 'null' || this.value == null) {
// this.value = ''
this.$emit('input', '')
}
let fileList
if (this.value != null && this.value !== '') {
let paramefile = this.value
if (paramefile.charAt(paramefile.length - 1) === ',') {
paramefile = paramefile.substring(0, paramefile.length - 1)
}
this.$http.get('att/attFile/getMultiFileInfos', {
fileIds: paramefile
}, {
_this: this
}, res => {
fileList = res.data
if (fileList != null && fileList.length > 0) {
for (let i = 0; i < fileList.length; i++) {
let obj = {name: '', response: {}}
obj.name = fileList[i].oldFileName
obj.response.data = fileList[i]
this.defaultFileList.push(obj)
}
}
}, e => {
})
}
},
uploadSuccess (res, file, fileList) {
if (res.ok) {
this.$emit('input', this.value + res.data.id + ',')
this.$message({
message: '文件上传成功',
type: 'success'
})
} else {
this.$message({
message: '文件上传失败',
type: 'error'
})
}
},
removeOneFile (file, fileList) {
const value = this.value
let ids = value.split(',')
let fileIds = file.response.data.id
let newIdList = this.removeArray(ids, fileIds)
let newStr = ''
if (newIdList != null && newIdList.length > 0) {
for (let i = 0; i < newIdList.length; i++) {
if (newIdList[i] !== '') {
newStr += newIdList[i] + ','
}
}
this.$emit('input', newStr)
} else {
this.$emit('input', '')
}
},
handleAddFormatError (file) {
this.$Message.error('文件' + file.name + '格式不正确,请上传pdf、PDF、doc、docx、ppt、pptx文件')
},
// 导入文件大小超出范围
handleSizeError (file) {
// this.spinShow = false
this.$Message.error('文件' + file.name + '大小不超过200M')
},
// 删除数组中的某个对象
removeArray (_arr, _obj) {
var length = _arr.length
for (var i = 0; i < length; i++) {
if (_arr[i] === _obj) {
if (i === 0) {
_arr.shift() // 删除并返回数组的第一个元素
return _arr
} else if (i === length - 1) {
_arr.pop() // 删除并返回数组的最后一个元素
return _arr
} else {
_arr.splice(i, 1) // 删除下标为i的元素
return _arr
}
}
}
}
}
}
</script>
<style lang="less" scoped>
#tableFile {
display: flex;
justify-content: center;
align-items: center;
.form-upload-btn {
position: static !important;
}
}
</style>
@@ -0,0 +1,439 @@
<!-- 组织机构树 -->
<template>
<div class="dept-tree">
<laws-tree
ref="deptTree"
:treeDivId="treeDivId"
:zNodes="zNodes"
:expandAll="expandAll"
:editable="editable"
:deptSelect="deptSelect"
:pIdCheck="pIdCheck"
:checkEnable="checkEnable"
:loading="loading.treeLoading"
:onlyChecked="onlyChecked"
@treeClick="(treeId, treeNode) => treeClick(treeId, treeNode)"
@treeOnExpand="(treeId, treeNode) => treeOnExpand(treeId, treeNode)"
@treeDblClick="(treeId, treeNode) => treeDblClick(treeId, treeNode)"
@treeReady="treeReady"
@treeOnCheck="(checkedList) => treeOnCheck(checkedList)"
></laws-tree>
</div>
</template>
<script>
import eventHub from '@/common/eventHub'
export default {
name: 'deptTree',
data () {
return {
dept: [], // 部门节点
deptUser: [], // 部门人员节点
projectManagerzNodes: [],
loading: {
treeLoading: false
}
}
},
methods: {
// 节点点击
treeClick (treeId, treeNode) {
this.$emit('treeClick', treeId, treeNode)
},
// 节点双击
treeDblClick (treeId, treeNode) {
this.$emit('treeDblClick', treeId, treeNode)
},
// 节点展开
treeOnExpand (treeId, treeNode) {
// this.projectManagerClick(treeNode.id, this.projectManagerzNodes)
// this.$emit('treeOnExpand', treeId, treeNode)
},
// 首次加载完成
treeReady () {
this.$emit('treeReady')
},
// 节点重新加载
treeReload () {
this.$refs.deptTree.lawsTreeInit()
},
// 选择节点复选框事件
treeOnCheck (checkedList) {
const personCheckedNameList = []
const personCheckedIdList = []
checkedList.map(item => {
if (item.orgName) {
personCheckedNameList.push(item.name)
personCheckedIdList.push(item.id)
}
})
const personCheckedId = personCheckedIdList.join(',')
const personCheckedName = personCheckedNameList.join(',')
this.$emit('treeOnCheck', checkedList)
this.$emit('personCheck', personCheckedId, personCheckedName)
},
// 回显选中checked节点
checkedNode (checkedNodes) {
this.$refs.deptTree.checkedNode(checkedNodes)
},
/**
* @description: 获取组织到部门
* @author: chenxiaoxi
* @date: 2018/10/11 16:29:37
*/
getDept () {
this.loading.treeLoading = true
return new Promise((resolve, reject) => {
let url = this.allDept ? 'sys/org/getTree' : 'sys/org/getIdsByorgType'
this.$http.get(url, {}, {
_this: this
}, res => {
if (res.ok) {
let zNodesDept = []
res.data.map((item, i) => {
let zObj = {}
// 该节点为机构
zObj.name = item.orgName
zObj.icon = 'static/images/dept.png'
// zObj.isParent = true
zObj.shotName = item.shotName
zObj.remarks = item.remarks
zObj.id = item.id
zObj.pId = item.pId
zNodesDept[i] = zObj
})
this.dept = zNodesDept
resolve(res.data)
}
}, e => {
reject(e)
})
})
},
/**
* @description: 获取所有人员
* @author: chenxiaoxi
* @date: 2018/10/11 16:57:33
*/
getUser (treeNodeList) {
return new Promise((resolve, reject) => {
this.$http.get('sys/user', {
pageNo: 1,
processFlag: '1'
}, {
_this: this
}, res => {
if (res.ok) {
for (let i = 0; i < res.data.list.length; i++) {
let obj = {}
for (let key in res.data.list[i]) {
if (key === 'usid') {
obj.id = res.data.list[i][key]
} else if (key === 'orgId') {
obj.pId = res.data.list[i][key]
} else {
obj[key] = res.data.list[i][key]
}
}
treeNodeList.push(obj)
}
// 获取组织与人员完毕,开始组装树结构
let zNodes = []
for (let i = 0; i < treeNodeList.length; i++) {
let zObj = {}
zObj.id = treeNodeList[i].id
zObj.pId = treeNodeList[i].pId
// 该节点为人员
if (treeNodeList[i].uname !== undefined) {
zObj.name = treeNodeList[i].uname
zObj.icon = 'static/images/user.png'
zObj.isParent = false
zObj.orgName = treeNodeList[i].orgName
} else {
// 该节点为机构
zObj.name = treeNodeList[i].orgName
zObj.icon = 'static/images/dept.png'
zObj.isParent = true
}
zObj.shotName = treeNodeList[i].shotName
zObj.remarks = treeNodeList[i].remarks
if (zObj.pId === null && !zObj.isParent) {
zObj.pId = ''
zObj.orgName = '未分配人员'
}
zNodes[i] = zObj
}
zNodes.push({
id: '',
pId: null,
name: '未分配人员',
isParent: true,
icon: 'static/images/dept.png'
})
this.deptUser = zNodes
this.loading.treeLoading = false
eventHub.$emit('deptUser', this.deptUser)
}
resolve()
}, e => {
reject(e)
})
})
},
/**
* @description: 选中节点移除
* @author: chenxiaoxi
* @date: 2018/10/29 14:42:02
*/
removeNode (treeNode) {
this.$refs.deptTree.removeNode(treeNode)
},
/**
* @description: 节点添加
* @author: chenxiaoxi
* @date: 2018/10/29 14:53:24
*/
addNode (treeNode) {
this.$refs.deptTree.addNode(treeNode)
},
/**
* @description: 节点取消选中
* @author: chenxiaoxi
* @date: 2018/10/29 16:09:11
*/
cancelSelectedNode (treeNode) {
if (treeNode !== '' && treeNode !== undefined) {
this.$refs.deptTree.cancelSelectedNode(treeNode)
} else {
this.$refs.deptTree.cancelSelectedNode()
}
},
/**
* @description: 节点选中
* @author: chenxiaoxi
* @date: 2018/10/29 16:14:23
*/
selectNode (treeNode) {
if (treeNode !== '' && treeNode !== undefined) {
this.$refs.deptTree.selectNode(treeNode)
}
},
/**
* @description: 获取选中节点
* @author: chenxiaoxi
* @date: 2018/10/29 16:14:23
*/
getSelectNode (idList) {
return this.$refs.deptTree.getSelectNode(idList)
},
/**
* @description: 保存打开的节点
* @author: chenxiaoxi
* @date: 2018/11/23 16:37:01
*/
setOpenNodes () {
this.$refs.deptTree.setOpenNodes()
},
/**
* @description: 清空过滤输入框
* @author: chenxiaoxi
* @date: 2018/11/23 16:52:10
*/
clearSearch () {
this.$refs.deptTree.clearSearch()
},
/**
* @author liruohao
* @date 2019/4/24
* @Description: 获取选中的部门下子子部门
*/
getDeptChild (list) {
this.$http.get('sys/org/getChildDept', {
orgId: list[0]
}, {
_this: this
}, res => {
if (res.ok) {
// 获取组织与人员完毕,开始组装树结构
let zNodes = []
let treeNodeList = res.data
for (let i = 0; i < treeNodeList.length; i++) {
let zObj = {}
zObj.id = treeNodeList[i].id
zObj.pId = treeNodeList[i].pId
// 该节点为机构
zObj.name = treeNodeList[i].orgName
zObj.icon = 'static/images/dept.png'
zObj.isParent = true
zObj.shotName = treeNodeList[i].shotName
zObj.remarks = treeNodeList[i].remarks
zNodes[i] = zObj
}
this.projectManagerClick(list[0], zNodes)
}
}, e => {
})
},
/**
* @author liruohao
* @date 2019/4/23
* @Description: 根据部门查询项目经理 责任工程师
*/
projectManagerClick (id, treeNodeList) {
this.$http.get('sys/org/getTreeByRoleAndOrgId1', {
roleName: this.department[1],
orgId: id,
processFlag: '1'
}, {
_this: this
}, res => {
if (res.ok) {
if (res.data.list.length !== 0) {
for (let i = 0; i < res.data.list.length; i++) {
let obj = {}
for (let key in res.data.list[i]) {
if (key === 'usId') {
obj.id = res.data.list[i][key]
} else if (key === 'userName') {
obj.name = res.data.list[i][key]
} else {
obj.icon = 'static/images/user.png'
obj.isParent = false
obj[key] = res.data.list[i][key]
}
}
treeNodeList.push(obj)
}
this.projectManagerzNodes = treeNodeList
}
}
}, e => {
})
}
},
components: {},
props: {
// 是否显示组织下的用户
showUser: {
type: Boolean,
default: false
},
// 是否禁用
disabled: {
type: Boolean,
default: false
},
// 部门节点
zNodesDept: {
type: Array
},
// 部门人员节点
zNodesDeptUser: {
type: Array
},
// 是否可进行操作
editable: {
type: Boolean,
default: true
},
// 部门是否可以被选择
deptSelect: {
type: Boolean,
default: false
},
// 树实例Id
treeDivId: {
type: String
},
// 是否获取所有组织
allDept: {
type: Boolean,
default: false
},
// 是否根据责任部门查找经理
department: {
type: Array
},
// 需要回显的节点
idList: {
type: Array,
required: false
},
// 回显的部门节点
deptList: {
type: Array
},
// 是否展开全部
expandAll: {
type: Boolean,
default: false
},
// 不选中根节点
pIdCheck: {
type: Boolean,
default: false
},
// 是否开启复选框
checkEnable: {
type: Boolean,
default: false
},
// 只能checkbox选中,不能点击选中节点
onlyChecked: {
type: Boolean,
default: false
}
},
computed: {
// 节点(给lawsTree传的节点,根据展示的类型传不同的值)
zNodes () {
return this.showUser ? (this.zNodesDeptUser || this.deptUser) : (this.projectManagerzNodes.length === 0 ? (this.zNodesDept || this.dept) : this.projectManagerzNodes)
}
},
watch: {
zNodes (val) {
this.$nextTick(() => {
if (this.idList && this.idList.length) {
let deptUser = this.$refs.deptTree.getSelectNode(this.idList)
this.$emit('selectNodeUser', deptUser)
}
})
},
deptList (val) {
if (val.length) {
let zNodes = this.showUser ? (this.zNodesDeptUser || this.deptUser) : (this.zNodesDept || this.dept)
for (let i = 0; i < zNodes.length; i++) {
val.map((displayNode) => {
if (zNodes[i].id === displayNode.id) {
zNodes.splice(i, 1)
}
})
}
}
}
},
mounted () {
if (this.department) {
this.getDeptChild(this.department)
} else {
this.getDept().then(res => {
this.getUser(res)
}, e => {})
}
}
}
</script>
<style lang="less">
.dept-tree{
height: 100%;
}
</style>
+241
View File
@@ -0,0 +1,241 @@
import Vue from 'vue';
import { isString, isObject } from 'element-ui/src/utils/types';
const hasOwnProperty = Object.prototype.hasOwnProperty;
export function noop() {};
export function hasOwn(obj, key) {
return hasOwnProperty.call(obj, key);
};
function extend(to, _from) {
for (let key in _from) {
to[key] = _from[key];
}
return to;
};
export function toObject(arr) {
var res = {};
for (let i = 0; i < arr.length; i++) {
if (arr[i]) {
extend(res, arr[i]);
}
}
return res;
};
export const getValueByPath = function(object, prop) {
prop = prop || '';
const paths = prop.split('.');
let current = object;
let result = null;
for (let i = 0, j = paths.length; i < j; i++) {
const path = paths[i];
if (!current) break;
if (i === j - 1) {
result = current[path];
break;
}
current = current[path];
}
return result;
};
export function getPropByPath(obj, path, strict) {
let tempObj = obj;
path = path.replace(/\[(\w+)\]/g, '.$1');
path = path.replace(/^\./, '');
let keyArr = path.split('.');
let i = 0;
for (let len = keyArr.length; i < len - 1; ++i) {
if (!tempObj && !strict) break;
let key = keyArr[i];
if (key in tempObj) {
tempObj = tempObj[key];
} else {
if (strict) {
throw new Error('please transfer a valid prop path to form item!');
}
break;
}
}
return {
o: tempObj,
k: keyArr[i],
v: tempObj ? tempObj[keyArr[i]] : null
};
};
export const generateId = function() {
return Math.floor(Math.random() * 10000);
};
export const valueEquals = (a, b) => {
// see: https://stackoverflow.com/questions/3115982/how-to-check-if-two-arrays-are-equal-with-javascript
if (a === b) return true;
if (!(a instanceof Array)) return false;
if (!(b instanceof Array)) return false;
if (a.length !== b.length) return false;
for (let i = 0; i !== a.length; ++i) {
if (a[i] !== b[i]) return false;
}
return true;
};
export const escapeRegexpString = (value = '') => String(value).replace(/[|\\{}()[\]^$+*?.]/g, '\\$&');
// TODO: use native Array.find, Array.findIndex when IE support is dropped
export const arrayFindIndex = function(arr, pred) {
for (let i = 0; i !== arr.length; ++i) {
if (pred(arr[i])) {
return i;
}
}
return -1;
};
export const arrayFind = function(arr, pred) {
const idx = arrayFindIndex(arr, pred);
return idx !== -1 ? arr[idx] : undefined;
};
// coerce truthy value to array
export const coerceTruthyValueToArray = function(val) {
if (Array.isArray(val)) {
return val;
} else if (val) {
return [val];
} else {
return [];
}
};
export const isIE = function() {
return !Vue.prototype.$isServer && !isNaN(Number(document.documentMode));
};
export const isEdge = function() {
return !Vue.prototype.$isServer && navigator.userAgent.indexOf('Edge') > -1;
};
export const isFirefox = function() {
return !Vue.prototype.$isServer && !!window.navigator.userAgent.match(/firefox/i);
};
export const autoprefixer = function(style) {
if (typeof style !== 'object') return style;
const rules = ['transform', 'transition', 'animation'];
const prefixes = ['ms-', 'webkit-'];
rules.forEach(rule => {
const value = style[rule];
if (rule && value) {
prefixes.forEach(prefix => {
style[prefix + rule] = value;
});
}
});
return style;
};
export const kebabCase = function(str) {
const hyphenateRE = /([^-])([A-Z])/g;
return str
.replace(hyphenateRE, '$1-$2')
.replace(hyphenateRE, '$1-$2')
.toLowerCase();
};
export const capitalize = function(str) {
if (!isString(str)) return str;
return str.charAt(0).toUpperCase() + str.slice(1);
};
export const looseEqual = function(a, b) {
const isObjectA = isObject(a);
const isObjectB = isObject(b);
if (isObjectA && isObjectB) {
return JSON.stringify(a) === JSON.stringify(b);
} else if (!isObjectA && !isObjectB) {
return String(a) === String(b);
} else {
return false;
}
};
export const arrayEquals = function(arrayA, arrayB) {
arrayA = arrayA || [];
arrayB = arrayB || [];
if (arrayA.length !== arrayB.length) {
return false;
}
for (let i = 0; i < arrayA.length; i++) {
if (!looseEqual(arrayA[i], arrayB[i])) {
return false;
}
}
return true;
};
export const isEqual = function(value1, value2) {
if (Array.isArray(value1) && Array.isArray(value2)) {
return arrayEquals(value1, value2);
}
return looseEqual(value1, value2);
};
export const isEmpty = function(val) {
// null or undefined
if (val == null) return true;
if (typeof val === 'boolean') return false;
if (typeof val === 'number') return !val;
if (val instanceof Error) return val.message === '';
switch (Object.prototype.toString.call(val)) {
// String or Array
case '[object String]':
case '[object Array]':
return !val.length;
// Map or Set or File
case '[object File]':
case '[object Map]':
case '[object Set]': {
return !val.size;
}
// Plain Object
case '[object Object]': {
return !Object.keys(val).length;
}
}
return false;
};
export function rafThrottle(fn) {
let locked = false;
return function(...args) {
if (locked) return;
locked = true;
window.requestAnimationFrame(_ => {
fn.apply(this, args);
locked = false;
});
};
}
export function objToArray(obj) {
if (Array.isArray(obj)) {
return obj;
}
return isEmpty(obj) ? [] : [obj];
}
File diff suppressed because it is too large Load Diff