初始化

This commit is contained in:
aixianling
2021-12-14 18:36:19 +08:00
parent 9afa4101b6
commit a8dff862d2
327 changed files with 88702 additions and 0 deletions

View File

@@ -0,0 +1,94 @@
<template>
<ai-list v-if="!isShowDetail">
<template slot="title">
<ai-title title="居民管理" :isShowBottomBorder="false"></ai-title>
</template>
<template slot="tabs">
<el-tabs v-model="currIndex">
<el-tab-pane v-for="(tab,i) in tabs" :key="i" :label="tab.label">
<component :ref="String(i)" v-if="currIndex == i" :is="tab.comp" @change="onChange" lazy :instance="instance" :dict="dict" :permissions="permissions"/>
</el-tab-pane>
</el-tabs>
</template>
</ai-list>
<Detail v-else-if="componentName === 'Detail'" :params="params" :instance="instance" :dict="dict" :permissions="permissions" @change="onChange"></Detail>
</template>
<script>
import List from './components/List.vue'
import Statistics from './components/Statistics'
import Tags from './components/Tags'
import Detail from './components/Detail'
import { mapState } from 'vuex'
export default {
name: 'AppResidentManage',
label: '居民管理',
components: {
List,
Tags,
Detail,
Statistics
},
props: {
instance: Function,
dict: Object,
permissions: Function
},
computed: {
...mapState(['user']),
tabs () {
const tabList = [
{label: '居民列表', name: 'List', comp: List, permission: ''},
{label: '居民统计', name: 'Statistics', comp: Statistics, permission: ''},
{label: '居民标签', name: 'Tags', comp: Tags, permission: ''}
].filter(item => {
return true
})
return tabList
}
},
data () {
return {
activeName: 'JoinEvent',
currIndex: '0',
componentName: '',
params: {},
isShowDetail: false
}
},
created () {
if (this.$route.query.id) {
this.componentName = this.$route.query?.type
this.params = {id: this.$route.query?.id}
this.isShowDetail = true
}
},
methods: {
onChange (data) {
if (data.type === 'list') {
this.componentName = 'List'
this.isShowDetail = false
this.params = data.params
}
if (data.type === 'detail') {
this.componentName = 'Detail'
this.isShowDetail = true
this.params = data.params
}
}
}
}
</script>
<style lang="scss" scoped>
</style>

View File

