<template>
    <!-- 弹出框表单 -->
    <el-dialog :title="title" :visible.sync="open" width="90%" append-to-body>
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
            <el-row>
              <Field :span="20" label="个人信息" prop="personId" v-model="form.personId" style="width:100%" type="select" :enumData="dict.personId" placeholder="请输入个人信息ID"/>
              <Field :span="20" label="联系方式" prop="contact" v-model="form.contact" placeholder="请输入联系方式"/>
              <Field :span="20" label="证件类型" prop="idCardType" v-model="form.idCardType" type="radio" :enumData="dict.idCardType" placeholder="请输入证件类型"/>
              <Field :span="20" label="证件号码" prop="idCardNo" v-model="form.idCard" placeholder="请输入证件号码"/>


<!--
                         <Field label="站点Id" prop="siteId" v-model="form.siteId" placeholder="请输入站点Id"/>
                            <Field label="站点名称" prop="siteName" v-model="form.siteName" type="textarea" placeholder="请输入站点名称"/>
                            <Field label="人员ID" prop="personId" v-model="form.personId" placeholder="请输入人员ID"/>
                            <Field label="姓名" prop="name" v-model="form.name" placeholder="请输入姓名"/>
                            <Field label="联系方式" prop="contact" v-model="form.contact" placeholder="请输入联系方式"/>
                            <Field label="身份证号码" prop="idCard" v-model="form.idCard" placeholder="请输入身份证号码"/>
                            <Field label="服务频次" prop="serviceFrequency" v-model="form.serviceFrequency" placeholder="请输入服务频次"/>
                            <Field label="跟踪时间" prop="trackingTime" v-model="form.trackingTime" type="date" />
                            <Field label="创建方式" prop="createWay" v-model="form.createWay" type="select" :enumData="dict.createWay" placeholder="请选择创建方式"/>
                            <Field label="操作人员" prop="operator" v-model="form.operator" placeholder="请输入操作人员"/>
                            <Field label="是否追踪 " prop="track" v-model="form.track" type="select" :enumData="dict.track" placeholder="请选择是否追踪 "/>
-->

            </el-row>
<!--                <el-divider content-position="center">主动关怀服务追踪信息</el-divider>
                <br/>
                <el-row :gutter="10" class="mb8">
                    <el-col :span="1.5">
                        <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddCareConstraintTrack">添加</el-button>
                    </el-col>
                    <el-col :span="1.5">
                        <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteCareConstraintTrack">删除</el-button>
                    </el-col>
                </el-row>

                <el-table :data="careConstraintTrackList" :row-class-name="rowCareConstraintTrackIndex" @selection-change="handleCareConstraintTrackSelectionChange" ref="careConstraintTrack">
                    <el-table-column type="selection" width="50" align="center" />
                    <el-table-column label="序号" align="center" prop="index" width="50"/>
                            <el-table-column label="反馈人ID" prop="feedbackId">
                                <template slot-scope="scope">
                                    <el-input v-model="scope.row.feedbackId" placeholder="请输入反馈人ID" />
                                </template>
                            </el-table-column>
                            <el-table-column label="反馈人姓名" prop="feedbackName">
                                <template slot-scope="scope">
                                    <el-input v-model="scope.row.feedbackName" placeholder="请输入反馈人姓名" />
                                </template>
                            </el-table-column>
                            <el-table-column label="反馈内容" prop="feedback">
                                <template slot-scope="scope">
                                    <el-input v-model="scope.row.feedback" placeholder="请输入反馈内容" />
                                </template>
                            </el-table-column>
                            <el-table-column label="跟踪时间" prop="feedbackTime">
                                <template slot-scope="scope">
                                    <el-input v-model="scope.row.feedbackTime" placeholder="请输入跟踪时间" />
                                </template>
                            </el-table-column>
                            <el-table-column label="创建方式" prop="createMethod">
                                <template slot-scope="scope">
                                    <el-input v-model="scope.row.createMethod" placeholder="请输入创建方式" />
                                </template>
                            </el-table-column>
                            <el-table-column label="创建时间" prop="createTime">
                                <template slot-scope="scope">
                                    <el-input v-model="scope.row.createTime" placeholder="请输入创建时间" />
                                </template>
                            </el-table-column>
                            <el-table-column label="创建人ID" prop="createUserId">
                                <template slot-scope="scope">
                                    <el-input v-model="scope.row.createUserId" placeholder="请输入创建人ID" />
                                </template>
                            </el-table-column>
                            <el-table-column label="更新时间" prop="updateTime">
                                <template slot-scope="scope">
                                    <el-input v-model="scope.row.updateTime" placeholder="请输入更新时间" />
                                </template>
                            </el-table-column>
                            <el-table-column label="更新人ID" prop="updateUserId">
                                <template slot-scope="scope">
                                    <el-input v-model="scope.row.updateUserId" placeholder="请输入更新人ID" />
                                </template>
                            </el-table-column>
                </el-table>-->

        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button type="primary" v-if="pageInfo.type !== 'view'" @click="submitForm">确 定</el-button>
            <el-button @click="cancel">取 消</el-button>
        </div>
    </el-dialog>
</template>

<script>
    import form from "@/assets/mixins/formdialog";
    import dialogShow from "./dialogshow";
    export default {
        mixins: [form],
        components: {
            dialogShow ,
        },
        data() {
            return {
                // 子表选中数据
                checkedCareConstraintTrack: [],
                // 主动关怀服务追踪表格数据
                careConstraintTrackList: [],
                // 遮罩层
                loading: true,
                // 弹出层标题
                title: "主动关怀服务约束",
                // 是否显示弹出层
                open: false,
                toString:[
                    "createWay",
                    "track",
                    "idCardType",
                    "personId",
                ],
                // 表单校验
                rules: {

                    idCard: [
                        {required: true,message: "请输入身份证号码", trigger: "blur" },
                        {max: 18,message: "最多只能录入18个字符",trigger: "blur",},
                    ],

                }
            };
        },

        methods: {

            // 渲染前置处理
            beforeRender(data) {
                if(data.entity.careConstraintTrackList) {
                    this.careConstraintTrackList = data.entity.careConstraintTrackList;
                }
                return data
            },
            /** 编辑 */
            edit(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="care/constraint/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改主动关怀服务约束";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "care/constraint/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增主动关怀服务约束";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="care/constraint/view";
                this.getData();
                this.pageInfo.type="view"
                this.title = "主动关怀服务约束详细";
            },
            /**取消按钮 */
            cancel() {
                this.open = false;
            },
            /**获取数据后弹框 */
            afterRender(data) {
                this.open = true;
            },

          beforeSubmit(data){
            data.name=this.dict['personId'][data.personId]
            return data;
          },

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

            // 表单重置
            reset() {
                this.form = {
                    siteId : null,
                    siteName : "",
                    personId : null,
                    name : "",
                    contact : "",
                    idCard : "",
                    idCardType : "居民身份证",
                    serviceFrequency : null,
                    trackingTime : null,
                    createWay : null,
                    operator : "",
                    track : 0,
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
