main
bibi 3 years ago
parent 67c042df6f
commit 7033667d8d

@ -0,0 +1,32 @@
import httpService from "@/request"
// 商品
// 品牌
export function brandList(params) {
return httpService({
url: `/user/shopBrand/list`,
method: 'get',
params: params,
})
}
export function brandInsert(params) {
return httpService({
url: `/user/shopBrand/insert`,
method: 'post',
data: params,
})
}
export function brandDel(params) {
return httpService({
url: `/user/shopBrand/delete`,
method: 'post',
data: params,
})
}
export function brandUpdate(params) {
return httpService({
url: `/user/shopBrand/update`,
method: 'post',
data: params,
})
}

@ -0,0 +1,32 @@
import httpService from "@/request"
// 商品
// 店铺
export function shopList(params) {
return httpService({
url: `/user/shopShop/list`,
method: 'get',
params: params,
})
}
export function shopInsert(params) {
return httpService({
url: `/user/shopShop/insert`,
method: 'post',
data: params,
})
}
export function shopDel(params) {
return httpService({
url: `/user/shopShop/delete`,
method: 'post',
data: params,
})
}
export function shopUpdate(params) {
return httpService({
url: `/user/shopShop/update`,
method: 'post',
data: params,
})
}

@ -0,0 +1,32 @@
import httpService from "@/request"
// 商品
// 供应商
export function vendorList(params) {
return httpService({
url: `/user/shopVendor/list`,
method: 'get',
params: params,
})
}
export function vendorInsert(params) {
return httpService({
url: `/user/shopVendor/insert`,
method: 'post',
data: params,
})
}
export function vendorDel(params) {
return httpService({
url: `/user/shopVendor/delete`,
method: 'post',
data: params,
})
}
export function vendorUpdate(params) {
return httpService({
url: `/user/shopVendor/update`,
method: 'post',
data: params,
})
}

@ -77,24 +77,24 @@ export default [
component: resolve => require(['@/views/Shop/OrderManage/depend/detail'], resolve), component: resolve => require(['@/views/Shop/OrderManage/depend/detail'], resolve),
meta: {title: '订单详情'} meta: {title: '订单详情'}
}, },
// { {
// path: '/SupplierManage', path: '/SupplierManage',
// name: "SupplierManage", name: "SupplierManage",
// title: "供应商管理", title: "供应商管理",
// hide: false, hide: false,
// icon: 'contacts', icon: 'contacts',
// component: resolve => require(['@/views/Shop/SupplierManage'], resolve), component: resolve => require(['@/views/Shop/SupplierManage'], resolve),
// meta: {title: '供应商管理'} meta: {title: '供应商管理'}
// }, },
// { {
// path: '/StoreManage', path: '/StoreManage',
// name: "StoreManage", name: "StoreManage",
// title: "店铺管理", title: "店铺管理",
// hide: false, hide: false,
// icon: 'shop', icon: 'shop',
// component: resolve => require(['@/views/Shop/StoreManage'], resolve), component: resolve => require(['@/views/Shop/StoreManage'], resolve),
// meta: {title: '店铺管理'} meta: {title: '店铺管理'}
// }, },
// { // {
// path: '/SwiperManage', // path: '/SwiperManage',
// name: "SwiperManage", // name: "SwiperManage",

@ -0,0 +1,30 @@
export const formItem = [
{
type: 'input',
label:'品牌名称',
prop:'brandName',
placeholder:'请输入'
},
]
export const columns = [
{
title: "品牌名称",
dataIndex: "brandName",
},
{
title: "操作",
dataIndex: "action",
key: "action",
width: "180",
fixed: "right",
scopedSlots: { customRender: "action" },
},
]
export const pagination = {
current: 1,
total: 0,
pageSize: 10,
showTotal: (total) => `${total}`,
showSizeChanger: true,
showQuickJumper: true,
}

@ -0,0 +1,7 @@
export const form = {
id:null,
brandName: undefined,
}
export const rules = {
brandName:[{required:true,message:'请输入品牌名',trigger:'blur'}],
}