@@ -0,0 +1,465 @@
<template>
<ai-detail class="AppResidentManage">
<template slot="title">
<ai-title title="居民详情" isShowBack isShowBottomBorder @onBackClick="cancel(false)"></ai-title>
</template>
<template slot="content">
<div class="detail-top">
<div class="detail-top__header">
<div class="header-left">
<img :src="info.avatar">
<div class="header-left__right">
<h2>{{ info.name }}</h2>
<p>{{ info.corpFullName }}</p>
</div>
</div>
<div class="header-right">
<div class="header-right__item">
<span>家庭积分</span>
<h3>{{ info.residentInfo ? (info.residentInfo.resident.familyIntegral || 0) : '0' }}</h3>
</div>
<div class="header-right__item">
<span>个人积分</span>
<h3>{{ info.residentInfo ? (info.residentInfo.resident.personalIntegral || 0) : '0' }}</h3>
</div>
<el-button type="primary" size="mini" v-if="info.realName" @click="toDetail">查看居民档案</el-button>
</div>
</div>
<div class="detail-top__content">
<ai-wrapper
label-width="80px">
<ai-info-item label="添加渠道" :value="dict.getLabel('wxCustomerAddWay', info.addWay)"></ai-info-item>
<ai-info-item label="添加时间" :value="info.createTime"></ai-info-item>
<ai-info-item label="真实姓名" :value="info.realName"></ai-info-item>
<ai-info-item label="手机号码"
:value="info.residentInfo ? info.residentInfo.resident.phone : '-'"></ai-info-item>
<ai-info-item label="标签" isLine>
<div class="table-tags">
<el-tag type="info" v-for="(item, index) in info.tags" size="small" :key="index">{{ item.tagName }}
</el-tag>
</div>
</ai-info-item>
</ai-wrapper>
</div>
</div>
<div class="detail-bottom">
<div class="detail-bottom__left">
<h2>居民动态</h2>
<div class="step-list">
<div class="step-item" v-for="(item, index) in logList" :key="index">
<i class="step-item__left"></i>
<div class="step-item__right">
<h2>{{ dict.getLabel('wxCustomerLogType', item.type) }}</h2>
<p>{{ item.createTime }}</p>
<div class="step-item__right--bottom" v-html="item.content"></div>
</div>
</div>
<div slot="empty" class="no-data" v-if="!logList.length" style="height:160px;"></div>
</div>
</div>
<div class="detail-bottom__right">
<div class="detail-table">
<h2>所属员工</h2>
<ai-table
class="detail-table__table"
:border="true"
:tableData="tableData"
:col-configs="colConfigs"
:total="total"
:stripe="false"
:current.sync="search.current"
:size.sync="search.size"
@getList="getDynamicInfo">
<el-table-column slot="userinfo" label="所属员工" width="268px" align="center">
<template slot-scope="{ row }">
<div class="userinfo">
<img :src="row.avatar">
<h3>{{ row.userName }}</h3>
</div>
</template>
</el-table-column>
</ai-table>
</div>
<div class="detail-table">
<h2>所在群聊</h2>
<ai-table
class="detail-table__table"
:border="true"
:tableData="grooupTableData"
:col-configs="groupColConfigs"
:total="grooupTableData.length"
:stripe="false"
:current.sync="groupSearch.current"
:size.sync="groupSearch.size"
@getList="getInfo">
</ai-table>
</div>
</div>
</div>
</template>
</ai-detail>
</template>
<script>
export default {
name: 'Detail',
props: {
instance: Function,
dict: Object,
params: Object
},
data() {
return {
isShow: false,
tags: ['青年', '郑村村', '郑村村', '青年', '郑村村', '郑村村'],
info: {},
search: {
current: 1,
size: 10
},
groupSearch: {
current: 1,
size: 10
},
groupTotal: 0,
form: {
explain: '',
imgs: []
},
total: 0,
logList: [],
colConfigs: [
{slot: 'userinfo'},
{prop: 'addWay', label: '客户来源', align: 'center', formart: v => this.dict.getLabel('wxCustomerAddWay', v)},
{prop: 'createTime', label: '添加时间', align: 'center'}
],
groupColConfigs: [
{prop: 'name', label: '群名称', align: 'left'},
{prop: 'ownerName', label: '群主', align: 'center'},
{prop: 'personCount', label: '群人数', align: 'left'},
{prop: 'joinTime', label: '居民入群时间', align: 'left'}
],
grooupTableData: [],
tableData: []
}
},
created() {
if (this.params && this.params.id) {
this.getInfo()
this.dict.load(['wxCustomerLogType', 'wxCustomerAddWay']).then(() => {
this.getWxcustomerlog()
this.getDynamicInfo()
})
}
},
methods: {
getInfo(id) {
this.instance.post(`/app/wxcp/wxcustomer/queryCustomerById?id=${this.params.id}`).then(res => {
if (res.code === 0) {
this.info = res.data
this.grooupTableData = res.data.groupInfos
}
})
},
getDynamicInfo(id) {
this.instance.post(`/app/wxcp/wxcustomer/getDynamicInfoById?customerId=${this.params.id}`, null, {
params: {
...this.search
}
}).then(res => {
if (res.code === 0) {
this.tableData = res.data.records
this.total = res.data.total
}
})
},
getWxcustomerlog() {
this.instance.post(`/app/wxcp/wxcustomerlog/listAll?customerId=${this.params.id}`).then(res => {
if (res.code === 0) {
this.logList = res.data
}
})
},
toDetail() {
this.$router.push({
name: '居民档案',
query: {
id: this.info.residentInfo.resident.id,
type: '0'
}
})
},
onClose() {
this.form.explain = ''
},
confirm() {
this.$refs.form.validate((valid) => {
if (valid) {
this.instance.post(`/app/appgirdmemberevent/rejectEvent`, {
eventId: this.params.id,
explain: this.form.explain
}).then(res => {
if (res.code == 0) {
this.$message.success('驳回成功')
setTimeout(() => {
this.cancel()
}, 600)
}
})
}
})
},
cancel(isRefresh) {
this.$emit('change', {
type: 'list',
isRefresh: isRefresh ? true : false
})
}
}
}
</script>
<style scoped lang="scss">
.AppResidentManage {
::v-deep .ai-detail__content--wrapper {
max-width: 100% !important;
padding: 20px;
}
h2, h3 {
margin: 0;
}
.userinfo {
display: flex;
align-items: center;
padding-left: 16px;
img {
width: 40px;
height: 40px;
margin-right: 8px;
border-radius: 2px;
}
h3 {
font-weight: normal;
color: #222222;
}
}
.detail-bottom {
display: flex;
margin-top: 20px;
.step-list {
padding: 36px 40px 40px;
.step-item {
display: flex;
position: relative;
padding-bottom: 36px;
&:last-child {
padding-bottom: 0;
&::after {
display: none;
}
}
&::after {
position: absolute;
left: 3px;
top: 14px;
width: 2px;
height: 100%;
background: #EEEEEE;
content: ' ';
}
.step-item__right--bottom {
color: #555;
font-size: 14px;
b {
font-weight: normal;
}
::v-deep i {
font-style: normal;
color: #2266FF;
}
}
.step-item__right {
flex: 1;
h2 {
line-height: 22px;
color: #222222;
font-size: 16px;
}
p {
line-height: 22px;
margin: 2px 0 4px;
color: #888888;
font-size: 14px;
}
}
.step-item__left {
position: relative;
top: 4px;
margin-right: 20px;
width: 8px;
height: 8px;
border-radius: 50%;
background: #2266FF;
}
}
}
.detail-bottom__left {
flex-shrink: 1;
width: 360px;
height: fit-content;
margin-right: 20px;
background: #FFFFFF;
box-shadow: 0px 4px 6px -2px rgba(15, 15, 21, 0.15);
border-radius: 2px;
& > h2 {
height: 56px;
line-height: 56px;
padding: 0 16px;
color: #222222;
font-size: 16px;
font-weight: 700;
border: 1px solid #EEEEEE;
}
}
.detail-bottom__right {
flex: 1;
& > div {
background: #FFFFFF;
box-shadow: 0px 4px 6px -2px rgba(15, 15, 21, 0.15);
border-radius: 2px;
&:last-child {
margin-top: 20px;
}
& > h2 {
height: 56px;
line-height: 56px;
padding: 0 16px;
color: #222222;
font-size: 16px;
font-weight: 700;
border: 1px solid #EEEEEE;
}
}
.detail-table__table {
padding: 16px;
}
}
}
.detail-top {
padding: 30px 40px;
background: #FFFFFF;
box-shadow: 0px 4px 6px -2px rgba(15, 15, 21, 0.15);
border-radius: 2px;
.detail-top__content {
padding-top: 32px;
}
.detail-top__header {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 32px;
border-bottom: 1px solid #EEEEEE;
.header-right {
.header-right__item {
width: 120px;
margin-right: 8px;
text-align: center;
}
div {
text-align: center;
&:last-child {
margin-right: 0;
}
span {
display: block;
margin-bottom: 10px;
color: #888888;
}
}
.el-button {
height: 28px;
margin-left: 8px;
border-radius: 14px;
font-size: 12px;
padding: 7px 15px;
}
}
.header-left, .header-right {
display: flex;
align-items: center;
}
.header-left {
img {
width: 64px;
height: 64px;
margin-right: 16px;
}
h2 {
margin-bottom: 6px;
color: #222222;
font-size: 16px;
}
p {
color: #2EA222;
font-size: 14px;
}
}
}
}
.table-tags {
.el-tag {
margin-right: 8px;
&:last-child {
margin-right: 0;
}
}
}
}
</style>

