智能方案管理页面
This commit is contained in:
26
src/api/all/enterpriseKnowledge.ts
Normal file
26
src/api/all/enterpriseKnowledge.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import Http from '@/api';
|
||||
|
||||
// 获取物料列表
|
||||
export const getMaterialsList = (params = {}) => {
|
||||
// 发送GET请求,获取行业树
|
||||
return Http.get('v1/materials', params);
|
||||
};
|
||||
|
||||
//删除物料
|
||||
export const deleteMaterials = (id: number) => {
|
||||
return Http.delete('v1/materials/' + id);
|
||||
};
|
||||
|
||||
//添加物料
|
||||
export const addMaterials = (data: any) => {
|
||||
return Http.post('v1/materials', data);
|
||||
};
|
||||
//修改物料
|
||||
export const updateMaterials = (id: number, data: any) => {
|
||||
return Http.put('v1/materials/' + id, data);
|
||||
};
|
||||
|
||||
//获取详情
|
||||
export const getMaterialsDetail = (id: number) => {
|
||||
return Http.get('v1/materials/' + id);
|
||||
};
|
||||
340
src/views/components/enterpriseKnowledge/materials.vue
Normal file
340
src/views/components/enterpriseKnowledge/materials.vue
Normal file
@ -0,0 +1,340 @@
|
||||
<template>
|
||||
<div class="materials-page">
|
||||
<!-- 顶部标题和新增按钮 -->
|
||||
<div class="header-row">
|
||||
<h2 class="page-title">品牌物料</h2>
|
||||
<a-button type="primary" @click="handleAdd" class="add-btn">+ 添加品牌</a-button>
|
||||
</div>
|
||||
|
||||
<!-- 搜索栏 -->
|
||||
<div class="search-row">
|
||||
品牌名称
|
||||
<a-input v-model="listQuery.name" placeholder="请搜索..." allow-clear class="search-input" />
|
||||
<a-button type="outline" @click="handleSearch">
|
||||
<template #icon>
|
||||
<icon-search />
|
||||
</template>
|
||||
<template #default>搜索</template>
|
||||
</a-button>
|
||||
<a-button type="outline" @click="handleReset">
|
||||
<template #icon>
|
||||
<icon-refresh />
|
||||
</template>
|
||||
<template #default>重置</template>
|
||||
</a-button>
|
||||
</div>
|
||||
|
||||
<!-- 表格 -->
|
||||
|
||||
<a-table :data="listResult.list" :pagination="false">
|
||||
<template #columns>
|
||||
<a-table-column title="品牌名称" data-index="name" />
|
||||
<a-table-column title="品牌logo" data-index="logo">
|
||||
<template #cell="{ record }">
|
||||
<img :src="record.logo" style="width: 50px; height: 50px" />
|
||||
</template>
|
||||
</a-table-column>
|
||||
<a-table-column title="Slogan" data-index="slogan" />
|
||||
<a-table-column title="操作" data-index="optional">
|
||||
<template #cell="{ record }">
|
||||
<a-popconfirm
|
||||
content="确定删除吗?"
|
||||
type="warning"
|
||||
ok-text="确认删除"
|
||||
cancel-text="取消"
|
||||
@ok="deleteBrand(record.id)"
|
||||
>
|
||||
<icon-delete></icon-delete>
|
||||
</a-popconfirm>
|
||||
<a-button type="outline" @click="handleEdit(record.id)">编辑</a-button>
|
||||
</template>
|
||||
</a-table-column>
|
||||
</template>
|
||||
</a-table>
|
||||
|
||||
<!-- 分页 -->
|
||||
<a-space direction="vertical" size="large">
|
||||
<a-pagination :total="listResult.total" :size="listQuery.page_size" show-total show-jumper show-page-size />
|
||||
</a-space>
|
||||
|
||||
<!-- 新增/编辑品牌弹窗 -->
|
||||
<a-modal
|
||||
v-model:visible="modalVisible"
|
||||
:title="modalTitle"
|
||||
:mask-closable="false"
|
||||
:esc-to-close="false"
|
||||
width="480px"
|
||||
@cancel="handleModalCancel"
|
||||
>
|
||||
<a-form
|
||||
:model="form"
|
||||
:label-col-props="{ span: 5, offset: 0 }"
|
||||
:wrapper-col-props="{ span: 19, offset: 0 }"
|
||||
label-align="left"
|
||||
:rules="formRule"
|
||||
ref="formRef"
|
||||
layout="left"
|
||||
>
|
||||
<a-form-item field="name" label="品牌名称">
|
||||
<a-input v-model="form.name" placeholder="请输入品牌名称" />
|
||||
</a-form-item>
|
||||
<a-form-item field="logo" class="form-item-logo" label="标准版Logo">
|
||||
<ImageUpload v-model="form.logo" :limit="1"></ImageUpload>
|
||||
<div class="form-tip">品牌常规展示标识,支持PNG、JPG格式</div>
|
||||
</a-form-item>
|
||||
<a-form-item field="otherLogos" class="form-item-logo" label="其他Logo">
|
||||
<ImageUpload v-model="form.other_logos" :limit="3"></ImageUpload>
|
||||
</a-form-item>
|
||||
<a-form-item field="slogan" label="Slogan">
|
||||
<a-textarea v-model="form.slogan" placeholder="请输入..." :max-length="50" show-word-limit />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
<template #footer>
|
||||
<a-button @click="handleModalCancel">取消</a-button>
|
||||
<a-button type="primary" @click="handleModalOk">{{ btn_str }}</a-button>
|
||||
</template>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, reactive, onMounted } from 'vue';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { IconDelete } from '@arco-design/web-vue/es/icon';
|
||||
import {
|
||||
addMaterials,
|
||||
deleteMaterials,
|
||||
getMaterialsList,
|
||||
getMaterialsDetail,
|
||||
updateMaterials,
|
||||
} from '@/api/all/enterpriseKnowledge';
|
||||
import ImageUpload from '@/components/upload/ImageUpload.vue';
|
||||
import { valid } from 'mockjs';
|
||||
|
||||
const searchName = ref('');
|
||||
const current = ref(1);
|
||||
|
||||
const listResult = reactive({
|
||||
list: ref([]),
|
||||
total: ref(0),
|
||||
});
|
||||
|
||||
const listQuery = reactive({
|
||||
page: ref(1),
|
||||
name: ref(''),
|
||||
page_size: ref('10'),
|
||||
});
|
||||
|
||||
const modalVisible = ref(false);
|
||||
const modalTitle = ref('编辑品牌');
|
||||
const formRef = ref();
|
||||
//表单验证
|
||||
const formRule = {
|
||||
name: [{ required: true, message: '请输入品牌名称', trigger: ['blur', 'change'] }],
|
||||
logo: [{ required: true, message: '请上传品牌logo', trigger: ['blur', 'change'] }],
|
||||
};
|
||||
const form = reactive({
|
||||
name: '',
|
||||
logo: '',
|
||||
id: 0,
|
||||
other_logos: [], // [{ url: '' }]
|
||||
slogan: '',
|
||||
});
|
||||
|
||||
const btn_str = ref('确认添加');
|
||||
|
||||
onMounted(() => {
|
||||
handleSearch();
|
||||
});
|
||||
|
||||
const handleSearch = () => {
|
||||
getMaterialsList(listQuery).then((response) => {
|
||||
listResult.list = response.data;
|
||||
listResult.total = response.total;
|
||||
});
|
||||
};
|
||||
|
||||
const deleteBrand = (id) => {
|
||||
console.log(id, 'id');
|
||||
deleteMaterials(id).then(() => {
|
||||
Message.success('删除成功');
|
||||
handleSearch();
|
||||
});
|
||||
};
|
||||
|
||||
function handleReset() {
|
||||
searchName.value = '';
|
||||
current.value = 1;
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
modalTitle.value = '添加品牌';
|
||||
btn_str.value = '确认添加';
|
||||
form.id = 0;
|
||||
form.logo = '';
|
||||
form.name = '';
|
||||
form.slogan = '';
|
||||
form.other_logos = [];
|
||||
modalVisible.value = true;
|
||||
}
|
||||
|
||||
function handleModalCancel() {
|
||||
modalVisible.value = false;
|
||||
}
|
||||
|
||||
function handleModalOk() {
|
||||
formRef.value
|
||||
.validate()
|
||||
.then((valid) => {
|
||||
if (!valid) {
|
||||
if (form.id) {
|
||||
updateMaterials(form.id, form).then(() => {
|
||||
Message.success('修改成功');
|
||||
handleSearch();
|
||||
});
|
||||
} else {
|
||||
addMaterials(form).then(() => {
|
||||
Message.success('新增成功');
|
||||
handleSearch();
|
||||
});
|
||||
}
|
||||
modalVisible.value = false;
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('验证失败:', error);
|
||||
Message.error('请检查表单填写是否正确');
|
||||
});
|
||||
}
|
||||
|
||||
function handleEdit(id) {
|
||||
modalTitle.value = '编辑品牌';
|
||||
formRef.value.resetFields();
|
||||
modalVisible.value = true;
|
||||
btn_str.value = '确认修改';
|
||||
getMaterialsDetail(id).then((response) => {
|
||||
Object.assign(form, response);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.materials-page {
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
padding: 32px 24px 24px 24px;
|
||||
min-height: 600px;
|
||||
}
|
||||
|
||||
.header-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.add-btn {
|
||||
font-size: 16px;
|
||||
padding: 0 24px;
|
||||
}
|
||||
|
||||
.search-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
width: 240px;
|
||||
}
|
||||
|
||||
.search-btn,
|
||||
.reset-btn {
|
||||
min-width: 72px;
|
||||
}
|
||||
|
||||
.brand-table {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.logo-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.logo-emoji {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.logo-text {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.pagination-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.page-size-select {
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
.upload-card {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
border: 1px dashed #d9d9d9;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #999;
|
||||
font-size: 24px;
|
||||
background: #fafafa;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.upload-tip {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.form-tip {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.form-item-logo .logo-upload-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
.logo-upload-card {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
}
|
||||
.form-tip {
|
||||
color: #999;
|
||||
font-size: 13px;
|
||||
margin-left: 8px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.a-form .a-form-item {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
.a-modal .a-modal-footer {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
</style>
|
||||
@ -1,325 +0,0 @@
|
||||
<template>
|
||||
<view>
|
||||
<a-space direction="vertical" style="background-color: #fff; width: 100%; padding: 24px; margin-bottom: 24px">
|
||||
<div class="materials-page">
|
||||
<!-- 顶部标题和新增按钮 -->
|
||||
<div class="header-row">
|
||||
<h2 class="page-title">品牌物料</h2>
|
||||
<a-button type="primary" @click="handleAdd" class="add-btn">+ 添加品牌</a-button>
|
||||
</div>
|
||||
|
||||
<!-- 搜索栏 -->
|
||||
<div class="search-row">
|
||||
品牌名称
|
||||
<a-input v-model="listQuery.name" placeholder="请搜索..." allow-clear class="search-input" />
|
||||
<a-button type="outline" @click="handleSearch">
|
||||
<template #icon>
|
||||
<icon-search />
|
||||
</template>
|
||||
<template #default>搜索</template>
|
||||
</a-button>
|
||||
<a-button type="outline" @click="handleReset">
|
||||
<template #icon>
|
||||
<icon-refresh />
|
||||
</template>
|
||||
<template #default>重置</template>
|
||||
</a-button>
|
||||
</div>
|
||||
|
||||
<!-- 表格 -->
|
||||
|
||||
<a-table :data="listResult.list" :pagination="false">
|
||||
<template #columns>
|
||||
<a-table-column title="品牌名称" data-index="name" />
|
||||
<a-table-column title="品牌logo" data-index="logo">
|
||||
<template #cell="{ record }">
|
||||
<img :src="record.logo" style="width: 50px; height: 50px" />
|
||||
</template>
|
||||
</a-table-column>
|
||||
<a-table-column title="Slogan" data-index="slogan" />
|
||||
<a-table-column title="操作" data-index="optional">
|
||||
<template #cell="{ record }">
|
||||
<a-popconfirm
|
||||
content="确定删除吗?"
|
||||
type="warning"
|
||||
ok-text="确认删除"
|
||||
cancel-text="取消"
|
||||
@ok="deleteBrand(record.id)"
|
||||
>
|
||||
<icon-delete></icon-delete>
|
||||
</a-popconfirm>
|
||||
<a-button type="outline" @click="handleEdit(record.id)">编辑</a-button>
|
||||
</template>
|
||||
</a-table-column>
|
||||
</template>
|
||||
</a-table>
|
||||
|
||||
<!-- 分页 -->
|
||||
<a-space direction="vertical" size="large">
|
||||
<a-pagination :total="listResult.total" :size="listQuery.page_size" show-total show-jumper show-page-size />
|
||||
</a-space>
|
||||
|
||||
<!-- 新增/编辑品牌弹窗 -->
|
||||
<a-modal
|
||||
v-model:visible="modalVisible"
|
||||
:title="modalTitle"
|
||||
:mask-closable="false"
|
||||
:esc-to-close="false"
|
||||
width="480px"
|
||||
@cancel="handleModalCancel"
|
||||
>
|
||||
<a-form
|
||||
:model="form"
|
||||
:label-col-props="{ span: 5, offset: 0 }"
|
||||
:wrapper-col-props="{ span: 19, offset: 0 }"
|
||||
label-align="left"
|
||||
:rules="formRule"
|
||||
ref="formRef"
|
||||
layout="left"
|
||||
>
|
||||
<a-form-item field="name" label="品牌名称">
|
||||
<a-input v-model="form.name" placeholder="请输入品牌名称" />
|
||||
</a-form-item>
|
||||
<a-form-item field="logo" label="标准版Logo">
|
||||
<ImageUpload v-model="form.logo" :limit="1"></ImageUpload>
|
||||
<div class="form-tip">品牌常规展示标识,支持PNG、JPG格式</div>
|
||||
</a-form-item>
|
||||
<a-form-item field="otherLogos" label="其他Logo">
|
||||
<ImageUpload v-model="form.other_logos" :limit="3"></ImageUpload>
|
||||
</a-form-item>
|
||||
<a-form-item field="slogan" label="Slogan">
|
||||
<a-textarea v-model="form.slogan" placeholder="请输入..." :max-length="50" show-word-limit />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
<template #footer>
|
||||
<a-button @click="handleModalCancel">取消</a-button>
|
||||
<a-button type="primary" @click="handleModalOk">{{ btn_str }}</a-button>
|
||||
</template>
|
||||
</a-modal>
|
||||
</div>
|
||||
</a-space>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, reactive, onMounted } from 'vue';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { IconDelete } from '@arco-design/web-vue/es/icon';
|
||||
import {
|
||||
addMaterials,
|
||||
deleteMaterials,
|
||||
getMaterialsList,
|
||||
getMaterialsDetail,
|
||||
updateMaterials,
|
||||
} from '@/api/all/enterpriseKnowledge';
|
||||
import ImageUpload from '@/components/upload/ImageUpload.vue';
|
||||
import { valid } from 'mockjs';
|
||||
|
||||
const searchName = ref('');
|
||||
const current = ref(1);
|
||||
|
||||
const listResult = reactive({
|
||||
list: ref([]),
|
||||
total: ref(0),
|
||||
});
|
||||
|
||||
const listQuery = reactive({
|
||||
page: ref(1),
|
||||
name: ref(''),
|
||||
page_size: ref('10'),
|
||||
});
|
||||
|
||||
const modalVisible = ref(false);
|
||||
const modalTitle = ref('编辑品牌');
|
||||
const formRef = ref();
|
||||
//表单验证
|
||||
const formRule = {
|
||||
name: [{ required: true, message: '请输入品牌名称', trigger: ['blur', 'change'] }],
|
||||
logo: [{ required: true, message: '请上传品牌logo', trigger: ['blur', 'change'] }],
|
||||
};
|
||||
const form = reactive({
|
||||
name: '',
|
||||
logo: '',
|
||||
id: 0,
|
||||
other_logos: [], // [{ url: '' }]
|
||||
slogan: '',
|
||||
});
|
||||
|
||||
const btn_str = ref('确认添加');
|
||||
|
||||
onMounted(() => {
|
||||
handleSearch();
|
||||
});
|
||||
|
||||
const handleSearch = () => {
|
||||
getMaterialsList(listQuery).then((response) => {
|
||||
listResult.list = response.data;
|
||||
});
|
||||
};
|
||||
|
||||
const deleteBrand = (id) => {
|
||||
console.log(id, 'id');
|
||||
deleteMaterials(id).then(() => {
|
||||
Message.success('删除成功');
|
||||
handleSearch();
|
||||
});
|
||||
};
|
||||
|
||||
function handleReset() {
|
||||
searchName.value = '';
|
||||
current.value = 1;
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
modalTitle.value = '添加品牌';
|
||||
btn_str.value = '确认添加';
|
||||
|
||||
Object.assign(form, {
|
||||
name: '',
|
||||
logo: '',
|
||||
id: 0,
|
||||
other_logos: [], // 或者 []
|
||||
slogan: '',
|
||||
});
|
||||
modalVisible.value = true;
|
||||
}
|
||||
|
||||
function handleModalCancel() {
|
||||
modalVisible.value = false;
|
||||
}
|
||||
|
||||
function handleModalOk() {
|
||||
formRef.value
|
||||
.validate()
|
||||
.then((valid) => {
|
||||
if (!valid) {
|
||||
if (form.id) {
|
||||
updateMaterials(form.id, form).then(() => {
|
||||
Message.success('修改成功');
|
||||
});
|
||||
} else {
|
||||
addMaterials(form).then(() => {
|
||||
Message.success('新增成功');
|
||||
});
|
||||
}
|
||||
handleSearch();
|
||||
modalVisible.value = false;
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('验证失败:', error);
|
||||
Message.error('请检查表单填写是否正确');
|
||||
});
|
||||
}
|
||||
|
||||
function handleEdit(id) {
|
||||
modalTitle.value = '编辑品牌';
|
||||
//清空form 字段数据
|
||||
formRef.value.resetFields();
|
||||
modalVisible.value = true;
|
||||
btn_str.value = '确认修改';
|
||||
getMaterialsDetail(id).then((response) => {
|
||||
//赋值给form表单
|
||||
Object.assign(form, response);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.materials-page {
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
padding: 32px 24px 24px 24px;
|
||||
min-height: 600px;
|
||||
}
|
||||
|
||||
.header-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.add-btn {
|
||||
font-size: 16px;
|
||||
padding: 0 24px;
|
||||
}
|
||||
|
||||
.search-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
width: 240px;
|
||||
}
|
||||
|
||||
.search-btn,
|
||||
.reset-btn {
|
||||
min-width: 72px;
|
||||
}
|
||||
|
||||
.brand-table {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.logo-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.logo-emoji {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.logo-text {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.pagination-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.page-size-select {
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
.upload-card {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
border: 1px dashed #d9d9d9;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #999;
|
||||
font-size: 24px;
|
||||
background: #fafafa;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.upload-tip {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.form-tip {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
margin-top: 4px;
|
||||
}
|
||||
</style>
|
||||
@ -1,3 +1,339 @@
|
||||
<template>
|
||||
<view> </view>
|
||||
<div class="materials-page">
|
||||
<!-- 顶部标题和新增按钮 -->
|
||||
<div class="header-row">
|
||||
<h2 class="page-title">品牌物料</h2>
|
||||
<a-button type="primary" @click="handleAdd" class="add-btn">+ 添加品牌</a-button>
|
||||
</div>
|
||||
|
||||
<!-- 搜索栏 -->
|
||||
<div class="search-row">
|
||||
品牌名称
|
||||
<a-input v-model="listQuery.name" placeholder="请搜索..." allow-clear class="search-input" />
|
||||
<a-button type="outline" @click="handleSearch">
|
||||
<template #icon>
|
||||
<icon-search />
|
||||
</template>
|
||||
<template #default>搜索</template>
|
||||
</a-button>
|
||||
<a-button type="outline" @click="handleReset">
|
||||
<template #icon>
|
||||
<icon-refresh />
|
||||
</template>
|
||||
<template #default>重置</template>
|
||||
</a-button>
|
||||
</div>
|
||||
|
||||
<!-- 表格 -->
|
||||
|
||||
<a-table :data="listResult.list" :pagination="false">
|
||||
<template #columns>
|
||||
<a-table-column title="品牌名称" data-index="name" />
|
||||
<a-table-column title="品牌logo" data-index="logo">
|
||||
<template #cell="{ record }">
|
||||
<img :src="record.logo" style="width: 50px; height: 50px" />
|
||||
</template>
|
||||
</a-table-column>
|
||||
<a-table-column title="Slogan" data-index="slogan" />
|
||||
<a-table-column title="操作" data-index="optional">
|
||||
<template #cell="{ record }">
|
||||
<a-popconfirm
|
||||
content="确定删除吗?"
|
||||
type="warning"
|
||||
ok-text="确认删除"
|
||||
cancel-text="取消"
|
||||
@ok="deleteBrand(record.id)"
|
||||
>
|
||||
<icon-delete></icon-delete>
|
||||
</a-popconfirm>
|
||||
<a-button type="outline" @click="handleEdit(record.id)">编辑</a-button>
|
||||
</template>
|
||||
</a-table-column>
|
||||
</template>
|
||||
</a-table>
|
||||
|
||||
<!-- 分页 -->
|
||||
<a-space direction="vertical" size="large">
|
||||
<a-pagination :total="listResult.total" :size="listQuery.page_size" show-total show-jumper show-page-size />
|
||||
</a-space>
|
||||
|
||||
<!-- 新增/编辑品牌弹窗 -->
|
||||
<a-modal
|
||||
v-model:visible="modalVisible"
|
||||
:title="modalTitle"
|
||||
:mask-closable="false"
|
||||
:esc-to-close="false"
|
||||
width="480px"
|
||||
@cancel="handleModalCancel"
|
||||
>
|
||||
<a-form
|
||||
:model="form"
|
||||
:label-col-props="{ span: 5, offset: 0 }"
|
||||
:wrapper-col-props="{ span: 19, offset: 0 }"
|
||||
label-align="left"
|
||||
:rules="formRule"
|
||||
ref="formRef"
|
||||
layout="left"
|
||||
>
|
||||
<a-form-item field="name" label="品牌名称">
|
||||
<a-input v-model="form.name" placeholder="请输入品牌名称" />
|
||||
</a-form-item>
|
||||
<a-form-item field="logo" class="form-item-logo" label="标准版Logo">
|
||||
<ImageUpload v-model="form.logo" :limit="1"></ImageUpload>
|
||||
<div class="form-tip">品牌常规展示标识,支持PNG、JPG格式</div>
|
||||
</a-form-item>
|
||||
<a-form-item field="otherLogos" class="form-item-logo" label="其他Logo">
|
||||
<ImageUpload v-model="form.other_logos" :limit="3"></ImageUpload>
|
||||
</a-form-item>
|
||||
<a-form-item field="slogan" label="Slogan">
|
||||
<a-textarea v-model="form.slogan" placeholder="请输入..." :max-length="50" show-word-limit />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
<template #footer>
|
||||
<a-button @click="handleModalCancel">取消</a-button>
|
||||
<a-button type="primary" @click="handleModalOk">{{ btn_str }}</a-button>
|
||||
</template>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, reactive, onMounted } from 'vue';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { IconDelete } from '@arco-design/web-vue/es/icon';
|
||||
import {
|
||||
addMaterials,
|
||||
deleteMaterials,
|
||||
getMaterialsList,
|
||||
getMaterialsDetail,
|
||||
updateMaterials,
|
||||
} from '@/api/all/enterpriseKnowledge';
|
||||
import ImageUpload from '@/components/upload/ImageUpload.vue';
|
||||
import { valid } from 'mockjs';
|
||||
|
||||
const searchName = ref('');
|
||||
const current = ref(1);
|
||||
|
||||
const listResult = reactive({
|
||||
list: ref([]),
|
||||
total: ref(0),
|
||||
});
|
||||
|
||||
const listQuery = reactive({
|
||||
page: ref(1),
|
||||
name: ref(''),
|
||||
page_size: ref('10'),
|
||||
});
|
||||
|
||||
const modalVisible = ref(false);
|
||||
const modalTitle = ref('编辑品牌');
|
||||
const formRef = ref();
|
||||
const formRule = {
|
||||
name: [{ required: true, message: '请输入品牌名称', trigger: ['blur', 'change'] }],
|
||||
logo: [{ required: true, message: '请上传品牌logo', trigger: ['blur', 'change'] }],
|
||||
};
|
||||
const form = reactive({
|
||||
name: '',
|
||||
logo: '',
|
||||
id: 0,
|
||||
other_logos: [], // [{ url: '' }]
|
||||
slogan: '',
|
||||
});
|
||||
|
||||
const btn_str = ref('确认添加');
|
||||
|
||||
onMounted(() => {
|
||||
handleSearch();
|
||||
});
|
||||
|
||||
const handleSearch = () => {
|
||||
getMaterialsList(listQuery).then((response) => {
|
||||
listResult.list = response.data;
|
||||
listResult.total = response.total;
|
||||
});
|
||||
};
|
||||
|
||||
const deleteBrand = (id) => {
|
||||
console.log(id, 'id');
|
||||
deleteMaterials(id).then(() => {
|
||||
Message.success('删除成功');
|
||||
handleSearch();
|
||||
});
|
||||
};
|
||||
|
||||
function handleReset() {
|
||||
searchName.value = '';
|
||||
current.value = 1;
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
modalTitle.value = '添加品牌';
|
||||
btn_str.value = '确认添加';
|
||||
form.id = 0;
|
||||
form.logo = '';
|
||||
form.name = '';
|
||||
form.slogan = '';
|
||||
form.other_logos = [];
|
||||
modalVisible.value = true;
|
||||
}
|
||||
|
||||
function handleModalCancel() {
|
||||
modalVisible.value = false;
|
||||
}
|
||||
|
||||
function handleModalOk() {
|
||||
formRef.value
|
||||
.validate()
|
||||
.then((valid) => {
|
||||
if (!valid) {
|
||||
if (form.id) {
|
||||
updateMaterials(form.id, form).then(() => {
|
||||
Message.success('修改成功');
|
||||
handleSearch();
|
||||
});
|
||||
} else {
|
||||
addMaterials(form).then(() => {
|
||||
Message.success('新增成功');
|
||||
handleSearch();
|
||||
});
|
||||
}
|
||||
modalVisible.value = false;
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('验证失败:', error);
|
||||
Message.error('请检查表单填写是否正确');
|
||||
});
|
||||
}
|
||||
|
||||
function handleEdit(id) {
|
||||
modalTitle.value = '编辑品牌';
|
||||
formRef.value.resetFields();
|
||||
modalVisible.value = true;
|
||||
btn_str.value = '确认修改';
|
||||
getMaterialsDetail(id).then((response) => {
|
||||
Object.assign(form, response);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.materials-page {
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
padding: 32px 24px 24px 24px;
|
||||
min-height: 600px;
|
||||
}
|
||||
|
||||
.header-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.add-btn {
|
||||
font-size: 16px;
|
||||
padding: 0 24px;
|
||||
}
|
||||
|
||||
.search-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
width: 240px;
|
||||
}
|
||||
|
||||
.search-btn,
|
||||
.reset-btn {
|
||||
min-width: 72px;
|
||||
}
|
||||
|
||||
.brand-table {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.logo-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.logo-emoji {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.logo-text {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.pagination-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.page-size-select {
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
.upload-card {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
border: 1px dashed #d9d9d9;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #999;
|
||||
font-size: 24px;
|
||||
background: #fafafa;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.upload-tip {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.form-tip {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.form-item-logo .logo-upload-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
.logo-upload-card {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
}
|
||||
.form-tip {
|
||||
color: #999;
|
||||
font-size: 13px;
|
||||
margin-left: 8px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.a-form .a-form-item {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
.a-modal .a-modal-footer {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user