|
|
|
@ -1,6 +1,56 @@ |
|
|
|
<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"> |
|
|
|
@ -58,7 +108,7 @@ |
|
|
|
</Row> |
|
|
|
<Row align="middle" justify="space-between" class="operation"> |
|
|
|
<div> |
|
|
|
<Button @click="add" type="primary" icon="md-add">添加数据</Button> |
|
|
|
<Button @click="add" type="primary" icon="md-add">新增商品</Button> |
|
|
|
<Button @click="delAll" icon="md-trash">批量删除</Button> |
|
|
|
</div> |
|
|
|
<div class="icons"> |
|
|
|
@ -94,7 +144,7 @@ |
|
|
|
<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.pageNumber" :total="total" :page-size="searchForm.pageSize" |
|
|
|
<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> |
|
|
|
@ -102,68 +152,175 @@ |
|
|
|
</Row> |
|
|
|
</Card> |
|
|
|
|
|
|
|
<addType :dataLength="dataLength" v-model="showAddDict" @on-submit="getAllDict" /> |
|
|
|
<addType ref="addTypePage" :dataLength="dataLength" v-model="showAddDict" @on-submit="getGoodsType" /> |
|
|
|
|
|
|
|
<editDictType :data="dictForm" v-model="showEditDict" @on-submit="editDictSuccess" /> |
|
|
|
<editDictType ref="editTypePage" :data="dictForm" v-model="showEditDict" @on-submit="editDictSuccess" /> |
|
|
|
|
|
|
|
<Modal :title="modalTitle" v-model="modalVisible" :mask-closable="false" :width="500"> |
|
|
|
<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="form.title" /> |
|
|
|
<Input v-model="addGoodsForm.productName" /> |
|
|
|
</FormItem> |
|
|
|
</Col> |
|
|
|
<Col span="6"> |
|
|
|
<FormItem label="店铺分类" class="form-noheight"> |
|
|
|
<Input v-model="editTitle" disabled /> |
|
|
|
</FormItem> |
|
|
|
<FormItem label="数据值" prop="value"> |
|
|
|
<Input v-model="form.value" /> |
|
|
|
</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;" placeholder="商品价格" /> |
|
|
|
<Input v-model="item.specNum" style="padding-right: 10px;" 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> |
|
|
|
<FormItem label="备注" prop="description"> |
|
|
|
<Input v-model="form.description" /> |
|
|
|
</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> |
|
|
|
<FormItem label="排序值" prop="sortOrder"> |
|
|
|
<Tooltip trigger="hover" placement="right" content="值越小越靠前,支持小数"> |
|
|
|
<InputNumber :max="1000" :min="0" v-model="form.sortOrder"></InputNumber> |
|
|
|
</Tooltip> |
|
|
|
</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> |
|
|
|
<FormItem label="是否启用" prop="status"> |
|
|
|
<i-switch size="large" v-model="form.status" :true-value="0" :false-value="-1"> |
|
|
|
<span slot="open">启用</span> |
|
|
|
<span slot="close">禁用</span> |
|
|
|
</i-switch> |
|
|
|
</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 { |
|
|
|
goodsType, |
|
|
|
deleteDict, |
|
|
|
searchDict, |
|
|
|
getAllDictDataList, |
|
|
|
addDictData, |
|
|
|
editDictData, |
|
|
|
deleteData, |
|
|
|
} from "@/api/index"; |
|
|
|
import { |
|
|
|
goodsType, |
|
|
|
deleteType, |
|
|
|
categoryList, |
|
|
|
categorySonList, |
|
|
|
productSave, |
|
|
|
getShareList, |
|
|
|
productEdit |
|
|
|
} 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 |
|
|
|
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", |
|
|
|
@ -174,19 +331,30 @@ |
|
|
|
span: 18, |
|
|
|
expandIcon: "ios-arrow-back", |
|
|
|
selectNode: {}, |
|
|
|
categoryData:[], |
|
|
|
categorySonData:[], |
|
|
|
treeData: [], // 树数据 |
|
|
|
selectList: [], // 多选数据 |
|
|
|
searchForm: { |
|
|
|
// 搜索框对应data对象 |
|
|
|
name: "", |
|
|
|
status: "", |
|
|
|
pageNumber: 1, // 当前页数 |
|
|
|
pageSize: 10, // 页面大小 |
|
|
|
sort: "sortOrder", // 默认排序字段 |
|
|
|
order: "asc", // 默认排序方式 |
|
|
|
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: { |
|
|
|
// 添加或编辑表单对象初始化数据 |
|
|
|
@ -194,26 +362,36 @@ |
|
|
|
value: "", |
|
|
|
status: 0, |
|
|
|
description: "", |
|
|
|
sortOrder: 0, |
|
|
|
sort: 0, |
|
|
|
}, |
|
|
|
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:"" //详细图文 |
|
|
|
}, |
|
|
|
formValidate: { |
|
|
|
// 表单验证规则 |
|
|
|
title: [{ |
|
|
|
required: true, |
|
|
|
message: "请输入", |
|
|
|
trigger: "blur" |
|
|
|
}], |
|
|
|
value: [{ |
|
|
|
productName: [{ |
|
|
|
required: true, |
|
|
|
message: "请输入", |
|
|
|
trigger: "blur" |
|
|
|
}], |
|
|
|
sortOrder: [{ |
|
|
|
required: true, |
|
|
|
type: "number", |
|
|
|
message: "请输入排序值", |
|
|
|
trigger: "blur", |
|
|
|
}, ], |
|
|
|
}] |
|
|
|
}, |
|
|
|
columns: [ |
|
|
|
// 表头 |
|
|
|
@ -228,65 +406,67 @@ |
|
|
|
align: "center", |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: "名称", |
|
|
|
key: "title", |
|
|
|
minWidth: 160, |
|
|
|
sortable: true, |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: "数据值", |
|
|
|
key: "value", |
|
|
|
title: "图片", |
|
|
|
key: "productPicture", |
|
|
|
minWidth: 160, |
|
|
|
sortable: true, |
|
|
|
render: (h, params) => { |
|
|
|
return h("img", { |
|
|
|
attrs: { |
|
|
|
src: params.row.productPicture, |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: "备注", |
|
|
|
key: "description", |
|
|
|
width: 150, |
|
|
|
sortable: true, |
|
|
|
style: { |
|
|
|
cursor: "zoom-in", |
|
|
|
width: "80px", |
|
|
|
height: "60px", |
|
|
|
margin: "10px 0", |
|
|
|
"object-fit": "contain", |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: "排序值", |
|
|
|
key: "sortOrder", |
|
|
|
width: 100, |
|
|
|
align: "center", |
|
|
|
sortable: true, |
|
|
|
sortType: "asc", |
|
|
|
on: { |
|
|
|
click: () => { |
|
|
|
this.showPic(params.row); |
|
|
|
}, |
|
|
|
{ |
|
|
|
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: "productName", |
|
|
|
minWidth: 160, |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: "创建时间", |
|
|
|
key: "createTime", |
|
|
|
width: 200, |
|
|
|
sortable: true, |
|
|
|
title: "起售数量", |
|
|
|
key: "startPayNum", |
|
|
|
width: 150, |
|
|
|
}, |
|
|
|
// { |
|
|
|
// 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", |
|
|
|
@ -327,18 +507,25 @@ |
|
|
|
submitLoading: false, // 添加或编辑提交状态 |
|
|
|
data: [], //表单数据 |
|
|
|
total: 0, // 表单数据总数 |
|
|
|
screenWidth: 0, |
|
|
|
}; |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
init() { |
|
|
|
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(); |
|
|
|
// this.getDataList(); |
|
|
|
}, |
|
|
|
getGoodsType() { |
|
|
|
this.treeLoading = true; |
|
|
|
goodsType().then((res) => { |
|
|
|
goodsType({ |
|
|
|
shopId: this.shopId |
|
|
|
}).then((res) => { |
|
|
|
this.treeLoading = false; |
|
|
|
if (res.success) { |
|
|
|
this.treeData = res.result; |
|
|
|
@ -362,9 +549,213 @@ |
|
|
|
}); |
|
|
|
} else { |
|
|
|
// 为空重新加载 |
|
|
|
this.getAllDict(); |
|
|
|
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].title == this.addGoodsForm.attributeListPrice[index].specName){ |
|
|
|
this.specValueArr.splice(m,1) |
|
|
|
this.addGoodsForm.attributeListPrice.splice(index,1) |
|
|
|
if(this.addGoodsForm.attributeListPrice.length == 1){ |
|
|
|
this.addGoodsForm.attributeListPrice = { |
|
|
|
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 |
|
|
|
|
|
|
|
if(this.modalclassType == 'shuxing'){ |
|
|
|
console.log('属性',this.attrValueArr) |
|
|
|
if(this.attrValueArr == ""){ |
|
|
|
this.attrValueArr = this.addGoodsForm.attributeListPrice |
|
|
|
} |
|
|
|
for (var i = 0; i < this.categorySonData.length; i++) { |
|
|
|
if(this.attrValueArr.length>0){ |
|
|
|
for (var m = 0; m < this.attrValueArr.length; m++) { |
|
|
|
if(this.attrValueArr[m].id == this.categorySonData[i].id){ |
|
|
|
this.categorySonData[i].checked = true |
|
|
|
}else{ |
|
|
|
this.categorySonData[i].checked = false |
|
|
|
} |
|
|
|
} |
|
|
|
}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; |
|
|
|
}, |
|
|
|
checkSpecValue(index){ |
|
|
|
//this.typeToAttrName = res.result.content[this.categoryIndex].title |
|
|
|
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].id == this.attrValueArr[i].id){ |
|
|
|
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'){ |
|
|
|
|
|
|
|
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.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 |
|
|
|
this.addGoodsForm.attributeListPrice = [] |
|
|
|
for(let i=0;i<this.specValueArr.length;i++){ |
|
|
|
this.addGoodsForm.attributeListPrice.push({ |
|
|
|
specName:this.specValueArr[i].title, |
|
|
|
specPrice:'', |
|
|
|
specNum:9999 |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this.modalclass = false; |
|
|
|
}, |
|
|
|
selectTree(v) { |
|
|
|
if (v.length > 0) { |
|
|
|
// 转换null为"" |
|
|
|
@ -377,9 +768,9 @@ |
|
|
|
let data = JSON.parse(str); |
|
|
|
this.selectNode = data; |
|
|
|
this.dictForm = data; |
|
|
|
this.editTitle = data.title + "(" + data.type + ")"; |
|
|
|
this.editTitle = data.title; |
|
|
|
// 重新加载表 |
|
|
|
this.searchForm.pageNumber = 1; |
|
|
|
this.searchForm.pageNum = 1; |
|
|
|
this.searchForm.pageSize = 10; |
|
|
|
this.getDataList(); |
|
|
|
} else { |
|
|
|
@ -394,7 +785,7 @@ |
|
|
|
// 取消选择后获取全部数据 |
|
|
|
this.selectNode = {}; |
|
|
|
this.editTitle = ""; |
|
|
|
this.getDataList(); |
|
|
|
// this.getDataList(); |
|
|
|
}, |
|
|
|
changeTableSize(v) { |
|
|
|
this.tableSize = v; |
|
|
|
@ -418,47 +809,47 @@ |
|
|
|
} |
|
|
|
}, |
|
|
|
changePage(v) { |
|
|
|
this.searchForm.pageNumber = v; |
|
|
|
this.getDataList(); |
|
|
|
this.searchForm.pageNum = v; |
|
|
|
// this.getDataList(); |
|
|
|
this.clearSelectAll(); |
|
|
|
}, |
|
|
|
changePageSize(v) { |
|
|
|
this.searchForm.pageSize = v; |
|
|
|
this.getDataList(); |
|
|
|
// this.getDataList(); |
|
|
|
}, |
|
|
|
getDataList() { |
|
|
|
this.loading = true; |
|
|
|
if (this.selectNode.id) { |
|
|
|
this.searchForm.dictId = this.selectNode.id; |
|
|
|
} else { |
|
|
|
delete this.searchForm.dictId; |
|
|
|
} |
|
|
|
// if (this.selectNode.id) { |
|
|
|
this.searchForm.categoryId = this.selectNode.id; |
|
|
|
// } else { |
|
|
|
// delete this.searchForm.dictId; |
|
|
|
// } |
|
|
|
if (!this.searchForm.status) { |
|
|
|
this.searchForm.status = ""; |
|
|
|
} |
|
|
|
getAllDictDataList(this.searchForm).then((res) => { |
|
|
|
getShareList(this.searchForm).then((res) => { |
|
|
|
this.loading = false; |
|
|
|
if (res.success) { |
|
|
|
this.data = res.result.content; |
|
|
|
this.total = res.result.totalElements; |
|
|
|
if (this.data.length == 0 && this.searchForm.pageNumber > 1) { |
|
|
|
this.searchForm.pageNumber -= 1; |
|
|
|
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.pageNumber = 1; |
|
|
|
this.searchForm.pageNum = 1; |
|
|
|
this.searchForm.pageSize = 10; |
|
|
|
this.getDataList(); |
|
|
|
// this.getDataList(); |
|
|
|
}, |
|
|
|
handleReset() { |
|
|
|
this.$refs.searchForm.resetFields(); |
|
|
|
this.searchForm.pageNumber = 1; |
|
|
|
this.searchForm.pageNum = 1; |
|
|
|
this.searchForm.pageSize = 10; |
|
|
|
// 重新加载数据 |
|
|
|
this.getDataList(); |
|
|
|
// this.getDataList(); |
|
|
|
}, |
|
|
|
changeSort(e) { |
|
|
|
this.searchForm.sort = e.key; |
|
|
|
@ -466,7 +857,7 @@ |
|
|
|
if (e.order == "normal") { |
|
|
|
this.searchForm.order = ""; |
|
|
|
} |
|
|
|
this.getDataList(); |
|
|
|
// this.getDataList(); |
|
|
|
}, |
|
|
|
showSelect(e) { |
|
|
|
this.selectList = e; |
|
|
|
@ -475,15 +866,15 @@ |
|
|
|
this.$refs.table.selectAll(false); |
|
|
|
}, |
|
|
|
refreshDict() { |
|
|
|
this.getAllDict(); |
|
|
|
this.getGoodsType(); |
|
|
|
this.selectNode = {}; |
|
|
|
this.editTitle = ""; |
|
|
|
this.getDataList(); |
|
|
|
// this.getDataList(); |
|
|
|
}, |
|
|
|
handleDropdown(name) { |
|
|
|
if (name == "editDict") { |
|
|
|
if (!this.selectNode.id) { |
|
|
|
this.$Message.warning("您还未选择要编辑的字典"); |
|
|
|
this.$Message.warning("您还未选择要编辑的分类"); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.handleEditDict(); |
|
|
|
@ -496,9 +887,11 @@ |
|
|
|
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) { |
|
|
|
@ -510,21 +903,22 @@ |
|
|
|
let data = JSON.parse(str); |
|
|
|
this.dictForm = data; |
|
|
|
this.editTitle = v.title + "(" + v.type + ")"; |
|
|
|
this.getAllDict(); |
|
|
|
this.getGoodsType(); |
|
|
|
}, |
|
|
|
delDict() { |
|
|
|
if (!this.selectNode.id) { |
|
|
|
this.$Message.warning("您还未选择要删除的字典"); |
|
|
|
this.$Message.warning("您还未选择要删除的分类"); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.$Modal.confirm({ |
|
|
|
title: "确认删除", |
|
|
|
loading: true, |
|
|
|
content: "您确认要删除字典 " + this.selectNode.title + " 及其所有数据?", |
|
|
|
content: "您确认要删除分类 " + this.selectNode.title + " 及其所有数据?", |
|
|
|
onOk: () => { |
|
|
|
// 删除 |
|
|
|
deleteDict({ |
|
|
|
ids: this.selectNode.id |
|
|
|
deleteType({ |
|
|
|
id: this.selectNode.id, |
|
|
|
shopId: this.shopId |
|
|
|
}).then((res) => { |
|
|
|
this.$Modal.remove(); |
|
|
|
if (res.success) { |
|
|
|
@ -537,30 +931,30 @@ |
|
|
|
}, |
|
|
|
getChildren(v) { |
|
|
|
this.Visiable = true; |
|
|
|
console.log(v) |
|
|
|
this.$nextTick(() => { |
|
|
|
this.$refs.dialog.initRecharge(v); |
|
|
|
}); |
|
|
|
}, |
|
|
|
add() { |
|
|
|
if (!this.selectNode.id) { |
|
|
|
this.$Message.warning("请先选择一个字典类别"); |
|
|
|
this.$Message.warning("请先选择一个分类"); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.modalType = 0; |
|
|
|
this.modalTitle = "添加字典 " + this.editTitle + " 的数据"; |
|
|
|
this.modalTitle = "添加分类 " + this.editTitle + " 的数据"; |
|
|
|
this.$refs.form.resetFields(); |
|
|
|
this.form.sortOrder = this.data.length + 1; |
|
|
|
this.form.sort = this.data.length + 1; |
|
|
|
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 + " 的数据"; |
|
|
|
this.modalTitle = "编辑分类 " + this.editTitle + " 的数据"; |
|
|
|
} else { |
|
|
|
this.modalTitle = "编辑字典数据"; |
|
|
|
this.modalTitle = "编辑分类数据"; |
|
|
|
} |
|
|
|
this.$refs.form.resetFields(); |
|
|
|
// 转换null为"" |
|
|
|
for (let attr in v) { |
|
|
|
if (v[attr] == null) { |
|
|
|
@ -569,32 +963,44 @@ |
|
|
|
} |
|
|
|
let str = JSON.stringify(v); |
|
|
|
let data = JSON.parse(str); |
|
|
|
this.form = data; |
|
|
|
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) |
|
|
|
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.form.id; |
|
|
|
this.form.dictId = this.selectNode.id; |
|
|
|
addDictData(this.form).then((res) => { |
|
|
|
delete this.addGoodsForm.id; |
|
|
|
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) { |
|
|
|
// 编辑 |
|
|
|
editDictData(this.form).then((res) => { |
|
|
|
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.getDataList(); |
|
|
|
this.modalVisible = false; |
|
|
|
} |
|
|
|
}); |
|
|
|
@ -616,7 +1022,7 @@ |
|
|
|
if (res.success) { |
|
|
|
this.clearSelectAll(); |
|
|
|
this.$Message.success("操作成功"); |
|
|
|
this.getDataList(); |
|
|
|
// this.getDataList(); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
@ -645,7 +1051,7 @@ |
|
|
|
if (res.success) { |
|
|
|
this.$Message.success("操作成功"); |
|
|
|
this.clearSelectAll(); |
|
|
|
this.getDataList(); |
|
|
|
// this.getDataList(); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
|