<template>
    <div>
        <!-- 新增第一步 -->
        <el-dialog
            :close-on-click-modal="false"
            title="问题新增"
            :visible.sync="add"
            width="50%"
            :before-close="handleClose"
        >
            <el-divider content-position="left" style="font-size: 18px; font-weight: bolder">
                第一步 基本信息填报
            </el-divider>
            <el-form :inline="true" ref="ruleForm" :rules="rules" :model="addData">
                <el-form-item label="所属单位:">
                    <el-input v-model="addData.orgName" clearable placeholder="请填写" disabled></el-input>
                </el-form-item>

                <el-form-item label="问题来源:" prop="problemSources">
                    <el-select v-model="addData.problemSources" clearable placeholder="请选择">
                        <el-option
                            v-for="item in problemData"
                            :key="item.code"
                            :label="item.label"
                            :value="item.code"
                        ></el-option>
                    </el-select>
                </el-form-item>

                <el-form-item label="问题名称:" prop="problemName">
                    <el-input v-model="addData.problemName" clearable placeholder="请填写"></el-input>
                </el-form-item>
            </el-form>

            <div style="display: flex; justify-content: center; margin-top: 10px">
                <el-button type="primary" class="ml20" @click="nextStep">下一步</el-button>
                <el-button type="primary" class="ml20" @click="handleClose">取消</el-button>
            </div>
        </el-dialog>

        <!-- 新增第二步(在线监测超标问题新增) -->
        <el-dialog
            :close-on-click-modal="false"
            title="在线监测超标问题新增"
            :visible.sync="onlineAdd"
            width="70%"
            :before-close="handleClose"
        >
            <el-divider content-position="left" style="font-size: 18px; font-weight: bolder">
                第二步 选择问题测点(请选择需要生成问题的告警监测点)
            </el-divider>
            <el-form :model="onlineAdddata" :inline="true" class="form">
                <el-form-item label="告警时间:">
                    <Month :interval="3" ref="interval" />
                </el-form-item>

                <el-form-item>
                    <el-button type="primary" icon="el-icon-search" @click="searchOnLine">查询</el-button>
                    <!-- <el-button type="primary" icon="el-icon-refresh" @click="resetFn1"
            >重置</el-button
          > -->
                </el-form-item>
            </el-form>

            <el-table
                stripe
                :data="onlineAddData"
                :height="height1"
                border
                style="width: 100%"
                v-loading="isLoading1"
                header-cell-class-name="table_header"
                @selection-change="ChangeOnline"
                :row-class-name="rowClassName"
            >
                <el-table-column type="selection" width="35"></el-table-column>
                <el-table-column prop="number" label="序号" width="100" :show-overflow-tooltip="true"></el-table-column>
                <el-table-column
                    prop="measurementPointName"
                    label="监测点名称"
                    :show-overflow-tooltip="true"
                ></el-table-column>
                <el-table-column
                    prop="alarmType"
                    label="告警类型"
                    :formatter="formatter"
                    :show-overflow-tooltip="true"
                ></el-table-column>
                <el-table-column prop="alarmInfo" label="告警描述" :show-overflow-tooltip="true"></el-table-column>
                <el-table-column
                    prop="alarmLastTime"
                    label="告警持续时间(s)"
                    :show-overflow-tooltip="true"
                ></el-table-column>
            </el-table>

            <div style="display: flex; justify-content: center; margin-top: 10px">
                <el-button type="primary" class="ml20" @click="previouStep">上一步</el-button>
                <el-button type="primary" class="ml20" @click="OnlineMonitoring">生成问题</el-button>
                <el-button type="primary" class="ml20" @click="handleClose">取消</el-button>
            </div>
        </el-dialog>

        <!-- 新增第二步(普测超标问题新增) -->
        <el-dialog
            :close-on-click-modal="false"
            title="普测超标问题新增"
            :visible.sync="ordinaryAdd"
            width="70%"
            :before-close="handleClose"
        >
            <el-divider content-position="left" style="font-size: 18px; font-weight: bolder">
                第二步 选择普测计划及问题类型(请查找需要生成问题的普测计划并选择一条需要生成问题的测试线路)
            </el-divider>
            <el-form :model="ordinaryA" :inline="true" class="form">
                <el-form-item>
                    <Area @click="handleNodeClick1" ref="area1"></Area>
                </el-form-item>

                <el-form-item label="普测结果上传时间:">
                    <el-date-picker
                        v-model="ordinaryA.planStartTime"
                        type="month"
                        format="yyyy 年 MM 月"
                        value-format="yyyy-MM-dd"
                        placeholder="选择月"
                        @change="queryPlanName"
                    ></el-date-picker>
                </el-form-item>

                <el-form-item label="普测计划名称:">
                    <el-select v-model="ordinaryA.planName" clearable placeholder="请选择">
                        <el-option
                            v-for="item in planNameList"
                            :key="item.planName"
                            :label="item.planName"
                            :value="item.planName"
                        ></el-option>
                    </el-select>
                </el-form-item>

                <el-form-item>
                    <el-button type="primary" icon="el-icon-search" @click="searchFnExcessive">查询</el-button>
                    <!-- <el-button type="primary" icon="el-icon-refresh" @click="resetFn2"
            >重置</el-button
          > -->
                </el-form-item>
            </el-form>

            <el-table
                stripe
                :data="ordinaryAddData"
                :height="height2"
                border
                style="width: 100%"
                v-loading="isLoading2"
                header-cell-class-name="table_header"
                @selection-change="handleSelectionChangeGeneral"
                :row-class-name="rowClassName"
            >
                <el-table-column type="selection" width="35"></el-table-column>
                <el-table-column prop="number" label="序号" width="100" :show-overflow-tooltip="true"></el-table-column>
                <el-table-column
                    prop="voltageLevel"
                    label="变电站电压等级(kV)"
                    :formatter="formFilter"
                    :show-overflow-tooltip="true"
                ></el-table-column>
                <el-table-column prop="subName" label="变电站名称" :show-overflow-tooltip="true"></el-table-column>
                <!-- <el-table-column
          prop="busbarName"
          label="母线名称"
          :show-overflow-tooltip="true"
        ></el-table-column> -->
            </el-table>

            <el-divider content-position="left" style="font-size: 18px; font-weight: bolder">
                第三步 选择问题指标
            </el-divider>
            <el-form :model="ordinaryAdddata" :rules="rules" ref="GeneralSurvey" :inline="true" class="form">
                <el-form-item label="稳态指标:" prop="steadyState">
                    <el-checkbox-group v-model="ordinaryAdddata.steadyState">
                        <el-checkbox v-for="(item, ind) in steadyStateList" :key="ind" :label="item.code">
                            {{ item.name }}
                        </el-checkbox>
                    </el-checkbox-group>
                </el-form-item>

                <el-form-item label="暂态指标:" prop="transientIndicators">
                    <el-checkbox-group v-model="ordinaryAdddata.transientIndicators">
                        <el-checkbox v-for="(item, ind) in transientIndicatorsList" :key="ind" :label="item.code">
                            {{ item.name }}
                        </el-checkbox>
                    </el-checkbox-group>
                </el-form-item>
            </el-form>

            <div style="display: flex; justify-content: center; margin-top: 10px">
                <el-button type="primary" class="ml20" @click="previouStep">上一步</el-button>
                <el-button type="primary" class="ml20" @click="GeneralSurvey">生成问题</el-button>
                <el-button type="primary" class="ml20" @click="handleClose">取消</el-button>
            </div>
        </el-dialog>

        <!-- 新增第二步(用户投诉问题新增) -->
        <el-dialog
            :close-on-click-modal="false"
            title="用户投诉问题新增"
            :visible.sync="userAdd"
            width="70%"
            :before-close="handleClose"
        >
            <el-divider content-position="left" style="font-size: 18px; font-weight: bolder">
                第二步 选择投诉用户(请精确查找用户户号并选中投诉用户)
            </el-divider>
            <el-form :model="userA" :inline="true" class="">
                <el-form-item label="用户类型:">
                    <el-select v-model="userA.userType" placeholder="请选择用户类型">
                        <el-option
                            v-for="item in userTypeData"
                            :key="item.code"
                            :label="item.label"
                            :value="item.code"
                        ></el-option>
                    </el-select>
                </el-form-item>

                <el-form-item label="用户编号:">
                    <el-input v-model="userA.id" clearable placeholder="请输入用户编号"></el-input>
                </el-form-item>

                <el-form-item>
                    <el-button type="primary" icon="el-icon-search" @click="searchFnComplain">查询</el-button>
                    <!-- <el-button type="primary" icon="el-icon-refresh" @click="resetFn3"
            >重置</el-button
          > -->
                </el-form-item>
            </el-form>

            <el-table
                stripe
                :data="userAddDataList"
                height="180px"
                border
                style="width: 100%"
                v-loading="isLoading3"
                header-cell-class-name="table_header"
                @selection-change="handleSelectionChangeUser"
                :row-class-name="rowClassName"
            >
                <el-table-column type="selection" width="35"></el-table-column>
                <el-table-column type="index" label="序号" width="100" :show-overflow-tooltip="true"></el-table-column>
                <el-table-column prop="id" label="用户编号" :show-overflow-tooltip="true"></el-table-column>
                <el-table-column prop="name" label="用户名称" :show-overflow-tooltip="true"></el-table-column>
                <!-- 用电用户 -->
                <el-table-column
                    v-if="showUserType"
                    prop="electricityType"
                    label="用电类别/电源类别"
                    :formatter="formatter1"
                    :show-overflow-tooltip="true"
                ></el-table-column>
                <!-- 发电用户 -->
                <el-table-column
                    v-else
                    prop="powerCategory"
                    label="用电类别/电源类别"
                    :formatter="formatter2"
                    :show-overflow-tooltip="true"
                ></el-table-column>
            </el-table>

            <el-divider content-position="left" style="font-size: 18px; font-weight: bolder">
                第三步 填写投诉详情
            </el-divider>
            <el-form :model="userAdddata" ref="userAdddata" :rules="rules" :inline="true" class="box">
                <el-form-item label="投诉内容:" style="margin-top: 10px" prop="complaintContent">
                    <el-input
                        type="textarea"
                        :rows="2"
                        placeholder="请输入内容"
                        v-model="userAdddata.complaintContent"
                    ></el-input>
                </el-form-item>

                <el-form-item label="投诉时间:" style="margin-top: 10px" prop="complaintTime">
                    <el-date-picker
                        v-model="userAdddata.complaintTime"
                        type="date"
                        placeholder="选择日期"
                        value-format="yyyy-MM-dd"
                    ></el-date-picker>
                </el-form-item>

                <el-divider content-position="left" style="font-size: 18px; font-weight: bolder">
                    第四步 选择问题指标
                </el-divider>

                <el-form-item label="稳态指标:" prop="steadyState">
                    <el-checkbox-group v-model="userAdddata.steadyState">
                        <el-checkbox v-for="(item, ind) in steadyStateList" :key="ind" :label="item.code">
                            {{ item.name }}
                        </el-checkbox>
                    </el-checkbox-group>
                </el-form-item>

                <el-form-item label="暂态指标:" prop="transientIndicators">
                    <el-checkbox-group v-model="userAdddata.transientIndicators">
                        <el-checkbox v-for="(item, ind) in transientIndicatorsList" :key="ind" :label="item.code">
                            {{ item.name }}
                        </el-checkbox>
                    </el-checkbox-group>
                </el-form-item>
            </el-form>

            <div style="display: flex; justify-content: center; margin-top: 10px">
                <el-button type="primary" class="ml20" @click="previouStep">上一步</el-button>
                <el-button type="primary" class="ml20" @click="userAddProblem">生成问题</el-button>
                <el-button type="primary" class="ml20" @click="handleClose">取消</el-button>
            </div>
        </el-dialog>

        <!-- 新增第二步(运维异常问题新增) -->
        <el-dialog
            :close-on-click-modal="false"
            title="运维异常问题新增"
            :visible.sync="operationAdd"
            width="70%"
            :before-close="handleClose"
        >
            <el-divider content-position="left" style="font-size: 18px; font-weight: bolder">
                第二步 选择普测计划及问题类型(请查找需要生成问题的普测计划并选择一条需要生成问题的测试线路)
            </el-divider>
            <el-form :model="operationAdddata" :inline="true" ref="operationAdd" :rules="rules" class="form">
                <el-form-item label="异常设备名称:" prop="abnormalDevName">
                    <el-input
                        v-model="operationAdddata.abnormalDevName"
                        clearable
                        placeholder="请填写异常设备名称"
                    ></el-input>
                </el-form-item>

                <el-form-item label="发现异常时间:" prop="abnormalDevTime">
                    <el-date-picker
                        v-model="operationAdddata.abnormalDevTime"
                        type="date"
                        placeholder="请选择发现异常时间"
                        value-format="yyyy-MM-dd"
                    ></el-date-picker>
                </el-form-item>
            </el-form>

            <el-form :inline="true" :model="operationAdddata" ref="operationAdd1" :rules="rules" class="box">
                <el-form-item label="设备异常描述:" style="margin-top: 10px" prop="eventDescription">
                    <el-input
                        type="textarea"
                        :rows="1"
                        placeholder="请填写设备异常描述"
                        v-model="operationAdddata.eventDescription"
                    ></el-input>
                </el-form-item>
            </el-form>

            <el-divider content-position="left" style="font-size: 18px; font-weight: bolder">
                第三步 选择问题指标
            </el-divider>
            <el-form :inline="true" :model="operationAdddata" ref="operationAdd2" :rules="rules" class="form">
                <el-form-item label="稳态指标:" prop="steadyState">
                    <el-checkbox-group v-model="operationAdddata.steadyState">
                        <el-checkbox v-for="(item, ind) in steadyStateList" :key="ind" :label="item.code">
                            {{ item.name }}
                        </el-checkbox>
                    </el-checkbox-group>
                </el-form-item>

                <el-form-item label="暂态指标:" prop="transientIndicators">
                    <el-checkbox-group v-model="operationAdddata.transientIndicators">
                        <el-checkbox v-for="(item, ind) in transientIndicatorsList" :key="ind" :label="item.code">
                            {{ item.name }}
                        </el-checkbox>
                    </el-checkbox-group>
                </el-form-item>
            </el-form>

            <div style="display: flex; justify-content: center; margin-top: 10px">
                <el-button type="primary" class="ml20" @click="previouStep">上一步</el-button>
                <el-button type="primary" class="ml20" @click="generateAbnormal">生成问题</el-button>
                <el-button type="primary" class="ml20" @click="handleClose">取消</el-button>
            </div>
        </el-dialog>
    </div>
