<template>
  <div class="content-main">
    <el-row>
      <el-form
        :inline="true"
        :model="formInlineLx"
        ref="formInlineLx"
        class="search-bm-boder"
      >
        <el-form-item label="设备名称" prop="sbmc">
          <el-input
            clearable
            v-model="formInlineLx.sbmc"
            class="inputCompatible"
            placeholder="请输入"
          ></el-input>
        </el-form-item>
        <el-form-item label="类型" prop="sblxmc">
          <el-input
            clearable
            v-model="formInlineLx.sblxmc"
            class="inputCompatible"
            placeholder="请输入"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <div class="search-button">
            <span class="search-line"></span>
            <el-button
              type="primary"
              size="small"
              class="iconfont iconchaxun"
              @click="doSearch"
              >查询</el-button
            >
            <el-button
              type="primary"
              @click="resetInfo('formInlineLx')"
              size="small"
              class="iconfont iconzhongzhi"
            >
              重置</el-button
            >
          </div>
        </el-form-item>
      </el-form>
    </el-row>
    <el-row></el-row>
    <el-row class="addBtnBg"> 企业名称: {{ this.$route.query.qymc }} </el-row>
    <el-row>
      <el-table
        :data="tableData"
        stripe
        v-loading="listLoading"
        border
        fit
        highlight-current-row
        style="width: 100%"
      >
        <el-table-column align="center" label="序号" width="70">
          <template slot-scope="scope">
            <span>{{ scope.$index + 1 }}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="sblxmc" label="类型">
          <template slot-scope="scope">{{ scope.row.sblxmc }}</template>
        </el-table-column>
        <el-table-column align="center" prop="ggxhmc" label="规格型号">
          <template slot-scope="scope">{{ scope.row.ggxhmc }}</template>
        </el-table-column>
        <el-table-column align="center" prop="sbmc" label="名称">
          <template slot-scope="scope">{{ scope.row.sbmc }}</template>
        </el-table-column>
        <el-table-column align="center" prop="zcbm" label="资产编码">
          <template slot-scope="scope">{{ scope.row.zcbm }}</template>
        </el-table-column>
        <el-table-column align="center" prop="kcsl" label="库存数量">
          <template slot-scope="scope">{{ scope.row.kcsl }}</template>
        </el-table-column>
        <el-table-column align="center" width="180" label="操作">
          <template slot-scope="scope">
            <el-tooltip
              class="item"
              effect="light"
              content="查看"
              placement="top"
            >
              <el-button
                @click="detailSubmit(scope.row.sblxbh)"
                type="primary"
                size="small"
                class="operate_show_btn iconfont iconchakan2"
              ></el-button>
            </el-tooltip>
            <!--    <el-tooltip
							class="item"
							effect="light"
							content="添加"
							placement="top"
						>
            <el-button
              @click="addMxSubmit(scope.row)"
              type="primary"
              size="small"
              class="operate_edit_btn iconfont iconxinzeng"
            ></el-button>
            </el-tooltip>
            <el-tooltip
							class="item"
							effect="light"
							content="删除"
							placement="top"
						>
            <el-button  
            @click="deleteSubmit(scope.row.sblxbh)" 
             type="primary"  size="small"  
             class="operate_delete_btn iconfont iconshanchu">
             </el-button> 
             </el-tooltip> -->
          </template>
        </el-table-column>
      </el-table>
    </el-row>
    <el-row>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page.sync="pageForm.page"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="pageForm.size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="pageForm.total"
      ></el-pagination>
    </el-row>

    <el-dialog
      :visible.sync="addDialog"
      title="设备类型维护"
      :close-on-click-modal="false"
      width="48%"
    >
      <!-- <el-form ref="dialogForm" :model="dialogForm" label-width="220px" :rules="rules"> -->
      <el-form
        ref="dialogForm"
        :model="dialogForm"
        :rules="rules"
        label-width="100px"
      >
        <el-row>
          <el-col :span="12">
            <el-form-item label="设备类型" prop="sblxmcbh">
              <el-select
                @change="sblxChange"
                clearable
                v-model="dialogForm.sblxmcbh"
                :disabled="disSign"
                filterable
                placeholder="请选择"
              >
                <el-option
                  v-for="item in sblxOptions"
                  :key="item.dictCode"
                  :label="item.dictName"
                  :value="item.dictCode"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设备名称" :disabled="disSign" prop="sbmcbm">
              <el-cascader
                clearable
                @change="sbmcChange"
                v-model="dialogForm.sbmcbm"
                placeholder="设备名称"
                :props="defaultParams"
                :options="sbmcOptions"
                :show-all-levels="false"
                filterable
              ></el-cascader>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="规格型号" prop="ggxhmc">
              <el-input
                v-model="dialogForm.ggxhmc"
                :disabled="disSign"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="资产编码" prop="zcbm">
              <el-input v-model="dialogForm.zcbm" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <div style="text-align: center; margin-top: 20px">
              <el-button
                icon="iconfont icontijiao"
                type="primary"
                v-if="dialogTitle === 'add'"
                @click="saveSubmit"
                >保存</el-button
              >

              <el-button
                type="primary"
                icon="iconfont iconfanhui"
                @click="cancel"
                >返回</el-button
              >
              <!-- <el-button
              icon="iconfont icontijiao"
              type="primary"
              v-if="dialogTitle === 'edit'"
              :disabled="updateDisSign"
              @click="updateSubmit('dialogForm')"
            >保存</el-button>
            <el-button
              icon="iconfont icontijiao"
              type="primary"
              v-if="dialogTitle === 'edit'"
              :disabled="updateDisSign"
              @click="updateSubmit('dialogForm')"
              >提交</el-button>-->
            </div>
          </el-col>
        </el-row>
      </el-form>
    </el-dialog>
    <el-dialog
      :visible.sync="addInfoDialog"
      title="设备信息维护"
      :close-on-click-modal="false"
      width="48%"
    >
      <!-- <el-form ref="dialogForm" :model="dialogForm" label-width="220px" :rules="rules"> -->
      <el-form
        ref="dialogFormInfo"
        :rules="rules1"
        :model="dialogFormInfo"
        label-width="100px"
      >
        <el-row>
          <el-col :span="12">
            <el-form-item label="设备编号" prop="sbbh">
              <el-input
                v-model="dialogFormInfo.sbbh"
                :disabled="disSign"
                readonly="readonly"
                placeholder="系统自动生成"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="单价(万元)" prop="cgjg">
              <el-input
                v-model="dialogFormInfo.cgjg"
                :disabled="disSign"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="入库数量" prop="sbsl">
              <el-input
                v-model="dialogFormInfo.sbsl"
                :disabled="disSign"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="单位" prop="sbdwmc">
              <el-select
                v-model="dialogFormInfo.sbdwmc"
                :disabled="disSign"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in dwOption"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="生产日期" prop="scrq">
              <!-- <el-input v-model="dialogFormInfo.scrq" :disabled="disSign"></el-input> -->
              <el-date-picker
                style="width: 100%"
                v-model="dialogFormInfo.scrq"
                type="date"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="选择日期"
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="入库日期" prop="rkrq">
              <!-- <el-input v-model="dialogFormInfo.rkrq" :disabled="disSign"></el-input> -->
              <el-date-picker
                style="width: 100%"
                v-model="dialogFormInfo.rkrq"
                type="date"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="选择日期"
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="生产厂家" prop="sccj">
              <el-input
                v-model="dialogFormInfo.sccj"
                :disabled="disSign"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设备状态" prop="sbzt">
              <el-input v-model="dialogFormInfo.sbzt" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设备使用年限" prop="sysm">
              <el-date-picker
                style="width: 100%"
                v-model="dialogFormInfo.sysm"
                type="year"
                value-format="yyyy"
                placeholder="选择年限"
                :disabled="disSign"
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="操作人" prop="djr">
              <el-input
                v-model="dialogFormInfo.djr"
                :disabled="true"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="操作时间" prop="whsj">
              <!-- <el-input v-model="dialogFormInfo.whsj" :disabled="disSign"></el-input> -->
              <el-date-picker
                style="width: 100%"
                v-model="dialogFormInfo.whsj"
                type="date"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="选择日期"
                :disabled="true"
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <div style="text-align: center; margin-top: 20px">
              <el-button
                icon="iconfont icontijiao"
                type="primary"
                v-if="dialogTitleInfo === 'add'"
                @click="saveSubmitInfo('save')"
                >保存</el-button
              >
              <el-button
                type="primary"
                icon="iconfont iconfanhui"
                @click="cancelInfo"
                >返回</el-button
              >
              <!-- <el-button
              icon="iconfont icontijiao"
              type="primary"
              v-if="dialogTitleInfo === 'edit'"
              @click="updateSubmitInfo('dialogFormInfo')"
            >保存</el-button>
            <el-button
              icon="iconfont icontijiao"
              type="primary"
              v-if="dialogTitleInfo === 'edit'"
              @click="updateSubmitInfo('dialogFormInfo')"
              >提交</el-button>-->
            </div>
          </el-col>
        </el-row>
      </el-form>
    </el-dialog>
    <el-dialog :visible.sync="infoDialog" title="设备信息列表" width="1200px">
      <el-table
        :data="tableDataInfo"
        stripe
        v-loading="listLoading"
        border
        fit
        highlight-current-row
        style="width: 100%"
      >
        <el-table-column align="center" label="序号" width="70">
          <template slot-scope="scope">
            <span>{{ scope.$index + 1 }}</span>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          align="center"
          prop="sblxmc"
          label="类型"
        >
          <template slot-scope="scope">{{ scope.row.sbfl }}</template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          align="center"
          prop="ggxhmc"
          label="规格型号"
        >
          <template slot-scope="scope">{{ scope.row.sbggxh }}</template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          align="center"
          prop="sbmc"
          label="名称"
        >
          <template slot-scope="scope">{{ scope.row.sbyqmc }}</template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          align="center"
          prop="zcbh"
          label="资产编码"
        >
          <template slot-scope="scope">{{ scope.row.zcbh }}</template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          align="center"
          prop="sbbh"
          label="设备编号"
        >
          <template slot-scope="scope">{{ scope.row.sbbh }}</template>
        </el-table-column>
        <el-table-column
          align="center"
          prop="rkrq"
          label="入库日期"
          width="110"
        >
          <template slot-scope="scope">{{ scope.row.rkrq }}</template>
        </el-table-column>
        <!-- <el-table-column align="center" prop="sbsl"  label="入库数量">
            <template slot-scope="scope">{{scope.row.sbsl}}</template>
        </el-table-column>-->
        <el-table-column
          show-overflow-tooltip
          align="center"
          prop="cgjg"
          label="单价"
        >
          <template slot-scope="scope">{{ scope.row.cgjg }}</template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          align="center"
          prop="sysm"
          label="使用年限"
        >
          <template slot-scope="scope">{{ scope.row.sysm }}</template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          align="center"
          prop="sccj"
          label="生产厂家"
        >
          <template slot-scope="scope">{{ scope.row.sccj }}</template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          align="center"
          prop="djr"
          label="操作人"
        >
          <template slot-scope="scope">{{ scope.row.djr }}</template>
        </el-table-column>
        <el-table-column
          align="center"
          prop="whsj"
          width="110"
          label="操作时间"
        >
          <template slot-scope="scope">{{ scope.row.whsj }}</template>
        </el-table-column>
      </el-table>
      <el-row>
        <el-pagination
          @size-change="handleSizeChangeInfo"
          @current-change="handleCurrentChangeInfo"
          :current-page.sync="pageFormInfo.page"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="pageFormInfo.size"
          layout="total, sizes, prev, pager, next, jumper"
          :total="pageFormInfo.total"
        ></el-pagination>
      </el-row>
    </el-dialog>
  </div>
