Compare commits

..

3 Commits

7 changed files with 647 additions and 480 deletions

View File

@ -188,6 +188,15 @@ const downloadWorkSummaryExcel = (data) => {
timeout: 600000 timeout: 600000
}) })
} }
const downloadWorkFlowExcel = (data) => {
return request({
url: '/excel/downloadWorkFlowExcel',
method: 'post',
responseType: 'blob',
data: data,
timeout: 600000
})
}
export { export {
uploadExcelStock, uploadExcelStock,
@ -209,5 +218,6 @@ export {
uploadExcelBaseGoods, uploadExcelBaseGoods,
uploadExcelKanban, uploadExcelKanban,
uploadWorkFlow, uploadWorkFlow,
uploadExcelWorkDate uploadExcelWorkDate,
downloadWorkFlowExcel
} }

View File

@ -68,36 +68,36 @@
<el-row :gutter="16"> <el-row :gutter="16">
<el-col :span="12" :offset="0"> <el-col :span="12" :offset="0">
<el-form-item label="小盒子" prop="smallBox"> <el-form-item label="小盒子" prop="smallBox">
<el-input v-model="configFormEntity.smallBox" disabled /> <el-input v-model="configFormEntity.smallBox" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="机型" prop="model"> <el-form-item label="机型" prop="model">
<el-input v-model="configFormEntity.model" disabled /> <el-input v-model="configFormEntity.model" />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="16"> <el-row :gutter="16">
<el-col :span="12" :offset="0"> <el-col :span="12" :offset="0">
<el-form-item label="工位" prop="workCenter"> <el-form-item label="工位" prop="workCenter">
<el-input v-model="configFormEntity.workCenter" disabled /> <el-input v-model="configFormEntity.workCenter" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="工位大盒子" prop="bigBox"> <el-form-item label="工位大盒子" prop="bigBox">
<el-input v-model="configFormEntity.bigBox" disabled /> <el-input v-model="configFormEntity.bigBox" />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="16"> <el-row :gutter="16">
<el-col :span="12" :offset="0"> <el-col :span="12" :offset="0">
<el-form-item label="车辆" prop="vehicle"> <el-form-item label="车辆" prop="vehicle">
<el-input v-model="configFormEntity.vehicle" disabled /> <el-input v-model="configFormEntity.vehicle" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="线边架/车位置" prop="vehicleLocation"> <el-form-item label="线边架/车位置" prop="vehicleLocation">
<el-input v-model="configFormEntity.vehicleLocation" disabled /> <el-input v-model="configFormEntity.vehicleLocation" />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>

View File

@ -20,6 +20,8 @@
:suffix-icon="Search" /> :suffix-icon="Search" />
<el-select-v2 v-model="goodsTypeQuery" style="width: 158px; margin-right: 10px;" placeholder="物料类型" <el-select-v2 v-model="goodsTypeQuery" style="width: 158px; margin-right: 10px;" placeholder="物料类型"
:options="goodsTypeOptions" @change="search()"></el-select-v2> :options="goodsTypeOptions" @change="search()"></el-select-v2>
<el-select-v2 v-model="stockStatusQuery" style="width: 158px; margin-right: 10px;" placeholder="库存状态"
:options="stockStatusSearchOptions" @change="search()"></el-select-v2>
<el-date-picker v-model="createTimeQuery" type="date" placeholder="选择上架日期" :shortcuts="shortcuts" <el-date-picker v-model="createTimeQuery" type="date" placeholder="选择上架日期" :shortcuts="shortcuts"
style="width: 158px; margin-right: 10px;" clearable /> style="width: 158px; margin-right: 10px;" clearable />
<el-button type="primary" @click="search()">搜索</el-button> <el-button type="primary" @click="search()">搜索</el-button>
@ -222,6 +224,7 @@ export default {
vehicleIdQuery: '', vehicleIdQuery: '',
locationIdQuery: '', locationIdQuery: '',
goodsTypeQuery: '', goodsTypeQuery: '',
stockStatusQuery: -99,
createTimeQuery: null, createTimeQuery: null,
shortcuts: [ shortcuts: [
{ {
@ -296,6 +299,40 @@ export default {
label: '库存锁定' label: '库存锁定'
} }
], ],
stockStatusSearchOptions: [
{
value: -99,
label: '全部'
},
{
value: 0,
label: '库存正常'
},
{
value: 1,
label: '出库中'
},
{
value: 2,
label: '盘点中'
},
{
value: 3,
label: '移库中'
},
{
value: 4,
label: '拣选中'
},
{
value: 5,
label: '回库中'
},
{
value: 9,
label: '库存锁定'
}
],
goodsList: [], goodsList: [],
goodsTypeOptions: [ goodsTypeOptions: [
{ {
@ -427,6 +464,7 @@ export default {
vehicleId: this.vehicleIdQuery.trim(), vehicleId: this.vehicleIdQuery.trim(),
locationId: this.locationIdQuery.trim(), locationId: this.locationIdQuery.trim(),
goodsType: this.goodsTypeQuery.trim(), goodsType: this.goodsTypeQuery.trim(),
stockStatus: this.stockStatusQuery == -99 ? null : this.stockStatusQuery,
createTime: timeFormatter(this.createTimeQuery), createTime: timeFormatter(this.createTimeQuery),
userName: store.getters.getUserName userName: store.getters.getUserName
} }
@ -448,6 +486,8 @@ export default {
this.goodsIdQuery = '' this.goodsIdQuery = ''
this.vehicleIdQuery = '' this.vehicleIdQuery = ''
this.locationIdQuery = '' this.locationIdQuery = ''
this.goodsTypeQuery = ''
this.stockStatusQuery = -99
this.createTimeQuery = null this.createTimeQuery = null
this.search() this.search()
}, },
@ -461,6 +501,7 @@ export default {
vehicleId: this.vehicleIdQuery.trim(), vehicleId: this.vehicleIdQuery.trim(),
locationId: this.locationIdQuery.trim(), locationId: this.locationIdQuery.trim(),
goodsType: this.goodsTypeQuery.trim(), goodsType: this.goodsTypeQuery.trim(),
stockStatus: this.stockStatusQuery == -99 ? null : this.stockStatusQuery,
createTime: timeFormatter(this.createTimeQuery), createTime: timeFormatter(this.createTimeQuery),
userName: store.getters.getUserName userName: store.getters.getUserName
} }

View File

@ -1,379 +1,388 @@
<template> <template>
<div style="margin-bottom: 10px"> <div style="margin-bottom: 10px">
<el-config-provider :locale="zhCn"> <el-config-provider :locale="zhCn">
<el-row> <el-row>
<el-input v-model="goodsIdQuery" style="width: 196px; margin-right: 10px;" placeholder="料号" /> <el-input v-model="goodsIdQuery" style="width: 196px; margin-right: 10px;" placeholder="料号"/>
<el-input v-model="vehicleIdQuery" style="width: 196px; margin-right: 10px;" placeholder="箱号" /> <el-input v-model="vehicleIdQuery" style="width: 196px; margin-right: 10px;" placeholder="箱号"/>
<el-select-v2 v-model="taskTypeQuery" style="width: 196px; margin-right: 10px;" placeholder="请选择任务类型" <el-select-v2 v-model="taskTypeQuery" style="width: 196px; margin-right: 10px;" placeholder="请选择任务类型"
:options="taskTypeOptions" @change="search()"></el-select-v2> :options="taskTypeOptions" @change="search()"></el-select-v2>
<el-select-v2 v-model="taskStatusQuery" style="width: 196px; margin-right: 10px;" placeholder="请选择任务状态" <el-select-v2 v-model="taskStatusQuery" style="width: 196px; margin-right: 10px;" placeholder="请选择任务状态"
:options="taskStatusOptions" @change="search()"></el-select-v2> :options="taskStatusOptions" @change="search()"></el-select-v2>
<el-button type="primary" @click="search()">搜索</el-button> <el-button type="primary" @click="search()">搜索</el-button>
<el-button type="warning" @click="reset()">重置</el-button> <el-button type="warning" @click="reset()">重置</el-button>
</el-row> </el-row>
<br /> <br/>
<el-table :data="tasks" stripe border v-loading="loading" style="width: 100%" max-height="684px" <el-table :data="tasks" stripe border v-loading="loading" style="width: 100%" max-height="684px"
class="table-class" :header-cell-style="{ 'text-align': 'center' }" :cell-style="{ 'text-align': 'center' }" class="table-class" :header-cell-style="{ 'text-align': 'center' }"
:cell-style="{ 'text-align': 'center' }"
@row-click="getCurrentRow"> @row-click="getCurrentRow">
<el-table-column width="65px" fixed="left"> <el-table-column width="65px" fixed="left">
<template v-slot="scope"> <template v-slot="scope">
<el-radio :label="scope.row.taskId" v-model="taskId">&nbsp;</el-radio> <el-radio :label="scope.row.taskId" v-model="taskId">&nbsp;</el-radio>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="taskId" label="任务号" fixed="left" show-overflow-tooltip min-width="120px" /> <el-table-column prop="taskId" label="任务号" fixed="left" show-overflow-tooltip min-width="120px"/>
<el-table-column prop="taskType" label="任务类型" fixed="left" :formatter="taskTypeFormat" min-width="120px" /> <el-table-column prop="taskType" label="任务类型" fixed="left" :formatter="taskTypeFormat" min-width="120px"/>
<el-table-column prop="vehicleId" label="箱号" min-width="120px" show-overflow-tooltip /> <el-table-column prop="vehicleId" label="箱号" min-width="120px" show-overflow-tooltip/>
<el-table-column prop="goodsRelated.goodsId" label="料号" min-width="120px" show-overflow-tooltip /> <el-table-column prop="goodsRelated.goodsId" label="料号" min-width="120px" show-overflow-tooltip/>
<el-table-column prop="goodsRelated.goodsName" label="料名" min-width="120px" show-overflow-tooltip /> <el-table-column prop="goodsRelated.goodsName" label="料名" min-width="120px" show-overflow-tooltip/>
<el-table-column prop="taskGroup" label="任务组" min-width="120px" show-overflow-tooltip /> <el-table-column prop="taskGroup" label="任务组" min-width="120px" show-overflow-tooltip/>
<el-table-column prop="origin" label="起点" min-width="120px" /> <el-table-column prop="origin" label="起点" min-width="120px"/>
<el-table-column prop="destination" label="终点" min-width="120px" /> <el-table-column prop="destination" label="终点" min-width="120px"/>
<el-table-column prop="goodsRelated.opNum" label="操作数量" min-width="120px" /> <el-table-column prop="goodsRelated.opNum" label="操作数量" min-width="120px"/>
<el-table-column prop="goodsRelated.originNum" label="库存数量" min-width="120px" /> <el-table-column prop="goodsRelated.originNum" label="库存数量" min-width="120px"/>
<el-table-column prop="taskPriority" label="任务优先级" min-width="120px" /> <el-table-column prop="taskPriority" label="任务优先级" min-width="120px"/>
<el-table-column prop="preTask" label="前置任务" min-width="120px" show-overflow-tooltip /> <el-table-column prop="preTask" label="前置任务" min-width="120px" show-overflow-tooltip/>
<el-table-column prop="createTime" label="创建时间" :formatter="timeFormat" min-width="120px" show-overflow-tooltip /> <el-table-column prop="pickStand" label="下发站台" min-width="120px" show-overflow-tooltip/>
<el-table-column prop="createTime" label="运行时长" :formatter="dueFormat" min-width="120px" show-overflow-tooltip /> <el-table-column prop="createTime" label="创建时间" :formatter="timeFormat" min-width="120px"
<el-table-column prop="userName" label="操作人员姓名" min-width="120px" /> show-overflow-tooltip/>
<el-table-column prop="taskStatus" label="任务状态" fixed="right" :formatter="taskStatusFormat" <el-table-column prop="createTime" label="运行时长" :formatter="dueFormat" min-width="120px"
min-width="120px" show-overflow-tooltip /> show-overflow-tooltip/>
<el-table-column fixed="right" label="操作" width="120px"> <el-table-column prop="userName" label="操作人员姓名" min-width="120px"/>
<template v-slot="scope"> <el-table-column prop="taskStatus" label="任务状态" fixed="right" :formatter="taskStatusFormat"
<el-button plain type="primary" @click="editCurrentRowTask(scope.row)">编辑</el-button> min-width="120px" show-overflow-tooltip/>
</template> <el-table-column fixed="right" label="操作" width="120px">
</el-table-column> <template v-slot="scope">
</el-table> <el-button plain type="primary" @click="editCurrentRowTask(scope.row)">编辑</el-button>
<br /> </template>
<el-pagination v-model:current-page="currentPage" v-model:page-size="pageSize" :page-sizes="[10, 25, 50]" </el-table-column>
:small="false" :disabled="false" :background="false" :default-page-size="10" </el-table>
layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="search" <br/>
@current-change="search" /> <el-pagination v-model:current-page="currentPage" v-model:page-size="pageSize" :page-sizes="[10, 25, 50]"
<el-dialog v-model="dialogVisible" title="任务信息" width="40%" draggable :show-close="false"> :small="false" :disabled="false" :background="false" :default-page-size="10"
<el-form ref="taskFormRef" :model="taskFormEntity" :label-position="labelPosition" label-width="100px" layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="search"
style="max-width: 100%" :rules="rules" status-icon> @current-change="search"/>
<el-row :gutter="16"> <el-dialog v-model="dialogVisible" title="任务信息" width="40%" draggable :show-close="false">
<el-col :span="12" :offset="0"> <el-form ref="taskFormRef" :model="taskFormEntity" :label-position="labelPosition" label-width="100px"
<el-form-item label="任务号" prop="taskId"> style="max-width: 100%" :rules="rules" status-icon>
<el-input v-model="taskFormEntity.taskId" disabled /> <el-row :gutter="16">
</el-form-item> <el-col :span="12" :offset="0">
</el-col> <el-form-item label="任务号" prop="taskId">
<el-col :span="12"> <el-input v-model="taskFormEntity.taskId" disabled/>
<el-form-item label="任务优先级" prop="taskPriority"> </el-form-item>
<el-input-number v-model.number="taskFormEntity.taskPriority" controls-position="right" </el-col>
:min="1" :max="9" disabled /> <el-col :span="12">
</el-form-item> <el-form-item label="任务优先级" prop="taskPriority">
</el-col> <el-input-number v-model.number="taskFormEntity.taskPriority" controls-position="right"
</el-row> :min="1" :max="9" disabled/>
<el-row :gutter="16"> </el-form-item>
<el-col :span="12" :offset="0"> </el-col>
<el-form-item label="料箱号" prop="vehicleId"> </el-row>
<el-input v-model="taskFormEntity.vehicleId" disabled /> <el-row :gutter="16">
</el-form-item> <el-col :span="12" :offset="0">
</el-col> <el-form-item label="料箱号" prop="vehicleId">
<el-col :span="12"> <el-input v-model="taskFormEntity.vehicleId" disabled/>
<el-form-item label="料号" prop="goodsId"> </el-form-item>
<el-input v-model="taskFormEntity.goodsId" disabled /> </el-col>
</el-form-item> <el-col :span="12">
</el-col> <el-form-item label="料号" prop="goodsId">
</el-row> <el-input v-model="taskFormEntity.goodsId" disabled/>
<el-row :gutter="16"> </el-form-item>
<el-col :span="12" :offset="0"> </el-col>
<el-form-item label="起点" prop="origin"> </el-row>
<el-input v-model="taskFormEntity.origin" disabled /> <el-row :gutter="16">
</el-form-item> <el-col :span="12" :offset="0">
</el-col> <el-form-item label="起点" prop="origin">
<!-- <el-col :span="12" v-if="taskFormEntity.taskType == 1"> <el-input v-model="taskFormEntity.origin" disabled/>
<el-form-item label="终点" prop="destination"> </el-form-item>
<el-select-v2 v-model="taskFormEntity.destination" </el-col>
:options="availableLocationOptions"></el-select-v2> <!-- <el-col :span="12" v-if="taskFormEntity.taskType == 1">
</el-form-item> <el-form-item label="终点" prop="destination">
</el-col> <el-select-v2 v-model="taskFormEntity.destination"
<el-col :span="12" v-if="taskFormEntity.taskType == 2"> :options="availableLocationOptions"></el-select-v2>
<el-form-item label="终点" prop="destination"> </el-form-item>
<el-input v-model="taskFormEntity.destination" disabled /> </el-col>
</el-form-item> <el-col :span="12" v-if="taskFormEntity.taskType == 2">
</el-col> --> <el-form-item label="终点" prop="destination">
<el-col :span="12"> <el-input v-model="taskFormEntity.destination" disabled />
<el-form-item label="终点" prop="destination"> </el-form-item>
<el-input v-model="taskFormEntity.destination" disabled /> </el-col> -->
</el-form-item> <el-col :span="12">
</el-col> <el-form-item label="终点" prop="destination">
</el-row> <el-input v-model="taskFormEntity.destination" disabled/>
<el-row :gutter="16"> </el-form-item>
<el-col :span="12" :offset="0"> </el-col>
<el-form-item label="任务类型" prop="taskType"> </el-row>
<el-select-v2 v-model="taskFormEntity.taskType" placeholder="请选择任务类型" disabled <el-row :gutter="16">
:options="taskTypeOptions"></el-select-v2> <el-col :span="12" :offset="0">
</el-form-item> <el-form-item label="任务类型" prop="taskType">
</el-col> <el-select-v2 v-model="taskFormEntity.taskType" placeholder="请选择任务类型" disabled
<el-col :span="12"> :options="taskTypeOptions"></el-select-v2>
<el-form-item label="任务状态" prop="taskStatus"> </el-form-item>
<el-select-v2 v-model="taskFormEntity.taskStatus" placeholder="请选择任务状态" </el-col>
:options="taskStatusOptions"></el-select-v2> <el-col :span="12">
</el-form-item> <el-form-item label="任务状态" prop="taskStatus">
</el-col> <el-select-v2 v-model="taskFormEntity.taskStatus" placeholder="请选择任务状态"
</el-row> :options="taskStatusOptions"></el-select-v2>
</el-form> </el-form-item>
<template #footer> </el-col>
</el-row>
</el-form>
<template #footer>
<span class="dialog-footer"> <span class="dialog-footer">
<el-button @click="dialogVisible = false">取消</el-button> <el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="submitTaskInfo(taskFormEntity)"> <el-button type="primary" @click="submitTaskInfo(taskFormEntity)">
确定 确定
</el-button> </el-button>
</span> </span>
</template> </template>
</el-dialog> </el-dialog>
</el-config-provider> </el-config-provider>
</div> </div>
</template> </template>
<script setup> <script setup>
import { getTasksByPage, updateTaskInfo } from '@/api/task.js' import {getTasksByPage, updateTaskInfo} from '@/api/task.js'
import { dateFormatter, taskStatusFormatter, timeFormatter, dueFormatter } from '@/utils/formatter.js' import {dateFormatter, taskStatusFormatter, timeFormatter, dueFormatter} from '@/utils/formatter.js'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs' import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import { errorBox } from '@/utils/myMessageBox.js' import {errorBox} from '@/utils/myMessageBox.js'
import { ElMessage } from 'element-plus' import {ElMessage} from 'element-plus'
import store from '@/store' import store from '@/store'
import { ref, reactive } from 'vue' import {ref, reactive} from 'vue'
</script> </script>
<script> <script>
export default { export default {
name: 'taskMonitor', name: 'taskMonitor',
data() { data() {
return { return {
tasks: [], tasks: [],
currentPage: 1, currentPage: 1,
pageSize: 10, pageSize: 10,
total: 0, total: 0,
goodsIdQuery: '', goodsIdQuery: '',
vehicleIdQuery: '', vehicleIdQuery: '',
taskTypeQuery: -99, taskTypeQuery: -99,
taskStatusQuery: -99, taskStatusQuery: -99,
loading: true, loading: true,
dialogVisible: false, dialogVisible: false,
taskFormEntity: reactive({}), taskFormEntity: reactive({}),
labelPosition: 'top', labelPosition: 'top',
taskFormRef: ref(), taskFormRef: ref(),
rules: reactive({}), rules: reactive({}),
taskId: '', taskId: '',
taskTypeOptions: [ taskTypeOptions: [
{ {
value: -99, value: -99,
label: '所有类型' label: '所有类型'
}, },
{ {
value: 1, value: 1,
label: '入库' label: '入库'
}, },
{ {
value: 2, value: 2,
label: '出库' label: '出库'
}, },
{ {
value: 3, value: 3,
label: '盘点' label: '盘点'
}, },
{ {
value: 9, value: 9,
label: '移库' label: '移库'
}, },
], ],
taskStatusOptions: [ taskStatusOptions: [
{ {
value: -99, value: -99,
label: '所有状态' label: '所有状态'
}, },
{ {
value: -2, value: -2,
label: '重复入库' label: '重复入库'
}, },
{ {
value: -1, value: -1,
label: '暂存' label: '暂存'
}, },
{ {
value: 0, value: 0,
label: '新建待下发' label: '新建待下发'
}, },
{ {
value: 1, value: 1,
label: '已下发' label: '已下发'
}, },
{ {
value: 2, value: 2,
label: '开始执行' label: '开始执行'
}, },
{ {
value: 8, value: 8,
label: '拣选中' label: '拣选中'
}, },
{ {
value: 9, value: 9,
label: '盘点中' label: '盘点中'
}, },
{ {
value: 100, value: 100,
label: '任务完成' label: '任务完成'
}, },
{ {
value: 998, value: 998,
label: '任务取消' label: '任务取消'
}, },
{ {
value: 999, value: 999,
label: '任务异常' label: '任务异常'
}
],
availableLocationOptions: []
} }
],
availableLocationOptions: []
}
},
mounted() {
this.search()
},
methods: {
dateFormat: (row, column, cellValue, index) => {
return dateFormatter(cellValue)
}, },
mounted() { timeFormat: (row, column, cellValue, index) => {
this.search() return timeFormatter(cellValue)
}, },
methods: { taskStatusFormat: (row, column, cellValue, index) => {
dateFormat: (row, column, cellValue, index) => { return taskStatusFormatter(cellValue)
return dateFormatter(cellValue) },
}, taskTypeFormat: (row, column, cellValue, index) => {
timeFormat: (row, column, cellValue, index) => { switch (cellValue) {
return timeFormatter(cellValue) case 1:
}, return '入库'
taskStatusFormat: (row, column, cellValue, index) => { case 2:
return taskStatusFormatter(cellValue) return '出库'
}, case 3:
taskTypeFormat: (row, column, cellValue, index) => { return '盘点'
switch (cellValue) { case 9:
case 1: return '入库' return '移库'
case 2: return '出库' default:
case 3: return '盘点' return '未知'
case 9: return '移库' }
default: return '未知' },
} dueFormat: (row, column, cellValue, index) => {
}, return dueFormatter(cellValue)
dueFormat: (row, column, cellValue, index) => { },
return dueFormatter(cellValue) search() {
}, this.loading = true
search() { const tableRequest = {
this.loading = true pageNo: this.currentPage,
const tableRequest = { pageSize: this.pageSize,
pageNo: this.currentPage, taskType: this.taskTypeQuery == -99 ? null : this.taskTypeQuery,
pageSize: this.pageSize, taskStatus: this.taskStatusQuery == -99 ? null : this.taskStatusQuery,
taskType: this.taskTypeQuery == -99 ? null : this.taskTypeQuery, goodsId: this.goodsIdQuery.trim(),
taskStatus: this.taskStatusQuery == -99 ? null : this.taskStatusQuery, vehicleId: this.vehicleIdQuery.trim(),
goodsId: this.goodsIdQuery.trim(), userName: store.getters.getUserName
vehicleId: this.vehicleIdQuery.trim(), }
userName: store.getters.getUserName getTasksByPage(tableRequest).then(res => {
} const tableResponse = res.data
getTasksByPage(tableRequest).then(res => { if (tableResponse.code == 0) {
const tableResponse = res.data this.tasks = tableResponse.returnData.lists
if (tableResponse.code == 0) { this.total = tableResponse.returnData.total
this.tasks = tableResponse.returnData.lists console.log(this.tasks)
this.total = tableResponse.returnData.total } else {
console.log(this.tasks) errorBox(tableResponse.message)
} else {
errorBox(tableResponse.message)
}
}).catch(err => {
console.log(err)
errorBox('查询任务错误')
})
this.loading = false
},
reset() {
this.goodsIdQuery = ''
this.vehicleIdQuery = ''
},
editCurrentRowTask(row) {
console.log(row)
// if (row.taskType == 1) {
// this.availableLocationOptions = []
// var currentOption = {
// value: row.destination,
// label: locationFormatter(row.destination)
// }
// this.availableLocationOptions.push(currentOption)
// //
// const requestParam = {
// areaId: 1
// }
// getAvailableLocations(requestParam).then(res => {
// if (res.data.code == 0) {
// for (const location of res.data.returnData) {
// var newOption = {}
// newOption.value = location.locationId
// newOption.label = locationFormatter(location.locationId)
// this.availableLocationOptions.push(newOption)
// }
// }
// }).catch(err => {
// errorBox(':' + err)
// })
// }
this.taskFormEntity = {
taskId: row.taskId,
taskPriority: row.taskPriority,
vehicleId: row.vehicleId,
goodsId: row.goodsRelated == null ? '' : row.goodsRelated.goodsId,
origin: row.origin,
destination: row.destination,
taskType: row.taskType,
taskStatus: row.taskStatus,
}
this.dialogVisible = true
},
submitTaskInfo() {
if (this.taskFormEntity.taskStatus == null || this.taskFormEntity.taskStatus == undefined) {
errorBox('请选择任务状态')
return
}
const request = {
taskId: this.taskFormEntity.taskId,
taskStatus: this.taskFormEntity.taskStatus,
userName: store.getters.getUserName
}
updateTaskInfo(request).then(res => {
if (res.data.code == 0) {
this.dialogVisible = false
ElMessage.success('修改任务成功')
this.search()
} else {
errorBox(res.data.message)
}
}).catch(err => {
console.log(err)
errorBox('修改任务失败')
})
},
getCurrentRow(row) {
this.taskId = row.taskId
} }
}).catch(err => {
console.log(err)
errorBox('查询任务错误')
})
this.loading = false
}, },
reset() {
this.goodsIdQuery = ''
this.vehicleIdQuery = ''
},
editCurrentRowTask(row) {
console.log(row)
// if (row.taskType == 1) {
// this.availableLocationOptions = []
// var currentOption = {
// value: row.destination,
// label: locationFormatter(row.destination)
// }
// this.availableLocationOptions.push(currentOption)
// //
// const requestParam = {
// areaId: 1
// }
// getAvailableLocations(requestParam).then(res => {
// if (res.data.code == 0) {
// for (const location of res.data.returnData) {
// var newOption = {}
// newOption.value = location.locationId
// newOption.label = locationFormatter(location.locationId)
// this.availableLocationOptions.push(newOption)
// }
// }
// }).catch(err => {
// errorBox(':' + err)
// })
// }
this.taskFormEntity = {
taskId: row.taskId,
taskPriority: row.taskPriority,
vehicleId: row.vehicleId,
goodsId: row.goodsRelated == null ? '' : row.goodsRelated.goodsId,
origin: row.origin,
destination: row.destination,
taskType: row.taskType,
taskStatus: row.taskStatus,
}
this.dialogVisible = true
},
submitTaskInfo() {
if (this.taskFormEntity.taskStatus == null || this.taskFormEntity.taskStatus == undefined) {
errorBox('请选择任务状态')
return
}
const request = {
taskId: this.taskFormEntity.taskId,
taskStatus: this.taskFormEntity.taskStatus,
userName: store.getters.getUserName
}
updateTaskInfo(request).then(res => {
if (res.data.code == 0) {
this.dialogVisible = false
ElMessage.success('修改任务成功')
this.search()
} else {
errorBox(res.data.message)
}
}).catch(err => {
console.log(err)
errorBox('修改任务失败')
})
},
getCurrentRow(row) {
this.taskId = row.taskId
}
},
} }
</script> </script>
<style scoped> <style scoped>
.el-pagination { .el-pagination {
padding-left: 5px; padding-left: 5px;
} }
.el-row .el-button { .el-row .el-button {
width: 72px; width: 72px;
margin-left: 0px; margin-left: 0px;
margin-right: 5px; margin-right: 5px;
} }
.table-class { .table-class {
width: 100%; width: 100%;
} }
.el-row .el-form-item .el-select-v2 { .el-row .el-form-item .el-select-v2 {
width: 100% !important; width: 100% !important;
} }
.el-row .el-form-item .el-input-number { .el-row .el-form-item .el-input-number {
width: 100% !important; width: 100% !important;
} }
.el-row .el-form-item .el-button { .el-row .el-form-item .el-button {
margin: auto; margin: auto;
} }
</style> </style>

View File

@ -3,13 +3,13 @@
<el-config-provider :locale="zhCn"> <el-config-provider :locale="zhCn">
<div style="display: flex;justify-content: space-between;"> <div style="display: flex;justify-content: space-between;">
<el-row> <el-row>
<el-input v-model="workOrderQuery" style="width: 158px; margin-right: 10px;" placeholder="工单号" <el-input v-model="workOrderQuery" style="width: 158px; margin-right: 10px; height: 32px;" placeholder="工单号"
:suffix-icon="Search"/> :suffix-icon="Search"/>
<el-input v-model="workCenterQuery" style="width: 158px; margin-right: 10px;" placeholder="工位/小盒子" <el-input v-model="workCenterQuery" style="width: 158px; margin-right: 10px; height: 32px;" placeholder="工位/小盒子"
:suffix-icon="Search"/> :suffix-icon="Search"/>
<el-input v-model="goodsIdQuery" style="width: 158px; margin-right: 10px;" placeholder="料号" <el-input v-model="goodsIdQuery" type="textarea" :rows="1" style="width: 158px; margin-right: 10px; height: 32px;"
:suffix-icon="Search"/> placeholder="请输入料号,多个料号请换行输入" class="goods-id-textarea" />
<el-input v-model="standIdQuery" style="width: 158px; margin-right: 10px;" placeholder="站台号" <el-input v-model="standIdQuery" style="width: 158px; margin-right: 10px; height: 32px;" placeholder="站台号"
:suffix-icon="Search"/> :suffix-icon="Search"/>
<el-select-v2 v-model="lightStatusQuery" style="width: 158px; margin-right: 10px;" <el-select-v2 v-model="lightStatusQuery" style="width: 158px; margin-right: 10px;"
placeholder="请选择灯光状态" :options="lightStatusOptions" @change="search()"></el-select-v2> placeholder="请选择灯光状态" :options="lightStatusOptions" @change="search()"></el-select-v2>
@ -21,6 +21,7 @@
<el-button type="warning" @click="reset()">重置</el-button> <el-button type="warning" @click="reset()">重置</el-button>
</el-row> </el-row>
<el-row> <el-row>
<el-button style="background-color: #32CD32; color: #000;" @click="exportExcel()">导出</el-button>
<el-button style="background-color: #00CED1; color: #000;" <el-button style="background-color: #00CED1; color: #000;"
@click="openUploadDialog()">导入 @click="openUploadDialog()">导入
</el-button> </el-button>
@ -43,6 +44,7 @@
<el-table-column prop="goodsId" label="料号" min-width="120px" show-overflow-tooltip/> <el-table-column prop="goodsId" label="料号" min-width="120px" show-overflow-tooltip/>
<el-table-column prop="needNum" label="需求数量" min-width="120px"/> <el-table-column prop="needNum" label="需求数量" min-width="120px"/>
<el-table-column prop="pickedNum" label="已拣数量" min-width="120px"/> <el-table-column prop="pickedNum" label="已拣数量" min-width="120px"/>
<el-table-column prop="distributedNum" label="已分配数量" min-width="120px"/>
<el-table-column prop="lightStatus" label="亮灯状态" :formatter="lightStatusFormat" min-width="120px"/> <el-table-column prop="lightStatus" label="亮灯状态" :formatter="lightStatusFormat" min-width="120px"/>
<el-table-column prop="workStatus" label="工作状态" :formatter="workStatusFormat" min-width="120px"/> <el-table-column prop="workStatus" label="工作状态" :formatter="workStatusFormat" min-width="120px"/>
<el-table-column prop="machineType" label="机型" :formatter="machineTypeFormat" min-width="120px"/> <el-table-column prop="machineType" label="机型" :formatter="machineTypeFormat" min-width="120px"/>
@ -51,7 +53,7 @@
show-overflow-tooltip/> show-overflow-tooltip/>
<el-table-column prop="finishTime" label="完成时间" :formatter="timeFormat" min-width="120px" <el-table-column prop="finishTime" label="完成时间" :formatter="timeFormat" min-width="120px"
show-overflow-tooltip/> show-overflow-tooltip/>
<el-table-column prop="opUser" label="操作用户" min-width="120px"/> <el-table-column prop="opUser" label="操作用户" min-width="120px" show-overflow-tooltip/>
<el-table-column fixed="right" label="操作" width="120px"> <el-table-column fixed="right" label="操作" width="120px">
<template v-slot="scope"> <template v-slot="scope">
<el-button plain type="primary" @click="editCurrentRow(scope.row)">编辑</el-button> <el-button plain type="primary" @click="editCurrentRow(scope.row)">编辑</el-button>
@ -121,7 +123,7 @@
</el-row> </el-row>
<el-row :gutter="16"> <el-row :gutter="16">
<el-col :span="12" :offset="0"> <el-col :span="12" :offset="0">
<el-form-item label="任务状态" prop="lightStatus"> <el-form-item label="亮灯状态" prop="lightStatus">
<el-select-v2 v-model="workFlowFormEntity.lightStatus" placeholder="请选择亮灯状态" <el-select-v2 v-model="workFlowFormEntity.lightStatus" placeholder="请选择亮灯状态"
:options="lightStatusOptions"></el-select-v2> :options="lightStatusOptions"></el-select-v2>
</el-form-item> </el-form-item>
@ -151,6 +153,13 @@
<el-input v-model="workFlowFormEntity.opUser" disabled/> <el-input v-model="workFlowFormEntity.opUser" disabled/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12">
<el-form-item label="已分配数量" prop="distributedNum">
<el-input-number v-model.number="workFlowFormEntity.distributedNum"
controls-position="right" :min="0" :max="workFlowFormEntity.needNum"
clearable/>
</el-form-item>
</el-col>
</el-row> </el-row>
</el-form> </el-form>
</div> </div>
@ -203,7 +212,7 @@ import {ref, reactive} from 'vue'
import {dateFormatter, timeFormatter} from '@/utils/formatter.js' import {dateFormatter, timeFormatter} from '@/utils/formatter.js'
import {Search} from '@element-plus/icons-vue' import {Search} from '@element-plus/icons-vue'
import UploadExcelWorkFlow from '@/excel/UploadExcelWorkFlow.vue' import UploadExcelWorkFlow from '@/excel/UploadExcelWorkFlow.vue'
import {queryUploadRecord} from '@/api/excel.js' import {queryUploadRecord, downloadWorkFlowExcel} from '@/api/excel.js'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs' import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
</script> </script>
<script> <script>
@ -303,7 +312,7 @@ export default {
workStation: this.standIdQuery.trim(), workStation: this.standIdQuery.trim(),
workOrder: this.workOrderQuery.trim(), workOrder: this.workOrderQuery.trim(),
workCenter: this.workCenterQuery.trim(), workCenter: this.workCenterQuery.trim(),
goodsId: this.goodsIdQuery.trim(), goodsId: this.goodsIdQuery.trim().split('\n').filter(id => id.trim() !== '').join(','),
lightStatus: this.lightStatusQuery == -99 ? null : this.lightStatusQuery, lightStatus: this.lightStatusQuery == -99 ? null : this.lightStatusQuery,
workStatus: this.workStatusQuery == -99 ? null : this.workStatusQuery, workStatus: this.workStatusQuery == -99 ? null : this.workStatusQuery,
machineType: this.machineTypeQuery == -99 ? null : this.machineTypeQuery, machineType: this.machineTypeQuery == -99 ? null : this.machineTypeQuery,
@ -343,6 +352,8 @@ export default {
}, },
workStatusFormat: (row, column, cellValue, index) => { workStatusFormat: (row, column, cellValue, index) => {
switch (cellValue) { switch (cellValue) {
case -1:
return '暂存'
case 0: case 0:
return '未开始' return '未开始'
case 1: case 1:
@ -381,6 +392,7 @@ export default {
goodsId: row.goodsId, goodsId: row.goodsId,
pickedNum: row.pickedNum, pickedNum: row.pickedNum,
needNum: row.needNum, needNum: row.needNum,
distributedNum: row.distributedNum,
lightStatus: row.lightStatus, lightStatus: row.lightStatus,
workStatus: row.workStatus, workStatus: row.workStatus,
createTime: row.createTime, createTime: row.createTime,
@ -393,6 +405,7 @@ export default {
const params = { const params = {
workFlowId: formData.workFlowId, workFlowId: formData.workFlowId,
pickedNum: formData.pickedNum, pickedNum: formData.pickedNum,
distributedNum: formData.distributedNum,
lightStatus: formData.lightStatus, lightStatus: formData.lightStatus,
workStatus: formData.workStatus, workStatus: formData.workStatus,
userName: store.getters.getUserName userName: store.getters.getUserName
@ -445,6 +458,41 @@ export default {
}) })
this.uploadDialogVisible = true this.uploadDialogVisible = true
}, },
exportExcel() {
const request = {
workStation: this.standIdQuery.trim(),
workOrder: this.workOrderQuery.trim(),
workCenter: this.workCenterQuery.trim(),
goodsId: this.goodsIdQuery.trim().split('\n').filter(id => id.trim() !== '').join(','),
lightStatus: this.lightStatusQuery == -99 ? null : this.lightStatusQuery,
workStatus: this.workStatusQuery == -99 ? null : this.workStatusQuery,
machineType: this.machineTypeQuery == -99 ? null : this.machineTypeQuery,
userName: store.getters.getUserName
}
downloadWorkFlowExcel(request).then(res => {
const link = document.createElement('a');//a
try {
let blob = res.data //blob
let _fileName = "工作流报表" + dateFormatter(new Date) + ".xlsx"
link.style.display = 'none'//
// URL
const url = window.URL || window.webkitURL || window.moxURL
link.href = url.createObjectURL(blob)
link.setAttribute('download', _fileName.substring(_fileName.lastIndexOf('_') + 1))
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
url.revokeObjectURL(link.href)//url
} catch (e) {
console.log(e)
errorBox('下载文件失败')
}
}).catch(err => {
console.log(err)
errorBox('导出失败')
})
},
}, },
} }
</script> </script>
@ -494,4 +542,28 @@ export default {
flex-direction: column; flex-direction: column;
padding: 10px; padding: 10px;
} }
/* 专门为料号文本域添加样式 */
.goods-id-textarea {
vertical-align: top;
}
.goods-id-textarea :deep(.el-textarea__inner) {
font-size: 12px;
line-height: 1.2;
padding: 5px;
height: 32px !important;
min-height: 32px !important;
resize: none;
}
/* 确保其他输入框保持一致的高度 */
.el-input {
height: 32px;
}
.el-input :deep(.el-input__wrapper) {
height: 32px;
line-height: 32px;
}
</style> </style>

View File

@ -3,13 +3,13 @@
<el-config-provider :locale="zhCn"> <el-config-provider :locale="zhCn">
<div style="display: flex;justify-content: space-between;"> <div style="display: flex;justify-content: space-between;">
<el-row> <el-row>
<el-input v-model="workOrderQuery" style="width: 158px; margin-right: 10px;" placeholder="工单号" <el-input v-model="workOrderQuery" style="width: 158px; margin-right: 10px; height: 32px;" placeholder="工单号"
:suffix-icon="Search" /> :suffix-icon="Search" />
<el-input v-model="workCenterQuery" style="width: 158px; margin-right: 10px;" placeholder="工位/小盒子" <el-input v-model="workCenterQuery" style="width: 158px; margin-right: 10px; height: 32px;" placeholder="工位/小盒子"
:suffix-icon="Search" /> :suffix-icon="Search" />
<el-input v-model="goodsIdQuery" style="width: 158px; margin-right: 10px;" placeholder="料号" <el-input v-model="goodsIdQuery" type="textarea" :rows="1" style="width: 158px; margin-right: 10px; height: 32px;"
:suffix-icon="Search" /> placeholder="请输入料号,多个料号请换行输入" class="goods-id-textarea" />
<el-input v-model="standIdQuery" style="width: 158px; margin-right: 10px;" placeholder="站台号" <el-input v-model="standIdQuery" style="width: 158px; margin-right: 10px; height: 32px;" placeholder="站台号"
:suffix-icon="Search" /> :suffix-icon="Search" />
<el-date-picker v-model="workDateQuery" type="date" placeholder="工作起始日期" :shortcuts="shortcuts" <el-date-picker v-model="workDateQuery" type="date" placeholder="工作起始日期" :shortcuts="shortcuts"
style="width: 158px; margin-right: 10px;" clearable /> style="width: 158px; margin-right: 10px;" clearable />
@ -129,7 +129,7 @@ export default {
workStation: this.standIdQuery.trim(), workStation: this.standIdQuery.trim(),
workOrder: this.workOrderQuery.trim(), workOrder: this.workOrderQuery.trim(),
workCenter: this.workCenterQuery.trim(), workCenter: this.workCenterQuery.trim(),
goodsId: this.goodsIdQuery.trim(), goodsId: this.goodsIdQuery.trim().split('\n').filter(id => id.trim() !== '').join(','),
lackStatus: this.lackStatusQuery == -99 ? null : this.lackStatusQuery, lackStatus: this.lackStatusQuery == -99 ? null : this.lackStatusQuery,
workDate: timeFormatter(this.workDateQuery), workDate: timeFormatter(this.workDateQuery),
workEndDate: timeFormatter(this.workEndDateQuery), workEndDate: timeFormatter(this.workEndDateQuery),
@ -193,10 +193,10 @@ export default {
workStation: this.standIdQuery.trim(), workStation: this.standIdQuery.trim(),
workOrder: this.workOrderQuery.trim(), workOrder: this.workOrderQuery.trim(),
workCenter: this.workCenterQuery.trim(), workCenter: this.workCenterQuery.trim(),
goodsId: this.goodsIdQuery.trim(), goodsId: this.goodsIdQuery.trim().split('\n').filter(id => id.trim() !== '').join(','),
lackStatus: this.lackStatusQuery == -99 ? null : this.lackStatusQuery, lackStatus: this.lackStatusQuery == -99 ? null : this.lackStatusQuery,
workDate: timeFormatter(this.workDateQuery), workDate: timeFormatter(this.workDateQuery),
workEndDate: timeFormatter(this.workEndDateQuery), workEndDate: timeFormatter(this.workEndDateQuery),
userName: store.getters.getUserName userName: store.getters.getUserName
} }
downloadWorkSummaryExcel(request).then(res => { downloadWorkSummaryExcel(request).then(res => {
@ -274,4 +274,33 @@ export default {
flex-direction: column; flex-direction: column;
padding: 10px; padding: 10px;
} }
/* 专门为料号文本域添加样式 */
.goods-id-container {
display: inline-block;
vertical-align: top;
}
.goods-id-textarea {
vertical-align: top;
}
.goods-id-textarea :deep(.el-textarea__inner) {
font-size: 12px;
line-height: 1.2;
padding: 5px;
height: 32px !important;
min-height: 32px !important;
resize: none;
}
/* 确保其他输入框保持一致的高度 */
.el-input {
height: 32px;
}
.el-input :deep(.el-input__wrapper) {
height: 32px;
line-height: 32px;
}
</style> </style>

View File

@ -1,28 +1,28 @@
<template> <template>
<body id="login-page"> <body id="login-page">
<el-form class="login-container" :model="loginForm" label-position="left" label-width="0px"> <el-form class="login-container" :model="loginForm" label-position="left" label-width="0px">
<h3 class="login_title">系统登录</h3> <h3 class="login_title">系统登录</h3>
<el-form-item> <el-form-item>
<el-input type="text" v-model="loginForm.loginAccount" auto-complete="off" placeholder="账号"></el-input> <el-input type="text" v-model="loginForm.loginAccount" auto-complete="off" placeholder="账号"></el-input>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-input type="password" v-model="loginForm.loginPassword" auto-complete="off" placeholder="密码"></el-input> <el-input type="password" v-model="loginForm.loginPassword" auto-complete="off" placeholder="密码"></el-input>
</el-form-item> </el-form-item>
<el-form-item style="width: 100%"> <el-form-item style="width: 100%">
<el-button type="primary" style="width: 100%; border: none" @click="login">登录</el-button> <el-button type="primary" style="width: 100%; border: none" @click="login">登录</el-button>
</el-form-item> </el-form-item>
<el-form-item style="width: 100%"> <el-form-item style="width: 100%">
<el-button type="primary" style="width: 100%; border: none" @click="loginCate">卡特账号登录</el-button> <el-button type="primary" style="width: 100%; border: none" @click="loginCate">卡特账号登录</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</body> </body>
</template> </template>
<script setup> <script setup>
import { getUser, loginWithAuth, loginWithoutAuth } from '@/api/login.js' import {getUser, loginWithAuth, loginWithoutAuth} from '@/api/login.js'
import { postToGetToken } from "@/api/kateLogin.js"; import {postToGetToken} from "@/api/kateLogin.js";
import { ElMessage, ElLoading } from 'element-plus' import {ElMessage, ElLoading} from 'element-plus'
import { reactive, onMounted } from 'vue'; import {reactive, onMounted} from 'vue';
import store from '@/store' import store from '@/store'
import router from '@/router' import router from '@/router'
import crypto from 'crypto' import crypto from 'crypto'
@ -30,35 +30,37 @@ import loading from "@/utils/loading";
// Dependency: Node.js crypto module // Dependency: Node.js crypto module
// https://nodejs.org/api/crypto.html#crypto_crypto // https://nodejs.org/api/crypto.html#crypto_crypto
function base64URLEncode(str) { function base64URLEncode(str) {
return str.toString('base64') return str.toString('base64')
.replace(/\+/g, '-') .replace(/\+/g, '-')
.replace(/\//g, '_') .replace(/\//g, '_')
.replace(/=/g, ''); .replace(/=/g, '');
} }
var verifier = base64URLEncode(crypto.randomBytes(32)); var verifier = base64URLEncode(crypto.randomBytes(32));
// Dependency: Node.js crypto module // Dependency: Node.js crypto module
// https://nodejs.org/api/crypto.html#crypto_crypto // https://nodejs.org/api/crypto.html#crypto_crypto
function sha256(buffer) { function sha256(buffer) {
return crypto.createHash('sha256').update(buffer).digest(); return crypto.createHash('sha256').update(buffer).digest();
} }
var challenge = base64URLEncode(sha256(verifier)); var challenge = base64URLEncode(sha256(verifier));
const loginForm = reactive({ const loginForm = reactive({
loginAccount: "", loginAccount: "",
loginPassword: "", loginPassword: "",
}) })
// todo // todo
const oauthConstants = { const oauthConstants = {
client_id: 'f921b5f5-ba70-4bcb-8a4b-f3c7d90ec84e',// id client_id: 'f921b5f5-ba70-4bcb-8a4b-f3c7d90ec84e',// id
// client_id: 'ASRS_ac_client', // client_id: 'ASRS_ac_client',
response_type: 'code',// code response_type: 'code',// code
state: '001',// state: '001',//
scope: 'openid%20profile',// openid scope: 'openid%20profile',// openid
grant_type: 'authorization_code', grant_type: 'authorization_code',
code_challenge: challenge, code_challenge: challenge,
code_challenge_method: 'S256', code_challenge_method: 'S256',
// response_mode: "form_post", // response_mode: "form_post",
redirect_uri: 'https://csclasrs.ecorp.cat.com/wms' redirect_uri: 'https://csclasrs.ecorp.cat.com/wms'
} }
@ -66,108 +68,112 @@ const oauthConstants = {
const cateLoginUrl = `https://login.microsoftonline.com/caterpillar.onmicrosoft.com/oauth2/v2.0/authorize?client_id=${oauthConstants.client_id}&response_type=${oauthConstants.response_type}&code_challenge=${oauthConstants.code_challenge}&code_challenge_method=S256&grant_type=${oauthConstants.grant_type}&scope=${oauthConstants.scope}&state=${oauthConstants.state}&redirect_uri=${oauthConstants.redirect_uri}` const cateLoginUrl = `https://login.microsoftonline.com/caterpillar.onmicrosoft.com/oauth2/v2.0/authorize?client_id=${oauthConstants.client_id}&response_type=${oauthConstants.response_type}&code_challenge=${oauthConstants.code_challenge}&code_challenge_method=S256&grant_type=${oauthConstants.grant_type}&scope=${oauthConstants.scope}&state=${oauthConstants.state}&redirect_uri=${oauthConstants.redirect_uri}`
// //
const login = () => { const login = () => {
const loading = ElLoading.service({ const loading = ElLoading.service({
lock: true, lock: true,
text: 'Loading', text: 'Loading',
background: 'rgba(0, 0, 0, 0.7)', background: 'rgba(0, 0, 0, 0.7)',
}) })
loginWithAuth(loginForm).then(res => { loginWithAuth(loginForm).then(res => {
loading.close() loading.close()
if (res.data.code === 0) { if (res.data.code === 0) {
store.commit('mutationUser', res.data.returnData.user)// store.commit('mutationUser', res.data.returnData.user)//
store.commit('mutationMenu', res.data.returnData.menuList)// store.commit('mutationMenu', res.data.returnData.menuList)//
store.commit('mutationStandId', res.data.returnData.standId) store.commit('mutationStandId', res.data.returnData.standId)
// router.replace({ path: '/' })// // router.replace({ path: '/' })//
router.replace({ path: '/systemCenter' })// router.replace({path: '/systemCenter'})//
} else { } else {
ElMessage.error(res.data.message) ElMessage.error(res.data.message)
} }
}).catch(err => { }).catch(err => {
console.log(err) console.log(err)
loading.close() loading.close()
ElMessage.error('登录失败!') ElMessage.error('登录失败!')
}) })
} }
// //
const loginCate = () => { const loginCate = () => {
store.commit('mutationAddVerify', verifier)// store.commit('mutationAddVerify', verifier)//
// console.log(cateLoginUrl) // console.log(cateLoginUrl)
window.location.href = cateLoginUrl// window.location.href = cateLoginUrl//
// window.open(cateLoginUrl)// // window.open(cateLoginUrl)//
} }
onMounted(() => { onMounted(() => {
if (router.currentRoute.value.query.code !== undefined) { const urlParams = new URLSearchParams(window.location.search);
loading.open('请求登录中...') const code = urlParams.get('code');
const tokenParam = { console.log(code); // ?code=
code_verifier: store.getters.getVerify, if (code !== undefined && code !== null && code !== '') {
client_id: '609f8296-74ab-441e-904f-3a8508030511', console.log('跳转并尝试登录。code' + code)
// scope: 'openid', loading.open('请求登录中...')
code: router.currentRoute.value.query.code, const tokenParam = {
redirect_uri: 'https://csclasrs.ecorp.cat.com/wms', code_verifier: store.getters.getVerify,
grant_type: 'authorization_code', client_id: 'f921b5f5-ba70-4bcb-8a4b-f3c7d90ec84e',
// client_secret: 'o6h8Q~iLegnIBG.GzJngXk.03FYdBJzIoCtTtcwj', // scope: 'openid',
// response_type: 'id_token', code: code,
// response_mode: 'form_post' redirect_uri: 'https://csclasrs.ecorp.cat.com/wms',
} grant_type: 'authorization_code',
postToGetToken(tokenParam).then(res => { // client_secret: 'o6h8Q~iLegnIBG.GzJngXk.03FYdBJzIoCtTtcwj',
store.commit('mutationClearVerify', verifier)// // response_type: 'id_token',
if (res.data.id_token !== undefined) { // response_mode: 'form_post'
const codeInfo = {
id_token: res.data.id_token
}
getUser(codeInfo).then(res => {
if (res.data.code === 0) {
store.commit('mutationUser', res.data.returnData.user)//
store.commit('mutationMenu', res.data.returnData.menuList)//
store.commit('mutationStandId', res.data.returnData.standId)
router.replace({ path: '/systemCenter' })
} else {
ElMessage.error(res.data.message)
}
}).catch(err => {
console.log(err)
ElMessage.error('登录失败!')
})
}
}).catch(err => {
console.log(err)
ElMessage.error('登录错误')
}).finally(() => {
loading.close()
})
} }
postToGetToken(tokenParam).then(res => {
store.commit('mutationClearVerify', verifier)//
if (res.data.id_token !== undefined) {
const codeInfo = {
id_token: res.data.id_token
}
getUser(codeInfo).then(res => {
if (res.data.code === 0) {
store.commit('mutationUser', res.data.returnData.user)//
store.commit('mutationMenu', res.data.returnData.menuList)//
store.commit('mutationStandId', res.data.returnData.standId)
router.replace({path: '/systemCenter'})
} else {
ElMessage.error(res.data.message)
}
}).catch(err => {
console.log(err)
ElMessage.error('登录失败!')
})
}
}).catch(err => {
console.log(err)
ElMessage.error('登录错误')
}).finally(() => {
loading.close()
})
}
}) })
</script> </script>
<style scoped> <style scoped>
#login-page { #login-page {
/* background: url("../assets/img/bg.jpg") no-repeat; */ /* background: url("../assets/img/bg.jpg") no-repeat; */
background-position: center; background-position: center;
height: 100%; height: 100%;
width: 100%; width: 100%;
background-size: cover; background-size: cover;
position: fixed; position: fixed;
} }
body { body {
margin: 0px; margin: 0px;
} }
.login-container { .login-container {
border-radius: 15px; border-radius: 15px;
background-clip: padding-box; background-clip: padding-box;
margin: 90px auto; margin: 90px auto;
width: 350px; width: 350px;
padding: 35px 35px 15px 35px; padding: 35px 35px 15px 35px;
background: #fff; background: #fff;
border: 1px solid #eaeaea; border: 1px solid #eaeaea;
box-shadow: 0 0 25px #cac6c6; box-shadow: 0 0 25px #cac6c6;
} }
.login_title { .login_title {
margin: 0px auto 40px auto; margin: 0px auto 40px auto;
text-align: center; text-align: center;
color: #505458; color: #505458;
} }
</style> </style>