<template>
    <!-- 弹出框表单 -->
    <el-drawer
            :title="title"
            :visible.sync="open"
            :direction="direction"
            size="50%">
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
            <el-row>
                        <Field :span="20" label="分类" prop="categoryId" v-model="form.categoryId" :enumData="dict.categoryId" type="select" placeholder="请选择分类"/>

                            <Field :span="20" label="考核内容简称" prop="name" v-model="form.name" placeholder="请输入考核内容简称"/>
                            <Field :span="20" label="评分标准" prop="content" v-model="form.content" type="textarea" placeholder="请输入评分标准"/>
                            <Field :span="20" label="增减类型" prop="subAddType" v-model="form.subAddType" type="select" :enumData="dict.subAddType" placeholder="请选择增减类型"/>
                            <Field :span="20" label="扣分" prop="score" v-model="form.score" placeholder="请输入扣分或增加分值"/>
                            <Field :span="20" label="关联负责人" prop="assoOwner" v-model="form.assoOwner" type="radio" :enumData="dict.assoOwner" placeholder="请选择是否关联负责人"/>
                            <Field :span="20" v-if="form.assoOwner==1" label="负责人扣分" prop="ownerScore" v-model="form.ownerScore" placeholder="请输入负责人扣分或增加分值"/>
                            <Field :span="20" label="备注" prop="remark" v-model="form.remark" type="textarea" placeholder="请输入备注"/>


            </el-row>

            <form-buttons v-if="pageInfo.type!='view'" @submit='submitForm' noCancelBtn />
        </el-form>

    </el-drawer>
</template>

<script>
    import form from "@/assets/mixins/formdialog";
    export default {
        name: "PerformRulesDetail",
        mixins: [form],
        components: {

        },
        created() {

        },
        data() {
            return {
                // 遮罩层
                loading: true,
                // 弹出层标题
                title: "绩效规则信息",
                // 是否显示弹出层
                open: false,
                direction:"rtl",
                toString:[
                    "subAddType",
                    "assoOwner",
                    "type",
                    "categoryId"
                ],
                toDate:[
                ],
                // 表单校验
                rules: {
                },
              urls: {
                currUrl: "/perform/rules/list",
                editUrl: "/perform/rules/edit",
                saveUrl: "/perform/rules/save",
              },
            };
        },

        methods: {
            /** 编辑 */
            edit(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="perform/rules/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改绩效规则信息";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "perform/rules/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增绩效规则信息";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="perform/rules/view";
                this.getData();
                this.pageInfo.type="view"
                this.title = "绩效规则信息详细";
            },
            /**取消按钮 */
            cancel() {
                this.open = false;
            },
            /**获取数据后弹框 */
            afterRender(data) {
              this.form.type=4
                this.open = true;
            },

            afterSubmit(data) {
                this.open = false;
                this.$emit("ok");
            },

            // 表单重置
            reset() {
                this.form = {
                    categoryId : null,
                    categoryName : "",
                    name : "",
                    content : "",
                    subAddType : 1,
                    score : 0.00,
                    assoOwner : 0,
                    ownerScore : 0.00,
                    remark : "",
                    type : 1,
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
