Commit 5e02edce by cwq0219

多选商品-跳转

1 parent c06c9057
<!-- 选择商品弹窗 --> <!-- 选择商品弹窗 -->
<template> <template>
<glsx-dialog class="muti-pro" title="选择商品" :isVisible.sync="isMutiSelectVisible" width="70%" @confirmDialog="handleMutiSelectConfirm" @closeDialog="handleMutiSelectClose"> <glsx-dialog
<GLTable v-loading="loading" ref="mutiProRef" :tableData="productList" :hasPage="false" :noDataImg="url" :tableParams="tableParams" @refreshTable="getList"> class="muti-pro"
title="选择商品"
:isVisible.sync="isMutiSelectVisible"
:btnOkLabel="productList.length ? '确定' : '创建商品'"
width="70%"
@confirmDialog="handleMutiSelectConfirm"
@closeDialog="handleMutiSelectClose"
v-loading="loading"
>
<div class="noproDiv" v-show="!productList.length && fnCallBack">
<img src="@/assets/noPro.png" />
<p class="noproP">系统暂无已创建的商品</p>
</div>
<div v-show="productList.length">
<slot name="search"></slot>
<GLTable
v-loading="loading"
ref="mutiProRef"
:tableData="productList"
:hasPage="false"
:noDataImg="url"
:tableParams="tableParams"
@refreshTable="getList"
>
<span slot="goodsImage" slot-scope="scope"> <span slot="goodsImage" slot-scope="scope">
<img class="m-t-10 img-60" :src="scope.scope.goodsImage" /> <img class="m-t-10 img-60" :src="scope.scope.goodsImage" />
</span> </span>
</GLTable> </GLTable>
</div>
</glsx-dialog> </glsx-dialog>
</template> </template>
<script> <script>
// import { getGoodsList } from '@/api/modules/common' // import { getGoodsList } from '@/api/modules/common'
import url from "@/assets/empty.png" import url from '@/assets/empty.png'
import glsxDialog from '@/components/glsx-dialog' import glsxDialog from '@/components/glsx-dialog'
export default { export default {
name: 'selectMutiProDialog', name: 'selectMutiProDialog',
...@@ -19,7 +43,9 @@ export default { ...@@ -19,7 +43,9 @@ export default {
return { return {
// 表格组件 // 表格组件
// getListApi: this.$apis.common.getGoodsListApi, // getListApi: this.$apis.common.getGoodsListApi,
userInfo: {},
productList: [], productList: [],
fnCallBack: false,
url: url, url: url,
loading: true, loading: true,
// pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' }, // pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
...@@ -58,6 +84,10 @@ export default { ...@@ -58,6 +84,10 @@ export default {
type: Boolean, type: Boolean,
default: false default: false
}, },
searchForm: {
type: Object,
default: () => {}
},
selectedProList: { selectedProList: {
type: Array, type: Array,
default: () => [] default: () => []
...@@ -68,23 +98,26 @@ export default { ...@@ -68,23 +98,26 @@ export default {
glsxDialog glsxDialog
}, },
created() { mounted() {
this.userInfo = this.$globalState.session
this.getList(true) this.getList(true)
}, },
methods: { methods: {
getList(isMounted = false) { getList(isReset = false) {
var params = { var params = {
...this.searchForm,
goodsStatus: 1, goodsStatus: 1,
goodsSource: 1, goodsSource: 1,
pageNum: isMounted ? 1 : this.$refs.mutiProRef.page.pageNum, pageNum: isReset ? 1 : this.$refs.mutiProRef.page.pageNum,
pageSize: isMounted ? 10 : this.$refs.mutiProRef.page.pageSize pageSize: isReset ? 10 : this.$refs.mutiProRef.page.pageSize
} }
var that = this var that = this
this.loading = true this.loading = true
this.$apis.common.getGoodsListApi(params).then(res => { this.$apis.common.getGoodsListApi(params).then(res => {
this.productList = res this.productList = res
this.loading = false this.loading = false
this.fnCallBack = true
// this.$refs.mutiProRef.tableTotal = res.total // this.$refs.mutiProRef.tableTotal = res.total
this.productList.forEach(function(item) { this.productList.forEach(function(item) {
item.saleAmount = item.goodsStatistics.saleAmount item.saleAmount = item.goodsStatistics.saleAmount
...@@ -123,8 +156,19 @@ export default { ...@@ -123,8 +156,19 @@ export default {
} }
}, },
handleMutiSelectConfirm() { handleMutiSelectConfirm() {
if (!this.productList.length) {
var params = {
addOrEdit: 1,
groupOrStore: this.userInfo.accountLevel == 4 ? 2 : 1,
$title: '新建商品'
}
this.$router.push({
path: '/productGroup/editProduct',
query: params
})
return true
}
var selectedData = this.$refs.mutiProRef.mutiSelectArr[this.tableParams.mutiSelectName] var selectedData = this.$refs.mutiProRef.mutiSelectArr[this.tableParams.mutiSelectName]
// console.log(selectedData)
this.$emit('handleMutiSelectConfirm', selectedData) this.$emit('handleMutiSelectConfirm', selectedData)
}, },
handleMutiSelectClose() { handleMutiSelectClose() {
...@@ -137,4 +181,14 @@ export default { ...@@ -137,4 +181,14 @@ export default {
.muti-pro .m-t-10 { .muti-pro .m-t-10 {
margin-top: 10px; margin-top: 10px;
} }
.muti-pro .noproP {
width: 100%;
height: 20px;
font-family: PingFangSC-Medium;
font-size: 16px;
color: #666666;
line-height: 20px;
font-weight: 500;
text-align: center;
}
</style> </style>
<!-- 选择商品弹窗 --> <!-- 选择商品弹窗 -->
<template> <template>
<glsx-dialog class="muti-pro" title="选择商品" :isVisible.sync="isMutiSelectVisible" width="70%" @confirmDialog="handleMutiSelectConfirm" @closeDialog="handleMutiSelectClose" :noClose="false" :noCancel="true" :showClose="true"> <glsx-dialog
class="muti-pro"
title="选择商品"
:isVisible.sync="isMutiSelectVisible"
:btnOkLabel="productList.length ? '确定' : '创建商品'"
width="70%"
@confirmDialog="handleMutiSelectConfirm"
@closeDialog="handleMutiSelectClose"
:noClose="false"
:noCancel="true"
:showClose="true"
>
<div style="max-height:60vh"> <div style="max-height:60vh">
<div class="noproDiv" v-if="!productList.length && fnCallBack"> <div class="noproDiv" v-if="!productList.length && fnCallBack">
<img src="@/assets/noPro.png" /> <img src="@/assets/noPro.png" />
...@@ -9,14 +20,26 @@ ...@@ -9,14 +20,26 @@
<div v-if="productList.length"> <div v-if="productList.length">
<el-form :inline="true" :model="searchProForm"> <el-form :inline="true" :model="searchProForm">
<el-form-item label="商品名称:"> <el-form-item label="商品名称:">
<el-input :size="size" v-model="searchProForm.name" placeholder="请输入商品名称" maxlength="20" clearable></el-input> <el-input
:size="size"
v-model="searchProForm.name"
placeholder="请输入商品名称"
maxlength="20"
clearable
></el-input>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button :size="size" type="primary" @click="handleConfigSearch">查询</el-button> <el-button :size="size" type="primary" @click="handleConfigSearch">查询</el-button>
<el-button :size="size" @click="handleConfigReset">重置</el-button> <el-button :size="size" @click="handleConfigReset">重置</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<GLTable ref="mutiProRef" :tableData="productList" :hasPage="false" :tableParams="tableParams" @refreshTable="getList"> <GLTable
ref="mutiProRef"
:tableData="productList"
:hasPage="false"
:tableParams="tableParams"
@refreshTable="getList"
>
<span slot="goodsImage" slot-scope="scope"> <span slot="goodsImage" slot-scope="scope">
<img class="m-t-10 img-60" :src="scope.scope.goodsImage" /> <img class="m-t-10 img-60" :src="scope.scope.goodsImage" />
</span> </span>
...@@ -36,6 +59,7 @@ export default { ...@@ -36,6 +59,7 @@ export default {
// 表格组件 // 表格组件
// getListApi: this.$apis.common.getGoodsListApi, // getListApi: this.$apis.common.getGoodsListApi,
productList: [], productList: [],
userInfo: {},
// pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' }, // pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
searchProForm: { searchProForm: {
name: '' name: ''
...@@ -87,6 +111,7 @@ export default { ...@@ -87,6 +111,7 @@ export default {
}, },
mounted() { mounted() {
this.userInfo = this.$globalState.session
this.getList(true) this.getList(true)
}, },
...@@ -147,12 +172,24 @@ export default { ...@@ -147,12 +172,24 @@ export default {
} }
}, },
handleMutiSelectConfirm() { handleMutiSelectConfirm() {
if(!this.productList.length) {
var params = {
addOrEdit: 1,
groupOrStore: this.userInfo.accountLevel == 4 ? 2 : 1,
$title: '新建商品'
}
this.$router.push({
path: '/productGroup/editProduct',
query: params
})
return true
}
var selectedData = this.$refs.mutiProRef.mutiSelectArr[this.tableParams.mutiSelectName] var selectedData = this.$refs.mutiProRef.mutiSelectArr[this.tableParams.mutiSelectName]
// console.log(selectedData)
if (!selectedData) { if (!selectedData) {
this.$message({ this.$message({
message: '未选择商品', message: '未选择商品',
type: 'error' type: 'error',
customClass: 'message-Z-zinde'
}) })
return return
} }
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<el-button type="primary" @click="handleConfirm">确定</el-button> <el-button type="primary" @click="handleConfirm">确定</el-button>
<el-button type="default" @click="handleCancel">取消</el-button> <el-button type="default" @click="handleCancel">取消</el-button>
</div> </div>
<select-muti-pro-dialog v-if="isMutiSelectVisible" :isMutiSelectVisible="isMutiSelectVisible" :searchForm="searchProForm" :selectedProList="selectedProList" @handleMutiSelectConfirm="handleMutiSelectConfirm" @handleMutiSelectClose="handleMutiSelectClose"> <select-muti-pro-dialog ref="classMutiProRef" v-if="isMutiSelectVisible" :isMutiSelectVisible="isMutiSelectVisible" :searchForm="searchProForm" :selectedProList="selectedProList" @handleMutiSelectConfirm="handleMutiSelectConfirm" @handleMutiSelectClose="handleMutiSelectClose">
<!-- <template slot="search"> <!-- <template slot="search">
<div class="flex"> <div class="flex">
<el-form :inline="true" :model="searchProForm"> <el-form :inline="true" :model="searchProForm">
...@@ -150,8 +150,16 @@ export default { ...@@ -150,8 +150,16 @@ export default {
}) })
}) })
}, },
handleConfigSearch() {
this.$refs.classMutiProRef.getList()
},
handleConfigReset() {
this.searchProForm = {
name: ''
}
this.handleConfigSearch()
},
handleMutiProClose(targetItem) { handleMutiProClose(targetItem) {
// console.log(targetItem)
this.selectedProList = this.$common.utils.deepClone(this.editForm.goodsRefList) this.selectedProList = this.$common.utils.deepClone(this.editForm.goodsRefList)
this.handleMutiSelectClose() this.handleMutiSelectClose()
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!