View File

@@ -0,0 +1,441 @@
<template>
<ai-list class="AppPetitionManage" isTabs>
<template slot="content">
<ai-search-bar class="search-bar">
<template slot="left">
<ai-select
v-model="search.isRealName"
@change="search.current = 1, getList()"
placeholder="是否实名"
:selectList="realStatus">
</ai-select>
<ai-select
v-model="search.wxUserId"
filterable
@change="search.current = 1, getList()"
placeholder="所属员工"
:selectList="userList">
</ai-select>
<ai-select
v-model="search.tagId"
@change="search.current = 1, getList()"
placeholder="选择标签"
:selectList="subTags">
</ai-select>
</template>
<template slot="right">
<el-input
v-model="search.name"
class="search-input"
size="small"
@keyup.enter.native="search.current = 1, getList()"
placeholder="请输入备注、昵称、姓名"
clearable
@change="getList"
@clear="search.current = 1, search.name = '', getList()"
suffix-icon="iconfont iconSearch">
</el-input>
</template>
</ai-search-bar>
<ai-search-bar>
<template slot="left">
<el-button type="primary" icon="iconfont iconAdd" @click="isShow = true" :disabled="!ids.length">批量打标签</el-button>
</template>
<template slot="right">
<el-button type="primary" icon="iconfont iconResetting" @click="update" :loading="btnLoading">更新数据</el-button>
</template>
</ai-search-bar>
<ai-table
:tableData="tableData"
:col-configs="colConfigs"
:total="total"
ref="aitableex"
:current.sync="search.current"
@selection-change="handleSelectionChange"
:size.sync="search.size"
v-loading="isLoading"
@getList="getList">
<el-table-column slot="avatar" label="" width="80" align="center">
<template slot-scope="{ row }">
<div class="avatar" style="text-align: right; justify-content: end;">
<img :src="row.avatar">
</div>
</template>
</el-table-column>
<el-table-column slot="userinfo" label="备注名" width="280px" align="left">
<template slot-scope="{ row }">
<div class="userinfo">
<div class="userinfo-right ellipsis">
<el-tooltip effect="dark" :content="row.corpFullName ? (row.remark || row.name) + '@' + row.corpFullName : (row.remark || row.name) + ''" placement="top">
<div class="userinfo-right__top">
<h3>{{ row.remark || row.name }}</h3>
<span class="ellipsis">{{ row.corpFullName ? '@' + row.corpFullName : '' }}</span>
</div>
</el-tooltip>
<div class="userinfo-right__bottom">
<el-tooltip effect="dark" :content="row.name" placement="top">
<i>昵称{{ row.name }}</i>
</el-tooltip>
</div>
</div>
</div>
</template>
</el-table-column>
<el-table-column slot="tags" label="标签" align="left">
<template slot-scope="{ row }">
<div class="table-tags">
<el-tag type="info" v-for="(item, index) in row.tags" size="medium" :key="index">{{ item.tagName }}</el-tag>
</div>
</template>
</el-table-column>
<el-table-column slot="options" label="操作" width="100" fixed="right" align="center">
<template slot-scope="{ row }">
<div class="table-options">
<el-button type="text" @click="toDetail(row.id)">详情</el-button>
</div>
</template>
</el-table-column>
</ai-table>
<ai-dialog
:visible.sync="isShow"
width="800px"
title="批量打标签"
@close="onClose"
@onConfirm="onConfirm">
<div class="tags">
<div class="tag-item" v-for="(item, index) in tags" :key="index">
<h2>{{ item.name }}</h2>
<div class="tag-item__right">
<el-button
:type="chooseTags.indexOf(item.id) === -1 ? '' : 'primary'"
v-for="(item, index) in item.tagList"
@click="choose(item.id)"
:key="index">
{{ item.name }}
</el-button>
</div>
</div>
</div>
</ai-dialog>
</template>
</ai-list>
</template>
<script>
import { mapState } from 'vuex'
export default {
name: 'List',
props: {
instance: Function,
dict: Object
},
data () {
return {
search: {
current: 1,
size: 10,
name: '',
tagId: '',
wxUserId: '',
isRealName: ''
},
btnLoading: false,
isLoading: false,
isShow: false,
ids: [],
total: 10,
chooseTags: [],
tags: [],
colConfigs: [
{ type: 'selection' },
{ slot: 'avatar' },
{ slot: 'userinfo' },
{ prop: 'realName', label: '真实姓名', align: 'center' },
{
prop: 'identityNumber', label: '是否实名', align: 'center',
render: (h, params) => {
return h('span', {
}, params.row.realName ? '是' : '否')
}
},
{ prop: 'wxUserNames', label: '所属员工', align: 'center' },
{ slot: 'tags' },
{ prop: 'createTime', label: '添加时间', align: 'left' },
{ prop: 'addWay', label: '添加渠道', align: 'center', formart: v => this.dict.getLabel('wxCustomerAddWay', v) },
{ slot: 'options', label: '操作', align: 'center' }
],
tableData: [],
realStatus: [{
dictName: '是',
dictValue: '1'
}, {
dictName: '否',
dictValue : '0'
}],
subTags: [],
userList: []
}
},
computed: {
...mapState(['user'])
},
mounted () {
this.getTags()
this.getSubTags()
this.getWxUserList()
this.isLoading = true
this.dict.load(['wxCustomerAddWay']).then(() => {
this.getList()
})
},
methods: {
getWxUserList () {
this.instance.post(`/app/wxcp/wxuser/listByDepartId`, {
}).then(res => {
if (res.code == 0) {
this.userList = res.data.map(item => {
item.dictName = item.name
item.dictValue = item.id
return item
})
}
})
},
update () {
this.btnLoading = true
this.instance.post(`/app/wxcp/wxusercustomer/sync`, null, {
timeout: 1000000
}).then(res => {
if (res.code == 0) {
this.$message.success('更新成功')
this.getList()
}
this.btnLoading = false
}).catch(() => {
this.btnLoading = false
})
},
onClose () {
this.chooseTags = []
},
getSubTags () {
this.instance.post(`/app/wxcp/wxcorptag/listAllTags`).then(res => {
if (res.code == 0) {
this.subTags = res.data.map(item => {
return {
dictName: item.name,
dictValue: item.id
}
})
}
})
},
getList() {
this.instance.post(`/app/wxcp/wxcustomer/list`, null, {
params: {
...this.search
}
}).then(res => {
if (res.code == 0) {
this.tableData = res.data.records
this.total = res.data.total
this.isLoading = false
} else {
this.isLoading = false
}
}).catch(() => {
this.isLoading = false
})
},
choose (id) {
const index = this.chooseTags.indexOf(id)
if (index === -1) {
this.chooseTags.push(id)
} else {
this.chooseTags.splice(index, 1)
}
},
onConfirm () {
if (!this.chooseTags.length) {
return this.$message.error('请选择标签')
}
this.instance.post(`/app/wxcp/wxcorptag/markTagForWeb`, {
addTagIds: this.chooseTags,
customerIds: this.ids.map(v => v.id)
}).then(res => {
if (res.code == 0) {
this.isShow = false
this.getList()
}
})
},
getTags () {
this.instance.post(`/app/wxcp/wxcorptag/listAll?size=100`).then(res => {
if (res.code == 0) {
this.tags = res.data.records
}
})
},
onAdd () {
this.$emit('change', {
type: 'add'
})
},
handleSelectionChange(e) {
this.ids = e
},
removeAll () {
this.remove(this.ids.map(v => v.id).join(','))
},
remove (id) {
this.$confirm('确定删除该数据?').then(() => {
this.instance.post(`/app/apppetition/delete?ids=${id}`).then(res => {
if (res.code == 0) {
this.$message.success('删除成功!')
this.getList()
}
})
})
},
toDetail (id) {
this.$emit('change', {
type: 'detail',
params: {
id: id
}
})
},
onAdd () {
this.$emit('change', {
type: 'add'
})
}
}
}
</script>
<style lang="scss" scoped>
.table-tags {
.el-tag {
margin-right: 8px;
margin-bottom: 8px;
border: 1px solid #D0D4DC;
background: #F3F4F7;
border-radius: 4px;
font-size: 13px;
color: #222222;
&:last-child {
margin-right: 0;
}
}
}
.ellipsis {
overflow: hidden;
text-overflow:ellipsis;
white-space: nowrap;
}
.tags {
.tag-item {
display: flex;
align-items: center;
padding-bottom: 30px;
padding-top: 30px;
border-bottom: 1px solid #EEEEEE;
&:first-child {
padding-top: 0;
}
.el-tag {
margin-right: 8px;
color: #222222;
}
h2 {
width: 88px;
margin-right: 40px;
text-align: right;
color: #888888;
font-size: 14px;
}
}
}
.avatar {
text-align: right;
img {
position: relative;
top: 4px;
width: 40px;
height: 40px;
border-radius: 2px;
border: 1px solid #CCCCCC;
}
}
.userinfo {
display: flex;
align-items: center;
line-height: 1;
.userinfo-right__top {
display: flex;
align-items: center;
margin-bottom: 10px;
cursor: pointer;
white-space: nowrap;
}
.userinfo-right__bottom {
text-align: left;
}
i {
cursor: pointer;
font-style: normal;
color: #888888;
font-size: 14px;
}
h3 {
margin-top: 0;
margin-bottom: 0;
margin-right: 8px;
color: #222222;
font-weight: normal;
font-size: 14px;
}
span {
color: #3C7FC8;
white-space: nowrap;
}
}
</style>

