|
@@ -5,17 +5,26 @@ style:
|
|
|
</route>
|
|
|
<script setup lang="ts">
|
|
|
import SectionHeading from '@/components/section-heading.vue'
|
|
|
-import { getByDictType, getCircleTags, getMemberTags } from '../../../core/libs/requests'
|
|
|
+import {
|
|
|
+ createMemberTag,
|
|
|
+ deleteMemberTag,
|
|
|
+ getByDictType,
|
|
|
+ getCircleTags,
|
|
|
+ getMemberTags,
|
|
|
+} from '../../../core/libs/requests'
|
|
|
import { DictType } from '../../../core/libs/models'
|
|
|
import { ref } from 'vue'
|
|
|
import { useUserStore } from '../../../store'
|
|
|
import { storeToRefs } from 'pinia'
|
|
|
import { useMessage } from 'wot-design-uni'
|
|
|
import FormMessageBox from '@/components/form-message-box.vue'
|
|
|
+import { requestToast } from '../../../core/utils/common'
|
|
|
|
|
|
const userStore = useUserStore()
|
|
|
const { userInfo } = storeToRefs(userStore)
|
|
|
const { confirm } = useMessage('wd-message-box-slot')
|
|
|
+const { confirm: deleteConfirm } = useMessage()
|
|
|
+const formData = ref({})
|
|
|
const { data: tagTypes, run: setTagTypes } = useRequest(() => getByDictType(DictType.circleTag), {
|
|
|
initialData: [],
|
|
|
})
|
|
@@ -45,19 +54,40 @@ const handleAddTag = async () => {
|
|
|
await confirm({
|
|
|
title: '添加标签',
|
|
|
beforeConfirm: async ({ resolve }) => {
|
|
|
- // if (!cancelReason.value) {
|
|
|
- // resolve(false)
|
|
|
- // uni.showToast({ title: '请输入驳回原因', icon: 'none' })
|
|
|
- // return
|
|
|
- // }
|
|
|
- // await requestToast(
|
|
|
- // () =>
|
|
|
- // orderPointsCancel({
|
|
|
- // id: message.businessId.toString(),
|
|
|
- // cancelReason: cancelReason.value,
|
|
|
- // }),
|
|
|
- // { success: true, successTitle: '积分确认已驳回' },
|
|
|
- // )
|
|
|
+ const { code } = await requestToast(
|
|
|
+ () =>
|
|
|
+ createMemberTag({
|
|
|
+ ...formData.value,
|
|
|
+ stylistId: userInfo.value?.userId,
|
|
|
+ stylistName: userInfo.value?.nickname,
|
|
|
+ }),
|
|
|
+ {
|
|
|
+ success: true,
|
|
|
+ successTitle: '添加成功',
|
|
|
+ },
|
|
|
+ )
|
|
|
+ if (code === 0) {
|
|
|
+ await setMemberTags()
|
|
|
+ formData.value = {}
|
|
|
+ resolve(true)
|
|
|
+ }
|
|
|
+ resolve(false)
|
|
|
+ },
|
|
|
+ })
|
|
|
+}
|
|
|
+const handleDeleteTag = async (tag: any) => {
|
|
|
+ deleteConfirm({
|
|
|
+ title: '删除标签',
|
|
|
+ msg: '确定删除该标签吗?',
|
|
|
+ beforeConfirm: async ({ resolve }) => {
|
|
|
+ const { code } = await requestToast(() => deleteMemberTag(tag.id), {
|
|
|
+ success: true,
|
|
|
+ successTitle: '删除成功',
|
|
|
+ })
|
|
|
+ if (code === 0) {
|
|
|
+ await setMemberTags()
|
|
|
+ resolve(true)
|
|
|
+ }
|
|
|
resolve(false)
|
|
|
},
|
|
|
})
|
|
@@ -96,8 +126,22 @@ onLoad(async (query: { tagName: string }) => {
|
|
|
<SectionHeading title="自定义标签" custom-class="my-6" size="base"></SectionHeading>
|
|
|
<div class="flex flex-wrap">
|
|
|
<template v-for="(it, i) in memberTags" :key="i">
|
|
|
- <div>
|
|
|
- <wd-tag custom-class="m-1">{{ it.tagName }}</wd-tag>
|
|
|
+ <div class="relative">
|
|
|
+ <div class="absolute right-0">
|
|
|
+ <div
|
|
|
+ class="w-5 h-5 bg-red-6 rounded-full flex items-center justify-center"
|
|
|
+ @click="handleDeleteTag(it)"
|
|
|
+ >
|
|
|
+ <wd-icon name="close" color="#fff" size="12"></wd-icon>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <wd-tag
|
|
|
+ custom-class="m-1"
|
|
|
+ @click="handleClick(it.tagName)"
|
|
|
+ :type="selected.includes(it.tagName) ? 'primary' : 'default'"
|
|
|
+ >
|
|
|
+ {{ it.tagName }}
|
|
|
+ </wd-tag>
|
|
|
</div>
|
|
|
</template>
|
|
|
<wd-tag custom-class="m-1" @click="handleAddTag">
|
|
@@ -106,6 +150,9 @@ onLoad(async (query: { tagName: string }) => {
|
|
|
</div>
|
|
|
<div class="flex-1"></div>
|
|
|
<div><wd-button block :round="false" @click="handleSubmit()">确定</wd-button></div>
|
|
|
- <FormMessageBox :schema="{ test: { type: 'TextField' } }"></FormMessageBox>
|
|
|
+ <FormMessageBox
|
|
|
+ v-model="formData"
|
|
|
+ :schema="{ tagName: { type: 'TextField', label: '标签', hiddenLabel: true } }"
|
|
|
+ ></FormMessageBox>
|
|
|
</div>
|
|
|
</template>
|