解决商品分类不同步数据问题,解决pc端添加发票问题
parent
99ae898139
commit
336643419e
|
@ -11,42 +11,37 @@
|
||||||
</div> -->
|
</div> -->
|
||||||
<!-- 普通发票 -->
|
<!-- 普通发票 -->
|
||||||
<div class="nav-content">
|
<div class="nav-content">
|
||||||
<Form
|
<Form :model="invoiceForm" ref="form" label-position="left" :rules="ruleInline" :label-width="110">
|
||||||
:model="invoiceForm"
|
|
||||||
ref="form"
|
|
||||||
label-position="left"
|
|
||||||
:rules="ruleInline"
|
|
||||||
:label-width="110"
|
|
||||||
>
|
|
||||||
<FormItem label="发票类型">
|
<FormItem label="发票类型">
|
||||||
<RadioGroup v-model="invoiceForm.type" type="button" button-style="solid">
|
<RadioGroup v-model="invoice" type="button" button-style="solid">
|
||||||
|
<Radio @on-change="changeInvoice" :label="1">电子普通发票</Radio>
|
||||||
|
<Radio :label="2" :disabled="true">增值税专用发票</Radio>
|
||||||
|
</RadioGroup>
|
||||||
|
</FormItem>
|
||||||
|
<FormItem label="发票抬头">
|
||||||
|
<RadioGroup v-model="type" @on-change="changeInvoice" type="button" button-style="solid">
|
||||||
<Radio :label="1">个人</Radio>
|
<Radio :label="1">个人</Radio>
|
||||||
<Radio :label="2">单位</Radio>
|
<Radio :label="2">单位</Radio>
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem
|
<FormItem label="个人名称" v-if="type === 1" prop="receiptTitle">
|
||||||
label="发票抬头"
|
|
||||||
v-if="invoiceForm.type == 2"
|
|
||||||
prop="receiptTitle"
|
|
||||||
>
|
|
||||||
<i-input v-model="invoiceForm.receiptTitle"></i-input>
|
<i-input v-model="invoiceForm.receiptTitle"></i-input>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem
|
<FormItem label="单位名称" v-if="type === 2" prop="receiptTitle">
|
||||||
label="纳税人识别号"
|
<i-input v-model="invoiceForm.receiptTitle"></i-input>
|
||||||
v-if="invoiceForm.type == 2"
|
</FormItem>
|
||||||
prop="taxpayerId"
|
<FormItem label="纳税人识别号" v-if="type === 2" prop="taxpayerId">
|
||||||
>
|
|
||||||
<i-input v-model="invoiceForm.taxpayerId"></i-input>
|
<i-input v-model="invoiceForm.taxpayerId"></i-input>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem label="发票内容">
|
<FormItem label="发票内容">
|
||||||
<RadioGroup v-model="invoiceForm.receiptContent" type="button" button-style="solid">
|
<RadioGroup v-model="invoiceForm.receiptContent" type="button" button-style="solid">
|
||||||
<Radio label="不开发票">不开发票</Radio>
|
|
||||||
<Radio label="商品明细">商品明细</Radio>
|
<Radio label="商品明细">商品明细</Radio>
|
||||||
|
<Radio label="商品类别">商品类别</Radio>
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</Form>
|
</Form>
|
||||||
<div style="text-align: center">
|
<div style="text-align: center">
|
||||||
<Button type="primary" :loading="loading" @click="save">保存发票信息</Button>
|
<Button type="primary" :loading="loading" @click="submit">保存发票信息</Button>
|
||||||
<Button type="default" @click="invoiceAvailable = false">取消</Button>
|
<Button type="default" @click="invoiceAvailable = false">取消</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -54,100 +49,104 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { saveReceipt } from '@/api/member.js';
|
import { receiptSelect } from "@/api/cart.js";
|
||||||
import { TINumber } from '@/plugins/RegExp.js';
|
import { TINumber } from "@/plugins/RegExp.js";
|
||||||
export default {
|
export default {
|
||||||
name: 'invoiceModal',
|
name: "invoiceModal",
|
||||||
data () {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
invoice: 1,
|
||||||
invoiceAvailable: false, // 模态框显隐
|
invoiceAvailable: false, // 模态框显隐
|
||||||
loading: false, // 提交状态
|
loading: false, // 提交状态
|
||||||
invoiceForm: { // 发票表单
|
invoiceForm: {
|
||||||
|
// 发票表单
|
||||||
// 普票表单
|
// 普票表单
|
||||||
receiptTitle: '', // 发票抬头
|
receiptTitle: "", // 发票抬头
|
||||||
taxpayerId: '', // 纳税人识别号
|
taxpayerId: "", // 纳税人识别号
|
||||||
receiptContent: '不开发票', // 发票内容
|
receiptContent: "商品明细", // 发票内容
|
||||||
type: 1 // 1 个人 2 单位
|
|
||||||
},
|
},
|
||||||
|
type: 1, // 1 个人 2 单位
|
||||||
ruleInline: {
|
ruleInline: {
|
||||||
receiptTitle: [{ required: true, message: '请填写公司名称' }],
|
|
||||||
taxpayerId: [
|
taxpayerId: [
|
||||||
{ required: true, message: '请填写纳税人识别号' },
|
{ required: true, message: "请填写纳税人识别号" },
|
||||||
{ pattern: TINumber, message: '请填写正确的纳税人识别号' }
|
{ pattern: TINumber, message: "请填写正确的纳税人识别号" },
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
props: ["invoiceData"],
|
||||||
save () {
|
watch: {
|
||||||
if (this.invoiceForm.type === 1) {
|
invoiceData: {
|
||||||
// 个人
|
handler(val) {
|
||||||
let flag = true;
|
this.invoiceForm = { ...val };
|
||||||
this.receiptItems.forEach((e) => {
|
|
||||||
if (
|
|
||||||
e.receiptTitle === '个人' &&
|
|
||||||
e.receiptContent === this.invoiceForm.receiptContent
|
|
||||||
) {
|
|
||||||
this.$emit('change', e);
|
|
||||||
flag = false;
|
|
||||||
this.invoiceAvailable = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (flag) {
|
if (val.taxpayerId) {
|
||||||
let params = {
|
this.type = 2;
|
||||||
receiptTitle: '个人',
|
} else {
|
||||||
receiptContent: this.invoiceForm.receiptContent
|
this.type = 1;
|
||||||
};
|
|
||||||
this.loading = true;
|
|
||||||
saveReceipt(params)
|
|
||||||
.then((res) => {
|
|
||||||
this.loading = false;
|
|
||||||
if (res.success) {
|
|
||||||
this.$emit('change', res.result);
|
|
||||||
this.invoiceAvailable = false;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
this.loading = false;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else {
|
},
|
||||||
// 单位
|
deep: true,
|
||||||
|
immeadite: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/**
|
||||||
|
* 选择发票抬头
|
||||||
|
*/
|
||||||
|
changeInvoice(val) {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.type = val;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存判断
|
||||||
|
*/
|
||||||
|
save() {
|
||||||
|
let flage = true;
|
||||||
|
|
||||||
|
// 保存分为两种类型,个人以及企业
|
||||||
|
const { type, receiptTitle, receiptContent } = JSON.parse(
|
||||||
|
JSON.stringify(this.invoiceForm)
|
||||||
|
);
|
||||||
|
|
||||||
|
// 判断是否填写发票抬头
|
||||||
|
if (!receiptTitle) {
|
||||||
|
this.$Message.error("请填写发票抬头!");
|
||||||
|
flage = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == 2) {
|
||||||
this.$refs.form.validate((valid) => {
|
this.$refs.form.validate((valid) => {
|
||||||
if (valid) {
|
if (!valid) {
|
||||||
this.loading = true;
|
flage = false;
|
||||||
let params = {
|
|
||||||
receiptTitle: this.invoiceForm.receiptTitle,
|
|
||||||
taxpayerId: this.invoiceForm.taxpayerId,
|
|
||||||
receiptContent: this.invoiceForm.receiptContent
|
|
||||||
};
|
|
||||||
let flag = true;
|
|
||||||
this.receiptItems.forEach((e) => {
|
|
||||||
if (e.taxpayerId === params.taxpayerId) {
|
|
||||||
flag = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (!flag) {
|
|
||||||
this.$Message.error('已有当前税号的发票信息,请直接选择已有发票');
|
|
||||||
} else {
|
|
||||||
saveReceipt(params)
|
|
||||||
.then((res) => {
|
|
||||||
this.loading = false;
|
|
||||||
if (res.success) {
|
|
||||||
this.$emit('change', res.result);
|
|
||||||
this.invoiceAvailable = false;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
this.loading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
delete this.invoiceForm.taxpayerId;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
return flage;
|
||||||
|
},
|
||||||
|
|
||||||
|
async submit() {
|
||||||
|
if (this.save()) {
|
||||||
|
this.loading = true;
|
||||||
|
let submit = {
|
||||||
|
way: this.$route.query.way,
|
||||||
|
...this.invoiceForm,
|
||||||
|
};
|
||||||
|
let receipt = await receiptSelect(submit);
|
||||||
|
if (receipt.success) {
|
||||||
|
this.$emit("change", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.loading = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -5,6 +5,13 @@ import { getRequest, postRequest, putRequest, deleteRequest} from '@/libs/axios'
|
||||||
export const getManagerBrandPage = (params) => {
|
export const getManagerBrandPage = (params) => {
|
||||||
return getRequest('/goods/brand/getByPage', params)
|
return getRequest('/goods/brand/getByPage', params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 批量删除
|
||||||
|
export const delBrand = (ids) =>{
|
||||||
|
return deleteRequest(`/goods/brand/delByIds/${ids}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 添加
|
// 添加
|
||||||
export const addBrand = (params) => {
|
export const addBrand = (params) => {
|
||||||
return postRequest('/goods/brand', params)
|
return postRequest('/goods/brand', params)
|
||||||
|
|
|
@ -17,10 +17,15 @@ export default {
|
||||||
* @description api请求基础路径
|
* @description api请求基础路径
|
||||||
*/
|
*/
|
||||||
api_dev: {
|
api_dev: {
|
||||||
common: "https://common-api.pickmall.cn",
|
// common: "https://common-api.pickmall.cn",
|
||||||
buyer: "https://buyer-api.pickmall.cn",
|
// buyer: "https://buyer-api.pickmall.cn",
|
||||||
seller: "https://store-api.pickmall.cn",
|
// seller: "https://store-api.pickmall.cn",
|
||||||
manager: "https://admin-api.pickmall.cn"
|
// manager: "https://admin-api.pickmall.cn"
|
||||||
|
common: "http://192.168.0.100:8890",
|
||||||
|
buyer: "http://192.168.0.100:8888",
|
||||||
|
seller: "http://192.168.0.100:8889",
|
||||||
|
manager: "http://192.168.0.100:8887"
|
||||||
|
|
||||||
},
|
},
|
||||||
api_prod: {
|
api_prod: {
|
||||||
common: "https://common-api.pickmall.cn",
|
common: "https://common-api.pickmall.cn",
|
||||||
|
|
|
@ -1,25 +1,13 @@
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
@import "@/styles/table-common.scss";
|
@import "@/styles/table-common.scss";
|
||||||
</style>
|
</style>
|
||||||
<template>
|
<template>
|
||||||
<div class="search">
|
<div class="search">
|
||||||
<Card>
|
<Card>
|
||||||
<Row @keydown.enter.native="handleSearch">
|
<Row @keydown.enter.native="handleSearch">
|
||||||
<Form
|
<Form ref="searchForm" :model="searchForm" inline :label-width="70" class="search-form">
|
||||||
ref="searchForm"
|
|
||||||
:model="searchForm"
|
|
||||||
inline
|
|
||||||
:label-width="70"
|
|
||||||
class="search-form"
|
|
||||||
>
|
|
||||||
<Form-item label="品牌名称" prop="name">
|
<Form-item label="品牌名称" prop="name">
|
||||||
<Input
|
<Input type="text" v-model="searchForm.name" placeholder="请输入品牌名称" clearable style="width: 200px" />
|
||||||
type="text"
|
|
||||||
v-model="searchForm.name"
|
|
||||||
placeholder="请输入品牌名称"
|
|
||||||
clearable
|
|
||||||
style="width: 200px"
|
|
||||||
/>
|
|
||||||
</Form-item>
|
</Form-item>
|
||||||
|
|
||||||
<Button @click="handleSearch" type="primary" icon="ios-search" class="search-btn">搜索</Button>
|
<Button @click="handleSearch" type="primary" icon="ios-search" class="search-btn">搜索</Button>
|
||||||
|
@ -28,370 +16,375 @@
|
||||||
<Row class="operation padding-row">
|
<Row class="operation padding-row">
|
||||||
<Button @click="add" type="primary">添加</Button>
|
<Button @click="add" type="primary">添加</Button>
|
||||||
</Row>
|
</Row>
|
||||||
<Table
|
<Table :loading="loading" border :columns="columns" :data="data" ref="table" sortable="custom" @on-sort-change="changeSort" @on-selection-change="changeSelect"></Table>
|
||||||
:loading="loading"
|
|
||||||
border
|
|
||||||
:columns="columns"
|
|
||||||
:data="data"
|
|
||||||
ref="table"
|
|
||||||
sortable="custom"
|
|
||||||
@on-sort-change="changeSort"
|
|
||||||
@on-selection-change="changeSelect"
|
|
||||||
></Table>
|
|
||||||
<Row type="flex" justify="end" class="page">
|
<Row type="flex" justify="end" class="page">
|
||||||
<Page
|
<Page :current="searchForm.pageNumber" :total="total" :page-size="searchForm.pageSize" @on-change="changePage" @on-page-size-change="changePageSize" :page-size-opts="[10, 20, 50]" size="small"
|
||||||
:current="searchForm.pageNumber"
|
show-total show-elevator show-sizer></Page>
|
||||||
:total="total"
|
|
||||||
:page-size="searchForm.pageSize"
|
|
||||||
@on-change="changePage"
|
|
||||||
@on-page-size-change="changePageSize"
|
|
||||||
:page-size-opts="[10, 20, 50]"
|
|
||||||
size="small"
|
|
||||||
show-total
|
|
||||||
show-elevator
|
|
||||||
show-sizer
|
|
||||||
></Page>
|
|
||||||
</Row>
|
</Row>
|
||||||
</Card>
|
</Card>
|
||||||
<Modal
|
<Modal :title="modalTitle" v-model="modalVisible" :mask-closable="false" :width="500">
|
||||||
:title="modalTitle"
|
|
||||||
v-model="modalVisible"
|
|
||||||
:mask-closable="false"
|
|
||||||
:width="500"
|
|
||||||
>
|
|
||||||
<Form ref="form" :model="form" :label-width="100" :rules="formValidate">
|
<Form ref="form" :model="form" :label-width="100" :rules="formValidate">
|
||||||
<FormItem label="品牌名称" prop="name">
|
<FormItem label="品牌名称" prop="name">
|
||||||
<Input v-model="form.name" clearable style="width: 100%"/>
|
<Input v-model="form.name" clearable style="width: 100%" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem label="品牌图标" prop="logo">
|
<FormItem label="品牌图标" prop="logo">
|
||||||
<upload-pic-input
|
<upload-pic-input v-model="form.logo" style="width: 100%"></upload-pic-input>
|
||||||
v-model="form.logo"
|
|
||||||
style="width: 100%"
|
|
||||||
></upload-pic-input>
|
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</Form>
|
</Form>
|
||||||
<div slot="footer">
|
<div slot="footer">
|
||||||
<Button type="text" @click="modalVisible = false">取消</Button>
|
<Button type="text" @click="modalVisible = false">取消</Button>
|
||||||
<Button type="primary" :loading="submitLoading" @click="handleSubmit"
|
<Button type="primary" :loading="submitLoading" @click="handleSubmit">提交
|
||||||
>提交
|
</Button>
|
||||||
</Button
|
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {getManagerBrandPage, addBrand,updateBrand, disableBrand} from "@/api/goods";
|
import {
|
||||||
import uploadPicInput from "@/views/my-components/lili/upload-pic-input";
|
getManagerBrandPage,
|
||||||
|
addBrand,
|
||||||
|
updateBrand,
|
||||||
|
disableBrand,
|
||||||
|
delBrand,
|
||||||
|
} from "@/api/goods";
|
||||||
|
import uploadPicInput from "@/views/my-components/lili/upload-pic-input";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "brand",
|
name: "brand",
|
||||||
components: {
|
components: {
|
||||||
uploadPicInput,
|
uploadPicInput,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
loading: true, // 表单加载状态
|
loading: true, // 表单加载状态
|
||||||
modalType: 0, // 添加或编辑标识
|
modalType: 0, // 添加或编辑标识
|
||||||
modalVisible: false, // 添加或编辑显示
|
modalVisible: false, // 添加或编辑显示
|
||||||
modalTitle: "", // 添加或编辑标题
|
modalTitle: "", // 添加或编辑标题
|
||||||
searchForm: {
|
searchForm: {
|
||||||
// 搜索框初始化对象
|
// 搜索框初始化对象
|
||||||
pageNumber: 1, // 当前页数
|
pageNumber: 1, // 当前页数
|
||||||
pageSize: 10, // 页面大小
|
pageSize: 10, // 页面大小
|
||||||
sort: "create_time", // 默认排序字段
|
sort: "create_time", // 默认排序字段
|
||||||
order: "desc", // 默认排序方式
|
order: "desc", // 默认排序方式
|
||||||
|
},
|
||||||
|
form: {
|
||||||
|
// 添加或编辑表单对象初始化数据
|
||||||
|
name: "",
|
||||||
|
logo: "",
|
||||||
|
deleteFlag: "",
|
||||||
|
},
|
||||||
|
// 表单验证规则
|
||||||
|
formValidate: {},
|
||||||
|
submitLoading: false, // 添加或编辑提交状态
|
||||||
|
selectList: [], // 多选数据
|
||||||
|
selectCount: 0, // 多选计数
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
title: "品牌名称",
|
||||||
|
key: "name",
|
||||||
|
width: 200,
|
||||||
|
resizable: true,
|
||||||
|
sortable: false,
|
||||||
},
|
},
|
||||||
form: {
|
{
|
||||||
// 添加或编辑表单对象初始化数据
|
title: "品牌图标",
|
||||||
name: "",
|
key: "logo",
|
||||||
logo: "",
|
align: "left",
|
||||||
deleteFlag: "",
|
render: (h, params) => {
|
||||||
|
return h("img", {
|
||||||
|
attrs: {
|
||||||
|
src: params.row.logo,
|
||||||
|
alt: "加载图片失败",
|
||||||
|
},
|
||||||
|
style: {
|
||||||
|
cursor: "pointer",
|
||||||
|
width: "80px",
|
||||||
|
height: "60px",
|
||||||
|
margin: "10px 0",
|
||||||
|
"object-fit": "contain",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
// 表单验证规则
|
{
|
||||||
formValidate: {},
|
title: "状态",
|
||||||
submitLoading: false, // 添加或编辑提交状态
|
key: "deleteFlag",
|
||||||
selectList: [], // 多选数据
|
align: "left",
|
||||||
selectCount: 0, // 多选计数
|
render: (h, params) => {
|
||||||
columns: [
|
if (params.row.deleteFlag == 0) {
|
||||||
{
|
|
||||||
title: "品牌名称",
|
|
||||||
key: "name",
|
|
||||||
width: 200,
|
|
||||||
resizable: true,
|
|
||||||
sortable: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "品牌图标",
|
|
||||||
key: "logo",
|
|
||||||
align: "left",
|
|
||||||
render: (h, params) => {
|
|
||||||
return h("img", {
|
|
||||||
attrs: {
|
|
||||||
src: params.row.logo,
|
|
||||||
alt: "加载图片失败",
|
|
||||||
},
|
|
||||||
style: {
|
|
||||||
cursor: "pointer",
|
|
||||||
width: "80px",
|
|
||||||
height: "60px",
|
|
||||||
margin: "10px 0",
|
|
||||||
"object-fit": "contain",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "状态",
|
|
||||||
key: "deleteFlag",
|
|
||||||
align: "left",
|
|
||||||
render: (h, params) => {
|
|
||||||
if (params.row.deleteFlag == 0) {
|
|
||||||
return h("div", [
|
|
||||||
h("Badge", {
|
|
||||||
props: {
|
|
||||||
status: "success",
|
|
||||||
text: "启用",
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
} else if (params.row.deleteFlag == 1) {
|
|
||||||
return h("div", [
|
|
||||||
h("Badge", {
|
|
||||||
props: {
|
|
||||||
status: "error",
|
|
||||||
text: "禁用",
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
filters: [
|
|
||||||
{
|
|
||||||
label: "启用",
|
|
||||||
value: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "禁用",
|
|
||||||
value: 1,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
filterMultiple: false,
|
|
||||||
filterMethod(value, row) {
|
|
||||||
if (value == 0) {
|
|
||||||
return row.deleteFlag == 0;
|
|
||||||
} else if (value == 1) {
|
|
||||||
return row.deleteFlag == 1;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "操作",
|
|
||||||
key: "action",
|
|
||||||
width: 180,
|
|
||||||
align: "center",
|
|
||||||
fixed: "right",
|
|
||||||
render: (h, params) => {
|
|
||||||
let enableOrDisable = "";
|
|
||||||
if (params.row.deleteFlag == 0) {
|
|
||||||
enableOrDisable = h(
|
|
||||||
"Button",
|
|
||||||
{
|
|
||||||
props: {
|
|
||||||
size: "small",
|
|
||||||
type: "error",
|
|
||||||
},
|
|
||||||
style: {
|
|
||||||
marginRight: "5px",
|
|
||||||
},
|
|
||||||
on: {
|
|
||||||
click: () => {
|
|
||||||
this.disable(params.row);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"禁用"
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
enableOrDisable = h(
|
|
||||||
"Button",
|
|
||||||
{
|
|
||||||
props: {
|
|
||||||
type: "success",
|
|
||||||
size: "small",
|
|
||||||
},
|
|
||||||
style: {
|
|
||||||
marginRight: "5px",
|
|
||||||
},
|
|
||||||
on: {
|
|
||||||
click: () => {
|
|
||||||
this.enable(params.row);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"启用"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return h("div", [
|
return h("div", [
|
||||||
h(
|
h("Badge", {
|
||||||
"Button",
|
props: {
|
||||||
{
|
status: "success",
|
||||||
props: {
|
text: "启用",
|
||||||
type: "info",
|
},
|
||||||
size: "small",
|
}),
|
||||||
},
|
]);
|
||||||
style: {
|
} else if (params.row.deleteFlag == 1) {
|
||||||
marginRight: "5px",
|
return h("div", [
|
||||||
},
|
h("Badge", {
|
||||||
on: {
|
props: {
|
||||||
click: () => {
|
status: "error",
|
||||||
this.edit(params.row);
|
text: "禁用",
|
||||||
},
|
},
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
filters: [
|
||||||
|
{
|
||||||
|
label: "启用",
|
||||||
|
value: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "禁用",
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
filterMultiple: false,
|
||||||
|
filterMethod(value, row) {
|
||||||
|
if (value == 0) {
|
||||||
|
return row.deleteFlag == 0;
|
||||||
|
} else if (value == 1) {
|
||||||
|
return row.deleteFlag == 1;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "操作",
|
||||||
|
key: "action",
|
||||||
|
width: 180,
|
||||||
|
align: "center",
|
||||||
|
fixed: "right",
|
||||||
|
render: (h, params) => {
|
||||||
|
let enableOrDisable = "";
|
||||||
|
if (params.row.deleteFlag == 0) {
|
||||||
|
enableOrDisable = h(
|
||||||
|
"Button",
|
||||||
|
{
|
||||||
|
props: {
|
||||||
|
size: "small",
|
||||||
|
type: "error",
|
||||||
|
},
|
||||||
|
style: {
|
||||||
|
marginRight: "5px",
|
||||||
|
},
|
||||||
|
on: {
|
||||||
|
click: () => {
|
||||||
|
this.disable(params.row);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"编辑"
|
},
|
||||||
),
|
"禁用"
|
||||||
enableOrDisable,
|
);
|
||||||
]);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
data: [], // 表单数据
|
|
||||||
total: 0, // 表单数据总数
|
|
||||||
};
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
init() {
|
|
||||||
this.getDataList();
|
|
||||||
},
|
|
||||||
changePage(v) {
|
|
||||||
this.searchForm.pageNumber = v;
|
|
||||||
this.getDataList();
|
|
||||||
this.clearSelectAll();
|
|
||||||
},
|
|
||||||
changePageSize(v) {
|
|
||||||
this.searchForm.pageSize = v;
|
|
||||||
this.getDataList();
|
|
||||||
},
|
|
||||||
handleSearch() {
|
|
||||||
this.searchForm.pageNumber = 1;
|
|
||||||
this.searchForm.pageSize = 10;
|
|
||||||
this.getDataList();
|
|
||||||
},
|
|
||||||
changeSort(e) {
|
|
||||||
this.searchForm.sort = e.key;
|
|
||||||
this.searchForm.order = e.order;
|
|
||||||
if (e.order === "normal") {
|
|
||||||
this.searchForm.order = "";
|
|
||||||
}
|
|
||||||
this.getDataList();
|
|
||||||
},
|
|
||||||
clearSelectAll() {
|
|
||||||
this.$refs.table.selectAll(false);
|
|
||||||
},
|
|
||||||
changeSelect(e) {
|
|
||||||
this.selectList = e;
|
|
||||||
this.selectCount = e.length;
|
|
||||||
},
|
|
||||||
getDataList() {
|
|
||||||
this.loading = true;
|
|
||||||
// 带多条件搜索参数获取表单数据 请自行修改接口
|
|
||||||
getManagerBrandPage(this.searchForm).then((res) => {
|
|
||||||
this.loading = false;
|
|
||||||
if (res.success) {
|
|
||||||
console.warn(12)
|
|
||||||
this.data = res.result.records;
|
|
||||||
this.total = res.result.total;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
handleSubmit() {
|
|
||||||
this.$refs.form.validate((valid) => {
|
|
||||||
if (valid) {
|
|
||||||
this.submitLoading = true;
|
|
||||||
if (this.modalType === 0) {
|
|
||||||
// 添加 避免编辑后传入id等数据 记得删除
|
|
||||||
delete this.form.id;
|
|
||||||
addBrand(this.form).then((res) => {
|
|
||||||
this.submitLoading = false;
|
|
||||||
if (res.success) {
|
|
||||||
this.$Message.success("操作成功");
|
|
||||||
this.getDataList();
|
|
||||||
this.modalVisible = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
// 编辑
|
enableOrDisable = h(
|
||||||
updateBrand(this.form).then((res) => {
|
"Button",
|
||||||
this.submitLoading = false;
|
{
|
||||||
if (res.success) {
|
props: {
|
||||||
this.$Message.success("操作成功");
|
type: "success",
|
||||||
this.getDataList();
|
size: "small",
|
||||||
this.modalVisible = false;
|
},
|
||||||
}
|
style: {
|
||||||
});
|
marginRight: "5px",
|
||||||
|
},
|
||||||
|
on: {
|
||||||
|
click: () => {
|
||||||
|
this.enable(params.row);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"启用"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
return h("div", [
|
||||||
});
|
h(
|
||||||
},
|
"Button",
|
||||||
add() {
|
{
|
||||||
this.modalType = 0;
|
props: {
|
||||||
this.modalTitle = "添加";
|
type: "info",
|
||||||
this.$refs.form.resetFields();
|
size: "small",
|
||||||
delete this.form.id;
|
},
|
||||||
this.modalVisible = true;
|
style: {
|
||||||
},
|
marginRight: "5px",
|
||||||
edit(v) {
|
},
|
||||||
this.modalType = 1;
|
on: {
|
||||||
this.modalTitle = "编辑";
|
click: () => {
|
||||||
this.$refs.form.resetFields();
|
this.edit(params.row);
|
||||||
// 转换null为""
|
},
|
||||||
for (let attr in v) {
|
},
|
||||||
if (v[attr] === null) {
|
},
|
||||||
v[attr] = "";
|
"编辑"
|
||||||
|
),
|
||||||
|
enableOrDisable,
|
||||||
|
|
||||||
|
h(
|
||||||
|
"Button",
|
||||||
|
{
|
||||||
|
props: {
|
||||||
|
size: "small",
|
||||||
|
},
|
||||||
|
style: {
|
||||||
|
marginRight: "5px",
|
||||||
|
},
|
||||||
|
on: {
|
||||||
|
click: () => {
|
||||||
|
this.delBrand(params.row.id);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"删除"
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
data: [], // 表单数据
|
||||||
|
total: 0, // 表单数据总数
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 删除品牌
|
||||||
|
async delBrand(id) {
|
||||||
|
let res = await delBrand(id);
|
||||||
|
|
||||||
|
if (res.success) {
|
||||||
|
this.$Message.success("品牌删除成功!");
|
||||||
|
this.getDataList();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
init() {
|
||||||
|
this.getDataList();
|
||||||
|
},
|
||||||
|
changePage(v) {
|
||||||
|
this.searchForm.pageNumber = v;
|
||||||
|
this.getDataList();
|
||||||
|
this.clearSelectAll();
|
||||||
|
},
|
||||||
|
changePageSize(v) {
|
||||||
|
this.searchForm.pageSize = v;
|
||||||
|
this.getDataList();
|
||||||
|
},
|
||||||
|
handleSearch() {
|
||||||
|
this.searchForm.pageNumber = 1;
|
||||||
|
this.searchForm.pageSize = 10;
|
||||||
|
this.getDataList();
|
||||||
|
},
|
||||||
|
changeSort(e) {
|
||||||
|
this.searchForm.sort = e.key;
|
||||||
|
this.searchForm.order = e.order;
|
||||||
|
if (e.order === "normal") {
|
||||||
|
this.searchForm.order = "";
|
||||||
|
}
|
||||||
|
this.getDataList();
|
||||||
|
},
|
||||||
|
clearSelectAll() {
|
||||||
|
this.$refs.table.selectAll(false);
|
||||||
|
},
|
||||||
|
changeSelect(e) {
|
||||||
|
this.selectList = e;
|
||||||
|
this.selectCount = e.length;
|
||||||
|
},
|
||||||
|
getDataList() {
|
||||||
|
this.loading = true;
|
||||||
|
// 带多条件搜索参数获取表单数据 请自行修改接口
|
||||||
|
getManagerBrandPage(this.searchForm).then((res) => {
|
||||||
|
this.loading = false;
|
||||||
|
if (res.success) {
|
||||||
|
console.warn(12);
|
||||||
|
this.data = res.result.records;
|
||||||
|
this.total = res.result.total;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleSubmit() {
|
||||||
|
this.$refs.form.validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
this.submitLoading = true;
|
||||||
|
if (this.modalType === 0) {
|
||||||
|
// 添加 避免编辑后传入id等数据 记得删除
|
||||||
|
delete this.form.id;
|
||||||
|
addBrand(this.form).then((res) => {
|
||||||
|
this.submitLoading = false;
|
||||||
|
if (res.success) {
|
||||||
|
this.$Message.success("操作成功");
|
||||||
|
this.getDataList();
|
||||||
|
this.modalVisible = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// 编辑
|
||||||
|
updateBrand(this.form).then((res) => {
|
||||||
|
this.submitLoading = false;
|
||||||
|
if (res.success) {
|
||||||
|
this.$Message.success("操作成功");
|
||||||
|
this.getDataList();
|
||||||
|
this.modalVisible = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let str = JSON.stringify(v);
|
});
|
||||||
let data = JSON.parse(str);
|
|
||||||
this.form = data;
|
|
||||||
this.modalVisible = true;
|
|
||||||
},
|
|
||||||
enable(v) {
|
|
||||||
this.$Modal.confirm({
|
|
||||||
title: "确认启用",
|
|
||||||
content: "您确认要启用品牌 " + v.name + " ?",
|
|
||||||
loading: true,
|
|
||||||
onOk: () => {
|
|
||||||
disableBrand(v.id, {disable: false}).then((res) => {
|
|
||||||
this.$Modal.remove();
|
|
||||||
if (res.success) {
|
|
||||||
this.$Message.success("操作成功");
|
|
||||||
this.getDataList();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
disable(v) {
|
|
||||||
this.$Modal.confirm({
|
|
||||||
title: "确认禁用",
|
|
||||||
content: "您确认要禁用品牌 " + v.name + " ?",
|
|
||||||
loading: true,
|
|
||||||
onOk: () => {
|
|
||||||
disableBrand(v.id, {disable: true}).then((res) => {
|
|
||||||
this.$Modal.remove();
|
|
||||||
if (res.success) {
|
|
||||||
this.$Message.success("操作成功");
|
|
||||||
this.getDataList();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
mounted() {
|
add() {
|
||||||
this.init();
|
this.modalType = 0;
|
||||||
|
this.modalTitle = "添加";
|
||||||
|
this.$refs.form.resetFields();
|
||||||
|
delete this.form.id;
|
||||||
|
this.modalVisible = true;
|
||||||
},
|
},
|
||||||
};
|
edit(v) {
|
||||||
|
this.modalType = 1;
|
||||||
|
this.modalTitle = "编辑";
|
||||||
|
this.$refs.form.resetFields();
|
||||||
|
// 转换null为""
|
||||||
|
for (let attr in v) {
|
||||||
|
if (v[attr] === null) {
|
||||||
|
v[attr] = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let str = JSON.stringify(v);
|
||||||
|
let data = JSON.parse(str);
|
||||||
|
this.form = data;
|
||||||
|
this.modalVisible = true;
|
||||||
|
},
|
||||||
|
enable(v) {
|
||||||
|
this.$Modal.confirm({
|
||||||
|
title: "确认启用",
|
||||||
|
content: "您确认要启用品牌 " + v.name + " ?",
|
||||||
|
loading: true,
|
||||||
|
onOk: () => {
|
||||||
|
disableBrand(v.id, { disable: false }).then((res) => {
|
||||||
|
this.$Modal.remove();
|
||||||
|
if (res.success) {
|
||||||
|
this.$Message.success("操作成功");
|
||||||
|
this.getDataList();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
disable(v) {
|
||||||
|
this.$Modal.confirm({
|
||||||
|
title: "确认禁用",
|
||||||
|
content: "您确认要禁用品牌 " + v.name + " ?",
|
||||||
|
loading: true,
|
||||||
|
onOk: () => {
|
||||||
|
disableBrand(v.id, { disable: true }).then((res) => {
|
||||||
|
this.$Modal.remove();
|
||||||
|
if (res.success) {
|
||||||
|
this.$Message.success("操作成功");
|
||||||
|
this.getDataList();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.init();
|
||||||
|
},
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<tree-table ref="treeTable" size="default" :loading="loading" :data="tableData" :columns="columns" :border="true" :show-index="false" :is-fold="true" :expand-type="false" primary-key="id">
|
<tree-table ref="treeTable" size="default" :loading="loading" :data="tableData" :columns="columns" :border="true" :show-index="false" :is-fold="true" :expand-type="false" primary-key="id">
|
||||||
|
|
||||||
<template slot="action" slot-scope="scope">
|
<template slot="action" slot-scope="scope">
|
||||||
<Dropdown v-show="scope.row.level == 2" transfer="true" trigger="click">
|
<Dropdown v-show="scope.row.level == 2" transfer="true" trigger="click">
|
||||||
<Button size="small">
|
<Button size="small">
|
||||||
绑定
|
绑定
|
||||||
<Icon type="ios-arrow-down"></Icon>
|
<Icon type="ios-arrow-down"></Icon>
|
||||||
|
@ -212,13 +212,17 @@ export default {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
tableData: [],
|
tableData: [],
|
||||||
|
categoryIndex: 0,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
changeSortCate(val) {
|
changeSortCate(val) {
|
||||||
let way = this.categoryList.find((item) => {
|
let way = this.categoryList.find((item, index) => {
|
||||||
return item.name == val;
|
if (item.name == val) {
|
||||||
|
this.categoryIndex = index;
|
||||||
|
console.log((this.categoryIndex = index));
|
||||||
|
return item.name == val;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
this.tableData = [way];
|
this.tableData = [way];
|
||||||
},
|
},
|
||||||
|
@ -244,7 +248,7 @@ export default {
|
||||||
//弹出品牌关联框
|
//弹出品牌关联框
|
||||||
brandOperation(v) {
|
brandOperation(v) {
|
||||||
getCategoryBrandListData(v.id).then((res) => {
|
getCategoryBrandListData(v.id).then((res) => {
|
||||||
console.warn(res)
|
console.warn(res);
|
||||||
this.categoryId = v.id;
|
this.categoryId = v.id;
|
||||||
this.modalBrandTitle = "品牌关联";
|
this.modalBrandTitle = "品牌关联";
|
||||||
this.brandForm.categoryBrands = res.result.map((item) => item.id);
|
this.brandForm.categoryBrands = res.result.map((item) => item.id);
|
||||||
|
@ -337,7 +341,7 @@ export default {
|
||||||
this.submitLoading = false;
|
this.submitLoading = false;
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
this.$Message.success("添加成功");
|
this.$Message.success("添加成功");
|
||||||
this.getAllList(0);
|
this.getAllList(this.categoryIndex);
|
||||||
this.modalVisible = false;
|
this.modalVisible = false;
|
||||||
this.$refs.form.resetFields();
|
this.$refs.form.resetFields();
|
||||||
}
|
}
|
||||||
|
@ -348,7 +352,7 @@ export default {
|
||||||
this.submitLoading = false;
|
this.submitLoading = false;
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
this.$Message.success("修改成功");
|
this.$Message.success("修改成功");
|
||||||
this.getAllList(0);
|
this.getAllList(this.categoryIndex);
|
||||||
this.modalVisible = false;
|
this.modalVisible = false;
|
||||||
this.$refs.form.resetFields();
|
this.$refs.form.resetFields();
|
||||||
}
|
}
|
||||||
|
@ -376,13 +380,11 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getAllList(parent_id) {
|
getAllList(parent_id) {
|
||||||
this.sortCateList = []
|
this.sortCateList = [];
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
getCategoryTree(parent_id).then((res) => {
|
getCategoryTree(parent_id).then((res) => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
// 仅展开指定级数 默认后台已展开所有
|
|
||||||
let expandLevel = this.expandLevel;
|
|
||||||
localStorage.setItem("category", JSON.stringify(res.result));
|
localStorage.setItem("category", JSON.stringify(res.result));
|
||||||
res.result.forEach((e, index, arr) => {
|
res.result.forEach((e, index, arr) => {
|
||||||
this.sortCateList.push({
|
this.sortCateList.push({
|
||||||
|
@ -390,65 +392,14 @@ export default {
|
||||||
value: e.name,
|
value: e.name,
|
||||||
});
|
});
|
||||||
this.sortCate = arr[0].name;
|
this.sortCate = arr[0].name;
|
||||||
if (expandLevel == 1) {
|
|
||||||
if (e.level == 0) {
|
|
||||||
e.expand = false;
|
|
||||||
}
|
|
||||||
if (e.children && e.children.length > 0) {
|
|
||||||
e.children.forEach(function (c) {
|
|
||||||
if (c.level == 1) {
|
|
||||||
c.expand = false;
|
|
||||||
}
|
|
||||||
if (c.children && c.children.length > 0) {
|
|
||||||
c.children.forEach(function (b) {
|
|
||||||
if (b.level == 2) {
|
|
||||||
b.expand = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if (expandLevel == 2) {
|
|
||||||
if (e.level == 0) {
|
|
||||||
e.expand = true;
|
|
||||||
}
|
|
||||||
if (e.children && e.children.length > 0) {
|
|
||||||
e.children.forEach(function (c) {
|
|
||||||
if (c.level == 1) {
|
|
||||||
c.expand = false;
|
|
||||||
}
|
|
||||||
if (c.children && c.children.length > 0) {
|
|
||||||
c.children.forEach(function (b) {
|
|
||||||
if (b.level == 2) {
|
|
||||||
b.expand = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if (expandLevel == 3) {
|
|
||||||
if (e.level == 0) {
|
|
||||||
e.expand = true;
|
|
||||||
}
|
|
||||||
if (e.children && e.children.length > 0) {
|
|
||||||
e.children.forEach(function (c) {
|
|
||||||
if (c.level == 1) {
|
|
||||||
c.expand = true;
|
|
||||||
}
|
|
||||||
if (c.children && c.children.length > 0) {
|
|
||||||
c.children.forEach(function (b) {
|
|
||||||
if (b.level == 2) {
|
|
||||||
b.expand = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.categoryList = res.result;
|
this.categoryList = res.result;
|
||||||
this.tableData = [res.result[0]];
|
|
||||||
|
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$set(this, "tableData", [res.result[this.categoryIndex]]);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue