<template>
    <div class="container">
        <fullscreen :fullscreen.sync="fullscreen" class="container-box">
            <div class="titbox">
                <h2>投诉单列表</h2>
                <div>
                    <i class="el-icon-refresh" @click="iconCli(1)"></i>
                    <i class="el-icon-full-screen" @click="iconCli(2)"></i>
                    <!--                    <i class="el-icon-folder-opened"></i>-->
                    <!--                    <i class="el-icon-view"></i>-->
                    <!--                    <i class="el-icon-more"></i>-->
                </div>
            </div>
            <div class="search">
                <mySearch :searchList="searchList" @searchInfo="searchInfo"></mySearch>
            </div>
            <div class="tabbox">
                <el-table height="calc(100% - 40px)" v-loading="loading" class="com-table" ref="multipleTable"
                    :data="tableData" tooltip-effect="dark" size="small" border style="width: 100%">
                    <el-table-column width="120" align="center" prop="complaintID" show-overflow-tooltip label="投诉单号">
                    </el-table-column>
                    <el-table-column width="120" align="center" prop="callID" label="呼叫ID">
                    </el-table-column>
                    <el-table-column prop="acptChnlID" label="受理渠道ID" show-overflow-tooltip width="120">
                    </el-table-column>
                    <el-table-column width="120" align="center" prop="srvReqTypeID" label="服务请求类型ID">
                    </el-table-column>
                    <el-table-column width="120" align="center" prop="acptCD" label="受理员工号码">
                    </el-table-column>
                    <el-table-column width="120" align="center" prop="acptTypeCD" label="受理方式代码">
                    </el-table-column>
                    align="center"
                    <el-table-column width="120" align="center" prop="acptTime" label="受理时间">
                    </el-table-column>
                    <el-table-column width="120" align="center" prop="callNumber" label="客户来电号码">
                        <template slot-scope="scope">
                              <span>{{vague(scope.row.callNumber)}}</span>
                        </template>
                    </el-table-column>
                    <el-table-column width="120" align="center" prop="cntctTel" label="客户编码">
                        <template slot-scope="scope">
                              <span>{{vague(scope.row.cntctTel)}}</span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="description" align="center" label="投诉内容" show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column width="120" prop="productID" label="关联产品"></el-table-column>
                    <el-table-column width="120" align="center" prop="cntctTel" label="联系电话号码">
                        <template slot-scope="scope">
                              <span>{{vague(scope.row.cntctTel)}}</span>
                        </template>
                    </el-table-column>
                    <el-table-column width="120" align="center" prop="email" label="电子邮箱地址"></el-table-column>
                    <el-table-column width="120" align="center" prop="node" label="处理环节">
                    </el-table-column>
                    <el-table-column width="120" align="center" prop="status" label="投诉单状态">
                    </el-table-column>
                    <el-table-column width="120" align="center" prop="status" label="派转外系统名称">
                    </el-table-column>
                    <el-table-column fixed="right" width="120" align="center" prop="rltSysNM" label="投诉处理工单列表">
                        <template slot-scope="scope">
                            <el-button size="mini" type="primary" plain @click="getDetailes(scope.row)">详情</el-button>
                        </template>
                    </el-table-column>
                    <el-table-column width="250" fixed="right" label="操作" align="center">
                        <template slot-scope="scope">
                            <el-button size="mini" type="danger" plain @click="goAlarm(scope.row)">工单告警</el-button>
                            <el-button size="mini" type="success" plain @click="goReturn(scope.row)">工单反馈</el-button>
                            <el-button size="mini" type="primary" plain @click="goLog(scope.row)">历史信息</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination class="pageBox" @current-change="currchange" layout="prev, pager, next" background
                    :total="total">
                </el-pagination>
            </div>
        </fullscreen>
        <el-dialog title="投诉处理工单列表" :visible.sync="tableStatus" width="80%" :close-on-press-escape="false"
            :show-close="false" :destroy-on-close="true" :modal-append-to-body="false" :close-on-click-modal="false">
            <el-table v-loading="loading" class="com-table" ref="multipleTable" :data="tableList" tooltip-effect="dark"
                size="small" border style="width: 100%">
                <el-table-column show-overflow-tooltip align="center" prop="complaintWOID" label="投诉单号">
                </el-table-column>
                <el-table-column width="100" align="center" prop="staffName" label="操作员">
                </el-table-column>
                <el-table-column width="100" align="center" prop="staffNO" label="操作员编码"></el-table-column>
                <el-table-column width="120" show-overflow-tooltip align="center" prop="createTime" label="创建时间">
                </el-table-column>
                <el-table-column width="150" align="center" prop="opTime" label="外系统处理环节名称">
                </el-table-column>
                <el-table-column width="120" align="center" show-overflow-tooltip prop="handleTime" label="处理时间">
                </el-table-column>
                <el-table-column width="120" align="center" prop="complaintWOSts" label="投诉处理工单状态">
                </el-table-column>
                <el-table-column align="center" prop="complaintNode" label="投诉环节">
                </el-table-column>
                <el-table-column align="center" prop="bizCode" label="返回码">
                </el-table-column>
                <el-table-column width="150" align="center" prop="bizDesc" label="返回信息描述" show-overflow-tooltip>
                </el-table-column>
            </el-table>
            <div slot="footer" class="dialog-footer">
                <el-button @click="
            () => {
              tableStatus = false;
            }
          ">取 消</el-button>
            </div>
        </el-dialog>
    </div>
