<!DOCTYPE html> 
 | 
<html lang="en"> 
 | 
  
 | 
    <head> 
 | 
        <meta charset="UTF-8"> 
 | 
        <title>任务管理</title> 
 | 
        <link rel="stylesheet" href="../static/vue/element/element.css"> 
 | 
        <script type="text/javascript" src="../static/js/jquery/jquery-3.3.1.min.js"></script> 
 | 
        <script type="text/javascript" src="../static/layui/layui.js"></script> 
 | 
        <script type="text/javascript" src="../static/js/common.js"></script> 
 | 
        <script type="text/javascript" src="../static/vue/js/vue.min.js"></script> 
 | 
        <script type="text/javascript" src="../static/vue/element/element.js"></script> 
 | 
        <style> 
 | 
            .el-table .success-row { 
 | 
                background: #b6ff8e; 
 | 
            } 
 | 
        </style> 
 | 
    </head> 
 | 
  
 | 
    <body> 
 | 
        <div id="app" style="display: flex;justify-content: center;flex-wrap: wrap;"> 
 | 
            <div style="width: 100%;"> 
 | 
                <el-card class="box-card"> 
 | 
                    <el-form :inline="true" :model="tableSearchParam" class="demo-form-inline"> 
 | 
                        <el-form-item label=""> 
 | 
                            <el-input v-model="tableSearchParam.wrk_no" placeholder="请输入工作号"></el-input> 
 | 
                        </el-form-item> 
 | 
                        <el-form-item> 
 | 
                            <el-button type="primary" @click="getTableData">查询</el-button> 
 | 
                            <el-button type="primary" @click="resetParam">重置</el-button> 
 | 
                        </el-form-item> 
 | 
                    </el-form> 
 | 
                    <el-table ref="singleTable" :data="tableData" style="width: 100%;"> 
 | 
                        <el-table-column property="wrkNo" label="工作号"> 
 | 
                        </el-table-column> 
 | 
                        <el-table-column property="wmsWrkNo" label="WMS任务号"> 
 | 
                        </el-table-column> 
 | 
                        <el-table-column property="wrkSts$" label="工作状态"> 
 | 
                        </el-table-column> 
 | 
                        <el-table-column property="ioType$" label="任务类型"> 
 | 
                        </el-table-column> 
 | 
                        <el-table-column property="ioPri" label="优先级"> 
 | 
                        </el-table-column> 
 | 
                        <el-table-column property="sourceStaNo" label="源站"> 
 | 
                        </el-table-column> 
 | 
                        <el-table-column property="staNo" label="目标站"> 
 | 
                        </el-table-column> 
 | 
                        <el-table-column property="sourceLocNo" label="源库位"> 
 | 
                        </el-table-column> 
 | 
                        <el-table-column property="locNo" label="目标库位"> 
 | 
                        </el-table-column> 
 | 
                        <el-table-column property="barcode" label="托盘码"> 
 | 
                        </el-table-column> 
 | 
                        <el-table-column property="liftNo" label="提升机"> 
 | 
                        </el-table-column> 
 | 
                        <el-table-column property="shuttleNo" label="穿梭车"> 
 | 
                        </el-table-column> 
 | 
                        <el-table-column label="操作" width="100"> 
 | 
                            <template slot-scope="scope"> 
 | 
                                <el-dropdown @command="(command)=>{handleCommand(command, scope.row)}"> 
 | 
                                    <el-button icon="el-icon-more" size="mini" type="primary"></el-button> 
 | 
                                    <el-dropdown-menu slot="dropdown"> 
 | 