</template>
<script>
import { dicData } from '@/assets/commjs/dictypeData'
import Month from './Month'
import Area from '@/views/components/Area/Area.vue'
import {
    addAbnormalIssues,
    getordinaryAddData,
    getAllAlarmDetailList,
    addExcessiveIssues,
    getPowerUtilizationUserList,
    getGenerateElectricityUserList,
    addComplaintIssues,
    addGeneralSurveyIssues,
    querySurveyPlanOnQuestion,
    querySurveyPlanName
} from '@/api/Process-supervision/electricitymanagement/electricitymanagement'
export default {
    components: { Area, Month },
    props: {},
    data() {
        return {
            add: false,
            addData: {
                orgName: '',
                problemSources: '',
                problemName: '',
                orgNo: ''
            },
            height1: null,
            height2: null,
            height3: null,
            isLoading1: false,
            isLoading2: false,
            isLoading3: false,
            userAddDataList: [],
            userA: {
                userType: 'Elec_User',
                id: ''
            },
            ordinaryA: {
                orgNo: '',
                planName: '',
                planStartTime: ''
            },
            UserList: [],
            GeneralSurveyList: [],
            rules: {
                problemName: [{ required: true, message: '请输入问题名称', trigger: 'blur' }],
                complaintContent: [{ required: true, message: '请输入投诉内容', trigger: 'blur' }],
                complaintTime: [{ required: true, message: '请选择时间', trigger: 'change' }],
                problemSources: [{ required: true, message: '情选择问题来源', trigger: 'change' }],
                abnormalDevTime: [{ required: true, message: '请选择时间', trigger: 'change' }],
                transientIndicators: [{ required: true, message: '请选择暂态指标', trigger: 'change' }],
                steadyState: [{ required: true, message: '请选择稳态指标', trigger: 'change' }],
                eventDescription: [{ required: true, message: '请输入设备异常描述', trigger: 'blur' }],
                abnormalDevName: [{ required: true, message: '请输入问题名称', trigger: 'blur' }]
            },
            userAdd: false,
            userAdddata: {
                complaintContent: '',
                complaintTime: '',
                steadyState: [],
                transientIndicators: []
            },
            showUserType: false,
            userAddData: [],
            //用户类型
            userTypeData: [],
            //问题来源
            problemData: [],
            onlineAddData: [],
            onlineAdd: false,
            ordinaryAdd: false,
            onlineAdddata: {
                alarmTime: ''
            },
            ordinaryAdddata: {
                uploadTime: '',
                name: '',
                steadyState: [],
                transientIndicators: []
            },
            ordinaryAddData: [],
            //普测计划名称
            planNameList: [],

            operationAdd: false,
            operationAdddata: {
                abnormalDevName: '',
                eventDescription: '',
                abnormalDevTime: '',
                steadyState: [],
                transientIndicators: []
            },

            steadyStateList: [], // 稳态指标
            transientIndicatorsList: [], //暂态指标
            OnlineList: []
        }
    },
    created() {},
    mounted() {
      this.setHeight()
      window.addEventListener('resize', this.setHeight)
      this.Dictionaries()
    },
    beforeDestroy() {
        window.removeEventListener('resize', this.setHeight)
    },
    methods: {
        setHeight() {
            this.height1 = window.sessionStorage.getItem('appheight') - 440
            this.height2 = window.sessionStorage.getItem('appheight') - 570
            this.height3 = window.sessionStorage.getItem('appheight') - 760
        },
        // 字典表
        Dictionaries() {
            this.addData.orgNo = JSON.parse(window.sessionStorage.getItem('Info')).deptId
            this.addData.orgName = JSON.parse(window.sessionStorage.getItem('Info')).deptName

            // /问题来源
            this.problemData = dicData('Problem_Sources', ['Load_Type'])
            // 稳态指标:
            this.steadyStateList = dicData('Steady_Indicator', ['Load_Type'])
            // 暂态指标:
            this.transientIndicatorsList = dicData('Transient_Indicators', ['Load_Type'])
            // 用户类型::
            this.userTypeData = dicData('User_Category', ['Load_Type'])
        },

        // 字典处理
        formatter(row, column) {
            let title = ''
            dicData('alarm_Type', ['Load_Type']).forEach(item => {
                if (item.id == row.alarmType) {
                    title = item.name
                }
            })
            return title
        },
        formatter1(row, column) {
            let title = ''
            dicData('Ele_Class', ['Load_Type']).forEach(item => {
                if (item.id == row.electricityType) {
                    title = item.name
                }
            })
            return title
        },
        formatter2(row, column) {
            let title = ''
            dicData('Power_Category', ['Load_Type']).forEach(item => {
                if (item.id == row.powerCategory) {
                    title = item.name
                }
            })
            return title
        },

        //下一步
        nextStep() {
            this.$refs.ruleForm.validate(valid => {
                if (valid) {
                    if (this.addData.problemSources == 'Online') {
                        this.add = false

                        this.onlineAdd = true
                        setTimeout(() => {
                            this.searchOnLine()
                        }, 0)
                    } else if (this.addData.problemSources == 'General') {
                        this.ordinaryA.orgNo = JSON.parse(window.sessionStorage.getItem('Info')).deptId
                        this.ordinaryA.planStartTime = this.getNowTime()

                        this.add = false
                        this.ordinaryAdd = true

                        this.queryPlanName()

                        setTimeout(() => {
                            this.searchFnExcessive()
                        }, 0)
                    } else if (this.addData.problemSources == 'User_Complaints') {
                        this.add = false
                        this.userAdd = true
                        this.searchFnComplain()
                    } else if (this.addData.problemSources == 'Dev_Exception') {
                        this.add = false
                        this.operationAdd = true
                    }
                }
            })
        },

        //获取当前时间
        getNowTime() {
            var date = new Date()
            //年 getFullYear()：四位数字返回年份
            var year = date.getFullYear() //getFullYear()代替getYear()
            //月 getMonth()：0 ~ 11
            var month = date.getMonth() + 1

            var time = year + '-' + this.addZero(month) + '-01'
            return time
        },
        //小于10的拼接上0字符串
        addZero(s) {
            return s < 10 ? '0' + s : s
        },
        queryPlanName() {
            //  this.ordinaryA.orgNo
            //            this.ordinaryA.planStartTime
            querySurveyPlanName({
                orgNo: this.ordinaryA.orgNo,
                planStartTime: this.ordinaryA.planStartTime
            }).then(res => {
                this.planNameList = res.data
                // if (res.data.length == 0) {
                //   this.ordinaryA.planName = "";
                //   this.ordinaryAddData = [];
                // }else{
                //     this.ordinaryA.planName = this.planNameList[0].planName;
                //      this.searchFnExcessive();
                // }
            })
        },
        //上一步
        previouStep() {
            this.onlineAdd = false
            this.ordinaryAdd = false
            this.userAdd = false
            this.operationAdd = false
            this.add = true
        },
        //在线新增查询   在线监测告警
        searchOnLine() {
            this.isLoading1 = true
            getAllAlarmDetailList({
                startTime: this.$refs.interval.timeValue[0],
                endTime: this.$refs.interval.timeValue[1]
            }).then(res => {
                this.isLoading1 = false
                this.onlineAddData = res.data
            })
        },
        //普测新增查询
        searchFnExcessive() {
            this.isLoading2 = true
            querySurveyPlanOnQuestion(this.ordinaryA).then(res => {
                this.isLoading2 = false
                this.ordinaryAddData = res.data
            })
        },
        // 用户投诉
        searchFnComplain() {
            this.isLoading3 = true
            if (this.userA.userType == 'Elec_User') {
                // 发电用户
                this.showUserType = false
                getGenerateElectricityUserList({ id: this.userA.id }).then(res => {
                    this.userAddDataList = res.data
                })
            } else {
                this.showUserType = true
                // 用电用户
                getPowerUtilizationUserList({ id: this.userA.id }).then(res => {
                    this.userAddDataList = res.data
                })
            }
            this.isLoading3 = false
        },

        // resetFn1() {
        //   this.onlineAdddata.alarmTime = "";
        // },
        //序号
        rowClassName({ row, rowIndex }) {
            row.number = rowIndex + 1
        },
        formFilter(row, column) {
            if (column.property == 'voltageLevel') {
                let title = ''
                dicData('Dev_Voltage', []).forEach(item => {
                    if (item.value == row.voltageLevel) {
                        title = item.label
                    }
                })
                return title
            } else {
                return row[column.property]
            }
        },
        //在线监测超标问题新增
        ChangeOnline(val) {
            this.OnlineList = val
        },

        handleSelectionChange(val) {
            this.multipleSelection = val
        },
        // 普测计划及问题类型
        handleSelectionChangeGeneral(val) {
            this.GeneralSurveyList = val
        },
        // 用户投诉
        handleSelectionChangeUser(val) {
            this.UserList = val
        },
        handleNodeClick1(data) {
            this.ordinaryA.orgNo = data.id
            this.queryPlanName()
        },

        // 关闭对话框
        handleClose() {
            this.$emit('handleClose')
        },
        //在线监测超标问题新增
        OnlineMonitoring() {
            if (this.OnlineList.length == 1) {
                let list = {
                    warnReason: this.OnlineList[0].alarmInfo,
                    warnLastTime: this.OnlineList[0].alarmLastTime,
                    warnTarget: this.OnlineList[0].alarmType,
                    measurementPointName: this.OnlineList[0].measurementPointName,
                    measurementPointId: this.OnlineList[0].measurementPointId
                }
                addExcessiveIssues({
                    ...list,
                    ...this.addData
                }).then(res => {
                    if (res.code == 'A0000') {
                        this.$message({
                            message: '新增成功!',
                            type: 'success'
                        })
                    }
                    this.$emit('handleClose')
                    this.$emit('onSubmit')
                })
            } else {
                this.$message({
                    message: '问题测点,请选择1条数据！！！',
                    type: 'warning'
                })
            }
        },

        // 生成填报运维监控异常问题
        generateAbnormal() {
            this.$refs['operationAdd'].validate(valid => {
                if (valid) {
                    this.$refs['operationAdd1'].validate(valid => {
                        if (valid) {
                            this.$refs['operationAdd2'].validate(valid => {
                                if (valid) {
                                    // this.operationAdddata.abnormalTarget = [
                                    //   ...this.operationAdddata.steadyState,
                                    //   ...this.operationAdddata.transientIndicators,
                                    // ];
                                    addAbnormalIssues({
                                        ...this.operationAdddata,
                                        ...this.addData
                                    }).then(res => {
                                        if (res.code == 'A0000') {
                                            this.$message({
                                                message: '新增成功!',
                                                type: 'success'
                                            })
                                            this.$emit('handleClose')
                                            this.$emit('onSubmit')
                                        }
                                    })
                                }
                            })
                        }
                    })
                }
            })
        },
        // 普测计划及问题类型
        GeneralSurvey() {
            if (this.GeneralSurveyList.length == 1) {
                this.$refs.GeneralSurvey.validate(valid => {
                    if (valid) {
                        this.ordinaryAdddata.substationId = this.GeneralSurveyList[0].subId
                        this.ordinaryAdddata.busbarId = this.GeneralSurveyList[0].busbarId
                        this.ordinaryAdddata.measurementPointId = this.GeneralSurveyList[0].measurementPointId
                        this.ordinaryAdddata.planName = this.GeneralSurveyList[0].planName
                        addGeneralSurveyIssues({
                            ...this.addData,
                            ...this.ordinaryAdddata
                        }).then(res => {
                            if (res.code == 'A0000') {
                                this.$message({
                                    message: '新增成功!',
                                    type: 'success'
                                })
                                this.$emit('handleClose')
                                this.$emit('onSubmit')
                            }
                        })
                    }
                })
            } else {
                this.$message({
                    message: '普测计划及问题类型,请选择1条数据！！！',
                    type: 'warning'
                })
            }
            //
        },
        // 填报用户投诉问题
        userAddProblem() {
            if (this.UserList.length == 1) {
                this.$refs.userAdddata.validate(valid => {
                    if (valid) {
                        this.userAdddata.userName = this.UserList[0].name
                        this.userAdddata.userNo = this.UserList[0].id
                        this.userAdddata.userType = this.userA.userType
                        this.userAdddata.electricityType =
                            this.userA.userType == 'Elec_User'
                                ? this.UserList[0].powerCategory
                                : this.UserList[0].electricityType

                        addComplaintIssues({ ...this.addData, ...this.userAdddata }).then(res => {
                            if (res.code == 'A0000') {
                                this.$message({
                                    message: '新增成功!',
                                    type: 'success'
                                })
                                this.$emit('handleClose')
                                this.$emit('onSubmit')
                            }
                        })
                    }
                })
            } else {
                this.$message({
                    message: '投诉用户,请选择1条数据！！！',
                    type: 'warning'
                })
            }
            //
        }
    },

    computed: {},

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