Browse Source

新增编辑商品

master
tianyi 1 month ago
parent
commit
4bb685b6c7
  1. 41
      src/api/app.js
  2. 237
      src/views/app/shop/addType.vue
  3. 706
      src/views/app/shop/dictManage.vue
  4. 247
      src/views/app/shop/editDictType.vue
  5. 6
      src/views/app/shop/shop.vue
  6. 2096
      src/views/sys/oss-manage/ossManage.vue

41
src/api/app.js

@ -46,6 +46,45 @@ export const deleteCompany = (params) => {
return postRequest('/app/company/delByIds', params) return postRequest('/app/company/delByIds', params)
} }
// 新增分类接口
export const addType = (params) => {
return postBodyRequest('/app/productCategory/batchSaveCategoryAndAttribute', params)
}
//编辑分类
export const editType = (params) => {
return postRequest('/app/productCategory/edit', params)
}
//子分类列表
export const categoryList = (params) => {
return postRequest('/app/productAttribute/selectByCategoryId', params)
}
//子分类规格值列表
export const categorySonList = (params) => {
return getRequest('/app/productAttributeValue/selectByAttributeId', params)
}
//新增商品
export const productSave = (params) => {
return postBodyRequest('/app/product/save', params)
}
//编辑商品
export const productEdit = (params) => {
return postBodyRequest('/app/product/edit', params)
}
//商品列表
export const getShareList = (params) => {
return postBodyRequest('/app/product/getShareList', params)
}
//删除分类
export const deleteType = (params) => {
return postRequest('/app/productCategory/delById', params)
}
export const getCompanyData = (params) => { export const getCompanyData = (params) => {
return getRequest('/app/company/getByCondition', params) return getRequest('/app/company/getByCondition', params)
} }
@ -150,7 +189,7 @@ export const addLogisticsRoute = (params) => {
//获取商品分类 //获取商品分类
export const goodsType = (params) => { export const goodsType = (params) => {
return postBodyRequest('/app/productCategory/list', params) return getRequest('/app/productCategory/list', params)
} }
//编辑线路 //编辑线路

237
src/views/app/shop/addType.vue

@ -1,142 +1,109 @@
<template> <template>
<div> <div>
<Modal <Modal title="添加字典" v-model="visible" :mask-closable="false" :width="500">
title="添加字典" <Form ref="form" :model="form" :label-width="85" :rules="formValidate">
v-model="visible" <FormItem label="分类名称" prop="title">
:mask-closable="false" <Input v-model="form.categoryName" />
:width="500" </FormItem>
> <FormItem label="排序值" prop="sortOrder">
<Form <Tooltip trigger="hover" placement="right" content="值越小越靠前,支持小数">
ref="form" <InputNumber :max="1000" :min="0" v-model="form.sort"></InputNumber>
:model="form" </Tooltip>
:label-width="85" </FormItem>
:rules="formValidate" </Form>
> <div slot="footer">
<FormItem label="字典名称" prop="title"> <Button type="text" @click="visible = false">取消</Button>
<Input v-model="form.title" /> <Button type="primary" :loading="submitLoading" @click="submit">提交</Button>
</FormItem> </div>
<FormItem label="字典类型" prop="type" class="block-tool"> </Modal>
<Tooltip </div>
placement="right"
:max-width="220"
transfer
content="建议设置为英文名且需唯一 非开发人员谨慎修改"
>
<Input v-model="form.type" />
</Tooltip>
</FormItem>
<FormItem label="备注" prop="description">
<Input v-model="form.description" />
</FormItem>
<FormItem label="排序值" prop="sortOrder">
<Tooltip
trigger="hover"
placement="right"
content="值越小越靠前,支持小数"
>
<InputNumber
:max="1000"
:min="0"
v-model="form.sortOrder"
></InputNumber>
</Tooltip>
</FormItem>
</Form>
<div slot="footer">
<Button type="text" @click="visible = false">取消</Button>
<Button
type="primary"
:loading="submitLoading"
@click="submit"
>提交</Button
>
</div>
</Modal>
</div>
</template> </template>
<script> <script>
import { addDict } from "@/api/index"; import {
export default { addType
name: "addDictType", } from "@/api/app";
components: {}, export default {
props: { name: "addDictType",
value: { components: {},
type: Boolean, props: {
default: false, value: {
}, type: Boolean,
dataLength: { default: false,
type: Number },
}, dataLength: {
}, type: Number
data() { },
return { },
visible: this.value, data() {
submitLoading: false, return {
form: { visible: this.value,
title: "", submitLoading: false,
type: "", form: {
description: "", categoryName: "",
sortOrder: 0, sort: 0,
}, shopId: ''
formValidate: { },
// formValidate: {
title: [{ required: true, message: "请输入", trigger: "blur" }], //
type: [{ required: true, message: "请输入", trigger: "blur" }], categoryName: [{
sortOrder: [ required: true,
{ message: "请输入",
required: true, trigger: "blur"
type: "number", }],
message: "请输入排序值", sort: [{
trigger: "blur", required: true,
}, type: "number",
], message: "请输入排序值",
}, trigger: "blur",
}; }, ],
}, },
methods: { };
init() {}, },
submit() { methods: {
this.$refs.form.validate((valid) => { init(v) {
if (valid) { this.form.shopId = v
// },
this.submitLoading = true; submit() {
addDict(this.form).then((res) => { this.$refs.form.validate((valid) => {
this.submitLoading = false; if (valid) {
if (res.success) { //
this.$Message.success("操作成功"); this.submitLoading = true;
this.$emit("on-submit", true); addType(this.form).then((res) => {
this.visible = false; this.submitLoading = false;
} if (res.success) {
}); this.$Message.success("操作成功");
} this.$emit("on-submit", true);
}); this.visible = false;
}, }
setCurrentValue(value) { });
if (value === this.visible) { }
return; });
} },
// setCurrentValue(value) {
this.$refs.form.resetFields(); if (value === this.visible) {
this.form.sortOrder = this.dataLength; return;
this.visible = value; }
}, //
}, this.$refs.form.resetFields();
watch: { this.form.sort = this.dataLength;
value(val) { this.visible = value;
this.setCurrentValue(val); },
}, },
visible(value) { watch: {
this.$emit("input", value); value(val) {
}, this.setCurrentValue(val);
}, },
mounted() { visible(value) {
this.init(); this.$emit("input", value);
}, },
}; },
mounted() {
this.init();
},
};
</script> </script>
<style lang="less"> <style lang="less">
@import "@/styles/drawer-common.less"; @import "@/styles/drawer-common.less";
</style> </style>

