<template>
    <el-dialog
        title="附加收费"
        width="300px"
        :visible.sync="visible"
        :before-close="_close"
    >
        <el-table :data="tableData" border style="width: 100%;" height="300" :row-style="{ color: '#303133' }" 
        :header-cell-style="{backgroundColor: 'rgb(245, 247, 250)',color: '#606266'}" highlight-current-row
          @selection-change="handleSelectionChange">
            <el-table-column align="center" type="selection" width="40"></el-table-column>
            <el-table-column align="center" prop="name" label="名称" width="100">
                <template slot-scope="scope">{{ scope.row.name }}</template>
            </el-table-column>
            <el-table-column align="center" prop="name" label="金额(元)">
                <template slot-scope="scope">
                    <el-input v-model="scope.row.money" placeholder=""></el-input>
                </template>
            </el-table-column>
        </el-table>
        <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>
 import { saveCharges } from "@/api/project/project"
export default {
    data(){
        return{
            visible:false,
            form:{
                name:''
            },
            tableData:[
              {id:1,name:"工本费",money:""},
              {id:2,name:"挂号费",money:""},
              {id:3,name:"诊疗费",money:""}  
            ],
            chargeTable:[]
        }
    },
    methods:{
        _close: function(done) {
            // this.clear()
            done()
        },
        clear: function() {
            this.form.id = 0;
            this.form.name = "";
            this.form.intro = "";
        },
        show() {
            // this.clear()
            this.visible = true
        },
        hide() {
            // this.clear()
            this.visible = false
        },
        handleSelectionChange(val){
          console.log("val",val)
          this.chargeTable = val
        },
        submitAction(){
          var params = {
             patient_id:this.patient_id,
             medicineData:this.chargeTable
           }
           console.log("params",params)
          saveCharges(params).then(response=>{
             if(response.data.state == 1){
               var additionalCharge =  response.data.data.additionalCharge
               console.log("additionalchar",additionalCharge)
               this.visible = false
               this.$message.success("保存成功")
             }
          })      
        }
    }
}
</script>

