|
|
|
|
@ -89,22 +89,20 @@
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<template v-slot:product_sku_list>
|
|
|
|
|
<template v-slot:product_sku_category_list>
|
|
|
|
|
<div class="xy-table-item">
|
|
|
|
|
<div class="xy-table-item-label">
|
|
|
|
|
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>关联服务:
|
|
|
|
|
<span style="color: red;font-weight: 600;padding-right: 4px;">*</span>服务分类:
|
|
|
|
|
</div>
|
|
|
|
|
<div class="xy-table-item-content">
|
|
|
|
|
<xy-table
|
|
|
|
|
ref="table"
|
|
|
|
|
:is-page="false"
|
|
|
|
|
:height="260"
|
|
|
|
|
:list="skus"
|
|
|
|
|
:table-item="skuTable"
|
|
|
|
|
@select="rowSelect"
|
|
|
|
|
@select-all="rowSelect">
|
|
|
|
|
<template v-slot:btns></template>
|
|
|
|
|
</xy-table>
|
|
|
|
|
|
|
|
|
|
<div class="classify-content">
|
|
|
|
|
<div class="classify-content__btn">
|
|
|
|
|
<el-button type="primary" size="small" @click="form.product_sku_category_list.push({id:'',name:''})">新增分类</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="classify-content__input" v-for="(item,index) in form.product_sku_category_list">
|
|
|
|
|
<el-input v-model="item.name" placeholder="输入服务分类名称" style="width: 240px;"></el-input>
|
|
|
|
|
<el-button type="danger" icon="el-icon-delete" circle size="small" style="margin-left: 20px" @click="deleteCategory(item,index)"></el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
@ -113,7 +111,8 @@
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import {getForm, save} from '@/api/productType'
|
|
|
|
|
import { save as saveSkuCategory ,destroy } from '@/api/skuCategory'
|
|
|
|
|
import { getForm, save } from '@/api/productType'
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
|
|
|
|
|
@ -144,7 +143,7 @@ export default {
|
|
|
|
|
sortnumber: 0,
|
|
|
|
|
max_age:0,
|
|
|
|
|
min_age:100,
|
|
|
|
|
product_sku_list:[]
|
|
|
|
|
product_sku_category_list:[]
|
|
|
|
|
},
|
|
|
|
|
rules: {
|
|
|
|
|
name: [
|
|
|
|
|
@ -176,45 +175,59 @@ export default {
|
|
|
|
|
{
|
|
|
|
|
prop:'service',
|
|
|
|
|
label:'服务内容',
|
|
|
|
|
minWidth: 160,
|
|
|
|
|
width: 160,
|
|
|
|
|
align:'left'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
deleteCategory(item,index){
|
|
|
|
|
if(item.id){
|
|
|
|
|
destroy(item.id).then(() => {
|
|
|
|
|
this.getDetail()
|
|
|
|
|
})
|
|
|
|
|
}else{
|
|
|
|
|
this.form.product_sku_category_list.splice(index,1)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async getDetail() {
|
|
|
|
|
const res = await getForm(this.id)
|
|
|
|
|
|
|
|
|
|
this.$integrateData(this.form, res)
|
|
|
|
|
this.form.product_sku_list = res.product_skus.map(item => {
|
|
|
|
|
this.form.product_sku_category_list = res.sku_category.map(item => {
|
|
|
|
|
return {
|
|
|
|
|
sku_id:item.sku_id
|
|
|
|
|
id:item.id,
|
|
|
|
|
name:item.name
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
console.log(res)
|
|
|
|
|
|
|
|
|
|
//默认勾选
|
|
|
|
|
this.$refs['table'].clearSelection()
|
|
|
|
|
let ids = this.form.product_sku_list.map(item => item.sku_id)
|
|
|
|
|
this.skus.forEach(item => {
|
|
|
|
|
if(ids.indexOf(item.id) !== -1){
|
|
|
|
|
this.$refs['table'].toggleRowSelection(item)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
rowSelect(selection){
|
|
|
|
|
console.log(selection)
|
|
|
|
|
this.form.product_sku_list = selection.map(item => {
|
|
|
|
|
async submit() {
|
|
|
|
|
let arr1 = [];//已有的分类
|
|
|
|
|
let arr2 = [];//新增的分类
|
|
|
|
|
this.form.product_sku_category_list.forEach(item => {
|
|
|
|
|
if(item.id){
|
|
|
|
|
arr1.push(saveSkuCategory({
|
|
|
|
|
name:item.name,
|
|
|
|
|
id:item.id
|
|
|
|
|
}))
|
|
|
|
|
}else{
|
|
|
|
|
arr2.push(saveSkuCategory({
|
|
|
|
|
name:item.name
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
let categoryRes = await Promise.all([...arr1,...arr2])
|
|
|
|
|
console.log(categoryRes)
|
|
|
|
|
this.form.product_sku_category_list = categoryRes.map(item => {
|
|
|
|
|
return {
|
|
|
|
|
sku_id:item.id
|
|
|
|
|
sku_category_id:item.id
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
submit() {
|
|
|
|
|
if (this.type === 'editor') {
|
|
|
|
|
Object.defineProperty(this.form, 'id', {
|
|
|
|
|
value: this.id,
|
|
|
|
|
@ -223,11 +236,10 @@ export default {
|
|
|
|
|
configurable: true
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
save(this.form).then(res => {
|
|
|
|
|
this.$successMessage(this.type, '业务类型')
|
|
|
|
|
this.isShow = false
|
|
|
|
|
this.$emit('refresh')
|
|
|
|
|
})
|
|
|
|
|
await save(this.form)
|
|
|
|
|
this.$successMessage(this.type, '业务类型')
|
|
|
|
|
this.isShow = false
|
|
|
|
|
this.$emit('refresh')
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
@ -254,4 +266,19 @@ export default {
|
|
|
|
|
::v-deep .el-slider__marks-text{
|
|
|
|
|
margin-top: 6px !important;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.classify-content{
|
|
|
|
|
|
|
|
|
|
&__btn{
|
|
|
|
|
margin-bottom: 10px;
|
|
|
|
|
}
|
|
|
|
|
&__input{
|
|
|
|
|
width: 300px;
|
|
|
|
|
|
|
|
|
|
margin-bottom: 10px;
|
|
|
|
|
}
|
|
|
|
|
&>div:last-child{
|
|
|
|
|
margin-bottom: 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|