<template>
  <div class="main-contain">
    <div class="position">
      <bread-crumb :crumbs="crumbs"></bread-crumb>
    </div>
    <div class="app-container">
        <!--<div class="configBox">-->
            <!--<p>收费发药</p>-->
            <!--<p style="font-size:14px;margin-top:5px;">开启收费发药分离后，处方发药的工作需要到收费发药页面完成</p>-->
            <!--<p style="margin-top:20px;">收费，发药分离：-->
                <!--<el-switch v-model="value"></el-switch>-->
            <!--</p>-->
        <!--</div>-->
        <div class="configBox">
            <p style="font-size:18px;font-weight:bold">门诊打印</p>
            <p style="font-size:14px;margin-top:5px;color:#333;">开启直接打印后，门诊病历、处方、治疗单、处置单、收费清单等打印时跳过打印预览，直接连接打印机打印。</p>
            <p style="margin-top:20px;">直接打印：
                <el-switch v-model="is_open_print" @change="changeFuncPrint"></el-switch>
            </p>
        </div>
        <div class="configBox">
          <p style="font-size:18px;font-weight:bold">医嘱同步</p>
          <p style="font-size:14px;margin-top:5px;color:#333;">开启门诊处方同步到透析医嘱后，同一个患者，门诊医生站开的药品类处方自动同步到透析管理临时医嘱中，同时在透析管理中，给患者开长期医嘱和临时医嘱的功能失效，医生只能在门诊医生站开处方，只有同时使用门诊管理和透析管理的机构方可开启。</p>
          <p style="margin-top:20px;">门诊处方同步到透析医嘱：
          <el-switch v-model="is_open_xt_his" @change="changeFuncOne"></el-switch>
          </p>
        </div>

        <div class="configBox">
            <p style="font-size:18px;font-weight:bold">处方项目同步到临时医嘱</p>
            <p style="font-size:14px;margin-top:5px;color:#333;">开启门诊处方的项目同步后，护士则在血透的临时医嘱中可以看到相关的耗材/检验检查数据</p>
            <p style="margin-top:20px;">门诊处方项目同步到透析医嘱：
                <el-switch v-model="is_open_xt_his_project" @change="changeFuncProject"></el-switch>
            </p>
        </div>


        <!-- <div class="configBox">
          <p style="font-size:18px;font-weight:bold">血压数据自动获取</p>
          <p style="font-size:14px;margin-top:5px;color:#333;">在联机的状态下,开启透析监测-血压数据自动获取功能后,则不需要手动输入,数据会自动上传到监测中</p>
          <p style="margin-top:20px;">透析监测-血压数据自动获取：
          <el-switch v-model="is_open_monitor" @change="changeFuncTwo"></el-switch>
          </p>
        </div>

        <div class="configBox">
          <p style="font-size:18px;font-weight:bold">透析机数据自动获取</p>
          <p style="font-size:14px;margin-top:5px;color:#333;">在联机的状态下,开启透析监测-透析机数据自动获取功能后,则不需要手动输入,数据会自动上传到监测中</p>
          <p style="margin-top:20px;">透析监测-血压数据自动获取：
          <el-switch v-model="is_open_order" @change="changeFuncThree"></el-switch>
          </p>
        </div> -->
        <!--<div class="configBox">-->
            <!--<p>药品，耗材出库</p>-->
            <!--<p style="font-size:14px;margin-top:5px;">开启药品，耗材出库自动扣减则医生开完医嘱或处方可直接出库，不开启则由发药动作或出库按钮手动出库</p>-->
            <!--<div style="display:flex;margin-top:20px;">-->
                <!--<p style="margin-right:20px;">药品出库：-->
                    <!--<el-switch v-model="value" @change="changeFuncTwo"></el-switch>-->
                <!--</p>-->
                <!--<p>耗材出库：-->
                    <!--<el-switch v-model="value"></el-switch>-->
                <!--</p>-->
            <!--</div>-->
        <!--</div>-->
        <!--<div class="configBox">-->
            <!--<p style="margin-bottom:20px;">药品有效期预警设置(药品即将失效的预警提示)</p>-->
            <!--<el-select v-model="value" placeholder="请选择">-->
                <!--<el-option-->
                <!--v-for="item in options"-->
                <!--:key="item.value"-->
                <!--:label="item.label"-->
                <!--:value="item.value">-->
                <!--</el-option>-->
            <!--</el-select>-->
        <!--</div>-->
        <!--<div class="configBox">-->
            <!--<p>处方单价锁定</p>-->
            <!--<p style="font-size:14px;margin-top:5px;">开启处方单价锁定后，开处方是无法修改药品或者诊疗项目以及附加费用单价</p>-->
            <!--<p style="margin-top:20px;">收费单价锁定：-->
                <!--<el-switch v-model="value"></el-switch>-->
            <!--</p>-->
        <!--</div>-->

    </div>
  </div>
</template>

<script>
import BreadCrumb from "@/xt_pages/components/bread-crumb";
import { getAllIsOpenInit,postXtHisIsOpen,postMonitorIsOpen,changeFuncPrint,getDataPrintList,postXtHisProjectIsOpen} from '@/api/config'

export default {
  name: "printTemplate",
  components: { BreadCrumb},
  data() {
    return {
      showViewer:false,
      crumbs: [
        { path: false, name: "管理中心" },
        { path: false, name: "基础配置" }
      ],
      value:false,
      is_open_xt_his:false,
      is_open_monitor:false,
      is_open_order:false,
      is_open_print:false,
      is_open_xt_his_project: false,
    };
  },
  methods: {
    getInitIsOpenConfig(){
      getAllIsOpenInit().then(
        response => {
          if (response.data.state === 1) {
            if(response.data.data.is_open_xt_his == 1) {
              this.is_open_xt_his = true

            }else{
              this.is_open_xt_his = false
            }

            if(response.data.data.is_open_xt_his_project == 1) {
              this.is_open_xt_his_project = true

            }else{
              this.is_open_xt_his_project = false
            }

          } else {
            this.$message.error(response.data.msg)
          }
        }
      )

    },
    changeFuncOne(val){
      if(this.is_open_xt_his){
        let params={
          is_open:this.is_open_xt_his
        }
        postXtHisIsOpen(params).then(
          response => {
            if (response.data.state === 1) {
              this.is_open_xt_his = response.data.data.is_open

            } else {
              this.$message.error(response.data.msg)
            }
          }
        )
      }else{
        let params={
          is_open:this.is_open_xt_his
        }
        postXtHisIsOpen(params).then(
          response => {
            if (response.data.state === 1) {
              this.is_open_xt_his = response.data.data.is_open

            } else {
              this.$message.error(response.data.msg)
            }
          }
        )
      }
    },
    changeFuncProject(val){
      if(this.is_open_xt_his_project){
        let params={
          is_open:this.is_open_xt_his_project
        }
        postXtHisProjectIsOpen(params).then(
          response => {
            if (response.data.state === 1) {
              this.is_open_xt_his_project = response.data.data.is_open

            } else {
              this.$message.error(response.data.msg)
            }
          }
        )
      }else{
        let params={
          is_open:this.is_open_xt_his_project
        }
        postXtHisProjectIsOpen(params).then(
          response => {
            if (response.data.state === 1) {
              this.is_open_xt_his_project = response.data.data.is_open

            } else {
              this.$message.error(response.data.msg)
            }
          }
        )
      }
    },


    changeFuncTwo(){
      console.log("3333333",this.is_open_monitor)
      var is_open = 0
      if(this.is_open_monitor == true){
          is_open = 1
       }
       if(this.is_open_monitor == false){
         is_open = 2
       }
      let params = {
         is_open:is_open,
       }
     console.log("params",params)
      postMonitorIsOpen(params).then(response=>{
         if(response.data.state == 1){
            var config = response.data.data.config
            this.$message.success("成功")
            this.getMonitorConfig()
         }
      })
    },
    getMonitorConfig(){
      getMonitorConfig().then(response=>{
         if(response.data.state == 1){
           var config =  response.data.data.config
           console.log("config",config)
           if (config.is_open == 1) {
              this.is_open_monitor = true
           }
           if (config.is_open == 2) {
              this.is_open_monitor = false
           }
         }
      })
    },

    changeFuncThree(){
      var is_open = 0
      if(this.is_open_order == true){
          is_open = 1
       }
       if(this.is_open_order == false){
         is_open = 2
       }
      let params = {
         is_open:is_open,
       }
      addOrderConfig(params).then(response=>{
         if(response.data.state == 1){
           var config = response.data.data.config
           this.$message.success("成功")
           this.getOrderConfig()
         }
      })
    },
    getOrderConfig(){
      getOrderConfig().then(response=>{
        if(response.data.state == 1){
           var config =  response.data.data.config
          if (config.is_open == 1) {
              this.is_open_order = true
           }
           if (config.is_open == 2) {
              this.is_open_order = false
           }
        }
      })
    },

    changeFuncPrint(val){
      console.log("val22222",val)
      var is_open  = 0
      if(val == true){
         is_open = 1
      }
      if(val == false){
        is_open = 0
      }
      var params = {
        is_open:is_open,
      }

      changeFuncPrint(params).then(response=>{
         if(response.data.state == 1){
           var dataPrint =  response.data.data.dataPrint
           this.$message.success("保存成功")
           this.getDataPrintList()
         }
      })
    },

    getDataPrintList(){
      getDataPrintList().then(response=>{
         if(response.data.state ==1){
           var dataPrint = response.data.data.dataPrint
           console.log("列表数据",dataPrint)
           if(dataPrint.is_open == 1){
              this.is_open_print = true
           }
           if(dataPrint.is_open == 0){
              this.is_open_print = false
           }
         }
      })
    }

  },
  created() {
    this.getInitIsOpenConfig()
    // this.getMonitorConfig()
    // this.getOrderConfig()
    this.getDataPrintList()
  }
};
</script>

<style lang="scss" scoped>
.configBox{
    padding-bottom:20px;
    margin-top:10px;
    border-bottom: 1px solid #000;
}
</style>