</template>


<script>
import {
  getPageList,
  detailsFn,
  deleteFn,
  addFn,
  editFn,
  getPageListLx,
  addFnLx,
  sbfindByGroupId,
} from "@/api/jcxxwh/sbxx";
import { dateFormat } from "@/utils";
import { getCodeName } from "@/utils/statusList";
import { kd } from "@/api/jcxxwh/kd";
export default {
  data() {
    return {
      kd: "",
      formInline: {
        sblxmc: "",
        sbmc: "",
      },
      formInlineLx: {
        sblxmc: "",
        sbmc: "",
        // ssfl:1
      },
      addDialog: false,
      addInfoDialog: false,
      infoDialog: false,
      disSign: false,
      dialogTitle: "add",
      dialogTitleInfo: "add",
      dialogForm: {
        // sbxxList:[]
      },
      dialogFormInfo: {},
      defaultParams: {
        label: "dictName",
        value: "dictCode",
        children: "subDataDictionarys",
        name: "dictName",
        emitPath: false,
      },
      listLoading: false,
      tableData: [],
      tableDataInfo: [],
      pageForm: {
        page: 1,
        size: 10,
        total: 0,
      },
      pageFormInfo: {
        page: 1,
        size: 10,
        total: 0,
      },
      sblxOptions: [],
      sbmcOptions: [],
      str: "",
      dwOption: [
        { value: "个", label: "个" },
        { value: "台", label: "台" },
        { value: "立方米", label: "立方米" },
        { value: "平方米", label: "平方米" },
        { value: "件", label: "件" },
        { value: "吨", label: "吨" },
        { value: "米", label: "米" },
      ],
      rules: {
        sblxmcbh: [
          { required: true, message: "请选择设备类型", trigger: "change" },
        ],
        sbmcbm: [
          { required: true, message: "请选择设备名称", trigger: "change" },
        ],
      },
      rules1: {
        cgjg: [
          { required: true, message: "请输入单价", trigger: "blur" },
          {
            pattern: /^\d{1,10}(\.\d{1,6})?$/,
            message: "限数字,单价精确到六位小数点",
          },
        ],
        rkrq: [
          { required: true, message: "请选择入库日期", trigger: "change" },
        ],
        sbsl: [
          { required: true, message: "请输入数量", trigger: "blur" },
          { pattern: /^\d{1,10}$/, message: "限数字,限 10 字符" },
        ],
      },
    };
  },
  created() {
    sbfindByGroupId({ groupId: "5476", pdictCode: "5476" }).then((res) => {
      if (res.infoCode == 200) {
        this.sblxOptions = res.data;
      }
    });
    // this.init()
    this.getList();
  },
  methods: {
    doSearch() {
      this.pageForm.page = 1;
      this.getList();
    },
    resetInfo(formName) {
      this.$refs[formName].resetFields();
      this.doSearch();
    },
    init() {
      kd().then((res) => {
        if (!res) return;
        if (!res.data[0]) return;
        this.kd = res.data[0].kddm;
        this.getList();
      });
    },
    dateFormat: dateFormat,
    //获取列表
    getList() {
      this.formInlineLx.tyshxydm = this.$route.query.tyshxydm;
      this.formInlineLx.kddm = this.kd;
      getPageListLx(this.pageForm, this.formInlineLx).then((res) => {
        if (res.infoCode == 200) {
          this.tableData = res.data.list;
          this.pageForm.total = res.data.total;
        }
      });
    },
    sblxChange(val) {
      let pdictCode = "";
      this.sblxOptions.map((item) => {
        if (item.dictCode == val) {
          pdictCode = item.dictCode;
        }
      });
      if (val) {
        sbfindByGroupId({ groupId: "5476", pdictCode: pdictCode }).then(
          (res) => {
            if (res.infoCode == 200) {
              this.sbmcOptions = this.getTreeData(res.data);
            }
          }
        );
      } else {
        this.sbmcOptions = [];
      }
    },
    sbmcChange(val) {
      if (val) {
        this.dialogForm.zcbm = val;
      } else {
        this.dialogForm.zcbm = "";
      }
    },
    getTreeData(data) {
      // 循环遍历json数据

      for (let i = 0; i < data.length; i++) {
        console.log(data[i].subDataDictionarys.length);

        if (
          data[i].subDataDictionarys == null ||
          data[i].subDataDictionarys.length < 1
        ) {
          // subDataDictionarys
          data[i].subDataDictionarys = undefined;
        } else {
          // subDataDictionarys 递归调用 本方法
          this.getTreeData(data[i].subDataDictionarys);
        }
      }
      return data;
    },
    getTreeVal(data, val) {
      // 循环遍历json数据
      console.log(data, val, "data,val");
      if (data.length > 0) {
        for (let i = 0; i < data.length; i++) {
          if (data[i].subDataDictionarys == undefined) {
            // subDataDictionarys
            if (data[i].dictCode == val) {
              // console.log(data[i].dictName)
              this.str = data[i].dictName;
            }
          } else {
            // subDataDictionarys 递归调用 本方法
            this.getTreeVal(data[i].subDataDictionarys, val);
          }
        }
      } else {
        if (data.dictCode == val) {
          this.str = data.dictName;
        }
      }
      console.log(this.str, "return");
      return this.str;
    },
    //类型新增
    addSubmit() {
      this.rest();
      this.addDialog = true;
    },
    //类型新增保存确认
    saveSubmit() {
      this.$refs["dialogForm"].validate((valid) => {
        if (valid) {
          this.dialogForm.sblxmc = getCodeName(
            this.dialogForm.sblxmcbh,
            this.sblxOptions,
            "dictCode",
            "dictName"
          );
          this.dialogForm.tyshxydm = sessionStorage.getItem("tyshxydm");
          // this.dialogForm.sbmcbm = this.dialogForm.sbmcbm.length == 1 ?this.dialogForm.sbmcbm.join() : this.dialogForm.sbmcbm.slice(-2,1).join();
          // console.log(this.dialogForm.sbmcbm)
          this.dialogForm.sbmc = this.getTreeVal(
            this.sbmcOptions,
            this.dialogForm.sbmcbm
          );
          this.dialogForm.jgId = sessionStorage.orgCode;
          this.dialogForm.kddm = this.kd;
          addFnLx(this.dialogForm).then((res) => {
            if (res.infoCode == 200) {
              this.$message({
                message: "新增成功",
                type: "success",
              });
              this.addDialog = false;
              this.rest();
              this.getList();
            } else {
              this.$message({
                message: res.msg,
                type: "error",
              });
            }
          });
        }
      });
    },

    //详情
    detailSubmit(sbbh) {
      this.infoDialog = true;
      this.formInline.sblxbh = sbbh;
      getPageList(this.pageFormInfo, this.formInline).then((res) => {
        if (res.infoCode == 200) {
          res.data.list.map((item) => {
            if (item.rkrq) {
              // item.rkrq = dateFormat(item.rkrq);
              item.rkrq = item.rkrq.slice(0, 10);
            }
          });
          this.tableDataInfo = res.data.list;
          this.pageFormInfo.total = res.data.total;
        }
      });
    },
    addMxSubmit(row) {
      this.restInfo();
      this.dialogFormInfo.sbfl = row.sbmc;
      this.dialogFormInfo.sbggxh = row.ggxhmc;
      this.dialogFormInfo.sbyqmc = row.sbmc;
      this.dialogFormInfo.zcbh = row.zcbm;
      this.dialogFormInfo.djr = sessionStorage.getItem("userName");
      var date = new Date();
      var year = date.getFullYear();
      var month =
        date.getMonth() + 1 < 10
          ? "0" + (date.getMonth() + 1)
          : date.getMonth() + 1;
      var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
      var hours =
        date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
      var minutes =
        date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
      var seconds =
        date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
      this.dialogFormInfo.whsj =
        year +
        "-" +
        month +
        "-" +
        day +
        " " +
        hours +
        ":" +
        minutes +
        ":" +
        seconds;
      this.dialogFormInfo.sblxbh = row.sblxbh;
      this.dialogTitleInfo = "add";
      this.addInfoDialog = true;
      this.dialogFormInfo.sbzt = "正常";
    },
    saveSubmitInfo(status) {
      this.$refs["dialogFormInfo"].validate((valid) => {
        if (valid) {
          if (status == "save") {
            this.dialogFormInfo.ssfl = 1;
            this.dialogFormInfo.sfba = 1;
            this.dialogFormInfo.jgId = sessionStorage.orgCode;
            this.dialogFormInfo.kddm = this.kd;
            addFn(this.dialogFormInfo).then((res) => {
              if (res.infoCode == 200) {
                this.$message({
                  message: "新增成功",
                  type: "success",
                });
                this.addInfoDialog = false;
                this.restInfo();
                this.getList();
              } else {
                this.$message({
                  message: res.msg,
                  type: "error",
                });
              }
            });
          } else if (status == "send") {
            this.dialogFormInfo.ssfl = 1;
            this.dialogFormInfo.sfba = 2;
            this.dialogFormInfo.jgId = sessionStorage.orgCode;
            this.dialogFormInfo.kddm = this.kd;
            addFn(this.dialogFormInfo).then((res) => {
              if (res.infoCode == 200) {
                this.$message({
                  message: "新增成功",
                  type: "success",
                });
                this.addDialogInfo = false;
                this.restInfo();
                this.getList();
              } else {
                this.$message({
                  message: res.msg,
                  type: "error",
                });
              }
            });
          }
        }
      });
    },
    //删除
    deleteSubmit(rowId) {
      this.$confirm("此操作将永久删除, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          deleteFn(rowId).then((res) => {
            if (res.infoCode == 200) {
              this.$message({
                message: "删除成功",
                type: "success",
              });
              this.getList();
            } else {
              this.$message({
                message: "删除失败",
                type: "error",
              });
              this.getList();
            }
          });
        })
        .catch(() => {
          this.$message({
            message: "已取消删除",
            type: "warning",
          });
        });
    },
    // 编辑
    editSubmit(id) {
      detailsFn(id).then((res) => {
        this.dialogForm = res.data;
        this.addDialog = true;
      });
    },
    // 编辑确认
    updateSubmit() {
      this.$refs[formObj].validate((valid) => {
        if (valid) {
          editFn(this.dialogForm).then((res) => {
            this.$notify({
              title: "提示",
              message: "修改成功",
              type: "success",
              duration: 2000,
            });
            this.addDialog = false;
            this.rest();
            this.getList();
          });
        } else {
          return false;
        }
      });
    },
    // 设备类型取消返回
    cancel() {
      this.addDialog = false;
    },
    cancelInfo() {
      this.addInfoDialog = false;
    },
    /* 初始化表单*/
    rest() {
      this.dialogForm = {
        // sbxxList:[]
      };
      if (this.$refs["dialogForm"] !== undefined) {
        this.$refs["dialogForm"].resetFields();
      }
    },
    restInfo() {
      this.dialogFormInfo = {};
      if (this.$refs["dialogFormInfo"] !== undefined) {
        this.$refs["dialogFormInfo"].resetFields();
      }
    },
    handleSizeChange(val) {
      this.pageForm.size = val;
      this.getList();
    },
    handleCurrentChange(val) {
      this.pageForm.page = val;
      this.getList();
    },
    handleSizeChangeInfo(val) {
      this.pageFormInfo.size = val;
      getPageList(this.pageFormInfo, this.formInline).then((res) => {
        this.tableDataInfo = res.data.list;
        this.pageFormInfo.total = res.data.total;
      });
    },
    handleCurrentChangeInfo(val) {
      this.pageFormInfo.page = val;
      getPageList(this.pageFormInfo, this.formInline).then((res) => {
        this.tableDataInfo = res.data.list;
        this.pageFormInfo.total = res.data.total;
      });
    },
  },
};
</script>
<style scoped>
.h3 {
  text-align: center;
  font-size: 1em;
  line-height: 2.5;
  color: #fff;
  background-color: #49a2fa;
  margin-bottom: 20px;
}
</style>
