<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="标题" prop="assetsName">
        <el-input
          v-model="queryParams.assetsName"
          placeholder="请输入标题"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
        >搜索
        </el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
        >新增
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>


    <el-table v-loading="loading" :data="assetsList" @selection-change="handleSelectionChange">
      <!--      <el-table-column type="selection" width="55" align="center" />-->
      <el-table-column label="序号" align="center" type="index"/>
      <el-table-column label="资产名称" align="center" prop="assetsName">
      </el-table-column>
      <el-table-column label="领用数量" align="center" prop="assetsNumbers"/>
      <el-table-column label="单位" align="center" prop="assetsUnit"/>
      <el-table-column label="规格型号" align="center" prop="assetsSpecs"/>
      <el-table-column label="资产类型" align="center" prop="claimType">
        <template slot-scope="scope">
          {{ scope.row.claimType === '0' ? '固定' : '低值易耗品' }}
        </template>
      </el-table-column>
      <!--      <el-table-column label="领用类型" align="center" prop="depositPlace"/>-->
      <el-table-column label="资产归属" align="center" prop="claimBelongName"/>
      <el-table-column label="领取人" align="center" prop="collectByName"/>
      <el-table-column label="领取时间" align="center" prop="collectDate"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="250px">
        <template slot-scope="scope">
          <div v-if="scope.row.state==='0'">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleUpdate(scope.row)"
              v-hasPermi="['system:assets:edit']"
            >修改
            </el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-success"
              @click="handleSubmit(scope.row)"
              v-hasPermi="['system:assets:remove']"
            >提交
            </el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              v-hasPermi="['system:assets:remove']"
            >删除
            </el-button>
          </div>

          <div v-else>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-view"
              @click="handleCheck(scope.row)"
              v-hasPermi="['system:assets:remove']"
            >查看
            </el-button>
          </div>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加物品登记对话框 -->
    <el-dialog title="新增物品领取" :visible.sync="open" width="1000px">
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row :gutter="20">
          <el-col :span="11">
            <el-form-item label="领用类型" prop="claimType">
              <el-select v-model="form.claimType" style="width: 100%  " @change="handleClaimTypeChange(form.claimType)"
                         placeholder="请选择领用类型">
                <el-option value="0" label="个人"></el-option>
                <el-option value="1" label="部门"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="11">
            <el-form-item label="资产归属" prop="claimBelongName">
              <el-input placeholder="请选择资产归属" v-model="form.claimBelongName" clearable
                        v-if="form.claimType == '0'"
                        @click.native="selectBoss1(1)"></el-input>
              <el-input v-else placeholder="请选择资产归属" v-model="form.claimBelongName"
                        @click.native.prevent="claimBelongSelectHandler"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="11">
            <el-form-item label="领用人" prop="teacherName">
              <el-input v-model="form.teacherName" placeholder="请输入领用人"
                        @click.native.prevent="handleToggle(1)"/>
            </el-form-item>
          </el-col>
          <el-col :span="11">
            <el-form-item label="领用时间" prop="collectDate">
              <el-date-picker
                style="width: 100%  "
                v-model="form.collectDate"
                type="date"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              plain
              icon="el-icon-plus"
              size="mini"
              @click="addDetail"
            >新增
            </el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              plain
              icon="el-icon-delete"
              size="mini"
              :disabled="!multiple"
              @click="deleteDetail"
            >删除
            </el-button>
          </el-col>
        </el-row>
        <el-table
          height="250"
          border
          :data="tableAssetsList"
          @selection-change="handleSelectionChange1"
        >
          <el-table-column type="selection" width="55" align="center"/>
          <el-table-column label="序号" type="index" align="center"></el-table-column>
          <el-table-column label="资产名称" align="center">
            <template slot-scope="scope">
              <el-input v-model="scope.row.assetsName" @click.native="assetsSelectHandler(scope.$index)"
                        readonly></el-input>
            </template>
          </el-table-column>
          <el-table-column label="领用数量" align="center">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.assetsNumbers"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column label="规格型号" align="center" disabled>
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.assetsSpecs" readonly
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column label="单位" align="center">
            <template slot-scope="scope">
              <el-input v-model="scope.row.assetsUnit" readonly></el-input>
            </template>
          </el-table-column>

          <el-table-column label="资产属性" align="center" prop="assetsAttribute">
            <template slot-scope="scope">
              <el-input :value="getAttributes(scope.row.assetsAttribute)" readonly/>
            </template>
          </el-table-column>
          <el-table-column label="资产分类" align="center" prop="assetsType" disabled>
            <template slot-scope="scope">
              <el-input v-model="scope.row.assetsType" readonly></el-input>
            </template>
          </el-table-column>
          <el-table-column label="存放地点" align="center" prop="depositPlace">
            <template slot-scope="scope">
              <el-input v-model="scope.row.depositPlace" readonly></el-input>
            </template>
          </el-table-column>
          <el-table-column label="备注" align="center" prop="remark">
            <template slot-scope="scope">
              <el-input v-model="scope.row.remark"
                        type="textarea"
                        :maxlength="500"
                        :autosize="{minRows: 1}"></el-input>
            </template>
          </el-table-column>
        </el-table>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!--  选择资产归属  -->
    <el-drawer ref="refDrawer" title="资产归属" :visible.sync="drawer">
      <Treeselect v-model="form.claimBelong" :options="deptTreeOption"
                  :show-count="true" @select="deptIdAndName" placeholder="请选择资产分类"/>
    </el-drawer>

    <el-drawer ref="refDrawer1" title="资产归属" :visible.sync="drawer1">
      <Treeselect v-model="form1.claimBelong" :options="deptTreeOption"
                  :show-count="true" @select="deptIdAndName1" placeholder="请选择资产分类"/>
    </el-drawer>

    <!--    修改物品领取对话框  -->
    <el-dialog title="修改物品领取" :visible.sync="open1" width="1000px">
      <el-form ref="form1" :model="form1" :rules="rules1" label-width="80px" :disabled="EditReadonly">
        <el-row :gutter="20">
          <el-col :span="11">
            <el-form-item label="领用类型" prop="claimType">
              <!--              <el-input v-model="form1.claimType" placeholder="请输入资产名称"/>-->
              <el-select v-model="form1.claimType" style="width: 100%" @change="handleClaimTypeChange(form.claimType)">
                <el-option value="0" label="个人"></el-option>
                <el-option value="1" label="部门"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="11">
            <el-form-item label="资产归属" prop="claimBelongName">
              <el-input placeholder="请选择资产归属" v-model="form1.claimBelongName" clearable
                        v-if="form1.claimType == '0'"
                        @click.native="selectBoss1(2)"></el-input>
              <el-input v-else v-model="form1.claimBelongName"
                        @click.native.prevent="claimBelongSelectHandler1"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="11">
            <el-form-item label="领用人" prop="collectByName">
              <el-input style="width: 100%" v-model="form1.collectByName" placeholder="请输入领用人"
                        @click.native.prevent="handleToggle"/>
            </el-form-item>
          </el-col>
          <el-col :span="11">
            <el-form-item label="领用时间" prop="collectDate">
              <el-input style="width: 100%" v-model="form1.collectDate" placeholder="请输入库存数量"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="11">
            <el-form-item label="资产名称" prop="assetsName">
              <el-input v-model="form1.assetsName" placeholder="请输入资产属性"/>
            </el-form-item>
          </el-col>
          <el-col :span="11">
            <el-form-item label="规格型号" prop="assetsId">
              <el-input v-model="form1.assetsId" placeholder=""/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="11">
            <el-form-item label="单位" prop="assetsUnit">
              <el-input v-model="form1.assetsUnit" placeholder="请输入资产属性"/>
            </el-form-item>
          </el-col>
          <el-col :span="11">
            <el-form-item label="数量" prop="assetsNumbers">
              <el-input v-model="form1.assetsNumbers" placeholder=""/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="11">
            <el-form-item label="资产属性" prop="assetsAttribute">
              <!--              <el-input v-model="form1.assetsAttribute" placeholder="请输入资产属性"/>-->
              <el-select v-model="form1.assetsAttribute" style="width: 100%" placeholder="请选择资产属性">
                <el-option
                  v-for="dict in dict.type.asset_attributes"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="11">
            <el-form-item label="存放地点" prop="depositPlace">
              <el-input v-model="form1.depositPlace" placeholder=""/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form1.remark" type="textarea" placeholder="请输入内容"/>
        </el-form-item>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm1" :disabled="EditReadonly">确 定</el-button>
        <el-button @click="cancel1">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 领用人   对话框-->
    <el-dialog :visible.sync="dialogVisible" width="780px" @open="dialogOpen">
      <el-form :model="queryParams2" ref="queryForm2" size="small" :inline="true" v-show="showSearch"
               label-width="68px">
        <el-form-item label="领用人" prop="teacherName">
          <el-input
            v-model="queryParams2.teacherName"
            placeholder="请输入领用人"
            clearable
            @keyup.enter.native="handleQuery2"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery2">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery2">重置</el-button>
        </el-form-item>
      </el-form>
      <el-table max-height="400" v-loading="loading" :data="claimList" @row-click="selectTeaher">
        <el-table-column label="老师姓名" align="center" prop="teacherName"/>
        <el-table-column label="老师性别" align="center" prop="sex">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.sex"/>
          </template>
        </el-table-column>
        <el-table-column label="老师电话" align="center" prop="teacherTel"/>
      </el-table>
      <pagination
        v-show="total2>0"
        :total="total2"
        :page.sync="queryParams2.pageNum"
        :limit.sync="queryParams2.pageSize"
        @pagination="handleQuery2"
      />
      <span slot="footer" class="dialog-footer">
