商品添加导出、时间筛选

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> <span>商品编码</span>
<el-input v-model="searchForm.external_sku_id" clearable></el-input> <el-input v-model="searchForm.external_sku_id" clearable></el-input>
</div> </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"> <div class="row">
<el-button type="primary" @click="handleChoose(1)" icon="el-icon-search">筛选</el-button> <el-button type="primary" @click="handleChoose(1)" icon="el-icon-search">筛选</el-button>
</div> </div>
@ -21,9 +35,10 @@
<el-upload ref="myUpload" action="/api/combination/goods" :multiple="false" name="combinationGoods" <el-upload ref="myUpload" action="/api/combination/goods" :multiple="false" name="combinationGoods"
:show-file-list="false" :on-success="uploadSuccess" :before-upload="beforeUpload" :show-file-list="false" :on-success="uploadSuccess" :before-upload="beforeUpload"
:on-error="uploadError" style="display:inline-block;margin: 0 15px 0 0;"> :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-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> </div>
<el-table v-loading="loading" ref="multipleTable" :data="tableData" class="table" tooltip-effect="dark" border <el-table v-loading="loading" ref="multipleTable" :data="tableData" class="table" tooltip-effect="dark" border
@ -36,7 +51,7 @@
<div> <div>
<p>{{ scope.row.title }}</p> <p>{{ scope.row.title }}</p>
<p>{{ scope.row.external_sku_id }}</p> <p>{{ scope.row.external_sku_id }}</p>
<p>{{ scope.row.updated_at }}</p> <p>{{ scope.row.created_at }}</p>
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
@ -149,7 +164,8 @@
}, },
skus: [], skus: [],
is_admin: false, is_admin: false,
remoteLoading: false remoteLoading: false,
filterTime: []
} }
}, },
methods: { methods: {
@ -180,7 +196,9 @@
this.searchForm = { this.searchForm = {
...this.searchForm, ...this.searchForm,
page: this.current_page, 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) this.getList(this.searchForm)
}, },
@ -265,6 +283,21 @@
type: "error" type: "error"
}); });
this.loadingModule.close() 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() { mounted() {

View File

@ -38,6 +38,20 @@
</el-option> </el-option>
</el-select> </el-select>
</div> </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"> <!-- <div class="row">
<el-select v-model="form.keyword_type" style="width: 80px;margin-right: 5px;"> <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"> <el-option v-for="item in options3" :key="item.value" :label="item.label" :value="item.value">
@ -76,8 +90,9 @@
</el-upload> --> </el-upload> -->
<el-button type="primary" @click="petchEditStock" icon="el-icon-edit" :disabled="!chooseList.length">批量更新在售库存</el-button> <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" @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="primary" plain v-if="is_admin" @click="handleImport" icon="el-icon-upload2">在售库存导入</el-button>
<el-button type="warning" @click="handleExport" icon="el-icon-download">表格导出</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> --> <!-- <el-button type="primary" plain @click="onCount">库存盘点</el-button> -->
</div> </div>
</div> </div>
@ -94,7 +109,7 @@
<div> <div>
<div class="tit">{{ scope.row.name }}</div> <div class="tit">{{ scope.row.name }}</div>
<p>{{ scope.row.external_sku_id }}</p> <p>{{ scope.row.external_sku_id }}</p>
<p>{{ scope.row.updated_at }}</p> <p>{{ scope.row.created_at }}</p>
</div> </div>
</div> </div>
</template> </template>
@ -399,7 +414,7 @@
</div> </div>
<div class="import-right"> <div class="import-right">
<el-button size="medium" type="text"> <el-button size="medium" type="text">
<a :href="`http://erp.chutang66.com/goods/import/template`">下载模板</a> <a :href="`/goods/import/template`">下载模板</a>
</el-button> </el-button>
</div> </div>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
@ -447,7 +462,7 @@
<script> <script>
import axios from 'axios' import axios from 'axios'
import { goods_types, Brand_goods_types } from '@/api/rankingData.js' 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 { orderRest } from "@/api/shop"
import Treeselect from '@riophae/vue-treeselect' import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css' import '@riophae/vue-treeselect/dist/vue-treeselect.css'
@ -554,7 +569,8 @@
is_admin: false, is_admin: false,
showAdd: false, showAdd: false,
showEdit: false, showEdit: false,
curId: 0 curId: 0,
filterTime: []
} }
}, },
methods: { methods: {
@ -626,7 +642,8 @@
// //
return _newPar 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) => { goods(newObj).then((res) => {
this.tableData = res.data.data this.tableData = res.data.data
this.tableData = this.tableData.map((item) => { this.tableData = this.tableData.map((item) => {
@ -663,7 +680,7 @@
}) })
}, },
// //
handleExport() { handleTypeExport() {
this.Tableexport = true this.Tableexport = true
}, },
// //
@ -722,6 +739,26 @@
this.stock = false 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 // or
onSubmit() { onSubmit() {
// //

View File

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

View File

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