<template>
  <div class="pd10" v-loading="isLoading" element-loading-text="数据加载中">
    <el-form :inline="true" :model="formData" class="demo-form-inline">
      <el-form-item>
        <Area @click="handleNodeClick" ref="area" @send="takeover"></Area>
      </el-form-item>
      <el-form-item>
        <Timeinterval ref="Timeinterval" :interval="3"></Timeinterval>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="onSubmit">查询</el-button>
        <el-button size="small" type="primary" icon="el-icon-circle-plus" @click="addFn">新增</el-button>
        <el-button size="small" type="primary" icon="el-icon-delete" @click="deleteFn">删除</el-button>
        <el-button size="small" type="primary" v-if="biaoCode === 'tjrbpush'" @click="push">上送网公司</el-button>
        <el-button size="small" type="primary" icon="el-icon-download" @click="exportEvent">导出</el-button>
      </el-form-item>
    </el-form>
    <vxe-table stripe :data="tableData" size="mini" ref="prealarmData"
               :row-config="{ isCurrent: true, isHover: true }" :height="vh" border style="width: 100%"
               header-cell-class-name="table_header" :header-cell-style="{
                height: '25px',
                padding: '0px'
            }" :row-style="{ height: '28px' }" :cell-style="{ padding: '0px' }" @checkbox-all="selectAllChangeEvent"
               @checkbox-change="handleSelectionChange">
      <vxe-table-column type="checkbox" align="center" width="55"></vxe-table-column>
      <vxe-table-column field="billNo" show-overflow align="center" title="单据编号"
                        min-width="120px"></vxe-table-column>
      <vxe-table-column field="billName" show-overflow align="center" title="单据名称"
                        min-width="120px"></vxe-table-column>
      <vxe-table-column field="billType" show-overflow align="center" title="单据类别" min-width="120px"
                        :formatter="formFilter1"></vxe-table-column>
      <vxe-table-column field="createrOrgName" show-overflow align="center" title="编制单位名称"
                        min-width="120px"></vxe-table-column>
      <vxe-table-column field="specialityType" show-overflow align="center" title="所属专业" min-width="120px"
                        :formatter="formFilter2"></vxe-table-column>
      <vxe-table-column field="orgName" show-overflow align="center" title="责任单位名称"
                        min-width="120px"></vxe-table-column>
      <vxe-table-column field="receiveUserName" show-overflow align="center" title="接收人名称" min-width="120px"
                        :formatter="formFilter"></vxe-table-column>
      <vxe-table-column field="createrTime" show-overflow align="center" title="编制时间"
                        min-width="120px"></vxe-table-column>
      <!-- <vxe-table-column field="isUploadHead" show-overflow align="center" title="上送表示" min-width="120px">
      <template slot-scope="scope">
        <el-tag type="primary" size="small" style="color: #409eff; background: #ecf5ff;" v-if="scope.row.isUploadHead == 0">未上送</el-tag>
        <el-tag type="primary" size="small" style="color: #67c23a; background: #f0f9eb;" v-if="scope.row.isUploadHead == 1">已上送</el-tag>
        <el-tag type="primary" size="small" style="color: #909399; background: #f4f4f5;" v-if="scope.row.isUploadHead == 2">取消上送</el-tag>
        <el-tag type="primary" size="small" style="color: orange; background: #f4f4f5;" v-if="scope.row.isUploadHead == 3">待重新上送</el-tag>

      </template>
