Commit 67e294da by xinla

公用组件优化与新增等,从release的部分合并

1 parent bd33c200
...@@ -27,9 +27,15 @@ ...@@ -27,9 +27,15 @@
<div class="load-title">正在加载系统资源,请耐心等待</div> <div class="load-title">正在加载系统资源,请耐心等待</div>
</div> </div>
<script type="module" src="/src/main.js"></script> <script type="module" src="/src/main.js"></script>
<script>
<script src="https://hm.baidu.com/hm.js?8f5214f3a0f80a33eb32a0f890167cc1"></script> setTimeout(() => {
<script src="https://hm.baidu.com/hm.js?489a58fd4fcaf2347cee64a8827e7094"></script> if (window.lwConfig && window.lwConfig._env !== 'development') {
var hm = document.createElement("script").src = "https://hm.baidu.com/hm.js?489a58fd4fcaf2347cee64a8827e7094";
var hm1 = document.createElement("script").src = "https://hm.baidu.com/hm.js?8f5214f3a0f80a33eb32a0f890167cc1";
document.body.append(hm, hm1)
}
}, 1000);
</script>
</body> </body>
</html> </html>
\ No newline at end of file \ No newline at end of file
...@@ -179,9 +179,9 @@ export default { ...@@ -179,9 +179,9 @@ export default {
</script> </script>
<template> <template>
<div v-if="series && series.length" ref="chart" class="chart-bar chart" key="1"></div> <div v-if="series?.length" ref="chart" class="chart-bar chart" key="1"></div>
<div v-else class="chart-bar chart" key="2"> <div v-else class="chart-bar chart" key="2">
<div class="cc">暂无数据</div> <div class="cc"><Empty /></div>
</div> </div>
</template> </template>
......
...@@ -221,8 +221,10 @@ export default { ...@@ -221,8 +221,10 @@ export default {
</script> </script>
<template> <template>
<div v-if="series && series.length" ref="chart" class="chart-line chart" key="1"></div> <div v-if="series?.length" ref="chart" class="chart-line chart" key="1"></div>
<div v-else class="chart-line chart" key="2"><div class="cc">暂无数据</div></div> <div v-else class="chart-line chart" key="2">
<div class="cc"><Empty /></div>
</div>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -122,13 +122,17 @@ export default { ...@@ -122,13 +122,17 @@ export default {
</script> </script>
<template> <template>
<div ref="chart" class="chart-pie chart"></div> <div v-if="series?.length" ref="chart" class="chart-pie chart" key="1"></div>
<div v-else class="chart-pie chart" key="2">
<div class="cc"><Empty /></div>
</div>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
.chart { .chart {
position: relative;
max-height: 100%; max-height: 100%;
min-width: 200px; min-width: 400px;
min-height: 200px; min-height: 400px;
} }
</style> </style>
<!-- 时间搜索(近一周,近一月,自定义)数据图表或表格 组件 -->
<script>
// import * as customerApi from '@/api/operateCenter/customerAnalysis'
// import * as groupApi from '@/api/operateCenter/groupAnalysis'
// import * as conversationApi from '@/api/operateCenter/conversationAnalysis'
import { getList as getGroupList } from '@/api/customer/group'
export default {
name: '',
components: {
ChartLine: defineAsyncComponent(() => import('@/components/ChartLine')),
ChartBar: defineAsyncComponent(() => import('@/components/ChartBar')),
},
props: {
// 数据展示图表类型
type: {
type: String, // lineChart, barChart, table
default: 'lineChart',
},
// 接口请求
request: {
type: Function,
},
// 是否显示时间查询
isTimeQuery: {
type: Boolean,
default: true,
},
// 是否显示选择部门员工搜索框
isStaffQuery: {
type: Boolean,
default: false,
},
// 选择员工搜索框的placeholder
staffQueryPlaceholder: {
type: String,
default: '请选择部门或员工',
},
// 是否只选择员工, 不能通过选择部门来选择员工
isOnlyStaff: {
type: Boolean,
default: false,
},
// 是否只选择部门
isOnlyDepart: {
type: Boolean,
default: false,
},
// 是否显示选择群聊搜索框
isGroupQuery: {
type: Boolean,
default: false,
},
// 自定义的查询参数处理方法,可用于添加和修改查询参数
dealQueryFun: {
type: Function,
default: null,
},
// 自定义的返回数据处理方法,可用于添加和修改查询参数
dealDataFun: {
type: Function,
default: null,
},
// 导出接口请求
requestExport: {
type: Function,
default: null,
},
// 导出文件名(需包含后缀名)
exportFileName: { type: String },
// 图表图例; 单个图例可传字符串,多个图例传数组
legend: {
type: [Array, String],
default: null,
},
// 自定义图表配置项,使用loadsh.merge(origin, option)和原有的配置进行覆盖合并
// loadsh.merge: https://www.html.cn/doc/lodash/#_mergeobject-sources
option: {
type: Object,
default: null,
},
},
data() {
return {
loading: false,
timeRange: 7,
total: 0,
// 表格数据
data: [],
xData: [],
// 日期范围
dateRange: [],
// 查询参数
query: {
pageNum: 1,
pageSize: undefined,
deptIds: [],
userIds: [],
chatIds: [],
ownerIds: [],
beginTime: undefined,
endTime: undefined,
},
// 群聊
groupChats: [],
tableProps: [],
userArray: [], // 选择人员
dialogVisible: false,
dialogType: '',
}
},
computed: {},
watch: {},
created() {
this.setTime(7)
this.isGroupQuery && this.getGroupList()
},
mounted() {},
methods: {
getList(page) {
if (this.type == 'table') {
this.query.pageSize || (this.query.pageSize = 10)
}
if (this.dateRange) {
this.query.beginTime = this.dateRange[0]
this.query.endTime = this.dateRange[1]
} else {
this.query.beginTime = ''
this.query.endTime = ''
}
this.dealQueryFun && this.dealQueryFun(this.query)
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(',')
if (this.isGroupQuery) {
this.query.ownerIds = this.userArray
.filter((e) => !e.isParty)
.map((e) => e.userId)
.join(',')
}
} else {
this.query.deptIds = this.query.userIds = this.query.ownerIds = ''
}
this.loading = true
page && (this.query.pageNum = page)
this.request(this.query)
.then(({ rows, total, data }) => {
data = data || rows
// if (!data) {
// return
// }
if (this.type == 'table') {
// 表格
this.data = data
this.total = +total
} else {
// 自定义echarts图表数据处理
this.dealDataFun && this.dealDataFun(data, this.data, this.xData)
}
})
.catch((e) => {
console.error(e)
})
.finally(() => {
this.loading = false
})
},
getTime(datePar) {
const d = datePar ? new Date(datePar) : new Date()
d.setMinutes(d.getMinutes() - d.getTimezoneOffset())
return d.toJSON().substr(0, 10)
},
setTime(days) {
this.timeRange = days
if (days) {
let date = new Date()
date.setDate(date.getDate() - days)
this.dateRange = [this.getTime(date), this.getTime()]
this.getList()
} else {
this.dateRange = null
}
},
// showDialog(type) {
// this.dialogType = type
// this.dialogVisible = true
// },
getSelectUser(data) {
this.userArray = data
if (this.isGroupQuery) {
this.query.chatIds = ''
// 根据群主获取群列表
this.getGroupList({
userIds: data.map((e) => e.userId).join(','),
})
}
this.getList()
},
// 获取群列表
getGroupList(params) {
getGroupList(params)
.then(({ rows }) => {
this.groupChats = rows
})
.catch(() => {})
},
exprotTable() {
this.$confirm('是否确认导出吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
this.loading = true
let query = Object.assign({}, this.query, { pageNum: undefined, pageSize: undefined })
return this.requestExport(query)
})
.then((resBlob) => {
this.downloadBlob(resBlob, this.exportFileName)
})
.catch((error) => {
console.error(error)
})
.finally(() => {
this.loading = false
})
},
},
}
</script>
<template>
<div>
<div class="operation">
<template v-if="isTimeQuery">
<el-button-group>
<el-button type="primary" :plain="timeRange != 7" @click="setTime(7)">近一周</el-button>
<el-button type="primary" :plain="timeRange != 30" @click="setTime(30)">近一月</el-button>
<el-button type="primary" :plain="!!timeRange" @click="setTime()">自定义</el-button>
</el-button-group>
<el-date-picker
v-if="!timeRange"
v-model="dateRange"
class="ml20"
style="width: 260px"
value-format="YYYY-MM-DD"
type="daterange"
:clearable="false"
v-bind="pickerOptions"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
@change="getList(1)"></el-date-picker>
</template>
<el-input
v-if="isStaffQuery"
style="width: 180px; margin-left: 20px"
:model-value="userArray.map((e) => e.name) + ''"
readonly
@click="dialogVisible = true"
:placeholder="staffQueryPlaceholder" />
<el-select
style="margin-left: 20px; vertical-align: middle"
v-if="isGroupQuery"
v-model="query.chatIds"
placeholder="请选择群聊"
clearable
@change="getList()">
<el-option
v-for="item in groupChats"
:key="item.chatId"
:label="item.groupName"
:value="item.chatId"></el-option>
</el-select>
<!-- <el-input
v-if="isStaffQuery"
style="width: 180px; margin-left: 20px"
:model-value="userArray.map((e) => e.name) + ''"
readonly
@click="showDialog('_users')"
:placeholder="staffQueryPlaceholder"/> -->
<slot name="query" :query="query"></slot>
<el-button v-if="requestExport" style="position: absolute; right: 0" type="primary" @click="exprotTable">
导出 Excel
</el-button>
</div>
<div v-loading="loading">
<!-- 折线图 -->
<ChartLine v-if="type == 'lineChart'" :xData="xData" :legend="legend" :series="data" :option="option"></ChartLine>
<!-- 柱状图 -->
<ChartBar v-else-if="'barChart'.includes(type)" :xData="xData" :series="data" :option="option"></ChartBar>
<!-- 表格 -->
<template v-else-if="type == 'table'">
<slot name="table" :data="data"></slot>
<pagination
:total="total"
v-model:page="query.pageNum"
v-model:limit="query.pageSize"
@pagination="getList()" />
</template>
</div>
<SelectUser
v-model:visible="dialogVisible"
title="组织架构"
departReplaceUser
:defaultValues="userArray"
:isOnlyDepart="isOnlyDepart"
:isOnlyLeaf="isOnlyStaff"
@success="getSelectUser"></SelectUser>
</div>
</template>
<style lang="scss" scoped>
.operation {
position: relative;
// display: flex;
// align-items: center;
margin-bottom: var(--card-margin, 16px);
}
</style>
<template>
<!-- 空状态,没有数据的时候 -->
<el-empty v-bind="$attrs" />
<!-- <div class="empty">
<svg-icon class="right-icon" :icon="nodataObj[type].svgName"></svg-icon>
<div class="nodata-text">{{ description}}</div>
</div> -->
</template>
<script>
export default {
props: {
// 显示的提示文字
// description: {
// type: String,
// default: null,
// },
},
data() {
return {}
},
}
</script>
<style lang="scss" scoped>
// .empty {
// width: 100%;
// height: 100%;
// display: flex;
// flex-direction: column;
// text-align: center;
// align-items: center;
// justify-content: center;
// .right-icon {
// width: 80px;
// height: 64px;
// }
// .nodata-text {
// font-size: 14px;
// font-weight: 400;
// color: #4e5969;
// line-height: 22px;
// }
// }
</style>
<template>
<!--
导入表格模板弹窗 组件
由透传属性,可直接使用 el-dialog 的所有props,
用法示例:<ImportDialog v-model="dialogVisible" title="title"/>
-->
<el-dialog width="600px" :close-on-click-modal="false">
<el-form v-loading="loading" ref="ruleForm" label-width="100px">
<el-form-item label="选择表格:" style="margin-bottom: 0">
<div style="display: flex; align-items: center; justify-content: space-between; height: 100%">
<div>
<input ref="input" type="file" style="display: none" @change="changeFile" />
<span v-if="file?.name" style="margin-right: 15px" @click="$refs.input.click()">{{ file?.name }}</span>
<el-button text @click="$refs.input.click()">
{{ file?.name ? '重新上传' : '上传表格' }}
</el-button>
</div>
<el-button v-if="downloadTemplateRequest" text @click="downloadTemplate">模版下载</el-button>
</div>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="$emit('update:model-value', false)">取消</el-button>
<el-button :disabled="!file?.name" type="primary" @click="importFile">确定</el-button>
</template>
</el-dialog>
</template>
<script>
export default {
props: {
// 导入文件格式, eg:xlsx, xls
format: {
type: Array,
default: () => ['xlsx', 'xls'], // xlsx
},
// 文件体积限制大小
maxSize: {
type: Number,
default: 50, // 50M
},
// 下载模板api
downloadTemplateRequest: {
type: Function,
default: undefined,
},
// 导出文件名(需包含后缀名)
downloadFileName: {
type: String,
default: '',
},
},
data() {
return {
loading: false,
file: {},
}
},
mounted() {},
methods: {
// 下载模板
downloadTemplate() {
this.loading = true
this.downloadTemplateRequest()
.then((res) => {
res && this.downloadBlob(res, this.downloadFileName)
})
.finally(() => {
this.loading = false
})
},
changeFile(event) {
let file = event.target.files[0]
const isOk = this.checkFile(file)
if (!isOk) return
this.file = file
},
// 文件校验
checkFile(file) {
const { size, name } = file
const reg = new RegExp(`\\.(${this.format.join('|')})$`, 'ig') // /\.(xlsx|xls)$/ig
const isXlsx = reg.test(name)
const isLimit = size / 1024 / 1024 < this.maxSize
if (!isXlsx) {
this.msgError(`上传文件只能是 ${this.format.join(',')} 格式!`)
}
if (!isLimit) {
this.msgError(`上传文件大小不能超过 ${this.maxSize}MB!`)
}
return isXlsx && isLimit
},
// 确认导入事件
importFile() {
const isOk = this.checkFile(this.file)
if (!isOk) return
this.$emit('confirm', this.$data)
},
},
}
</script>
<style lang="scss" scoped></style>
...@@ -32,7 +32,7 @@ export default { ...@@ -32,7 +32,7 @@ export default {
pageSizes: { pageSizes: {
type: Array, type: Array,
default() { default() {
return [10, 20, 30, 50] return [10, 20, 30, 50, 1000]
}, },
}, },
layout: { layout: {
......
<script> <script>
import { getDeptUserAll } from '@/api/organization' import { getDeptUserAll } from '@/api/organization'
export default { export default {
name: 'SelectPost', name: 'SelectPost',
components: {}, components: {},
props: { props: {
visible: { visible: {
type: Boolean, type: Boolean,
default: false default: false,
}, },
title: { title: {
type: String, type: String,
default: '选择岗位' default: '选择岗位',
}, },
// 是否单选 // 是否单选
isSigleSelect: { isSigleSelect: {
type: Boolean, type: Boolean,
default: false default: false,
}, },
// 默认选中 // 默认选中
defaultValues: { defaultValues: {
type: Array, type: Array,
default: () => [] default: () => [],
}, },
// 禁止选中 // 禁止选中
disabledValues: { disabledValues: {
type: Array, type: Array,
default: () => [] default: () => [],
}, },
destroyOnClose: Boolean destroyOnClose: Boolean,
}, },
data() { data() {
return { return {
postList: [], postList: [],
selectList: [] selectList: [],
} }
}, },
watch: { watch: {
...@@ -41,23 +41,27 @@ ...@@ -41,23 +41,27 @@
this.selectList = value this.selectList = value
}, },
immediate: true, immediate: true,
deep: true deep: true,
}, },
Pvisible(val) { Pvisible(val) {
this.selectList = this.defaultValues this.selectList = this.defaultValues
} },
}, },
computed: { computed: {
Pvisible: { Pvisible: {
get() { get() {
this.visible && !this.postList?.length && this.getList()
return this.visible return this.visible
}, },
set(val) { set(val) {
this.$emit('update:visible', val) this.$emit('update:visible', val)
}
}
}, },
created() { },
},
created() {},
mounted() {},
methods: {
getList() {
getDeptUserAll().then(({ data }) => { getDeptUserAll().then(({ data }) => {
let arr = data.map((item) => { let arr = data.map((item) => {
return item.position return item.position
...@@ -65,8 +69,6 @@ ...@@ -65,8 +69,6 @@
this.postList = Array.from(new Set(arr)) this.postList = Array.from(new Set(arr))
}) })
}, },
mounted() {},
methods: {
// 确 定 // 确 定
submit() { submit() {
this.Pvisible = false this.Pvisible = false
...@@ -75,9 +77,9 @@ ...@@ -75,9 +77,9 @@
// 取消选择 // 取消选择
cancle(index) { cancle(index) {
this.selectList.splice(index, 1) this.selectList.splice(index, 1)
} },
} },
} }
</script> </script>
<template> <template>
<el-dialog :title="title" v-model="Pvisible" :close-on-click-modal="false" :destroy-on-close="destroyOnClose"> <el-dialog :title="title" v-model="Pvisible" :close-on-click-modal="false" :destroy-on-close="destroyOnClose">
...@@ -86,7 +88,7 @@ ...@@ -86,7 +88,7 @@
<div class="head-container"> <div class="head-container">
<el-checkbox-group v-model="selectList"> <el-checkbox-group v-model="selectList">
<template v-for="(unit, index) in postList" :key="index"> <template v-for="(unit, index) in postList" :key="index">
<el-checkbox style="display: block;" :label="unit" v-if="unit" :disabled="disabledValues.includes(unit)"> <el-checkbox style="display: block" :label="unit" v-if="unit" :disabled="disabledValues.includes(unit)">
{{ unit }} {{ unit }}
</el-checkbox> </el-checkbox>
</template> </template>
...@@ -112,9 +114,9 @@ ...@@ -112,9 +114,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>
<script> <script>
import { getDeptTree, getDeptUser } from '@/api/organization' import { getDeptTree, getDeptUser } from '@/api/organization'
export default { export default {
name: 'SelectUser', name: 'SelectUser',
components: {}, components: {},
props: { props: {
isWechat: { isWechat: {
type: Boolean, type: Boolean,
default: true default: true,
}, },
// 添加标签显隐 // 添加标签显隐
visible: { visible: {
type: Boolean, type: Boolean,
default: false default: false,
}, },
title: { title: {
type: String, type: String,
default: '组织架构' default: '组织架构',
},
// 是否 只选择部门节点,true时将不再加载人员节点
isOnlyDepart: {
type: Boolean,
default: false,
}, },
// 是否 只选择叶子节点(人员节点)/禁止选择父节点(部门节点) // 是否 只选择叶子节点(人员节点)/禁止选择父节点(部门节点)
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,
default: () => [], default: () => [],
// 必须含有userId和name属性 // 必须含有userId和name属性, 只有userId不可行,name用于右侧列表回显
validator(val) { validator(val) {
return val.every((e) => e.userId && e.name) return val.every((e) => e.userId && e.name)
} },
}, },
// 禁止选中的节点 // 禁止选中的节点
disabledValues: { disabledValues: {
type: Array, type: Array,
default: () => [] default: () => [],
}, },
destroyOnClose: Boolean, destroyOnClose: Boolean,
// 选中部门时,是否用部门代替显示该部门下所有人员 // 子级全部选中时,右侧选中列表是否只显示父级, 仅在 isOnlyLeaf 为 false 时有效
departReplaceUser: { departReplaceUser: {
type: Boolean, type: Boolean,
default: false default: false,
} },
}, },
data() { data() {
return { return {
...@@ -57,7 +62,7 @@ ...@@ -57,7 +62,7 @@
keywords: '', keywords: '',
searchResult: [], searchResult: [],
searchState: false, searchState: false,
checked: [] checked: [],
} }
}, },
watch: { watch: {
...@@ -77,7 +82,7 @@ ...@@ -77,7 +82,7 @@
} }
}, },
immediate: true, immediate: true,
deep: true deep: true,
}, },
Pvisible(val) { Pvisible(val) {
val && this.$refs.tree && this.$refs.tree.setCheckedKeys(this.defaultValues.map((e) => e.userId || e.id)) val && this.$refs.tree && this.$refs.tree.setCheckedKeys(this.defaultValues.map((e) => e.userId || e.id))
...@@ -86,7 +91,7 @@ ...@@ -86,7 +91,7 @@
this.$refs.tree && this.$refs.tree.setCheckedKeys(this.defaultValues.map((e) => e.userId || e.id)) this.$refs.tree && this.$refs.tree.setCheckedKeys(this.defaultValues.map((e) => e.userId || e.id))
}, 300) }, 300)
} }
} },
}, },
computed: { computed: {
Pvisible: { Pvisible: {
...@@ -95,7 +100,7 @@ ...@@ -95,7 +100,7 @@
}, },
set(val) { set(val) {
this.$emit('update:visible', val) this.$emit('update:visible', val)
} },
}, },
defaultProps() { defaultProps() {
let that = this let that = this
...@@ -107,11 +112,11 @@ ...@@ -107,11 +112,11 @@
}, },
isLeaf(data, node) { isLeaf(data, node) {
return !data.id return !data.id
} },
} }
}, },
dealedUserList() { dealedUserList() {
if (!this.departReplaceUser) { if (this.isOnlyLeaf || !this.departReplaceUser) {
return this.userList return this.userList
} }
// 提取所有部门 // 提取所有部门
...@@ -122,7 +127,7 @@ ...@@ -122,7 +127,7 @@
arr = arr.filter((e) => !arr.some((e2) => e.parentId == e2.id)) arr = arr.filter((e) => !arr.some((e2) => e.parentId == e2.id))
arr.push(...userList) arr.push(...userList)
return arr return arr
} },
}, },
created() {}, created() {},
mounted() {}, mounted() {},
...@@ -142,7 +147,7 @@ ...@@ -142,7 +147,7 @@
}) })
getDeptUser({ getDeptUser({
// deptId: this.deptId, // deptId: this.deptId,
userName: this.keywords userName: this.keywords,
}).then((res) => { }).then((res) => {
this.searchResult = this.handleUser(res.rows) this.searchResult = this.handleUser(res.rows)
}) })
...@@ -199,7 +204,9 @@ ...@@ -199,7 +204,9 @@
resolve(value) resolve(value)
}) })
} else { } else {
getDeptUser({ deptId: node.data.id }).then(({ rows }) => { this.isOnlyDepart
? resolve(node.data.children)
: getDeptUser({ deptId: node.data.id }).then(({ rows }) => {
let arr = this.handleUser(rows) let arr = this.handleUser(rows)
node.data.children && arr.push(...node.data.children) node.data.children && arr.push(...node.data.children)
// 懒加载选中状态的子节点不会触发子节点的选中事件,需要手动触发 // 懒加载选中状态的子节点不会触发子节点的选中事件,需要手动触发
...@@ -278,9 +285,9 @@ ...@@ -278,9 +285,9 @@
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.slice().splice(order, 1) order > -1 && this.defaultValues.slice().splice(order, 1)
} },
} },
} }
</script> </script>
<template> <template>
<el-dialog <el-dialog
...@@ -288,8 +295,7 @@ ...@@ -288,8 +295,7 @@
:title="title" :title="title"
v-model="Pvisible" v-model="Pvisible"
:close-on-click-modal="false" :close-on-click-modal="false"
:destroy-on-close="destroyOnClose" :destroy-on-close="destroyOnClose">
>
<div class="content"> <div class="content">
<div class="left"> <div class="left">
<div class="search-input"> <div class="search-input">
...@@ -298,8 +304,7 @@ ...@@ -298,8 +304,7 @@
@keyup.enter="setSearch" @keyup.enter="setSearch"
placeholder="请输入员工名称" placeholder="请输入员工名称"
clearable clearable
@change="setChange" @change="setChange">
>
<template #append><el-button icon="el-icon-search" @click="setSearch"></el-button></template> <template #append><el-button icon="el-icon-search" @click="setSearch"></el-button></template>
</el-input> </el-input>
</div> </div>
...@@ -326,13 +331,12 @@ ...@@ -326,13 +331,12 @@
:load="loadNode" :load="loadNode"
:props="defaultProps" :props="defaultProps"
:check-strictly="isOnlyLeaf" :check-strictly="isOnlyLeaf"
@check-change="handleCheckChange" @check-change="handleCheckChange"></el-tree>
></el-tree>
</div> </div>
</transition> </transition>
</div> </div>
<div class="right user-list"> <div class="right user-list">
<div>选择人员列表</div> <div>已选列表</div>
<div v-for="(item, index) in dealedUserList" :key="index" class="flex aic"> <div v-for="(item, index) in dealedUserList" :key="index" class="flex aic">
<el-icon-UserFilled class="el-icon-UserFilled"></el-icon-UserFilled> <el-icon-UserFilled class="el-icon-UserFilled"></el-icon-UserFilled>
<span class="user-name">{{ item.name }}</span> <span class="user-name">{{ item.name }}</span>
...@@ -348,42 +352,42 @@ ...@@ -348,42 +352,42 @@
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
.content { .content {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
} }
.left, .left,
.right { .right {
width: 49%; width: 49%;
max-height: calc(100vh - 170px); max-height: calc(100vh - 170px);
overflow: auto; overflow: auto;
} }
.search-input { .search-input {
margin-top: 5px; margin-top: 5px;
margin-bottom: 10px; margin-bottom: 10px;
} }
.user-list { .user-list {
line-height: 26px; line-height: 26px;
padding-right: 10px; padding-right: 10px;
.user-name { .user-name {
margin: 0 5px; margin: 0 5px;
flex: auto; flex: auto;
} }
} }
.search-list { .search-list {
line-height: 26px; line-height: 26px;
padding: 0 10px; padding: 0 10px;
} }
.fade-enter-active { .fade-enter-active {
transition: opacity 0.5s; transition: opacity 0.5s;
} }
.fade-enter { .fade-enter {
opacity: 0; opacity: 0;
} }
.fade-leave-active { .fade-leave-active {
transition: opacity 0.5s; transition: opacity 0.5s;
} }
.fade-leave-to { .fade-leave-to {
opacity: 0; opacity: 0;
} }
</style> </style>
<!-- 选择部门,岗位,人员组合组件 -->
<script>
import { getDeptTree, getDeptUserAll } from '@/api/organization'
import SelectPost from '@/components/SelectPost'
export default {
components: { SelectPost },
props: {
modelValue: {
type: Object,
default: () => ({
selectedUserList: {
select: false,
weUserIds: [],
},
selectedDeptList: {
select: false,
deptIds: [],
},
selectedPostList: {
select: false,
posts: [],
},
}),
},
// 是否必选,至少一项
required: {
type: Boolean,
default: true,
},
},
data() {
return {
dialogVisibleSelectUser: false,
dialogVisibleSelectDept: false,
dialogVisibleSelectPost: false,
selectedUserList: [],
selectedDeptList: [],
// selectedPostList: [],
}
},
computed: {},
watch: {
modelValue: {
handler(val) {
// 设置默认值
val.selectedUserList || (val.selectedUserList = {})
val.selectedDeptList || (val.selectedDeptList = {})
val.selectedPostList || (val.selectedPostList = {})
if (val.selectedUserList?.weUserIds?.length && !this.selectedUserList.length) {
this.setEditUser()
}
if (val.selectedDeptList?.deptIds?.length && !this.selectedDeptList.length) {
this.setEditDept()
}
this.$emit('update:modelValue', val)
},
deep: true,
immediate: true,
},
},
created() {},
mounted() {},
methods: {
// 提交校验
validate() {
if (
this.required &&
!this.modelValue.selectedUserList?.select &&
!this.modelValue.selectedDeptList?.select &&
!this.modelValue.selectedPostList?.select
) {
this.msgError('请选择成员!')
return false
}
if (this.modelValue.selectedUserList?.select) {
if (!this.modelValue.selectedUserList?.weUserIds?.length) {
this.msgError('请选择员工!')
return false
}
}
if (this.modelValue.selectedDeptList?.select) {
if (!this.modelValue.selectedDeptList.deptIds.length) {
this.msgError('请选择部门!')
return false
}
}
if (this.modelValue.selectedPostList?.select) {
if (!this.modelValue.selectedPostList.posts?.length) {
this.msgError('请选择岗位!')
return false
}
}
return true
},
// ------ 选中事件 ------
// 选中员工
selectedUser(data) {
this.selectedUserList = data
this.modelValue.selectedUserList.weUserIds = data.map((dd) => {
return dd.userId
})
// this.changeFn()
},
// 选中部门
selectedDept(data) {
this.selectedDeptList = data
this.modelValue.selectedDeptList.deptIds = data.map((dd) => {
return dd.deptId
})
// this.changeFn()
},
// 选中岗位
selectedPost(data) {
// this.selectedPostList = data
this.modelValue.selectedPostList.posts = data
// this.changeFn()
},
// ------ 清空选中 ------
clearUserData(data) {
if (!data) {
this.selectedUserList = []
this.modelValue.selectedUserList.weUserIds = []
// this.changeFn()
}
},
clearDeptData(data) {
if (!data) {
this.selectedDeptList = []
this.modelValue.selectedDeptList.deptIds = []
// this.selectedPostList = []
// this.modelValue.selectedDeptList.posts = []
// this.changeFn()
}
},
clearPostData(data) {
if (!data) {
// this.selectedPostList = []
this.modelValue.selectedPostList.posts = []
// this.changeFn()
}
},
// changeFn() {
// this.$emit('update', this.modelValue)
// },
// ------ 根据选中的 id 回显 数据 -------
setEditUser() {
if (this.modelValue.selectedUserList?.weUserIds) {
getDeptUserAll().then(({ data }) => {
this.selectedUserList = []
this.modelValue.selectedUserList.weUserIds.forEach((element) => {
let traget = data.find((item) => item.weUserId == element)
if (traget) {
traget.userId = element
traget.name = traget.userName
this.selectedUserList.push(traget)
}
})
})
}
},
setEditDept() {
if (this.modelValue.selectedDeptList?.deptIds?.length) {
getDeptTree().then(({ data }) => {
this.selectedDeptList = []
this.modelValue.selectedDeptList.deptIds.forEach((element) => {
let traget = data.find((item) => item.deptId == element)
if (traget) {
traget.userId = element
traget.name = traget.deptName
this.selectedDeptList.push(traget)
}
})
})
}
},
},
}
</script>
<template>
<div>
<!-- 选择成员 -->
<div>
<el-checkbox v-model="modelValue.selectedUserList.select" @change="clearUserData" label="选择成员"></el-checkbox>
<template v-if="modelValue.selectedUserList.select">
<el-button type="primary" @click="dialogVisibleSelectUser = true">选择成员</el-button>
<TagEllipsis :list="selectedUserList" limit="10" type="info" style="display: block" />
</template>
</div>
<!-- 选择部门 -->
<div class="mt10">
<el-checkbox v-model="modelValue.selectedDeptList.select" @change="clearDeptData" label="选择部门"></el-checkbox>
<template v-if="modelValue.selectedDeptList.select">
<el-button type="primary" @click="dialogVisibleSelectDept = true">选择部门</el-button>
<TagEllipsis :list="selectedDeptList" limit="10" type="info" style="display: block" />
</template>
</div>
<!-- 选择岗位 -->
<div class="mt10">
<el-checkbox v-model="modelValue.selectedPostList.select" @change="clearPostData" label="选择岗位"></el-checkbox>
<template v-if="modelValue.selectedPostList.select">
<el-button type="primary" @click="dialogVisibleSelectPost = true">选择岗位</el-button>
<TagEllipsis :list="modelValue.selectedPostList.posts" limit="10" type="info" style="display: block" />
</template>
</div>
<SelectUser
v-model:visible="dialogVisibleSelectUser"
append-to-body
width="600px"
title="选择员工"
:defaultValues="selectedUserList"
@success="selectedUser"></SelectUser>
<SelectUser
v-model:visible="dialogVisibleSelectDept"
append-to-body
width="600px"
title="选择部门"
:isOnlyDepart="true"
:departReplaceUser="true"
:isOnlyLeaf="false"
:defaultValues="selectedDeptList"
@success="selectedDept"></SelectUser>
<SelectPost
v-model:visible="dialogVisibleSelectPost"
append-to-body
width="600px"
title="选择岗位"
:defaultValues="modelValue.selectedPostList.posts"
@success="selectedPost"></SelectPost>
</div>
</template>
<style lang="scss" scoped>
.el-checkbox {
vertical-align: middle;
margin-right: 10px;
}
</style>
<script> <script>
import { del } from '@/views/clue/clueTemplate/api'
export default { export default {
name: 'TagEllipsis', name: 'TagEllipsis',
components: {}, components: {},
...@@ -15,28 +17,37 @@ export default { ...@@ -15,28 +17,37 @@ export default {
type: String, type: String,
default: 'name', default: 'name',
}, },
// 空数据时显示的文本内容
emptyText: {
type: String,
default: '',
},
}, },
data() { data() {
return {} return {}
}, },
computed: { computed: {
_list() { _list() {
return this.list.filter((e) => (typeof e === 'string' ? e : e[this.defaultProps])) return this.list?.filter((e) => (typeof e === 'string' ? e : e[this.defaultProps]))
}, },
}, },
watch: {}, watch: {},
created() {}, created() {
// 可传入 el-tag 的props
this.elTagProps = Object.assign({}, this.$attrs)
delete this.elTagProps.style
},
mounted() {}, mounted() {},
methods: {}, methods: {},
} }
</script> </script>
<template> <template>
<div class="tag-ellipsis"> <div class="tag-ellipsis" v-if="_list?.length || emptyText">
<div v-if="!_list.length">无</div> <div v-if="!_list?.length">{{ emptyText }}</div>
<template v-else-if="_list.length <= +limit"> <template v-else-if="_list.length <= +limit">
<el-tag v-for="(item, unique) in _list" :key="unique"> <el-tag v-bind="elTagProps" v-for="(item, unique) in _list" :key="unique">
{{ item[defaultProps] || item }} {{ item[defaultProps] || item }}
</el-tag> </el-tag>
</template> </template>
...@@ -44,16 +55,16 @@ export default { ...@@ -44,16 +55,16 @@ export default {
<el-popover v-else placement="bottom" trigger="hover"> <el-popover v-else placement="bottom" trigger="hover">
<!-- 插入到body,这里用css scoped calss无效,需使用style--> <!-- 插入到body,这里用css scoped calss无效,需使用style-->
<div class="tag-all" style="display: flex; flex-wrap: wrap; gap: 10px"> <div class="tag-all" style="display: flex; flex-wrap: wrap; gap: 10px">
<el-tag v-for="(item, unique) in _list" :key="unique" style="margin: 0"> <el-tag v-bind="elTagProps" v-for="(item, unique) in _list" :key="unique" style="margin: 0">
{{ item[defaultProps] || item }} {{ item[defaultProps] || item }}
</el-tag> </el-tag>
</div> </div>
<template #reference> <template #reference>
<div> <div>
<el-tag v-for="(item, unique) in _list.slice(0, +limit)" :key="unique"> <el-tag v-bind="elTagProps" v-for="(item, unique) in _list.slice(0, +limit)" :key="unique">
{{ item[defaultProps] || item }} {{ item[defaultProps] || item }}
</el-tag> </el-tag>
<el-tag key="a" v-if="_list.length > +limit">...</el-tag> <el-tag v-bind="elTagProps" key="a" v-if="_list.length > +limit">...</el-tag>
</div> </div>
</template> </template>
</el-popover> </el-popover>
......
// 带 插入 表情/客户昵称 等扩展工具栏的文本内容框 <!-- // 带 插入 表情/客户昵称 等扩展工具栏的文本内容框 -->
<script> <script>
export default { export default {
name: '', name: '',
...@@ -57,11 +57,7 @@ export default { ...@@ -57,11 +57,7 @@ export default {
</el-button> </el-button>
</template> </template>
</SelectEmoji> </SelectEmoji>
<el-button <el-button v-if="toolbar.includes('insertCustomerNickName')" @click="insertContent(nikeName)" class="ml10">
v-if="toolbar.includes('insertCustomerNickName')"
@click="insertContent(nikeName)"
class="ml10"
>
插入客户昵称 插入客户昵称
</el-button> </el-button>
</div> </div>
......
...@@ -106,7 +106,6 @@ export default { ...@@ -106,7 +106,6 @@ export default {
fileUrlWatch: this.fileUrl, fileUrlWatch: this.fileUrl,
fileNameWatch: this.fileName, fileNameWatch: this.fileName,
fileListWatch: this.fileList, fileListWatch: this.fileList,
imgSizeWatch: this.imgSize,
picUrl: '', // 视频第一帧 picUrl: '', // 视频第一帧
file: undefined, file: undefined,
...@@ -130,11 +129,6 @@ export default { ...@@ -130,11 +129,6 @@ export default {
this.fileNameWatch = value this.fileNameWatch = value
}, },
}, },
imgSize: {
handler(value) {
this.imgSizeWatch = value
},
},
fileList: { fileList: {
handler(value) { handler(value) {
this.fileListWatch = value this.fileListWatch = value
...@@ -425,9 +419,9 @@ export default { ...@@ -425,9 +419,9 @@ export default {
format = formatDefault[this.type].value format = formatDefault[this.type].value
tip = formatDefault[this.type].tip tip = formatDefault[this.type].tip
} }
let match = file.name.match(/\.(\w+)$/g)
let fileFormat = match && match[0].replace('.', '').toLowerCase() const reg = new RegExp(`\\.(${this.format.join('|')})$`, 'ig') // /\.xlsx|.$/
isFormat = format[0] === '*' || format.includes(fileFormat) isFormat = format[0] === '*' || reg.test(file.name)
if (!isFormat) { if (!isFormat) {
this.$message.error('文件格式错误,仅支持 ' + (tip || format.join(',')) + ' 格式!') this.$message.error('文件格式错误,仅支持 ' + (tip || format.join(',')) + ' 格式!')
this.loading = false this.loading = false
......
...@@ -30,9 +30,10 @@ for (const [key, component] of Object.entries(ElementPlusIconsVue)) { ...@@ -30,9 +30,10 @@ for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
// 全局异步组件挂载, // 全局异步组件挂载,
// 所有异步组件,在其父组件需要更改其样式时可能会导致同级权重css样式顺序覆盖问题,使用时需注意加权 // 所有异步组件,在其父组件需要更改其样式时可能会导致同级权重css样式顺序覆盖问题,使用时需注意加权
let components = { let components = {
Empty: () => import('./components/Empty.vue'),
Upload: () => import('./components/Upload.vue'),
Pagination: () => import('./components/Pagination.vue'), Pagination: () => import('./components/Pagination.vue'),
RightToolbar: () => import('./components/RightToolbar.vue'), RightToolbar: () => import('./components/RightToolbar.vue'),
Upload: () => import('./components/Upload.vue'),
ButtonSync: () => import('./components/ButtonSync.vue'), ButtonSync: () => import('./components/ButtonSync.vue'),
TagEllipsis: () => import('./components/TagEllipsis.vue'), TagEllipsis: () => import('./components/TagEllipsis.vue'),
SelectUser: () => import('./components/SelectUser.vue'), SelectUser: () => import('./components/SelectUser.vue'),
...@@ -41,6 +42,7 @@ let components = { ...@@ -41,6 +42,7 @@ let components = {
PhoneTemplate: () => import('./components/PhoneTemplate.vue'), PhoneTemplate: () => import('./components/PhoneTemplate.vue'),
CardGroupIndex: () => import('./components/CardGroupIndex.vue'), CardGroupIndex: () => import('./components/CardGroupIndex.vue'),
TextareaExtend: () => import('./components/TextareaExtend.vue'), // 带 插入 表情/客户昵称 等扩展工具栏的文本内容框 TextareaExtend: () => import('./components/TextareaExtend.vue'), // 带 插入 表情/客户昵称 等扩展工具栏的文本内容框
DateSearchChartTable: () => import('./components/DateSearchChartTable.vue'),
} }
for (const c in components) { for (const c in components) {
app.component(c, defineAsyncComponent(components[c])) app.component(c, defineAsyncComponent(components[c]))
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!