<!--        <el-button type="primary" @click="onCloser" :disabled="!single2">确 定</el-button>-->
        <el-button @click="dialogVisible = false">取 消</el-button>

  </span>
    </el-dialog>


    <!--     资产选择对话框   -->
    <el-dialog :visible.sync="assetsNameDialogVisible">
      <el-form :model="queryParams3" ref="queryForm3" size="small" :inline="true" v-show="showSearch"
               label-width="68px">
        <el-form-item label="资产名称" prop="assetsName">
          <el-input
            v-model="queryParams3.assetsName"
            placeholder="请输入资产"
            clearable
            @keyup.enter.native="handleQuery3"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery3">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery3">重置</el-button>
        </el-form-item>
      </el-form>
      <el-table
        style="margin: 20px"
        :data="assetsInfoList"
        @row-click="assetsInfoSelect">
        <el-table-column label="序号" type="index" align="center"></el-table-column>
        <el-table-column label="资产名称" align="center" prop="assetsName"/>
        <el-table-column label="规格型号" align="center" prop="assetsSpecs"/>
        <el-table-column label="单位" align="center" prop="assetsUnit"/>
        <el-table-column label="资产属性" align="center" prop="assetsAttribute">
          <template slot-scope="scope">
            {{ getAttributes(scope.row.assetsAttribute) }}
          </template>
        </el-table-column>
        <el-table-column label="资产分类" align="center" prop="assetsType"/>
      </el-table>

      <pagination
        v-show="total3>0"
        :total="total3"
        :page.sync="queryParams3.pageNum"
        :limit.sync="queryParams3.pageSize"
        @pagination="handleQuery3"
      />
    </el-dialog>

    <TeacherSelectLite v-if="teacherOptions.open" :openSelect.sync="teacherOptions.open" :title="teacherOptions.title"
                       @getTeacherList="getTeacherList" @setTeacherInfo="setTeacherInfo"></TeacherSelectLite>
  </div>
