<template>
    <el-dialog
        title="保存病历模板"
        width="600px"
        :visible.sync="visible"
        :before-close="_close"
        class="recordDialog"
    >
        <el-form class="recordForm" :model="form"  ref="form" label-width="80px">
            <el-form-item label="模板名称: " prop="name" style="width:100%;">
                <el-input v-model="template_name" placeholder=""></el-input>
            </el-form-item>
            <el-form-item label="模板说明:" prop="name" style="width:100%;">
                <el-input
                type="textarea"
                :rows="2"
                placeholder="请输入内容"
                v-model="template_remark">
                </el-input>
            </el-form-item>
            <el-form-item label="创建人:" prop="name" style="width:49%;">
                <span>{{user_name}}</span>
            </el-form-item>
            <el-form-item label="创建时间:" prop="name" style="width:49%;">
                {{start_time}}
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="hide">取 消</el-button>
            <el-button type="primary"  @click="submitAction()">保 存</el-button>
        </div>
    </el-dialog>         
</template>

<script>
const moment = require('moment')
import { SaveHisPatientCaseHistoryTemplate } from "@/api/project/project"
export default {
    data(){
        return{
            visible:false,
            form:{
                name:''
            },
            mode_type:"1",
            textarea:"",
            chief_conplain:"",
            past_history:"",
            history_of_present_illness:"",
            personal_history:"",
            family_history:"",
            diagnostic:"",
            mode_type:"",
            start_time:"",
            user_name:"",
            template_name:"",
            template_remark:"",
            mode_status:0,
            doctor_advice:'',
            remark:''
        }
     },
    
    methods:{
        _close: function(done) {
            // this.clear()
            done()
        },
        clear: function() {
            this.form.id = 0;
            this.form.name = "";
            this.form.intro = "";
        },
        show(obj) {
         console.log("obj",obj)
         this.chief_conplain= obj.chief_conplaint
         this.past_history = obj.past_history
         this.history_of_present_illness = obj.history_of_present_illness
         this.personal_history = obj.personal_history
         this.family_history = obj.family_history
         this.diagnostic = obj.diagnostic
         this.doctor_advice = obj.doctor_advice
         this.remark = obj.remark
         this.visible = true
        },
        hide() {
            // this.clear()
            this.visible = false
        },

        submitAction(){
          var params = {
             template_name:this.template_name,
             template_remark:this.template_remark,
             user_name:this.user_name,
             record_date:this.start_time,
             chief_conplain:this.chief_conplain,
             past_history:this.past_history,
             history_of_present_illness:this.history_of_present_illness,
             personal_history:this.personal_history,
             family_history:this.family_history,
             diagnostic:this.diagnostic,
             doctor_advice:this.doctor_advice,
             remark:this.remark
            }
         console.log("params",params)
       
          SaveHisPatientCaseHistoryTemplate(params).then(response=>{
              if(response.data.state == 1){
                 this.mode_status = 1
                 this.$message.success("保存成功")
                 this.visible = false
                
              }
          })   
        }
    },
    created(){
      this.start_time = moment().format("YYYY-MM-DD HH:mm:ss")
      this.user_name = this.$store.getters.xt_user.user.user_name
      
    }
}
</script>

<style lang="scss" scoped>
.recordForm{
    display: flex;
    flex-wrap: wrap;
    .el-form-item{
        width:24%;
        margin-right: 1%;
    }
}
</style>

