商品添加导出、时间筛选

This commit is contained in:
DESKTOP-8FGKA8Q\chunfen 2024-10-30 16:25:58 +08:00
parent c95efcdc15
commit 74b42969b7
4 changed files with 224 additions and 153 deletions

View File

@ -10,6 +10,20 @@
<span>商品编码</span>
<el-input v-model="searchForm.external_sku_id" clearable></el-input>
</div>
<div class="row">
<span>创建时间</span>
<el-date-picker
v-model="filterTime"
type="datetimerange"
range-separator="至"
start-placeholder="开始时间"
end-placeholder="结束时间"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
clearable
style="width: 250px;">
</el-date-picker>
</div>
<div class="row">
<el-button type="primary" @click="handleChoose(1)" icon="el-icon-search">筛选</el-button>
</div>
@ -21,9 +35,10 @@
<el-upload ref="myUpload" action="/api/combination/goods" :multiple="false" name="combinationGoods"
:show-file-list="false" :on-success="uploadSuccess" :before-upload="beforeUpload"
:on-error="uploadError" style="display:inline-block;margin: 0 15px 0 0;">
<el-button type="warning" icon="el-icon-upload2">组合商品导入</el-button>
<el-button type="primary" plain icon="el-icon-upload2">组合商品导入</el-button>
</el-upload>
<el-button type="primary" plain @click="addGoodsCombination" icon="el-icon-plus" v-if="is_admin">新增组合商品</el-button>
<el-button type="primary" @click="addGoodsCombination" icon="el-icon-plus" v-if="is_admin">新增组合商品</el-button>
<el-button type="warning" @click="handleExport" icon="el-icon-download">数据导出</el-button>
</div>
<el-table v-loading="loading" ref="multipleTable" :data="tableData" class="table" tooltip-effect="dark" border
@ -36,7 +51,7 @@
<div>
<p>{{ scope.row.title }}</p>
<p>{{ scope.row.external_sku_id }}</p>
<p>{{ scope.row.updated_at }}</p>
<p>{{ scope.row.created_at }}</p>
</div>
</template>
</el-table-column>
@ -149,7 +164,8 @@
},
skus: [],
is_admin: false,
remoteLoading: false
remoteLoading: false,
filterTime: []
}
},
methods: {
@ -180,7 +196,9 @@
this.searchForm = {
...this.searchForm,
page: this.current_page,
per_page: this.per_page
per_page: this.per_page,
create_time_start: this.filterTime ? this.filterTime[0] : '',
create_time_end: this.filterTime ? this.filterTime[1] : ''
}
this.getList(this.searchForm)
},
@ -265,6 +283,21 @@
type: "error"
});
this.loadingModule.close()
},
handleExport() {
let params = {
exportType: 'goods_combination',
external_sku_id: this.searchForm.external_sku_id,
sku_title: this.searchForm.sku_title,
create_time_start: this.filterTime ? this.filterTime[0] : '',
create_time_end: this.filterTime ? this.filterTime[1] : ''
}
window.open("/goods_skus/export?" + this.objectToQueryString(params))
},
objectToQueryString(obj) {
return Object.keys(obj)
.map(key => encodeURIComponent(key) + '=' + (obj[key] ? encodeURIComponent(obj[key]) : ''))
.join('&');
}
},
mounted() {

View File

@ -38,6 +38,20 @@
</el-option>
</el-select>
</div>
<div class="row">
<span>创建时间</span>
<el-date-picker
v-model="filterTime"
type="datetimerange"
range-separator="至"
start-placeholder="开始时间"
end-placeholder="结束时间"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
clearable
style="width: 250px;">
</el-date-picker>
</div>
<!-- <div class="row">
<el-select v-model="form.keyword_type" style="width: 80px;margin-right: 5px;">
<el-option v-for="item in options3" :key="item.value" :label="item.label" :value="item.value">
@ -76,8 +90,9 @@
</el-upload> -->
<el-button type="primary" @click="petchEditStock" icon="el-icon-edit" :disabled="!chooseList.length">批量更新在售库存</el-button>
<el-button type="primary" v-if="is_admin" @click="addNewgoods" icon="el-icon-plus">新增商品</el-button>
<el-button type="primary" v-if="is_admin" plain @click="handleImport" icon="el-icon-upload2">在售库存导入</el-button>
<el-button type="warning" @click="handleExport" icon="el-icon-download">表格导出</el-button>
<el-button type="primary" plain v-if="is_admin" @click="handleImport" icon="el-icon-upload2">在售库存导入</el-button>
<el-button type="warning" @click="handleTypeExport" icon="el-icon-download">选择类型导出</el-button>
<el-button type="warning" @click="handleExport" icon="el-icon-download">数据导出</el-button>
<!-- <el-button type="primary" plain @click="onCount">库存盘点</el-button> -->
</div>
</div>
@ -94,7 +109,7 @@
<div>
<div class="tit">{{ scope.row.name }}</div>
<p>{{ scope.row.external_sku_id }}</p>
<p>{{ scope.row.updated_at }}</p>
<p>{{ scope.row.created_at }}</p>
</div>
</div>
</template>
@ -399,7 +414,7 @@
</div>
<div class="import-right">
<el-button size="medium" type="text">
<a :href="`http://erp.chutang66.com/goods/import/template`">下载模板</a>
<a :href="`/goods/import/template`">下载模板</a>
</el-button>
</div>
<span slot="footer" class="dialog-footer">
@ -447,7 +462,7 @@
<script>
import axios from 'axios'
import { goods_types, Brand_goods_types } from '@/api/rankingData.js'
import { goods, update, singleUpdate, getStockNum, updateSaleStock } from '@/api/goods'
import { goods, update, singleUpdate, getStockNum, updateSaleStock, goodsSkuExport } from '@/api/goods'
import { orderRest } from "@/api/shop"
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
@ -554,7 +569,8 @@
is_admin: false,
showAdd: false,
showEdit: false,
curId: 0
curId: 0,
filterTime: []
}
},
methods: {
@ -626,7 +642,8 @@
//
return _newPar
}
newObj.type_id = newObj.type_id || ''
newObj.create_time_start = this.filterTime ? this.filterTime[0] : ''
newObj.create_time_end = this.filterTime ? this.filterTime[1] : ''
goods(newObj).then((res) => {
this.tableData = res.data.data
this.tableData = this.tableData.map((item) => {
@ -663,7 +680,7 @@
})
},
//
handleExport() {
handleTypeExport() {
this.Tableexport = true
},
//
@ -722,6 +739,26 @@
this.stock = false
},
handleExport() {
let params = {
exportType: 'goods_sku',
external_sku_id: this.form.external_sku_id,
goods_title: this.form.goods_title,
type_id: this.form.type_id || '',
status: this.form.status,
keyword_type: 'stock',
create_time_start: this.filterTime ? this.filterTime[0] : '',
create_time_end: this.filterTime ? this.filterTime[1] : ''
}
window.open("/goods_skus/export?" + this.objectToQueryString(params))
},
objectToQueryString(obj) {
return Object.keys(obj)
.map(key => encodeURIComponent(key) + '=' + (obj[key] ? encodeURIComponent(obj[key]) : ''))
.join('&');
},
// or
onSubmit() {
//

View File

@ -308,7 +308,7 @@ export default {
.add {
cursor: pointer;
font-size: 20px;
font-size: 16px;
color: #606266;
}

View File

@ -1,157 +1,158 @@
<template>
<div class="pageBox">
<el-card>
<div class="opaBox">
<el-button type="primary" icon="el-icon-plus" @click="dialogVisible2 = true">新增</el-button>
</div>
<el-table v-loading="loading" :data="tableList" style="width: 100%" border>
<el-table-column prop="id" label="ID"> </el-table-column>
<el-table-column prop="name" label="角色名称"> </el-table-column>
<el-table-column label="权限内容">
<template slot-scope="scope">
<span v-for="item in scope.row.permissions" :key="item.id">{{ item.name }}&nbsp;</span>
</template>
</el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button type="primary" @click="onEdit(scope.row)" icon="el-icon-edit">编辑权限</el-button>
</template>
</el-table-column>
</el-table>
</el-card>
<div class="pageBox">
<el-card>
<div class="opaBox">
<el-button type="primary" icon="el-icon-plus" @click="dialogVisible2 = true">新增</el-button>
</div>
<el-table v-loading="loading" :data="tableList" style="width: 100%" border>
<el-table-column prop="id" label="ID" width="100" align="center" />
<el-table-column prop="name" label="角色名称" width="200" align="center" />
<el-table-column label="权限内容">
<template slot-scope="scope">
<span v-for="item in scope.row.permissions" :key="item.id">{{ item.name }}<span style="color: #333;">&nbsp;|&nbsp;</span></span>
</template>
</el-table-column>
<el-table-column label="操作" width="200" align="center">
<template slot-scope="scope">
<el-button type="primary" @click="onEdit(scope.row)" icon="el-icon-edit">编辑权限</el-button>
</template>
</el-table-column>
</el-table>
</el-card>
<!-- 点击编辑弹出权限框 -->
<el-dialog title="编辑权限" :visible.sync="dialogVisible" width="30%" :close-on-click-modal="false">
<el-tree v-if="isShowtree" :data="Role_Permission" show-checkbox :default-expand-all="false" node-key="id"
ref="tree" highlight-current :props="defaultProps" :default-checked-keys="chekedKeys"
v-model="permissionIds">
</el-tree>
<span slot="footer" class="dialog-footer">
<el-button @click="cancel()"> </el-button>
<el-button type="primary" @click="getCheckedKeys()"> </el-button>
</span>
</el-dialog>
<!-- 点击编辑弹出权限框 -->
<el-dialog title="编辑权限" :visible.sync="dialogVisible" width="30%" :close-on-click-modal="false">
<el-tree
v-if="isShowtree"
:data="Role_Permission"
show-checkbox
:default-expand-all="false"
node-key="id"
ref="tree"
highlight-current
:props="defaultProps"
:default-checked-keys="chekedKeys"
v-model="permissionIds">
</el-tree>
<span slot="footer" class="dialog-footer">
<el-button @click="cancel()"> </el-button>
<el-button type="primary" @click="getCheckedKeys()"> </el-button>
</span>
</el-dialog>
<el-dialog title="新增角色" :visible.sync="dialogVisible2" width="30%" :close-on-click-modal="false">
<div>
<el-form label-width="80px">
<el-form-item label="角色名称">
<el-input v-model="newrole"></el-input>
</el-form-item>
<div class="from-btn">
<el-button @click="dialogVisible2 = false">取消</el-button>
<el-button type="primary" @click="onSubmit">确认</el-button>
</div>
</el-form>
</div>
</el-dialog>
</div>
<el-dialog title="新增角色" :visible.sync="dialogVisible2" width="30%" :close-on-click-modal="false">
<el-form label-width="80px">
<el-form-item label="角色名称">
<el-input v-model="newrole"></el-input>
</el-form-item>
<div class="from-btn">
<el-button @click="dialogVisible2 = false">取消</el-button>
<el-button type="primary" @click="onSubmit">确认</el-button>
</div>
</el-form>
</el-dialog>
</div>
</template>
<script>
import { roleList, roleAdd, jurisdiction, jurisdictionEdit } from "@/api/role.js"
export default {
data() {
return {
id: "", //id
loading: true,
tableList: [], //
rolePermissions: [],
newrole: "", //input
dialogVisible: false, //
dialogVisible2: false, //
permissionIds: [], //ID
allpermissionIds: {}, //id
Role_Permission: [], //
defaultProps: {
children: "children",
label: "name",
},
isShowtree: false,
chekedKeys: [],
};
data() {
return {
id: "", //id
loading: true,
tableList: [], //
rolePermissions: [],
newrole: "", //input
dialogVisible: false, //
dialogVisible2: false, //
permissionIds: [], //ID
allpermissionIds: {}, //id
Role_Permission: [], //
defaultProps: {
children: "children",
label: "name"
},
isShowtree: false,
chekedKeys: []
}
},
mounted() {
this.getroleList()
this.getJurisdiction()
},
methods: {
//
getroleList() {
roleList().then((res) => {
this.tableList = res.data.data
})
this.loading = false
},
mounted() {
this.getroleList();
this.getJurisdiction();
//
getJurisdiction() {
jurisdiction().then((res) => {
this.Role_Permission = res.data.data
})
},
methods: {
//
getroleList() {
roleList().then((res) => {
this.tableList = res.data.data;
});
this.loading = false;
},
//
getJurisdiction() {
jurisdiction().then((res) => {
this.Role_Permission = res.data.data;
});
},
//
onSubmit() {
let roleName = {
name: this.newrole,
};
roleAdd(roleName).then((res) => {
this.dialogVisible2 = false;
this.getroleList();
if (res.status == 201) {
this.$message({
message: "角色添加成功!",
type: "success",
});
}
});
},
//
onEdit(row) {
this.id = row.id;
let arr = row.permissions.map((item) => {
return item.id;
});
this.chekedKeys = arr;
this.dialogVisible = true;
this.isShowtree = true;
},
//
cancel() {
this.dialogVisible = false;
this.isShowtree = false;
},
//
getCheckedKeys() {
let id = this.id; //ID
this.permissionIds = this.$refs.tree.getCheckedKeys(); //ID
this.allpermissionIds = {
permissionIds: this.permissionIds,
};
jurisdictionEdit(id, this.allpermissionIds).then((res) => {
if (res.status === 200) {
this.dialogVisible = false;
this.getroleList();
this.$message({
message: "权限修改成功!",
type: "success",
});
}
});
},
//
onSubmit() {
let roleName = {
name: this.newrole
}
roleAdd(roleName).then((res) => {
this.dialogVisible2 = false;
this.getroleList()
if (res.status == 201) {
this.$message({
message: "角色添加成功!",
type: "success"
})
}
})
},
};
//
onEdit(row) {
this.id = row.id
let arr = row.permissions.map((item) => {
return item.id
})
this.chekedKeys = arr
this.dialogVisible = true
this.isShowtree = true
},
//
cancel() {
this.dialogVisible = false
this.isShowtree = false
},
//
getCheckedKeys() {
let id = this.id //ID
this.permissionIds = this.$refs.tree.getCheckedKeys() //ID
this.allpermissionIds = {
permissionIds: this.permissionIds
}
jurisdictionEdit(id, this.allpermissionIds).then((res) => {
if (res.status === 200) {
this.dialogVisible = false
this.getroleList()
this.$message({ message: "权限修改成功!", type: "success" })
}
})
}
}
}
</script>
<style lang="scss" scoped>
.opaBox{
margin-bottom: 15px;
}
.opaBox{
margin-bottom: 15px;
}
</style>