@ -1,14 +1,214 @@
<template> <template>
<div></div> <div>
<div class="cardTitle">品牌管理</div>
<searchForm :formItem="formItem" @getSearch="getData($event)"></searchForm>
<a-button style="margin: 10px" class="add-btn" @click="drawer.show = true"
>新增品牌</a-button
>
<a-table
:columns="columns"
:data-source="tableData"
:pagination="pagination"
@change="handleTableChange"
:row-selection="{
selectedRowKeys: selectedRowKeys,
onChange: selectionChoosed,
}"
:row-key="
(record, index) => {
return record.id;
}
"
>
<span slot="action" slot-scope="text, row">
<a-space>
<a class="ant-dropdown-link" @click="edit(row)"></a>
<a class="ant-dropdown-link" @click="del([row.id])"></a>
</a-space>
</span>
</a-table>
<div class="action">
<a-dropdown :disabled="!hasSelected">
<a-menu slot="overlay" @click="handleMenuClick">
<a-menu-item key="del"> 批量删除 </a-menu-item>
</a-menu>
<a-button> 批量操作 <a-icon type="down" /> </a-button>
</a-dropdown>
<span style="margin-left: 8px">
<template v-if="hasSelected">
{{ `已选择 ${selectedRowKeys.length}` }}
</template>
</span>
</div>
<a-drawer
:title="drawer.title"
:width="720"
:visible="drawer.show"
:body-style="{ paddingBottom: '80px' }"
@close="addClose"
>
<div class="drawer-content">
基本信息
<a-divider></a-divider>
<a-form-model
ref="ruleForm"
:model="form"
:rules="rules"
layout="vertical"
>
<a-form-model-item prop="brandName" label="品牌名称">
<a-input
v-model="form.brandName"
placeholder="请输入品牌名称"
style="width: 50%"
></a-input>
</a-form-model-item>
</a-form-model>
</div>
<div class="drawer-footer">
<a-button :style="{ marginRight: '8px' }" @click="addClose">
关闭
</a-button>
<a-button type="primary" @click="submit"> </a-button>
</div>
</a-drawer>
</div>
</template> </template>
<script> <script>
import {
brandList,
brandInsert,
brandDel,
brandUpdate,
} from "@/api/shop/goods/brand.js";
import { formItem, columns, pagination } from "./depend/config";
import { form, rules } from "./depend/form.js";
export default { export default {
data() { data() {
return {}; return {
drawer: {
show: false,
title: "新增品牌"
},
tableData: [],
searchForm: {
name: undefined,
},
formItem,
columns,
form,
rules,
pagination,
// index
selectedRowKeys: [],
};
},
mounted() {
this.getData();
},
methods: {
async getData(data) {
if (data !== undefined) {
console.log(data);
this.searchForm = data;
console.log(this.searchForm);
}
let res = await brandList({
pageNum: this.pagination.current,
size: this.pagination.pageSize,
...this.searchForm,
});
this.tableData = res.data.rows;
this.pagination.total = res.data.total;
this.selectedRowKeys = [];
},
edit(data) {
this.form.brandName = data.brandName
this.form.id = data.id
this.drawer.show = true;
this.drawer.title = '修改品牌';
},
del(ids) {
this.$confirm({
title: "是否删除",
// okText:'',
// cancelText:'',
icon: "delete",
onOk: async () => {
let res = await brandDel({ ids: ids });
if (res.code === 200) {
this.$message.success(res.msg);
this.getData();
} else {
this.$message.error(res.msg);
}
},
});
},
// id
selectionChoosed(data) {
this.selectedRowKeys = data;
},
//
handleMenuClick(data) {
console.log(data);
if (data.key === "del") {
this.del(this.selectedRowKeys);
}
},
//
handleTableChange(pagination) {
console.log(pagination);
const pager = { ...this.pagination };
pager.current = pagination.current;
pager.pageSize = pagination.pageSize;
this.pagination = pager;
this.getData();
},
addClose() {
this.$refs.ruleForm.resetFields();
this.drawer.show = false;
this.drawer.title = '新增品牌';
},
submit() {
console.log(this.form);
this.$refs.ruleForm.validate(async (valid) => {
if (valid) {
if (this.form.id === null) {
let res = await brandInsert(this.form);
if (res.code === 200) {
this.$message.success(res.msg);
this.addClose();
this.getData();
} else {
this.$message.error(res.msg);
}
} else {
console.log(this.form);
let res = await brandUpdate(this.form);
if (res.code === 200) {
this.$message.success(res.msg);
this.addClose();
this.getData();
} else {
this.$message.error(res.msg);
}
}
}
});
},
},
computed: {
hasSelected() {
return this.selectedRowKeys.length > 0;
},
}, },
methods: {},
}; };
</script> </script>
<style lang="less" scoped>
<style lang="less" scoped></style> .table-img {
width: 40px;
height: 40px;
}
</style>

