提交 2ef7a507 authored 作者: 王天霸's avatar 王天霸

1111

上级 8673829e
......@@ -4,8 +4,8 @@ ENV = 'development'
# 正式环境
#VUE_APP_BASE_API = 'http://sjapi.jxhh.com'
# 开发环境
VUE_APP_BASE_API = 'http://192.168.111.34:8200'
#VUE_APP_BASE_API = 'http://192.168.26.179:8200'
#VUE_APP_BASE_API = 'http://192.168.111.34:8200'
VUE_APP_BASE_API = 'http://192.168.26.179:8200'
# 路由懒加载
VUE_CLI_BABEL_TRANSPILE_MODULES = true
import request from '@/utils/request'
// 查询商品列表(上架,下架)
export function getlistGoods(query) {
return request({
url: '/system/goodsNew/list',
method: 'get',
params: query
})
}
//上架商品
export function shelvesStatus(data) {
return request({
url: '/system/goodsNew/shelvesStatus',
method: 'post',
data: data
})
}
// 查询类别
export function GetCategory(query) {
return request({
url: '/system/goods/getCategory',
method: 'get',
params: query
})
}
// 查询运费模板
export function GetFreight(query) {
return request({
url: '/system/goods/getFreight',
method: 'get',
params: query
})
}
// 查询goods详细
export function getGoods (id) {
return request({
url: '/system/goods/edit?goodsId='+id,
method: 'get'
})
}
// 新增goods
export function addGoods(data) {
return request({
url: '/system/goods/add',
method: 'post',
data: data
})
}
// 修改goods
export function updateGoods(data) {
return request({
url: '/system/goods/edit',
method: 'post',
data: data
})
}
// 删除goods
export function delGoods(ids) {
return request({
url: '/system/goods/delete',
method: 'delete',
data:{ids:ids}
})
}
//上传图片
export function UploadImg(data) {
return request({
url: '/system/goods/uploadImg',
method: 'post',
data: data
})
}
......@@ -183,10 +183,30 @@ export const constantRoutes = [
path: 'fields',
component: (resolve) => require(['@/views/system/model/info/list/fields'], resolve),
name: 'modelFields',
meta: { title: '模型字段列表' }
meta: { title: '商品管理' }
}
]
},
{
path: '/goodsimport',
component: Layout,
meta: { title: '模型字段列表' },
hidden: false,
children: [
{
path: 'import',
component: (resolve) => require(['@/views/system/goodsimport/index'], resolve),
name: 'modelFields',
meta: { title: '商品导入' }
},
{
path: 'management',
component: (resolve) => require(['@/views/system/goodsimport/goodsgement.vue'], resolve),
name: 'goodsgement',
meta: { title: '商品管理' }
}
]
}
/* 正式上线需要 注释 */
// {
// path: '/brand',
......
<template>
<div class="app-container">
<el-card class="box-card">
<div slot="header" class="clearfix">
<el-radio-group v-model="radiomodel" class="radiomodels" @change="radiomodelbtn">
<el-radio-button label="1">上架销售中({{onsale_count}}</el-radio-button>
<el-radio-button label="2">仓库中的商品({{downsale_count}}</el-radio-button>
<el-radio-button label="3">审核记录</el-radio-button>
<el-radio-button label="4">最近删除({{del_count}}</el-radio-button>
</el-radio-group>
</div>
<el-form :inline="true" class="queryFormInline" :model="formInline" >
<el-row :span="24" type="flex" align="middle" justify="space-between">
<el-col :span="20">
<el-form-item label="商品编号">
<el-input v-model="formInline.goods_id" size="mini" placeholder="填写商品编号"></el-input>
</el-form-item>
<el-form-item label="商品名称">
<el-input v-model="formInline.goods_name" size="mini" placeholder="填写商品编号"></el-input>
</el-form-item>
<el-form-item label="商品状态" v-show="radiomodel==3">
<el-select v-model="formInline.status" placeholder="请选择" size="mini" style='width:100px;'>
<el-option label="全部" value="5" v-if='radiomodel==3'></el-option>
<el-option label="审核中" value="1" v-if='radiomodel==3'></el-option>
<el-option label="审核拒绝" value="2" v-if='radiomodel==3'></el-option>
</el-select>
</el-form-item>
<el-form-item label="发布时间">
<el-date-picker
style='width:315px;'
v-model="formInline.uptime"
type="daterange"
range-separator="至"
size="mini"
format="yyyy 年 MM 月 dd 日"
value-format="timestamp"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
<el-form-item label="价格区间">
<el-input v-model="formInline.price_min" size="mini" placeholder="最小价格" style="width:100px;"></el-input>
-
<el-input v-model="formInline.price_max" size="mini" placeholder="最大价格" style="width:100px;"></el-input>
</el-form-item>
<el-form-item >
<el-button
type="primary"
icon="el-icon-delete"
size="mini"
@click="handleQuery"
>查询
</el-button>
</el-form-item>
</el-col>
<el-col :span="4">
<div style="float: right">
<el-button
style="float:right;margin-left: 10px;"
type="danger"
size="mini"
:disabled="multiple"
@click="handleDelete"
>批量删除
</el-button>
<el-button
v-if='radiomodel==1'
style="float:right;margin-left: 20px;"
type="primary"
:disabled="multiple"
size="mini"
@click="handleUpsale('9','down','all')"
>批量下架
</el-button>
<el-button
v-if='radiomodel==2'
style="float:right;margin-left: 20px;"
type="primary"
:disabled="multiple"
size="mini"
@click="handleUpsale('9','up','all')"
>批量上架
</el-button>
<el-button
v-if='radiomodel==4'
style="float:right;margin-left: 20px;"
type="primary"
size="mini"
@click="handleAdd"
>批量还原
</el-button>
</div>
</el-col>
</el-row>
</el-form>
<el-table v-loading="loading" :data="freightList" :height="tableHeight" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center"/>
<el-table-column label="商品主图" width="95" align="center">
<template slot-scope="scope">
<img :src="scope.row.default_image" alt="" style="width:80px;height:80px;">
</template>
</el-table-column>
<el-table-column label="商品编号" align="center" prop="goods_id"/>
<el-table-column label="商品名称" align="center" prop="goods_brand"/>
<el-table-column label="协议价" align="center" prop="">
<template slot-scope="scope">
{{scope.row.js_price/100}}
</template>
</el-table-column>
<!-- <el-table-column label="类型" align="center" :formatter="formatType" prop="ChargeType"/> -->
<el-table-column label="库存量" align="center" prop="stock"/>
<el-table-column label="商品状态" align="center" prop>
<template slot-scope="scope">
<span v-if="radiomodel==1||radiomodel==2">
{{scope.row.is_onsale===0?'下架':'上架'}}
</span>
<span v-if="radiomodel==3">
{{scope.row.up_onsale===1?'审核中':'审核拒绝'}}
</span>
<span v-if="radiomodel==4">
{{scope.row.is_on===0?'已删除':'彻底删除'}}
</span>
</template>
</el-table-column>
<el-table-column label="发布时间" align="center" :formatter="formatTime" prop="add_time"/>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope" >
<div v-if='radiomodel==3&&scope.row.up_onsale===1'>
<!-- <el-button
size="mini"
type="text"
@click="handleUpdate(scope.row)"
>取消上架申请
</el-button> -->
<el-button
size="mini"
type="text"
disabled="true"
>审核中
</el-button>
</div>
<div v-else>
<el-button
v-if="radiomodel==1"
size="mini"
type="text"
@click="handleUpsale(scope.row,'down','one')"
>下架
</el-button>
<el-button
v-if="radiomodel==2"
size="mini"
type="text"
@click="handleUpsale(scope.row,'up','one')"
>上架
</el-button>
<el-button
v-if="radiomodel==4"
size="mini"
type="text"
@click="handleUpdate(scope.row)"
>还原
</el-button>
<el-divider direction="vertical" v-if="radiomodel!=3"></el-divider>
<el-button
v-if="radiomodel!=4"
size="mini"
type="text"
@click="editgoods(scope.row)"
>编辑
</el-button>
<el-divider direction="vertical" v-if="radiomodel!=4"></el-divider>
<el-button
size="mini"
type="text"
@click="lookdetail(scope.row)"
>预览
</el-button>
<el-divider direction="vertical"></el-divider>
<el-button
v-if="radiomodel!=4"
size="mini"
type="text"
@click="handleDelete(scope.row)"
>删除
</el-button>
<el-button
v-if="radiomodel==4"
size="mini"
type="text"
@click="handleDelete(scope.row)"
>彻底删除
</el-button>
</div>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="formInline.page"
:limit.sync="formInline.limit"
@pagination="getList"
/>
<!-- 商品编辑-->
<el-dialog title="编辑商品" :visible.sync="editisOpen" v-if="editisOpen" width="70%" class="freightTemplate-add">
<editGood :option="form" @closeIndexbtn="closeDialog" ></editGood>
</el-dialog>
<el-dialog title="商品详情" :visible.sync="isOpen" v-if="isOpen" width="70%" class="freightTemplate-add">
<goodDetail :option="form" @closeIndexbtn="closeDialog" ></goodDetail>
</el-dialog>
</el-card>
</div>
</template>
<script>
import goodDetail from './components/goodsdetail'
import editGood from '@/views/system/goods/add/index'
import {getlistGoods, shelvesStatus, delFreight, addFreight, updateFreight} from '@/api/module/goodsgement'
import {dateFormat} from '@/utils'
export default {
name: "freight",
data() {
return {
editisOpen: false,//编辑
downsale_count:'',//仓库数量
onsale_count:'',//上架数量
del_count:'',//删除数量
radiomodel:'1',
formInline: {
page: 1,
limit: 20,
goods_name: '',
goods_id: '',
status:'5',
uptime:'',
price_min:'',
price_max:''
},
fullHeight: 0,
tableHeight: 0,
// 遮罩层
loading: false,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// freight表格数据
freightList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
isOpen: false,
// 查询参数
queryParams: {
page: 1,
limit: 20,
seller_id: null,
name: null,
sort: null,
is_default: null,
charge_type: null,
dispatching: null,
disdispatching: null,
publish: null,
created: null,
modified: null,
},
// 表单参数
form: {},
// 表单校验
rules: {
name: [
{required: true, message: "模板名称不能为空", trigger: "blur"}
],
}
};
},
components: {
goodDetail,
editGood
},
created() {
this.getList();
this.$nextTick(() => {
let headerHeight = document.getElementsByClassName('queryFormInline')[0].clientHeight
this.fullHeight = document.getElementsByClassName('box-card')[0].clientHeight - headerHeight
})
},
watch: {
fullHeight(val) {
let headerHeight = document.getElementsByClassName('queryFormInline')[0].clientHeight
let formHeight = document.getElementsByClassName('clearfix')[0].clientHeight
this.tableHeight = val - formHeight - 40 - headerHeight
}
},
methods: {
handleUpsale(row,status,isall){ //上下架
debugger
let good_id,is_onsale,title,message
if(isall=='one'){
good_id = [row.goods_id]
if(status=='up'){ // 0 下架 1上架
is_onsale = 1
title ="商品上架"
message = "是否上架该商品"
}
if(status=='down'){
is_onsale = 0
title ="商品下架"
message = "是否下架该商品!"
}
}else if(isall=='all'){
good_id = this.ids
if(status=='up'){
is_onsale = 1
title ="商品批量上架"
message = "是否上架选中的商品!"
}
if(status=='down'){
is_onsale = 0
title ="商品批量下架"
message = "是否下架选中的商品!"
}
}
let data={
'goods_id':good_id,
'is_onsale':is_onsale
}
this.$msgbox({
title: title,
message: message,
center:true,
showCancelButton: true,
confirmButtonText: '确定',
cancelButtonText: '取消',
beforeClose: (action, instance, done) => {
if (action === 'confirm') {
shelvesStatus(data).then(res=>{
if(res.code==1){
done()
this.getList()
}
})
} else {
done();
}
}
}).then(action => {
this.$message({
type: 'success',
message: '操作成功!'
});
});
},
editgoods(){//商品编辑
this.editisOpen = true
},
lookdetail(){//预览商品详情
this.isOpen = true
},
radiomodelbtn(val){ //头部切换
console.log(val)
this.formInline= {
page: 1,
limit: 20,
goods_name: '',
goods_id: '',
status:'5',
uptime:'',
price_min:'',
price_max:''
}
this.getList()
},
closeDialog(val) {
this.isOpen = val;
this.getList();
},
//格式化状态
formatDefault(row) {
var types = row.IsDefault
var optDes = ''
if (types == 1) {
optDes = "是"
} else if (types == 0) {
optDes = "否"
}
return optDes
},
//格式化时间
formatTime(row) {
var Time = row.add_time
var newtime = ""
if (Time > 0) {
newtime = dateFormat(Time * 1000, "Y-m-d H:i:s");
}
return newtime
},
/** 查询freight列表 */
getList() {
// formInline: {
// page: 1,
// limit: 20,
// goods_name: '',
// goods_id: '',
// status:'',
// uptime:''
// price_min:'',
// price_max:''
// },
let data = {
page: this.formInline.page,
limit: this.formInline.limit,
}
if(this.radiomodel==='1'){
data['is_onsale'] = 1
}
if(this.radiomodel==2){
data['is_onsale'] = 0
}
if(this.radiomodel==3){
data['up_onsale'] = Number(this.formInline.status)
}
if(this.radiomodel==4){
data['is_on'] = 0
}
if(this.formInline.goods_name){
data['goods_name'] = this.formInline.goods_name
}
if(this.formInline.goods_id){
data['goods_id'] = this.formInline.goods_id
}
if(this.formInline.uptime&&this.formInline.uptime.length==2){
data['start_time'] = this.formInline.uptime[0]/1000
data['end_time'] = this.formInline.uptime[1]/1000
}
if(this.formInline.price_min &&this.formInline.price_max){
data['price_min'] = this.formInline.price_min
data['price_max'] = this.formInline.price_max
}
getlistGoods(data).then(res => {
if(res.data) {
this.freightList = res.data.list;
this.total = res.data.count;
this.downsale_count = res.data.downsale_count//仓库数量
this.onsale_count = res.data.onsale_count//上架数量
this.del_count = res.data.del_count//删除数量
}
});
},
// 取消按钮
cancel() {
this.isOpen = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
seller_id: null,
name: null,
sort: null,
is_default: null,
charge_type: null,
dispatching: null,
disdispatching: null,
publish: null,
created: null,
modified: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.formInline.page = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.Id)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
if(this.total >= 50) {
this.$message({ message: '您已经有50个运费模板了,暂时不再支持更多!',type: 'warning'});
return;
}
this.reset();
this.isOpen = true;
this.form = {
Id: 0,
Sort: 0,
Name: "0",
IsDefault: 0,
ChargeType: 0,
Dispatching: [
{
a: "全国",
f: 500,
fp: 10,
n: 100,
np: 5,
}
],
Disdispatching: "",
Publish: 0,
};
this.title = "添加运费模板";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.isOpen = true;
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
debugger
if (valid) {
if (this.form.id != null) {
updateFreight(this.form).then(response => {
if (response.code === 0) {
this.msgSuccess("修改成功");
this.isOpen = false;
this.getList();
}
});
} else {
addFreight(this.form).then(response => {
if (response.code === 0) {
this.msgSuccess("新增成功");
this.isOpen = false;
this.getList();
}
});
}
}
});
},
/*
* publish 启用禁用状态 1是启用,0 禁用
* */
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.Id || this.ids;
debugger
this.$confirm('是否确认删除运费模板编号为“' + ids + '"的数据?','警告',{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async()=> {
this.loading = true;
let delResult = await delFreight(ids);
if(delResult.code === 1) {
this.$message({type: 'success',message: delResult.msg});
this.getList();
}
if(delResult.code === 0) {
this.$message({type: 'error',message: delResult.msg});
}
this.loading = false;
}).catch(()=> {});
},
} //methods结束
};
</script>
<style scoped lang="scss" type="text/stylus">
.freightTemplate-add {
/deep/.el-dialog {
height: 80%;
overflow : hidden;
}
/deep/.el-dialog__body{
height: calc(100% - 60px);
overflow-x: hidden;
overflow-y: scroll;
}
}
.radiomodels .el-radio-button{
margin:0 10px;
}
/deep/ .radiomodels .el-radio-button .el-radio-button__inner{
border: 1px solid #DCDFE6 !important;
border-radius: 4px !important;
}
/deep/ .radiomodels .el-radio-button .el-radio-button__orig-radio:checked+.el-radio-button__inner{
box-shadow: none;
}
.queryFormInline{
padding-bottom:20px;
}
</style>
<template>
</template>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论