</template>
<script>
    import pForm from "../../../components/p-form";
    import mySearch from "../../../components/search";

    export default {
        components: {
            mySearch,
            pForm,
        },
        data() {
            return {
                tableList: [],
                tableStatus: false,
                fullscreen: false,
                total: 0,
                pageSize: 1,
                tableData: [],
                dialogStatus: false,
                searchList: [{
                        type: "input",
                        tit: "故障号码",
                        value: "",
                        width: "32%",
                        options: [],
                    },
                    {
                        type: "sel",
                        tit: "投诉状态",
                        value: "",
                        width: "32%",
                        options: [{
                                dataName: "待处理",
                                dataCode: "0"
                            },
                            {
                                dataName: "关闭",
                                dataCode: "1"
                            },
                        ],
                    },
                    {
                        type: "datetime",
                        tit: "开始时间",
                        value: "",
                        width: "32%",
                    },
                    {
                        type: "datetime",
                        tit: "结束时间",
                        value: "",
                        width: "32%",
                    },
                ],
                params: {
                    srvNumber: "",
                    complaintStatus: "",
                    startTime: "",
                    endTime: "",
                },
                loading: false,
            };
        },
        methods: {
            vague(v){
                v = v.split("");
                v[3] = "*";
                v[4] = "*";
                v[5] = "*";
                v[6] = "*";
                let phone = '';
                for (let i = 0; i < v.length; i++) {
                    phone += v[i]
                }
                return phone
            },
            defaultMenu(path, name) {
                let defaults = this.$store.state.tabList.filter((item) => {
                    if (item.rountPath == path) {
                        return item;
                    }
                });
                if (defaults.length == 1) {
                    return;
                }
                let params = {
                    children: "",
                    name: name,
                    rountPath: path,
                    target: "_self",
                };
                let set = new Set([...this.$store.state.tabList, params]);
                this.$store.commit("setDefaultActive", path);
                this.$store.commit("setTabList", Array.from(set));
            },
            // 工单告警
            goAlarm(val) {
                this.$router.push({
                    name: "complaintWoAlarmInfoQuery",
                    params: {
                        complaintWOID: val.complaintID,
                    },
                });
                this.defaultMenu("/complaintWoAlarmInfoQuery", "投诉工单告警信息查询");
            },
            // 详情列表
            getDetailes(val) {
                this.tableStatus = true;
                this.tableList = val.complaintWOList;
            },
            goLog(val) {
                this.$router.push({
                    name: "complaintWoQuery",
                    params: {
                        complaintWOID: val.complaintID,
                    },
                });
                this.defaultMenu("/complaintWoQuery", "投诉处理工单历史信息查询");
            },
            // 工单反馈
            goReturn(val) {
                this.$router.push({
                    name: "complaintworkfeedback",
                    params: {
                        handleTime: val.acptTime,
                        staffNO: val.acptCD,
                        complaintWOID: val.complaintID,
                    },
                });
                this.defaultMenu("/complaintworkfeedback", "投诉处理工单反馈");
            },
            // 取消提交
            resetUser() {
                this.$refs.pForm.resetForm(this.form.formName);
            },
            closeDialog() {
                this.dialogStatus = false;
                this.getList(this.params, this.pageSize);
            },
            //搜索数据
            searchInfo(v) {
                this.params = {};
                v[0] ? (this.params.srvNumber = v[0]) : "";
                v[1] ? (this.params.complaintStatus = v[1]) : "";
                v[2] ?
                    (this.params.startTime = this.$formatDate(
                        v[2],
                        "YYYY-MM-DD"
                    )) :
                    "";
                v[3] ?
                    (this.params.endTime = this.$formatDate(v[3], "YYYY-MM-DD")) :
                    "";
                this.getList(this.params, this.pageSize);
            },
            //获取列表
            getList(v, n) {
                this.loading = true;
                this.pageSize = n;
                this.$http({
                    url: "/compvis/cpv/complaintQuery",
                    method: "post",
                    headers: {
                        "Content-Type": "application/json",
                        page: '{"pageNo":"' + n + '","pageSize":"10"}',
                    },
                    data: v,
                }).then((res) => {
                    this.loading = false;
                    this.tableData = res.data.data;
                    this.total = res.data.totalRecord;
                });
            },
            //功能栏
            iconCli(v) {
                if (v === 1) {
                    this.getList(this.params, this.pageSize);
                }
                if (v === 2) {
                    this.fullscreen = !this.fullscreen;
                }
            },
            // 分页
            currchange(v) {
                this.pageSize = v;
                this.getList(this.params, this.pageSize);
            },
        },
        mounted() {
            this.getList(this.params, this.pageSize);
        },
        created() {},
    };
</script>
<style>
    .el-input__suffix {
        cursor: pointer;
    }
</style>
<style scoped lang="scss">
    .titbox {
        div {
            float: right;

            i {
                font-size: 22px;
                margin-left: 20px;
                cursor: pointer;
            }
        }
    }

    .tabbox {
        margin-top: 15px;
    }

    .pageBox {
        text-align: right;
        margin-top: 10px;
    }
</style>
