<template>
    <fullscreen :fullscreen.sync="fullscreen" class="container">
        <div class="container-box">
            <toolList @iconCli="iconCli" :tooltit="tooltit"></toolList>
            <!-- <div class="search">
                <mySearch
                    :searchList="searchList"
                    @searchInfo="searchInfo"
                ></mySearch>
                <el-button
                    class="btn-check"
                    size="medium"
                    type="primary"
                    @click="jumpadd"
                    v-if="isFuncBtnShow"
                    >新建
                </el-button>
            </div> -->
            <div class="tabbox">
                <el-table
                    height="calc(100% - 40px)"
                    class="com-table"
                    ref="multipleTable"
                    :data="tableData"
                    tooltip-effect="dark"
                    size="small"
                    border
                    style="width: 100%"
                    v-loading="loading"
                >
                    <el-table-column prop="regionName" label="模板名称">
                    </el-table-column>
                    <el-table-column label="操作" width="300px" align="center">
                        <template slot-scope="scope">
                            <!-- <el-button
                                size="mini"
                                type="primary"
                                @click="jump(2, scope.row)"
                                >查看</el-button
                            > -->
                            <el-button
                                size="mini"
                                type="primary"
                                @click="jump(1, scope.row)"
                                >查看</el-button
                            >
                            <!-- <el-button
                                size="mini"
                                type="primary"
                                @click="jump(2, scope.row)"
                                v-if="scope.row.fillFlag == 0"
                                >办结</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>
        </div>

        <myMessage
            :messTit="messTit"
            @closeMessage="closeMessage(1)"
            :centerDialogVisible="centerDialogVisible"
            v-if="centerDialogVisible"
        ></myMessage>
    </fullscreen>
</template>
<script>
import mySearch from "../../../components/search.vue";
import myMessage from "../../../components/myMessage.vue";
import toolList from "../../../components/toolList";
import myUpload from "../../../components/upload";
import deptTree from "../../../components/deptTreeUser.vue";
import deptTreep from "../../../components/deptTreeP.vue";

