diff --git a/src/views/productManagement/ProWorkorder/index.vue b/src/views/productManagement/ProWorkorder/index.vue
index d1e078c..ab4f3ef 100644
--- a/src/views/productManagement/ProWorkorder/index.vue
+++ b/src/views/productManagement/ProWorkorder/index.vue
@@ -7,19 +7,9 @@
start-placeholder="开始时间" end-placeholder="结束时间" placeholder="请选择工单日期区间" />
-
-
@@ -29,9 +19,6 @@
-
{{ $t('btn.search') }}
@@ -45,16 +32,6 @@
手动新增工单
-
打印
-
@@ -132,22 +101,8 @@
{{ scope.row.productionCode }}
-
-
@@ -189,26 +144,6 @@
v-if="columns.showColumn('updatedBy')" />
-
@@ -250,13 +185,13 @@
-
+
-
+
@@ -265,28 +200,6 @@
-
-
-
@@ -374,6 +279,15 @@
+
+
+
@@ -629,32 +543,27 @@ var dictParams = []
const allList = ref([])
const lackMaterialCodeTotal = computed(() => {
- // 根据 count 的值计算出新的值
return allList.value.filter((item) => item.isMatch_material_code === null).length
})
const lackMaterialNameTotal = computed(() => {
- // 根据 count 的值计算出新的值
return allList.value.filter((item) => item.isMatch_material_name === null).length
})
const lackLineTotal = computed(() => {
- // 根据 count 的值计算出新的值
return allList.value.filter((item) => item.isMatch_line === null).length
})
const lackGroupTotal = computed(() => {
- // 根据 count 的值计算出新的值
return allList.value.filter((item) => item.isMatch_group === null).length
})
const lackMatchUnitTotal = computed(() => {
- // 根据 count 的值计算出新的值
return allList.value.filter((item) => item.isMatch_Unit === null).length
})
-// 日期格式化函数
+// 日期格式化函数(仅用于页面展示)
function formatDate(dateString) {
if (!dateString) return ''
const date = new Date(dateString)
- if (isNaN(date.getTime())) return '' // 检查日期是否有效
+ if (isNaN(date.getTime())) return ''
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
@@ -751,7 +660,6 @@ function handleQuery() {
// 重置查询操作
function resetQuery() {
proxy.resetForm('queryRef')
- // 重置日期范围为当前日期
queryParams.workorderDate = [new Date(), new Date()]
handleQuery()
}
@@ -785,7 +693,6 @@ function tableCellClassName({ row, column, rowIndex, columnIndex }) {
if (row.isMatch_Unit === null && column.label === '单位') {
return 'danger-cell-1'
}
- // return 'common-row'
}
/*************** form操作 ***************/
const formRef = ref()
@@ -805,7 +712,7 @@ const state = reactive({
lineCode: [{ required: true, message: '线别不能为空', trigger: 'blur' }]
},
options: {
- // 工单状态 选项列表 格式 eg:{ dictLabel: '标签', dictValue: '0'}
+ // 工单状态 选项列表
statusOptions: [],
// 优先级
priorityOptions: [
@@ -819,7 +726,7 @@ const state = reactive({
{ dictLabel: '个', dictValue: '个', listClass: 'info' },
{ dictLabel: '件', dictValue: '件', listClass: 'info' }
],
- // 是否足料(1-缺料 2-足料) 选项列表 格式 eg:{ dictLabel: '标签', dictValue: '0'}
+ // 是否足料
isSufficientOptions: [
{ dictLabel: '足料', dictValue: '2', listClass: '' },
{ dictLabel: '缺料', dictValue: '1', listClass: '' },
@@ -844,29 +751,7 @@ async function initDict() {
}
/// ===================================================
-/// ===================== 获取单位下拉 ====================
-// import { listBaseUnit } from '@/api/baseManagement/baseunit.js'
-// function getUnitOptions() {
-// const params = {
-// status: 1
-// }
-// listBaseUnit(params).then((res) => {
-// if (res.code === 200) {
-// options.value.unitOptions = res.data.result.map((item) => {
-// return {
-// dictLabel: `${item.unitName}`,
-// dictValue: `${item.unitCode}`
-// }
-// })
-// }
-// })
-// }
-// getUnitOptions()
-
-/// ======================================================
-
/// ===================== 获取线别下拉,组别下拉 =======================
-
const lineOptions = ref([])
function getFormLineOptions(clear = false) {
lineOptions.value = []
@@ -909,21 +794,6 @@ function getGroupOptions(routeCode = null) {
}
})
}
-// import { listBaseGroup } from '@/api/baseManagement/basegroup.js'
-// function getAllGroupOptions() {
-// listBaseGroup({ pageNum: 1, pageSize: 100, status: 1 }).then((res) => {
-// const { code, data } = res
-// if (code == 200) {
-// groupOptions.value = data.result.map((item) => {
-// return {
-// label: `${item.groupCode}-${item.groupName}`,
-// value: `${item.groupCode}`
-// }
-// })
-// }
-// })
-// }
-// getAllGroupOptions()
/// =================================================================
// 关闭dialog
@@ -934,11 +804,14 @@ function cancel() {
// 重置表单
function reset() {
+ // 初始化日期为 ISO 格式(2026-01-13T00:00:00 样式)
+ const today = new Date()
+ const isoDate = new Date(today.setHours(0, 0, 0, 0)).toISOString().slice(0, 19)
+
form.value = {
id: null,
productionName: null,
productionCode: null,
- // productionCodeList: [],
specification: '',
customCode: null,
deliveryNum: 0,
@@ -948,13 +821,12 @@ function reset() {
groupCode: null,
lineCode: null,
sort: 1,
- workorderDate: new Date().toISOString().split('T')[0], // 使用原生JS获取当前日期
+ workorderDate: isoDate, // 保持ISO格式
year: null,
week: null,
date: null,
priority: '2',
status: 1,
- // beat工单节拍
beat: 0,
remark: null,
createdBy: null,
@@ -964,13 +836,11 @@ function reset() {
}
search01.value = ''
search02.value = ''
- // lineOptions.value = []
- // groupOptions.value = []
proxy.resetForm('formRef')
}
+
// 插入生产工单
const nextId = ref('')
-
function handleAdd(id = -1) {
reset()
open.value = true
@@ -982,8 +852,8 @@ function handleAdd(id = -1) {
} else {
form.value.priority = 2
}
- // getFormLineOptions()
}
+
// 修改按钮操作
function handleUpdate(row) {
reset()
@@ -995,30 +865,49 @@ function handleUpdate(row) {
title.value = '修改生产工单'
opertype.value = 2
+ // 确保回显的日期是 ISO 格式
+ if (data.workorderDate && !(data.workorderDate.includes('T'))) {
+ data.workorderDate = new Date(data.workorderDate).toISOString().slice(0, 19)
+ }
+
form.value = {
...data
}
- // getFormLineOptions()
}
})
}
-// 添加&修改 表单提交
+// 添加&修改 表单提交 - 核心修改:确保提交的是 ISO 格式日期
function submitForm(toNext = false) {
proxy.$refs['formRef'].validate((valid) => {
if (valid) {
- if (form.value.id != undefined && opertype.value === 2) {
- updateProWorkorder(form.value).then((res) => {
+ // 深拷贝表单数据,避免修改原数据
+ const submitData = { ...form.value }
+
+ // 确保 workorderDate 是 2026-01-13T00:00:00 格式
+ if (submitData.workorderDate) {
+ // 如果是 Date 对象,转换为 ISO 格式
+ if (submitData.workorderDate instanceof Date) {
+ submitData.workorderDate = submitData.workorderDate.toISOString().slice(0, 19)
+ }
+ // 如果是 YYYY-MM-DD 字符串,转换为 ISO 格式
+ else if (typeof submitData.workorderDate === 'string' && submitData.workorderDate.includes('-') && !submitData.workorderDate.includes('T')) {
+ submitData.workorderDate = new Date(submitData.workorderDate + 'T00:00:00').toISOString().slice(0, 19)
+ }
+ }
+
+ if (submitData.id != undefined && opertype.value === 2) {
+ updateProWorkorder(submitData).then((res) => {
proxy.$modal.msgSuccess('修改成功')
if (!toNext) {
open.value = false
}
- WorkOrderLog({ workorder: form.value.workorder, log: '修改' })
+ WorkOrderLog({ workorder: submitData.workorder, log: '修改' })
getList()
})
} else {
- form.value.next_id = nextId.value
- Insert_workOrder(form.value).then((res) => {
+ submitData.next_id = nextId.value
+ Insert_workOrder(submitData).then((res) => {
proxy.$modal.msgSuccess('新增成功')
if (!toNext) {
open.value = false
@@ -1048,14 +937,13 @@ function handleDelete(row) {
// 生成工单
const createWorkOrderShow = ref(false)
const createWorkOrderDate = ref(new Date())
-
function handleCreateWorkOrder() {
createWorkOrderShow.value = true
}
function submitCreateWorkOrder() {
const submitData = {
- workorderDate: createWorkOrderDate.value
+ workorderDate: createWorkOrderDate.value.toISOString().slice(0, 19) // 保持ISO格式
}
Generate_workorder(submitData).then((res) => {
const { code, data } = res
@@ -1085,24 +973,19 @@ function handleMove(row, type) {
}
})
}
+
import { getToken } from '@/utils/auth'
/*** 导入参数 */
const upload = reactive({
- // 是否显示弹出层(导入)
open: false,
- // 弹出层标题(导入)
title: '',
- // 是否禁用上传
isUploading: false,
- // 是否更新数据
updateSupport: 0,
- // 更新方式 1-覆盖 2-追加
uploadType: 1,
- // 设置上传的请求头部
headers: { Authorization: 'Bearer ' + getToken() },
- // 上传的地址
url: import.meta.env.VITE_APP_BASE_API + '/mes/productManagement/ProWorkorder/importData'
})
+
/** 导入按钮操作 */
function handleImport(type) {
if (type === 1) {
@@ -1114,17 +997,19 @@ function handleImport(type) {
upload.uploadType = 2
upload.url = import.meta.env.VITE_APP_BASE_API + '/mes/productManagement/ProWorkorder/importData_append'
}
-
upload.open = true
}
+
/** 下载模板操作 */
function importTemplate() {
proxy.download('/mes/productManagement/ProWorkorder/importTemplate', '工单数据导入模板')
}
+
/**文件上传中处理 */
const handleFileUploadProgress = (event, file, fileList) => {
upload.isUploading = true
}
+
/** 文件上传成功处理 */
const handleFileSuccess = (response, file, fileList) => {
const { code, msg, data } = response
@@ -1147,16 +1032,13 @@ const handleFileSuccess = (response, file, fileList) => {
dangerouslyUseHTMLString: true
})
handleUpdatePaintingMrp()
- // submitCreateWorkOrder()
getList()
}
+
/** 文件上传异常处理 */
const handleFileError = (error, file, fileList) => {
- const { code, msg, data } = response
- if (error) {
- proxy.$message.error('模板导入异常!')
- return
- }
+ proxy.$message.error('模板导入异常!')
+ upload.isUploading = false
}
/** 提交上传文件 */
@@ -1166,20 +1048,18 @@ function submitFileForm() {
/*** 导出参数 */
const exportDialog = reactive({
- // 是否显示弹出层(导入)
open: false,
- // 弹出层标题(导入)
title: '',
- // 设置上传的请求头部
time: new Date(),
- // 导出的地址
url: '/mes/productManagement/ProWorkorder/export'
})
+
// 导出弹框
function handleExport() {
exportDialog.title = '按日期导出工单Excel'
exportDialog.open = true
}
+
// 导出提交
function submitExport() {
proxy.$modal
@@ -1192,14 +1072,10 @@ function submitExport() {
const time = exportDialog.time
let dateString = `${time.getFullYear()}-${(time.getMonth() + 1).toString().padStart(2, '0')}-${time.getDate().toString().padStart(2, '0')}`
proxy.download(exportDialog.url + '?extportDate=' + dateString, '工单数据导出模板')
- // await downFile(exportDialog.url, { extportDate: exportDialog.time })
exportDialog.open = false
})
}
-
-
-
/// =========== 生成物料需求计划MRP ===============
import { GenerateMmRequirePlan } from '@/api/materialManagement/mmrequireplan.js'
import { GenerateLineMmCallMRP } from '@/api/materialManagement/mmcallrequests/mmcallrequests.js'
@@ -1207,32 +1083,25 @@ const CreateMaterialPlanDialogShow = ref(false)
const planDate = ref(new Date())
const syncLoading = ref(false)
const updateResults = ref([])
+
function openCreateMaterialPlanDialog() {
CreateMaterialPlanDialogShow.value = true
}
+
// 更新物流需求计划
function handleCreateMaterialPlan() {
- // 清空之前的结果
updateResults.value = []
-
- // 获取所有线别
const lines = allRouteOptions.value.map(item => item.value)
- // 如果没有线别,直接返回
if (lines.length === 0) {
proxy.$modal.msgWarning('没有可更新的线别')
return
}
- // 设置加载状态
syncLoading.value = true
-
- // 创建一个Promise数组来处理所有线别的更新
const updatePromises = lines.map(lineCode => {
- // 格式化日期为YYYY-MM-DD格式
- const formattedDate = formatDate(planDate.value);
+ const formattedDate = new Date(planDate.value).toISOString().slice(0, 19)
return GenerateMmRequirePlan({ lineCode, plan_date: formattedDate }).then(res => {
- // 更新结果
updateResults.value.push({
lineCode: lineCode,
status: res.code === 200 ? '成功' : '失败',
@@ -1240,7 +1109,6 @@ function handleCreateMaterialPlan() {
})
return res
}).catch(error => {
- // 更新结果
updateResults.value.push({
lineCode: lineCode,
status: '失败',
@@ -1250,7 +1118,6 @@ function handleCreateMaterialPlan() {
})
})
- // 等待所有更新完成
Promise.all(updatePromises).then(() => {
syncLoading.value = false
proxy.$modal.msgSuccess('所有线别更新完成')
@@ -1263,27 +1130,18 @@ function handleCreateMaterialPlan() {
// 更新涂装MRP
function handleUpdatePaintingMrp() {
- // 清空之前的结果
updateResults.value = []
-
- // 获取所有线别
const lines = allRouteOptions.value.map(item => item.value)
- // 如果没有线别,直接返回
if (lines.length === 0) {
proxy.$modal.msgWarning('没有可更新的线别')
return
}
- // 设置加载状态
syncLoading.value = true
-
- // 创建一个Promise数组来处理所有线别的更新
const updatePromises = lines.map(lineCode => {
- // 格式化日期为YYYY-MM-DD格式
- const formattedDate = formatDate(planDate.value);
+ const formattedDate = new Date(planDate.value).toISOString().slice(0, 19)
return GenerateLineMmCallMRP({ lineCode, workOrderDate: formattedDate }).then(res => {
- // 更新结果
updateResults.value.push({
lineCode: lineCode,
status: res.msg === 'ok' ? '成功' : '更新失败',
@@ -1291,7 +1149,6 @@ function handleUpdatePaintingMrp() {
})
return res
}).catch(error => {
- // 更新结果
updateResults.value.push({
lineCode: lineCode,
status: '失败',
@@ -1301,7 +1158,6 @@ function handleUpdatePaintingMrp() {
})
})
- // 等待所有更新完成
Promise.all(updatePromises).then(() => {
syncLoading.value = false
proxy.$modal.msgSuccess('所有线别更新完成')
@@ -1317,6 +1173,7 @@ function handleUpdatePaintingMrp() {
const search01 = ref('')
const search01Loading = ref(false)
const search01Options = ref([])
+
function querySearch01(query) {
search01Loading.value = true
GetMaterialInfo({ Name_or_Code: query }).then((res) => {
@@ -1333,14 +1190,17 @@ function querySearch01(query) {
}
})
}
+
function search01Change(value) {
form.value.productionName = value.name
form.value.productionCode = value.code
form.value.specification = value.specification
}
+
const search02 = ref('')
const search02Loading = ref(false)
const search02Options = ref([])
+
function querySearch02(query) {
GetCustomInfo({ CustomNo: query }).then((res) => {
if (res.code === 200) {
@@ -1354,6 +1214,7 @@ function querySearch02(query) {
}
})
}
+
function search02Change(value) {
form.value.customCode = value
}
@@ -1361,18 +1222,14 @@ function search02Change(value) {
/// ============= 更新BOM表 ===============
import { GeneratePaintBOM } from '@/api/materialManagement/mmcallrequests/mmcallrequests.js'
-// 同步涂装车间BOM清单
let isSyncing = false
-
-
-
/// ======================================
-
/// ======================= BOM展示 ======================
const bomListShow = ref(false)
const bomList = ref([])
const selectMaterialCode = ref('')
+
function showBOM(row) {
const params = {
workorder_num: row.workorder
@@ -1384,12 +1241,8 @@ function showBOM(row) {
}
})
}
-
/// ======================================================
-
-
-
/// ================= 工单打印 =========================
const PrintDialogShow = ref(false)
const printList = ref([])
@@ -1397,10 +1250,12 @@ const printObj = {
id: 'printTable',
popTitle: '工单打印'
}
+
function handlePrint() {
PrintDialogShow.value = true
printList.value = getPrintList()
}
+
function getPrintList() {
const _list = allList.value
const groupedData = _list.reduce((acc, item) => {
@@ -1413,6 +1268,7 @@ function getPrintList() {
}, {})
return Object.values(groupedData)
}
+
// 获取打印时间
function getPrintTime() {
if (queryParams.workorderDate != null && queryParams.workorderDate.length > 0) {
@@ -1425,6 +1281,9 @@ function getPrintTime() {
}
/// ================================================
+// 初始化变量
+const value1 = ref('')
+
initDict()
handleQuery()
@@ -1443,18 +1302,6 @@ handleQuery()
width: 500px !important;
}
-/* :deep(.table-header) {
- font-size: 22px;
- font-weight: 600;
- background: black;
- color: #303133;
-}
-
-:deep(.common-row) {
- font-size: 20px;
- font-weight: 600;
-} */
-
:deep(.warning-cell-1) {
background-color: #e6a23c !important;
color: black;
@@ -1532,17 +1379,12 @@ handleQuery()
.qrCode {
text-align: center;
padding: 10px;
- /* width: 36px !important;
- height: 36px !important; */
}
td {
white-space: normal;
- /* 允许内容换行 */
word-break: break-all;
- /* 在长单词或URL需要时允许换行 */
overflow: hidden;
- /* 隐藏超出的部分 */
}
}
\ No newline at end of file