You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
4.5 KiB

3 years ago
<template>
<div style="padding:0 20px;">
<div ref="lxHeader">
<lx-header icon="md-apps" text="福利包" style="margin-bottom: 10px; border: 0px; margin-top: 15px">
<div slot="content"></div>
<slot>
<div>
<Input style="width: 200px; margin-right: 10px" placeholder="关键字搜索" />
<Button type="primary">查询</Button>
3 years ago
<Button type="primary" style="margin-left: 10px" @click="$refs['addWelfare'].type = 'add',$refs['addWelfare'].isShow = true">新增</Button>
3 years ago
</div>
</slot>
</lx-header>
</div>
3 years ago
<xy-table :list="list" :table-item="table" :total="total" :page-size="select.pageSize" @pageIndexChange="pageChange" @pageSizeChange="e => select.pageSize = e">
3 years ago
<template v-slot:btns>
3 years ago
<el-table-column label="操作" header-align="center" fixed="right" min-width="382">
3 years ago
<template slot-scope="scope">
3 years ago
<Button icon="ios-basket" type="primary" style="margin-left: 10px;" size="small" @click="isShowCombine = true,$refs['productCombine'].id = scope.row.id">产品组合</Button>
<Button icon="ios-build" type="primary" style="margin-left: 10px;" size="small" @click="editorClick(scope.row)"></Button>
<Poptip
transfer
confirm
title="确认删除?"
@on-ok="deletePackage(scope.row)">
<Button icon="ios-trash-outline" type="primary" style="margin-left: 10px;" size="small" ghost>删除</Button>
</Poptip>
3 years ago
<el-switch
style="margin-left: 10px;"
:value="scope.row.state_name == '已上架' ? true : false"
active-color="#BF617C"
inactive-color="#E5E5E5"
:active-text="scope.row.state_name == '已上架' ? '已上架' : '已下架'"
@change="stateChange(scope.row)">
</el-switch>
</template>
</el-table-column>
</template>
3 years ago
</xy-table>
3 years ago
3 years ago
<productCombine ref="productCombine" :is-show.sync="isShowCombine"></productCombine>
3 years ago
3 years ago
<addWelfare ref="addWelfare" @refresh="getPackage"></addWelfare>
3 years ago
</div>
</template>
<script>
3 years ago
import {index,toggleActive,destroy} from "@/api/package"
import {deepCopy} from '@/utils'
3 years ago
import productCombine from './components/productCombine'
3 years ago
import addWelfare from '@/views/productService/components/addWelfare'
import { Message } from 'element-ui'
3 years ago
export default {
components:{
3 years ago
productCombine,
addWelfare
3 years ago
},
data() {
return {
3 years ago
select:{
pageIndex:1,
pageSize:10,
},
3 years ago
isShowCombine:false,
3 years ago
total:0,
list:[],
3 years ago
table:[
{
prop:"name",
label:'名称',
3 years ago
width: 280,
align:'left'
3 years ago
},
{
label:'项目数量',
3 years ago
width: 200,
customFn:(row)=>{
return (<div>{row.items.length}</div>)
}
3 years ago
},
{
prop:"price",
label:"价格",
3 years ago
width: 180,
align:'right'
3 years ago
},
{
prop: 'state_name',
label: '状态',
3 years ago
width: 160,
3 years ago
customFn:(row)=>{
if(row.state_name == '已上架'){
3 years ago
return <div style="color: green;text-align: center;">{row.state_name}</div>
3 years ago
}else{
3 years ago
return <div style="color: red;text-align: center;">{row.state_name}</div>
3 years ago
}
}
}
]
}
},
methods: {
stateChange(row){
3 years ago
toggleActive({id:row.id}).then(res => {
row.state_name = row.state_name == '已上架' ? '已下架' : '已上架'
Message({
type:'success',
message:`${row.state_name.slice(1)}成功`
})
})
},
pageChange(e){
this.select.pageIndex = e
this.getPackage()
},
async getPackage(){
const res = await index({
page_size:this.select.pageSize,
page:this.select.pageIndex
})
this.list = res.data
this.total = res.total
},
deletePackage(row){
destroy({id:row.id}).then(res => {
Message({
type:'success',
message:'删除成功'
})
this.getPackage()
})
},
editorClick(row){
this.$refs['addWelfare'].id = row.id
this.$refs['addWelfare'].detail = deepCopy(row)
this.$refs['addWelfare'].type = 'editor'
this.$refs['addWelfare'].isShow = true
3 years ago
}
3 years ago
},
mounted() {
this.getPackage()
3 years ago
}
}
</script>
<style scoped lang="scss">
</style>