Commit b0c35adf by zhangquan

提交代码

1 parent 94cced33
...@@ -18,7 +18,6 @@ const getCategoryListApi = params => { ...@@ -18,7 +18,6 @@ const getCategoryListApi = params => {
reject() reject()
}) })
} }
console.log(params, '8888')
params.method = 'scrm.api.shopmall.discover.category.page' params.method = 'scrm.api.shopmall.discover.category.page'
return http({ return http({
url, url,
......
<template>
<div class="goods-ctnr">
<div class="container">
<glsx-combi-form :isInline="false" class="glsx-combi-form" ref="baseInfoRef" labelWidth="154px" defaultWidth="432px" :formObj.sync="formObj" :formData="formData" :formRules="myRule">
<div slot="selectBtnSlot">
<el-button class="el-icon-plus" size="small" @click="openGoodsDialog">选择商品</el-button>
</div>
<div slot="goodsInfoSlot" class="goods-wrap">
<glsx-combi-form :isInline="false" ref="goodsInfoRef" labelWidth="154px" defaultWidth="432px" :formObj.sync="formObj" :formData="goodsFormData" :formRules="goodsRule">
<div slot="uploadSlot">
<glsx-preview :picOptions="posterOptions" :imageUrlArr="formObj.coverList" @change="changeChannelImg"></glsx-preview>
</div>
</glsx-combi-form>
</div>
<div slot="saleStoreSlot">
<el-button v-if="!disabled" class="el-icon-plus" size="small" @click="closeDialog">选择门店</el-button>
<template v-if="merchantRequestList && merchantRequestList.length">
<GLTable class="selected-table" :hasPage="false" ref="selectedRef" :tableParams="selectedtableParams" :tableData="merchantRequestList">
<div slot="activityPriceSlot" slot-scope="scope">
<format-input :disabled="disabled" :intDigit="6" :precise="2" placeholder="请输入" v-model="scope.scope.activityPrice"></format-input>
</div>
<div slot="giveIntegralSlot" slot-scope="scope">
<format-input :disabled="disabled" :intDigit="6" :precise="2" placeholder="请输入" v-model="scope.scope.giveIntegral"></format-input>
</div>
<div slot="auth-button" slot-scope="scope">
<el-button v-if="!disabled" type="text" @click="handleDel(scope.scope)">删除</el-button>
</div>
</GLTable>
</template>
</div>
<div slot="expressFeeSlot">
<format-input :disabled="disabled" :intDigit="4" :precise="2" v-model="formObj.expressFee"></format-input>
</div>
</glsx-combi-form>
</div>
<GLFooter style="margin-top: 16px;">
<el-button @click="handleCancel">取消</el-button>
<el-button v-if="!disabled" type="primary" @click="handleSave">确定</el-button>
</GLFooter>
<selectGoods v-if="goodsVisible" :routeInfo="routeInfo" :dialogVisible="goodsVisible" :goodsInfo="formObj" @handleGoodsConfirm="handleGoodsConfirm" @handleGoodsClose="handleGoodsClose"></selectGoods>
<selectMerchantDialog @confirmDialog="confirmDialog" @closeDialog="closeDialog" :goodsId="formObj.smartcarlifeInfoId" :selectedList="merchantRequestList" v-if="merchantDialogVisible" :isVisible="merchantDialogVisible"></selectMerchantDialog>
</div>
</template>
<script>
const MerchantColumns = [
{
label: '门店名称',
prop: 'merchantName'
},
{
label: '门店价格(元)',
width: 220,
addHtml: 'activityPriceSlot'
},
{
label: '赠送积分',
width: 220,
addHtml: 'giveIntegralSlot'
}
]
import glsxCombiForm from '@/components/glsx-combi-form'
import selectGoods from './components/selectGoods'
import selectMerchantDialog from './components/selectMerchantDialog'
export default {
name: 'add',
components: {
glsxCombiForm,
selectGoods,
selectMerchantDialog
},
data() {
return {
goodsVisible: false,
merchantDialogVisible: false,
disabled: false,
goodsInfo: {},
posterOptions: {
width: '104px',
height: '104px',
key: 'posterImg',
isClose: true
},
goodsFormData:[
{
label: '商品图',
addHtml: 'uploadSlot',
isDisabled: false
},
{
label: '商品名称',
name: 'goodsName',
maxlength: 20,
showLimit: true,
type: 'input',
isDisabled: false
},
{
label: '售价(元)',
name: 'retailPrice',
type: 'showTxt'
},
{
label: '最低售价(元)',
name: 'minSellPrice',
type: 'showTxt'
},
],
formObj:{
source: '2',
channelType: '6',
method: '2',
expressFee: '',
smartcarlifeInfoId: '',
goodsName: '',
goodsImage: '',
minSellPrice: '',
retailPrice: '',
coverList: [],
associationClassifyFirstId: '',
introduction: ''
},
merchantRequestList:[],
goodsList: [],
myRule: {
selectBtnSlot: [
{
required: true,
validator: (rule, value, callback) => {
if(!this.formObj.smartcarlifeInfoId){
callback(new Error('请选择商品'))
}else{
callback()
}
},
trigger: 'change'
}
],
goodsInfoSlot: [{
required: true,
validator: (rule, value, callback) => {
if(!this.formObj.coverList && !this.formObj.coverList[0]){
callback(new Error('请上传商品图'))
}else if(!this.formObj.goodsName){
callback(new Error('请输入商品名称'))
}else{
callback()
}
},
trigger: 'change'
}],
saleStoreSlot: [{
required: true,
validator: (rule, value, callback) => {
const _target = this.merchantRequestList.find(item => !item.activityPrice)
const _integralTarget = this.merchantRequestList.find(item => !item.giveIntegral)
if(!this.merchantRequestList.length){
callback(new Error('请选择门店'))
}else if(_target){
callback(new Error('请输入门店活动价'))
}else if(_integralTarget){
callback(new Error('请输入赠送积分'))
}else{
callback()
}
},
trigger: 'change'
}],
associationClassifyFirstId: [{required: true, message: '请选择关联商品分类', trigger: 'change'}],
source: [{required: true, message: '请选择来源', trigger: 'change'}],
method: [{required: true, message: '请选择配送方式', trigger: 'change'}],
expressFee: [{required: true, message: '请输入运费', trigger: 'change'}],
},
formData:[
{
label: '关联商品分类',
name: 'associationClassifyFirstId',
type: 'select',
optionList: [],
optionId: 'id',
optionLabel: 'categoryName',
isDisabled: false
},
{
label: '来源',
name: 'source',
type: 'radio',
optionList: [{
confId: '2',
confName: '嘀加智享平台'
}],
optionId: 'confId',
optionLabel: 'confName',
isDisabled: false
},
{
label: '选择商品',
name: 'selectBtnSlot',
addHtml: 'selectBtnSlot',
isDisabled: false
},
{
label: '商品信息',
name: 'goodsInfoSlot',
addHtml: 'goodsInfoSlot',
isDisabled: false
},
{
label: '销售门店',
name: 'saleStoreSlot',
addHtml: 'saleStoreSlot',
isDisabled: false
},
{
label: '配送方式',
name: 'method',
type: 'radio',
optionList: [{
confId: '2',
confName: '快递发货'
}],
optionId: 'confId',
optionLabel: 'confName',
isDisabled: false
},
{
label: '运费/元',
name: 'expressFee',
addHtml: 'expressFeeSlot',
isDisabled: false
},
{
label: '服务说明',
name: 'introduction',
type: 'input',
inputType: 'textarea',
isDisabled: false
},
],
selectedtableParams: {
listName: 'list',
tableOption: {
width: 100
},
tableColumns: MerchantColumns
}
}
},
created(){
this.getCategory()
const urlParam = this.$route.params
this.routeInfo = JSON.parse(decodeURIComponent(urlParam.id))
const { id, type } = this.routeInfo
if(type == 1) {
this.disabled = true
this.posterOptions.isClose = false
const _target = this.goodsFormData.find(item => item.name == 'goodsName')
_target.isDisabled = true
this.selectedtableParams.tableOption = null
}
if(id){
this.getDetail()
}
},
methods:{
getCategory(){
const params = {
pageSize: 10000,
pageNum: 1,
categoryType: 2
}
this.$apis.category.getCategoryListApi(params).then(res => {
if(res?.list?.length){
const _target = this.formData.find(item => item.name == 'associationClassifyFirstId')
_target.optionList = res.list
}
})
},
validateField(field){
if(Array.isArray(field)){
field.forEach(item => {
this.$refs.baseInfoRef.$refs.formRef.validateField(item)
})
}else{
this.$refs.baseInfoRef.$refs.formRef.validateField(field)
}
},
openGoodsDialog(){
if(this.disabled) return
this.goodsVisible = true
},
handleGoodsClose(){
this.goodsVisible = false
},
handleGoodsConfirm(e){
if(this.formObj.smartcarlifeInfoId!=e?.id) this.merchantRequestList = []
let { id: smartcarlifeInfoId, goodsName, goodsImage, minSellPrice, retailPrice } = e || {}
minSellPrice = minSellPrice ? Number(Number(minSellPrice/100).toFixed(2)) : 0
retailPrice = retailPrice ? Number(Number(retailPrice/100).toFixed(2)) : 0
this.formObj = {...this.formObj, smartcarlifeInfoId, goodsName, goodsImage, coverList: [goodsImage], minSellPrice, retailPrice}
this.handleGoodsClose()
this.validateField(['selectBtnSlot','goodsInfoSlot'])
},
confirmDialog(e){
this.merchantRequestList = e || []
this.merchantRequestList.map(item => this.$set(item, 'giveIntegral', ''))
this.validateField('saleStoreSlot')
this.closeDialog()
},
closeDialog(){
if(!this.merchantDialogVisible && !this.formObj.smartcarlifeInfoId){
return this.$message.error('请先选择商品')
}
this.merchantDialogVisible = !this.merchantDialogVisible
},
handleDel(row) {
const idx = this.merchantRequestList.findIndex(item => item.id == row.id)
this.merchantRequestList.splice(idx, 1)
},
getParams(){
let obj = JSON.parse(JSON.stringify(this.formObj))
obj.goodsImage = obj.coverList[0]
delete obj.minSellPrice
delete obj.retailPrice
delete obj.coverList
delete obj.source
delete obj.method
let merchantRequestList = this.merchantRequestList.map(item => {
let { merchantId, merchantName, activityPrice, giveIntegral } = item
activityPrice = activityPrice ? Number(Number(activityPrice*10*10).toFixed(0)) : 0
return {merchantId , merchantName, activityPrice, giveIntegral}
})
const params = {
merchantRequestList,
...obj
}
if(this.routeInfo.id) params.id = this.routeInfo.id
return params
},
handleSave(){
this.$refs.baseInfoRef.$refs.formRef.validate(valid => {
if(valid){
const params = this.getParams()
this.$apis.goods.addGoodsApi(params).then(res =>{
if(res) {
this.$message.success('新增成功')
this.handleCancel()
}
})
}
})
},
handleCancel(){
this.$router.back()
},
getDetail(){
const params = {
id: this.routeInfo.id
}
if(this.routeInfo.merchantId) params.merchantId= this.routeInfo.merchantId
this.$apis.goods.getGoodsDetail(params).then(res => {
if(res) {
for(const key in this.formObj){
const formatAttr = ['depositPrice', 'minSellPrice', 'retailPrice']
if(formatAttr.includes(key)){
this.formObj[key] = res[key] ? Number(Number(res[key]/100).toFixed(2)) : 0
}else{
this.formObj[key] = res[key]
}
}
this.curCategoryInfo = {
categoryName: res.associationClassifySecondName,
id: res.associationClassifySecondId
}
this.formObj.coverList = [res.goodsImage]
this.merchantRequestList = res.merchantList?.map(item => {
let activityPrice = item.activityPrice ? Number(Number(item.activityPrice/100).toFixed(2)) : 0
return {...item, activityPrice}
}) || []
}
})
}
}
}
</script>
<style scoped lang="scss">
.container{
background-color: #fff;
.disabled-class{
cursor: not-allowed;
color: #666666;
}
.goods-wrap{
padding: 20px 20px 1px;
width: 866px;
background: #F9F9F9;
border-radius: 4px;
}
.selected-table {
margin-top: 10px;
width: 100%;
max-width: 750px;
.el-button--text{
padding: 0;
}
}
}
</style>
\ No newline at end of file \ No newline at end of file
...@@ -94,7 +94,7 @@ export default { ...@@ -94,7 +94,7 @@ export default {
methods: { methods: {
getCategory(){ getCategory(){
const params = { const params = {
pageSize: 1000, pageSize: 10000,
pageNum: 1, pageNum: 1,
categoryType: 1 categoryType: 1
} }
......
<template> <template>
<div class="goods-list-cntr"> <div class="goods-list-cntr">
<!-- <GLTabs v-model="activeName" :tabPaneList="tabPaneList" @tab-click="handleClick"></GLTabs> --> <GLTabs v-model="activeName" :tabPaneList="tabPaneList" @tab-click="handleClick"></GLTabs>
<div class="table-wrap"> <preferList v-if="activeName == 'carOwner'"></preferList>
<div v-else class="table-wrap">
<GLCombiForm ref="showSearch" class="search-wrap" :rowNumber="1" :formObj="tableSearchForm" :formData="searchFormData" @handleOk="handleSearch" @handleRest="handleReset"> <GLCombiForm ref="showSearch" class="search-wrap" :rowNumber="1" :formObj="tableSearchForm" :formData="searchFormData" @handleOk="handleSearch" @handleRest="handleReset">
<div slot="categorySlot"> <div slot="categorySlot">
<brandCascader ref="cascaderRef" @clickItem="selectCategory" class="category-slot-class"></brandCascader> <brandCascader ref="cascaderRef" @clickItem="selectCategory" class="category-slot-class"></brandCascader>
...@@ -51,10 +52,12 @@ ...@@ -51,10 +52,12 @@
<script> <script>
import url from '@/assets/empty.png' import url from '@/assets/empty.png'
import brandCascader from './components/brandCascader' import brandCascader from './components/brandCascader'
import preferList from './preferList'
export default { export default {
name: 'App', name: 'App',
components: { components: {
brandCascader, brandCascader,
preferList
}, },
data() { data() {
return { return {
...@@ -65,7 +68,8 @@ ...@@ -65,7 +68,8 @@
associationClassifySecondId: '', associationClassifySecondId: '',
merchantName: '' merchantName: ''
}, },
tabPaneList: [{name: 'sa', label: '配置升级'}, {name: 'sa', label: '车主优选'}], activeName: 'sa',
tabPaneList: [{name: 'sas', label: '配置升级'}, {name: 'carOwner', label: '车主优选'}],
buttonList: [ buttonList: [
{ {
type: 'el-button', type: 'el-button',
......
<template>
<div class="prefer-list-cntr">
<div class="table-wrap">
<GLCombiForm ref="showSearch" class="search-wrap" :rowNumber="1" :formObj="tableSearchForm" :formData="searchFormData" @handleOk="handleSearch" @handleRest="handleReset">
</GLCombiForm>
<div class="operate-wrap">
<span class="table-title">车主优选商品列表</span>
<el-button class="operate-btn" type="primary" size="small" @click="handleAdd">新增商品</el-button>
</div>
<GLTable ref="channelRef" :getListApi="getListApi" :noDataImg="url" :searchForm="searchForm" :beforeSearchFn="beforeSearchFn" :tableParams="tableParams" :pageConf="pageConf" @setTableFinishFun="setTableFinishFun">
<div slot="imageSlot" class="table-image" slot-scope="scope">
<el-popover placement="top" width="160" trigger="hover" popper-class="table-popover-block">
<img class="table-popover-img" :src="scope.scope.goodsImage" />
<img class="img-36 pointer" slot="reference" :src="scope.scope.goodsImage" />
</el-popover>
</div>
<div slot="statusSlot" slot-scope="scope">
<span :class="['status', scope.scope.goodsStatus==1 ? 'success-status': 'error-status']"></span>
<span>{{scope.scope.goodsStatus==1 ? '上架' : '下架' }}</span>
</div>
<div slot="merchantPriceSlot" slot-scope="scope">
<template v-if="scope.scope.merchantList && scope.scope.merchantList.length > 1">
<span>{{ filterData(scope.scope).slice(0, 1).join('、') }}</span>
<el-popover
placement="top"
width="400"
trigger="hover">
<div v-for="(item,index) in filterData(scope.scope)" :key="index">
{{item}}
</div>
<span class="more-info" slot="reference">...[{{ scope.scope.merchantList.length }}]</span>
</el-popover>
</template>
<template v-else>
<span v-if="!scope.scope.merchantList || !scope.scope.merchantList.length">--</span>
<span v-else>{{ filterData(scope.scope).join('、') }}</span>
</template>
</div>
<div class="table-btns" slot="auth-button" slot-scope="scope">
<GLTableButton :buttonList="buttonList" :buttonItem="scope" :buttonNum="4"></GLTableButton>
</div>
</GLTable>
</div>
</div>
</template>
<script>
import url from '@/assets/empty.png'
export default {
name: 'App',
data() {
return {
tableSearchForm: {
channelName: '',
createDate: [],
associationClassifyFirstId: '',
associationClassifySecondId: '',
merchantName: '',
channelType: 6
},
tabPaneList: [{name: 'sa', label: '配置升级'}, {name: 'sa', label: '车主优选'}],
buttonList: [
{
type: 'el-button',
name: '查看',
attrs: {
type: 'text',
fn: '查看'
},
listeners: {
click: row => this.handleAdd(row.scope, 1)
}
},
{
type: 'el-button',
name: '编辑',
attrs: {
type: 'text',
fn: '编辑'
},
listeners: {
click: row => this.handleAdd(row.scope, 2)
}
},
{
type: 'el-button',
name: '上架',
attrs: {
type: 'text',
fn: '上架'
},
condition: row => {
return row.scope.goodsStatus!=1
},
listeners: {
click: row => this.shelfGoodsFn(row.scope, 1)
}
},
{
type: 'el-button',
name: '下架',
attrs: {
type: 'text',
fn: '下架'
},
condition: row => {
return row.scope.goodsStatus==1
},
listeners: {
click: row => this.shelfGoodsFn(row.scope, 0)
}
},
{
type: 'el-button',
name: '删除',
attrs: {
type: 'text',
fn: '删除'
},
condition: row => {
return row.scope.goodsStatus!=1
},
listeners: {
click: row => this.delGoodsFn(row.scope)
}
}
],
searchForm: {},
url: url,
searchFormData: [
{
label: '分类名称',
name: 'goodsName',
type: 'input'
},
{
label: '创建日期',
name: 'createDate',
type: 'datePicker',
isClear: true,
customPickerOptions: {
disabledDate(date) {
const yesterday = new Date(new Date().setDate(new Date().getDate()))
if (date > yesterday) {
return true
}
return false
}
}
},
{
label: '分类名称',
name: 'goodsName',
type: 'select',
optionList: [],
optionId: 'confId',
optionLabel: 'confName'
},
{
label: '来源',
name: 'source',
type: 'select',
optionList: [
{
id: '',
name: '全部'
},
{
id: '1',
name: '云中鹤'
},
{
id: '2',
name: '嘀加智享'
},
],
optionId: 'id',
optionLabel: 'name'
},
],
getListApi: this.$apis.goods.getGoodsListApi,
tableParams: {
listName: 'list',
tableOption: {
width: 200
},
tableColumns: [
{
label: '来源',
prop: 'sourse'
},
{
label: '商品名称',
width: 150,
prop: 'goodsName'
},
{
label: '缩略图',
addHtml: 'imageSlot'
},
{
label: '供货价格(元)',
formatter: cellValue => {
return cellValue.paymentType==1 ? '全款' : '定金+尾款'
}
},
{
label: '市场价格(元)',
formatter: cellValue => {
return cellValue.depositPrice ? Number((Number(cellValue.depositPrice)/100).toFixed(2)) : '--'
}
},
{
label: '销售价格(元)',
width: 200,
addHtml: 'merchantPriceSlot'
},
{
label: '赠送积分',
formatter: cellValue => {
return `${cellValue.associationClassifyFirstName||''}-${cellValue.associationClassifySecondName||''}`
}
},
{
label: '使用积分',
formatter: cellValue => {
return `${cellValue.associationClassifyFirstName||''}-${cellValue.associationClassifySecondName||''}`
}
},
{
label: '商品分类',
formatter: cellValue => {
return `${cellValue.associationClassifyFirstName||''}-${cellValue.associationClassifySecondName||''}`
}
},
{
label: '状态',
addHtml: 'statusSlot'
},
{
label: '创建日期',
prop: 'createdDate',
width: 220
},
{
label: '更新时间',
prop: 'updatedDate',
width: 220
},
{
label: '操作人',
prop: 'operator',
},
]
},
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' }
}
},
created() {},
mounted() {},
methods: {
selectCategory(e){
this.tableSearchForm.associationClassifyFirstId = e?.parent?.id
this.tableSearchForm.associationClassifySecondId = e?.data?.id
},
shelfGoodsFn(item, type){
if(type==1){
this.updateStatus(item.id, type)
}else{
this.$confirm(`确定下架该商品吗`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
callback: action => {
if (action == 'confirm') {
this.updateStatus(item.id, type)
}
}
})
}
},
delGoodsFn(item){
this.$confirm(`确定删除该商品吗`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
callback: action => {
if (action == 'confirm') {
this.$apis.goods.delGoodsApi({id: item.id}).then(res =>{
if(res){
this.$message.success('删除成功')
this.handleSearch()
}
})
}
}
})
},
updateStatus(id, goodsStatus){
this.$apis.goods.updateGoodsStatusApi({id, goodsStatus}).then(res =>{
if(res){
this.$message.success('操作成功')
this.handleSearch()
}
})
},
filterData({merchantList: list}){
return list?.map(item => {
let activityPrice = item.activityPrice ? Number((Number(item.activityPrice)/100).toFixed(2)) : 0
return `${item.merchantName || '--'}:${activityPrice || '0'}`
}) || []
},
getParams() {
var params = JSON.parse(JSON.stringify(this.tableSearchForm))
if (this.tableSearchForm.createDate.length) {
params.createdDateStrat = new Date(this.tableSearchForm.createDate[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
params.createdDateEnd = new Date(this.tableSearchForm.createDate[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
}
return params
},
beforeSearchFn() {
return new Promise(resolve => {
this.searchForm = this.getParams()
delete this.searchForm.createDate
resolve()
})
},
handleSearch() {
this.$refs.channelRef.refreshTable()
},
handleReset() {
this.tableSearchForm = {
channelName: '',
channelType: '6',
createDate: [],
associationClassifyFirstId: '',
associationClassifySecondId: '',
merchantName: ''
},
this.$refs?.cascaderRef?.curBrand && (this.$refs.cascaderRef.curBrand = {})
this.searchForm = {}
this.handleSearch()
},
setTableFinishFun() {
//接收到的数据为空
this.$refs.channelRef.data.length ? (this.$refs.channelRef.tableHeightValues = '') : this.$refs.channelRef.setTableHeightFun()
},
handleAdd(row={},type){
const params = {}
let title = '新增商品'
if(type){
params.id = row.id
params.type = type
title = type == 1 ? '查看商品' : '编辑商品'
}
const queryStr = encodeURIComponent(JSON.stringify(params))
this.$router.push({ path: `/goods/addPrefer/`+queryStr,query: { $title: title }})
}
}
}
</script>
<style scoped lang="scss">
.prefer-list-cntr{
.table-wrap{
margin-top: 16px;
padding: 20px;
background-color: #fff;
.status{
width: 6px;
height: 6px;
border-radius: 50%;
display: inline-block;
vertical-align: middle;
margin-right: 8px;
}
.success-status{
background-color: #37C67F;
}
.error-status{
background-color: #999999;
}
.more-info{
white-space: nowrap;
color: #5850FF;
cursor: pointer;
}
}
}
</style>
\ No newline at end of file \ No newline at end of file
...@@ -257,6 +257,12 @@ ...@@ -257,6 +257,12 @@
this.loading = false this.loading = false
}) })
}, },
flatData(list){
// let
// list.forEach(item =>{
// })
},
handleConfirm(){ handleConfirm(){
console.log(this.selectdData) console.log(this.selectdData)
this.$emit('handleConfirm', this.selectdData) this.$emit('handleConfirm', this.selectdData)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!