Commit e026e3cf by xinla

--no commit message

1 parent 9dae7c3b
...@@ -55,13 +55,22 @@ export default { ...@@ -55,13 +55,22 @@ export default {
return {} return {}
}, },
computed: {}, computed: {},
watch: {}, watch: {
series() {
this.$nextTick(() => {
this.drawChart()
})
}
},
created() {}, created() {},
mounted() { mounted() {
this.drawChart() this.drawChart()
}, },
methods: { methods: {
drawChart() { drawChart() {
if (!(this.series && this.series.length)) {
return
}
// eslint-disable-next-line // eslint-disable-next-line
this.myChart = echarts.init(this.$refs.chart) this.myChart = echarts.init(this.$refs.chart)
let option let option
...@@ -160,16 +169,17 @@ export default { ...@@ -160,16 +169,17 @@ export default {
this.option && merge(option, this.option) this.option && merge(option, this.option)
option && this.myChart.setOption(option) option && this.myChart.setOption(option)
new ResizeObserver((entries) => { // new ResizeObserver((entries) => {
this.myChart.resize() // this.myChart.resize()
}).observe(this.$refs.chart) // }).observe(this.$refs.chart)
} }
} }
} }
</script> </script>
<template> <template>
<div ref="chart" class="chart-bar chart"></div> <div v-if="series && series.length" ref="chart" class="chart-bar chart"></div>
<div v-else>暂无数据</div>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -58,7 +58,9 @@ export default { ...@@ -58,7 +58,9 @@ export default {
computed: {}, computed: {},
watch: { watch: {
series() { series() {
this.$nextTick(() => {
this.drawChart() this.drawChart()
})
} }
}, },
created() {}, created() {},
...@@ -67,6 +69,9 @@ export default { ...@@ -67,6 +69,9 @@ export default {
}, },
methods: { methods: {
drawChart() { drawChart() {
if (!(this.series && this.series.length)) {
return
}
// eslint-disable-next-line // eslint-disable-next-line
this.myChart = echarts.init(this.$refs.chart) this.myChart = echarts.init(this.$refs.chart)
let option let option
...@@ -215,7 +220,8 @@ export default { ...@@ -215,7 +220,8 @@ export default {
</script> </script>
<template> <template>
<div ref="chart" class="chart-line chart"></div> <div v-if="series && series.length" ref="chart" class="chart-line chart"></div>
<div v-else>暂无数据</div>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
......
<script> <script>
import { getTree, getList } from '@/api/organization' import { getTree, getList } from '@/api/organization'
import { createUniqueString } from '@/utils' import { createUniqueString } from '@/utils'
export default { export default {
name: 'SelectUser', name: 'SelectUser',
components: {}, components: {},
props: { props: {
// 添加标签显隐 // 添加标签显隐
visible: { visible: {
type: Boolean, type: Boolean,
default: false, default: false
}, },
title: { title: {
type: String, type: String,
default: '组织架构', default: '组织架构'
}, },
// 是否 只选择叶子节点(人员节点)/禁止选择父节点(部门节点) // 是否 只选择叶子节点(人员节点)/禁止选择父节点(部门节点)
isOnlyLeaf: { isOnlyLeaf: {
type: Boolean, type: Boolean,
default: true, default: true
}, },
// 是否单选 // 是否单选
isSigleSelect: { isSigleSelect: {
type: Boolean, type: Boolean,
default: false, default: false
}, },
defaultValues: { defaultValues: {
type: Array, type: Array,
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
}, },
destroyOnClose: Boolean destroyOnClose: Boolean
}, },
data () { data() {
let isOnlyLeaf = this.isOnlyLeaf let isOnlyLeaf = this.isOnlyLeaf
return { return {
treeData: [], treeData: [],
...@@ -38,41 +38,38 @@ ...@@ -38,41 +38,38 @@
defaultProps: { defaultProps: {
label: 'name', label: 'name',
children: 'children', children: 'children',
disabled (data, node) { disabled(data, node) {
return isOnlyLeaf && !data.userId return isOnlyLeaf && data.isParty
}, },
isLeaf (data, node) { isLeaf(data, node) {
return !data.id return !data.id
}, }
}, }
} }
}, },
watch: { watch: {
defaultValues (value) { defaultValues(value) {
if (this.$refs.tree) this.$refs.tree.setCheckedKeys([]) if (this.$refs.tree) this.$refs.tree.setCheckedKeys([])
} }
}, },
computed: { computed: {
Pvisible: { Pvisible: {
get () { get() {
// this.getTree(); // this.getTree();
return this.visible return this.visible
}, },
set (val) { set(val) {
this.$emit('update:visible', val) this.$emit('update:visible', val)
}
}, },
}, defaultCheckedKeys() {
defaultCheckedKeys () {
const checkedList = [] const checkedList = []
const checkedUserList = [] const checkedUserList = []
if ( if (!Array.isArray(this.defaultValues) || this.defaultValues.length == 0) {
!Array.isArray(this.defaultValues) ||
this.defaultValues.length == 0
) {
this.userList = [] this.userList = []
} else { } else {
this.defaultValues.forEach(i => { this.defaultValues.forEach((i) => {
const id = this.isOnlyLeaf ? i.userId : (i.userId || i.id) const id = this.isOnlyLeaf ? i.userId : i.userId || i.id
if (id) { if (id) {
checkedList.push(id) checkedList.push(id)
checkedUserList.push(i) checkedUserList.push(i)
...@@ -83,13 +80,13 @@ ...@@ -83,13 +80,13 @@
return checkedList return checkedList
} }
}, },
created () { }, created() {},
mounted () { }, mounted() {},
methods: { methods: {
treeFormat (list) { treeFormat(list) {
let dealOptions = [] let dealOptions = []
list.forEach(one => { list.forEach((one) => {
let findIndex = list.findIndex(item => { let findIndex = list.findIndex((item) => {
return item.id === one.parentId return item.id === one.parentId
}) })
if ((!one.parentId && one.parentId !== 0 && one.parentId !== false) || findIndex === -1) { if ((!one.parentId && one.parentId !== 0 && one.parentId !== false) || findIndex === -1) {
...@@ -105,11 +102,9 @@ ...@@ -105,11 +102,9 @@
}) })
return dealOptions return dealOptions
}, },
loadNode (node, resolve) { loadNode(node, resolve) {
if (node.level === 0) { if (node.level === 0) {
if (!Array.isArray(this.defaultValues) || if (!Array.isArray(this.defaultValues) || this.defaultValues.length == 0) {
this.defaultValues.length == 0
) {
this.userList = [] this.userList = []
} }
getTree().then(({ data }) => { getTree().then(({ data }) => {
...@@ -124,19 +119,17 @@ ...@@ -124,19 +119,17 @@
// }); // });
}) })
} else { } else {
getList({ department: node.data.id, isActivate: 1 }).then( getList({ department: node.data.id, isActivate: 1 }).then(({ rows }) => {
({ rows }) => {
// rows.forEach((element) => { // rows.forEach((element) => {
// element.key = createUniqueString() // element.key = createUniqueString()
// }) // })
node.data.children && rows.push(...node.data.children) node.data.children && rows.push(...node.data.children)
resolve(rows) resolve(rows)
} })
)
} }
}, },
handleTree (data) { handleTree(data) {
return data.map(i => { return data.map((i) => {
if (i.id) { if (i.id) {
i.userId = i.id i.userId = i.id
i.isParty = true i.isParty = true
...@@ -145,7 +138,7 @@ ...@@ -145,7 +138,7 @@
}) })
}, },
// 选择变化 // 选择变化
handleCheckChange (data, checked, indeterminate) { handleCheckChange(data, checked, indeterminate) {
// console.log(arguments) // console.log(arguments)
if (checked) { if (checked) {
if (this.isSigleSelect) { if (this.isSigleSelect) {
...@@ -157,50 +150,63 @@ ...@@ -157,50 +150,63 @@
this.userList.push(data) this.userList.push(data)
} }
} else { } else {
const isExist = this.userList.findIndex(i => i.userId === data.userId) > -1 const isExist = this.userList.findIndex((i) => i.userId === data.userId) > -1
!isExist && this.userList.push(data) !isExist && this.userList.push(data)
} }
} else { } else {
// let index = this.userList.indexOf(data) // let index = this.userList.indexOf(data)
let index = this.userList.findIndex(i => i.userId === data.userId) let index = this.userList.findIndex((i) => i.userId === data.userId)
index > -1 && this.userList.splice(index, 1) index > -1 && this.userList.splice(index, 1)
} }
// console.log(data, checked, indeterminate); // console.log(data, checked, indeterminate);
this.userList = this.unique(this.userList) this.userList = this.unique(this.userList)
}, },
unique (arr) { unique(arr) {
for (var i = 0; i < arr.length; i++) { for (var i = 0; i < arr.length; i++) {
for (var j = i + 1; j < arr.length; j++) { for (var j = i + 1; j < arr.length; j++) {
if (arr[i].userId.split('_')[0] == arr[j].userId.split('_')[0]) { if (arr[i].userId.split('_')[0] == arr[j].userId.split('_')[0]) {
arr.splice(j, 1); arr.splice(j, 1)
j--; j--
} }
} }
} }
return arr; return arr
}, },
// 确 定 // 确 定
submit () { submit() {
this.Pvisible = false this.Pvisible = false
this.$emit('success', [...this.userList]) this.$emit('success', [...this.userList])
}, },
// 取消选择 // 取消选择
cancle (key) { cancle(key) {
this.$refs.tree.setChecked(key, false) this.$refs.tree.setChecked(key, false)
let index = this.userList.findIndex(i => i.userId === key) let index = this.userList.findIndex((i) => i.userId === key)
index > -1 && this.userList.splice(index, 1) index > -1 && this.userList.splice(index, 1)
let order = this.defaultValues.findIndex(i => i.userId === key) let order = this.defaultValues.findIndex((i) => i.userId === key)
order > -1 && this.defaultValues.splice(order, 1) order > -1 && this.defaultValues.splice(order, 1)
},
},
} }
}
}
</script> </script>
<template> <template>
<el-dialog :title="title" :visible.sync="Pvisible" :destroy-on-close="destroyOnClose"> <el-dialog :title="title" :visible.sync="Pvisible" :destroy-on-close="destroyOnClose">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12" :xs="24"> <el-col :span="12" :xs="24">
<div class="head-container"> <div class="head-container">
<el-tree node-key="userId" ref="tree" lazy accordion show-checkbox :check-on-click-node="false" :expand-on-click-node="true" :default-checked-keys="defaultCheckedKeys" :load="loadNode" :props="defaultProps" :check-strictly="isOnlyLeaf" @check-change="handleCheckChange"></el-tree> <el-tree
node-key="userId"
ref="tree"
lazy
accordion
show-checkbox
:check-on-click-node="false"
:expand-on-click-node="true"
:default-checked-keys="defaultCheckedKeys"
:load="loadNode"
:props="defaultProps"
:check-strictly="isOnlyLeaf"
@check-change="handleCheckChange"
></el-tree>
</div> </div>
</el-col> </el-col>
<el-col :span="12" :xs="24" class="user-list"> <el-col :span="12" :xs="24" class="user-list">
...@@ -220,9 +226,9 @@ ...@@ -220,9 +226,9 @@
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
.user-list { .user-list {
.el-row { .el-row {
line-height: 26px; line-height: 26px;
} }
} }
</style> </style>
...@@ -110,6 +110,18 @@ export default { ...@@ -110,6 +110,18 @@ export default {
getList(page) { getList(page) {
this.query.beginTime = this.dateRange && this.dateRange[0] this.query.beginTime = this.dateRange && this.dateRange[0]
this.query.endTime = this.dateRange && this.dateRange[1] this.query.endTime = this.dateRange && this.dateRange[1]
if (Array.isArray(this.userArray)) {
this.query.deptIds = this.userArray
.filter((e) => e.isParty)
.map((e) => e.id)
.join(',')
this.query.userIds = this.userArray
.filter((e) => !e.isParty)
.map((e) => e.userId)
.join(',')
} else {
this.query.deptIds = this.query.userIds = ''
}
this.loading = true this.loading = true
page && (this.query.pageNum = page) page && (this.query.pageNum = page)
...@@ -183,13 +195,9 @@ export default { ...@@ -183,13 +195,9 @@ export default {
} }
}, },
getSelectUser(data) { getSelectUser(data) {
debugger
this.userArray = data this.userArray = data
this.query.qrUserName = this.userArray this.query.qrUserName = data.map((e) => e.name).join(',')
.map(function (obj, index) { this.getList()
return obj.name
})
.join(',')
} }
} }
} }
...@@ -218,25 +226,21 @@ export default { ...@@ -218,25 +226,21 @@ export default {
value-format="yyyy-MM-dd" value-format="yyyy-MM-dd"
type="daterange" type="daterange"
:clearable="false" :clearable="false"
:picker-options="pickerOptions"
range-separator="-" range-separator="-"
start-placeholder="开始日期" start-placeholder="开始日期"
end-placeholder="结束日期" end-placeholder="结束日期"
@change="getList(1)" @change="getList(1)"
></el-date-picker> ></el-date-picker>
<el-select <el-input
v-if="type.toLowerCase().includes('group')" v-if="type.toLowerCase().includes('group')"
v-model="query.group" v-model="query.group"
readonly
@focus="dialogVisible = true"
placeholder="请选择群主" placeholder="请选择群主"
@change="getList(1)" @change="getList(1)"
> >
<el-option </el-input>
v-for="item in groupOwners"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
<el-select <el-select
v-if="['customerGroupMemberTotalChart', 'customerGroupMemberTotalTable'].includes(type)" v-if="['customerGroupMemberTotalChart', 'customerGroupMemberTotalTable'].includes(type)"
v-model="query.group" v-model="query.group"
...@@ -252,7 +256,14 @@ export default { ...@@ -252,7 +256,14 @@ export default {
</el-option> </el-option>
</el-select> </el-select>
<el-input <el-input
v-if="['customerTotalChart', 'realDataChart', 'customerContactTable'].includes(type)" v-if="
[
'customerTotalChart',
'customerTotalTable',
'realDataChart',
'customerContactTable'
].includes(type)
"
style="width: 180px" style="width: 180px"
:value="query.qrUserName" :value="query.qrUserName"
readonly readonly
...@@ -289,6 +300,7 @@ export default { ...@@ -289,6 +300,7 @@ export default {
title="组织架构" title="组织架构"
:selected="userArray" :selected="userArray"
@success="getSelectUser" @success="getSelectUser"
:isOnlyLeaf="false"
></SelectUser> ></SelectUser>
</div> </div>
</template> </template>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!