改造文章管理系统
This commit is contained in:
@@ -0,0 +1,147 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space :size="10" style="flex-wrap: wrap">
|
||||
<a-button type="primary" class="ele-btn-icon" @click="add">
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
<span>添加</span>
|
||||
</a-button>
|
||||
<a-radio-group v-model:value="type" @change="handleSearch">
|
||||
<a-radio-button value="已发布"
|
||||
>已发布({{ goodsCount?.totalNum }})</a-radio-button
|
||||
>
|
||||
<a-radio-button value="待审核"
|
||||
>待审核({{ goodsCount?.totalNum2 }})</a-radio-button
|
||||
>
|
||||
<a-radio-button value="已驳回"
|
||||
>已驳回({{ goodsCount?.totalNum3 }})</a-radio-button
|
||||
>
|
||||
</a-radio-group>
|
||||
<!-- <SelectMerchant-->
|
||||
<!-- :placeholder="`选择商户`"-->
|
||||
<!-- class="input-item"-->
|
||||
<!-- v-if="!merchantId"-->
|
||||
<!-- v-model:value="where.merchantName"-->
|
||||
<!-- @done="chooseMerchantId"-->
|
||||
<!-- />-->
|
||||
<SelectNavigsation
|
||||
class="input-item"
|
||||
:placeholder="`选择栏目`"
|
||||
v-model:value="where.categoryName"
|
||||
@done="chooseArticleCategory"
|
||||
/>
|
||||
<a-input-search
|
||||
allow-clear
|
||||
placeholder="请输入关键词"
|
||||
v-model:value="where.keywords"
|
||||
@pressEnter="reload"
|
||||
@search="reload"
|
||||
/>
|
||||
<a-button @click="reset">重置</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { PlusOutlined } from '@ant-design/icons-vue';
|
||||
import { ref, watch } from 'vue';
|
||||
import { getCount } from '@/api/shop/goods';
|
||||
import type { ArticleCount, ArticleParam } from '@/api/cms/article/model';
|
||||
import useSearch from '@/utils/use-search';
|
||||
import { Merchant } from '@/api/shop/merchant/model';
|
||||
import { Navigation } from '@/api/cms/navigation/model';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的角色
|
||||
selection?: [];
|
||||
merchantId?: number;
|
||||
}>(),
|
||||
{}
|
||||
);
|
||||
|
||||
const type = ref<string>();
|
||||
// 统计数据
|
||||
const goodsCount = ref<ArticleCount>();
|
||||
|
||||
// 表单数据
|
||||
const { where, resetFields } = useSearch<ArticleParam>({
|
||||
articleId: undefined,
|
||||
navigationId: undefined,
|
||||
categoryId: undefined,
|
||||
merchantId: undefined,
|
||||
keywords: ''
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: ArticleParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
(e: 'batchMove'): void;
|
||||
}>();
|
||||
|
||||
// 新增
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
const handleSearch = (e) => {
|
||||
const text = e.target.value;
|
||||
resetFields();
|
||||
if (text === '已发布') {
|
||||
where.status = 1;
|
||||
}
|
||||
if (text === '待审核') {
|
||||
where.status = 0;
|
||||
}
|
||||
if (text === '已驳回') {
|
||||
where.status = 2;
|
||||
}
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
const reload = () => {
|
||||
getCount(where).then((data: any) => {
|
||||
goodsCount.value = data;
|
||||
});
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const chooseMerchantId = (item: Merchant) => {
|
||||
where.merchantName = item.merchantName;
|
||||
where.merchantId = item.merchantId;
|
||||
reload();
|
||||
};
|
||||
|
||||
const chooseArticleCategory = (category: Navigation) => {
|
||||
where.categoryName = category.title;
|
||||
where.navigationId = category.navigationId;
|
||||
reload();
|
||||
};
|
||||
|
||||
/* 重置 */
|
||||
const reset = () => {
|
||||
resetFields();
|
||||
type.value = '';
|
||||
reload();
|
||||
};
|
||||
|
||||
// watch(
|
||||
// () => props.selection,
|
||||
// () => {}
|
||||
// );
|
||||
watch(
|
||||
() => props.merchantId,
|
||||
(id) => {
|
||||
if (Number(id) > 0) {
|
||||
where.merchantId = id;
|
||||
reload();
|
||||
} else {
|
||||
where.merchantId = undefined;
|
||||
reload();
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
Reference in New Issue
Block a user