<style scoped>
    .add-Enclosure {
        display: flex;
        justify-content: space-between;
    }

    .add-Enclosure-left {
        display: flex;
    }

    .item-but-box {
        display: flex;
    }

    .item-but {
        margin-right: 10px;
    }

    .numIcon {
        font-size: 12px;
        padding: 5px;
        color: #409eff;
    }

    .numIcon:hover {
        cursor: pointer;
    }

    .tatusText.grey {
        color: grey;
    }

    .tatusText.success {
        color: #21BA45;
    }

    .tatusText.error {
        color: #F2C037;
    }

    .tatusText.cancel {
        color: #c1c1c1;
    }

    .tatusText.Black {
        color: Black;
    }

    .ToBeReceived.red {
        color: #fd397a;
    }

    .ToBeReceived.blue {
        color: #409eff;
    }

    .income_1 {
        color: #2961FE;
        cursor: pointer;
    }

    .income_2 {
        color: #3FC4FF;
        cursor: pointer;
    }

    .enedit-box {
        display: flex;
        align-items: center;
    }

    .select-right {
        margin-left: 5px;
    }

    .Credentials {
        color: #2961FE;
        cursor: pointer;
    }

    .agreement-IncomeMoney-box {
        /* position: relative; */
    }

    .agreement-IncomeMoney-box .numIcon {
        position: relative;
    }

    .agreement-IncomeMoney-pop {
        position: absolute;
        top: -15px;
        left: 30px;
        z-index: 1;
        background: #fff;
        padding: 10px 19px 10px 19px;
        Box-shadow: 5px 5px 10px 5px #ccc;
    }

    /deep/.Agreement-Business .el-table .cell {
        overflow: initial !important;
    }

    .agreement-Cancel {
        text-align: right;
        color: #409eff;
    }

    .agreement-Cancel span:first-child {
        color: #999999;
        margin-right: 20px;
    }

    .agreement-Cancel span:hover {
        cursor: pointer;
    }

    .float-flag-shape {
        position: absolute;
        top: 20px;
        border: 1px solid #fff;
        height: 0;
        width: 0;
        border-left: 4px solid rgba(0, 0, 0, 0);
        border-right: 4px solid #fff;
        border-top: 3px solid rgba(0, 0, 0, 0);
        border-bottom: 3px solid #fff;
        left: -8px;
    }

    /deep/.el-table .cell.el-tooltip {
        overflow: hidden !important;
    }

    /deep/.classorder .Agreement-Business table th {
        text-indent: 0 !important;
    }

    /deep/.el-table th>.cell {
        text-align: left !important;
    }

    .OrderType-text-box {
        word-break: break-word;
        word-wrap: break-word;
        white-space: -moz-pre-wrap;
        white-space: -hp-pre-wrap;
        white-space: -o-pre-wrap;
        white-space: -pre-wrap;
        white-space: pre;
        white-space: pre-wrap;
        white-space: pre-line;
    }

    .text-underline {
        font-size: 16px;
        color: rgb(41, 97, 254);
        margin-right: 10px;
        font-weight: bold;
        cursor: pointer;
    }

    .OrderType-text-box .text-underline:hover {
        text-decoration: underline;
    }

    .OrderType-text {
        font-size: 10px;
        font-weight: 100;
        margin-left: 5px;
        border-radius: 3px;
        display: inline-block;
        padding: 0 1px;
        margin-bottom: 2px;
    }

    .OrderType-text-box .OrderType-text:nth-child(2) {
        margin-left: 0;
    }

    .OrderType-text.one {
        color: rgb(41, 97, 254);
        background-color: rgba(41, 97, 254, .2);
    }

    .OrderType-text.two {
        color: rgb(242, 140, 29);
        background-color: rgba(242, 140, 29, .2);
    }

    .OrderType-text.three {
        color: rgb(63, 196, 255);
        background-color: rgba(63, 196, 255, .2);
    }

    .OrderType-text.four {
        color: rgb(255, 111, 0);
        background-color: rgba(255, 111, 0, .2);
    }

    .OrderType-text.five {
        color: rgb(33, 186, 69);
        background-color: rgba(33, 186, 69, .2);
    }

    .Order-list-Status.six {
        color: rgb(102, 187, 106);
        background-color: rgba(102, 187, 106, .2);
    }
