<template>
  <div v-loading="pageloading" class="goodsServicesEdit">
      <div class="head-title">
        <span @click="CommonJump('goodsServices')" class="blue point">服务</span> / 服务编辑
    </div>
    <el-form :model="addMsg" :rules="rules" ref="addMsg" label-width="150px">
        <el-card shadow="never" style="margin-top:10px" class="box-card">
            <el-form-item class="commonLabel discount" label="服务名称" prop="Name">
                <el-tooltip class="item" effect="dark" content="例如：正品保障|极速发货|7天退换货" placement="top-start">
                        <i class=" elzk el-tooltip el-icon-info"></i>
                    </el-tooltip>
                <el-input v-model="addMsg.Name" style="width:690px" size="small">
                </el-input>
            </el-form-item>
            <el-form-item label="排序" prop="Sort">
                <el-input type="number" min="1" size="small" style="width:690px" placeholder="请输入" v-model="addMsg.Sort">
                </el-input>
            </el-form-item>
            <el-form-item label="备注">
                <el-input type="textarea" :row="2" style="width:690px" placeholder="请输入" v-model="addMsg.Remark">
                </el-input>
            </el-form-item>
            <el-form-item label="是否默认">
                <el-switch
                    v-model="addMsg.IsDefault"
                    active-color="#409EFF"
                    :active-value="1"
                    :inactive-value="0">
                </el-switch>
            </el-form-item>
            
        </el-card>
    </el-form>
    <div style="padding:20px;background:#fff;margin-top:10px">
        <el-button @click="Save('addMsg')" size="small" type="primary">保存</el-button>
    </div>
  </div>
</template>

<script>
export default {
    name: "goodsServicesEdit",
    data(){
        return{
            pageloading:false,
            addMsg:{
                Id:0,
                Name:'',
                Sort:100,
                IsDefault:0,
                Remark:'',
                UpdateType:0,
            },
            rules:{
                Name: [
                    { required: true, message: '请输入服务名称', trigger: 'blur' },
                ],
                Sort:[
                    { required: true, message: '请输入排序', trigger: 'blur' },
                ],
            },
        }
    },
    created(){
        // this.getData()
    },
    methods:{
        Save(formName){
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    this.apipost('/api/product/SetProductServiceInfo',this.addMsg,
                        res => {
                        if (res.data.resultCode === 1) {
                            this.CommonJump('goodsServices')
                            this.Success(res.data.message)

                        } else {
                            this.Error(res.data.message);
                        }
                        },
                        null
                    );
                } else {
                return false;
                }
            });
        },
        getData(){
            this.pageloading=true;
            this.apipost("/api/product/GetProductRecommendSetInfo",{}, res => {
                this.pageloading=false;
                if(res.data.resultCode==1){
                    this.addMsg=res.data.data;
                }else {
                    this.Error(res.data.message);
                }
            })
        },
    },
};
</script>

<style>
.goodsServicesEdit .discount .el-form-item__label{
    padding-right: 30px;
}   
.goodsServicesEdit .el-form-item .elzk{
    position: absolute;
    left: -25px;
    top:12px;
}
</style>