<!--                                        <el-dropdown-item command="change">修改</el-dropdown-item>--> 
 | 
                                        <el-dropdown-item command="complete">完成</el-dropdown-item> 
 | 
                                        <el-dropdown-item command="cancel">取消</el-dropdown-item> 
 | 
                                        <el-dropdown-item command="shuttleCommand">穿梭车指令</el-dropdown-item> 
 | 
                                    </el-dropdown-menu> 
 | 
                                </el-dropdown> 
 | 
                            </template> 
 | 
                        </el-table-column> 
 | 
                    </el-table> 
 | 
  
 | 
                    <div style="margin-top: 10px;"> 
 | 
                        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" 
 | 
                            :current-page="currentPage" :page-sizes="pageSizes" :page-size="pageSize" 
 | 
                            layout="total, sizes, prev, pager, next, jumper" :total="pageTotal"> 
 | 
                        </el-pagination> 
 | 
                    </div> 
 | 
                </el-card> 
 | 
            </div> 
 | 
  
 | 
            <el-dialog :title="shuttleCommandTitle" :visible.sync="shuttleCommandVisible"> 
 | 
                <el-table ref="singleTable" :data="shuttleCommandData.commands" style="width: 100%;" :row-class-name="tableRowClassName"> 
 | 
                    <el-table-column property="mode$" label="命令类型"> 
 | 
                    </el-table-column> 
 | 
                    <el-table-column property="start" label="起点"> 
 | 
                        <template slot-scope="scope"> 
 | 
                            <div v-if="scope.row.nodes"> 
 | 
                                x:{{ scope.row.nodes[0].x }} 
 | 
                                y:{{ scope.row.nodes[0].y }} 
 | 
                                z:{{ scope.row.nodes[0].z }} 
 | 
                            </div> 
 | 
                        </template> 
 | 
                    </el-table-column> 
 | 
                    <el-table-column property="target" label="终点"> 
 | 
                        <template slot-scope="scope"> 
 | 
                            <div v-if="scope.row.nodes"> 
 | 
                                x:{{ scope.row.nodes[scope.row.nodes.length-1].x }} 
 | 
                                y:{{ scope.row.nodes[scope.row.nodes.length-1].y }} 
 | 
                                z:{{ scope.row.nodes[scope.row.nodes.length-1].z }} 
 | 
                            </div> 
 | 
                        </template> 
 | 
                    </el-table-column> 
 | 
                    <el-table-column property="taskNo" label="任务号"> 
 | 
                    </el-table-column> 
 | 
                    <el-table-column property="shuttleNo" label="穿梭车"> 
 | 
                    </el-table-column> 
 | 
                    <el-table-column property="complete" label="是否完成"> 
 | 
                        <template slot-scope="scope"> 
 | 
                            <el-switch 
 | 
                                    v-model="scope.row.complete" 
 | 
                                    active-color="#13ce66" 
 | 
                                    @change="changeComplete(scope)"> 
 | 
                            </el-switch> 
 | 
                        </template> 
 | 
                    </el-table-column> 
 | 
                    <el-table-column label="操作" width="100"> 
 | 
                        <template slot-scope="scope"> 
 | 
                            <el-button @click="shuttleCommandRollback(scope)" size="mini">回退指令</el-button> 
 | 
                        </template> 
 | 
                    </el-table-column> 
 | 
                </el-table> 
 | 
                <div slot="footer" class="dialog-footer"> 
 | 
                    <el-button @click="shuttleCommandVisible = false">关闭</el-button> 
 | 
                </div> 
 | 
            </el-dialog> 
 | 
  
 | 
        </div> 
 | 
        <script> 
 | 
            var $layui = layui.config({ 
 | 
                base: baseUrl + "/static/wms/layui/lay/modules/" 
 | 
            }).use(['layer', 'form'], function() {}) 
 | 
  
 | 
            var app = new Vue({ 
 | 
                el: '#app', 
 | 
                data: { 
 | 
                    tableData: [], 
 | 
                    currentPage: 1, 
 | 
                    pageSizes: [16, 30, 50, 100, 150, 200], 
 | 
                    pageSize: 30, 
 | 
                    pageTotal: 0, 
 | 
                    tableSearchParam: { 
 | 
                        wrk_no: null, 
 | 
                    }, 
 | 
                    shuttleCommandVisible: false, 
 | 
                    shuttleCommandData: { 
 | 
                        assignCommand: { 
 | 
                            commands: [] 
 | 
                        }, 
 | 
                        commandStep: 0 
 | 
                    }, 
 | 
                    shuttleCommandWrkNo: null, 
 | 
                    shuttleCommandLabelWidth: '80px', 
 | 
                    shuttleCommandTitle: '' 
 | 
                }, 
 | 
                created() { 
 | 
                    this.init() 
 | 
                }, 
 | 
                methods: { 
 | 
                    init() { 
 | 
                        this.getTableData() 
 | 
                    }, 
 | 
                    getTableData() { 
 | 
                        let that = this; 
 | 
                        let data = JSON.parse(JSON.stringify(this.tableSearchParam)) 
 | 
                        data.curr = this.currentPage 
 | 
                        data.limit = this.pageSize 
 | 
                        if (this.tableSearchParam.datetime != null) { 
 | 
                            data.datetime = null 
 | 
                            data.create_time = this.tableSearchParam.datetime[0] + " - " + this.tableSearchParam.datetime[1] 
 | 
                        } 
 | 
                        $.ajax({ 
 | 
                            url: baseUrl + "/wrkMast/list/auth", 
 | 
                            headers: { 
 | 
                                'token': localStorage.getItem('token') 
 | 
                            }, 
 | 
                            data: data, 
 | 
                            dataType: 'json', 
 | 
                            contentType: 'application/json;charset=UTF-8', 
 | 
                            method: 'GET', 
 | 
                            success: function(res) { 
 | 
                                if (res.code == 200) { 
 | 
                                    that.tableData = res.data.records 
 | 
                                    that.pageTotal = res.data.total 
 | 
                                } else if (res.code === 403) { 
 | 
                                    top.location.href = baseUrl + "/"; 
 | 
                                } else { 
 | 
                                    that.$message({ 
 | 
                                        message: res.msg, 
 | 
                                        type: 'error' 
 | 
                                    }); 
 | 
                                } 
 | 
                            } 
 | 
                        }); 
 | 
                    }, 
 | 
                    handleSizeChange(val) { 
 | 
                        console.log(`每页 ${val} 条`); 
 | 
                        this.pageSize = val 
 | 
                        this.getTableData() 
 | 
                    }, 
 | 
                    handleCurrentChange(val) { 
 | 
                        console.log(`当前页: ${val}`); 
 | 
                        this.currentPage = val 
 | 
                        this.getTableData() 
 | 
                    }, 
 | 
                    resetParam() { 
 | 
                        this.tableSearchParam = { 
 | 
                            task_no: null, 
 | 
                            status: null, 
 | 
                            wrk_no: null 
 | 
                        } 
 | 
                        this.getTableData() 
 | 
                    }, 
 | 
                    handleCommand(command, row) { 
 | 
                        switch (command) { 
 | 
                            case "complete": 
 | 
                                this.completeTask(row) 
 | 
                                break; 
 | 
                            case "cancel": 
 | 
                                this.cancelTask(row) 
 | 
                                break; 
 | 
                            case "shuttleCommand": 
 | 
                                this.showShuttleCommand(row.wrkNo) 
 | 
                                break; 
 | 
                        } 
 | 
                    }, 
 | 
                    showShuttleCommand(wrkNo){ 
 | 
                        let that = this; 
 | 
                        $.ajax({ 
 | 
                            url: baseUrl + "/shuttle/command/query", 
 | 
                            headers: { 
 | 
                                'token': localStorage.getItem('token') 
 | 
                            }, 
 | 
                            data: { 
 | 
                                wrkNo: wrkNo 
 | 
                            }, 
 | 
                            method: 'GET', 
 | 
                            success: function(res) { 
 | 
                                if (res.code == 200) { 
 | 
                                    console.log(res) 
 | 
                                    that.shuttleCommandVisible = true; 
 | 
                                    that.shuttleCommandData = res.data; 
 | 
                                    that.shuttleCommandWrkNo = wrkNo; 
 | 
                                } else if (res.code === 403) { 
 | 
                                    top.location.href = baseUrl + "/"; 
 | 
                                } else { 
 | 
                                    that.$message({ 
 | 
                                        message: res.msg, 
 | 
                                        type: 'error' 
 | 
                                    }); 
 | 
                                } 
 | 
                            } 
 | 
                        }); 
 | 
                    }, 
 | 
                    completeTask(row) { 
 | 
                        let that = this 
 | 
                        this.$confirm('确定完成该任务吗?', '提示', { 
 | 
                            confirmButtonText: '确定', 
 | 
                            cancelButtonText: '取消', 
 | 
                            type: 'warning' 
 | 
                        }).then(() => { 
 | 
                            $.ajax({ 
 | 
                                url: baseUrl + "/openapi/completeTask", 
 | 
                                contentType: 'application/json', 
 | 
                                headers: { 
 | 
                                    'token': localStorage.getItem('token') 
 | 
                                }, 
 | 
                                data: JSON.stringify({ 
 | 
                                    wrkNo: row.wrkNo, 
 | 
                                }), 
 | 
                                method: 'POST', 
 | 
                                success: function(res) { 
 | 
                                    if (res.code == 200) { 
 | 
                                        that.$message({ 
 | 
                                            message: "完成成功", 
 | 
                                            type: 'success' 
 | 
                                        }); 
 | 
                                        that.getTableData() 
 | 
                                    } else if (res.code === 403) { 
 | 
                                        top.location.href = baseUrl + "/"; 
 | 
                                    } else { 
 | 
                                        that.$message({ 
 | 
                                            message: res.msg, 
 | 
                                            type: 'error' 
 | 
                                        }); 
 | 
                                    } 
 | 
                                } 
 | 
                            }); 
 | 
                        }).catch(() => { 
 | 
                            // this.$message({ 
 | 
                            //     type: 'info', 
 | 
                            //     message: '已取消删除' 
 | 
                            // }); 
 | 
                        }); 
 | 
                    }, 
 | 
                    cancelTask(row) { 
 | 
                        let that = this 
 | 
                        this.$confirm('确定取消该任务吗?', '提示', { 
 | 
                            confirmButtonText: '确定', 
 | 
                            cancelButtonText: '取消', 
 | 
                            type: 'warning' 
 | 
                        }).then(() => { 
 | 
                            $.ajax({ 
 | 
                                url: baseUrl + "/openapi/cancelTask", 
 | 
                                contentType: 'application/json', 
 | 
                                headers: { 
 | 
                                    'token': localStorage.getItem('token') 
 | 
                                }, 
 | 
                                data: JSON.stringify({ 
 | 
                                    wrkNo: row.wrkNo, 
 | 
                                }), 
 | 
                                method: 'POST', 
 | 
                                success: function(res) { 
 | 
                                    if (res.code == 200) { 
 | 
                                        that.$message({ 
 | 
                                            message: "取消成功", 
 | 
                                            type: 'success' 
 | 
                                        }); 
 | 
                                        that.getTableData() 
 | 
                                    } else if (res.code === 403) { 
 | 
                                        top.location.href = baseUrl + "/"; 
 | 
                                    } else { 
 | 
                                        that.$message({ 
 | 
                                            message: res.msg, 
 | 
                                            type: 'error' 
 | 
                                        }); 
 | 
                                    } 
 | 
                                } 
 | 
                            }); 
 | 
                        }).catch(() => { 
 | 
                            // this.$message({ 
 | 
                            //     type: 'info', 
 | 
                            //     message: '已取消删除' 
 | 
                            // }); 
 | 
                        }); 
 | 
                    }, 
 | 
                    tableRowClassName({row, rowIndex}) { 
 | 
                        if (rowIndex === this.shuttleCommandData.commandStep) { 
 | 
                            return 'success-row'; 
 | 
                        } 
 | 
                        return ''; 
 | 
                    }, 
 | 
                    shuttleCommandRollback(scope) { 
 | 
                        let that = this; 
 | 
                        let idx = scope.$index; 
 | 
                        $.ajax({ 
 | 
                            url: baseUrl + "/shuttle/command/rollback", 
 | 
                            headers: { 
 | 
                                'token': localStorage.getItem('token') 
 | 
                            }, 
 | 
                            data: { 
 | 
                                wrkNo: that.shuttleCommandWrkNo, 
 | 
                                commandStep: idx 
 | 
                            }, 
 | 
                            method: 'GET', 
 | 
                            success: function(res) { 
 | 
                                if (res.code == 200) { 
 | 
                                    that.showShuttleCommand(that.shuttleCommandWrkNo) 
 | 
                                } else if (res.code === 403) { 
 | 
                                    top.location.href = baseUrl + "/"; 
 | 
                                } else { 
 | 
                                    that.$message({ 
 | 
                                        message: res.msg, 
 | 
                                        type: 'error' 
 | 
                                    }); 
 | 
                                } 
 | 
                            } 
 | 
                        }); 
 | 
                    }, 
 | 
                    changeComplete(scope) { 
 | 
                        let that = this; 
 | 
                        let idx = scope.$index; 
 | 
                        $.ajax({ 
 | 
                            url: baseUrl + "/shuttle/command/completeSwitch", 
 | 
                            headers: { 
 | 
                                'token': localStorage.getItem('token') 
 | 
                            }, 
 | 
                            data: { 
 | 
                                wrkNo: that.shuttleCommandWrkNo, 
 | 
                                commandStep: idx, 
 | 
                                complete: scope.row.complete ? 1 : 0 
 | 
                            }, 
 | 
                            method: 'GET', 
 | 
                            success: function(res) { 
 | 
                                if (res.code == 200) { 
 | 
                                    that.showShuttleCommand(that.shuttleCommandWrkNo) 
 | 
                                } else if (res.code === 403) { 
 | 
                                    top.location.href = baseUrl + "/"; 
 | 
                                } else { 
 | 
                                    that.$message({ 
 | 
                                        message: res.msg, 
 | 
                                        type: 'error' 
 | 
                                    }); 
 | 
                                } 
 | 
                            } 
 | 
                        }); 
 | 
                    } 
 | 
                }, 
 | 
            }) 
 | 
        </script> 
 | 
    </body> 
 | 
  
 | 
</html> 
 |