</style>
<template>
    <div class="Agreement-Business">
        <div class="add-Enclosure">
            <el-row :gutter="22">
                <el-col :span="8">
                    <el-input size="mini" placeholder="输入订单ID" v-model="msg.OrderId" label="订单ID"
                        @keyup.native="handleCurrentChange(1)"></el-input>
                </el-col>
                <el-col :span="8">
                    <div style="display: flex;flex-direction: row;align-items: center;">
                        <span class="font-size-12" style="padding-right: 10px;flex-shrink: 0;">订单类型：</span>
                        <el-select size="mini" width="200" v-model="msg.OrderType" placeholder="请选择" @change="handleCurrentChange(1)">
                            <el-option v-for="item in OrderTypeList" :key="item.Id" :label="item.Name" :value="item.Id">
                            </el-option>
                        </el-select>
                    </div>
                </el-col>
                <el-col :span="8">
                    <div style="display: flex;flex-direction: row;align-items: center;">
                        <span class="font-size-12" style="padding-right: 10px;flex-shrink: 0;">订单状态：</span>
                        <el-select size="mini" width="200" v-model="msg.OrderState" placeholder="请选择"
                            @change="handleCurrentChange(1)">
                            <el-option v-for="item in OrderStatusList" :key="item.Id" :label="item.Name"
                                :value="item.Id"></el-option>
                        </el-select>
                    </div>
                </el-col>
            </el-row>
            <el-dropdown @command="handleCommand" style="top: 1px;">
                <el-button plain icon="el-icon-plus" type="primary" size="mini" class="margin-right0">
                创建订单</el-button>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item command="1"> 机票订单</el-dropdown-item>
                  <el-dropdown-item command="2"> 签证订单</el-dropdown-item>
                  <el-dropdown-item command="3"> 跟团游订单</el-dropdown-item>
                  <el-dropdown-item command="4"> 当地游订单</el-dropdown-item>
                  <el-dropdown-item command="5"> 酒店订单</el-dropdown-item>
                  <el-dropdown-item command="6"> 门票订单</el-dropdown-item>
                  <el-dropdown-item command="7"> 包车订单</el-dropdown-item>
                </el-dropdown-menu>
            </el-dropdown>
        </div>
        <div class="page-content">
            <orderList :dataList="dataList" :pagesTitle="title" :loading="loading" @emptyMore="emptyMore"></orderList>
        </div>
        <div v-if="total>0">
            <el-pagination class="Mypagination" background @current-change="handleCurrentChange"
                :page-sizes="[10, 30, 60, 90, 100]" :page-size="msg.pageSize" layout="total, sizes, prev, pager, next"
                @size-change="handleSizeChange" :total="total">
            </el-pagination>
        </div>
        <!-- 单号抽屉 -->
        <el-drawer @closed="closeOrderDrawerHandler" :with-header="false" size='70%' :append-to-body="true"
            :visible.sync="orderDrawer" direction="rtl" :before-close="handleClose">
            <orderDetailsDrawer v-if="currentOrder" :orderId="currentOrder.OrderId" />
        </el-drawer>
    </div>