</template>

<script>
import {
  addAssets,
  updateAssets,
  submitAssets,
  listAssets,
  addAssetsTableInfo,
  delAssets,
  listInform,
  listInform2,
  listAssests, getDeptTree, teacherListInform
} from "@/api/smartSchool/logisticsManage/objectClaim";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import TeacherSelectLite from '@/views/components/moduleComponets/TeacherSelectLite/index.vue'

export default {
  name: "ObjectClaim",
  dicts: ['asset_attributes', 'sys_user_sex'],
  components: {Treeselect, TeacherSelectLite},
  data() {
    return {
      // 选择领导人对话框
      teacherOptions: {
        open: false,
        title: '选择教师',
        token: null
      },
      addIndex: "",
      //树形控件抽屉
      drawer: false,
      drawer1: false,
      index: undefined,
      //树形控件默认配置
      defaultProps: {
        children: 'children',
        label: 'label'
      },
      // 下拉框选项
      peopleOption: [],
      deptTreeOption: [],
      //资产列表
      assetsInfoList: [],
      //资产新增弹窗
      assetsNameDialogVisible: false,
      //选择领用人   领用人信息
      collectByInfo: {},
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      ids1: [],
      // 非单个禁用
      single1: true,
      // 非多个禁用
      multiple1: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      total2: 0,
      total3: 0,
      // 物品登记表格数据
      claimList: [],
      assetsList: [],
      tableAssetsList: [],
      ids2: true,
      single2: true,
      multiple2: true,
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      open1: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        assetsName: null,
        assetsSpecs: null,
        assetsNumbers: null,
        assetsUnit: null,
        assetsAttribute: null,
        depositPlace: null,
        assetsType: null,
      },
      queryParams2: {
        pageNum: 1,
        pageSize: 10,
        teacherName: null,
        teacherTel: null,
        teacherCode: null,
        idCard: null,
        homeAddress: null,
        nation: null,
        picUrl: null,
        birthday: null,
        education: null,
        status: null,
        deptId: null,
      },
      queryParams3: {
        pageNum: 1,
        pageSize: 10,
        assetsName: undefined,
      },
      // 表单参数
      form: {
        claimType: null,
        claimBelong: null,
        claimBelongName: null,
        collectBy: null,
        collectDate: null,
        list: null
      },
      form1: {},
      // 表单校验
      rules: {
        delFlag: [
          {required: true, message: "$comment不能为空", trigger: "blur"}
        ]
      },
      rules1: {
        claimType: [
          {required: true, message: "领用类型不能为空", trigger: "blur"}

        ],
        claimBelongName: [
          {required: true, message: "资产归属不能为空", trigger: "blur"}

        ],
        collectByName: [
          {required: true, message: "领用人不能为空", trigger: "blur"}

        ],
        collectDate: [
          {required: true, message: "领用时间不能为空", trigger: "blur"}

        ],
        assetsName: [
          {required: true, message: "资产名称不能为空", trigger: "blur"}

        ],
        assetsNumbers: [
          {required: true, message: "数目不能为空", trigger: "blur"}

        ],
        delFlag: [
          {required: true, message: "$comment不能为空", trigger: "blur"}
        ]
      },
      EditReadonly: false,
      dialogVisible: false,
      dialogToken: null,
      singleVal: null
    };
  },
  created() {
    this.getList();
  },
  methods: {
    //树形抽屉
    claimBelongSelectHandler() {
      this.drawer = true;
    },
    claimBelongSelectHandler1() {
      this.drawer1 = true;
    },
    //树形控件点击事件
    deptIdAndName(node) {
      this.form.claimBelongName = node.label;
      this.form.claimBelong = node.id;
    },
    deptIdAndName1(node) {
      this.form1.claimBelongName = node.label;
      this.form1.claimBelong = node.id;
    },
    //领用类型修改时触发
    handleClaimTypeChange(claimType) {
      if (claimType == '0') {
        listInform().then(res => {
          this.peopleOption = res.rows
        })
      } else {
        getDeptTree().then(res => {
          this.deptTreeOption = res.data
        })
      }
    },
    //资产归属修改触发
    handleClaimBelongChange(claimBelong) {

      let people = this.peopleOption.filter(function (people) {
        return people.id == claimBelong;
      })
      this.form.claimBelongName = people[0].teacherName
      console.log(this.form.claimBelongName)
    },
    //资产名称选择
    assetsInfoSelect(row) {
      console.log(597, row)
      this.assetsNameDialogVisible = false;
      let tem = {
        assetsId: row.id,
        assetsName: row.assetsName,
        assetsSpecs: row.assetsSpecs,
        assetsUnit: row.assetsUnit,
        assetsAttribute: row.assetsAttribute,
        assetsType: row.assetsType
      }
      Object.assign(this.tableAssetsList[this.addIndex], tem)
    },
    //获取数据字典列表
    getAttributes(assetsAttribute) {
      if (assetsAttribute != '') {
        return this.selectDictLabel(this.dict.type.asset_attributes, Number(assetsAttribute));
      }

    },
    //资产选择
    assetsSelectHandler(index) {
      this.addIndex = index
      this.assetsNameDialogVisible = true;
      this.handleQuery3()
    },
    //tabel行点击事件  选择领用人


    selectTeaher(row) {
      // console.log(650, row)
      this.dialogVisible = false;

      if (this.dialogToken === 1) {
        this.form.teacherName = row.teacherName
        this.form.collectBy = row.id
      } else {
        this.form1.collectByName = row.teacherName
        this.form1.collectBy = row.id

      }
    },


    /** 查询物品登记列表 */
    getList() {
      this.loading = true;
      // console.log("查询物品登记列表=======>",this.queryParams, 318)
      listAssets(this.queryParams).then(response => {
        this.assetsList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    }, cancel1() {
      this.open1 = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        claimType: null,
        claimBelong: null,
        claimBelongName: null,
        teacherName: null,
        collectDate: null,
        // list: null
      };
      this.tableAssetsList = []
      this.resetForm("form");
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList(this.queryParams);
    },
    handleQuery2() {
      listInform2(this.queryParams2).then(res => {
        this.total2 = res.total
        this.claimList = res.rows
      })
    },
    handleQuery3() {
      listAssests(this.queryParams3).then(res => {
        this.assetsInfoList = res.rows
        this.total3 = res.total;
      })
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    resetQuery2() {
      this.resetForm("queryForm2");
      this.handleQuery2();
    },
    resetQuery3() {
      this.resetForm("queryForm3");
      this.handleQuery3();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    handleSelectionChange1(selection) {
      this.ids1 = selection.map(item => item.id)
      this.single1 = (selection.length !== 1) ? ids1[0] : false
      this.multiple1 = !selection.length
    },
    handleSelectionChange2(selection) {
      this.ids2 = selection.map(item => item.id)
      this.single2 = selection.length !== 1
      this.singleVal = (selection.length !== 1) ? ids2[0] : false
      this.multiple2 = !selection.length
    },
    /** 主界面新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.form.state = "0"
      // addAssetsTableInfo().then(res => {
      //   this.tableAssetsList = res.rows
      // })
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      // const id = row.id || this.ids
      this.form1 = row;
      this.open1 = true;
      this.EditReadonly = false
    },
    /** 查看按钮操作 */
    handleCheck(row) {
      this.reset();
      // const id = row.id || this.ids
      console.log(row, 767)
      this.form1 = row;
      this.open1 = true;
      this.EditReadonly = true
    },
    /** 修改按钮操作 */
    handleSubmit(row) {
      submitAssets(row.id).then(response => {
        // this.open = true;
        this.getList();
        console.log(response)
        this.$modal.msgSuccess("提交成功");
      }).catch(err => {
        console.log(err)
      });
    },
    /** 新增提交按钮 */
    submitForm() {
      this.form.list = this.tableAssetsList
      this.$refs["form"].validate(valid => {
        if (valid) {
          addAssets(this.form).then(response => {
            this.$modal.msgSuccess("新增成功");
            this.open = false;
            this.getList();
          });
        }
      });
    },
    /** 修改提交按钮 */
    submitForm1() {
      this.$refs["form1"].validate(valid => {
        if (valid) {
          if (this.form1.id != null) {
            updateAssets(this.form1).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open1 = false;
              this.getList();
            });
          } else {
            addAssets(this.form1).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open1 = false;
              this.getList();
            });
          }
        }
      });
    },

    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除该数据项？').then(function () {
        return delAssets(ids);
      }).then((res) => {
        console.log(res)
        this.getList();
        if (res.msg === "禁止删除") {
          this.$modal.msgError("删除失败：禁止删除");
        } else this.$modal.msgSuccess("删除成功");
      }).catch((err) => {
      });
    },
    addDetail() {
      this.tableAssetsList.unshift({
        assetsId: '',
        assetsName: '',
        assetsSpecs: '',
        assetsUnit: '',
        assetsNumbers: '',
        assetsAttribute: '',
        assetsType: '',
        depositPlace: '',
        remark: '',
      })
    },
    // 删除明细
    deleteDetail() {
      this.ids1.forEach(selectItem => {
        const index = this.tableAssetsList.findIndex(item => item.assetsId === this.single1);
        this.tableAssetsList.splice(index, 1);
      })
      this.selectIndexs = [];
    },

    handleToggle(val) {
      this.dialogVisible = true
      this.dialogToken = val
    },

    dialogOpen() {
      this.handleQuery2()
    },

    onCloser() {
      this.form.collectBy = this.singleVal
    },

    getTeacherList(queryForm, callback) {
      teacherListInform(queryForm).then(response => {
        callback(response.rows, response.total);
      }).catch(error => {
        callback([], 0);
      })
    },

    setTeacherInfo(item) {
      // this.form.teacherName = item.teacherName;
      if (this.teacherOptions.token === 1) {
        this.$set(this.form, 'claimBelongName', item.teacherName);
        this.$set(this.form, 'claimBelong', item.id);
      } else {
        this.$set(this.form1, 'claimBelongName', item.teacherName);
        this.$set(this.form1, 'claimBelong', item.id);
      }

    },
    selectBoss1(val) {
      this.teacherOptions.open = true;
      this.teacherOptions.token = val
    },

  }
};
</script>
