<template>
  <div>
    <xy-dialog ref="dialog" :width="40" :is-show.sync="isShow" :type="'form'" title="履责填报" :form="form"
      :rules='rules' @submit="submit">
      <template v-slot:menu>
        <div class="xy-table-item">
          <div class="xy-table-item-label" style="font-weight: bold">
            <span style="color: red;font-weight: bold;padding-right: 4px;"></span>评价项目：
          </div>
          <div class="xy-table-item-content">
            {{form.menu}}
          </div>
        </div>
      </template>
      <template v-slot:normal_score>
        <div class="xy-table-item">
          <div class="xy-table-item-label" style="font-weight: bold">
            <span style="color: red;font-weight: bold;padding-right: 4px;"></span>标准分值：
          </div>
          <div class="xy-table-item-content">
            {{form.normal_score}}分
          </div>
        </div>
      </template>


      <template v-slot:methods>
        <div class="xy-table-item">
          <div class="xy-table-item-label" style="font-weight: bold">
            <span style="color: red;font-weight: bold;padding-right: 4px;"></span>评价方法及评分标准：
          </div>
          <div class="xy-table-item-content">
            {{form.methods}}
          </div>
        </div>
      </template>
      <template v-slot:content>
        <div class="xy-table-item">
          <div class="xy-table-item-label" style="font-weight: bold">
            <span style="color: red;font-weight: bold;padding-right: 4px;"></span>内容：
          </div>
          <div class="xy-table-item-content">
            <el-input v-model="form.content1" type="textarea" placeholder="请输入内容" clearable
              style="width: 400px;"></el-input>
          </div>
        </div>
      </template>

  <!--    <template v-slot:footerContent>
        <Button type="primary" style='margin-left:5px;margin-bottom:5px;' @click="clickSubmit">确认</Button>
        <Button type="primary" ghost style='margin-left:5px;margin-bottom:5px;' @click="isShow=false">取消</Button>
      </template> -->

    </xy-dialog>

  </div>
</template>

<script>
  import {
    Message
  } from 'element-ui'
  import {
    show,
    save
  } from '@/api/task/newplan.js'
  import {
    getparameteritem
  } from "@/api/system/dictionary.js";
  export default {
    components: {

    },
    data() {
      return {
        isShow: false,
        type: 'add',
        id: '',
        form: {
          // pid:0,
          // pname:'',
          // name: '',
          // year: '',
          menu: '',
          total_score:'',
          // level:'',
          // third_level:'',
          normal_score:'',
          methods:'',
          content: '',
          // true_score:''
        },
        levelList:[],
        depList:[],
        checkAll: false,
        isIndeterminate: true,
        menuList: [],
        levelList: [],
        showMenu:false,
        rules: {

        }
      }
    },
    created() {
      // this.loadDeptOptions()
    },
    methods: {
      setName(e){
        if(e){
          this.form.name = e
        }
      },
      setYear(e){
        if(e){
          this.form.year = e
        }
      },
      setMenu(e){
        if(e){
          this.form.menu = e
          this.form.pname = e
        }
      },
      setPid(e){
        if(e){
          this.form.pid = e
        }
        console.log("e",e)
      },
      changeMenu(e){
        if(e){
          this.menuList.map(item=>{
            if(e===item){
              this.levelList = item.remark?item.remark.split("、"):[]
            }
          })
        }
      },
      submit() {
        return
        if (this.id) {
          this.form.id = this.id
        }
        save({
          table_name: 'new_scores',
          ...this.form
        }).then(res => {
          Message({
            type: 'success',
            message: this.type === 'add' ? '新增打分表成功' : '编辑打分表成功'
          })
          this.$emit('refresh')
          this.isShow = false

        })
      },
      getDetail() {
        show({
          id: this.id,
          table_name: 'new_scores',
        }).then(res => {
          this.form = {
            // pid:res?.pid,
            // pname:res?.pname,
            // name: res?.name,
            // year: res?.year,
            menu: res?.menu,
            // total_score:res?.total_score,
            // level:'',
            // third_level:'',
            normal_score:res?.normal_score,
            methods:res?.methods,
            content: res?.content,
            true_score:res?.true_score


          }
        })
      }

    },
    watch: {
      isShow(newVal) {
        if (newVal) {
            this.getDetail()
        } else {
          this.id = ''
          this.showMenu = false
          this.$refs['dialog'].reset()
        }
      },
    }

  }
</script>

<style scoped lang="scss">

  ::v-deep .pid,
  ::v-deep .pname{
    display: none;
  }
  ::v-deep .menu,
  ::v-deep .normal_score,
  ::v-deep .methods,
  ::v-deep .content{
      flex-basis: 100%;
  }
  ::v-deep .xy-table-item-label {
    margin-right: 10px;
    width:140px;
    max-width: 140px;
  }


</style>
