<template>
    <div class="box">
        <div class="box-title">下发任务</div>
        <div class="box-container" style="padding-top: 20px;">
            <div class="inputer">
                <span>位置：</span>
                <el-input size="mini" style="width:300px;" v-model="location"></el-input>
            </div>
            <div class="inputer">
                <span>任务详情：</span>
                <el-input type="textarea" :rows="2" style="width:300px;" placeholder="请输入内容" v-model="content">
                </el-input>
            </div>
            <div class="inputer">
                <span style="float:left;margin-left:12px;">接收人员：</span>

                <div class="" style="float:left;width:300px;">
                    <el-table ref="multipleTable" :data="list" tooltip-effect="dark" height="200px"
                        style="width: 100%;margin-top:12px;" @selection-change="handleSelectionChange">
                        <el-table-column type="selection" width="55">
                        </el-table-column>
                        <el-table-column prop="name" label="姓名">
                        </el-table-column>

                    </el-table>
                </div>
            </div>
        </div>
        <div style="text-align:right;margin:0px 28px;">
            <el-button size="mini" @click="close">关闭</el-button>
            <el-button type="primary" size="mini" @click="onSubmit" :disabled="loading">下发任务</el-button>
        </div>
    </div>
</template>

<script>
import axios from 'axios'
import { getMethodCommon } from '../../../api/common';
let BASE_URL = process.env.VUE_APP_BASE_API;
export default {
    name: 'taskDelivery',
    props: ['globalmap', 'lng', 'lat'],
    data() {
        return {
            location: '',
            content: '',
            pathPointGraphicLayer: null,
            list: [],
            multipleSelection: [],
            listQuery:{
                pageIndex:1,
                pageSize:12,
                name:null,
            },
            loading:false,
        }
    },
    watch: {

    },
    created() {
        this.getUserList();
    },
    mounted() {
        if (this.lat) {
            this.location = this.lng + "," + this.lat;
        } ``
    },
    methods: {
        handleSelectionChange(val) {
            this.multipleSelection = val;
        },
        getUserList() {
            getMethodCommon("/FireManagement/LoadFireClueUser",this.listQuery).then(res=>{
                if(res.code == 200){
                    this.list = res.data;
                }
            })
        },
        close() {
            // if (this.pathPointGraphicLayer != null) {
            //     this.pathPointGraphicLayer.clear();
            //     window.globalmap.off(mars3d.EventType.click)
            // }
            this.$emit('closeTask')
        },
        buttonLoading(){
            this.loading = true;
            let _this = this;
            setTimeout(function(){
                _this.loading = false;
            },10000)
        },
        onSubmit() {
            var querys = {
                content: this.content,
                lng: this.lng,
                lat: this.lat,
                recipientUsers: this.multipleSelection.map(e => e.id)
            }
            if (this.lng == '') {
                this.$message.warning("请选择位置");
                return;
            }
            var url = process.env.VUE_APP_BASE_API + '/FireManagement/FireClueTask'
            // 按钮禁用
            this.buttonLoading();
            var _this = this
            axios({
                method: "post",
                url: url,
                data: querys,
                headers: {
                    'X-Token': localStorage.getItem("X-Token")
                }
            }).then(res => {
                if (res.data.code == 200) {
                    this.$message.success(res.data.msg);
                    // TODO 添加任务点后，在地图显示相应的图标
                    _this.close()
                } else {
                    this.$message.error(res.data.msg);
                }
            })
        }
    }
}
</script>

<style scoped>
.box {
    width: 100%;
    /* height: 100%; */
    background-image: url(/img/huoqing-bg.png);
    background-size: 100% 100%;
}

.box-container {
    width: calc(100% - 0px);
    padding: 0px 12px;
    height: calc(100% - 170px)!important;
}

.box-title {
    width: 100%;
    height: 45px;
    line-height: 45px;
    color: #fff;
    text-indent: 30px;
    text-align: left;
}

.tab-container {
    width: 210px;
    height: 60px;
    border-bottom: 1px solid #2F5D55;
    padding-top: 10px;
    margin: 0px auto;
}

.inputer {
    width: 84%;
    margin: 0px auto;
    line-height: 40px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

::v-deep .el-input__inner {
    background: none;
    border-color: #00fff0;
    color: #fff;
}

::v-deep .el-textarea__inner {
    background: none;
    border-color: #00fff0;
    color: #fff;
}

.upload-iocn-box {
    width: 240px;
    height: 210px;
    float: left;
    text-align: center;
    position: relative;
    margin-top: 25px;
    margin-left: 10px;
}

.upload-icon-bg {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0px;
    left: 0px;
    background: #193632;
    z-index: 2;
}

.upload-iocn-box::after {
    content: "";
    width: 40px;
    height: 40px;
    background: #00fff0;
    position: absolute;
    top: -3px;
    left: -3px;
    z-index: 1;
    border-radius: 1px;
}

.upload-iocn-box::before {
    content: "";
    width: 40px;
    height: 40px;
    background: #00fff0;
    position: absolute;
    top: -3px;
    right: -3px;
    border-radius: 1px;
    z-index: 1;
}

.upload-icon-bg2::after {
    content: "";
    width: 40px;
    height: 40px;
    background: #00fff0;
    position: absolute;
    bottom: -3px;
    left: -3px;
    border-radius: 1px;
    z-index: 1;
}

.upload-icon-bg2::before {
    content: "";
    width: 40px;
    height: 40px;
    background: #00fff0;
    position: absolute;
    bottom: -3px;
    right: -3px;
    border-radius: 1px;
    z-index: 1;
}

.upload-iocn-box img {
    width: 80px;
}

.upload-iocn {
    margin-top: 10px;
}

.upload-icon-text {
    font-size: 14px;
    color: #ccc;
    margin: 16px 0px;
}

::v-deep .el-table th.el-table__cell {
    background: #193632;
    color: #fff;
    border: 1px solid #00fff0;
}

::v-deep .el-table tr {
    background: #193632;
    color: #fff;

}


::v-deep .el-table .el-table__body tr:hover>td {
    background-color: rgba(255, 255, 255, .1) !important;
}

::v-deep .el-table .el-table__body tr.current-row>td {
    background-color: rgba(255, 255, 255, .1) !important;
}

::v-deep .el-table,
.el-table__expanded-cell {
    background: none;
}

::v-deep .el-table td,
.el-table th.is-leaf {
    border: 0px;
}

::v-deep .el-table th,
.el-table tr {
    background: none;
}
</style>