<template>
    <!-- 弹出框表单 -->
    <el-drawer
            :title="title"
            :visible.sync="open"
            :direction="direction"
            :destroy-on-close="true"
            size="50%">
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
            <el-row>
                            <Field label="项目产品名称" :span="20" prop="name" v-model="form.name" placeholder="请输入项目产品名称"/>
                            <Field label="项目产品编码" :span="20" prop="projectCode" v-model="form.projectCode"  placeholder="请输入项目产品编码"/>
                            <Field label="项目部署地址" :span="20" prop="projectPath" v-model="form.projectPath" placeholder="请输入项目部署地址"/>
                            <Field label="项目shell地址" :span="20" prop="projectShell" v-model="form.projectShell"  placeholder="请输入项目shell地址"/>
                            <Field label="项目源文件地址" :span="20" prop="sourceProject" v-model="form.sourceProject"  placeholder="请输入项目源文件地址，空则为内部包含"/>
                            <Field label="数据库host地址" :span="20" prop="dbHost" v-model="form.dbHost"  placeholder="请输入数据库host地址"/>
                            <Field label="数据库端口" :span="20" prop="dbPort" v-model="form.dbPort"  placeholder="请输入数据库端口"/>
                            <Field label="数据库用户" :span="20" prop="dbUser" v-model="form.dbUser"  placeholder="请输入数据库用户"/>
                            <Field label="数据库密码" :span="20" prop="dbPassword" v-model="form.dbPassword"  placeholder="请输入数据库密码"/>
                            <Field label="数据库名称" :span="20" prop="dbName" v-model="form.dbName"  placeholder="请输入数据库名称"/>
                            <Field label="项目版本" :span="20" prop="version" v-model="form.version"  placeholder="请输入项目版本"/>
                            <Field label="项目类型" :span="20" prop="projectType" v-model="form.projectType" type="select" :enumData="dict.projectType" placeholder="请选择项目类型"/>
                            <Field label="项目状态" :span="20" prop="projectStatus" v-model="form.projectStatus" type="select" :enumData="dict.projectStatus" placeholder="请选择项目状态"/>
              <Field label="排序" :span="20" prop="orderNum" v-model="form.orderNum"  placeholder="请输入序号"/>

              <Field label="备注" :span="20" prop="remark" v-model="form.remark" type="textarea" placeholder="请输入备注"/>

            </el-row>

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

    </el-drawer>
</template>

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

        },
        created() {
            this.changePath("setup/project")
        },
        data() {
            return {
                // 遮罩层
                loading: true,
                // 弹出层标题
                title: "项目工程信息",
                // 是否显示弹出层
                open: false,
                direction:"rtl",
                toString:[
                    "projectType",
                    "projectStatus",
                ],
                toDate:[
                ],
                // 表单校验
                rules: {
                    createTime: [
                        {required: true,message: "请选择创建时间" },
                    ],
                    createUser: [
                        {required: true,message: "请输入创建用户,登录名", trigger: "blur" },
                        {max: 50,message: "最多只能录入50个字符",trigger: "blur",},
                    ],
                }
            };
        },

        methods: {
            /** 编辑 */
            edit(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="setup/project/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改项目工程信息";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "setup/project/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增项目工程信息";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="setup/project/view";
                this.getData();
                this.pageInfo.type="view"
                this.title = "项目工程信息详细";
            },
            /**取消按钮 */
            cancel() {
                this.open = false;
            },
            /**获取数据后弹框 */
            afterRender(data) {
                this.open = true;
            },

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

            // 表单重置
            reset() {
                this.form = {
                    name : null,
                    projectCode : null,
                    projectPath : null,
                    projectShell : "",
                    sourceProject : "",
                    dbHost : "127.0.0.1",
                    dbPort : "3306",
                    dbUser : "root",
                    dbPassword : "xhx@2022",
                    dbName : "",
                    version : "1.0",
                    projectType : 1,
                    orderNum : 1,
                    projectStatus : 1,
                    remark : null,
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
