<template>
  <div v-loading="pageloading" class="commentLabelEdit">
      <div class="head-title">
        <span @click="CommonJump('commentLabelList')" 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="" 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-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: "commentLabelEdit",
    data(){
        return{
            pageloading:false,
            addMsg:{
                Id:0,
                Name:'',
            },
            rules:{
                Name: [
                    { required: true, message: '请输入标签名称', trigger: 'blur' },
                ],
            },
            ServiceId:-1,
        }
    },
    created(){
        if(this.$route.query.ServiceId){
            this.ServiceId=this.$route.query.ServiceId;
            this.getData()
        }
    },
    methods:{
        Save(formName){
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    this.apipost('/api/Order/SetCommentLabel',this.addMsg,
                        res => {
                        if (res.data.resultCode === 1) {
                            this.CommonJump('commentLabelList')
                            this.Success(res.data.message)

                        } else {
                            this.Error(res.data.message);
                        }
                        },
                        null
                    );
                } else {
                return false;
                }
            });
        },
        getData(){
            this.pageloading=true;
            this.apipost("/api/Order/GetCommentLabel",{Id:this.ServiceId}, 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>