</vxe-table-column> -->
      <vxe-table-column field="managerDeptName" show-overflow align="center" title="主管部门名称"
                        min-width="120px"></vxe-table-column>
      <vxe-table-column field="mainSenderName" show-overflow align="center" title="主送单位名称"
                        min-width="120px"></vxe-table-column>
      <vxe-table-column field="copySenderName" show-overflow align="center" title="抄送单位名称"
                        min-width="120px"></vxe-table-column>
      <vxe-table-column field="techSupvBasis" show-overflow align="center" title="依据标准"
                        min-width="120px"></vxe-table-column>
      <vxe-table-column field="problemDesc" show-overflow align="center" title="问题描述"
                        min-width="120px"></vxe-table-column>
      <vxe-table-column field="dealAdvise" show-overflow align="center" title="处理建议"
                        min-width="120px"></vxe-table-column>


      <vxe-table-column field="isUploadHead" show-overflow align="center" title="上送状态"
                        min-width="100px">
        <template slot-scope="scope">
          <el-tag type="primary" size="small" style="color: #409eff; background: #ecf5ff"
                  v-if="scope.row.isUploadHead == 0">
            未上送
          </el-tag>
          <el-tag type="primary" size="small" style="color: #67c23a; background: #f0f9eb"
                  v-if="scope.row.isUploadHead == 1">
            已上送
          </el-tag>
          <el-tag type="primary" size="small" style="color: #909399; background: #f4f4f5"
                  v-if="scope.row.isUploadHead == 2">
            取消上送
          </el-tag>
          <el-tag type="primary" size="small" style="color: orange; background: #f4f4f5"
                  v-if="scope.row.isUploadHead == 3">
            待重新上送
          </el-tag>
        </template>
      </vxe-table-column>


      <vxe-table-column field="province" show-overflow align="center" title="操作" min-width="180px" fixed="right">
        <template slot-scope="scope">
          <el-button type="primary" size="mini" @click="feedbackFn(scope.row)">反馈数据</el-button>
          <el-button type="primary" size="mini" @click="modifyFn(scope.row)">修改</el-button>
        </template>
      </vxe-table-column>
    </vxe-table>
    <el-pagination background align="right" @size-change="handleSizeChange" @current-change="handleCurrentChange"
                   :current-page="formData.pageNum" :page-sizes="[20, 30, 50, 100]" :page-size="formData.pageSize"
                   layout="total, sizes, prev, pager, next, jumper" :total="total" class="mt10"></el-pagination>
    <!-- 新增/修改 -->
    <el-dialog :close-on-click-modal="false" :title="alarmTitle" :visible.sync="modifyInformation" width="50%">
      <el-form :inline="true" :model="form" class="form" ref="form" label-width="120px" :rules="rules">
        <el-form-item label="单据编号:" prop="billNo" class="mt10">
          <el-input v-model="form.billNo" placeholder="请输入单据编号" clearable></el-input>
        </el-form-item>
        <el-form-item label="单据名称:" prop="billName" class="mt10">
          <el-input v-model="form.billName" placeholder="请输入单据名称" clearable></el-input>
        </el-form-item>
        <el-form-item label="单据类别:" prop="billType" class="mt10">
          <el-select v-model="form.billType" clearable placeholder="请选择单据类别">
            <el-option v-for="item in Categories" :key="item.id" :label="item.name"
                       :value="item.id"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="编制单位名称:" class="mt10" prop="createrOrgName">
          <Organization @click="handleNodeClick1" ref="Organization" :valueTitle="valueTitle"
                        :editCheckCode="editCheckCode"></Organization>
        </el-form-item>
        <el-form-item label="所属专业:" prop="specialityType" class="mt10">
          <el-select v-model="form.specialityType" clearable placeholder="请选择所属专业">
            <el-option v-for="item in Major" :key="item.id" :label="item.name" :value="item.id"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="责任单位名称:" class="mt10" prop="orgName">
          <Company @click="handleNodeClick2" ref="Company" :valueTitle="valueTitle1"
                   :editCheckCode="editCheckCode1">
          </Company>
        </el-form-item>
        <el-form-item label="接收人名称:" prop="receiveUserId" class="mt10">
          <el-select v-model="form.receiveUserId" clearable placeholder="请选择接收人名称" @change="changeFn"
                     @clear="clear('receiveUserId', 'receiveUserName')">
            <el-option v-for="item in ImplementationPeople" :key="item.id" :label="item.name"
                       :value="item.id"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="编制时间:" prop="createrTime" class="mt10">
          <el-date-picker v-model="form.createrTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetime"
                          placeholder="选择日期"></el-date-picker>
        </el-form-item>
        <el-form-item label="主管部门名称:" class="mt10" prop="managerDeptName">
          <Operation @click="handleNodeClick3" ref="Operation" :valueTitle="valueTitle2"
                     :editCheckCode="editCheckCode2"></Operation>
        </el-form-item>
        <el-form-item label="主送单位名称:" class="mt10" prop="mainSenderName">
          <Organization1 @click="handleNodeClick4" ref="Organization1" :valueTitle="valueTitle3"
                         @clear="clear('mainSenderId', 'mainSenderName')" :editCheckCode="editCheckCode3">
          </Organization1>
        </el-form-item>
        <el-form-item label="抄送单位名称:" class="mt10" prop="copySenderName">
          <Organization2 @click="handleNodeClick5" ref="Organization2" :valueTitle="valueTitle4"
                         @clear="clear('copySenderId', 'copySenderName')" :editCheckCode="editCheckCode4">
          </Organization2>
        </el-form-item>
        <el-form-item label="处理建议:" prop="dealAdvise" class="mt10">
          <el-input v-model="form.dealAdvise" type="textarea" :rows="3" placeholder="请输入处理建议"
                    clearable></el-input>
        </el-form-item>
        <el-form-item label="依据标准:" prop="techSupvBasis" class="mt50">
          <el-input v-model="form.techSupvBasis" type="textarea" :rows="3" placeholder="请输入依据标准"></el-input>
        </el-form-item>
        <el-form-item label="问题描述:" prop="problemDesc" class="mt50">
          <el-input v-model="form.problemDesc" type="textarea" :rows="3" placeholder="请输入问题描述"></el-input>
        </el-form-item>
      </el-form>

      <span slot="footer" class="dialog-footer">
                <el-button type="primary" @click="modifyInformation = false">取 消</el-button>
                <el-button v-if="add" type="primary" @click="AddinformationFn">确 定</el-button>
                <el-button v-if="modify" type="primary" @click="modifyinformationFn">确 定</el-button>
            </span>
    </el-dialog>
    <!-- 反馈数据 -->
    <el-dialog :close-on-click-modal="false" title="反馈数据" :visible.sync="Feedbackinformation" width="90%"
               height="90%">
      <div v-loading="isLoading1" element-loading-text="数据加载中">
        <el-form ref="form" :inline="true">
          <!-- <el-form-item>
    <Timeinterval :interval="3" ref="Timeinterval"></Timeinterval>
  </el-form-item> -->
          <el-form-item>
            <el-button size="small" type="primary" icon="el-icon-circle-plus" @click="feedBackAdd">
              新增
            </el-button>
            <el-button size="small" type="primary" icon="el-icon-delete" @click="feedBackDel">
              删除
            </el-button>
            <el-button size="small" type="primary" icon="el-icon-download" @click="exportEvent1">
              导出
            </el-button>
          </el-form-item>
        </el-form>

        <div class="boxS">
          <div class="boxTableS">
            <vxe-table stripe size="mini" :row-config="{ isCurrent: true, isHover: true }"
                       :data="feedBackData" ref="problems" highlight-current-row border :height="vh"
                       header-cell-class-name="table_header" @checkbox-all="selectAllChangeEvent1"
                       @checkbox-change="handleSelectionChange1">
              <vxe-table-column type="checkbox" align="center" width="55"></vxe-table-column>
              <vxe-table-column field="executeOrgName" show-overflow align="center" title="项目执行单位名称"
                                min-width="120px"></vxe-table-column>
              <vxe-table-column field="treatmentMeasures" show-overflow align="center" title="采取措施"
                                min-width="120px"></vxe-table-column>
              <vxe-table-column field="fillUserName" show-overflow align="center" title="填报人名称"
                                min-width="120px"></vxe-table-column>
              <vxe-table-column field="completeTime" show-overflow align="center" title="完成时间"
                                min-width="120px"></vxe-table-column>
              <!-- <vxe-table-column field="workAlarmId" show-overflow align="center" title="告预警单id" min-width="120px"></vxe-table-column> -->
              <vxe-table-column field="feedbackOrgName" show-overflow align="center" title="反馈单位名称"
                                min-width="120px"></vxe-table-column>
              <vxe-table-column field="provinceName" show-overflow align="center" title="省名称"
                                min-width="120px"></vxe-table-column>


              <vxe-table-column field="isUploadHead" show-overflow align="center" title="上送状态"
                                min-width="100px">
                <template slot-scope="scope">
                  <el-tag type="primary" size="small" style="color: #409eff; background: #ecf5ff"
                          v-if="scope.row.isUploadHead == 0">
                    未上送
                  </el-tag>
                  <el-tag type="primary" size="small" style="color: #67c23a; background: #f0f9eb"
                          v-if="scope.row.isUploadHead == 1">
                    已上送
                  </el-tag>
                  <el-tag type="primary" size="small" style="color: #909399; background: #f4f4f5"
                          v-if="scope.row.isUploadHead == 2">
                    取消上送
                  </el-tag>
                  <el-tag type="primary" size="small" style="color: orange; background: #f4f4f5"
                          v-if="scope.row.isUploadHead == 3">
                    待重新上送
                  </el-tag>
                </template>
              </vxe-table-column>


              <vxe-table-column field="province" show-overflow align="center" title="操作"
                                min-width="120px">
                <template slot-scope="scope">
                  <el-button type="primary" size="mini" @click="feedmodify(scope.row)">
                    修改
                  </el-button>
                </template>
              </vxe-table-column>
            </vxe-table>
            <el-pagination background align="right" @size-change="handleSizeChange1"
                           @current-change="handleCurrentChange1" :current-page="formData1.pageNum"
                           :page-sizes="[20, 30, 40, 50, 100]" :page-size="formData1.pageSize"
                           layout="total, sizes, prev, pager, next, jumper" :total="feedBackTotal"
                           class="mt10"></el-pagination>
          </div>
        </div>
      </div>
    </el-dialog>
    <!-- 反馈数据新增/修改 -->
    <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="feedBackDataInformation" width="40%"
               height="80%">
      <el-form :inline="true" :model="form1" class="form" ref="form" label-width="130px" :rules="rules">
        <el-form-item label="项目执行单位名称:" class="mt10" prop="executeOrgName">
          <Organization1 @click="handleNodeClick6" ref="Organization1" :valueTitle="valueTitle5"
                         @clear="clear('executeOrgId', 'executeOrgName')" :editCheckCode="editCheckCode5">
          </Organization1>
        </el-form-item>
        <el-form-item label="采取措施:" prop="treatmentMeasures" class="mt10">
          <el-input v-model="form1.treatmentMeasures" placeholder="请输入采取措施"></el-input>
        </el-form-item>
        <el-form-item label="填报人名称:" prop="fillUserId" class="mt10">
          <el-select v-model="form1.fillUserId" clearable placeholder="请选择接收人名称" @change="changeFn">
            <el-option v-for="item in ImplementationPeople" :key="item.id" :label="item.name"
                       :value="item.id"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="完成时间:" prop="completeTime" class="mt10">
          <el-date-picker v-model="form1.completeTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetime"
                          placeholder="选择日期"></el-date-picker>
        </el-form-item>
        <!-- <el-form-item label="告预警单id:" prop="workAlarmId" class="mt10">
            <el-input v-model="form1.workAlarmId" ></el-input>
        </el-form-item> -->
        <el-form-item label="反馈单位名称:" class="mt10" prop="feedbackOrgName">
          <Organization2 @click="handleNodeClick7" ref="Organization2" :valueTitle="valueTitle6"
                         @clear="clear('feedbackOrgId', 'feedbackOrgName')" :editCheckCode="editCheckCode6">
          </Organization2>
        </el-form-item>
        <!-- <el-form-item label="省名称:" class="mt10" prop="provinceName" >
          <Organization1
            @click="handleNodeClick8" ref="Organization1" :valueTitle="valueTitle7"
            :editCheckCode="editCheckCode7"></Organization1>
        </el-form-item> -->
      </el-form>

      <span slot="footer" class="dialog-footer">
                <el-button type="primary" @click="feedBackDataInformation = false">取 消</el-button>
                <el-button v-if="feedBackadd" type="primary" @click="feedBackAddFn">确 定</el-button>
                <el-button v-if="feedBackmodify" type="primary" @click="feedBackModifyFn">确 定</el-button>
            </span>
    </el-dialog>
  </div>
</template>
<script>
import Area from '@/views/components/Area/Area.vue'
import Organization from './Area/Organization.vue'
import Organization2 from './Area/Organization2.vue'
import Organization1 from './Area/Organization1.vue'
import Company from './Area/Company.vue'
import Operation from './Area/Operation.vue'
import Timeinterval from '@/views/components/TimePicker/index4'
import { dicData } from '@/assets/commjs/dictypeData'
import {
  pageAlarm,
  getUserListByDeptId,
  addAlarm,
  updateAlarm,
  delAlarm,
  pageAlarmBack,
  addAlarmBack,
  updateAlarmBack,
  delAlarmBack,
  pushAlarm,
  downAlarm
} from '@/api/Supervisionmanage2/prealarmData'
import { listRoleMenu, updateRoleMenu } from '@/api/admin/role'
export default {
  components: { Area, Timeinterval, Organization, Company, Operation, Organization1, Organization2 },
  props: {},
  data() {
    return {
      biaoCode: '',
      id: JSON.parse(window.sessionStorage.getItem('Info')).roleList[0],
      isLoading: false,
      isLoading1: false,
      modifyInformation: false,
      Feedbackinformation: false,
      feedBackDataInformation: false,
      add: false,
      feedBackadd: false,
      modify: false,
      feedBackmodify: false,
      zoom: '', //图表焦点校验
      vh: undefined,
      title: '',
      alarmTitle:'',
      editCheckCode: '',
      valueTitle: '',
      editCheckCode1: '',
      valueTitle1: '',
      editCheckCode2: '',
      valueTitle2: '',
      editCheckCode3: '',
      valueTitle3: '',
      editCheckCode4: '',
      valueTitle4: '',
      editCheckCode5: '',
      valueTitle5: '',
      editCheckCode6: '',
      valueTitle6: '',
      editCheckCode7: '',
      valueTitle7: '',
      alarmId: '',
      formData: {
        orgId: '',
        searchBeginTime: '',
        searchEndTime: '',
        pageNum: 1,
        pageSize: 20
      },
      formData1: {
        workAlarmId: '',
        pageNum: 1,
        pageSize: 20
      },
      form: {
        billName: '',
        billNo: '',
        billType: '',
        copySenderId: '',
        copySenderName: '',
        createrOrgId: '',
        createrOrgName: '',
        createrTime: '',
        dealAdvise: '',
        mainSenderId: '',
        mainSenderName: '',
        managerDeptId: '',
        managerDeptName: '',
        orgId: '',
        orgName: '',
        problemDesc: '',
        receiveUserName: '',
        receiveUserId: '',
        specialityType: '',
        techSupvBasis: ''
      },
      form1: {
        completeTime: '',
        executeOrgId: '',
        executeOrgName: '',
        feedbackOrgId: '',
        feedbackOrgName: '',
        fillUserId: '',
        fillUserName: '',
        treatmentMeasures: '',
        workAlarmId: ''
      },
      rules: {
        billNo: [{ required: true, message: '请输入单据编号', trigger: 'blur' }],
        billName: [{ required: true, message: '请输入单据名称', trigger: 'blur' }],
        billType: [{ required: true, message: '请选择单据类别', trigger: 'change' }],
        createrOrgName: [{ required: true, message: '请选择编制单位', trigger: 'change' }],
        specialityType: [{ required: true, message: '请选择所属专业', trigger: 'change' }],
        orgName: [{ required: true, message: '请选择责任单位', trigger: 'change' }],
        createrTime: [{ required: true, message: '选择日期', trigger: 'change' }],
        managerDeptName: [{ required: true, message: '请选择主管部门名称', trigger: 'change' }],
        techSupvBasis: [{ required: true, message: '请输入依据标准', trigger: 'blur' }],
        problemDesc: [{ required: true, message: '请输入问题描述', trigger: 'blur' }],
        dealAdvise: [{ required: true, message: '请输入处理建议', trigger: 'blur' }],
        treatmentMeasures: [{ required: true, message: '请输入采取措施', trigger: 'blur' }],
        fillUserId: [{ required: true, message: '请选择接收人名称', trigger: 'change' }],
        completeTime: [{ required: true, message: '选择日期', trigger: 'change' }]
      },
      total: undefined,
      feedBackTotal: undefined,
      tableData: [],
      feedBackData: [],
      planStatus: [],
      Major: [],
      Categories: [],
      ImplementationPeople: [],
      multipleSelection: [],
      multipleSelection1: []
    }
  },
  created() {
    this.getclassificationData()
    this.getUserId()
  },
  mounted() {
    this.setHeight()
    window.addEventListener('resize', this.setHeight)
    this.listmenuRoleList()

    // this.onSubmit();
  },
  beforeDestroy() {
    window.removeEventListener('resize', this.setHeight)
  },
  methods: {
    setHeight() {
      this.vh = window.sessionStorage.getItem('appheight') - 95
    },
    clear(key, key1) {
      this.form[key] = ''
      this.form[key1] = ''
      this.form1[key] = ''
      this.form1[key1] = ''
    },
    //获取权限
    listmenuRoleList() {
      let p = { id: this.id }
      listRoleMenu(p).then(response => {
        let ids = []
        //console.log("权限资源",response.data)
        response.data.forEach(item => {
          if (item.code === 'tjrbpush') {
            this.biaoCode = item.code
          }
        })
      })
    },
    //获取类型
    getclassificationData() {
      //计划状态
      this.planStatus = dicData('plan_status', [])
      //所属专业
      this.Major = dicData('speciality_type', [])
      //单据类型
      this.Categories = dicData('bill_type', [])
    },
    takeover(val) {
      this.formData.orgId = val[0].code
      this.onSubmit()
    },
    getUserId() {
      let form = {
        deptId: JSON.parse(window.sessionStorage.getItem('Info')).deptId
      }
      getUserListByDeptId(form).then(res => {
        this.ImplementationPeople = res.data
      })
    },
    //复选框
    handleSelectionChange(val) {
      // console.log(val);
      this.multipleSelection = val.records
    },
    selectAllChangeEvent(val) {
      // console.log(val);
      this.multipleSelection = val.records
    },
    handleSelectionChange1(val) {
      this.multipleSelection1 = val.records
    },
    selectAllChangeEvent1(val) {
      // console.log(val.records);
      this.multipleSelection1 = val.records
    },
    //查询
    onSubmit() {
      this.isLoading = true
      // this.$refs.Timeinterval.timeOptions = [
      //   // { label: "年份", value: 1 },
      //   // { label: "季度", value: 2 },
      //   { label: "月份", value: 3 },
      //   // { label: "周", value: 4 },
      //   // // { label: "自定义", value: 5 },
      // ]
      this.item = this.$refs.Timeinterval.timeValue
      this.formData.searchBeginTime = this.item[0]
      this.formData.searchEndTime = this.item[1]
      pageAlarm(this.formData).then(res => {
        this.tableData = res.data.records
        this.total = res.data.total
        this.isLoading = false
      })
    },
    //数据过滤
    formFilter(row, column) {
      if (row.column.property == 'planStatus') {
        let title = ''
        this.planStatus.forEach(item => {
          if (item.id == row.row.planStatus) {
            title = item.name
          }
        })
        return title
      } else {
        return row.row[row.column.property]
      }
    },
    formFilter1(row, column) {
      if (row.column.property == 'billType') {
        let title = ''
        this.Categories.forEach(item => {
          if (item.id == row.row.billType) {
            title = item.name
          }
        })
        return title
      } else {
        return row.row[row.column.property]
      }
    },
    formFilter2(row, column) {
      if (row.column.property == 'specialityType') {
        let title = ''
        this.Major.forEach(item => {
          if (item.id == row.row.specialityType) {
            title = item.name
          }
        })
        return title
      } else {
        return row.row[row.column.property]
      }
    },
    //新增
    addFn() {
      this.alarmTitle = '新增预告警单'
      this.add = true
      this.modify = false
      this.valueTitle = ''
      this.editCheckCode = ''
      this.valueTitle1 = ''
      this.editCheckCode1 = ''
      this.valueTitle2 = ''
      this.editCheckCode2 = ''
      this.valueTitle3 = ''
      this.editCheckCode3 = ''
      this.valueTitle4 = ''
      this.editCheckCode4 = ''
      this.form = {
        billName: '',
        billNo: '',
        billType: '',
        copySenderId: '',
        copySenderName: '',
        createrOrgId: '',
        createrOrgName: '',
        createrTime: '',
        dealAdvise: '',
        mainSenderId: '',
        mainSenderName: '',
        managerDeptId: '',
        managerDeptName: '',
        orgId: '',
        orgName: '',
        problemDesc: '',
        receiveUserName: '',
        receiveUserid: '',
        specialityType: '',
        techSupvBasis: ''
      }
      this.$nextTick(() => {
        this.$refs['form'].clearValidate()
      })
      this.modifyInformation = true
    },
    //新增确定
    AddinformationFn() {
      this.$refs.form.validate(value => {
        // console.log(value);
        if (value == true) {
          this.$confirm('是否确认新增?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          })
              .then(() => {
                addAlarm(this.form).then(res => {
                  if (res.code == 'A0000') {
                    this.$message({
                      type: 'success',
                      message: res.message
                    })
                  }
                  this.onSubmit()
                  this.modifyInformation = false
                })
              })
              .catch(() => {
                this.$message({
                  type: 'info',
                  message: '已取消新增'
                })
              })
        }
      })
    },
    //修改
    modifyFn(val) {
      this.alarmTitle = '修改预告警单'
      this.modifyInformation = true
      this.add = false
      this.modify = true
      this.form = JSON.parse(JSON.stringify(val))
      this.valueTitle = val.createrOrgName
      this.editCheckCode = val.createrOrgId
      this.valueTitle1 = val.orgName
      this.editCheckCode1 = val.orgId
      this.valueTitle2 = val.managerDeptName
      this.editCheckCode2 = val.managerDeptId
      this.valueTitle3 = val.mainSenderName
      this.editCheckCode3 = val.mainSenderId
      this.valueTitle4 = val.copySenderName
      this.editCheckCode4 = val.copySenderId
    },
    //修改确定
    modifyinformationFn() {
      this.$refs.form.validate(value => {
        // console.log(value);
        if (value == true) {
          this.$confirm('是否确认修改?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          })
              .then(() => {
                updateAlarm(this.form).then(res => {
                  if (res.code == 'A0000') {
                    this.$message({
                      type: 'success',
                      message: res.message
                    })
                  }
                  this.onSubmit()
                  this.modifyInformation = false
                })
              })
              .catch(() => {
                this.$message({
                  type: 'info',
                  message: '已取消修改'
                })
              })
        }
      })
    },
    //反馈数据
    feedbackFn(val) {
      this.Feedbackinformation = true
      this.form1.workAlarmId = val.alarmId
      this.alarmId = val.alarmId
      this.feedbackQuery()
    },
    //查询
    feedbackQuery() {
      this.isLoading1 = true
      this.formData1.workAlarmId = this.alarmId
      pageAlarmBack(this.formData1).then(res => {
        this.feedBackData = res.data.records
        this.feedBackTotal = res.data.total
        this.isLoading1 = false
      })
    },
    //反馈数据新增
    feedBackAdd() {
      this.title = '新增反馈数据'
      this.feedBackadd = true
      this.feedBackmodify = false
      this.valueTitle5 = ''
      this.editCheckCode5 = ''
      this.valueTitle6 = ''
      this.editCheckCode6 = ''
      this.form1 = {
        completeTime: '',
        executeOrgId: '',
        executeOrgName: '',
        feedbackOrgId: '',
        feedbackOrgName: '',
        fillUserId: '',
        fillUserName: '',
        treatmentMeasures: '',
        workAlarmId: this.alarmId
      }
      this.$nextTick(() => {
        this.$refs['form'].clearValidate()
      })
      this.feedBackDataInformation = true
    },
    //反馈数据新增确认
    feedBackAddFn() {
      this.$refs.form.validate(value => {
        // console.log(value);
        if (value == true) {
          this.$confirm('是否确认新增?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          })
              .then(() => {
                addAlarmBack(this.form1).then(res => {
                  if (res.code == 'A0000') {
                    this.$message({
                      type: 'success',
                      message: res.message
                    })
                  }
                  this.feedbackQuery()
                  this.feedBackDataInformation = false
                })
              })
              .catch(() => {
                this.$message({
                  type: 'info',
                  message: '已取消新增'
                })
              })
        }
      })
    },
    //反馈数据修改
    feedmodify(val) {
      this.title = '修改反馈数据'
      this.feedBackDataInformation = true
      this.feedBackadd = false
      this.feedBackmodify = true
      this.valueTitle5 = val.executeOrgName
      this.editCheckCode5 = val.executeOrgId
      this.valueTitle6 = val.feedbackOrgName
      this.editCheckCode6 = val.feedbackOrgId
      this.form1 = JSON.parse(JSON.stringify(val))
    },
    //反馈数据修改确定
    feedBackModifyFn() {
      this.$refs.form.validate(value => {
        // console.log(value);
        if (value == true) {
          this.$confirm('是否确认修改?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          })
              .then(() => {
                updateAlarmBack(this.form1).then(res => {
                  if (res.code == 'A0000') {
                    this.$message({
                      type: 'success',
                      message: res.message
                    })
                  }
                  this.feedbackQuery()
                  this.feedBackDataInformation = false
                })
              })
              .catch(() => {
                this.$message({
                  type: 'info',
                  message: '已取消修改'
                })
              })
        }
      })
    },
    //反馈数据删除
    feedBackDel() {
      if (this.multipleSelection1.length == 0) {
        this.$message({
          showClose: true,
          message: '请选择一条数据删除!!!',
          type: 'warning'
        })
        return
      }
      this.$confirm('是否确认删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
          .then(() => {
            let planIds = []
            this.multipleSelection1.forEach(item => {
              planIds.push(item.alarmBackId)
            })

            delAlarmBack(planIds).then(res => {
              if ((res.code == 'A0000')) {
                this.$message({
                  type: 'success',
                  message: res.message
                })
              }
              this.feedbackQuery()
            })
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消删除'
            })
          })
    },
    //导出
    exportEvent() {
      // pageAlarm({
      //   searchBeginTime:this.formData.searchBeginTime,
      //   searchEndTime:this.formData.searchEndTime,
      //   orgId:this.formData.orgId ,
      //   pageNum: 1,
      //   pageSize: this.total,
      // }).then((res) => {
      //   res.data.records.forEach(item=>{
      //     if(item.isUploadHead == 0){
      //       item.isUploadHead = '未上送'
      //     }else if(item.isUploadHead == 1){
      //       item.isUploadHead = '已上送'
      //     }else if(item.isUploadHead == 2){
      //       item.isUploadHead = '取消上送'
      //     }
      //   })
      //   this.$refs.prealarmData.exportData({
      //     filename: '技术监督预告警单数据', // 文件名字
      //     sheetName: "Sheet1",
      //     type: "xlsx", //导出文件类型 xlsx 和 csv
      //     useStyle: true,
      //     data: res.data.records, // 数据源 // 过滤那个字段导出
      //     columnFilterMethod: function (column, $columnIndex) {
      //       return !(column.$columnIndex === 0);
      //     },
      //   });
      // });
      downAlarm().then(res => {
        let blob = new Blob([res], {
          type: 'application/vnd.ms-excel'
        })
        const url = window.URL.createObjectURL(blob)
        const link = document.createElement('a') // 创建a标签
        link.href = url // link.download = "电压暂降事件分析报告"; // 设置下载的文件名
        link.download = '技术监督预告警单数据.xls' // 设置下载的文件名
        document.body.appendChild(link)
        link.click() //执行下载
        document.body.removeChild(link)
      })
    },
    exportEvent1() {
      pageAlarmBack({
        workAlarmId: this.formData.workAlarmId,
        pageNum: 1,
        pageSize: this.total
      }).then(res => {
        res.data.records.forEach(item => {
          if (item.isUploadHead == 0) {
            item.isUploadHead = '未上送'
          } else if (item.isUploadHead == 1) {
            item.isUploadHead = '已上送'
          } else if (item.isUploadHead == 2) {
            item.isUploadHead = '取消上送'
          }
        })
        this.$refs.problems.exportData({
          filename: '反馈数据', // 文件名字
          sheetName: 'Sheet1',
          type: 'xlsx', //导出文件类型 xlsx 和 csv
          useStyle: true,
          data: res.data.records, // 数据源 // 过滤那个字段导出
          columnFilterMethod: function (column, $columnIndex) {
            return !(column.$columnIndex === 0)
          }
        })
      })
    },
    //计划上送网公司
    push() {
      if (this.multipleSelection.length == 0) {
        this.$message({
          showClose: true,
          message: '请选择一条数据上送网公司!!!',
          type: 'warning'
        })
        return
      }
      // let isUpload = []
      // this.multipleSelection.forEach(item=>{
      //   isUpload.push(item.isUploadHead)
      // })
      // if(isUpload.includes(1) == true){
      //       this.$message({
      //               type: "warning",
      //               message: '已上送,无需重复上送',
      //               });
      //               return
      // }else{
      this.$confirm('是否确认上送网公司?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
          .then(() => {
            let ids = []
            this.multipleSelection.forEach(item => {
              ids.push(item.alarmId)
            })

            pushAlarm(ids).then(res => {
              if ((res.code == 'A0000')) {
                this.$message({
                  type: 'success',
                  message: res.message
                })
              }
              this.onSubmit()
            })
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消上送'
            })
          })
      // }
    },
    // 删除
    deleteFn() {
      if (this.multipleSelection.length == 0) {
        this.$message({
          showClose: true,
          message: '请选择一条数据删除!!!',
          type: 'warning'
        })
        return
      }
      this.$confirm('是否确认删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
          .then(() => {
            let planIds = []
            this.multipleSelection.forEach(item => {
              planIds.push(item.alarmId)
            })

            delAlarm(planIds).then(res => {
              if ((res.code == 'A0000')) {
                this.$message({
                  type: 'success',
                  message: res.message
                })
              }
              this.onSubmit()
            })
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消删除'
            })
          })
    },
    //每页条数改变时触发 选择一页显示多少行
    handleSizeChange(val) {
      this.formData.pageSize = val
      this.onSubmit()
    },
    //当前页改变时触发 跳转其他页
    handleCurrentChange(val) {
      this.formData.pageNum = val
      this.onSubmit()
    },
    //每页条数改变时触发 选择一页显示多少行
    handleSizeChange1(val) {
      this.formData1.pageSize = val
      this.onSubmit()
    },
    //当前页改变时触发 跳转其他页
    handleCurrentChange1(val) {
      this.formData1.pageNum = val
      this.onSubmit()
    },
    changeFn(val) {
      this.ImplementationPeople.forEach(item => {
        if (val == item.id) {
          this.form.receiveUserName = item.name
          this.form1.fillUserName = item.name
        }
      })
    },
    handleNodeClick(data) {
      this.formData.orgId = data.code
    },
    handleNodeClick1(data) {
      this.form.createrOrgId = data.code
      this.form.createrOrgName = data.name
    },
    handleNodeClick2(data) {
      this.form.orgId = data.code
      this.form.orgName = data.name
    },
    handleNodeClick3(data) {
      this.form.managerDeptId = data.code
      this.form.managerDeptName = data.name
    },
    handleNodeClick4(data) {
      this.form.mainSenderId = data.code
      this.form.mainSenderName = data.name
    },
    handleNodeClick5(data) {
      this.form.copySenderId = data.code
      this.form.copySenderName = data.name
    },
    handleNodeClick6(data) {
      this.form1.executeOrgId = data.code
      this.form1.executeOrgName = data.name
    },
    handleNodeClick7(data) {
      this.form1.feedbackOrgId = data.code
      this.form1.feedbackOrgName = data.name
    }
    // handleNodeClick8(data) {
    //   this.form.provinceId = data.code
    //   this.form.provinceName = data.name
    // },
  },

  computed: {},

  watch: {}
}
</script>
<style lang="less" scoped>
@import url('../../../styles/comStyle.less');

::v-deep .el-form-item--small .el-form-item__content,
.el-form-item--small .el-form-item__label {
  height: 32px;
}

.boxS {
  width: 100%;
}

::v-deep .el-dialog .el-dialog__body {
  max-height: 100vh;
  min-height: 150px;
  padding: 20px;
  overflow-y: auto;
}

::v-deep .form {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;

  .el-form-item {
    display: flex;
    width: 48%;

    .el-form-item__content {
      flex: 1 !important;

      .el-select {
        width: 100%;
      }

      .el-input__inner {
        width: 100% !important;
      }

      .el-date-editor {
        width: 100%;
      }
    }
  }
}

::v-deep .el-form-item--small .el-form-item__error {
  padding-top: 8px;
}

::v-deep .vxe-table .cell {
  text-align: center;
}
</style>