706
src/views/app/shop/dictManage.vue

@ -1,6 +1,56 @@
<style lang="less"> <style lang="less">
@import "@/styles/tree&table-common.less"; @import "@/styles/tree&table-common.less";
@import "./dictManage.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> </style>
<template> <template>
<div class="search"> <div class="search">
@ -58,7 +108,7 @@
</Row> </Row>
<Row align="middle" justify="space-between" class="operation"> <Row align="middle" justify="space-between" class="operation">
<div> <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> <Button @click="delAll" icon="md-trash">批量删除</Button>
</div> </div>
<div class="icons"> <div class="icons">
@ -94,7 +144,7 @@
<Table :loading="loading" border :columns="columns" :data="data" :size="tableSize" sortable="custom" <Table :loading="loading" border :columns="columns" :data="data" :size="tableSize" sortable="custom"
@on-sort-change="changeSort" @on-selection-change="showSelect" ref="table"></Table> @on-sort-change="changeSort" @on-selection-change="showSelect" ref="table"></Table>
<Row type="flex" justify="end" class="page"> <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]" @on-change="changePage" @on-page-size-change="changePageSize" :page-size-opts="[10, 20, 50]"
size="small" show-total show-elevator show-sizer></Page> size="small" show-total show-elevator show-sizer></Page>
</Row> </Row>
@ -102,68 +152,175 @@
</Row> </Row>
</Card> </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"> <Form ref="form" :model="form" :label-width="80" :rules="formValidate">
<FormItem label="名称" prop="title"> <Col span="6">
<Input v-model="form.title" /> <FormItem label="商品图标" class="form-noheight">
</FormItem> <upload-pic-input v-model="addGoodsForm.productPicture"></upload-pic-input>
<FormItem label="数据值" prop="value"> </FormItem>
<Input v-model="form.value" /> </Col>
</FormItem> <Col span="6">
<FormItem label="备注" prop="description"> <FormItem label="名称" prop="title">
<Input v-model="form.description" /> <Input v-model="addGoodsForm.productName" />
</FormItem> </FormItem>
<FormItem label="排序值" prop="sortOrder"> </Col>
<Tooltip trigger="hover" placement="right" content="值越小越靠前,支持小数"> <Col span="6">
<InputNumber :max="1000" :min="0" v-model="form.sortOrder"></InputNumber> <FormItem label="店铺分类" class="form-noheight">
</Tooltip> <Input v-model="editTitle" disabled />
</FormItem> </FormItem>
<FormItem label="是否启用" prop="status"> </Col>
<i-switch size="large" v-model="form.status" :true-value="0" :false-value="-1"> <Col span="6">
<span slot="open">启用</span> <FormItem label="商品规格" class="form-noheight">
<span slot="close">禁用</span> <div>
</i-switch> <div v-for="(item,index) in addGoodsForm.attributeListPrice" style="display: flex;margin-top:5px;">
</FormItem> <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>
</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 style="width:500px;height:400px;">
<editor v-model="addGoodsForm.productIntro" height="250"></editor>
</div>
</FormItem>
</Col>
</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="handelSubmit">提交</Button> <Button type="primary" :loading="submitLoading" @click="handelSubmit">提交</Button>
</div> </div>
</Modal> </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> </div>
</template> </template>
<script> <script>
import { import {
goodsType,
deleteDict,
searchDict, searchDict,
getAllDictDataList, getAllDictDataList,
addDictData, addDictData,
editDictData, editDictData,
deleteData, deleteData,
} from "@/api/index"; } from "@/api/index";
import {
goodsType,
deleteType,
categoryList,
categorySonList,
productSave,
getShareList,
productEdit
} from "@/api/app";
import addType from "./addType.vue"; import addType from "./addType.vue";
import editDictType from "./editDictType.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 { export default {
name: "dic-manage", name: "dic-manage",
components: { components: {
addType, addType,
editDictType editDictType,
uploadPicInput,
dict,
editor
}, },
data() { data() {
return { return {
Visiable: false, Visiable: false,
specValueArr:[],
attrValueArr:[],
modalclassType:'',
shopId: '',
tableSize: "default", tableSize: "default",
dataLength: 0, dataLength: 0,
showAddDict: false, showAddDict: false,
dictForm: {}, dictForm: {},
showEditDict: false, showEditDict: false,
openSearch: true, openSearch: true,
categoryIndex: 0,
openTip: true, openTip: true,
treeLoading: false, // treeLoading: false, //
maxHeight: "500px", maxHeight: "500px",
@ -174,19 +331,30 @@
span: 18, span: 18,
expandIcon: "ios-arrow-back", expandIcon: "ios-arrow-back",
selectNode: {}, selectNode: {},
categoryData:[],
categorySonData:[],
treeData: [], // treeData: [], //
selectList: [], // selectList: [], //
searchForm: { searchForm: {
// data // data
name: "", categoryId: "",
status: "", shopId:'',
pageNumber: 1, // order: "",
pageSize: 10, // pageNum: 1,
sort: "sortOrder", // pageSize: "10",
order: "asc", // searchStr: "",
sort: ""
// name: "",
// status: "",
// pageSize: 10, //
// sort: "sort", //
// order: "asc", //
}, },
modalType: 0, // modalType: 0, //
modalVisible: false, // modalVisible: false, //
modalclass:false,
modalTitle: "", // modalTitle: "", //
form: { form: {
// //
@ -194,26 +362,36 @@
value: "", value: "",
status: 0, status: 0,
description: "", 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: { formValidate: {
// //
title: [{ productName: [{
required: true,
message: "请输入",
trigger: "blur"
}],
value: [{
required: true, required: true,
message: "请输入", message: "请输入",
trigger: "blur" trigger: "blur"
}], }]
sortOrder: [{
required: true,
type: "number",
message: "请输入排序值",
trigger: "blur",
}, ],
}, },
columns: [ columns: [
// //
@ -228,65 +406,67 @@
align: "center", align: "center",
}, },
{ {
title: "名称", title: "图片",
key: "title", key: "productPicture",
minWidth: 160, minWidth: 160,
sortable: true, 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: "数据值", title: "名称",
key: "value", key: "productName",
minWidth: 160, minWidth: 160,
sortable: true,
}, },
{ {
title: "备注", title: "起售数量",
key: "description", key: "startPayNum",
width: 150, width: 150,
sortable: true,
},
{
title: "排序值",
key: "sortOrder",
width: 100,
align: "center",
sortable: true,
sortType: "asc",
},
{
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: "createTime",
width: 200,
sortable: true,
}, },
// {
// 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: "操作", title: "操作",
key: "action", key: "action",
@ -327,22 +507,29 @@
submitLoading: false, // submitLoading: false, //
data: [], // data: [], //
total: 0, // total: 0, //
screenWidth: 0,
}; };
}, },
methods: { 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.getGoodsType();
// //
this.getDataList(); // this.getDataList();
}, },
getGoodsType() { getGoodsType() {
this.treeLoading = true; this.treeLoading = true;
goodsType().then((res) => { goodsType({
shopId: this.shopId
}).then((res) => {
this.treeLoading = false; this.treeLoading = false;
if (res.success) { if (res.success) {
this.treeData = res.result; this.treeData = res.result;
for(let i=0;i<this.treeData.length;i++){ for (let i = 0; i < this.treeData.length; i++) {
this.treeData[i].title = this.treeData[i].categoryName this.treeData[i].title = this.treeData[i].categoryName
} }
} }
@ -362,8 +549,212 @@
}); });
} else { } 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) { selectTree(v) {
if (v.length > 0) { if (v.length > 0) {
@ -377,9 +768,9 @@
let data = JSON.parse(str); let data = JSON.parse(str);
this.selectNode = data; this.selectNode = data;
this.dictForm = 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.searchForm.pageSize = 10;
this.getDataList(); this.getDataList();
} else { } else {
@ -394,7 +785,7 @@
// //
this.selectNode = {}; this.selectNode = {};
this.editTitle = ""; this.editTitle = "";
this.getDataList(); // this.getDataList();
}, },
changeTableSize(v) { changeTableSize(v) {
this.tableSize = v; this.tableSize = v;
@ -418,47 +809,47 @@
} }
}, },
changePage(v) { changePage(v) {
this.searchForm.pageNumber = v; this.searchForm.pageNum = v;
this.getDataList(); // this.getDataList();
this.clearSelectAll(); this.clearSelectAll();
}, },
changePageSize(v) { changePageSize(v) {
this.searchForm.pageSize = v; this.searchForm.pageSize = v;
this.getDataList(); // this.getDataList();
}, },
getDataList() { getDataList() {
this.loading = true; this.loading = true;
if (this.selectNode.id) { // if (this.selectNode.id) {
this.searchForm.dictId = this.selectNode.id; this.searchForm.categoryId = this.selectNode.id;
} else { // } else {
delete this.searchForm.dictId; // delete this.searchForm.dictId;
} // }
if (!this.searchForm.status) { if (!this.searchForm.status) {
this.searchForm.status = ""; this.searchForm.status = "";
} }
getAllDictDataList(this.searchForm).then((res) => { getShareList(this.searchForm).then((res) => {
this.loading = false; this.loading = false;
if (res.success) { if (res.success) {
this.data = res.result.content; this.data = res.result.records;
this.total = res.result.totalElements; this.total = res.result.total;
if (this.data.length == 0 && this.searchForm.pageNumber > 1) { if (this.data.length == 0 && this.searchForm.pageNum > 1) {
this.searchForm.pageNumber -= 1; this.searchForm.pageNum -= 1;
this.getDataList(); this.getDataList();
} }
} }
}); });
}, },
handleSearch() { handleSearch() {
this.searchForm.pageNumber = 1; this.searchForm.pageNum = 1;
this.searchForm.pageSize = 10; this.searchForm.pageSize = 10;
this.getDataList(); // this.getDataList();
}, },
handleReset() { handleReset() {
this.$refs.searchForm.resetFields(); this.$refs.searchForm.resetFields();
this.searchForm.pageNumber = 1; this.searchForm.pageNum = 1;
this.searchForm.pageSize = 10; this.searchForm.pageSize = 10;
// //
this.getDataList(); // this.getDataList();
}, },
changeSort(e) { changeSort(e) {
this.searchForm.sort = e.key; this.searchForm.sort = e.key;
@ -466,7 +857,7 @@
if (e.order == "normal") { if (e.order == "normal") {
this.searchForm.order = ""; this.searchForm.order = "";
} }
this.getDataList(); // this.getDataList();
}, },
showSelect(e) { showSelect(e) {
this.selectList = e; this.selectList = e;
@ -475,15 +866,15 @@
this.$refs.table.selectAll(false); this.$refs.table.selectAll(false);
}, },
refreshDict() { refreshDict() {
this.getAllDict(); this.getGoodsType();
this.selectNode = {}; this.selectNode = {};
this.editTitle = ""; this.editTitle = "";
this.getDataList(); // this.getDataList();
}, },
handleDropdown(name) { handleDropdown(name) {
if (name == "editDict") { if (name == "editDict") {
if (!this.selectNode.id) { if (!this.selectNode.id) {
this.$Message.warning("您还未选择要编辑的字典"); this.$Message.warning("您还未选择要编辑的分类");
return; return;
} }
this.handleEditDict(); this.handleEditDict();
@ -496,9 +887,11 @@
handleAddDict() { handleAddDict() {
this.dataLength = this.treeData.length + 1; this.dataLength = this.treeData.length + 1;
this.showAddDict = true; this.showAddDict = true;
this.$refs.addTypePage.init(this.shopId)
}, },
handleEditDict() { handleEditDict() {
this.showEditDict = true; this.showEditDict = true;
this.$refs.editTypePage.init(this.shopId)
}, },
editDictSuccess(v) { editDictSuccess(v) {
for (let attr in v) { for (let attr in v) {
@ -510,21 +903,22 @@
let data = JSON.parse(str); let data = JSON.parse(str);
this.dictForm = data; this.dictForm = data;
this.editTitle = v.title + "(" + v.type + ")"; this.editTitle = v.title + "(" + v.type + ")";
this.getAllDict(); this.getGoodsType();
}, },
delDict() { delDict() {
if (!this.selectNode.id) { if (!this.selectNode.id) {
this.$Message.warning("您还未选择要删除的字典"); this.$Message.warning("您还未选择要删除的分类");
return; return;
} }
this.$Modal.confirm({ this.$Modal.confirm({
title: "确认删除", title: "确认删除",
loading: true, loading: true,
content: "您确认要删除字典 " + this.selectNode.title + " 及其所有数据?", content: "您确认要删除分类 " + this.selectNode.title + " 及其所有数据?",
onOk: () => { onOk: () => {
// //
deleteDict({ deleteType({
ids: this.selectNode.id id: this.selectNode.id,
shopId: this.shopId
}).then((res) => { }).then((res) => {
this.$Modal.remove(); this.$Modal.remove();
if (res.success) { if (res.success) {
@ -535,32 +929,32 @@
}, },
}); });
}, },
getChildren(v){ getChildren(v) {
this.Visiable = true; this.Visiable = true;
console.log(v)
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.dialog.initRecharge(v); this.$refs.dialog.initRecharge(v);
}); });
}, },
add() { add() {
if (!this.selectNode.id) { if (!this.selectNode.id) {
this.$Message.warning("请先选择一个字典类别"); this.$Message.warning("请先选择一个分类");
return; return;
} }
this.modalType = 0; this.modalType = 0;
this.modalTitle = "添加字典 " + this.editTitle + " 的数据"; this.modalTitle = "添加分类 " + this.editTitle + " 的数据";
this.$refs.form.resetFields(); 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; this.modalVisible = true;
}, },
edit(v) { edit(v) {
this.modalType = 1; this.modalType = 1;
if (this.editTitle) { if (this.editTitle) {
this.modalTitle = "编辑字典 " + this.editTitle + " 的数据"; this.modalTitle = "编辑分类 " + this.editTitle + " 的数据";
} else { } else {
this.modalTitle = "编辑字典数据"; this.modalTitle = "编辑分类数据";
} }
this.$refs.form.resetFields();
// null"" // null""
for (let attr in v) { for (let attr in v) {
if (v[attr] == null) { if (v[attr] == null) {
@ -569,32 +963,44 @@
} }
let str = JSON.stringify(v); let str = JSON.stringify(v);
let data = JSON.parse(str); 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; this.modalVisible = true;
}, },
handelSubmit() { handelSubmit() {
this.$refs.form.validate((valid) => { this.$refs.form.validate((valid) => {
if (valid) { if (valid) {
this.submitLoading = true; this.submitLoading = true;
if (this.modalType == 0) { if (this.modalType == 0) {
// id // id
delete this.form.id; delete this.addGoodsForm.id;
this.form.dictId = this.selectNode.id; this.addGoodsForm.attributeListPrice = JSON.stringify(this.addGoodsForm.attributeListPrice)
addDictData(this.form).then((res) => { this.addGoodsForm.attributeList = Object.fromEntries(this.addGoodsForm.attributeList1)
this.addGoodsForm.attributeList = JSON.stringify(this.addGoodsForm.attributeList)
productSave(this.addGoodsForm).then((res) => {
this.submitLoading = false; this.submitLoading = false;
if (res.success) { if (res.success) {
this.$Message.success("操作成功"); this.$Message.success("操作成功");
this.getDataList();
this.modalVisible = false; this.modalVisible = false;
} }
}); });
} else if (this.modalType == 1) { } 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; this.submitLoading = false;
if (res.success) { if (res.success) {
this.$Message.success("操作成功"); this.$Message.success("操作成功");
this.getDataList(); // this.getDataList();
this.modalVisible = false; this.modalVisible = false;
} }
}); });
@ -616,7 +1022,7 @@
if (res.success) { if (res.success) {
this.clearSelectAll(); this.clearSelectAll();
this.$Message.success("操作成功"); this.$Message.success("操作成功");
this.getDataList(); // this.getDataList();
} }
}); });
}, },
@ -645,7 +1051,7 @@
if (res.success) { if (res.success) {
this.$Message.success("操作成功"); this.$Message.success("操作成功");
this.clearSelectAll(); this.clearSelectAll();
this.getDataList(); // this.getDataList();
} }
}); });
}, },

247
src/views/app/shop/editDictType.vue

@ -1,143 +1,118 @@
<template> <template>
<div> <div>
<Modal <Modal title="编辑分类" v-model="visible" :mask-closable="false" :width="500">
title="编辑字典" <Form ref="form" :model="form" :label-width="85" :rules="formValidate">
v-model="visible" <FormItem label="分类名称" prop="title">
:mask-closable="false" <Input v-model="form.categoryName" />
:width="500" </FormItem>
> <FormItem label="排序值" prop="sort">
<Form ref="form" :model="form" :label-width="85" :rules="formValidate"> <Tooltip trigger="hover" placement="right" content="值越小越靠前,支持小数">
<FormItem label="字典名称" prop="title"> <InputNumber :max="1000" :min="0" v-model="form.sort"></InputNumber>
<Input v-model="form.title" /> </Tooltip>
</FormItem> </FormItem>
<FormItem label="字典类型" prop="type" class="block-tool"> </Form>
<Tooltip <div slot="footer">
placement="right" <Button type="text" @click="visible = false">取消</Button>
:max-width="220" <Button type="primary" :loading="submitLoading" @click="submit">提交</Button>
transfer </div>
content="建议设置为英文名且需唯一 非开发人员谨慎修改" </Modal>
> </div>
<Input v-model="form.type" />
</Tooltip>
</FormItem>
<FormItem label="备注" prop="description">
<Input v-model="form.description" />
</FormItem>
<FormItem label="排序值" prop="sortOrder">
<Tooltip
trigger="hover"
placement="right"
content="值越小越靠前,支持小数"
>
<InputNumber
:max="1000"
:min="0"
v-model="form.sortOrder"
></InputNumber>
</Tooltip>
</FormItem>
</Form>
<div slot="footer">
<Button type="text" @click="visible = false">取消</Button>
<Button type="primary" :loading="submitLoading" @click="submit"
>提交</Button
>
</div>
</Modal>
</div>
</template> </template>
<script> <script>
import { editDict } from "@/api/index"; import {
export default { editType
name: "addDictType", } from "@/api/app";
components: {}, export default {
props: { name: "addDictType",
value: { components: {},
type: Boolean, props: {
default: false, value: {
}, type: Boolean,
data: { default: false,
type: Object, },
}, data: {
}, type: Object,
data() { },
return { },
visible: this.value, data() {
submitLoading: false, return {
form: { shopId:'',
title: "", visible: this.value,
type: "", submitLoading: false,
description: "", form: {
sortOrder: 0, categoryName: "",
}, sort: "",
formValidate: { shopId:''
// },
title: [{ required: true, message: "请输入", trigger: "blur" }], formValidate: {
type: [{ required: true, message: "请输入", trigger: "blur" }], //
sortOrder: [ categoryName: [{
{ required: true,
required: true, message: "请输入",
type: "number", trigger: "blur"
message: "请输入排序值", }],
trigger: "blur", sort: [{
}, required: true,
], message: "请输入排序值",
}, trigger: "blur",
}; }, ],
}, },
methods: { };
init() {}, },
submit() { methods: {
this.$refs.form.validate((valid) => { init(v) {
if (valid) { this.form.shopId = v
// },
this.submitLoading = true; submit() {
editDict(this.form).then((res) => { this.$refs.form.validate((valid) => {
this.submitLoading = false; if (valid) {
if (res.success) { //
this.$Message.success("操作成功"); this.submitLoading = true;
this.$emit("on-submit", this.form); editType(this.form).then((res) => {
this.visible = false; this.submitLoading = false;
} if (res.success) {
}); this.$Message.success("操作成功");
} this.$emit("on-submit", this.form);
}); this.visible = false;
}, }
setCurrentValue(value) { });
if (value === this.visible) { }
return; });
} },
// setCurrentValue(value) {
this.$refs.form.resetFields(); if (value === this.visible) {
// null"" return;
let v = this.data; }
for (let attr in v) { //
if (v[attr] == null) { this.$refs.form.resetFields();
v[attr] = ""; // null""
} let v = this.data;
} for (let attr in v) {
let str = JSON.stringify(v); if (v[attr] == null) {
let data = JSON.parse(str); v[attr] = "";
this.form = data; }
this.visible = value; }
}, let str = JSON.stringify(v);
}, let data = JSON.parse(str);
watch: { this.form = data;
value(val) { this.visible = value;
this.setCurrentValue(val); },
}, },
visible(value) { watch: {
this.$emit("input", value); value(val) {
}, this.setCurrentValue(val);
}, },
mounted() { visible(value) {
this.init(); this.$emit("input", value);
}, },
}; },
mounted() {
this.init();
},
};
</script> </script>
<style lang="less"> <style lang="less">
@import "@/styles/drawer-common.less"; @import "@/styles/drawer-common.less";
</style> </style>

6
src/views/app/shop/shop.vue

@ -675,9 +675,9 @@
}, },
goodsList(v){ goodsList(v){
this.Visiable = true; this.Visiable = true;
// this.$nextTick(() => { this.$nextTick(() => {
// this.$refs.dialog.initRecharge(v); this.$refs.goodsPage.init(v);
// }); });
}, },
edit(v) { edit(v) {
// null"" // null""

2096
src/views/sys/oss-manage/ossManage.vue

File diff suppressed because it is too large
Loading…
Cancel
Save