<!-- 器材报修验收-->
<!-- 库管员业务管理页面 这里操作报修验收  验收后设置状态为验收完成--><!--  管理员器材报修审核-->
<template>

  <div>

    <data-table
      ref="pagingTable"
      :options="options"
      :list-query="listQuery"
      @multi-actions="handleMultiAction"
    >
      <template slot="filter-content">
        <el-input v-model="listQuery.params.id" style="width: 200px" placeholder="搜索学生编码" class="filter-item"/>
        <el-input v-model="listQuery.params.xm" style="width: 200px" placeholder="搜索学生姓名" class="filter-item"/>
        <el-select v-model="listQuery.params.nj" style="width: 200px" placeholder="搜索年级" class="filter-item">
          <el-option
            v-for="item in njDicData"
            :key="item.value"
            :label="item.text"
            :value="item.value">
          </el-option>
        </el-select>
        <el-select v-model="listQuery.params.yuanxi" style="width: 200px" placeholder="搜索学院" class="filter-item"  @change="changeXy">
          <el-option
            v-for="item in yxDicData"
            :key="item.value"
            :label="item.text"
            :value="item.value">
          </el-option>
        </el-select>
        <el-select v-model="listQuery.params.zhuanye" style="width: 200px" placeholder="搜索专业" class="filter-item" @change="changgeZy">
          <el-option
            v-for="item in selectZyData"
            :key="item.value"
            :label="item.text"
            :value="item.value">
          </el-option>
        </el-select>
        <el-select v-model="listQuery.params.banji" style="width: 200px" placeholder="搜索班级" class="filter-item" >
          <el-option
            v-for="item in selectBjData"
            :key="item.value"
            :label="item.text"
            :value="item.value">
          </el-option>
        </el-select>
        <!--        <el-input v-model="listQuery.params.qctype" style="width: 200px" placeholder="搜索器材种类" class="filter-item"/>-->
        <!--        <el-button class="filter-item" type="primary" icon="el-icon-plus" @click="handleAdd">
                  添加
                </el-button>-->
      </template>
      <template slot="data-columns">
        <el-table-column align="center" label="学生编号" prop="id"/>
        <template slot-scope="scope">
          <a style="color: #1890ff" @click="handleUpdate(scope.row)">{{ scope.row.id }}</a>
        </template>
        <el-table-column align="center" label="学生姓名" prop="xm">

        </el-table-column>

        <el-table-column :formatter="dataFormatter" align="center" label="性别" prop="xb" class-name="DIC_XB"/>
        <el-table-column :formatter="dataFormatter" align="center" label="年级" prop="nj" class-name="DIC_NJ"/>
        <el-table-column :formatter="dataFormatter" align="center" label="学院" prop="yuanxi" class-name="DIC_XY"
                         width="150px"/>
        <el-table-column :formatter="dataFormatter" align="center" label="专业" prop="zhuanye" class-name="DIC_ZY"
                         width="150px"/>
        <el-table-column :formatter="dataFormatter" align="center" label="班级" prop="banji" class-name="DIC_BJ"
                         width="100px"/>
        <el-table-column :formatter="dataFormatter" align="center" label="去向省" prop="txdzsf" class-name="DIC_SF"
                         width="100px"/>
        <el-table-column :formatter="dataFormatter" align="center" label="去向市" prop="txdzs" class-name="DIC_SS"
                         width="100px"/>


        <el-table-column align="center" label="操作">
          <template slot-scope="scope">
            <a style="color: #1890ff" @click="handleUpdate(scope.row)">
              <el-button link type="primary" size="small"
              >编辑
              </el-button>
            </a>
          </template>

        </el-table-column>

      </template>
    </data-table>

    <!--    编辑按钮按下-->
    <el-dialog :visible.sync="dialogVisible" title="编辑人员信息" width="500px">
      <el-form :model="formData" label-position="left" label-width="100px">
        <el-form-item label="器材编号">
          <el-input v-model="formData.id" disabled="disabled"/>
        </el-form-item>
        <el-form-item label="器材名">
          <el-input v-model="formData.qcmc" disabled="disabled"/>
        </el-form-item>
        <el-form-item label="器材类型">
          <el-select v-model="formData.qctype" placeholder="请选器材类型" disabled="disabled">
            <!--            <el-option
                          v-for="item in treeData"
                          :key="item.value"
                          :label="item.text"
                          :value="item.value" >
                        </el-option>-->
          </el-select>
        </el-form-item>
        <el-form-item label="主管教师">
          <el-select v-model="formData.teacherid" placeholder="请选主管教师" disabled="disabled">
            <!--            <el-option
                          v-for="item in teacherData"
                          :key="item.value"
                          :label="item.text"
                          :value="item.value">
                        </el-option>-->
          </el-select>
        </el-form-item>
        <el-form-item label="附言">
          <el-input v-model="formData.bz" disabled="disabled"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleUpCancel">取 消</el-button>
        <el-button type="primary" @click="handleSave">确 认 验 收</el-button>
      </div>
    </el-dialog>

  </div>

</template>

<script>
import DataTable from '@/components/DataTable'
import MeetRole from '@/components/MeetRole'
// import { jcqsqrData} from '@/api/sys/baseqcgl/baseqcgl'
import DepartTreeSelect from '@/components/DepartTreeSelect'
import {fetchTree} from '@/api/sys/depart/depart'
import {getSelectOptions} from '@/api/sys/dict/dict'
import {dataFormatter} from '@/utils'
import {getBjList, getZyList} from "@/api/sys/grxxgl/grxxgl";