View File

@@ -0,0 +1,201 @@
<template>
<ai-list class="statistics" isTabs style="width: 100%">
<template slot="content" v-loading="loading">
<div class="statistics-top">
<div class="statistics-top__item">
<span>居民总数</span>
<h2 style="color: #2266FF;">{{ info.total }}</h2>
</div>
<div class="statistics-top__item">
<span>今日新增</span>
<h2 style="color: #22AA99;">{{ info.increase }}</h2>
</div>
<div class="statistics-top__item">
<span>今日流失</span>
<h2 style="color: #F8B425">{{ info.decrease }}</h2>
</div>
</div>
<ai-card title="趋势图">
<template #content>
<div class="chart" style="height: 340px; width: 100%;"></div>
<ai-empty v-if="false" style="height: 148px;"></ai-empty>
</template>
</ai-card>
</template>
</ai-list>
</template>
<script>
import * as echarts from 'echarts'
export default {
name: 'Statistics',
props: {
instance: Function,
dict: Object
},
data () {
return {
chart: null,
info: {},
chartWidth: '',
loading: false
}
},
mounted () {
this.loading = true
this.$nextTick(() => {
this.chart = echarts.init(document.querySelector('.chart'))
window.addEventListener('resize', this.onResize)
this.getInfo()
})
},
destroyed () {
window.removeEventListener('resize', this.onResize)
},
methods: {
onResize () {
this.chart.resize()
},
getInfo () {
this.instance.post(`/app/wxcp/wxcustomerlog/customerStatistic`).then(res => {
if (res.code == 0) {
this.info = res.data.today
this.initChart(res.data.list)
this.loading = false
} else {
this.loading = false
}
})
},
initChart (data) {
const x = Object.keys(data)
const y = Object.values(data)
let option = {
tooltip: {
trigger: 'axis'
},
legend: {
type: "plain"
},
grid: {
left: '20px',
right: '38px',
bottom: '14px',
top: '30px',
containLabel: true
},
color: ['#2266FF', '#22AA99', '#F8B425'],
xAxis: {
type: 'category',
axisLabel: {
align: 'center',
padding: [2, 0, 0, 0],
interval: 0,
fontSize: 14,
color: '#666666'
},
boundaryGap: false,
axisLine: {
lineStyle: {
color: '#E1E5EF'
}
},
data: x
},
yAxis: {
axisTick: {
length: 0,
show: false
},
splitLine: {
show: true,
lineStyle:{
color: ['#E1E5EF'],
width: 1,
type: 'solid'
}
},
nameTextStyle: {
color: '#666666',
align: 'left'
},
axisLine: {
show: false
},
axisLabel: {
color: '#666666'
},
type: 'value'
},
series: [
{
name: '居民总数',
type: 'line',
data: y.map(v => v.total)
},
{
name: '新增居民数',
type: 'line',
data: y.map(v => v.increase)
},
{
name: '流失居民数',
type: 'line',
data: y.map(v => v.decrease)
}
]
}
this.chart.setOption(option)
}
}
}
</script>
<style scoped lang="scss">
.statistics {
::v-deep .ai-list__content--right-wrapper {
background: transparent!important;
box-shadow: none!important;
padding: 12px 0 12px!important;
}
.statistics-top {
display: flex;
align-items: center;
margin-bottom: 20px;
& > div {
flex: 1;
height: 96px;
line-height: 1;
margin-right: 20px;
padding: 16px 24px;
background: #FFFFFF;
box-shadow: 0px 4px 6px -2px rgba(15, 15, 21, 0.15);
border-radius: 4px;
&:last-child {
margin-right: 0;
}
h3 {
font-size: 24px;
}
span {
display: block;
margin-bottom: 16px;
color: #888888;
font-size: 16px;
}
}
}
}
</style>

