<template>
  <div class="content-main">
    <el-form
      :model="searchform"
      ref="form"
      label-width="80px"
      :inline="true"
      class="search-bm-boder"
      label-position="left"
    >
      <el-form-item>
        <label slot="label">罐&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号:</label>
        <el-input v-model="searchform.ygmc" clearable></el-input>
      </el-form-item>
      <el-form-item label="建造日期:">
        <el-date-picker
          v-model="searchform.sjnd"
          type="daterange"
          unlink-panels
          value-format="yyyy-MM-dd"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          style="width: 250px"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <div class="search-button">
          <span class="search-line"></span>
          <!-- <div class="search-select" @click="searchShowMoreBool=!searchShowMoreBool">更多条件 <i class="el-icon-arrow-up" v-show="searchShowMoreBool"></i><i class="el-icon-arrow-down" v-show="!searchShowMoreBool"></i></div> -->
          <el-button
            type="primary"
            @click="getMaintainList"
            size="small"
            class="iconfont iconchaxun"
            >查询</el-button
          >
          <el-button
            type="primary"
            @click="reastGetMaintainList"
            size="small"
            class="iconfont iconzhongzhi"
            >重置</el-button
          >
        </div>
      </el-form-item>
    </el-form>
    <!-- <el-row class="addBtnBg">
      <el-button type="primary" @click="adddetail()" class="iconfont iconxinzeng">新建</el-button>
    </el-row> -->

    <el-table v-loading="loading" :data="maintainlist" border stripe>
      <el-table-column
        fixed
        type="index"
        label="序号"
        width="60"
        align="center"
        show-overflow-tooltip
      ></el-table-column>
      <el-table-column
        prop="ygmc"
        label="罐号"
        align="center"
        show-overflow-tooltip
      ></el-table-column>
      <el-table-column
        prop="sjnd"
        label="建造日期"
        align="center"
        :formatter="dateformatter"
        show-overflow-tooltip
      ></el-table-column>
      <el-table-column
        prop="sjgr"
        label="设计罐容"
        align="center"
        show-overflow-tooltip
      >
        <template slot-scope="scope" class="cell">
          <!-- && (scope.row.sjgr).toLocaleString() -->
          <span>{{ scope.row && scope.row.sjgr }}</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="ygdmj"
        label="底面积"
        align="center"
        show-overflow-tooltip
      >
        <template slot-scope="scope" class="cell">
          <span>{{ scope.row && scope.row.ygdmj }}</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="zygd"
        label="设计储油高度"
        align="center"
        show-overflow-tooltip
      >
        <template slot-scope="scope" class="cell">
          <span>{{ scope.row && scope.row.zygd }}</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="ygnzj"
        label="单罐内直径"
        align="center"
        show-overflow-tooltip
      >
        <template slot-scope="scope" class="cell">
          <span>{{ scope.row && scope.row.ygnzj }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column
        prop="ygzt"
        label="状态"
        align="center"
        :formatter="statusformatter"
        show-overflow-tooltip
      ></el-table-column> -->
      <el-table-column label="操作" align="center" width="190">
        <template slot-scope="scope">
          <el-tooltip
            class="item"
            effect="light"
            content="查看"
            placement="top"
          >
            <el-button
              type="primary"
              @click="showYGDetail(scope.row.id, scope.row.sfba)"
              class="operate_show_btn iconfont iconchakan2"
              size="small"
            ></el-button>
          </el-tooltip>
          <!-- <el-tooltip
            class="item"
            effect="light"
            content="修改"
            placement="top"
            v-if="buttonNameList.indexOf('修改') > -1 && (scope.row.ygzt==0||scope.row.sqzt==0)"
          >
            <el-button
              type="primary"
              @click="updateDetail(scope.row.ygbh)"
              class="operate_edit_btn iconfont iconxiugai1"
              size="small"
            ></el-button>
          </el-tooltip>
          <el-tooltip
            class="item"
            effect="light"
            content="删除"
            placement="top"
            v-if="buttonNameList.indexOf('删除') > -1 && (scope.row.ygzt==0||scope.row.sqzt==0)"
          >
            <el-button
              type="primary"
              @click="handleDelete(scope.row.ygbh)"
              class="operate_delete_btn iconfont iconshanchu"
              size="small"
            ></el-button>
          </el-tooltip> -->
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      class="newspage"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="page.start"
      :page-sizes="[10, 15, 20]"
      :page-size="page.limit"
      layout="total, sizes, prev, pager, next, jumper"
      :total="page.todolcount"
    ></el-pagination>

    <el-dialog
      title="油罐信息"
      width="60%"
      center
      :visible.sync="dialogTableVisible"
      @open="handlerDialogOpen"
      @close="handlerDialogClose"
      id="tpdialog"
    >
      <el-form
        :inline="true"
        label-width="125px"
        label-position="left"
        :model="formDetail"
        ref="dialogForm"
        :rules="rules"
      >
        <el-row>
          <el-col :span="12">
            <el-form-item label="罐号：" prop="ygmc" v-if="dialogType == 2">
              <el-input
                clearable
                v-model="formDetail.ygmc"
                :disabled="isdialogView"
                class="input-box"
              ></el-input>
            </el-form-item>
            <el-form-item label="罐号：" prop="ygmcFal" v-else>
              <el-input
                clearable
                v-model="formDetail.ygmcFal"
                :disabled="isdialogView"
                class="input-box"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="单位名称：" prop="kdmc">
              <el-input
                v-model="formDetail.kdmc"
                :disabled="true"
                style="padding-right: 15px"
                class="input-box"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="建造日期：" prop="sjnd">
              <el-date-picker
                v-model="formDetail.sjnd"
                type="date"
                format="yyyy-MM-dd"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="选择日期"
                @change="sjndDateChange"
                :default-value="formDetail.sjnd"
                :disabled="isdialogView"
                class="input-box"
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设计罐容(吨)：" prop="sjgr">
              <el-input
                clearable
                v-model="formDetail.sjgr"
                v-input-float
                :disabled="isdialogView"
                class="input-box"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="罐型：" prop="yglx">
              <el-select
                v-model="formDetail.yglx"
                placeholder="请选择油罐型号"
                :disabled="isdialogView"
                class="input-box"
              >
                <el-option label="拱顶罐" value="1"></el-option>
                <el-option label="浮顶罐" value="2"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="单罐内直径：" prop="ygnzj">
              <el-input
                clearable
                v-model="formDetail.ygnzj"
                v-input-float
                :disabled="isdialogView"
                class="input-box"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="底面积：" prop="ygdmj">
              <el-input
                v-model="formDetail.ygdmj"
                v-input-float
                :disabled="isdialogView"
                class="input-box"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="油罐高度：" prop="yggd">
              <el-input
                clearable
                v-model="formDetail.yggd"
                v-input-float
                :disabled="isdialogView"
                class="input-box"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="设计储油高度：" prop="zygd">
              <el-input
                v-model="formDetail.zygd"
                v-input-float
                :disabled="isdialogView"
                class="input-box"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item
              label="出油口高度："
              prop="ygcykgd"
              label-width="115px"
              style="padding-left: 10px"
            >
              <el-input
                clearable
                v-model="formDetail.ygcykgd"
                v-input-float
                :disabled="isdialogView"
                class="input-box"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item
              label="检查口高度："
              prop="ygjckgd"
              label-width="115px"
              style="padding-left: 10px"
            >
              <el-input
                v-model="formDetail.ygjckgd"
                v-input-float
                :disabled="isdialogView"
                class="input-box"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row style="text-align: left">
          <el-form-item label="油罐图：" label-width="115px" class="scieClass">
            <el-upload
              :action="fileApi"
              list-type="picture-card"
              accept="image/*"
              :limit="1"
              :with-credentials="true"
              :headers="myHeader"
              :disabled="isdialogView"
              :on-preview="handleYGPictureCardPreview"
              :on-remove="handleYGRemove"
              :on-success="handleYGSuccess"
              :on-error="handlerError"
              :fileList="ygpmtList"
              :on-exceed="handleExceed"
            >
              <i class="el-icon-plus"></i>
            </el-upload>
            <el-dialog :visible.sync="dialogYGVisible">
              <img width="100%" :src="ygpmt" alt />
            </el-dialog>
          </el-form-item>
        </el-row>
        <el-row style="text-align: left">
          <el-form-item
            label="油罐库区图："
            label-width="115px"
            class="scieClass"
          >
            <el-upload
              :action="fileApi"
              list-type="picture-card"
              accept="image/*"
              :limit="1"
              :with-credentials="true"
              :headers="myHeader"
              :disabled="isdialogView"
              :on-preview="handleKQPictureCardPreview"
              :on-remove="handleKQRemove"
              :on-exceed="handleExceed"
              :on-error="handlerError"
              :on-success="handleKQSuccess"
              :fileList="ygkqtList"
            >
              <i class="el-icon-plus"></i>
            </el-upload>
            <el-dialog :visible.sync="dialogKQVisible">
              <img width="100%" :src="ygkqt" alt />
            </el-dialog>
          </el-form-item>
        </el-row>
      </el-form>

      <span slot="footer" class="dialog-footer">
        <el-button
          type="primary"
          size="small"
          class="iconfont iconchucun iconbaocun"
          v-show="!isdialogView"
          @click="save"
          >保存</el-button
        >
        <el-button
          type="primary"
          size="small"
          class="iconfont iconfabu"
          v-show="!isdialogView"
          @click="publish"
          >发布</el-button
        >
        <el-button
          type="primary"
          size="small"
          class="iconfont iconfanhui"
          @click="cancel"
          >返回</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { authorityControl } from "@/api/menuList";
import {
  selectEmptyPotApplyList,
  searchPotApplyList,
  deleteEmptyPotApplyList,
  selectEmptyPotApplyListnumber,
  addEmptyPotApplyList,
  updateEmptyPotApplyList,
  getSlqy,
  getKDDetail,
  downloadPic,
} from "@/api/grainReserves/accEmptywarehouse/applyManymentMaintain/index";
import { getToken } from "@/utils/auth";
import { FileApi } from "@/api/index";
export default {
  name: "index",
  data() {
    return {
      buttonNameList: [],
      fileApi: FileApi + "/file/upload",
      downloadPicUrl: `${FileApi}/file/download?id=`,
      dialogTableVisible: false,
      loading: false,
      //搜索
      searchform: {
        ygbh: "", // 油罐编号 后端生成 唯一标识
        ygmc: "", // 罐号, 油罐名称
        sjnd: [], //
        jzksrq: "",
        jzjsrq: "",
        kddm: this.$route.query.kddm,
      },
      searchformBak: {},
      //列表数据
      maintainlist: [],
      // 分页
      page: {
        start: 1, //当前第几页
        limit: 10, //每页显示的个数
        todolcount: 0, //总数
        todopage: 0, //总页数
      },
      formDetail: {
        // ygbh: '', //油罐编号 str
        ygmcFal: "", // 罐号, 油罐名称
        kddm: "", // 库点编号
        kdmc: "", //库点名称
        sjgr: "", // 设计罐容 double
        sjnd: "", // 设计年代 date
        yglx: "", // 油罐类型
        ygnzj: "", // 油罐内直径 str
        ygdmj: "", //油罐底面积 str
        yggd: "", // 油罐高度 int
        zygd: "", //装油高度  int
        ygcykgd: "", //油罐出油口高度 str
        ygjckgd: "", // 油罐检查口高度 str,
        ygpmt: "", // 图片id
        ygkqt: "", // 图片id
        // ygzt:'0', // 0 草稿, 1 已发布
      },
      formDetailBak: {},
      ygpmtList: [],
      ygpmt: "", // 油罐平面图
      dialogYGVisible: false,
      dialogType: 1, // 1 新增, 2 查看, 3 修改
      ygkqt: "", // 油罐库区图
      ygkqtList: [],
      dialogKQVisible: false,
      rules: {
        ygmcFal: [
          {
            required: true,
            message: "请输入油罐名称",
            trigger: ["change", "blur"],
          },
          {
            pattern: /^[0-9a-zA-Z]{1,10}$/g,
            message: "限字母或数字,限 10 字符",
          },
        ],
        kdmc: [
          {
            required: true,
            message: "必填项",
          },
        ],
        sjnd: [
          {
            required: true,
            message: "请选择建造日期",
            trigger: ["change", "blur"],
          },
        ],
        sjgr: [
          {
            required: true,
            message: "请输入设计罐容",
            trigger: ["change", "blur"],
          },
          { pattern: /^\d{1,5}$/, message: "限数字,限 5 字符" },
        ],
        yglx: [
          {
            required: true,
            message: "请选择油罐类型",
            trigger: "change",
          },
        ],
        ygnzj: [
          {
            required: true,
            message: "请输入油罐内直径",
            trigger: ["change", "blur"],
          },
          { pattern: /^\d{1,5}$/, message: "限数字,限 5 字符" },
        ],
        ygdmj: [
          {
            required: true,
            message: "请输入底面积",
            trigger: ["change", "blur"],
          },
          { pattern: /^\d{1,5}$/, message: "限数字,限 5 字符" },
        ],
        yggd: [
          {
            required: true,
            message: "请输入油罐高度",
            trigger: ["change", "blur"],
          },
          { pattern: /^\d{1,5}$/, message: "限数字,限 5 字符" },
        ],
        zygd: [
          {
            required: true,
            message: "请输入设计储油高度",
            trigger: ["change", "blur"],
          },
          { pattern: /^\d{1,5}$/, message: "限数字,限 5 字符" },
        ],
        ygcykgd: [
          {
            required: false,
            message: "请输入出油口高度",
            trigger: ["change", "blur"],
          },
          { pattern: /^\d{1,5}$/, message: "限数字,限 5 字符" },
        ],
        ygjckgd: [
          {
            required: false,
            message: "请输入检查口高度",
            trigger: ["change", "blur"],
          },
          { pattern: /^\d{1,5}$/, message: "限数字,限 5 字符" },
        ],
      },
    };
  },
  created() {
    this.getButtonList(
      sessionStorage.getItem("resourceCode"),
      sessionStorage.getItem("userCode")
    );
    //上传图片样式兼容ie

    this.getMaintainList("start");
    // this.getStoreHouseName();
  },
  mounted() {},
  computed: {
    isdialogView() {
      return this.dialogType == 2;
    },
    isDialogFormChange() {
      return this.dialogType == 3;
    },
    myHeader() {
      return {
        token: getToken(),
      };
    },
  },
  methods: {
    getButtonList(menuCode, userCode) {
      let codeData = {
        resourceCode: menuCode,
        userId: userCode,
      };
      authorityControl(codeData).then((res) => {
        let buttonNameList = [];
        res.data.forEach((item) => {
          this.buttonNameList.push(item.resourceName);
        });
      });
    },
    // 关闭dialog
    handlerDialogClose() {
      this.ygpmtList = [];
      this.ygkqtList = [];
      this.formDetail = Object.assign({}, this.formDetailBak);
      this.$refs.dialogForm.resetFields();
    },
    // 添加到fileList里 预览图片
    parseFileList(id, type) {
      if (!id) return;
      this[type] = [{ url: this.downloadPicUrl + id }];
      // downloadPic(id)
      //     .then(res => {
      //         if (res.infoCode !== 200) {
      //             this.$message.error(res.msg);
      //             return;
      //         }
      //         this[type] = [{
      //             url: res.data
      //         }];
      //     })
      //     .catch(error => {
      //         this.$message.error("图片加载失败");
      //     });
    },
    // 获取新增里的单位名称, (库点编号和库点名称)
    // 一般情况是所属企业代码 后边跟 001/002等, 现在是通过接口获取拿第一条
    getStoreHouseName() {
      // getSlqy({
      //   qyjgdm: sessionStorage.getItem("orgCode"),
      // })
      //   .then((res) => {
      //     if (res.infoCode !== 200) {
      //       this.$message.error("获取信息失败");
      //       return;
      //     }
      // getKDDetail({
      //   tyshxydm: this.$route.query.kddm,
      // }).then((resp) => {
      //   var d = resp.data;
      //   if (res.infoCode === 200 && d && d[0]) {
      //     this.formDetail.kdmc = d[0].kdmc;
      //     this.formDetail.kddm = d[0].kddm;
      //     this.formDetailBak = Object.assign({}, this.formDetail);
      //     return;
      //   }
      // });
      // })
      // .catch((err) => {
      //   this.$message.error("访问失败");
      // });
    },
    // 格式化列表显示状态
    statusformatter(row) {
      return {
        0: "草稿",
        1: "已发布",
      }[row.ygzt];
    },
    // 格式化列表显示日期
    dateformatter(row) {
      return row.sjnd && row.sjnd.slice(0, 10);
    },
    reastGetMaintainList() {
      (this.searchform = {
        ygbh: "", // 油罐编号 后端生成 唯一标识
        ygmc: "", // 罐号, 油罐名称
        sjnd: [], //
        jzksrq: "",
        jzjsrq: "",
      }),
        this.getMaintainList();
    },
    // 获取查询 翻页数据
    getMaintainList(type) {
      if (type != "start") {
        //非初始化调用：查询、分页
        sessionStorage.setItem("searchData", JSON.stringify(this.searchform));
        sessionStorage.setItem("pageData", JSON.stringify(this.page));
      } else {
        //初始化分两种情况，详情页等返回后的初始化，以及第一次进入此菜单的初始化
        if (JSON.parse(sessionStorage.getItem("searchData"))) {
          //详情页返回后，将对应查询条件和分页的字段赋值，页面回显参数
          this.searchform = JSON.parse(sessionStorage.getItem("searchData"));
          this.page = JSON.parse(sessionStorage.getItem("pageData"));
        } else {
          //第一次进去此菜单时，保存上方默认的data
          sessionStorage.setItem("searchData", JSON.stringify(this.searchform));
          sessionStorage.setItem("pageData", JSON.stringify(this.page));
        }
      }
      this.loading = true;
      var searchData = {};
      // data值存在 是点击搜索按钮
      // if (data) {
      //   this.page.start = 1;
      //   searchData.ygmc = data.ygmc;
      //   if (data.sjnd && data.sjnd.length) {
      //     searchData.jzksrq = data.sjnd[0];
      //     searchData.jzjsrq = data.sjnd[1];
      //   }
      //   this.searchformBak = searchData;
      // } else {
      //   searchData = Object.assign({}, this.searchformBak);
      // }

      searchData.ygmc = this.searchform.ygmc;
      if (this.searchform.sjnd && this.searchform.sjnd.length) {
        searchData.jzksrq = this.searchform.sjnd[0];
        searchData.jzjsrq = this.searchform.sjnd[1];
      } else {
        searchData.jzksrq = "";
        searchData.jzjsrq = "";
      }
      // this.searchformBak = searchData;

      //分页的查询条件
      var { start, limit } = this.page; //解构
      //搜索的查询条件
      // var searchObj = this.searchForm;
      searchData.kddm = this.$route.query.kddm;
      console.log(searchData);
      selectEmptyPotApplyList({
        ...searchData,
        pageNum: start,
        pageSize: limit,
      })
        .then((res) => {
          this.loading = false;
          if (!res) {
            this.maintainlist = [];
            return;
          }
          this.page.limit = res.data.pageSize;
          this.page.todolcount = res.data.total;
          this.page.todopage = res.data.pages;
          this.maintainlist = res.data.list;
        })
        .catch((err) => {
          this.loading = false;
          this.$message.error("访问失败");
        });
    },
    save() {
      // this.$refs.dialogForm.validate(valid => {
      // if (valid) {
      this.formDetail.ygzt = 0; // 草稿状态
      if (this.formDetail.ygmcFal.indexOf("号罐") == -1) {
        this.formDetail.ygmc = this.formDetail.ygmcFal + "号罐";
      }
      this.formDetail.sqzt = 0;

      // 修改
      if (this.isDialogFormChange) {
        updateEmptyPotApplyList(this.formDetail)
          .then((res) => {
            if (res.infoCode === 200) {
              this.$refs.dialogForm.resetFields();
              this.dialogTableVisible = false;
              this.$message.success({
                message: "恭喜你,修改成功",
              });
              this.getMaintainList();
            } else {
              this.$message.error(res.msg);
            }
          })
          .catch((err) => {
            this.$message.error("访问失败");
          });
        return;
      }
      // 新增
      addEmptyPotApplyList(this.formDetail)
        .then((res) => {
          if (res.infoCode === 200) {
            this.$message({
              message: "恭喜你，保存成功!!!",
              type: "success",
            });
            this.getMaintainList();
            this.$refs.dialogForm.resetFields();
            this.dialogTableVisible = false;
          } else {
            this.$message.error(res.msg);
          }
        })
        .catch((err) => {
          this.$message.error("访问失败");
        });
      // } else {
      //   this.$message({
      //     message: "保存前,须先输入必填项!!!",
      //     type: "warning"
      //   });
      //   return false;
      // }
      // });
    },
    publish() {
      this.$refs.dialogForm.validate((valid) => {
        if (valid) {
          this.formDetail.ygzt = 1; // 发布状态
          // 修改
          if (this.formDetail.ygmcFal.indexOf("号罐") == -1) {
            this.formDetail.ygmc = this.formDetail.ygmcFal + "号罐";
          }
          this.formDetail.sqzt = 0;
          if (this.isDialogFormChange) {
            updateEmptyPotApplyList(this.formDetail)
              .then((res) => {
                if (res.infoCode === 200) {
                  this.$refs.dialogForm.resetFields();
                  this.dialogTableVisible = false;
                  this.$message.success("恭喜你,发布成功");
                  this.getMaintainList();
                } else {
                  this.$message.error(res.msg);
                }
              })
              .catch((err) => {
                this.$message.error("访问失败");
              });
            return;
          }
          // 新增
          addEmptyPotApplyList(this.formDetail)
            .then((res) => {
              if (res.infoCode === 200) {
                this.$message({
                  message: "恭喜你，发布成功!!!",
                  type: "success",
                });
                this.getMaintainList();
                this.$refs.dialogForm.resetFields();
                this.dialogTableVisible = false;
              } else {
                this.$message.error(res.msg);
              }
            })
            .catch((err) => {
              this.$message.error("访问失败");
            });
        } else {
          this.$message({
            message: "发布前,须先输入必填项!!!",
            type: "warning",
          });
          return false;
        }
      });
    },
    // 取消
    cancel() {
      this.dialogTableVisible = false;
      this.$refs.dialogForm.resetFields();
    },
    // 分页显示条数
    handleSizeChange(val) {
      this.page.limit = val;
      this.getMaintainList();
    },
    // 跳页
    handleCurrentChange(val) {
      this.page.start = val;
      this.getMaintainList();
    },
    //删除
    handleDelete(ygbh) {
      this.$confirm("此操作将永久删除该信息, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          deleteEmptyPotApplyList({
            ygbh: ygbh,
          })
            .then((res) => {
              if (res.infoCode === 200) {
                this.$message.success("删除成功");
                this.getMaintainList();
              } else {
                this.$message.error(res.msg);
              }
            })
            .catch((err) => {
              this.$message.error("访问失败");
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "操作已取消",
          });
        });
    },
    // 打开dialog 获取详情
    getYGDetail(ygbh) {
      selectEmptyPotApplyListnumber({
        ygbh: ygbh,
      })
        .then((res) => {
          if (res.infoCode === 200) {
            if (!res.data) {
              this.$message.error("返回数据错误");
              return;
            }
            this.formDetail = res.data;
            if (!res.data.sjnd) {
              this.formDetail.sjnd = this.formDetailBak.sjnd;
            }
            if (!res.data.kdmc) {
              this.formDetail.kdmc = this.formDetailBak.kdmc;
            }
            if (this.dialogType != 2) {
              if (this.formDetail.ygmc.indexOf("号罐") > -1) {
                this.$set(
                  this.formDetail,
                  "ygmcFal",
                  this.formDetail.ygmc.substring(
                    0,
                    this.formDetail.ygmc.length - 2
                  )
                );
              }
            }

            if (res.data.ygpmt) {
              this.parseFileList(res.data.ygpmt, "ygpmtList");
            }
            if (res.data.ygkqt) {
              this.parseFileList(res.data.ygkqt, "ygkqtList");
            }
          } else {
            this.$message.error(res.msg);
          }
        })
        .catch((err) => {
          this.$message.error("访问失败");
        });
    },
    //解决ie上传图片样式问题 20200312
    handlerDialogOpen() {
      if (!!window.ActiveXObject || "ActiveXObject" in window) {
        this.$nextTick(() => {
          let a = document.getElementsByClassName("scieClass");
          a[0].style.padding = "0 0 0 50px";
          a[1].style.padding = "0 0 0 50px";
        });
      } else {
        this.$nextTick(() => {
          let a = document.getElementsByClassName("scieClass");
          a[0].style.padding = "0 0 0 10px";
          a[1].style.padding = "0 0 0 10px";
        });
      }
    },
    //新建
    adddetail() {
      this.dialogTableVisible = true;
      this.dialogType = 1;
    },
    // 编辑
    updateDetail(ygbh) {
      this.getYGDetail(ygbh);
      this.dialogTableVisible = true;
      this.dialogType = 3;
    },
    showYGDetail(ygbh, sfba) {
      this.$router.push({
        name: "ygxxAdd",
        query: {
          state: "detail",
          ygbh: ygbh,
          sfba: sfba,
        },
      });

      // this.getYGDetail(ygbh);
      // this.dialogTableVisible = true;
      // this.dialogType = 2;
    },
    handleYGSuccess(res, file) {
      if (res.infoCode === 200) {
        this.formDetail.ygpmt = res.data.id;
      }
    },
    handleYGRemove(file, fileList) {
      this.formDetail.ygpmt = "";
    },
    handleYGPictureCardPreview(file) {
      this.ygpmt = file.url;
      this.dialogYGVisible = true;
    },
    handleExceed(file, fileList) {
      this.$message.warning(`当前限制选择 1 个图片`);
    },
    handlerError() {
      this.$message.error("图片上传失败,请重试");
    },
    handleKQSuccess(res, file) {
      if (res.infoCode === 200) {
        this.formDetail.ygkqt = res.data.id;
      }
    },
    handleKQRemove(file, fileList) {
      this.formDetail.ygkqt = "";
    },
    handleKQPictureCardPreview(file) {
      this.ygkqt = file.url;
      this.dialogKQVisible = true;
    },
    // 格式化返回日期值
    sjndDateChange(val) {
      this.formDetail.sjnd = val;
    },
  },
};
</script>

<style lang="scss" scoped>
.content-main {
  .btns-line {
    margin-bottom: 20px;
  }

  .input-box {
    width: 220px;
  }
  #tpdialog /deep/ .el-dialog .el-dialog .el-dialog__header {
    height: 20px;
  }
}

.iconfont {
  font-size: 13px;
}
</style>
<style>
.v-modal {
  z-index: 2000 !important;
}
</style>