</template>
<script>
    import orderList from "../myOrdersAllType/components/orderList";
    import orderDetailsDrawer from "../customerManage/orderDetailsDrawer";
    export default {
        components: {
            orderList,
            orderDetailsDrawer
        },
        props: ["detailsData","ID", "BusinessType"],
        data() {
            return {
                title: '详情',
                VisaList: [{
                        Name: "不限",
                        Id: "0"
                    },
                    {
                        Name: "未出签",
                        Id: "1"
                    },
                    {
                        Name: "已出签",
                        Id: "2"
                    },
                ],
                MultipleChoiceList: [ //多选项目
                    {
                        Name: '机票',
                        Id: '1',
                        show: false
                    }, {
                        Name: '签证',
                        Id: '2',
                        show: false
                    }, {
                        Name: '地接',
                        Id: '3',
                        show: false
                    }, {
                        Name: '套餐',
                        Id: '4',
                        show: false
                    }, {
                        Name: '其他',
                        Id: '5',
                        show: false
                    }
                ],
                checkList: [],
                MoreList: [{
                        Name: '取消订单',
                        Id: '1'
                    }, {
                        Name: '订单转交',
                        Id: '2'
                    },
                    {
                        Name: "修改出票状态",
                        Id: "4",
                    }, {
                        Name: '完结',
                        Id: '5'
                    }, {
                        Name: '操作日志',
                        Id: '3'
                    },
                ],
                OrderStatusList: [
                {Name: '不限',Id:0},
                {Name: '正常',Id:1},
                {Name: '取消',Id:2}], //订单状态
                OrderTypeList:[],
                ticketingStatusList: [], // 出票状态
                dataList: [],
                loading: false,
                msg: {
                    // pageIndex: 1,
                    // pageSize: 10,
                    // OrderId: "",
                    // GuestId: "",
                    // TicketStatus: '0',
                    // VisaStatus: "0", //出签状态
                    // OrderStatus: "0",
                    // StartCityName: "",
                    // EndCityName: "",
                    // EnterID: "",
                    // userInfo: {},
                    pageIndex: 1,
                    pageSize: 15,
                    OrderId: "", //订单id
                    GuestId: 0, //客人id
                    EnterId: '0', //业务员id
                    OrderState: 1, //订单状态
                    Q_IsCollect: "0", //收款状态
                    StartTime: "",//报名开始日期
                    EndTime: "",//报名结束日期
                    IsMyOrder: "1", //我的订单
                    FinishSTime: "",//完结开始时间 
                    FinishETime: "",//完结结束时间
                    DepartSTime: "",//出发开始
                    DepartETime: "",//出发结束
                    TCNUM: "",//团号
                    ProductName: "",//商品名称
                    CustomerName: "",//客户名称
                    LureEmpId: 0,//引流人员
                    LineId: 0,//线路
                    TravelType: 0,//跟团类型 1跟团 2当地游
                    OrderType: "0",//订单类型
                    IsSelectCRM: 1,//1来源crm
                    IsMyOrder: 0,//1我的订单
                },
                total: 0,
                currentOrder: null,
                orderDrawer: false,
            };
        },
        watch: {
            ID: {
                handler(val, oldVal) {
                    this.getList();
                },
                deep: true,
            },
            detailsData: {
                handler(val, oldVal) {
                    this.detailsData = val
                },
                deep: true,
            },
        },
        mounted() {
            // this.msg.StartTime = this.getBeforeDate(31, new Date())
            this.msg.EndTime = this.formatDate(new Date(), "YYYY-MM-dd", 0)
            this.userInfo = this.getLocalStorage();
            this.getList();
            this.GetTicketStatusEnumList()
            this.GetOrderTypeEnumList() //订单状态枚举
            let $this = this
            $this.MsgBus.$on("closeGetList", function () {
                $this.getList()
            });
            $this.MsgBus.$on("closeBillMaking", function () {
                for (let i = 0; i < $this.dataList.length; i++) {
                    $this.dataList[i].checkList = []
                    $this.dataList[i].selectedType = ""
                    $this.dataList[i].actuallyReceived = false
                    $this.dataList[i].cost = false
                }
                $this.emptyMore()
            });
        },
        methods: {
            handleCommand(command) {
                let data = [{
                    path: "",
                    LureEmpNmae: this.detailsData.CreateByStr,//引流姓名
                    LureEmpId: this.detailsData.CreateBy,//引流id
                    CRMGuestId: this.ID, //客人ID
                    CRMGuestName: this.detailsData.SurName+this.detailsData.Name //客人ID
                }]
                let href
                let url = this.domainManager().erpRoutingUrl;
                if (command == 1) { 
                    this.addBusiness();
                }else{
                    if (command == 2) {
                        data[0].path = 'VisaProductAddOrder'
                        href =url +"automaticLogin?token=" +this.getLocalStorage().token +"&data=" +JSON.stringify(data);
                    }else if (command == 3) {
                        data[0].path = 'productQuery'
                        href =url +"automaticLogin?token=" +this.getLocalStorage().token +"&data=" +JSON.stringify(data);
                    }
                    else if (command == 4) {
                        data[0].path = 'productQueryOne'
                        href =url +"automaticLogin?token=" +this.getLocalStorage().token +"&data=" +JSON.stringify(data);
                    }
                    else if (command == 5) {
                        data[0].path = 'singleProductHotelList'
                        href =url +"automaticLogin?token=" +this.getLocalStorage().token +"&data=" +JSON.stringify(data);
                    }
                    else if (command == 6) {
                        data[0].path = 'SingleticketList'
                        href =url +"automaticLogin?token=" +this.getLocalStorage().token +"&data=" +JSON.stringify(data);
                    }
                    else if (command == 7) {
                        data[0].path = 'BookAcarList'
                        href =url +"automaticLogin?token=" +this.getLocalStorage().token +"&data=" +JSON.stringify(data);
                    }
                    if(href){
                        window.open(href);
                    }
                    
                }
            },
            // 清空下拉
            emptyMore() {
                this.dataList.forEach(item => {
                    return item.More = ''
                })
            },
            // 点击单号
            clickSingleNumber(item) {
                this.currentOrder = item;
                this.orderDrawer = true;
            },
            closeOrderDrawerHandler() {
                this.currentOrder = null;
                this.orderDrawer = false;
            },
            handleClose(done) {
                done();
            },
            // 取消
            popCancelClick(row, index, num) {
                this.dataList.forEach(item => {
                    item.checkList = []
                    item.selectedType = ''
                    item.actuallyReceived = false
                    item.cost = false
                })
            },
            // 确定弹窗
            popClick(row, index, num) {
                if (!row.selectedType) {
                    this.$message.warning('请选择类型!');
                    return
                }
                this.makeAdocumentFun(row, index, num)
                this.dataList[index].actuallyReceived = false
                this.dataList[index].cost = false
            },

            // 查看出票凭据
            viewCredentials(row) {
                let $this = this;
                this.MsgBus.$emit("CredentialsOrderTicketOrderBoxOpen", $this.ID, row, true);
            },
            // 清空下拉
            emptyMore() {
                this.dataList.forEach(item => {
                    return item.More = ''
                })
            },
            chooseMore(row) {
                //   取消订单
                if (row.More == "1") {
                    this.cancelOrder(row);
                }
                //   订单转交
                if (row.More == "2") {
                    this.convertOrder(row);
                }
                //   编辑订单金额
                if (row.More == '3') {
                    this.editOrderAmount(row)
                }
                //   修改出票状态
                if (row.More == '4') {
                    this.modifyStatus(row)
                }
                //   修改出签状态
                if (row.More == "5") {
                    this.AmendVisa(row)
                }
                //   完结
                if (row.More == "6") {
                    this.orderCompleted(row)
                }
                //   操作日志
                if (row.More == "7") {
                    this.operationLog(row);
                }
                //   订单收损
                if (row.More == "8") {
                    this.lossOperationfun(row);
                }
                //   订单收损完结
                if (row.More == "9") {
                    this.endOfLoss(row);
                }
                //   修改日期
                if (row.More == "10") {
                    this.modifiedDate(row);
                }
            },
            //  修改日期
            modifiedDate(row){
                let $this = this
                this.MsgBus.$emit("modifiedDateOrderBoxOpen", $this.ID, row, true);
            },
            //   订单收损完结
            endOfLoss(row) {
                if (this.userInfo.EmployeeId != row.EnterID && this.userInfo.EmployeeId != row.CreateBy) {
                    this.ValidateOperator();
                } else {
                    this.endOfLossfun(row)
                }

            },
            endOfLossfun(row) {
                let tips = '一旦确认订单收损完结，你将无法对订单执行任何操作，包括订单相关的财务单据。'
                this.$confirm(tips, '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    this.apipost('/api/Order/SetOrderLossFinish', {
                        OrderId: row.OrderId,
                    }, res => {
                        if (res.data.resultCode == 1) {
                            this.$message.success(res.data.message);
                            this.MsgBus.$emit("closeGetList");
                        } else {
                            this.$message.warning(res.data.message);
                        }
                    })
                }).catch(() => {
                    this.emptyMore()
                    this.$message({
                        type: 'info',
                        message: '已取消'
                    });
                });
            },
            // 收损
            lossOperation(row) {
                if (this.userInfo.EmployeeId != row.EnterID && this.userInfo.EmployeeId != row.CreateBy) {
                    this.ValidateOperator();
                } else {
                    this.lossOperationfun(row)
                }
            },
            lossOperationfun(row) {
                this.MsgBus.$emit(
                    "lossOrderBoxOpen",
                    row.GuestId,
                    row,
                    true
                );
            },
            // 订单完结
            orderCompleted(row) {
                if (this.userInfo.EmployeeId != row.EnterID && this.userInfo.EmployeeId != row.CreateBy) {
                    this.ValidateOperator();
                } else {
                    this.orderCompletedfun(row)
                }
            },
            orderCompletedfun(row) {
                let tips = '一旦确认订单完结，你将无法对订单执行任何操作，包括订单相关的财务单据。'
                this.$confirm(tips, '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    this.apipost('/api/Order/SetOrderFinish', {
                        OrderId: row.OrderId,
                    }, res => {
                        if (res.data.resultCode == 1) {
                            this.$message.success(res.data.message);
                            this.getList()
                        } else {
                            this.$message.warning(res.data.message);
                        }
                    })
                }).catch(() => {
                    this.emptyMore()
                    this.$message({
                        type: 'info',
                        message: '已取消'
                    });
                });
            },
            // 转换订单  
            convertOrder(row) {
                if (this.userInfo.EmployeeId != row.EnterID && this.userInfo.EmployeeId != row.CreateBy) {
                    this.ValidateOperator();
                } else {
                    this.convertOrderfun(row)
                }
            },
            convertOrderfun(row) {
                if (row.OrderStatus != '2') {
                    this.MsgBus.$emit(
                        "convertOrderTicketOrderBoxOpen",
                        row.GuestId,
                        row,
                        true
                    );
                } else {
                    this.$confirm('抱歉,该订单已取消,不能转交', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        this.emptyMore()
                    }).catch(() => {
                        this.emptyMore()
                    });
                }
            },
            // 验证操作员
            ValidateOperator() {
                this.$message({
                    type: 'warning',
                    message: '抱歉,该订单您没有操作权限!'
                });
                this.emptyMore()
            },
            // 多选发生变化
            clickMultipleChoice(row, index, num) {
                if (num == 1) {
                    row.selectedType = row.checkList.join(',')
                }
            },
            // 删除套餐值
            delType(row, item) {
                for (let i = 0; i < row.checkList.length; i++) {
                    if (row.checkList[i] == item) {
                        row.checkList.splice(i, 1)
                    }
                }
            },
            // 制作单据
            makeAdocument(row, index, num) {
                let list = row.OrderType && row.OrderType.split(',')
                if (list != null && list.length > 1 && num == 1) {
                    this.dataList.forEach(item => {
                        return item.cost = false
                    })
                    this.dataList.forEach(item => {
                        return item.actuallyReceived = false
                    })
                    this.dataList[index].actuallyReceived = true

                } else if (list != null && list.length > 1 && num == 3) {
                    this.dataList.forEach(item => {
                        return item.actuallyReceived = false
                    })
                    this.dataList.forEach(item => {
                        return item.cost = false
                    })
                    this.dataList[index].cost = true
                } else {
                    this.makeAdocumentFun(row, index, num)
                }
            },
            makeAdocumentFun(row, index, num) {
                let type
                type = num == 1 ? 1 : 2 // 1收款 2退款 3成本
                let href
                let url = this.domainManager().erpRoutingUrl
                let data
                let list = row.OrderType && row.OrderType.split(',')
                if (this.userInfo.EmployeeId != row.EnterID && this.userInfo.EmployeeId != row.CreateBy) {
                    this.ValidateOperator()
                } else {
                    if (row.OrderStatus != '2') {
                        if (list && list.length > 1) {
                            let typeList = row.selectedType.split(',')
                            if (num == '1' && typeList.length >= 2) {
                                let $this = this;
                                row.ReFinanceId2 = num
                                this.MsgBus.$emit("BillMakingOrderBoxOpen", $this.ID, row, true);
                            }
                            if (typeList.length == 1 && num == '1' || num == '3') {
                                data = [{
                                    path: 'ChoiceAddFinancialDocuments',
                                    type: type,
                                    OtherType: 55,
                                    ReFinanceId: row.OrderId,
                                    ReFinanceId2: num,
                                    GuestId: row.GuestId,
                                    RelevanceFrId: row.selectedType, // 单据类型
                                }]
                                href = url + 'automaticLogin?token=' + this.getLocalStorage().token + '&data=' + JSON
                                    .stringify(data)
                                window.open(href);
                                for (let i = 0; i < this.dataList.length; i++) {
                                    this.dataList[i].checkList = []
                                    this.dataList[i].selectedType = ""
                                    this.dataList[i].actuallyReceived = false
                                    this.dataList[i].cost = false
                                }
                            }
                            if (num == '2') {
                                data = [{
                                    path: 'ChoiceAddFinancialDocuments',
                                    type: type,
                                    OtherType: 55,
                                    ReFinanceId: row.OrderId,
                                    ReFinanceId2: num,
                                    GuestId: row.GuestId,
                                }]
                                href = url + 'automaticLogin?token=' + this.getLocalStorage().token + '&data=' + JSON
                                    .stringify(data)
                                window.open(href);
                                for (let i = 0; i < this.dataList.length; i++) {
                                    this.dataList[i].checkList = []
                                    this.dataList[i].selectedType = ""
                                    this.dataList[i].actuallyReceived = false
                                    this.dataList[i].cost = false
                                }
                            }

                        } else {
                            data = [{
                                path: 'ChoiceAddFinancialDocuments',
                                type: type,
                                OtherType: 55,
                                ReFinanceId: row.OrderId,
                                ReFinanceId2: num,
                                GuestId: row.GuestId,
                                RelevanceFrId: num==2?1:row.OrderType, // 单据类型
                            }]
                            href = url + 'automaticLogin?token=' + this.getLocalStorage().token + '&data=' + JSON
                                .stringify(data)
                            window.open(href);
                            for (let i = 0; i < this.dataList.length; i++) {
                                this.dataList[i].checkList = []
                                this.dataList[i].selectedType = ""
                                this.dataList[i].actuallyReceived = false
                                this.dataList[i].cost = false
                            }
                        }

                    }

                }
            },

            // 操作日志
            operationLog(row) {
                let $this = this;
                this.MsgBus.$emit("logTicketOrderBoxOpen", $this.ID, row, true);
            },
            // 修改签证状态
            AmendVisa(row) {
                if (this.userInfo.EmployeeId != row.EnterID && this.userInfo.EmployeeId != row.CreateBy) {
                    this.ValidateOperator()
                } else {
                    this.AmendVisafun(row);
                }
            },
            AmendVisafun(row) {
                this.MsgBus.$emit("AmendVisaOrderBoxOpen", row.GuestId, row, true);
            },
            // 出签凭证详情
            CheckOutDetails(row) {
                let $this = this;
                this.MsgBus.$emit(
                    "CheckOutDetailsOrderBoxOpen",
                    $this.ID,
                    row,
                    true
                );
            },
            // 修改出票状态
            modifyStatus(row) {
                if (this.userInfo.EmployeeId != row.EnterID && this.userInfo.EmployeeId != row.CreateBy) {
                    this.ValidateOperator()
                } else {
                    if (row.OrderStatus == 2) {
                        this.emptyMore()
                    } else {
                        if (row.TicketStatus == 3) {
                            return
                        } else if (row.TicketStatus == 4) {
                            return
                        } else {
                            let $this = this;
                            this.MsgBus.$emit("reviseTicketOrderBoxOpen", $this.ID, row, true);
                        }
                    }
                }
            },
            // 取消订单
            cancelOrder(row) {
                if (this.userInfo.EmployeeId != row.EnterID && this.userInfo.EmployeeId != row.CreateBy) {
                    this.ValidateOperator()
                } else {
                    if (row.OrderStatus != '2' && row.IncomeFinance.length == 0 && row.BackFinance.length == 0 && row
                        .PayFinance.length == 0) {
                        let tips = '此操作将取消该订单，是否继续取消?'
                        this.$confirm(tips, '提示', {
                            confirmButtonText: '确定',
                            cancelButtonText: '取消',
                            type: 'warning'
                        }).then(() => {
                            this.apipost('/api/Order/SetGuestOrderState', {
                                OrderId: row.OrderId,
                                Type: '1',
                            }, res => {
                                if (res.data.resultCode == 1) {
                                    this.$message.success(res.data.message);
                                    this.getList()
                                }
                            })
                        }).catch(() => {
                            this.emptyMore()
                            this.$message({
                                type: 'info',
                                message: '已取消'
                            });
                        });
                    } else {
                        this.$message({
                            type: 'warning',
                            message: '该订单已有财务单据，不能取消!'
                        });
                        this.emptyMore()
                    }
                }

            },
            // 编辑订单
            editOrder(row) {
                if (this.userInfo.EmployeeId != row.EnterID && this.userInfo.EmployeeId != row.CreateBy) {
                    this.ValidateOperator()
                } else {
                    if (row.OrderStatus==1&&(row.TicketStatus == 1||row.TicketStatus == 5) || (row.visaStatus == 0||row.visaStatus == 1)) { 
                        let $this = this;
                        this.MsgBus.$emit("editOrderTicketOrderBoxOpen", $this.ID, row, true);
                    } else {
                        this.emptyMore()
                    }
                }
            },
            // 编辑订单金额
            editOrderAmount(row) {
                if (this.userInfo.EmployeeId != row.EnterID && this.userInfo.EmployeeId != row.CreateBy) {
                    this.ValidateOperator()
                } else {
                    if (row.OrderStatus==1&&(row.TicketStatus == 1||row.TicketStatus == 5) || (row.visaStatus == 0||row.visaStatus == 1)) {
                        let $this = this;
                        this.MsgBus.$emit("editTicketOrderBoxOpen", $this.ID, row, true);
                    } else {
                        this.emptyMore()
                    }
                }


            },
            openDetails(row) {
                let href
                let url = this.domainManager().erpRoutingUrl
                let data = [{
                    path: 'FinancialDocumentsDetail',
                    id: row
                }]
                href = url + 'automaticLogin?token=' + this.getLocalStorage().token + '&data=' + JSON.stringify(data)
                window.open(href);
            },
            // 获取订单状态枚举
            GetOrderTypeEnumList() {
                this.apipost2("CarSingle_post_GetOrderTypeEnumList", {}, (res) => {
                    if (res.data.resultCode == 1) {
                        this.OrderTypeList = res.data.data;
                        let data = {
                            Name: "不限",
                            Id: "0",
                        };
                        this.OrderTypeList.unshift(data);
                    } else {
                        this.$message.error(res.data.message);
                    }
                });
            },
            // 获取出票状态枚举
            GetTicketStatusEnumList() {
                let $this = this
                this.msg.GuestId = $this.ID
                this.apipost(
                    "/api/Order/GetTicketStatusEnumList", {},
                    (res) => {
                        if (res.data.resultCode == 1) {
                            this.ticketingStatusList = res.data.data;
                            let data = {
                                Name: '全部',
                                Id: '0'
                            }
                            this.ticketingStatusList.unshift(data)
                        } else {
                            this.$message.error(res.data.message);
                        }
                    }
                );
            },
            // 获取订单列表
            getList() {
                this.loading = true;
                this.msg.GuestId = this.ID;
                this.apipost2(
                    "CarSingle_post_GetGuestOrderStatisticsPageList",
                    this.msg,
                    (res) => {
                        if (res.data.resultCode == 1) {
                            let data = res.data.data.pageData;
                            this.dataList = data;
                            this.total = res.data.data.count;
                            this.loading = false
                        } else {
                            this.loading = false
                            this.$message.error(res.data.message);
                        }
                    }
                )
            },
            // 添加订单
            addBusiness() {
                let $this = this;
                this.MsgBus.$emit("addTicketOrderBoxOpen", $this.ID, 0, true);
            },
            handleSizeChange(val) {
                this.msg.pageSize = val;
                this.getList();
            },
            handleCurrentChange(val) {
                this.msg.pageIndex = val;
                this.getList();
            },
        },
    };
</script>