export default {
  name: 'BysxxglList',
  components: {
    DepartTreeSelect,
    DataTable,
    MeetRole
  },

  data() {
    return {

      defaultProps: {
        value: 'value',
        text: 'text',
        label: 'deptName',
        children: 'children'
      },
      qcglData: {},
      dialogVisible: false,// 编辑是否显示

      listQuery: {
        current: 0,
        size: 10,
        total: 0,
        params: {}
      },

      formData: {
        avatar: ''
      },


      selectZyData:[],// 查询专业字典
      selectBjData:[],// 查询班级字典

      xbDicData: [], // 性别字典 DIC_XB
      mzDicData: [],// 民族字典 DIC_MZ
      pyfxDicData: [],// 培养方向字典 DIC_PYFX
      zzmmDicData: [],// 政治面貌字典 DIC_ZZMM
      njDicData: [],// 年级字典 DIC_NJ
      yxDicData: [],// 院系字典 DIC_XY
      zyDicData: [],// 专业字典 DIC_ZY
      bjDicData: [],// 班级字典 DIC_BJ
      dwxzData: [],// 单位性质 DIC_DWXZ
      dwhyData: [],// 单位行业 DIC_DWHY
      sssfData: [],// 所在省份 DIC_SF
      ssssData: [],// 所在市 DIC_SS
      sssqData: [],// 所在区 DIC_SQ


      options: {
        //  列表请求URL
        listUrl: '/student/student/paging',
        // 删除
        deleteUrl: '/lsjqcxx/lsj-qcgl/delete',
        //  批量操作列表
        multiActions: [
          {
            value: 'delete',
            label: '删除'
          }
        ]
      }
    }
  },

  //  页面初始化
  created() {
    getSelectOptions('DIC_XB').then(response => {
      //  性别字典
      this.xbDicData = response.data
    })
    getSelectOptions('DIC_MZ').then(response => {
      //  教师民族字典字典
      this.mzDicData = response.data
    })
    getSelectOptions('DIC_PYFX').then(response => {
      //  培养方向字典
      this.pyfxDicData = response.data
    })

    getSelectOptions('DIC_ZZMM').then(response => {
      //  政治面貌字典
      this.zzmmDicData = response.data
    })
    getSelectOptions('DIC_NJ').then(response => {
      //  年级字典
      this.njDicData = response.data
    })
    getSelectOptions('DIC_XY').then(response => {
      //  院系字典
      this.yxDicData = response.data
    })
    getSelectOptions('DIC_ZY').then(response => {
      //  专业字典
      this.zyDicData = response.data
      this.selectZyData = response.data
    })
    getSelectOptions('DIC_BJ').then(response => {
      //  班级字典
      this.bjDicData = response.data
      this.selectBjData =response.data
    })
    getSelectOptions('DIC_DWXZ').then(response => {
      //  单位性质字典
      this.dwxzData = response.data
    })
    getSelectOptions('DIC_DWHY').then(response => {
      //  单位行业字典字典
      this.dwhyData = response.data
    })
    getSelectOptions('DIC_SF').then(response => {
      //  所在省份字典
      this.sssfData = response.data
    })

    getSelectOptions('DIC_SS').then(response => {
      //  所在市字典
      this.ssssData = response.data
    })
    getSelectOptions('DIC_SQ').then(response => {
      //  所在区字典
      this.sssqData = response.data
    })
  },

// 方法
  methods: {
    //  格式化字典
    dataFormatter,

    // 根据学院获取专业list
    changeXy(){
      getZyList(this.form).then((response) => {

        this.listQuery.params.zhuanye='' // 专业输入框清空
        this.listQuery.params.banji='' // 班级输入框清空
        this.selectZyData=[] // 重置专业字典
        this.selectBjData=[] // 班级字典清空
        this.selectZyData = response.data // 专业字典重新赋值

      })
    },
    // 根据专业获取班级list
    changgeZy(){
      getBjList(this.form).then((response) =>{
        this.listQuery.params.banji='' // 班级输入框清空
        this.selectBjData=[] // 班级字典清空
        this.selectBjData = response.data
      })
    },

    //借出申请按钮按下
    handleUpdate(row) {
      this.dialogVisible = true
      this.formData = row
      //  this.formData.roles = row.roleIds.split(',')
      //this.formData.password = null
    },

    //取消按钮按下
    handleUpCancel() {
      this.dialogVisible = false;
    },

    departSelected(data) {
      this.formData.id = data.id
      console.log(data + "----depart")
    },
    // 确认返还按钮按下 入参返还教师id 返还备注信息  返还器材编号
    handleSave() {
      //this.qcglData=this.formData;
      this.qcglData.bz = this.formData.bz;// 库存数量
      this.qcglData.teacherid = this.formData.teacherid; // 教师id
      this.qcglData.id = this.formData.id;//器材id
      this.qcglData.jcqcid = this.formData.jcqcid;//器材id
      jcqsqrData(this.qcglData).then((response) => {
        this.$message({
          type: 'success',
          message: '验收成功!'
        }, {
          type: 'error',
          message: response.msg
        })
        this.dialogVisible = false
        this.dialogVisibleb = false
        this.dialogVisiblec = false
        this.$refs.pagingTable.getList()
        console.log('handlesave')
      })
    },

    //  批量操作监听
    handleMultiAction(obj) {
      if (obj.opt === 'cancel') {
        this.handleCancelOrder(obj.ids)
      }
    }
  }
}
</script>