export default {
    components: {
        mySearch,
        myMessage,
        toolList,
        myUpload,
        deptTree,
        deptTreep
    },
    data() {
        const woName = (rule, value, callback) => {
            if (!this.infolist.woName) {
                callback(new Error("不能为空"));
            } else {
                callback();
            }
        };
        // const time = (rule, value, callback) => {
        //     if (!this.infolist.time) {
        //         callback(new Error("不能为空"));
        //     } else {
        //         callback();
        //     }
        // };
        return {
            rules: {
                woName: [
                    {
                        required: true,
                        trigger: "blur",
                        validator: woName
                    }
                ]
                // time: [
                //     {
                //         required: true,
                //         trigger: "change",
                //         validator: time
                //     }
                // ]
            },
            searchList: [
                // {
                //     type: 'input',
                //     tit: '业务名称',
                //     value: '',
                //     width: '32%',
                // },
                {
                    type: "sel",
                    tit: "状态",
                    value: "",
                    width: "100%",
                    options: [
                        {
                            dataCode: "0",
                            dataName: "待上传模板"
                        },
                        {
                            dataCode: "1",
                            dataName: "填写中"
                        },
                        {
                            dataCode: "2",
                            dataName: "已锁定"
                        }
                    ]
                }
                // {
                //     type: 'date',
                //     tit: '申请时间',
                //     value: '',
                //     width: '32%',
                // },
            ],
            tooltit: "存量运营策略征集",
            fullscreen: false,
            total: 0,
            pageSize: 1,
            tableData: [],
            dialogStatus: false,
            disableStatus: false,
            titname: "",
            infolist: {},
            // treeList: [],
            treeListp: [],
            treeListponly: [],
            closeList: [],
            defaultList: [],
            depttype: 0,
            fadept: {},
            deptList: [],
            userInfo: {},
            params: {},
            centerDialogVisible: false,
            messTit: "",
            delid: "",
            loading: false,
            loadinged: false,
            fileInfo: {
                limit: 10,
                url: "/market/cwo/upload",
                fileList: []
            },
            infoApply: {},
            rovaList: [],
            applicationDialogStatus: false,

            stsArr: ["待上传模板", "填写中", "已锁定"],
            provinceCityArr: ["省", "地市", "区县"],
            loginNoStr: "",
            cityWoId: "",
            menus: JSON.parse(window.sessionStorage.childrenMenus),
            isFuncBtnShow: false,
            countyFlag: "0",
            regionList: [],
            currentData: {},
            regionFlag: "0", //地区 0 省 1 地市 2 区
            regionCode: "", //地市名称
            parentWoNo: "", //工单id
            woName: "" //模板名称
        };
    },
    methods: {
        jump(v, n) {
            if (v === 1) {
                this.$router.push({
                    path: "/stockHandle",
                    query: {
                        strategyId: n.strategyId,
                        usrName: this.userInfo.loginName,
                        sts:'2',
                        countyFlag: '2',
                        fillFlag:'0',
                        regionName: n.regionName,
                        woName: this.woName
                    }
                });
            }
        },
        //搜索数据
        // searchInfo(v) {
        //     this.params = {};
        //     v[0] ? (this.params.sts = v[0]) : "";

        //     this.getList(this.params, this.pageSize);
        // },
        //获取列表
        getList(v, n) {
            this.pageSize = n;
            this.loading = true;
            this.tableData = [];
            this.$http({
                url: "/market/cAdvStrategy/queryMkAdvStrategyByPWoNo",
                method: "post",
                headers: {
                    "Content-Type": "application/json",
                    page: '{"pageNo":"' + n + '","pageSize":"10"}'
                },
                data: {
                    mkStrategyBic: {
                        parentWoNo: this.parentWoNo
                    },
                    regionList: [this.regionCode]
                }
            }).then(res => {
                this.tableData = res.data.data;
                this.total = res.data.totalRecord;
                this.loading = false;
            });
        },
        // 分页
        currchange(v) {
            this.pageSize = v;
            this.getList({}, this.pageSize);
        },

        closeMessage(v) {
            this.centerDialogVisible = false;
            let _this = this;
            if (v === 1) {
                _this
                    .$http({
                        url: "/market/cStrategyBic/update",
                        method: "post",
                        headers: {
                            "Content-Type": "application/json"
                        },
                        data: {
                            fillName: this.userInfo.loginName,
                            woNo: this.currentData.woNo,
                            sts: this.currentData.sts
                        }
                    })
                    .then(res => {
                        if (res.data.result === 1) {
                            _this.$message({
                                message: res.data.desc,
                                type: "error"
                            });
                        } else {
                            _this.$message({
                                message: "办结成功",
                                type: "success"
                            });
                            _this.getList({}, this.pageSize);
                        }
                    });
            }
        },
        //删除
        delLine(v) {
            this.centerDialogVisible = true;
            this.messTit = "即将删除此条数据, 是否删除?";
            this.delid = v.id;
        },
        //功能栏
        iconCli(v) {
            if (v === 1) {
                this.getList({}, this.pageSize);
            }
            if (v === 2) {
                this.fullscreen = !this.fullscreen;
            }
        },
        getUser() {
            this.userInfo = JSON.parse(window.sessionStorage.userInfo);
            this.loginNoStr = this.userInfo.loginNoStr;
        }
    },
    mounted() {
        if (JSON.stringify(this.$route.query) != "{}") {
            this.regionCode = this.$route.query.regionCode;
            this.parentWoNo = this.$route.query.parentWoNo;
            this.woName = this.$route.query.woName;
        }
        this.getUser();
        this.getList({}, 1);
        // for (var i = 0; i < this.menus.length; i++) {
        //     if (this.menus[i].jspUrl == "/stockOperate") {
        //         this.isFuncBtnShow = true;
        //         break;
        //     }
        // }

        // if (this.userInfo.countyName != null) {
        //     this.countyFlag = "0";
        //     this.isFuncBtnShow = false;
        //     this.regionFlag = "2";
        // } else if (
        //     this.userInfo.cityName != null &&
        //     this.userInfo.countyName == null
        // ) {
        //     this.countyFlag = "1";
        //     this.isFuncBtnShow = true;
        //     this.regionFlag = "1";
        // } else if (
        //     this.userInfo.cityName == null &&
        //     this.userInfo.countyName == null
        // ) {
        //     this.countyFlag = "1";
        //     this.isFuncBtnShow = true;
        //     this.regionFlag = "0";
        // }
        // this.userInfo.countyName != null
        //     ? (this.countyFlag = "0")
        //     : (this.countyFlag = "1");
    },
    created() {}
};
</script>
<style scoped lang="scss">
.onetab {
    margin-bottom: 20px;
    padding: 0 20px;
}

