|
@@ -0,0 +1,197 @@
|
|
|
+<template>
|
|
|
+ <div class="ent-group-index">
|
|
|
+ <div class="j-main">
|
|
|
+ <van-cell-group>
|
|
|
+ <van-cell
|
|
|
+ v-for="item in groupList"
|
|
|
+ :key="item.id"
|
|
|
+ :title="`${item.name}(${item.count})`"
|
|
|
+ :is-link="item.isPut !== 0"
|
|
|
+ @click="setGroupEvent(item)"
|
|
|
+ />
|
|
|
+ </van-cell-group>
|
|
|
+ </div>
|
|
|
+ <div class="j-footer">
|
|
|
+ <div class="j-button-group">
|
|
|
+ <div class="j-button-confirm" @click="showAddGroupingDialog = true">
|
|
|
+ <van-icon name="plus" />
|
|
|
+ <span style="margin-left: 8px">新增分组</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <van-dialog
|
|
|
+ v-model="showAddGroupingDialog"
|
|
|
+ class="add-grouping-dialog"
|
|
|
+ title="新增分组"
|
|
|
+ :show-confirm-button="false"
|
|
|
+ @confirm="addGrouping"
|
|
|
+ >
|
|
|
+ <van-field
|
|
|
+ v-model="groupingName"
|
|
|
+ show-word-limit
|
|
|
+ maxlength="15"
|
|
|
+ :error-message="errorMessageText"
|
|
|
+ placeholder="请输入分组名称"
|
|
|
+ @input="setGroupingName"
|
|
|
+ />
|
|
|
+ <div class="dialog-footer">
|
|
|
+ <van-button type="default" @click="showAddGroupingDialog = false">
|
|
|
+ 取消
|
|
|
+ </van-button>
|
|
|
+ <van-button
|
|
|
+ type="default"
|
|
|
+ class="confirm-button"
|
|
|
+ :disabled="isConfirmButtonDisabled"
|
|
|
+ @click="addGrouping"
|
|
|
+ >
|
|
|
+ 确定
|
|
|
+ </van-button>
|
|
|
+ </div>
|
|
|
+ </van-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { Button, Cell, CellGroup, Dialog, Field, Icon } from 'vant'
|
|
|
+import { mapActions } from 'vuex'
|
|
|
+import { getGroupList } from '@/api/modules/'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'EntGroupIndex',
|
|
|
+ components: {
|
|
|
+ [Cell.name]: Cell,
|
|
|
+ [CellGroup.name]: CellGroup,
|
|
|
+ [Dialog.name]: Dialog,
|
|
|
+ [Button.name]: Button,
|
|
|
+ [Icon.name]: Icon,
|
|
|
+ [Field.name]: Field
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ groupList: [],
|
|
|
+ groupingName: '',
|
|
|
+ showAddGroupingDialog: false,
|
|
|
+ errorMessageText: '',
|
|
|
+ isConfirmButtonDisabled: true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.getMyFollowList()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...mapActions('group', ['setEntGroupList']),
|
|
|
+ async getMyFollowList() {
|
|
|
+ const { error_code: code, data } = await this.setEntGroupList()
|
|
|
+ console.log(data)
|
|
|
+ if (code === 0) {
|
|
|
+ this.groupList = data?.groupUserArr || []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setGroupEvent(data) {
|
|
|
+ if (data.name === '默认分组') return
|
|
|
+ this.$router.push({
|
|
|
+ path: '/entgroup/detail',
|
|
|
+ query: {
|
|
|
+ id: data.id,
|
|
|
+ name: data.name
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ setGroupingName(val) {
|
|
|
+ this.groupingName = val.trim().replace(/\s+/g, '')
|
|
|
+ this.errorMessageText = ''
|
|
|
+ this.isConfirmButtonDisabled = false
|
|
|
+
|
|
|
+ if (this.groupingName === '') {
|
|
|
+ this.errorMessageText = '分组名称不能为空'
|
|
|
+ this.isConfirmButtonDisabled = true
|
|
|
+ } else {
|
|
|
+ const exists = this.groupList.some(
|
|
|
+ (item) => item.name === this.groupingName
|
|
|
+ )
|
|
|
+ if (exists) {
|
|
|
+ this.errorMessageText = '该分组已存在'
|
|
|
+ this.isConfirmButtonDisabled = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async addGrouping() {
|
|
|
+ const { error_code: code } = await getGroupList({
|
|
|
+ name: this.groupingName,
|
|
|
+ type: 'add'
|
|
|
+ })
|
|
|
+ if (code === 0) {
|
|
|
+ this.$toast('新增分组成功')
|
|
|
+ this.groupingName = ''
|
|
|
+ this.showAddGroupingDialog = false
|
|
|
+ this.getMyFollowList()
|
|
|
+ } else {
|
|
|
+ this.$toast('新增分组失败')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.ent-group-index {
|
|
|
+ .van-cell {
|
|
|
+ padding: 15px 16px;
|
|
|
+ &::after {
|
|
|
+ left: 0;
|
|
|
+ right: 0;
|
|
|
+ }
|
|
|
+ .van-cell__title {
|
|
|
+ font-size: 16px;
|
|
|
+ color: #171826;
|
|
|
+ line-height: 24px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .add-grouping-dialog {
|
|
|
+ ::v-deep {
|
|
|
+ .van-dialog__header {
|
|
|
+ font-size: 18px;
|
|
|
+ }
|
|
|
+ .dialog-footer {
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ .van-button {
|
|
|
+ flex: 1;
|
|
|
+ font-size: 18px;
|
|
|
+ border: none;
|
|
|
+ border-top: 0.5px solid rgba(0, 0, 0, 0.1);
|
|
|
+ &.confirm-button {
|
|
|
+ color: #2abed1;
|
|
|
+ border-left: 0.5px solid rgba(0, 0, 0, 0.1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .van-cell {
|
|
|
+ padding: 0 16px;
|
|
|
+ margin: 16px 0 22px 0;
|
|
|
+ .van-field__body {
|
|
|
+ padding-bottom: 11px;
|
|
|
+ border-bottom: 0.5px solid rgba(0, 0, 0, 0.05);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .van-field__control::placeholder {
|
|
|
+ color: #9b9ca3;
|
|
|
+ }
|
|
|
+ .van-field__word-limit {
|
|
|
+ position: absolute;
|
|
|
+ right: 0;
|
|
|
+ top: 0;
|
|
|
+ .van-field__word-num {
|
|
|
+ color: #2abed1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .van-field__error-message {
|
|
|
+ margin-top: 8px;
|
|
|
+ font-size: 14px;
|
|
|
+ color: #fb483d;
|
|
|
+ line-height: 20px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|