@ -1,99 +1,15 @@
export const formItem = [ export const formItem = [
{ {
type: 'input', type: 'input',
label:'标题', label:'店铺名称',
prop:'title', prop:'shopName',
placeholder:'请输入' placeholder:'请输入'
}, },
{
type: 'select',
label:'推送对象',
prop:'object',
option:[{ id:1,name:'全部'},{ id:2,name:'住户'},{ id:3,name:'业主'},{ id:4,name:'租户'},{ id:5,name:'管家'}],
placeholder:'请选择'
},
{
type: 'select',
label:'发布状态',
prop:'status',
option:[{ id:1,name:'未发布'},{ id:2,name:'已发布'}],
placeholder:'请选择'
},
{
type: 'time',
label:'更新时间',
start: 'modifyStartTime',
end:'modifyEndTime'
},
] ]
export const columns = [ export const columns = [
{ {
title: "标题", title: "店铺名称",
dataIndex: "title", dataIndex: "shopName",
width: "16%",
},
{
title: "推送对象",
dataIndex: "object",
width: "10%",
customRender: function (object) {
switch (object) {
case 1:
return '全部'
break;
case 2:
return '住户'
break;
case 3:
return '业主'
break;
case 4:
return '租户'
break;
case 5:
return '管家'
break;
default:
break;
}
}
},
{
title: "状态",
dataIndex: "status",
width: "10%",
customRender: function (status) {
switch (status) {
case 1:
return '未发布'
break;
case 2:
return '已发布'
break;
default:
break;
}
}
},
{
title: "内容",
dataIndex: "content",
width: "13%",
},
{
title: "阅读量",
dataIndex: "readingVolume",
width: "10%",
},
{
title: "附件下载次数",
dataIndex: "downloadNum",
width: "10%",
},
{
title: "更新时间",
dataIndex: "modifyDate",
width: "14%",
}, },
{ {
title: "操作", title: "操作",

@ -1,28 +1,7 @@
export const form = { export const form = {
id:undefined, id:null,
title:undefined, shopName: undefined,
object:undefined,
status:undefined,
content:undefined,
coverImgUrls:[],
annexUrls:[],
} }
export const rules = { export const rules = {
title:[{required:true,message:'请输入标题',trigger:'blur'}], shopName:[{required:true,message:'请输入店铺名',trigger:'blur'}],
object:[{required:true,message:'请选择',trigger:'change'}],
status:[{required:true,message:'请选择',trigger:'change'}],
content:[{required:true,message:'请输入标题',trigger:'blur'}],
}
export const options = {
status:[
{ id:1, name:'未发布' },
{ id:2, name:'已发布' },
],
object:[
{ id:1, name:'全部' },
{ id:2, name:'住户' },
{ id:3, name:'业主' },
{ id:4, name:'租户' },
{ id:5, name:'管家' },
],
} }

@ -1,241 +0,0 @@
<template>
<div>
<a-drawer
:title="title"
:width="720"
:visible="show"
:body-style="{ paddingBottom: '80px' }"
@close="addClose"
>
<div class="drawer-content">
基本信息
<a-divider></a-divider>
<a-form-model
ref="ruleForm"
:model="form"
:rules="rules"
layout="vertical"
>
<a-form-model-item prop="title" label="标题">
<a-input
v-model="form.title"
placeholder="请输入标题"
style="width: 80%"
></a-input>
</a-form-model-item>
<a-form-model-item prop="object" label="推送对象">
<a-select
v-model="form.object"
placeholder="请选择"
style="width: 80%"
>
<a-select-option
v-for="item in options.object"
:key="item.id"
:value="item.id"
>{{ item.name }}</a-select-option
>
</a-select>
</a-form-model-item>
<a-form-model-item prop="status" label="状态">
<a-select
v-model="form.status"
placeholder="请选择"
style="width: 80%"
>
<a-select-option
v-for="item in options.status"
:key="item.id"
:value="item.id"
>{{ item.name }}</a-select-option
>
</a-select>
</a-form-model-item>
<a-form-model-item prop="content" label="内容">
<a-textarea
v-model="form.content"
placeholder="请输入内容"
style="width: 80%"
></a-textarea>
</a-form-model-item>
封面图片
<commonUpload
:fileList="fileList"
@handleChange="handleChange"
></commonUpload>
附件
<a-upload
name="file"
:multiple="true"
:action="`${$upload}`"
:file-list="documentList"
accept=".doc,.DOC,.xls,.XLS,.xlsx,.XLSX,.pdf,.PDF"
:headers="uploadHeaders"
@change="changeFile"
>
<a-button> <a-icon type="upload" /> 上传附件</a-button>
</a-upload>
</a-form-model>
</div>
<div class="drawer-footer">
<a-button :style="{ marginRight: '8px' }" @click="addClose">
关闭
</a-button>
<a-button type="primary" @click="submit"> </a-button>
</div>
</a-drawer>
</div>
</template>
<script>
import store from "@/store";
import { form, rules, options } from "./form.js";
import {
announcementInsert,
announcementUpdate,
announcementInfo,
} from "@/api/operation/announcement";
export default {
props: {
show: {
type: Boolean,
default: false,
},
editId: Number,
},
data() {
return {
title: "新增公告",
form,
rules,
options,
fileList: [],
documentList: [],
uploadHeaders: {
"manage-login-token": store.getters.getToken,
},
};
},
methods: {
addClose() {
this.$refs.ruleForm.resetFields();
this.fileList = [];
this.documentList = [];
this.form.coverImgUrls = [];
this.form.annexUrls = [];
this.$emit("addClose");
},
success() {
this.$emit("success");
this.addClose();
},
submit() {
console.log(this.documentList);
let arr = [];
for (let k of this.documentList) {
if (k.response) {
arr.push(k.response.data);
} else {
arr.push(k.url.split("/")[k.url.split("/").length - 1]);
}
}
this.form.annexUrls = arr;
console.log(this.form);
this.$refs.ruleForm.validate(async (valid) => {
if (valid) {
if (this.editId === null) {
let res = await announcementInsert(this.form);
if (res.code === 200) {
this.$message.success(res.msg);
this.success();
} else {
this.$message.error(res.msg);
}
} else {
console.log(this.form);
let res = await announcementUpdate(this.form);
if (res.code === 200) {
this.$message.success(res.msg);
this.success();
} else {
this.$message.error(res.msg);
}
}
}
});
},
changeFile(info) {
this.documentList = info.fileList;
if (info.file.status !== "uploading") {
console.log(info.file, info.fileList);
}
if (info.file.status === "done") {
this.$message.success(`${info.file.name} 上传成功`);
// this.form.annexUrls.push(info.file.response.data);
} else if (info.file.status === "error") {
this.$message.error(`${info.file.name} 上传失败`);
}
},
handleChange(data) {
this.fileList = data;
this.form.coverImgUrls = [];
if (data[0].status === "done") {
console.log("-------done-------");
this.form.coverImgUrls.push(data[0].response.data);
}
},
},
watch: {
editId: {
handler(val) {
if (val !== null) {
this.title = "修改公告";
this.form.id = val;
announcementInfo({ announcementId: val }).then((res) => {
this.form = res.data;
if (res.data.coverImgList.length > 0) {
console.log(res.data.coverImgList);
const pic = [];
for (let item of res.data.coverImgList) {
let obj = {
name: item.url.split("_")[0] + "." + item.url.split(".")[1],
url: this.$ImgUrl(item.url),
uid: item.url.split("_")[1],
status: "done",
thumbUrl: this.$ImgUrl(item.url),
};
pic.push(obj);
}
this.fileList = pic;
} else {
this.form.coverImgList = [];
}
if (res.data.annexImgList.length > 0) {
console.log(res.data.annexImgList);
const file = [];
for (let item of res.data.annexImgList) {
let obj = {
name: item.url.split("_")[0] + "." + item.url.split(".")[1],
url: this.$ImgUrl(item.url),
uid: item.url.split("_")[1],
status: "done",
thumbUrl: this.$ImgUrl(item.url),
};
file.push(obj);
}
this.documentList = file;
} else {
this.form.coverImgList = [];
}
});
} else {
this.title = "新增公告";
}
},
immediate: true,
},
},
};
</script>
<style></style>

@ -1,15 +1,14 @@
<template> <template>
<div> <div>
<div class="cardTitle">公告</div> <div class="cardTitle">店铺管理</div>
<searchForm :formItem="formItem" @getSearch="getData($event)"></searchForm> <searchForm :formItem="formItem" @getSearch="getData($event)"></searchForm>
<a-button style="margin: 10px" class="add-btn" @click="drawer.show = true" <a-button style="margin: 10px" class="add-btn" @click="drawer.show = true"
>新增公告</a-button >新增店铺</a-button
> >
<a-table <a-table
:columns="columns" :columns="columns"
:data-source="tableData" :data-source="tableData"
:pagination="pagination" :pagination="pagination"
:scroll="{ x: 1600 }"
@change="handleTableChange" @change="handleTableChange"
:row-selection="{ :row-selection="{
selectedRowKeys: selectedRowKeys, selectedRowKeys: selectedRowKeys,
@ -23,7 +22,7 @@
> >
<span slot="action" slot-scope="text, row"> <span slot="action" slot-scope="text, row">
<a-space> <a-space>
<a class="ant-dropdown-link" @click="edit(row.id)"></a> <a class="ant-dropdown-link" @click="edit(row)"></a>
<a class="ant-dropdown-link" @click="del([row.id])"></a> <a class="ant-dropdown-link" @click="del([row.id])"></a>
</a-space> </a-space>
</span> </span>
@ -41,39 +40,65 @@
</template> </template>
</span> </span>
</div> </div>
<addForm <a-drawer
:show="drawer.show" :title="drawer.title"
@success="success" :width="720"
@addClose="addClose" :visible="drawer.show"
:editId="editId" :body-style="{ paddingBottom: '80px' }"
></addForm> @close="addClose"
>
<div class="drawer-content">
基本信息
<a-divider></a-divider>
<a-form-model
ref="ruleForm"
:model="form"
:rules="rules"
layout="vertical"
>
<a-form-model-item prop="shopName" label="店铺名称">
<a-input
v-model="form.shopName"
placeholder="请输入店铺名称"
style="width: 50%"
></a-input>
</a-form-model-item>
</a-form-model>
</div>
<div class="drawer-footer">
<a-button :style="{ marginRight: '8px' }" @click="addClose">
关闭
</a-button>
<a-button type="primary" @click="submit"> </a-button>
</div>
</a-drawer>
</div> </div>
</template> </template>
<script> <script>
import { announcementList, announcementDel } from "@/api/operation/announcement"; import {
shopList,
shopInsert,
shopDel,
shopUpdate,
} from "@/api/shop/shop";
import { formItem, columns, pagination } from "./depend/config"; import { formItem, columns, pagination } from "./depend/config";
import addForm from "./depend/form.vue"; import { form, rules } from "./depend/form.js";
export default { export default {
components: {
addForm,
},
data() { data() {
return { return {
drawer: { drawer: {
show: false, show: false,
title: "新增店铺"
}, },
editId: null,
tableData: [], tableData: [],
searchForm: { searchForm: {
title:undefined, name: undefined,
status:undefined,
object:undefined,
modifyStartTime:undefined,
modifyEndTime:undefined,
}, },
formItem, formItem,
columns, columns,
form,
rules,
pagination, pagination,
// index // index
selectedRowKeys: [], selectedRowKeys: [],
@ -89,28 +114,29 @@ export default {
this.searchForm = data; this.searchForm = data;
console.log(this.searchForm); console.log(this.searchForm);
} }
let res = await announcementList({ let res = await shopList({
pageNum: this.pagination.current, pageNum: this.pagination.current,
size: this.pagination.pageSize, size: this.pagination.pageSize,
...this.searchForm ...this.searchForm,
}); });
this.tableData = res.data.rows; this.tableData = res.data.rows;
this.pagination.total = res.data.total; this.pagination.total = res.data.total;
this.selectedRowKeys=[] this.selectedRowKeys = [];
}, },
edit(id) { edit(data) {
this.editId = id; this.form.shopName = data.shopName
this.form.id = data.id
this.drawer.show = true; this.drawer.show = true;
this.drawer.title = '修改店铺';
}, },
del(ids) { del(ids) {
console.log(ids);
this.$confirm({ this.$confirm({
title: "是否删除", title: "是否删除",
// okText:'', // okText:'',
// cancelText:'', // cancelText:'',
icon: "delete", icon: "delete",
onOk: async () => { onOk: async () => {
let res = await announcementDel({ activityOrganizerIds: ids }); let res = await shopDel({ ids: ids });
if (res.code === 200) { if (res.code === 200) {
this.$message.success(res.msg); this.$message.success(res.msg);
this.getData(); this.getData();
@ -141,11 +167,36 @@ export default {
this.getData(); this.getData();
}, },
addClose() { addClose() {
this.$refs.ruleForm.resetFields();
this.drawer.show = false; this.drawer.show = false;
this.editId = null; this.drawer.title = '新增店铺';
}, },
success() { submit() {
console.log(this.form);
this.$refs.ruleForm.validate(async (valid) => {
if (valid) {
if (this.form.id === null) {
let res = await shopInsert(this.form);
if (res.code === 200) {
this.$message.success(res.msg);
this.addClose();
this.getData(); this.getData();
} else {
this.$message.error(res.msg);
}
} else {
console.log(this.form);
let res = await shopUpdate(this.form);
if (res.code === 200) {
this.$message.success(res.msg);
this.addClose();
this.getData();
} else {
this.$message.error(res.msg);
}
}
}
});
}, },
}, },
computed: { computed: {

@ -1,99 +1,15 @@
export const formItem = [ export const formItem = [
{ {
type: 'input', type: 'input',
label:'标题', label:'供应商名称',
prop:'title', prop:'vendorName',
placeholder:'请输入' placeholder:'请输入'
}, },
{
type: 'select',
label:'推送对象',
prop:'object',
option:[{ id:1,name:'全部'},{ id:2,name:'住户'},{ id:3,name:'业主'},{ id:4,name:'租户'},{ id:5,name:'管家'}],
placeholder:'请选择'
},
{
type: 'select',
label:'发布状态',
prop:'status',
option:[{ id:1,name:'未发布'},{ id:2,name:'已发布'}],
placeholder:'请选择'
},
{
type: 'time',
label:'更新时间',
start: 'modifyStartTime',
end:'modifyEndTime'
},
] ]
export const columns = [ export const columns = [
{ {
title: "标题", title: "供应商名称",
dataIndex: "title", dataIndex: "vendorName",
width: "16%",
},
{
title: "推送对象",
dataIndex: "object",
width: "10%",
customRender: function (object) {
switch (object) {
case 1:
return '全部'
break;
case 2:
return '住户'
break;
case 3:
return '业主'
break;
case 4:
return '租户'
break;
case 5:
return '管家'
break;
default:
break;
}
}
},
{
title: "状态",
dataIndex: "status",
width: "10%",
customRender: function (status) {
switch (status) {
case 1:
return '未发布'
break;
case 2:
return '已发布'
break;
default:
break;
}
}
},
{
title: "内容",
dataIndex: "content",
width: "13%",
},
{
title: "阅读量",
dataIndex: "readingVolume",
width: "10%",
},
{
title: "附件下载次数",
dataIndex: "downloadNum",
width: "10%",
},
{
title: "更新时间",
dataIndex: "modifyDate",
width: "14%",
}, },
{ {
title: "操作", title: "操作",

@ -1,28 +1,7 @@
export const form = { export const form = {
id:undefined, id:null,
title:undefined, vendorName: undefined,
object:undefined,
status:undefined,
content:undefined,
coverImgUrls:[],
annexUrls:[],
} }
export const rules = { export const rules = {
title:[{required:true,message:'请输入标题',trigger:'blur'}], vendorName:[{required:true,message:'请输入供应商名',trigger:'blur'}],
object:[{required:true,message:'请选择',trigger:'change'}],
status:[{required:true,message:'请选择',trigger:'change'}],
content:[{required:true,message:'请输入标题',trigger:'blur'}],
}
export const options = {
status:[
{ id:1, name:'未发布' },
{ id:2, name:'已发布' },
],
object:[
{ id:1, name:'全部' },
{ id:2, name:'住户' },
{ id:3, name:'业主' },
{ id:4, name:'租户' },
{ id:5, name:'管家' },
],
} }

@ -1,241 +0,0 @@
<template>
<div>
<a-drawer
:title="title"
:width="720"
:visible="show"
:body-style="{ paddingBottom: '80px' }"
@close="addClose"
>
<div class="drawer-content">
基本信息
<a-divider></a-divider>
<a-form-model
ref="ruleForm"
:model="form"
:rules="rules"
layout="vertical"
>
<a-form-model-item prop="title" label="标题">
<a-input
v-model="form.title"
placeholder="请输入标题"
style="width: 80%"
></a-input>
</a-form-model-item>
<a-form-model-item prop="object" label="推送对象">
<a-select
v-model="form.object"
placeholder="请选择"
style="width: 80%"
>
<a-select-option
v-for="item in options.object"
:key="item.id"
:value="item.id"
>{{ item.name }}</a-select-option
>
</a-select>
</a-form-model-item>
<a-form-model-item prop="status" label="状态">
<a-select
v-model="form.status"
placeholder="请选择"
style="width: 80%"
>
<a-select-option
v-for="item in options.status"
:key="item.id"
:value="item.id"
>{{ item.name }}</a-select-option
>
</a-select>
</a-form-model-item>
<a-form-model-item prop="content" label="内容">
<a-textarea
v-model="form.content"
placeholder="请输入内容"
style="width: 80%"
></a-textarea>
</a-form-model-item>
封面图片
<commonUpload
:fileList="fileList"
@handleChange="handleChange"
></commonUpload>
附件
<a-upload
name="file"
:multiple="true"
:action="`${$upload}`"
:file-list="documentList"
accept=".doc,.DOC,.xls,.XLS,.xlsx,.XLSX,.pdf,.PDF"
:headers="uploadHeaders"
@change="changeFile"
>
<a-button> <a-icon type="upload" /> 上传附件</a-button>
</a-upload>
</a-form-model>
</div>
<div class="drawer-footer">
<a-button :style="{ marginRight: '8px' }" @click="addClose">
关闭
</a-button>
<a-button type="primary" @click="submit"> </a-button>
</div>
</a-drawer>
</div>
</template>
<script>
import store from "@/store";
import { form, rules, options } from "./form.js";
import {
announcementInsert,
announcementUpdate,
announcementInfo,
} from "@/api/operation/announcement";
export default {
props: {
show: {
type: Boolean,
default: false,
},
editId: Number,
},
data() {
return {
title: "新增公告",
form,
rules,
options,
fileList: [],
documentList: [],
uploadHeaders: {
"manage-login-token": store.getters.getToken,
},
};
},
methods: {
addClose() {
this.$refs.ruleForm.resetFields();
this.fileList = [];
this.documentList = [];
this.form.coverImgUrls = [];
this.form.annexUrls = [];
this.$emit("addClose");
},
success() {
this.$emit("success");
this.addClose();
},
submit() {
console.log(this.documentList);
let arr = [];
for (let k of this.documentList) {
if (k.response) {
arr.push(k.response.data);
} else {
arr.push(k.url.split("/")[k.url.split("/").length - 1]);
}
}
this.form.annexUrls = arr;
console.log(this.form);
this.$refs.ruleForm.validate(async (valid) => {
if (valid) {
if (this.editId === null) {
let res = await announcementInsert(this.form);
if (res.code === 200) {
this.$message.success(res.msg);
this.success();
} else {
this.$message.error(res.msg);
}
} else {
console.log(this.form);
let res = await announcementUpdate(this.form);
if (res.code === 200) {
this.$message.success(res.msg);
this.success();
} else {
this.$message.error(res.msg);
}
}
}
});
},
changeFile(info) {
this.documentList = info.fileList;
if (info.file.status !== "uploading") {
console.log(info.file, info.fileList);
}
if (info.file.status === "done") {
this.$message.success(`${info.file.name} 上传成功`);
// this.form.annexUrls.push(info.file.response.data);
} else if (info.file.status === "error") {
this.$message.error(`${info.file.name} 上传失败`);
}
},
handleChange(data) {
this.fileList = data;
this.form.coverImgUrls = [];
if (data[0].status === "done") {
console.log("-------done-------");
this.form.coverImgUrls.push(data[0].response.data);
}
},
},
watch: {
editId: {
handler(val) {
if (val !== null) {
this.title = "修改公告";
this.form.id = val;
announcementInfo({ announcementId: val }).then((res) => {
this.form = res.data;
if (res.data.coverImgList.length > 0) {
console.log(res.data.coverImgList);
const pic = [];
for (let item of res.data.coverImgList) {
let obj = {
name: item.url.split("_")[0] + "." + item.url.split(".")[1],
url: this.$ImgUrl(item.url),
uid: item.url.split("_")[1],
status: "done",
thumbUrl: this.$ImgUrl(item.url),
};
pic.push(obj);
}
this.fileList = pic;
} else {
this.form.coverImgList = [];
}
if (res.data.annexImgList.length > 0) {
console.log(res.data.annexImgList);
const file = [];
for (let item of res.data.annexImgList) {
let obj = {
name: item.url.split("_")[0] + "." + item.url.split(".")[1],
url: this.$ImgUrl(item.url),
uid: item.url.split("_")[1],
status: "done",
thumbUrl: this.$ImgUrl(item.url),
};
file.push(obj);
}
this.documentList = file;
} else {
this.form.coverImgList = [];
}
});
} else {
this.title = "新增公告";
}
},
immediate: true,
},
},
};
</script>
<style></style>

@ -1,15 +1,14 @@
<template> <template>
<div> <div>
<div class="cardTitle">公告</div> <div class="cardTitle">供应商管理</div>
<searchForm :formItem="formItem" @getSearch="getData($event)"></searchForm> <searchForm :formItem="formItem" @getSearch="getData($event)"></searchForm>
<a-button style="margin: 10px" class="add-btn" @click="drawer.show = true" <a-button style="margin: 10px" class="add-btn" @click="drawer.show = true"
>新增公告</a-button >新增供应商</a-button
> >
<a-table <a-table
:columns="columns" :columns="columns"
:data-source="tableData" :data-source="tableData"
:pagination="pagination" :pagination="pagination"
:scroll="{ x: 1600 }"
@change="handleTableChange" @change="handleTableChange"
:row-selection="{ :row-selection="{
selectedRowKeys: selectedRowKeys, selectedRowKeys: selectedRowKeys,
@ -23,7 +22,7 @@
> >
<span slot="action" slot-scope="text, row"> <span slot="action" slot-scope="text, row">
<a-space> <a-space>
<a class="ant-dropdown-link" @click="edit(row.id)"></a> <a class="ant-dropdown-link" @click="edit(row)"></a>
<a class="ant-dropdown-link" @click="del([row.id])"></a> <a class="ant-dropdown-link" @click="del([row.id])"></a>
</a-space> </a-space>
</span> </span>
@ -41,39 +40,65 @@
</template> </template>
</span> </span>
</div> </div>
<addForm <a-drawer
:show="drawer.show" :title="drawer.title"
@success="success" :width="720"
@addClose="addClose" :visible="drawer.show"
:editId="editId" :body-style="{ paddingBottom: '80px' }"
></addForm> @close="addClose"
>
<div class="drawer-content">
基本信息
<a-divider></a-divider>
<a-form-model
ref="ruleForm"
:model="form"
:rules="rules"
layout="vertical"
>
<a-form-model-item prop="vendorName" label="供应商名称">
<a-input
v-model="form.vendorName"
placeholder="请输入供应商名称"
style="width: 50%"
></a-input>
</a-form-model-item>
</a-form-model>
</div>
<div class="drawer-footer">
<a-button :style="{ marginRight: '8px' }" @click="addClose">
关闭
</a-button>
<a-button type="primary" @click="submit"> </a-button>
</div>
</a-drawer>
</div> </div>
</template> </template>
<script> <script>
import { announcementList, announcementDel } from "@/api/operation/announcement"; import {
vendorList,
vendorInsert,
vendorDel,
vendorUpdate,
} from "@/api/shop/vendor";
import { formItem, columns, pagination } from "./depend/config"; import { formItem, columns, pagination } from "./depend/config";
import addForm from "./depend/form.vue"; import { form, rules } from "./depend/form.js";
export default { export default {
components: {
addForm,
},
data() { data() {
return { return {
drawer: { drawer: {
show: false, show: false,
title: "新增供应商"
}, },
editId: null,
tableData: [], tableData: [],
searchForm: { searchForm: {
title:undefined, name: undefined,
status:undefined,
object:undefined,
modifyStartTime:undefined,
modifyEndTime:undefined,
}, },
formItem, formItem,
columns, columns,
form,
rules,
pagination, pagination,
// index // index
selectedRowKeys: [], selectedRowKeys: [],
@ -89,28 +114,29 @@ export default {
this.searchForm = data; this.searchForm = data;
console.log(this.searchForm); console.log(this.searchForm);
} }
let res = await announcementList({ let res = await vendorList({
pageNum: this.pagination.current, pageNum: this.pagination.current,
size: this.pagination.pageSize, size: this.pagination.pageSize,
...this.searchForm ...this.searchForm,
}); });
this.tableData = res.data.rows; this.tableData = res.data.rows;
this.pagination.total = res.data.total; this.pagination.total = res.data.total;
this.selectedRowKeys=[] this.selectedRowKeys = [];
}, },
edit(id) { edit(data) {
this.editId = id; this.form.vendorName = data.vendorName
this.form.id = data.id
this.drawer.show = true; this.drawer.show = true;
this.drawer.title = '修改供应商';
}, },
del(ids) { del(ids) {
console.log(ids);
this.$confirm({ this.$confirm({
title: "是否删除", title: "是否删除",
// okText:'', // okText:'',
// cancelText:'', // cancelText:'',
icon: "delete", icon: "delete",
onOk: async () => { onOk: async () => {
let res = await announcementDel({ activityOrganizerIds: ids }); let res = await vendorDel({ ids: ids });
if (res.code === 200) { if (res.code === 200) {
this.$message.success(res.msg); this.$message.success(res.msg);
this.getData(); this.getData();
@ -141,11 +167,36 @@ export default {
this.getData(); this.getData();
}, },
addClose() { addClose() {
this.$refs.ruleForm.resetFields();
this.drawer.show = false; this.drawer.show = false;
this.editId = null; this.drawer.title = '新增供应商';
}, },
success() { submit() {
console.log(this.form);
this.$refs.ruleForm.validate(async (valid) => {
if (valid) {
if (this.form.id === null) {
let res = await vendorInsert(this.form);
if (res.code === 200) {
this.$message.success(res.msg);
this.addClose();
this.getData(); this.getData();
} else {
this.$message.error(res.msg);
}
} else {
console.log(this.form);
let res = await vendorUpdate(this.form);
if (res.code === 200) {
this.$message.success(res.msg);
this.addClose();
this.getData();
} else {
this.$message.error(res.msg);
}
}
}
});
}, },
}, },
computed: { computed: {

Loading…
Cancel
Save