View File

@@ -0,0 +1,201 @@
<template>
<ai-list class="AppPetitionManage" isTabs>
<template slot="content">
<ai-search-bar>
<template slot="left">
<el-button type="primary" icon="iconfont iconAdd" @click="id = '', form.name = '', form.tagList = [], isShow = true">添加标签组</el-button>
</template>
</ai-search-bar>
<ai-table
:tableData="tableData"
:col-configs="colConfigs"
:total="total"
ref="aitableex"
:current.sync="search.current"
:size.sync="search.size"
@getList="getList">
<el-table-column slot="tags" label="标签" align="left">
<template slot-scope="{ row }">
<div class="table-tags">
<el-tag type="info" v-for="(item, index) in row.tagList" size="small" :key="index">{{ item.name }}</el-tag>
</div>
</template>
</el-table-column>
<el-table-column slot="options" label="操作" width="180" fixed="right" align="center">
<template slot-scope="{ row }">
<div class="table-options">
<!-- <el-button type="text" @click="edit(row)">添加标签</el-button> -->
<el-button type="text" @click="edit(row)">编辑</el-button>
<el-button type="text" @click="remove(row.id)">删除</el-button>
</div>
</template>
</el-table-column>
</ai-table>
<ai-dialog
:visible.sync="isShow"
width="800px"
title="添加标签组"
@onConfirm="onConfirm"
@onCancel="onCancel">
<el-form class="ai-form" ref="form" label-width="100px" :model="form">
<el-form-item style="width: 100%" label="标签组名称" prop="name" :rules="[{ required: true, message: '请输入标签组名称', trigger: 'blur' }]">
<el-input size="small" v-model.trim="form.name" :maxlength="15" show-word-limit placeholder="请输入标签组名称"></el-input>
</el-form-item>
<el-form-item style="width: 100%" label="标签" prop="tagList" :rules="[{ required: true, message: '请输入标签组名称', trigger: 'blur' }]">
<div class="table-tags">
<el-tag type="info" color="#fff" closable @close="onClose(index)" v-for="(item, index) in form.tagList" :key="index">{{ item.name }}</el-tag>
<el-input
v-if="inputVisible"
v-model.trim="tagName"
size="small"
style="width: 100px;"
maxlength="30"
clearable
@keyup.enter.native="handleInputConfirm"
@blur="handleInputConfirm">
</el-input>
<el-button v-else size="small" icon="iconfont iconAdd" @click="inputVisible = true">添加</el-button>
</div>
</el-form-item>
</el-form>
</ai-dialog>
</template>
</ai-list>
</template>
<script>
export default {
name: 'Tags',
props: {
instance: Function,
dict: Object
},
data () {
return {
search: {
current: 1,
size: 10
},
tagName: '',
form: {
name: '',
tagList: []
},
inputVisible: false,
isShow: false,
ids: [],
total: 10,
colConfigs: [
{ prop: 'name', label: '标签组', align: 'left', width: 160 },
{ slot: 'tags' },
{ slot: 'options', label: '操作', align: 'center' }
],
id: '',
tableData: [],
}
},
mounted () {
this.getList()
},
methods: {
getList() {
this.instance.post(`/app/wxcp/wxcorptag/listAll`, null, {
params: {
...this.search
}
}).then(res => {
if (res.code == 0) {
this.tableData = res.data.records
this.total = res.data.total
}
})
},
onCancel () {
this.form.name = ''
this.form.tagList = []
this.id = ''
this.inputVisible = ''
this.isShow = false
},
edit (e) {
this.id = e.id
this.form = JSON.parse(JSON.stringify(e))
this.$nextTick(() => {
this.isShow = true
})
},
handleInputConfirm () {
if (!this.tagName) {
return
}
this.form.tagList.push({
name: this.tagName
})
this.$nextTick(() => {
this.tagName = ''
this.inputVisible = false
})
},
onClose (index) {
this.form.tagList.splice(index, 1)
},
onConfirm () {
this.$refs.form.validate((valid) => {
if (valid) {
this.instance.post(this.id ? '/app/wxcp/wxcorptag/update' : `/app/wxcp/wxcorptag/add`, {
name: this.form.name,
id: this.id || '',
tagList: this.form.tagList
}).then(res => {
if (res.code === 0) {
this.getList()
this.isShow = false
this.$message.success(`${this.id}` ? '编辑成功' : '提交成功')
}
})
}
})
},
remove (id) {
this.$confirm('确定删除该数据?').then(() => {
this.instance.post(`/app/wxcp/wxcorptag/delete?id=${id}&type=0`).then(res => {
if (res.code == 0) {
this.$message.success('删除成功!')
this.getList()
}
})
})
}
}
}
</script>
<style lang="scss" scoped>
.table-tags {
.el-tag {
margin-right: 8px;
border: 1px solid #D0D4DC;
background: #F3F4F7;
border-radius: 4px;
font-size: 13px;
color: #222222;
&:last-child {
margin-right: 0;
}
}
}
</style>