You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1312 lines
38 KiB
1312 lines
38 KiB
<style lang="less">
|
|
@import "@/styles/tree&table-common.less";
|
|
@import "./dictManage.less";
|
|
.btn{
|
|
width: 80px;
|
|
height: 30px;
|
|
text-align: center;
|
|
line-height: 30px;
|
|
background: #008ba0;
|
|
color:#fff;
|
|
border-right:1px solid #fff;
|
|
}
|
|
.content-left {
|
|
width: 80px;
|
|
background: #eee;
|
|
height: 475px;
|
|
overflow: scroll;
|
|
scrollbar-width: none;
|
|
}
|
|
.left-box {
|
|
width: 100%;
|
|
height: 50px;
|
|
font-size: 14px;
|
|
text-align: center;
|
|
line-height: 50px;
|
|
border-bottom: 1px solid #fff;
|
|
}
|
|
|
|
.left-box-hover {
|
|
width: 100%;
|
|
height: 50px;
|
|
font-size: 14px;
|
|
text-align: center;
|
|
line-height: 50px;
|
|
border-bottom: 1px solid #fff;
|
|
background-color: #fff;
|
|
}
|
|
|
|
.red {
|
|
border-right: 3px solid red;
|
|
}
|
|
.content-low{
|
|
height: 50px;
|
|
padding: 3px 5px;
|
|
border:1px solid #eee;
|
|
display: inline;
|
|
margin-right: 5px;
|
|
font-weight: bold;
|
|
}
|
|
.checked{
|
|
background: #60F3FF;
|
|
color: #fff !important;
|
|
}
|
|
</style>
|
|
<template>
|
|
<div class="search">
|
|
<Card>
|
|
<Row type="flex" justify="space-between">
|
|
<Col v-show="expand" span="5">
|
|
<Row class="operation">
|
|
<Button @click="handleAddDict" type="primary" icon="md-add">添加分类</Button>
|
|
<Dropdown @on-click="handleDropdown">
|
|
<Button>
|
|
更多操作
|
|
<Icon type="md-arrow-dropdown" />
|
|
</Button>
|
|
<DropdownMenu slot="list">
|
|
<DropdownItem name="editDict">编辑分类</DropdownItem>
|
|
<DropdownItem name="delDict">删除分类</DropdownItem>
|
|
<DropdownItem name="refreshDict">刷新</DropdownItem>
|
|
</DropdownMenu>
|
|
</Dropdown>
|
|
</Row>
|
|
<Alert show-icon>
|
|
当前选择:
|
|
<span class="select-title">{{ editTitle }}</span>
|
|
<a class="select-clear" v-if="editTitle" @click="cancelEdit">取消选择</a>
|
|
</Alert>
|
|
<Input v-model="searchKey" suffix="ios-search" @on-change="search" placeholder="输入搜索分类" clearable />
|
|
<div style="position: relative">
|
|
<div class="tree-bar" :style="{ maxHeight: maxHeight }">
|
|
<Tree ref="tree" :data="treeData" @on-select-change="selectTree"></Tree>
|
|
</div>
|
|
<Spin size="large" fix v-if="treeLoading"></Spin>
|
|
</div>
|
|
</Col>
|
|
<div class="expand">
|
|
<Icon :type="expandIcon" size="16" class="icon" @click="changeExpand" />
|
|
</div>
|
|
<Col :span="span">
|
|
<Row v-show="openSearch" @keydown.enter.native="handleSearch">
|
|
<Form ref="searchForm" :model="searchForm" inline :label-width="70">
|
|
<FormItem label="商品名称" prop="title">
|
|
<Input type="text" v-model="searchForm.productName" placeholder="请输入" clearable
|
|
style="width: 200px" />
|
|
</FormItem>
|
|
<FormItem style="margin-left: -35px" class="br">
|
|
<Button @click="handleSearch" type="primary" icon="ios-search">搜索</Button>
|
|
<Button @click="handleReset">重置</Button>
|
|
</FormItem>
|
|
</Form>
|
|
</Row>
|
|
<Row align="middle" justify="space-between" class="operation">
|
|
<div>
|
|
<Button @click="add" type="primary" icon="md-add">新增商品</Button>
|
|
</div>
|
|
<div class="icons">
|
|
<Tooltip content="刷新" placement="top" transfer>
|
|
<Icon type="md-refresh" size="18" class="item" @click="getDataList" />
|
|
</Tooltip>
|
|
<Tooltip :content="openSearch ? '关闭搜索' : '开启搜索'" placement="top" transfer>
|
|
<Icon type="ios-search" size="18" class="item tip" @click="openSearch = !openSearch" />
|
|
</Tooltip>
|
|
<Tooltip :content="openTip ? '关闭提示' : '开启提示'" placement="top" transfer>
|
|
<Icon type="md-bulb" size="18" class="item tip" @click="openTip = !openTip" />
|
|
</Tooltip>
|
|
<Tooltip content="表格密度" placement="top" transfer>
|
|
<Dropdown @on-click="changeTableSize" trigger="click">
|
|
<Icon type="md-list" size="18" class="item" />
|
|
<DropdownMenu slot="list">
|
|
<DropdownItem :selected="tableSize == 'default'" name="default">默认</DropdownItem>
|
|
<DropdownItem :selected="tableSize == 'large'" name="large">宽松</DropdownItem>
|
|
<DropdownItem :selected="tableSize == 'small'" name="small">紧密</DropdownItem>
|
|
</DropdownMenu>
|
|
</Dropdown>
|
|
</Tooltip>
|
|
<Tooltip content="导出数据" placement="top" transfer>
|
|
<Icon type="md-download" size="18" class="item" @click="exportData" />
|
|
</Tooltip>
|
|
</div>
|
|
</Row>
|
|
<Alert show-icon v-show="openTip">
|
|
已选择
|
|
<span class="select-count">{{ selectList.length }}</span> 项
|
|
<a class="select-clear" @click="clearSelectAll">清空</a>
|
|
</Alert>
|
|
<Table :loading="loading" border :columns="columns" :data="data" :size="tableSize" sortable="custom"
|
|
@on-sort-change="changeSort" @on-selection-change="showSelect" ref="table"></Table>
|
|
<Row type="flex" justify="end" class="page">
|
|
<Page :current="searchForm.pageNum" :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>
|
|
</Col>
|
|
</Row>
|
|
</Card>
|
|
|
|
<addType ref="addTypePage" :dataLength="dataLength" v-model="showAddDict" @on-submit="getGoodsType" />
|
|
|
|
<editDictType ref="editTypePage" :data="dictForm" v-model="showEditDict" @on-submit="editDictSuccess" />
|
|
|
|
<Modal :title="modalTitle" v-model="modalVisible" :mask-closable="false" :width="screenWidth *0.9">
|
|
<Form ref="form" :model="form" :label-width="80" :rules="formValidate">
|
|
<Col span="6">
|
|
<FormItem label="商品图标" class="form-noheight">
|
|
<upload-pic-input v-model="addGoodsForm.productPicture"></upload-pic-input>
|
|
</FormItem>
|
|
</Col>
|
|
<Col span="6">
|
|
<FormItem label="名称" prop="title">
|
|
<Input v-model="addGoodsForm.productName" />
|
|
</FormItem>
|
|
</Col>
|
|
<Col span="6">
|
|
<FormItem label="店铺分类" class="form-noheight">
|
|
<Input v-model="editTitle" disabled />
|
|
</FormItem>
|
|
</Col>
|
|
<Col span="6">
|
|
<FormItem label="商品规格" class="form-noheight">
|
|
<div>
|
|
<div v-for="(item,index) in addGoodsForm.attributeListPrice" style="display: flex;margin-top:5px;">
|
|
<Input v-model="item.specName" v-if="item.specName != ''&& addGoodsForm.attributeListPrice.length != 1" style="padding-right: 10px;" disabled />
|
|
<Input v-model="item.specPrice" style="padding-right: 10px;" @click="changePrice(index)" placeholder="商品价格" />
|
|
<Input v-model="item.specNum" style="padding-right: 10px;" @click="changecount(index)" placeholder="商品库存"/>
|
|
<button @click="deldantiaoguige(index)" v-if="addGoodsForm.attributeListPrice.length>1" style="width: 120px;height: 30px;line-height: 30px;color: red;border:none;background: #fff;">删除</button>
|
|
</div>
|
|
<div @click="checkSpec('guige')" style="margin-top:5px;width: 80px;height: 30px;text-align: center;line-height: 30px;background: #008ba0;color:#fff;">
|
|
选择规格
|
|
</div>
|
|
</div>
|
|
</FormItem>
|
|
</Col>
|
|
<Col span="6">
|
|
<FormItem label="拼团信息" class="form-noheight">
|
|
<div>
|
|
<div v-for="(item,index) in addGoodsForm.productGroupBuyPrices" style="display: flex;margin-top:5px;">
|
|
<Input v-model="item.groupCount" style="padding-right: 10px;" placeholder="成团人数" />
|
|
<Input v-model="item.groupPrice" style="padding-right: 10px;" placeholder="成团价格"/>
|
|
<button @click="delGroup(index)" v-if="addGoodsForm.productGroupBuyPrices.length>1" style="width: 120px;height: 30px;line-height: 30px;color: red;border:none;background: #fff;">删除</button>
|
|
</div>
|
|
<div @click="addGroup()" style="margin-top:5px;width: 80px;height: 30px;text-align: center;line-height: 30px;background: #008ba0;color:#fff;">
|
|
新增拼团
|
|
</div>
|
|
</div>
|
|
</FormItem>
|
|
</Col>
|
|
<Col span="6">
|
|
<FormItem label="餐盒费" class="form-noheight">
|
|
<Input v-model="addGoodsForm.lunchBox" />
|
|
</FormItem>
|
|
</Col>
|
|
<Col span="6">
|
|
<FormItem label="商品属性" class="form-noheight">
|
|
<div style="display: flex;flex-direction: column;">
|
|
<div v-for="(value,key) in Array.from(addGoodsForm.attributeList1)" style="display: flex;">
|
|
{{value[0]}}:
|
|
<div v-for="(item,index) in value[1].title">
|
|
{{item}}、
|
|
</div>
|
|
</div>
|
|
<div @click="checkSpec('shuxing')" style="width: 80px;height: 30px;text-align: center;line-height: 30px;background: #008ba0;color:#fff;">
|
|
选择属性
|
|
</div>
|
|
</div>
|
|
</FormItem>
|
|
</Col>
|
|
<Col span="6">
|
|
<FormItem label="起售数量" class="form-noheight">
|
|
<Input v-model="addGoodsForm.startPayNum" type="number" placeholder="每笔订单起购数量" />
|
|
</FormItem>
|
|
</Col>
|
|
<Col span="8">
|
|
<FormItem label="可售时间" class="form-noheight">
|
|
<div>
|
|
<div style="line-height: 37px;">
|
|
<input type="radio" :checked="addGoodsForm.sellTime==0" name="sellTime" @click="checkSellTime('0')" />全时段售卖
|
|
<input type="radio" :checked="addGoodsForm.sellTime==1" name="sellTime" @click="checkSellTime('1')" />自定义时段
|
|
</div>
|
|
</div>
|
|
<div style="display: flex;" v-if="addGoodsForm.sellTime == 1">
|
|
<TimePicker format="HH:mm" v-model="addGoodsForm.sellBeginTime" @on-change="selectDateRange" placeholder="选择起始时间"/>
|
|
<div style="width: 10px;height: 10px;"></div>
|
|
<TimePicker format="HH:mm" v-model="addGoodsForm.sellEndTime" @on-change="selectDateRange" placeholder="选择结束时间"/>
|
|
</div>
|
|
</FormItem>
|
|
</Col>
|
|
<Col span="8">
|
|
<FormItem label="设置加料" class="form-noheight">
|
|
<div>
|
|
<div style="line-height: 37px;">
|
|
<input type="radio" :checked="addGoodsForm.isMoreBuy==0" name="isMoreBuy" @click="checkisMoreBuy('0')" />否
|
|
<input type="radio" :checked="addGoodsForm.isMoreBuy==1" name="isMoreBuy" @click="checkisMoreBuy('1')" />是
|
|
</div>
|
|
</div>
|
|
</FormItem>
|
|
</Col>
|
|
<Col span="8">
|
|
<FormItem label="详细图文" class="form-noheight">
|
|
<div style="width:500px;height:400px;">
|
|
<editor v-model="addGoodsForm.productIntro" height="250"></editor>
|
|
</div>
|
|
</FormItem>
|
|
</Col>
|
|
</Form>
|
|
<div slot="footer">
|
|
<Button type="text" @click="modalVisible = false">取消</Button>
|
|
<Button type="primary" :loading="submitLoading" @click="handelSubmit">提交</Button>
|
|
</div>
|
|
</Modal>
|
|
<Modal :title="modalTitle" v-model="modalclass" :mask-closable="false" :width="700">
|
|
<div style="height:500px;">
|
|
<div class="content-left" style="float: left;">
|
|
<div class="left-box" v-for="(item,index) in categoryData" :key="index"
|
|
:class="item.parentId ? 'left-box-hover':''" @click="clickLeftBtn(index)">
|
|
<span style="width: 100%;height: 50px;line-height: 50px;display: inline-block;overflow: hidden;"
|
|
:class="item.parentId ? 'red' :''">{{item.title}}</span>
|
|
</div>
|
|
</div>
|
|
<div v-for="(item,index) in categorySonData" :key="index" @click="checkSpecValue(index)" class="content-low" :class="item.checked?'checked':''">
|
|
{{item.title}}
|
|
</div>
|
|
</div>
|
|
<div slot="footer">
|
|
<Button type="text" @click="modalclass = false">取消</Button>
|
|
<Button type="primary" :loading="submitLoading" @click="guigeSubmit">提交</Button>
|
|
</div>
|
|
</Modal>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import {
|
|
searchDict,
|
|
getAllDictDataList,
|
|
addDictData,
|
|
editDictData,
|
|
deleteData,
|
|
} from "@/api/index";
|
|
import {
|
|
goodsType,
|
|
deleteType,
|
|
categoryList,
|
|
categorySonList,
|
|
productSave,
|
|
getShareList,
|
|
productEdit,
|
|
productDelete,
|
|
productisMust,
|
|
productisPush,
|
|
productUp,
|
|
productDown
|
|
} from "@/api/app";
|
|
import addType from "./addType.vue";
|
|
import editDictType from "./editDictType.vue";
|
|
import uploadPicInput from "@/views/my-components/hiver/upload-pic-input";
|
|
import editor from "@/views/my-components/hiver/editor";
|
|
import dict from "@/views/my-components/hiver/dict";
|
|
export default {
|
|
name: "dic-manage",
|
|
components: {
|
|
addType,
|
|
editDictType,
|
|
uploadPicInput,
|
|
dict,
|
|
editor
|
|
},
|
|
data() {
|
|
return {
|
|
Visiable: false,
|
|
specValueArr:[],
|
|
attrValueArr:[],
|
|
modalclassType:'',
|
|
shopId: '',
|
|
tableSize: "default",
|
|
dataLength: 0,
|
|
showAddDict: false,
|
|
dictForm: {},
|
|
showEditDict: false,
|
|
openSearch: true,
|
|
categoryIndex: 0,
|
|
openTip: true,
|
|
treeLoading: false, // 树加载状态
|
|
maxHeight: "500px",
|
|
loading: false, // 表格加载状态
|
|
editTitle: "", // 编辑节点名称
|
|
searchKey: "", // 搜索树
|
|
expand: true,
|
|
span: 18,
|
|
expandIcon: "ios-arrow-back",
|
|
selectNode: {},
|
|
categoryData:[],
|
|
categorySonData:[],
|
|
treeData: [], // 树数据
|
|
selectList: [], // 多选数据
|
|
searchForm: {
|
|
// 搜索框对应data对象
|
|
categoryId: "",
|
|
shopId:'',
|
|
order: "",
|
|
pageNum: 1,
|
|
pageSize: "10",
|
|
searchStr: "",
|
|
sort: ""
|
|
|
|
|
|
// name: "",
|
|
// status: "",
|
|
// pageSize: 10, // 页面大小
|
|
// sort: "sort", // 默认排序字段
|
|
// order: "asc", // 默认排序方式
|
|
},
|
|
modalType: 0, // 添加或编辑标识
|
|
modalVisible: false, // 添加或编辑显示
|
|
modalclass:false,
|
|
modalTitle: "", // 添加或编辑标题
|
|
form: {
|
|
// 添加或编辑表单对象初始化数据
|
|
title: "",
|
|
value: "",
|
|
status: 0,
|
|
description: "",
|
|
sort: 0,
|
|
},
|
|
addGoodsForm:{
|
|
id:'',
|
|
shopId:'',
|
|
categoryId:'', //商品分类id
|
|
categoryName:'', //商品分类名称
|
|
productPicture:'', //商品图标
|
|
productName:'', //商品名称
|
|
lunchBox:0, //餐盒
|
|
startPayNum:'', //起售数量
|
|
attributeListPrice:[{ //商品规格
|
|
specPrice:"",
|
|
specNum:9999
|
|
}],
|
|
sellTime:0, //可售时间
|
|
isMoreBuy:0,
|
|
sellBeginTime:'', //可售时段自定义---开始时间
|
|
sellEndTime:'', //可售时段自定义---结束时间
|
|
attributeList:'',
|
|
productGroupBuyPrices:[],
|
|
attributeList1:new Map(), //商品属性
|
|
productIntro:"" //详细图文
|
|
},
|
|
formValidate: {
|
|
// 表单验证规则
|
|
productName: [{
|
|
required: true,
|
|
message: "请输入",
|
|
trigger: "blur"
|
|
}]
|
|
},
|
|
columns: [
|
|
// 表头
|
|
{
|
|
type: "selection",
|
|
width: 60,
|
|
align: "center",
|
|
},
|
|
{
|
|
type: "index",
|
|
width: 60,
|
|
align: "center",
|
|
},
|
|
{
|
|
title: "图片",
|
|
key: "productPicture",
|
|
minWidth: 60,
|
|
render: (h, params) => {
|
|
return h("img", {
|
|
attrs: {
|
|
src: params.row.productPicture,
|
|
},
|
|
style: {
|
|
cursor: "zoom-in",
|
|
width: "80px",
|
|
height: "60px",
|
|
margin: "10px 0",
|
|
"object-fit": "contain",
|
|
},
|
|
on: {
|
|
click: () => {
|
|
this.showPic(params.row);
|
|
},
|
|
},
|
|
});
|
|
},
|
|
},
|
|
{
|
|
title: "名称",
|
|
key: "productName",
|
|
minWidth: 60,
|
|
},
|
|
{
|
|
title: "起售数量",
|
|
key: "startPayNum",
|
|
width: 100,
|
|
},
|
|
// {
|
|
// title: "状态",
|
|
// key: "status",
|
|
// align: "center",
|
|
// width: 120,
|
|
// render: (h, params) => {
|
|
// let re = "";
|
|
// if (params.row.status == 0) {
|
|
// return h("div", [
|
|
// h("Badge", {
|
|
// props: {
|
|
// status: "success",
|
|
// text: "启用",
|
|
// },
|
|
// }),
|
|
// ]);
|
|
// } else if (params.row.status == -1) {
|
|
// return h("div", [
|
|
// h("Badge", {
|
|
// props: {
|
|
// status: "error",
|
|
// text: "禁用",
|
|
// },
|
|
// }),
|
|
// ]);
|
|
// }
|
|
// },
|
|
// },
|
|
{
|
|
title: "操作",
|
|
key: "action",
|
|
width: 350,
|
|
align: "center",
|
|
fixed: "right",
|
|
render: (h, params) => {
|
|
let enableOrdelFlag = "";
|
|
if(params.row.delFlag ==0){
|
|
enableOrdelFlag = h(
|
|
"a", {
|
|
on: {
|
|
click: () => {
|
|
this.upDown(params.row,1);
|
|
},
|
|
},
|
|
},
|
|
"上架"
|
|
);
|
|
}else{
|
|
enableOrdelFlag = h(
|
|
"a", {
|
|
on: {
|
|
click: () => {
|
|
this.upDown(params.row,0);
|
|
},
|
|
},
|
|
},
|
|
"下架"
|
|
);
|
|
}
|
|
let enableOrisPush = "";
|
|
if(params.row.isPush ==0){
|
|
enableOrisPush = h(
|
|
"a", {
|
|
on: {
|
|
click: () => {
|
|
this.isPush(params.row,1);
|
|
},
|
|
},
|
|
},
|
|
"设为推荐"
|
|
);
|
|
}else{
|
|
enableOrisPush = h(
|
|
"a", {
|
|
on: {
|
|
click: () => {
|
|
this.isPush(params.row,0);
|
|
},
|
|
},
|
|
},
|
|
"取消推荐"
|
|
);
|
|
}
|
|
let enableOrisMust = "";
|
|
if(params.row.isMust ==0){
|
|
enableOrisMust = h(
|
|
"a", {
|
|
on: {
|
|
click: () => {
|
|
this.isMust(params.row,1);
|
|
},
|
|
},
|
|
},
|
|
"设为必点"
|
|
);
|
|
}else{
|
|
enableOrisMust = h(
|
|
"a", {
|
|
on: {
|
|
click: () => {
|
|
this.isMust(params.row,0);
|
|
},
|
|
},
|
|
},
|
|
"取消必点"
|
|
);
|
|
}
|
|
return h("div", [
|
|
h(
|
|
"a", {
|
|
on: {
|
|
click: () => {
|
|
this.edit(params.row);
|
|
},
|
|
},
|
|
},
|
|
"编辑"
|
|
),
|
|
h("Divider", {
|
|
props: {
|
|
type: "vertical",
|
|
},
|
|
}),
|
|
enableOrdelFlag,
|
|
h("Divider", {
|
|
props: {
|
|
type: "vertical",
|
|
},
|
|
}),
|
|
|
|
enableOrisPush,
|
|
h("Divider", {
|
|
props: {
|
|
type: "vertical",
|
|
},
|
|
}),
|
|
|
|
enableOrisMust,
|
|
h("Divider", {
|
|
props: {
|
|
type: "vertical",
|
|
},
|
|
}),
|
|
h(
|
|
"a", {
|
|
on: {
|
|
click: () => {
|
|
this.remove(params.row);
|
|
},
|
|
},
|
|
},
|
|
"删除"
|
|
),
|
|
]);
|
|
},
|
|
},
|
|
],
|
|
submitLoading: false, // 添加或编辑提交状态
|
|
data: [], //表单数据
|
|
total: 0, // 表单数据总数
|
|
screenWidth: 0,
|
|
};
|
|
},
|
|
methods: {
|
|
init(v) {
|
|
this.shopId = v.id
|
|
this.searchForm.shopId = v.id
|
|
this.addGoodsForm.shopId = v.id
|
|
this.screenWidth = window.screen.width;
|
|
// 获取树数据
|
|
this.getGoodsType();
|
|
// 获取表单数据
|
|
// this.getDataList();
|
|
},
|
|
changePrice(index){
|
|
this.specValueArr[index].specPrice = this.addGoodsForm.attributeListPrice[index].specPrice
|
|
},
|
|
changeCount(index){
|
|
this.specValueArr[index].specNum = this.addGoodsForm.attributeListPrice[index].specNum
|
|
},
|
|
getGoodsType() {
|
|
this.treeLoading = true;
|
|
goodsType({
|
|
shopId: this.shopId
|
|
}).then((res) => {
|
|
this.treeLoading = false;
|
|
if (res.success) {
|
|
this.treeData = res.result;
|
|
let bidain ={
|
|
"id": "bidian",
|
|
"delFlag": 0,
|
|
"categoryName": '必点',
|
|
"shopId": this.shopId,
|
|
"count": 0,
|
|
"stockCount": 0,
|
|
"minusStockCount": null,
|
|
"sort": null,
|
|
"title": '必点',
|
|
"nodeKey": 0
|
|
}
|
|
let tuijian ={
|
|
"id": "tuijian",
|
|
"delFlag": 0,
|
|
"categoryName": '推荐',
|
|
"shopId": this.shopId,
|
|
"count": 0,
|
|
"stockCount": 0,
|
|
"minusStockCount": null,
|
|
"sort": null,
|
|
"title": '推荐',
|
|
"nodeKey": 0
|
|
}
|
|
for (let i = 0; i < this.treeData.length; i++) {
|
|
this.treeData[i].title = this.treeData[i].categoryName
|
|
}
|
|
this.treeData.unshift(bidain)
|
|
this.treeData.unshift(tuijian)
|
|
}
|
|
});
|
|
},
|
|
search() {
|
|
// 搜索树
|
|
if (this.searchKey) {
|
|
this.treeLoading = true;
|
|
searchDict({
|
|
key: this.searchKey
|
|
}).then((res) => {
|
|
this.treeLoading = false;
|
|
if (res.success) {
|
|
this.treeData = res.result;
|
|
}
|
|
});
|
|
} else {
|
|
// 为空重新加载
|
|
this.getGoodsType();
|
|
}
|
|
},
|
|
checkSpec(type){
|
|
this.modalclass = true;
|
|
this.modalclassType = type
|
|
if(type == 'shuxing'){
|
|
this.modalTitle = "选择属性";
|
|
}else{
|
|
this.modalTitle = "选择规格";
|
|
}
|
|
getAllDictDataList({
|
|
name: "",
|
|
status: "",
|
|
pageNumber: 1,
|
|
pageSize: 100000,
|
|
sort: 'sortOrder',
|
|
order: 'asc',
|
|
dictId: '2026945661353725952'
|
|
}).then((res) => {
|
|
if(res.code == 200){
|
|
this.categoryData = res.result.content
|
|
for (var i = 0; i < this.categoryData.length; i++) {
|
|
if (i == this.categoryIndex) {
|
|
this.categoryData[i].parentId = true
|
|
} else {
|
|
this.categoryData[i].parentId = false
|
|
}
|
|
}
|
|
//如果是选择属性,需要拿一个分类名,保存成parent
|
|
this.typeToAttrName = res.result.content[this.categoryIndex].title
|
|
this.getCateGorySon(res.result.content[this.categoryIndex].id)
|
|
}
|
|
});
|
|
},
|
|
deldantiaoguige(index){
|
|
for (var m = 0; m < this.specValueArr.length; m++) {
|
|
if(this.specValueArr[m].id == this.addGoodsForm.attributeListPrice[index].id){
|
|
this.specValueArr.splice(m,1)
|
|
this.addGoodsForm.attributeListPrice.splice(index,1)
|
|
console.log("11",this.addGoodsForm.attributeListPrice)
|
|
if(this.addGoodsForm.attributeListPrice.length == 1){
|
|
this.addGoodsForm.attributeListPrice = []
|
|
this.addGoodsForm.attributeListPrice.push({
|
|
specName:"",
|
|
specPrice:'',
|
|
specNum:9999
|
|
})
|
|
this.specValueArr = []
|
|
}
|
|
this.$forceUpdate()
|
|
return
|
|
}
|
|
}
|
|
},
|
|
delGroup(index){
|
|
this.addGoodsForm.productGroupBuyPrices.splice(index,1)
|
|
},
|
|
addGroup(){
|
|
let data = {
|
|
groupCount:'',
|
|
groupPrice:0
|
|
}
|
|
this.addGoodsForm.productGroupBuyPrices.push(data)
|
|
},
|
|
showPic(v) {
|
|
let image = new Image();
|
|
image.src = v.productPicture;
|
|
let viewer = new Viewer(image, {
|
|
hidden: function() {
|
|
viewer.destroy();
|
|
},
|
|
});
|
|
viewer.show();
|
|
},
|
|
getCateGorySon(id){
|
|
getAllDictDataList({
|
|
name: "",
|
|
status: "",
|
|
pageNumber: 1,
|
|
pageSize: 100000,
|
|
sort: 'sortOrder',
|
|
order: 'asc',
|
|
dictId: id
|
|
}).then((res) => {
|
|
if(res.code == 200){
|
|
this.categorySonData = res.result.content
|
|
console.log("this.modalclassType",this.modalclassType)
|
|
console.log("this.categorySonData",this.categorySonData)
|
|
if(this.modalclassType == 'shuxing'){
|
|
for (var i = 0; i < this.categorySonData.length; i++) {
|
|
if(this.attrValueArr.length>0){
|
|
let index1 = false
|
|
for (var m = 0; m < this.attrValueArr.length; m++) {
|
|
if(this.attrValueArr[m].title == this.categorySonData[i].title){
|
|
index1 = true
|
|
this.categorySonData[i].checked = true
|
|
}
|
|
}
|
|
if(index1){
|
|
this.categorySonData[i].checked = true
|
|
}
|
|
}else{
|
|
this.categorySonData[i].checked = false
|
|
}
|
|
}
|
|
}else{
|
|
//guige
|
|
|
|
|
|
for (var i = 0; i < this.categorySonData.length; i++) {
|
|
if(this.specValueArr.length>0){
|
|
for (var m = 0; m < this.specValueArr.length; m++) {
|
|
if(this.specValueArr[m].id == this.categorySonData[i].id){
|
|
this.categorySonData[i].checked = true
|
|
}
|
|
}
|
|
}else{
|
|
this.categorySonData[i].checked = false
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
});
|
|
},
|
|
//点击左侧菜单切换
|
|
clickLeftBtn(index) {
|
|
for (var i = 0; i < this.categoryData.length; i++) {
|
|
if (i == index) {
|
|
this.categoryData[i].parentId = true
|
|
} else {
|
|
this.categoryData[i].parentId = false
|
|
}
|
|
}
|
|
this.categoryIndex = index
|
|
this.typeToAttrName = this.categoryData[this.categoryIndex].title
|
|
this.getCateGorySon(this.categoryData[this.categoryIndex].id)
|
|
},
|
|
checkSellTime(type){
|
|
this.addGoodsForm.sellTime = type;
|
|
},
|
|
checkisMoreBuy(type){
|
|
this.addGoodsForm.isMoreBuy = type;
|
|
},
|
|
checkSpecValue(index){
|
|
//this.typeToAttrName = res.result.content[this.categoryIndex].title
|
|
console.log("this.categorySonData[index]",this.categorySonData[index])
|
|
console.log("this.modalclassType",this.modalclassType)
|
|
this.categorySonData[index].checked = !this.categorySonData[index].checked
|
|
if(this.modalclassType == 'shuxing'){
|
|
if(this.categorySonData[index].checked == true){
|
|
this.categorySonData[index].parentName = this.typeToAttrName
|
|
this.attrValueArr.push(this.categorySonData[index])
|
|
}else{
|
|
for(let i=0;i<this.attrValueArr.length;i++){
|
|
if(this.categorySonData[index].title == this.attrValueArr[i].title){
|
|
this.attrValueArr.splice(i,1)
|
|
}
|
|
}
|
|
}
|
|
}else{
|
|
//guige
|
|
if(this.categorySonData[index].checked == true){
|
|
this.specValueArr.push(this.categorySonData[index])
|
|
}else{
|
|
for(let i=0;i<this.specValueArr.length;i++){
|
|
if(this.categorySonData[index].id == this.specValueArr[i].id){
|
|
this.specValueArr.splice(i,1)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.$forceUpdate()
|
|
},
|
|
guigeSubmit(){
|
|
if(this.modalclassType == 'shuxing'){
|
|
console.log("this.addGoodsForm.attributeList1",this.addGoodsForm.attributeList1)
|
|
console.log("this.attrValueArr",this.attrValueArr)
|
|
for(let i=0;i<this.attrValueArr.length;i++){
|
|
if(this.addGoodsForm.attributeList1.size == 0){
|
|
//set has get
|
|
let data = {
|
|
title:[]
|
|
}
|
|
data.title.push(this.attrValueArr[i].title)
|
|
this.addGoodsForm.attributeList1.set(this.attrValueArr[i].parentName,data)
|
|
}else{
|
|
if(this.addGoodsForm.attributeList1.has(this.attrValueArr[i].parentName) && this.addGoodsForm.attributeList1.get(this.attrValueArr[i].parentName).title.indexOf(this.attrValueArr[i].title) == -1){
|
|
this.addGoodsForm.attributeList1.get(this.attrValueArr[i].parentName).title.push(this.attrValueArr[i].title)
|
|
}else{
|
|
let data = {
|
|
title:[]
|
|
}
|
|
data.title.push(this.attrValueArr[i].title)
|
|
this.addGoodsForm.attributeList1.set(this.attrValueArr[i].parentName,data)
|
|
}
|
|
}
|
|
}
|
|
}else{
|
|
//guige
|
|
let message = []
|
|
console.log("this.specValueArr",this.specValueArr)
|
|
for(let i=0;i<this.specValueArr.length;i++){
|
|
for(let m=0;m<this.addGoodsForm.attributeListPrice.length;m++){
|
|
if(this.specValueArr[i].id == this.addGoodsForm.attributeListPrice[m].id){
|
|
this.specValueArr[i].specPrice = this.addGoodsForm.attributeListPrice[m].specPrice
|
|
this.specValueArr[i].specName = this.addGoodsForm.attributeListPrice[m].specName
|
|
this.specValueArr[i].specNum = this.addGoodsForm.attributeListPrice[m].specNum
|
|
}
|
|
}
|
|
message.push({
|
|
id:this.specValueArr[i].id,
|
|
specName:this.specValueArr[i].specName == undefined ? this.specValueArr[i].title : this.specValueArr[i].specName,
|
|
specPrice:this.specValueArr[i].specPrice == undefined ? '' : this.specValueArr[i].specPrice,
|
|
specNum:this.specValueArr[i].specNum == undefined ? 9999 : this.specValueArr[i].specNum
|
|
})
|
|
}
|
|
this.addGoodsForm.attributeListPrice = message
|
|
}
|
|
|
|
this.modalclass = false;
|
|
},
|
|
selectTree(v) {
|
|
if (v.length > 0) {
|
|
// 转换null为""
|
|
for (let attr in v[0]) {
|
|
if (v[0][attr] == null) {
|
|
v[0][attr] = "";
|
|
}
|
|
}
|
|
let str = JSON.stringify(v[0]);
|
|
let data = JSON.parse(str);
|
|
this.selectNode = data;
|
|
this.dictForm = data;
|
|
this.editTitle = data.title;
|
|
// 重新加载表
|
|
this.searchForm.pageNum = 1;
|
|
this.searchForm.pageSize = 10;
|
|
this.getDataList();
|
|
} else {
|
|
this.cancelEdit();
|
|
}
|
|
},
|
|
cancelEdit() {
|
|
let data = this.$refs.tree.getSelectedNodes()[0];
|
|
if (data) {
|
|
data.selected = false;
|
|
}
|
|
// 取消选择后获取全部数据
|
|
this.selectNode = {};
|
|
this.editTitle = "";
|
|
// this.getDataList();
|
|
},
|
|
changeTableSize(v) {
|
|
this.tableSize = v;
|
|
},
|
|
exportData() {
|
|
this.$refs.table.exportCsv({
|
|
filename: "数据",
|
|
});
|
|
},
|
|
changeSelect(v) {
|
|
this.selectList = v;
|
|
},
|
|
changeExpand() {
|
|
this.expand = !this.expand;
|
|
if (this.expand) {
|
|
this.expandIcon = "ios-arrow-back";
|
|
this.span = 18;
|
|
} else {
|
|
this.expandIcon = "ios-arrow-forward";
|
|
this.span = 23;
|
|
}
|
|
},
|
|
changePage(v) {
|
|
this.searchForm.pageNum = v;
|
|
// this.getDataList();
|
|
this.clearSelectAll();
|
|
},
|
|
changePageSize(v) {
|
|
this.searchForm.pageSize = v;
|
|
// this.getDataList();
|
|
},
|
|
getDataList() {
|
|
this.loading = true;
|
|
// if (this.selectNode.id) {
|
|
this.searchForm.categoryId = this.selectNode.id;
|
|
// } else {
|
|
// delete this.searchForm.dictId;
|
|
// }
|
|
if (!this.searchForm.status) {
|
|
this.searchForm.status = "";
|
|
}
|
|
getShareList(this.searchForm).then((res) => {
|
|
this.loading = false;
|
|
if (res.success) {
|
|
this.data = res.result.records;
|
|
this.total = res.result.total;
|
|
if (this.data.length == 0 && this.searchForm.pageNum > 1) {
|
|
this.searchForm.pageNum -= 1;
|
|
this.getDataList();
|
|
}
|
|
}
|
|
});
|
|
},
|
|
handleSearch() {
|
|
this.searchForm.pageNum = 1;
|
|
this.searchForm.pageSize = 10;
|
|
this.getDataList();
|
|
},
|
|
handleReset() {
|
|
this.$refs.searchForm.resetFields();
|
|
this.searchForm.pageNum = 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();
|
|
},
|
|
showSelect(e) {
|
|
this.selectList = e;
|
|
},
|
|
clearSelectAll() {
|
|
this.$refs.table.selectAll(false);
|
|
},
|
|
refreshDict() {
|
|
this.getGoodsType();
|
|
this.selectNode = {};
|
|
this.editTitle = "";
|
|
// this.getDataList();
|
|
},
|
|
handleDropdown(name) {
|
|
if (name == "editDict") {
|
|
if (!this.selectNode.id) {
|
|
this.$Message.warning("您还未选择要编辑的分类");
|
|
return;
|
|
}
|
|
this.handleEditDict();
|
|
} else if (name == "delDict") {
|
|
this.delDict();
|
|
} else if (name == "refreshDict") {
|
|
this.refreshDict();
|
|
}
|
|
},
|
|
handleAddDict() {
|
|
this.dataLength = this.treeData.length + 1;
|
|
this.showAddDict = true;
|
|
this.$refs.addTypePage.init(this.shopId)
|
|
},
|
|
handleEditDict() {
|
|
this.showEditDict = true;
|
|
this.$refs.editTypePage.init(this.shopId)
|
|
},
|
|
editDictSuccess(v) {
|
|
for (let attr in v) {
|
|
if (v[attr] == null) {
|
|
v[attr] = "";
|
|
}
|
|
}
|
|
let str = JSON.stringify(v);
|
|
let data = JSON.parse(str);
|
|
this.dictForm = data;
|
|
this.editTitle = v.title + "(" + v.type + ")";
|
|
this.getGoodsType();
|
|
},
|
|
delDict() {
|
|
if (!this.selectNode.id) {
|
|
this.$Message.warning("您还未选择要删除的分类");
|
|
return;
|
|
}
|
|
this.$Modal.confirm({
|
|
title: "确认删除",
|
|
loading: true,
|
|
content: "您确认要删除分类 " + this.selectNode.title + " 及其所有数据?",
|
|
onOk: () => {
|
|
// 删除
|
|
deleteType({
|
|
id: this.selectNode.id,
|
|
shopId: this.shopId
|
|
}).then((res) => {
|
|
this.$Modal.remove();
|
|
if (res.success) {
|
|
this.$Message.success("操作成功");
|
|
this.refreshDict();
|
|
}
|
|
});
|
|
},
|
|
});
|
|
},
|
|
getChildren(v) {
|
|
this.Visiable = true;
|
|
this.$nextTick(() => {
|
|
this.$refs.dialog.initRecharge(v);
|
|
});
|
|
},
|
|
add() {
|
|
if (!this.selectNode.id) {
|
|
this.$Message.warning("请先选择一个分类");
|
|
return;
|
|
}
|
|
this.modalType = 0;
|
|
this.modalTitle = "添加分类 " + this.editTitle + " 的数据";
|
|
this.$refs.form.resetFields();
|
|
this.form.sort = this.data.length + 1;
|
|
this.addGoodsForm = {
|
|
id:'',
|
|
shopId:'',
|
|
categoryId:'', //商品分类id
|
|
categoryName:'', //商品分类名称
|
|
productPicture:'', //商品图标
|
|
productName:'', //商品名称
|
|
lunchBox:0, //餐盒
|
|
startPayNum:'', //起售数量
|
|
attributeListPrice:[{ //商品规格
|
|
specPrice:"",
|
|
specNum:9999
|
|
}],
|
|
sellTime:0, //可售时间
|
|
sellBeginTime:'', //可售时段自定义---开始时间
|
|
sellEndTime:'', //可售时段自定义---结束时间
|
|
attributeList:'',
|
|
productGroupBuyPrices:[],
|
|
attributeList1:new Map(), //商品属性
|
|
productIntro:"" //详细图文
|
|
}
|
|
this.specValueArr = []
|
|
this.attrValueArr = []
|
|
this.addGoodsForm.shopId = this.shopId
|
|
this.addGoodsForm.categoryId = this.selectNode.id
|
|
this.addGoodsForm.categoryName = this.selectNode.categoryName
|
|
this.modalVisible = true;
|
|
},
|
|
edit(v) {
|
|
this.modalType = 1;
|
|
if (this.editTitle) {
|
|
this.modalTitle = "编辑分类 " + this.editTitle + " 的数据";
|
|
} else {
|
|
this.modalTitle = "编辑分类数据";
|
|
}
|
|
// 转换null为""
|
|
for (let attr in v) {
|
|
if (v[attr] == null) {
|
|
v[attr] = "";
|
|
}
|
|
}
|
|
let str = JSON.stringify(v);
|
|
let data = JSON.parse(str);
|
|
console.log('111111',data)
|
|
this.addGoodsForm = data;
|
|
this.addGoodsForm.attributeList1 = JSON.parse(this.addGoodsForm.attributeList)
|
|
this.addGoodsForm.attributeList1 = new Map(Object.entries(this.addGoodsForm.attributeList1));
|
|
this.addGoodsForm.attributeListPrice = JSON.parse(this.addGoodsForm.attributeListPrice)
|
|
|
|
console.log("this.addGoodsForm.attributeList1",this.addGoodsForm.attributeList1)
|
|
console.log("this.addGoodsForm.attributeListPrice",this.addGoodsForm.attributeListPrice)
|
|
|
|
this.addGoodsForm.attributeList1.forEach((value, key) => {
|
|
for(let i = 0;i<value.title.length;i++){
|
|
this.attrValueArr.push({
|
|
parentName:key,
|
|
title:value.title[i]
|
|
})
|
|
}
|
|
});
|
|
this.specValueArr = this.addGoodsForm.attributeListPrice
|
|
|
|
|
|
this.addGoodsForm.sellTime = this.addGoodsForm.sellBeginTime != '' ? 1 : 0
|
|
this.modalVisible = true;
|
|
},
|
|
handelSubmit() {
|
|
this.$refs.form.validate((valid) => {
|
|
if (valid) {
|
|
|
|
|
|
this.submitLoading = true;
|
|
if (this.modalType == 0) {
|
|
// 添加 避免编辑后传入id等数据 记得删除
|
|
delete this.addGoodsForm.id;
|
|
if(this.addGoodsForm.isMoreBuy != 1){
|
|
this.addGoodsForm.isMoreBuy = 0
|
|
}
|
|
this.addGoodsForm.attributeListPrice = JSON.stringify(this.addGoodsForm.attributeListPrice)
|
|
this.addGoodsForm.attributeList = Object.fromEntries(this.addGoodsForm.attributeList1)
|
|
this.addGoodsForm.attributeList = JSON.stringify(this.addGoodsForm.attributeList)
|
|
productSave(this.addGoodsForm).then((res) => {
|
|
this.submitLoading = false;
|
|
if (res.success) {
|
|
this.$Message.success("操作成功");
|
|
this.getDataList();
|
|
this.modalVisible = false;
|
|
}
|
|
});
|
|
} else if (this.modalType == 1) {
|
|
// 编辑
|
|
this.addGoodsForm.attributeListPrice = JSON.stringify(this.addGoodsForm.attributeListPrice)
|
|
this.addGoodsForm.attributeList = Object.fromEntries(this.addGoodsForm.attributeList1)
|
|
this.addGoodsForm.attributeList = JSON.stringify(this.addGoodsForm.attributeList)
|
|
this.addGoodsForm.productPictures = []
|
|
productEdit(this.addGoodsForm).then((res) => {
|
|
this.submitLoading = false;
|
|
if (res.success) {
|
|
this.$Message.success("操作成功");
|
|
this.getDataList();
|
|
this.modalVisible = false;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
},
|
|
remove(v) {
|
|
this.$Modal.confirm({
|
|
title: "确认删除",
|
|
content: "您确认要删除 " + v.productName + " ?",
|
|
loading: true,
|
|
onOk: () => {
|
|
// 删除
|
|
productDelete({
|
|
id: v.id
|
|
}).then((res) => {
|
|
this.$Modal.remove();
|
|
if (res.success) {
|
|
this.clearSelectAll();
|
|
this.$Message.success("操作成功");
|
|
this.getDataList();
|
|
}
|
|
});
|
|
},
|
|
});
|
|
},
|
|
upDown(v,value) {
|
|
if(value == 0){
|
|
productDown({
|
|
id: v.id
|
|
}).then((res) => {
|
|
this.$Modal.remove();
|
|
if (res.success) {
|
|
this.clearSelectAll();
|
|
this.$Message.success("操作成功");
|
|
this.getDataList();
|
|
}
|
|
});
|
|
}else{
|
|
productUp({
|
|
id: v.id
|
|
}).then((res) => {
|
|
this.$Modal.remove();
|
|
if (res.success) {
|
|
this.clearSelectAll();
|
|
this.$Message.success("操作成功");
|
|
this.getDataList();
|
|
}
|
|
});
|
|
}
|
|
|
|
},
|
|
isPush(v,value) {
|
|
productisPush({
|
|
id: v.id,
|
|
isPush:value
|
|
}).then((res) => {
|
|
this.$Modal.remove();
|
|
if (res.success) {
|
|
this.clearSelectAll();
|
|
this.$Message.success("操作成功");
|
|
this.getDataList();
|
|
}
|
|
});
|
|
},
|
|
isMust(v,value) {
|
|
productisMust({
|
|
id: v.id,
|
|
isMust:value
|
|
}).then((res) => {
|
|
this.$Modal.remove();
|
|
if (res.success) {
|
|
this.clearSelectAll();
|
|
this.$Message.success("操作成功");
|
|
this.getDataList();
|
|
}
|
|
});
|
|
},
|
|
delAll() {
|
|
if (this.selectList.length <= 0) {
|
|
this.$Message.warning("您还未选择要删除的数据");
|
|
return;
|
|
}
|
|
this.$Modal.confirm({
|
|
title: "确认删除",
|
|
content: "您确认要删除所选的 " + this.selectList.length + " 条数据?",
|
|
loading: true,
|
|
onOk: () => {
|
|
let ids = "";
|
|
this.selectList.forEach(function(e) {
|
|
ids += e.id + ",";
|
|
});
|
|
ids = ids.substring(0, ids.length - 1);
|
|
// 批量删除
|
|
deleteData({
|
|
ids: ids
|
|
}).then((res) => {
|
|
this.$Modal.remove();
|
|
if (res.success) {
|
|
this.$Message.success("操作成功");
|
|
this.clearSelectAll();
|
|
// this.getDataList();
|
|
}
|
|
});
|
|
},
|
|
});
|
|
},
|
|
},
|
|
mounted() {
|
|
// 计算高度
|
|
let height = document.documentElement.clientHeight;
|
|
this.maxHeight = Number(height - 287) + "px";
|
|
this.init();
|
|
},
|
|
};
|
|
</script>
|