mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2025-12-22 10:55:54 +08:00
批量上传、添加注释
This commit is contained in:
@@ -126,13 +126,16 @@ export default {
|
||||
template: "action",
|
||||
}
|
||||
],
|
||||
// 表格数据
|
||||
tableData: []
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
// 初始化数据
|
||||
init() {
|
||||
this.getAllList();
|
||||
},
|
||||
// 刷新列表
|
||||
refresh() {
|
||||
this.loading = true;
|
||||
let that = this;
|
||||
@@ -152,6 +155,7 @@ export default {
|
||||
this.formAdd.parentId = v.id;
|
||||
this.modalVisible = true;
|
||||
},
|
||||
// 编辑分类
|
||||
edit(v) {
|
||||
this.modalType = 1;
|
||||
this.modalTitle = "编辑";
|
||||
@@ -209,6 +213,7 @@ export default {
|
||||
}
|
||||
});
|
||||
},
|
||||
// 确认删除分类
|
||||
remove(v) {
|
||||
this.$Modal.confirm({
|
||||
title: "确认删除",
|
||||
@@ -227,6 +232,7 @@ export default {
|
||||
}
|
||||
});
|
||||
},
|
||||
// 获取分类
|
||||
getAllList() {
|
||||
this.loading = true;
|
||||
API_Goods.getShopGoodsLabelList(this.searchForm).then((res) => {
|
||||
|
||||
@@ -1,57 +1,56 @@
|
||||
<template>
|
||||
<div class="search">
|
||||
<Card>
|
||||
<Row v-show="openSearch" @keydown.enter.native="handleSearch">
|
||||
<Form
|
||||
ref="searchForm"
|
||||
:model="searchForm"
|
||||
inline
|
||||
:label-width="70"
|
||||
class="search-form"
|
||||
>
|
||||
<Form-item label="商品名称" prop="goodsName">
|
||||
<Form
|
||||
ref="searchForm"
|
||||
:model="searchForm"
|
||||
inline
|
||||
:label-width="70"
|
||||
class="search-form mb_10"
|
||||
@keydown.enter.native="handleSearch"
|
||||
>
|
||||
<Form-item label="商品名称" prop="goodsName">
|
||||
<Input
|
||||
type="text"
|
||||
v-model="searchForm.goodsName"
|
||||
placeholder="请输入商品名称"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
/>
|
||||
</Form-item>
|
||||
<span v-if="drop">
|
||||
<Form-item label="状态" prop="status">
|
||||
<Select
|
||||
v-model="searchForm.marketEnable"
|
||||
placeholder="请选择"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
>
|
||||
<Option value="DOWN">下架</Option>
|
||||
<Option value="UPPER">上架</Option>
|
||||
</Select>
|
||||
</Form-item>
|
||||
<Form-item label="商品编号" prop="sn">
|
||||
<Input
|
||||
type="text"
|
||||
v-model="searchForm.goodsName"
|
||||
placeholder="请输入商品名称"
|
||||
v-model="searchForm.sn"
|
||||
placeholder="商品编号"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
/>
|
||||
</Form-item>
|
||||
<span v-if="drop">
|
||||
<Form-item label="状态" prop="status">
|
||||
<Select
|
||||
v-model="searchForm.marketEnable"
|
||||
placeholder="请选择"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
>
|
||||
<Option value="DOWN">下架</Option>
|
||||
<Option value="UPPER">上架</Option>
|
||||
</Select>
|
||||
</Form-item>
|
||||
<Form-item label="商品编号" prop="sn">
|
||||
<Input
|
||||
type="text"
|
||||
v-model="searchForm.sn"
|
||||
placeholder="商品编号"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
/>
|
||||
</Form-item>
|
||||
</span>
|
||||
<Form-item style="margin-left: -35px" class="br">
|
||||
<Button @click="handleSearch" type="primary" icon="ios-search"
|
||||
>搜索</Button
|
||||
>
|
||||
<Button @click="handleReset">重置</Button>
|
||||
<a class="drop-down" @click="dropDown">
|
||||
{{ dropDownContent }}
|
||||
<Icon :type="dropDownIcon"></Icon>
|
||||
</a>
|
||||
</Form-item>
|
||||
</Form>
|
||||
</Row>
|
||||
</span>
|
||||
<Form-item style="margin-left: -35px" class="br">
|
||||
<Button @click="handleSearch" type="primary" icon="ios-search"
|
||||
>搜索</Button
|
||||
>
|
||||
<Button @click="handleReset">重置</Button>
|
||||
<a class="drop-down" @click="dropDown">
|
||||
{{ dropDownContent }}
|
||||
<Icon :type="dropDownIcon"></Icon>
|
||||
</a>
|
||||
</Form-item>
|
||||
</Form>
|
||||
<Table
|
||||
:loading="loading"
|
||||
border
|
||||
@@ -198,13 +197,14 @@ export default {
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
init() { // 初始化数据
|
||||
this.getDataList();
|
||||
},
|
||||
// 编辑模板
|
||||
editGoods(v) {
|
||||
this.$router.push({ name: "goods-template-operation-edit", query: { draftId: v.id } })
|
||||
this.$router.push({ name: "goods-template-operation-edit", query: { draftId: v.id } })
|
||||
},
|
||||
// 删除模板
|
||||
removeDraft (id) {
|
||||
let showType = "模版";
|
||||
this.$Modal.confirm({
|
||||
@@ -222,19 +222,23 @@ export default {
|
||||
},
|
||||
});
|
||||
},
|
||||
// 改变页数
|
||||
changePage(v) {
|
||||
this.searchForm.pageNumber = v;
|
||||
this.getDataList();
|
||||
},
|
||||
// 改变页码
|
||||
changePageSize(v) {
|
||||
this.searchForm.pageSize = v;
|
||||
this.getDataList();
|
||||
},
|
||||
// 搜索
|
||||
handleSearch() {
|
||||
this.searchForm.pageNumber = 1;
|
||||
this.searchForm.pageSize = 10;
|
||||
this.getDataList();
|
||||
},
|
||||
// 重置
|
||||
handleReset() {
|
||||
this.$refs.searchForm.resetFields();
|
||||
this.searchForm.pageNumber = 1;
|
||||
@@ -242,6 +246,7 @@ export default {
|
||||
// 重新加载数据
|
||||
this.getDataList();
|
||||
},
|
||||
// 展开、收起搜索项
|
||||
dropDown() {
|
||||
if (this.drop) {
|
||||
this.dropDownContent = "展开";
|
||||
@@ -252,6 +257,7 @@ export default {
|
||||
}
|
||||
this.drop = !this.drop;
|
||||
},
|
||||
// 获取列表数据
|
||||
getDataList() {
|
||||
this.loading = true;
|
||||
// 带多条件搜索参数获取表单数据
|
||||
|
||||
@@ -64,7 +64,6 @@
|
||||
</template>
|
||||
|
||||
</Table>
|
||||
|
||||
<Row type="flex" justify="end" class="page">
|
||||
<Page :current="searchForm.pageNumber" :total="total" :page-size="searchForm.pageSize" @on-change="changePage" @on-page-size-change="changePageSize" :page-size-opts="[10, 20, 50]" size="small"
|
||||
show-total show-elevator show-sizer></Page>
|
||||
@@ -123,7 +122,7 @@ export default {
|
||||
return {
|
||||
id: "", //要操作的id
|
||||
loading: true, // 表单加载状态
|
||||
shipTemplateForm: {},
|
||||
shipTemplateForm: {}, // 物流模板
|
||||
shipTemplateModal: false, // 物流模板是否显示
|
||||
logisticsTemplate: [], // 物流列表
|
||||
updateStockModalVisible: false, // 更新库存模态框显隐
|
||||
@@ -382,12 +381,14 @@ export default {
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
init() { // 初始化数据
|
||||
this.getDataList();
|
||||
},
|
||||
// 添加商品
|
||||
addGoods() {
|
||||
this.$router.push({ name: "goods-operation" });
|
||||
},
|
||||
// 编辑商品
|
||||
editGoods(v) {
|
||||
this.$router.push({ name: "goods-operation-edit", query: { id: v.id } });
|
||||
},
|
||||
@@ -437,20 +438,24 @@ export default {
|
||||
}
|
||||
});
|
||||
},
|
||||
// 改变页码
|
||||
changePage(v) {
|
||||
this.searchForm.pageNumber = v;
|
||||
this.getDataList();
|
||||
this.clearSelectAll();
|
||||
},
|
||||
// 改变页数
|
||||
changePageSize(v) {
|
||||
this.searchForm.pageSize = v;
|
||||
this.getDataList();
|
||||
},
|
||||
// 搜索
|
||||
handleSearch() {
|
||||
this.searchForm.pageNumber = 1;
|
||||
this.searchForm.pageSize = 10;
|
||||
this.getDataList();
|
||||
},
|
||||
// 重置搜索条件
|
||||
handleReset() {
|
||||
this.searchForm = {};
|
||||
this.searchForm.pageNumber = 1;
|
||||
@@ -458,24 +463,17 @@ export default {
|
||||
// 重新加载数据
|
||||
this.getDataList();
|
||||
},
|
||||
changeSort(e) {
|
||||
this.searchForm.sort = e.key;
|
||||
this.searchForm.order = e.order;
|
||||
if (e.order === "normal") {
|
||||
this.searchForm.order = "";
|
||||
}
|
||||
this.getDataList();
|
||||
},
|
||||
// 清除多选
|
||||
clearSelectAll() {
|
||||
this.$refs.table.selectAll(false);
|
||||
},
|
||||
// 添加选中项
|
||||
changeSelect(e) {
|
||||
this.selectList = e;
|
||||
this.selectCount = e.length;
|
||||
},
|
||||
//保存物流模板信息
|
||||
saveShipTemplate() {
|
||||
|
||||
this.$Modal.confirm({
|
||||
title: "确认设置物流模板",
|
||||
content:
|
||||
|
||||
@@ -37,6 +37,7 @@ export default {
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
// 选择商品分类回调
|
||||
getFirstData (item) {
|
||||
this.firstData = item;
|
||||
this.activestep = 1;
|
||||
@@ -54,7 +55,6 @@ export default {
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import "./addGoods.scss";
|
||||
</style>
|
||||
|
||||
@@ -108,10 +108,8 @@ export default {
|
||||
goodsType: '',
|
||||
/** 1级分类列表*/
|
||||
categoryListLevel1: [],
|
||||
|
||||
/** 2级分类列表*/
|
||||
categoryListLevel2: [],
|
||||
|
||||
/** 3级分类列表*/
|
||||
categoryListLevel3: [],
|
||||
}
|
||||
|
||||
@@ -59,36 +59,33 @@
|
||||
<Input type="text" v-model="baseInfoForm.cost" placeholder="市场价格" clearable style="width: 260px"/>
|
||||
</FormItem>
|
||||
<FormItem class="form-item-view-el required" label="商品图片" prop="goodsGalleryFiles">
|
||||
<vuedraggable
|
||||
:list="baseInfoForm.goodsGalleryFiles"
|
||||
:animation="200"
|
||||
style="display:inline-block;"
|
||||
ghost-class="thumb-ghost"
|
||||
>
|
||||
<div class="demo-upload-list" v-for="(item, __index) in baseInfoForm.goodsGalleryFiles" :key="__index">
|
||||
<template v-if="item.status === 'finished'">
|
||||
<img :src="item.url"/>
|
||||
<div class="demo-upload-list-cover">
|
||||
<div>
|
||||
<Icon type="ios-eye-outline" size="30" @click.native="handleViewGoodsPicture(item.url)"></Icon>
|
||||
<Icon type="ios-trash-outline" size="30" @click.native="handleRemoveGoodsPicture(item)"></Icon>
|
||||
<div style="display:flex;flex-wrap:flex-start;">
|
||||
<vuedraggable
|
||||
:list="baseInfoForm.goodsGalleryFiles"
|
||||
:animation="200"
|
||||
>
|
||||
<div class="demo-upload-list" v-for="(item, __index) in baseInfoForm.goodsGalleryFiles" :key="__index">
|
||||
<template>
|
||||
<img :src="item.url"/>
|
||||
<div class="demo-upload-list-cover">
|
||||
<div>
|
||||
<Icon type="md-search" size="30" @click.native="handleViewGoodsPicture(item.url)"></Icon>
|
||||
<Icon type="md-trash" size="30" @click.native="handleRemoveGoodsPicture(item)"></Icon>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<Progress v-if="item.showProgress" :percent="item.percentage" hide-info></Progress>
|
||||
</template>
|
||||
</div>
|
||||
</vuedraggable>
|
||||
<Upload ref="upload" :show-upload-list="false" :default-file-list="baseInfoForm.goodsGalleryFiles"
|
||||
:on-success="handleSuccessGoodsPicture" :format="['jpg', 'jpeg', 'png']"
|
||||
:on-format-error="handleFormatError" :on-exceeded-size="handleMaxSize"
|
||||
:before-upload="handleBeforeUploadGoodsPicture" multiple type="drag" :action="uploadFileUrl"
|
||||
:headers="accessToken" style="display: inline-block;margin-left:10px;">
|
||||
<div style="width: 80px; height: 80px; line-height: 80px">
|
||||
<Icon type="ios-camera" size="20"></Icon>
|
||||
</div>
|
||||
</Upload>
|
||||
</template>
|
||||
</div>
|
||||
</vuedraggable>
|
||||
<Upload ref="upload" :show-upload-list="false"
|
||||
:on-success="handleSuccessGoodsPicture" :format="['jpg', 'jpeg', 'png']"
|
||||
:on-format-error="handleFormatError" :on-exceeded-size="handleMaxSize"
|
||||
:before-upload="handleBeforeUploadGoodsPicture" multiple type="drag" :action="uploadFileUrl"
|
||||
:headers="accessToken" style="margin-left:10px">
|
||||
<div style="width: 148px; height: 148px; line-height: 148px">
|
||||
<Icon type="md-add" size="20"></Icon>
|
||||
</div>
|
||||
</Upload>
|
||||
</div>
|
||||
<Modal title="View Image" v-model="goodsPictureVisible">
|
||||
<img :src="previewGoodsPicture" v-if="goodsPictureVisible" style="width: 100%"/>
|
||||
</Modal>
|
||||
@@ -98,7 +95,7 @@
|
||||
<Panel name="1">
|
||||
规格名称
|
||||
<div slot="content" class="sku-item-content">
|
||||
<Form :model="skuForm" @submit.native.prevent>
|
||||
<Form>
|
||||
<div class="sku-item" v-for="(item, $index) in skuInfo" :key="$index">
|
||||
<Card :bordered="true">
|
||||
<FormItem label="规格名:" class="sku-item-content-name">
|
||||
@@ -113,7 +110,7 @@
|
||||
<FormItem label="规格值:" prop="sku">
|
||||
<!--规格值文本列表-->
|
||||
<div v-for="(val, index) in item.spec_values" :key="index"
|
||||
style="padding: 0px 20px 10px 0px; float: left">
|
||||
style="padding: 0px 20px 10px 0px; float: left">
|
||||
<div>
|
||||
<AutoComplete style="width: 150px; float: left" v-model="val.value"
|
||||
:maxlength="30" placeholder="请输入规格值名称"
|
||||
@@ -170,24 +167,21 @@
|
||||
</div>
|
||||
<Divider/>
|
||||
<vuedraggable
|
||||
:list="baseInfoForm.goodsGalleryFiles"
|
||||
:list="selectedSku.images"
|
||||
:animation="200"
|
||||
style="display:inline-block;"
|
||||
>
|
||||
<div class="sku-upload-list" v-for="(img, __index) in selectedSku.images" :key="__index">
|
||||
<template v-if="img.status === 'finished'">
|
||||
<template>
|
||||
<img :src="img.url"/>
|
||||
<div class="sku-upload-list-cover">
|
||||
<Icon type="ios-eye-outline" @click="handleView(img.url)"></Icon>
|
||||
<Icon type="ios-trash-outline" @click="handleRemove(img, __index)"></Icon>
|
||||
<Icon type="md-search" @click="handleView(img.url)"></Icon>
|
||||
<Icon type="md-trash" @click="handleRemove(img, __index)"></Icon>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<Progress v-if="img.showProgress" :percent="img.percentage" hide-info></Progress>
|
||||
</template>
|
||||
</div>
|
||||
</vuedraggable>
|
||||
<Upload ref="uploadSku" :show-upload-list="false" :default-file-list="row.images"
|
||||
<Upload ref="uploadSku" :show-upload-list="false"
|
||||
:on-success="handleSuccess" :format="['jpg', 'jpeg', 'png']"
|
||||
:on-format-error="handleFormatError" :on-exceeded-size="handleMaxSize"
|
||||
:before-upload="handleBeforeUpload" multiple type="drag" :action="uploadFileUrl"
|
||||
@@ -425,28 +419,20 @@ export default {
|
||||
/** 商品分类中文名 */
|
||||
categoryName: []
|
||||
},
|
||||
/** 表单数据*/
|
||||
skuForm: {},
|
||||
/** 表格头 */
|
||||
skuTableColumn: [],
|
||||
/** 表格数据 */
|
||||
skuTableData: [],
|
||||
|
||||
/** 默认的规格参数 */
|
||||
skuData: [],
|
||||
|
||||
/** 默认的规格值 */
|
||||
skuVals: [],
|
||||
// 某一规格名下的规格值
|
||||
skuVal: [],
|
||||
// 规格展开的项
|
||||
open_panel: [1, 2],
|
||||
|
||||
/** 要提交的规格数据*/
|
||||
skuInfo: [],
|
||||
|
||||
/** 规格图片 */
|
||||
images: [],
|
||||
|
||||
/** 物流模板 **/
|
||||
logisticsTemplate: [],
|
||||
|
||||
@@ -491,12 +477,11 @@ export default {
|
||||
},
|
||||
/** 品牌列表 */
|
||||
brandList: [],
|
||||
collapseVal: [],
|
||||
/** 店铺分类列表 */
|
||||
shopCategory: [],
|
||||
/** 商品单位列表 */
|
||||
goodsUnitList: [],
|
||||
ignoreColumn: [
|
||||
ignoreColumn: [ // 添加规格时需要忽略的参数
|
||||
"_index",
|
||||
"_rowKey",
|
||||
"sn",
|
||||
@@ -506,8 +491,7 @@ export default {
|
||||
"quantity",
|
||||
"specId",
|
||||
"specValueId",
|
||||
],
|
||||
skuValVisible: true,
|
||||
]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -577,19 +561,23 @@ export default {
|
||||
this.previewPicture = "";
|
||||
}
|
||||
},
|
||||
// 查看商品大图
|
||||
handleViewGoodsPicture(url) {
|
||||
this.previewGoodsPicture = url;
|
||||
this.goodsPictureVisible = true;
|
||||
},
|
||||
// 移除商品图片
|
||||
handleRemoveGoodsPicture(file) {
|
||||
this.baseInfoForm.goodsGalleryFiles =
|
||||
this.baseInfoForm.goodsGalleryFiles.filter((i) => i.url !== file.url);
|
||||
},
|
||||
// 更新sku图片
|
||||
updateSkuPicture() {
|
||||
this.baseInfoForm.regeneratorSkuFlag = true;
|
||||
let _index = this.selectedSku._index;
|
||||
this.skuTableData[_index] = this.selectedSku;
|
||||
},
|
||||
// sku图片上传成功
|
||||
handleSuccess(res, file) {
|
||||
if (file.response) {
|
||||
file.url = file.response.result;
|
||||
@@ -601,26 +589,31 @@ export default {
|
||||
this.previewPicture = file.url;
|
||||
}
|
||||
},
|
||||
// 商品图片上传成功
|
||||
handleSuccessGoodsPicture(res, file) {
|
||||
console.log(res);
|
||||
if (file.response) {
|
||||
file.url = file.response.result;
|
||||
this.baseInfoForm.goodsGalleryFiles.push(file);
|
||||
}
|
||||
},
|
||||
// 图片格式不正确
|
||||
handleFormatError(file) {
|
||||
this.$Notice.warning({
|
||||
title: "文件格式不正确",
|
||||
desc: "文件 " + file.name + " 的格式不正确"
|
||||
});
|
||||
},
|
||||
// 图片大小不正确
|
||||
handleMaxSize(file) {
|
||||
this.$Notice.warning({
|
||||
title: "超过文件大小限制",
|
||||
desc: "图片 " + file.name + " 不能超过2mb"
|
||||
});
|
||||
},
|
||||
// 商品图片上传
|
||||
handleBeforeUploadGoodsPicture() {
|
||||
// 图片上传前钩子
|
||||
handleBeforeUploadGoodsPicture(file) {
|
||||
|
||||
const check = this.baseInfoForm.goodsGalleryFiles.length < 5;
|
||||
if (!check) {
|
||||
this.$Notice.warning({
|
||||
@@ -629,18 +622,15 @@ export default {
|
||||
return false
|
||||
}
|
||||
},
|
||||
// sku图片上传前钩子
|
||||
handleBeforeUpload(file) {
|
||||
const check =
|
||||
this.selectedSku.images !== undefined &&
|
||||
this.selectedSku.images.length > 5;
|
||||
if (check) {
|
||||
this.$Notice.warning({
|
||||
title: "图片数量不能大于五张",
|
||||
});
|
||||
this.$Notice.warning({ title: "图片数量不能大于五张" });
|
||||
return false
|
||||
}
|
||||
console.log(file);
|
||||
return !check;
|
||||
|
||||
},
|
||||
|
||||
/** 查询商品品牌列表 */
|
||||
|
||||
@@ -26,6 +26,7 @@ export default {
|
||||
gotoGoodsList() {
|
||||
this.$router.push({name: "goods"});
|
||||
},
|
||||
// 刷新页面
|
||||
gotoBack() {
|
||||
this.$router.go();
|
||||
},
|
||||
|
||||
@@ -1,341 +0,0 @@
|
||||
<template>
|
||||
<div class="search">
|
||||
<Card>
|
||||
<Row v-show="openSearch" @keydown.enter.native="handleSearch">
|
||||
<Form
|
||||
ref="searchForm"
|
||||
:model="searchForm"
|
||||
inline
|
||||
:label-width="70"
|
||||
class="search-form"
|
||||
>
|
||||
<Form-item label="商品名称" prop="goodsName">
|
||||
<Input
|
||||
type="text"
|
||||
v-model="searchForm.goodsName"
|
||||
placeholder="请输入商品名称"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
/>
|
||||
</Form-item>
|
||||
<span v-if="drop">
|
||||
<Form-item label="状态" prop="status">
|
||||
<Select
|
||||
v-model="searchForm.marketEnable"
|
||||
placeholder="请选择"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
>
|
||||
<Option value="DOWN">下架</Option>
|
||||
<Option value="UPPER">上架</Option>
|
||||
</Select>
|
||||
</Form-item>
|
||||
<Form-item label="商品编号" prop="sn">
|
||||
<Input
|
||||
type="text"
|
||||
v-model="searchForm.sn"
|
||||
placeholder="商品编号"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
/>
|
||||
</Form-item>
|
||||
</span>
|
||||
<Form-item style="margin-left: -35px" class="br">
|
||||
<Button @click="handleSearch" type="primary" icon="ios-search"
|
||||
>搜索</Button
|
||||
>
|
||||
<Button @click="handleReset">重置</Button>
|
||||
<a class="drop-down" @click="dropDown">
|
||||
{{ dropDownContent }}
|
||||
<Icon :type="dropDownIcon"></Icon>
|
||||
</a>
|
||||
</Form-item>
|
||||
</Form>
|
||||
</Row>
|
||||
<Row class="operation">
|
||||
<Button @click="addGoods" icon="md-refresh">添加商品</Button>
|
||||
<Button @click="getDataList" icon="md-refresh">刷新</Button>
|
||||
<Button type="dashed" @click="openSearch = !openSearch">{{
|
||||
openSearch ? "关闭搜索" : "开启搜索"
|
||||
}}</Button>
|
||||
<Button type="dashed" @click="openTip = !openTip">{{
|
||||
openTip ? "关闭提示" : "开启提示"
|
||||
}}</Button>
|
||||
</Row>
|
||||
<Row v-show="openTip">
|
||||
<Alert show-icon>
|
||||
已选择 <span class="select-count">{{ selectCount }}</span> 项
|
||||
<a class="select-clear" @click="clearSelectAll">清空</a>
|
||||
</Alert>
|
||||
</Row>
|
||||
<Table
|
||||
:loading="loading"
|
||||
border
|
||||
:columns="columns"
|
||||
:data="data"
|
||||
ref="table"
|
||||
sortable="custom"
|
||||
@on-sort-change="changeSort"
|
||||
@on-selection-change="changeSelect"
|
||||
></Table>
|
||||
<Row type="flex" justify="end" class="page">
|
||||
<Page
|
||||
:current="searchForm.pageNumber"
|
||||
:total="total"
|
||||
:page-size="searchForm.pageSize"
|
||||
@on-change="changePage"
|
||||
@on-page-size-change="changePageSize"
|
||||
:page-size-opts="[10, 20, 50]"
|
||||
size="small"
|
||||
show-total
|
||||
show-elevator
|
||||
show-sizer
|
||||
></Page>
|
||||
</Row>
|
||||
</Card>
|
||||
<Modal
|
||||
title="更新库存"
|
||||
v-model="updateStockModalVisible"
|
||||
:mask-closable="false"
|
||||
:width="500"
|
||||
>
|
||||
<Input
|
||||
type="number"
|
||||
v-model="updateStockParam.quantity"
|
||||
/>
|
||||
<div slot="footer">
|
||||
<Button type="text" @click="updateStockModalVisible = false"
|
||||
>取消</Button
|
||||
>
|
||||
<Button type="primary" @click="updateStock">更新</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
getGoodsListDataByStockSeller,
|
||||
getGoodsSkuListDataSeller,
|
||||
updateGoodsSkuStocks,
|
||||
upGoods,
|
||||
lowGoods,
|
||||
} from "@/api/goods";
|
||||
export default {
|
||||
name: "goods",
|
||||
components: {},
|
||||
data() {
|
||||
return {
|
||||
id: "", //要操作的id
|
||||
openSearch: true, // 显示搜索
|
||||
openTip: true, // 显示提示
|
||||
loading: true, // 表单加载状态
|
||||
updateStockModalVisible: false, // 更新库存模态框
|
||||
drop: false, // 搜索栏更多选项
|
||||
dropDownContent: "展开",
|
||||
dropDownIcon: "ios-arrow-down",
|
||||
searchForm: {
|
||||
// 搜索框初始化对象
|
||||
pageNumber: 1, // 当前页数
|
||||
pageSize: 10, // 页面大小
|
||||
sort: "create_time", // 默认排序字段
|
||||
order: "desc", // 默认排序方式
|
||||
},
|
||||
updateStockParam: { // 更新库存表单
|
||||
id: 0,
|
||||
quantity: 0,
|
||||
},
|
||||
form: {
|
||||
// 添加或编辑表单对象初始化数据
|
||||
goodsName: "",
|
||||
sn: "",
|
||||
marketEnable: "",
|
||||
price: "",
|
||||
sellerName: "",
|
||||
},
|
||||
selectList: [], // 多选数据
|
||||
selectCount: 0, // 多选计数
|
||||
columns: [ // 表格表头
|
||||
{
|
||||
type: "selection",
|
||||
width: 60,
|
||||
align: "center",
|
||||
},
|
||||
|
||||
{
|
||||
title: "商品缩略图",
|
||||
key: "thumbnail",
|
||||
width: 150,
|
||||
align: "center",
|
||||
render: (h, params) => {
|
||||
return h("img", {
|
||||
attrs: {
|
||||
src: params.row.thumbnail,
|
||||
alt: "加载图片失败",
|
||||
},
|
||||
style: {
|
||||
cursor: "pointer",
|
||||
width: "80px",
|
||||
height: "60px",
|
||||
margin: "10px 0",
|
||||
"object-fit": "contain",
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
title: "商品名称",
|
||||
key: "goodsName",
|
||||
minWidth: 120
|
||||
},
|
||||
|
||||
{
|
||||
title: "库存预警数量",
|
||||
key: "stockWarningNum",
|
||||
minWidth: 120
|
||||
},
|
||||
|
||||
{
|
||||
title: "商品库存",
|
||||
key: "quantity",
|
||||
minWidth: 120
|
||||
},
|
||||
|
||||
{
|
||||
title: "操作",
|
||||
key: "action",
|
||||
align: "center",
|
||||
width: 200,
|
||||
render: (h, params) => {
|
||||
return h("div", [
|
||||
h(
|
||||
"Button",
|
||||
{
|
||||
props: {
|
||||
type: "info",
|
||||
size: "small",
|
||||
},
|
||||
style: {
|
||||
marginRight: "5px",
|
||||
},
|
||||
on: {
|
||||
click: () => {
|
||||
this.getUpdateStock(params.row);
|
||||
},
|
||||
},
|
||||
},
|
||||
"库存"
|
||||
)
|
||||
]);
|
||||
},
|
||||
},
|
||||
],
|
||||
data: [], // 表单数据
|
||||
total: 0, // 表单数据总数
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
this.getDataList();
|
||||
},
|
||||
getUpdateStock(row) {
|
||||
this.updateStockParam = {skuId: row.id, quantity: row.quantity};
|
||||
this.updateStockModalVisible = true;
|
||||
},
|
||||
updateStock() {
|
||||
let updateStockList = [this.updateStockParam];
|
||||
updateGoodsSkuStocks(updateStockList).then(res => {
|
||||
if (res.success) {
|
||||
this.updateStockModalVisible = false;
|
||||
this.$Message.success("更新库存成功");
|
||||
this.getDataList();
|
||||
}
|
||||
});
|
||||
},
|
||||
changePage(v) {
|
||||
this.searchForm.pageNumber = v;
|
||||
this.getDataList();
|
||||
this.clearSelectAll();
|
||||
},
|
||||
changePageSize(v) {
|
||||
this.searchForm.pageSize = v;
|
||||
this.getDataList();
|
||||
},
|
||||
handleSearch() {
|
||||
this.searchForm.pageNumber = 1;
|
||||
this.searchForm.pageSize = 10;
|
||||
this.getDataList();
|
||||
},
|
||||
handleReset() {
|
||||
this.$refs.searchForm.resetFields();
|
||||
this.searchForm.pageNumber = 1;
|
||||
this.searchForm.pageSize = 10;
|
||||
// 重新加载数据
|
||||
this.getDataList();
|
||||
},
|
||||
changeSort(e) {
|
||||
this.searchForm.sort = e.key;
|
||||
this.searchForm.order = e.order;
|
||||
if (e.order === "normal") {
|
||||
this.searchForm.order = "";
|
||||
}
|
||||
this.getDataList();
|
||||
},
|
||||
clearSelectAll() {
|
||||
this.$refs.table.selectAll(false);
|
||||
},
|
||||
changeSelect(e) {
|
||||
this.selectList = e;
|
||||
this.selectCount = e.length;
|
||||
},
|
||||
dropDown() {
|
||||
if (this.drop) {
|
||||
this.dropDownContent = "展开";
|
||||
this.dropDownIcon = "ios-arrow-down";
|
||||
} else {
|
||||
this.dropDownContent = "收起";
|
||||
this.dropDownIcon = "ios-arrow-up";
|
||||
}
|
||||
this.drop = !this.drop;
|
||||
},
|
||||
getDataList() {
|
||||
this.loading = true;
|
||||
// 带多条件搜索参数获取表单数据
|
||||
getGoodsListDataByStockSeller(this.searchForm).then((res) => {
|
||||
this.loading = false;
|
||||
if (res.success) {
|
||||
this.data = res.result.goodsSkuIPage.records.map(i =>{
|
||||
i.stockWarningNum = res.result.stockWarningNum
|
||||
return i;
|
||||
});
|
||||
this.total = res.result.goodsSkuIPage.total;
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.init();
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.search {
|
||||
.operation {
|
||||
margin-bottom: 2vh;
|
||||
}
|
||||
.select-count {
|
||||
font-weight: 600;
|
||||
color: #40a9ff;
|
||||
}
|
||||
.select-clear {
|
||||
margin-left: 10px;
|
||||
}
|
||||
.page {
|
||||
margin-top: 2vh;
|
||||
}
|
||||
.drop-down {
|
||||
margin-left: 5px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user