Commit 5570f6ee authored by dragondean@qq.com's avatar dragondean@qq.com

批量設置路線價格可以勾選篩選結果

parent 088a5859
...@@ -61,6 +61,15 @@ export function getProductPage(query) { ...@@ -61,6 +61,15 @@ export function getProductPage(query) {
}) })
} }
// 获得产品ID
export function getProductIds(params) {
return request({
url: '/ecw/product/simpleIdList',
params,
method: 'get'
})
}
// 导出产品 Excel // 导出产品 Excel
export function exportProductExcel(query) { export function exportProductExcel(query) {
return request({ return request({
......
...@@ -3,18 +3,19 @@ ...@@ -3,18 +3,19 @@
<div class="flex-1"> <div class="flex-1">
<el-card> <el-card>
<div slot="header" class="header"> <div slot="header" class="header">
<el-select v-model="queryParams.typeId" :placeholder="$t('选择类型')" style="width:120px" clearable> <el-select v-model="queryParams.typeId" :placeholder="$t('选择类型')" style="width:120px" clearable @change="getList" :disabled="loading">
<el-option v-for="item in typeList" :key="item.id" :label="item.titleZh" :value="item.id" /> <el-option v-for="item in typeList" :key="item.id" :label="item.titleZh" :value="item.id" />
</el-select> </el-select>
<el-select v-model="queryParams.attrId" :placeholder="$t('选择属性')" style="width:120px" clearable> <el-select v-model="queryParams.attrId" :placeholder="$t('选择属性')" style="width:120px" clearable @change="getList" :disabled="loading">
<el-option v-for="item in attrList" :key="item.id" :label="item.attrName" :value="item.id" /> <el-option v-for="item in attrList" :key="item.id" :label="item.attrName" :value="item.id" />
</el-select> </el-select>
<el-input v-model="queryParams.titleZh" :placeholder="$t('产品关键字')" style="width:120px" clearable /> <el-input v-model="queryParams.titleZh" :placeholder="$t('产品关键字')" style="width:120px" clearable :disabled="loading"/>
<el-button type="primary" @click="reLoad">{{$t('搜索')}}</el-button> <el-button type="primary" @click="reLoad" :loading="loading">{{$t('搜索')}}</el-button>
<div v-if="showAll"> <div v-if="showAll">
<el-checkbox :label="$t('全选') + `(${total > 500 ? $t('最多500') : $t('{total}个', {total})})`" @change="toggleAll" :disabled="isAllProduct"></el-checkbox> <el-checkbox :label="$t('全选') + `(${total > 500 ? $t('最多500') : $t('{total}个', {total})})`" @change="toggleAll" :disabled="isAllProduct || loading"></el-checkbox>
<el-checkbox :label="$t('全选库内商品(共{cnt}个)', {cnt: allTotal})" v-model="isAllProduct"></el-checkbox> <el-checkbox :label="$t('全选库内商品(共{cnt}个)', {cnt: allTotal})" v-model="isAllProduct" :disabled="loading"></el-checkbox>
<el-checkbox v-if="showFiltered && enableFiltered" :label="$t('根据商品搜索结果(共{cnt}个)', {cnt: total})" v-model="isAllFiltered" :disabled="loading"></el-checkbox>
</div> </div>
</div> </div>
<div class="list"> <div class="list">
...@@ -28,9 +29,9 @@ ...@@ -28,9 +29,9 @@
<div class="flex-1 ml-10"> <div class="flex-1 ml-10">
<el-card style="height:100%"> <el-card style="height:100%">
<div slot="header" class="header flex"> <div slot="header" class="header flex">
<div class="flex-1 flex items-center">{{$t('已选{cnt}个产品', {cnt: isAllProduct ? total : choosedList.length})}}</div> <div class="flex-1 flex items-center">{{$t('已选{cnt}个产品', {cnt: isAllProduct || isAllFiltered ? total : choosedList.length})}}</div>
<el-button v-if="choosedList.length" type="text" @click="clearAll">{{$t('全部清除')}}</el-button> <el-button :disabled="!choosedList.length" type="text" @click="clearAll">{{$t('全部清除')}}</el-button>
</div> </div>
<div class="list"> <div class="list">
<div class="item" v-for="(choosed) in choosedList" :key="choosed.id" :data-data="JSON.stringify(choosed)"> <div class="item" v-for="(choosed) in choosedList" :key="choosed.id" :data-data="JSON.stringify(choosed)">
...@@ -43,7 +44,7 @@ ...@@ -43,7 +44,7 @@
</div> </div>
</template> </template>
<script> <script>
import { getProductPage, getProductList } from '@/api/ecw/product' import {getProductPage, getProductList, getProductIds} from '@/api/ecw/product'
import { getProductTypeList } from '@/api/ecw/productType' import { getProductTypeList } from '@/api/ecw/productType'
import { getProductAttrList } from '@/api/ecw/productAttr' import { getProductAttrList } from '@/api/ecw/productAttr'
...@@ -56,10 +57,13 @@ export default { ...@@ -56,10 +57,13 @@ export default {
} }
}, },
showAll: Boolean, showAll: Boolean,
isall: Boolean isall: Boolean,
// 是否允许勾选全部搜索结果,优惠券那边无法回显所以不能启用,编辑路线价格等不需要回显的场景可以启用
enableFiltered: Boolean
}, },
data() { data() {
return { return {
loading: false,
list: [], list: [],
page: 1, page: 1,
pages: 1, pages: 1,
...@@ -75,7 +79,10 @@ export default { ...@@ -75,7 +79,10 @@ export default {
choosedList: [], choosedList: [],
typeList: [], typeList: [],
attrList: [], attrList: [],
isAllProduct: false isAllProduct: false,
isAllFiltered: false, // 是否全部搜索结果
// 是否显示搜索结果勾选,有筛选条件才显示
showFiltered: false
} }
}, },
computed: { computed: {
...@@ -101,6 +108,11 @@ export default { ...@@ -101,6 +108,11 @@ export default {
this.choosedList = [] this.choosedList = []
this.$emit('setall', isAllProduct) this.$emit('setall', isAllProduct)
}, },
isAllFiltered(isAllFiltered){
this.choosedList = []
this.isAllProduct = false
this.$emit('setFiltered', isAllFiltered)
},
defaultIds(newValue, oldValue){ defaultIds(newValue, oldValue){
if(!oldValue || !oldValue.length){ if(!oldValue || !oldValue.length){
this.loadDefaultProds() this.loadDefaultProds()
...@@ -158,21 +170,23 @@ export default { ...@@ -158,21 +170,23 @@ export default {
this.getList() this.getList()
}, },
getList() { getList() {
this.loading = true
getProductPage(this.queryParams).then(res => { getProductPage(this.queryParams).then(res => {
this.list = res.data.list //.concat(res.data.list || []) this.list = res.data.list //.concat(res.data.list || [])
this.page = res.data.page this.page = res.data.page
this.pages = res.data.pages this.pages = res.data.pages
this.total = res.data.total this.total = res.data.total
// this.choosedList = [] //搜搜重置,数据回显
/* if (this.defaultIds.length > 0) { // 必须在搜索之后才显示勾选,这个时候才有数量
this.defaultIds.map(item => { this.showFiltered = !!this.queryParams.attrId || !!this.queryParams.titleZh || !!this.queryParams.typeId
this.list.map(items => { }).finally(() => {
if (items.id == item) { this.loading = false
this.choosedList.push(items)
}
})
}) })
} */ },
// 获得指定条件的商品的全部ID
getFilteredIds(){
return getProductIds(this.queryParams).then(res => {
return res.data
}) })
}, },
toggleCheck(item, checked) { toggleCheck(item, checked) {
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
<el-table-column :label="$t('结束时间')" align="center" prop="endTime" width="180"> <el-table-column :label="$t('结束时间')" align="center" prop="endTime" width="180">
<template slot-scope="{row}"> <template slot-scope="{row}">
<div :style="{color: !row.overdueStatus ? 'red' : null}">{{ parseTime(row.endTime, '{y}-{m}-{d}') }}</div> <div :style="{color: !row.overdueStatus ? 'red' : null}">{{ parseTime(row.endTime, '{y}-{m}-{d}') }}</div>
<div v-if="!row.overdueStatus" style="color: red">{{ $t('已过期') }}</div> <div style="color: red">{{ !row.overdueStatus ? $t('已过期') : expireTips(row.endTime) }}</div>
</template> </template>
</el-table-column> </el-table-column>
<!-- <!--
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
v-hasPermi="['ecw:coupon:update']">{{ $t('编辑') }}</el-button> v-hasPermi="['ecw:coupon:update']">{{ $t('编辑') }}</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleCopy(scope.row)" <el-button size="mini" type="text" icon="el-icon-edit" @click="handleCopy(scope.row)"
v-hasPermi="['ecw:coupon:copy']">{{ $t('复制') }}</el-button> v-hasPermi="['ecw:coupon:copy']">{{ $t('复制') }}</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="updateEndtimeItem = scope.row" v-if="scope.row.endTime && scope.row.status" <el-button size="mini" type="text" icon="el-icon-edit" @click="updateEndtimeItem = scope.row" v-if="scope.row.endTime"
v-hasPermi="['ecw:coupon:delay']">{{ $t('延期') }}</el-button> v-hasPermi="['ecw:coupon:delay']">{{ $t('延期') }}</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
v-hasPermi="['ecw:coupon:delete']">{{ $t('删除') }}</el-button> v-hasPermi="['ecw:coupon:delete']">{{ $t('删除') }}</el-button>
...@@ -232,6 +232,27 @@ export default { ...@@ -232,6 +232,27 @@ export default {
{required: !this.updateEndtimeForm.forever, message: "请填写结束时间"} {required: !this.updateEndtimeForm.forever, message: "请填写结束时间"}
] ]
} }
},
expireTips(){
return endTime => {
if(!endTime) return ''
console.log({endTime})
// 7天以内用红色标注提醒:“还有N天到期”,最后一天显示1天过期
let endDate = new Date(endTime.replace(/-/g, '/'))
if(endDate.getHours() == 0){
endDate.setHours(23)
endDate.setMinutes(59)
endDate.setSeconds(59)
}
let now = new Date()
let diff = endDate.getTime() - now.getTime()
let days = Math.ceil(diff / (24 * 60 * 60 * 1000))
if(days <= 1){
return this.$t('1天内过期')
}else if(days <= 7){
return this.$t('还有{days}天到期', {days})
}
}
} }
}, },
watch:{ watch:{
......
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form ref="form" :model="form" :rules="rules" label-width="150px"> <el-form ref="form" :model="form" :rules="rules" label-width="150px">
<products-selector ref="productSelector" v-model="form.productIdList" show-all @setall="isAllProduct=$event" :default-ids="form.productIdList" class="mb-20" /> <products-selector ref="productSelector" v-model="form.productIdList" show-all @setall="isAllProduct=$event" :default-ids="form.productIdList" enable-filtered @setFiltered="isAllFilteredProduct=$event" class="mb-20" />
<routers-selector v-model="selectedRoutes" :type="type" /> <routers-selector v-model="selectedRoutes" :type="type" />
...@@ -216,6 +216,7 @@ export default { ...@@ -216,6 +216,7 @@ export default {
// dayLimit: 10000 // dayLimit: 10000
}, },
isAllProduct: false, // 是否全部商品 isAllProduct: false, // 是否全部商品
isAllFilteredProduct: false, // 是否勾選全部搜索結果
specialProducts: [], specialProducts: [],
// priceStepList: [{},{}], // 阶梯价格 // priceStepList: [{},{}], // 阶梯价格
// specialList:[], // 特殊需求,默认四个 // specialList:[], // 特殊需求,默认四个
...@@ -465,14 +466,20 @@ export default { ...@@ -465,14 +466,20 @@ export default {
this.$message.error(this.$t('请选择线路')); this.$message.error(this.$t('请选择线路'));
return; return;
} }
if(!this.isAllProduct && (!this.form.productIdList || !this.form.productIdList.length)){
return this.$message.error('请选择商品')
}
let data = Object.assign({}, this.form, { let data = Object.assign({}, this.form, {
// lineChannelList: this.selectedRoutes, // lineChannelList: this.selectedRoutes,
// specialList: this.specialProducts, // specialList: this.specialProducts,
isAllProduct: this.isAllProduct ? 1:0 isAllProduct: this.isAllProduct ? 1:0
}) })
// 如果是勾選了全部篩選商品,則獲取商品ID
if(this.isAllFilteredProduct){
data.productIdList = await this.$refs.productSelector.getFilteredIds()
}
if(!data.isAllProduct && (!data.productIdList || !data.productIdList.length)){
return this.$message.error('请选择商品')
}
/* if(this.form.stepPrice == 1){ /* if(this.form.stepPrice == 1){
data.priceStepList = this.form.priceStepList data.priceStepList = this.form.priceStepList
} */ } */
...@@ -488,7 +495,7 @@ export default { ...@@ -488,7 +495,7 @@ export default {
} }
await this.$confirm(this.$t('已选择{route}条路线,{product}个商品;确认提交修改?', { await this.$confirm(this.$t('已选择{route}条路线,{product}个商品;确认提交修改?', {
route: data.lineChannelList.length, route: data.lineChannelList.length,
product: this.isAllProduct ? this.$refs.productSelector.allTotal : this.form.productIdList.length product: this.isAllProduct ? this.$refs.productSelector.allTotal : data.productIdList.length
})) }))
this.loading = true this.loading = true
batchUpdateProductPrice(data).then(response => { batchUpdateProductPrice(data).then(response => {
......
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form ref="form" :model="form" :rules="rules" label-width="150px"> <el-form ref="form" :model="form" :rules="rules" label-width="150px">
<products-selector ref="productSelector" v-model="form.productIdList" show-all @setall="isAllProduct=$event" :default-ids="form.productIdList" class="mb-20" /> <products-selector ref="productSelector" v-model="form.productIdList" show-all @setall="isAllProduct=$event"
enable-filtered @setFiltered="isAllFilteredProduct=$event"
:default-ids="form.productIdList" class="mb-20"/>
<routers-selector v-model="selectedRoutes" :type="type" /> <routers-selector v-model="selectedRoutes" :type="type" />
...@@ -96,6 +98,7 @@ export default { ...@@ -96,6 +98,7 @@ export default {
stepPrice: 0 stepPrice: 0
}, },
isAllProduct: false, // 是否全部商品 isAllProduct: false, // 是否全部商品
isAllFilteredProduct: false, // 是否全部篩選商品
specialProducts: [], specialProducts: [],
rules: {}, rules: {},
product: null, product: null,
...@@ -252,15 +255,21 @@ export default { ...@@ -252,15 +255,21 @@ export default {
this.$message.error(this.$t('请选择线路')); this.$message.error(this.$t('请选择线路'));
return; return;
} }
if(!this.isAllProduct && (!this.form.productIdList || !this.form.productIdList.length)){
return this.$message.error('请选择商品')
}
let data = Object.assign({}, this.form, { let data = Object.assign({}, this.form, {
// lineChannelList: this.selectedRoutes, // lineChannelList: this.selectedRoutes,
// specialList: this.specialProducts, // specialList: this.specialProducts,
isAllProduct: this.isAllProduct ? 1:0 isAllProduct: this.isAllProduct ? 1:0
}) })
// 如果是勾選了全部篩選商品,則獲取商品ID
if(this.isAllFilteredProduct){
data.productIdList = await this.$refs.productSelector.getFilteredIds()
}
if(!data.isAllProduct && (!data.productIdList || !data.productIdList.length)){
return this.$message.error(this.$t('请选择商品') + "!")
}
data.lineChannelList = this.selectedRoutes data.lineChannelList = this.selectedRoutes
if(data.lineChannelList.length < 1){ if(data.lineChannelList.length < 1){
...@@ -268,7 +277,7 @@ export default { ...@@ -268,7 +277,7 @@ export default {
} }
await this.$confirm(this.$t('已选择{route}条路线,{product}个商品;确认提交修改?', { await this.$confirm(this.$t('已选择{route}条路线,{product}个商品;确认提交修改?', {
route: data.lineChannelList.length, route: data.lineChannelList.length,
product: this.isAllProduct ? this.$refs.productSelector.allTotal : this.form.productIdList.length product: this.isAllProduct ? this.$refs.productSelector.allTotal : data.productIdList.length
})) }))
this.loading = true this.loading = true
batchAddPrice(data).then(async(response) => { batchAddPrice(data).then(async(response) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment