<template>
  <div>
    <el-dialog
      :title="title"
      :visible.sync="coordinatingVisible"
      @close="cancel"
    >
      <!--            <el-row :gutter="30" class="row search" type="flex" style="margin-bottom:0;">-->
      <el-form
        ref="setForm"
        :rules="addRules"
        :model="model"
        label-width="250px"
        label-suffix=":"
        label-position="right"
        size="mini"
        style="width: 100%;"
      >
        <el-form-item label="备注">
          <el-col :span="15">
            <el-input
              v-model="model.coordinatedRemark"
              type="textarea"
              style="width: 130%;"
              size="small"
              minlength="2"
              maxlength="500"
              placeholder="(选填)请输入备注信息"
            />
          </el-col>
        </el-form-item>
      </el-form>
      <!--            </el-row>-->
      <span
        slot="footer"
        class="dialog-footer"
        style="text-align: center;"
      >
        <el-button @click="cancel">取 消</el-button>
        <el-button
          type="primary"
          @click="confirm"
        >确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
  import {updateDiagnosis} from '../../utils/diagnosis';
  let vm = null;
  export default {
    props: {
      coordinatingVisible: {
        type: Boolean,
        default: false
      },
      diagnoseLogId: {
        type: Number,
        default: 0
      },
      bizType: {
        type: Number,
        default: 0
      },
    },
    data() {
      return {
        show: false,
        title: '设置待协调医生',
        confirmTxt: '确定',
        cancleTxt: '',
        _promise: null,
        model:{
          coordinatedRemark:''
        },
        addRules:{
        // coordinatedRemark: [
        //   {required: true, message: "（选填）请输入备注信息", trigger: 'blur'}
        // ]
        }
      };
    },
    created() {
      vm = this;
    },
    mounted() {
    // if(this.bizType == 8){
    //   this.title = "设置待协调医生";
    // }
    // else if(this.bizType == 10){
    //   this.title = "重新匹配医生";
    // }
    },
    methods: {
      confirm() {
        this.$refs.setForm.validate((valid) => {
          if (valid) {
            const req = {
              id:this.diagnoseLogId,
              bizType:this.bizType,
              coordinatedRemark:this.model.coordinatedRemark
            };
            updateDiagnosis(req).then(function (res) {
              if(res.code == '000000') {
                vm.cancel();
                vm.$emit('search');
              } else {
                vm.$message.error(res.message);
              }
            }).catch(function (error) {
              vm.$message.error(res.message);
            });
          }
        });

      },
      cancel() {
        this.model.coordinatedRemark = '';
        this.$emit('update:coordinatingVisible', false);
      }
    }
  };
</script>

<style lang="scss" scoped>

</style>
