123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844 |
- <template>
- <div class="app-container">
- <el-card class="filter-container" shadow="never">
- <div>
- <i class="el-icon-search"></i>
- <span>筛选搜索</span>
- <el-button
- style="float: right"
- @click="handleSearchList()"
- type="primary"
- size="small"
- >
- 查询结果
- </el-button>
- <el-button
- style="float: right; margin-right: 15px"
- @click="handleResetSearch()"
- size="small"
- >
- 重置
- </el-button>
- </div>
- <div style="margin-top: 15px">
- <el-form
- :inline="true"
- :model="listQuery"
- size="small"
- label-width="140px"
- >
- <el-form-item label="输入搜索:">
- <el-input
- style="width: 203px"
- v-model="listQuery.keyword"
- placeholder="商品名称"
- ></el-input>
- </el-form-item>
- <el-form-item label="商品货号:">
- <el-input
- style="width: 203px"
- v-model="listQuery.productSn"
- placeholder="商品货号"
- ></el-input>
- </el-form-item>
- <el-form-item label="商品分类:">
- <el-cascader
- clearable
- v-model="selectProductCateValue"
- :options="productCateOptions"
- >
- </el-cascader>
- </el-form-item>
- <el-form-item label="商品品牌:">
- <el-select
- v-model="listQuery.brandId"
- placeholder="请选择品牌"
- clearable
- >
- <el-option
- v-for="item in brandOptions"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="上架状态:">
- <el-select
- v-model="listQuery.publishStatus"
- placeholder="全部"
- clearable
- >
- <el-option
- v-for="item in publishStatusOptions"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="是否缺货">
- <el-select
- v-model="listQuery.stock"
- placeholder="是否缺货"
- clearable
- style="width:203px"
- >
- <el-option
- v-for="item in stockOptions"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-form>
- </div>
- </el-card>
- <el-card class="operate-container" shadow="never">
- <i class="el-icon-tickets"></i>
- <span>数据列表</span>
- <div class="btn-add">
- <el-button @click="handleAddProduct()" size="mini">
- 添加
- </el-button>
- <el-button type="primary" @click="handleDownloadStock()" size="mini">
- 导出库存
- </el-button>
- <el-button type="primary" @click="handleDownloadProductStock()" size="mini">
- 导出进货清单
- </el-button>
- </div>
- </el-card>
- <div class="table-container">
- <el-table
- ref="productTable"
- :data="list"
- style="width: 100%"
- @selection-change="handleSelectionChange"
- v-loading="listLoading"
- border
- >
- <el-table-column
- type="selection"
- width="60"
- align="center"
- ></el-table-column>
- <el-table-column label="编号" width="100" align="center">
- <template slot-scope="scope">{{ scope.row.id }}</template>
- </el-table-column>
- <el-table-column label="商品图片" width="120" align="center">
- <template slot-scope="scope"
- ><img style="height: 80px" :src="scope.row.pic"
- /></template>
- </el-table-column>
- <el-table-column label="商品名称" align="center">
- <template slot-scope="scope">
- <p>{{ scope.row.name }}</p>
- <p>品牌:{{ scope.row.brandName }}</p>
- <p>类型:{{ scope.row.productType | goodsTypeFilter }}</p>
- </template>
- </el-table-column>
- <el-table-column label="价格/货号" width="120" align="center">
- <template slot-scope="scope">
- <p>价格:¥{{ scope.row.price }}</p>
- <p>货号:{{ scope.row.productSn }}</p>
- </template>
- </el-table-column>
- <el-table-column label="标签" width="140" align="center">
- <template slot-scope="scope">
- <p>
- 上架:
- <el-switch
- @change="handlePublishStatusChange(scope.$index, scope.row)"
- :active-value="1"
- :inactive-value="0"
- v-model="scope.row.publishStatus"
- >
- </el-switch>
- </p>
- <!-- <p>
- 新品:
- <el-switch
- @change="handleNewStatusChange(scope.$index, scope.row)"
- :active-value="1"
- :inactive-value="0"
- v-model="scope.row.newStatus"
- >
- </el-switch>
- </p> -->
- <p>
- 推荐:
- <el-switch
- @change="handleRecommendStatusChange(scope.$index, scope.row)"
- :active-value="1"
- :inactive-value="0"
- v-model="scope.row.recommandStatus"
- >
- </el-switch>
- </p>
- </template>
- </el-table-column>
- <el-table-column label="排序" width="100" align="center">
- <template slot-scope="scope">{{ scope.row.sort }}</template>
- </el-table-column>
- <el-table-column label="SKU库存" width="100" align="center">
- <template slot-scope="scope">
- <el-button
- type="primary"
- icon="el-icon-edit"
- @click="handleShowSkuEditDialog(scope.$index, scope.row)"
- circle
- ></el-button>
- </template>
- </el-table-column>
- <el-table-column label="销量" width="100" align="center">
- <template slot-scope="scope">{{ scope.row.sale }}</template>
- </el-table-column>
- <!-- <el-table-column label="审核状态" width="100" align="center">
- <template slot-scope="scope">
- <p>{{scope.row.verifyStatus | verifyStatusFilter}}</p>
- <p>
- <el-button
- type="text"
- @click="handleShowVerifyDetail(scope.$index, scope.row)">审核详情
- </el-button>
- </p>
- </template>
- </el-table-column> -->
- <el-table-column label="操作" width="220" align="center">
- <template slot-scope="scope">
- <p class="table-btn-group">
- <el-button
- size="mini"
- @click="handleShowProduct(scope.$index, scope.row)"
- >查看
- </el-button>
- <el-button
- size="mini"
- @click="handleUpdateProduct(scope.$index, scope.row)"
- >编辑
- </el-button>
- <el-button
- size="mini"
- type="danger"
- @click="handleDelete(scope.$index, scope.row)"
- >删除
- </el-button>
- <el-button
- size="mini"
- @click="handleShowPurchase(scope.row)">进货清单
- </el-button>
- </p>
- <p>
- <!-- <el-button
- size="mini"
- @click="handleShowLog(scope.$index, scope.row)">日志
- </el-button> -->
- </p>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <!-- <div class="batch-operate-container">
- <el-select size="small" v-model="operateType" placeholder="批量操作">
- <el-option
- v-for="item in operates"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- <el-button
- style="margin-left: 20px"
- class="search-button"
- @click="handleBatchOperate()"
- type="primary"
- size="small"
- >
- 确定
- </el-button>
- </div> -->
- <div class="pagination-container">
- <el-pagination
- background
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- layout="total, sizes,prev, pager, next,jumper"
- :page-size="listQuery.pageSize"
- :page-sizes="[5, 10, 15]"
- :current-page.sync="listQuery.pageNum"
- :total="total"
- >
- </el-pagination>
- </div>
- <el-dialog
- title="编辑货品信息"
- :visible.sync="editSkuInfo.dialogVisible"
- width="60%"
- >
- <span>商品货号:</span>
- <span>{{ editSkuInfo.productSn }}</span>
- <el-input
- placeholder="按sku编号搜索"
- v-model="editSkuInfo.keyword"
- size="small"
- style="width: 50%; margin-left: 20px"
- >
- <el-button
- slot="append"
- icon="el-icon-search"
- @click="handleSearchEditSku"
- ></el-button>
- </el-input>
- <el-table
- style="width: 100%; margin-top: 20px"
- :data="editSkuInfo.stockList"
- border
- >
- <el-table-column label="SKU编号" align="center">
- <template slot-scope="scope">
- <el-input v-model="scope.row.skuCode"></el-input>
- <!-- {{ scope.row.skuCode }} -->
- </template>
- </el-table-column>
- <el-table-column
- v-for="(item, index) in editSkuInfo.productAttr"
- :label="item.name"
- :key="item.id"
- align="center"
- >
- <template slot-scope="scope">
- {{ getProductSkuSp(scope.row, index) }}
- </template>
- </el-table-column>
- <el-table-column label="销售价格" align="center">
- <template slot-scope="scope">
- <!-- <el-input v-model="scope.row.price"></el-input> -->
- <el-input-number :controls="false" class="number-input" v-model="scope.row.price" :min="0.01" :max="999999" :precision="2"
- type="number"></el-input-number>
- </template>
- </el-table-column>
- <el-table-column label="内部库存" align="center">
- <template slot-scope="scope">
- {{ scope.row.internalStock }}
- </template>
- </el-table-column>
- <el-table-column label="税务库存" align="center">
- <template slot-scope="scope">
- {{scope.row.taxStock}}
- </template>
- </el-table-column>
- <el-table-column label="库存预警值" width="100" align="center">
- <template slot-scope="scope">
- <!-- <el-input v-model="scope.row.lowStock"></el-input> -->
- <el-input-number :controls="false" class="number-input" v-model="scope.row.lowStock" :min="0" :max="999999" :precision="0"
- type="number"></el-input-number>
- </template>
- </el-table-column>
- </el-table>
- <span slot="footer" class="dialog-footer">
- <el-button @click="editSkuInfo.dialogVisible = false">取 消</el-button>
- <el-button type="primary" @click="handleEditSkuConfirm"
- >确 定</el-button
- >
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import {goodsType} from './components/ProductInfoDetail.vue'
- import {
- fetchList,
- updateDeleteStatus,
- updateNewStatus,
- updateRecommendStatus,
- updatePublishStatus,
- } from "@/api/product";
- import {
- fetchList as fetchSkuStockList,
- update as updateSkuStockList,
- } from "@/api/skuStock";
- import { fetchList as fetchProductAttrList } from "@/api/productAttr";
- import { fetchList as fetchBrandList } from "@/api/brand";
- import { fetchListWithChildren } from "@/api/productCate";
- import { Export } from "@/utils/downLoadFile";
- const defaultListQuery = {
- keyword: null,
- pageNum: 1,
- pageSize: 5,
- publishStatus: null,
- verifyStatus: null,
- productSn: null,
- productCategoryId: null,
- brandId: null,
- stock:null
- };
- export default {
- name: "productList",
- data() {
- return {
- editSkuInfo: {
- dialogVisible: false,
- productId: null,
- productSn: "",
- productAttributeCategoryId: null,
- stockList: [],
- productAttr: [],
- keyword: null,
- },
- operates: [
- {
- label: "商品上架",
- value: "publishOn",
- },
- {
- label: "商品下架",
- value: "publishOff",
- },
- {
- label: "设为推荐",
- value: "recommendOn",
- },
- {
- label: "取消推荐",
- value: "recommendOff",
- },
- {
- label: "设为新品",
- value: "newOn",
- },
- {
- label: "取消新品",
- value: "newOff",
- },
- {
- label: "转移到分类",
- value: "transferCategory",
- },
- {
- label: "移入回收站",
- value: "recycle",
- },
- ],
- operateType: null,
- listQuery: Object.assign({}, defaultListQuery),
- list: null,
- total: null,
- listLoading: true,
- selectProductCateValue: null,
- multipleSelection: [],
- productCateOptions: [],
- brandOptions: [],
- publishStatusOptions: [
- {
- value: 1,
- label: "上架",
- },
- {
- value: 0,
- label: "下架",
- },
- ],
- verifyStatusOptions: [
- {
- value: 1,
- label: "审核通过",
- },
- {
- value: 0,
- label: "未审核",
- },
- ],
- stockOptions: [
- {
- value: 1,
- label: "是",
- },
- {
- value: 0,
- label: "否",
- },
- ],
- };
- },
- created() {
- if (this.$route.params.stock + "") {
- this.listQuery.stock = this.$route.params.stock;
- }
- this.getList();
- this.getBrandList();
- this.getProductCateList();
- },
- watch: {
- selectProductCateValue: function (newValue) {
- if (newValue != null && newValue.length == 2) {
- this.listQuery.productCategoryId = newValue[1];
- } else {
- this.listQuery.productCategoryId = null;
- }
- },
- },
- filters: {
- verifyStatusFilter(value) {
- if (value === 1) {
- return "审核通过";
- } else {
- return "未审核";
- }
- },
- goodsTypeFilter(value) {
- let name = '--';
- (goodsType || []).forEach(item => {
- if(item.value === value) {
- name = item.label
- }
- });
- return name
- }
- },
- methods: {
- getProductSkuSp(row, index) {
- let spData = JSON.parse(row.spData);
- if (spData != null && index < spData.length) {
- return spData[index].value;
- } else {
- return null;
- }
- },
- getList() {
- this.listLoading = true;
- fetchList(this.listQuery).then((response) => {
- this.listLoading = false;
- this.list = response.data.list;
- this.total = response.data.total;
- });
- },
- getBrandList() {
- fetchBrandList({ pageNum: 1, pageSize: 100 }).then((response) => {
- this.brandOptions = [];
- let brandList = response.data.list;
- for (let i = 0; i < brandList.length; i++) {
- this.brandOptions.push({
- label: brandList[i].name,
- value: brandList[i].id,
- });
- }
- });
- },
- getProductCateList() {
- fetchListWithChildren().then((response) => {
- let list = response.data;
- this.productCateOptions = [];
- for (let i = 0; i < list.length; i++) {
- let children = [];
- if (list[i].children != null && list[i].children.length > 0) {
- for (let j = 0; j < list[i].children.length; j++) {
- children.push({
- label: list[i].children[j].name,
- value: list[i].children[j].id,
- });
- }
- }
- this.productCateOptions.push({
- label: list[i].name,
- value: list[i].id,
- children: children,
- });
- }
- });
- },
- handleShowSkuEditDialog(index, row) {
- this.editSkuInfo.dialogVisible = true;
- this.editSkuInfo.productId = row.id;
- this.editSkuInfo.productSn = row.productSn;
- this.editSkuInfo.productAttributeCategoryId =
- row.productAttributeCategoryId;
- this.editSkuInfo.keyword = null;
- fetchSkuStockList(row.id, { keyword: this.editSkuInfo.keyword }).then(
- (response) => {
- this.editSkuInfo.stockList = response.data;
- }
- );
- if (row.productAttributeCategoryId != null) {
- fetchProductAttrList(row.productAttributeCategoryId, { type: 0 }).then(
- (response) => {
- this.editSkuInfo.productAttr = response.data.list;
- }
- );
- }
- },
- handleSearchEditSku() {
- fetchSkuStockList(this.editSkuInfo.productId, {
- keyword: this.editSkuInfo.keyword,
- }).then((response) => {
- this.editSkuInfo.stockList = response.data;
- });
- },
- handleEditSkuConfirm() {
- if (
- this.editSkuInfo.stockList == null ||
- this.editSkuInfo.stockList.length <= 0
- ) {
- this.$message({
- message: "暂无sku信息",
- type: "warning",
- duration: 1000,
- });
- return;
- }
- this.$confirm("是否要进行修改", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- }).then(() => {
- updateSkuStockList(
- this.editSkuInfo.productId,
- this.editSkuInfo.stockList
- ).then((response) => {
- this.$message({
- message: "修改成功",
- type: "success",
- duration: 1000,
- });
- this.editSkuInfo.dialogVisible = false;
- });
- });
- },
- handleSearchList() {
- this.listQuery.pageNum = 1;
- this.getList();
- },
- handleAddProduct() {
- this.$router.push({ path: "/pms/addProduct" });
- },
- handleDownloadStock() {
- Export(
- this,
- {
- url: "/api-mall-admin/export/productExport",
- fileName: "库存列表.xls",
- method: "get",
- params: { ...this.listQuery },
- },
- "您确定导出库存?"
- );
- },
- handleDownloadProductStock() {
- Export(
- this,
- {
- url: "/api-mall-admin/export/productStockRecordExport",
- fileName: "进货清单.xls",
- method: "get",
- params: { ...this.listQuery },
- },
- "您确定导出进货清单?"
- );
- },
- handleBatchOperate() {
- if (this.operateType == null) {
- this.$message({
- message: "请选择操作类型",
- type: "warning",
- duration: 1000,
- });
- return;
- }
- if (this.multipleSelection == null || this.multipleSelection.length < 1) {
- this.$message({
- message: "请选择要操作的商品",
- type: "warning",
- duration: 1000,
- });
- return;
- }
- this.$confirm("是否要进行该批量操作?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- }).then(() => {
- let ids = [];
- for (let i = 0; i < this.multipleSelection.length; i++) {
- ids.push(this.multipleSelection[i].id);
- }
- ids = ids.join(",");
- switch (this.operateType) {
- case this.operates[0].value:
- this.updatePublishStatus(1, ids);
- break;
- case this.operates[1].value:
- this.updatePublishStatus(0, ids);
- break;
- case this.operates[2].value:
- this.updateRecommendStatus(1, ids);
- break;
- case this.operates[3].value:
- this.updateRecommendStatus(0, ids);
- break;
- case this.operates[4].value:
- this.updateNewStatus(1, ids);
- break;
- case this.operates[5].value:
- this.updateNewStatus(0, ids);
- break;
- case this.operates[6].value:
- break;
- case this.operates[7].value:
- this.updateDeleteStatus(1, ids);
- break;
- default:
- break;
- }
- this.getList();
- });
- },
- handleSizeChange(val) {
- this.listQuery.pageNum = 1;
- this.listQuery.pageSize = val;
- this.getList();
- },
- handleCurrentChange(val) {
- this.listQuery.pageNum = val;
- this.getList();
- },
- handleSelectionChange(val) {
- this.multipleSelection = val;
- },
- handlePublishStatusChange(index, row) {
- let ids = [];
- ids.push(row.id);
- ids = ids.join(",");
- this.updatePublishStatus(row.publishStatus, ids);
- },
- handleNewStatusChange(index, row) {
- let ids = [];
- ids.push(row.id);
- ids = ids.join(",");
- this.updateNewStatus(row.newStatus, ids);
- },
- handleRecommendStatusChange(index, row) {
- let ids = [];
- ids.push(row.id);
- ids = ids.join(",");
- this.updateRecommendStatus(row.recommandStatus, ids);
- },
- handleResetSearch() {
- this.selectProductCateValue = [];
- this.listQuery = Object.assign({}, defaultListQuery);
- },
- handleDelete(index, row) {
- this.$confirm("是否要进行删除操作?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- }).then(() => {
- let ids = [];
- ids.push(row.id);
- ids = ids.join(",");
- this.updateDeleteStatus(1, ids);
- });
- },
- handleUpdateProduct(index, row) {
- this.$router.push({ path: "/pms/updateProduct", query: { id: row.id } });
- },
- handleShowProduct(index, row) {
- this.$router.push({ path: "/pms/detailProduct", query: { id: row.id } });
- // console.log("handleShowProduct",row);
- },
- handleShowVerifyDetail(index, row) {
- console.log("handleShowVerifyDetail", row);
- },
- handleShowPurchase(row) {
- this.$router.push({ path: "/pms/purchaseList", query: { id: row.id, name: row.name } });
- },
- handleShowLog(index, row) {
- console.log("handleShowLog", row);
- },
- updatePublishStatus(publishStatus, ids) {
- let obj = {
- ids,
- publishStatus,
- };
- updatePublishStatus(obj).then((response) => {
- this.$message({
- message: "修改成功",
- type: "success",
- duration: 1000,
- });
- });
- },
- updateNewStatus(newStatus, ids) {
- let obj = {
- ids,
- newStatus,
- };
- updateNewStatus(obj).then((response) => {
- this.$message({
- message: "修改成功",
- type: "success",
- duration: 1000,
- });
- });
- },
- updateRecommendStatus(recommendStatus, ids) {
- let obj = {
- ids,
- recommendStatus,
- };
- updateRecommendStatus(obj).then((response) => {
- this.$message({
- message: "修改成功",
- type: "success",
- duration: 1000,
- });
- });
- },
- updateDeleteStatus(deleteStatus, ids) {
- let obj = {
- ids,
- deleteStatus,
- };
- updateDeleteStatus(obj).then((response) => {
- this.$message({
- message: "删除成功",
- type: "success",
- duration: 1000,
- });
- });
- this.getList();
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- ::v-deep.el-select--small {
- width: 203px !important;
- }
- .number-input {
- input {
- text-align: left;
- }
- width: 100%;
- }
- .table-btn-group {
- .el-button {
- margin: 5px 3px;
- }
- }
- </style>
|