.titbox {
    div {
        float: right;

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

.tabbox {
    margin-top: 15px;
}

.pageBox {
    text-align: right;
    margin-top: 10px;
}

.info-line {
    width: 100%;
    display: block;
    padding-left: 20px;

    div {
        width: 50%;
        display: inline-block;
    }

    span {
        width: 80px;
        display: inline-block;
        text-align: left;

        i {
            color: red;
            display: inline-block;
            padding-right: 5px;
        }
    }

    .el-select,
    .el-input {
        width: calc(100% - 100px);
    }
}

.online::v-deep {
    width: 100%;

    .el-select {
        width: calc(100% - 120px);
    }

    span {
        // vertical-align: top;
    }

    .el-textarea,
    .el-date-editor {
        width: calc(100% - 100px);
        display: inline-flex;
    }
    .el-form-item__content {
        display: flex;
    }
}
.adv-type {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    // border: 1px solid #ddd;
    border-radius: 5px;
    padding: 20px;
    box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
    div {
        width: 33%;
        text-align: center;
        height: 80px;
        overflow: hidden;
        min-width: 100px;
        cursor: pointer;
        padding-top: 10px;
        margin: 10px 0;
    }
    div:hover {
        background: #cfe8fc;
        border-radius: 5px;
    }
    span {
        width: 100%;
        display: inline-block;
        height: 40px;
        // line-height: 40px;
        i {
            color: #0074d9;
            font-size: 36px;
        }
    }
}

.boximgc {
    display: flex;
    flex-wrap: wrap;
    width: 100% !important;
    margin-top: 20px;

    div {
        display: inline-block;
        width: 18% !important;
        margin-right: 2%;
        margin-bottom: 20px;
        overflow: hidden;
        border: 1px solid #ddd;
        border-radius: 3px;
        background: #fff;
        position: relative;
        height: 100px;

        img {
            width: 100%;
            position: absolute;
            top: 0;
            bottom: 0;
            margin: auto;
            // height: 100%;
        }
    }
}
.tree {
    width: calc(50% - 60px);
    display: inline-block;
    margin-right: 20px;
    height: 300px;
    overflow-y: scroll;
    flex: 1;
    p {
        overflow: hidden;
        display: flex;
        justify-content: space-between;
    }
    .p-btn {
        width: 50px !important;
        cursor: pointer;
        color: #0074da;
    }
    span {
        display: inline-block;
        width: calc(100% - 100px);
    }

    .el-icon-error {
        float: right;
        font-size: 20px;
        margin-top: 9px;
        cursor: pointer;
    }
}

.treeUser {
    // margin: 0;
    border: 1px solid #ddd;

    p {
        background: #f4f4f4;
        padding: 0 20px;
        margin-bottom: 5px;
    }
}

.treeUserb {
    width: calc(100% - 100px);
    border: 1px solid #ddd;
    background: #f4f4f4;
    border-radius: 3px;
    height: auto;
    overflow: hidden;

    p {
        display: inline-block;
        padding: 0 20px;
        margin-bottom: 5px;
    }
}

.treeUserp {
    p {
        padding: 5px;
    }
    p:hover {
        background: #01bef0;
        color: #fff;
        cursor: pointer;
    }
}
</style>
