生产工单新增修改时修改日期格式

This commit is contained in:
17630416519 2026-01-13 14:44:35 +08:00
parent 43b8c320df
commit 6483af23fb

View File

@ -7,19 +7,9 @@
start-placeholder="开始时间" end-placeholder="结束时间" placeholder="请选择工单日期区间" />
</el-form-item>
<el-form-item label="组别" prop="groupCode">
<!-- <el-select v-model="queryParams.groupCode" placeholder="全部">
<el-option label="全部" value="" />
<el-option v-for="(item, index) in allGroupOptions" :key="index" :label="item.label"
:value="item.value" />
</el-select> -->
<el-input v-model="queryParams.groupCode" placeholder="请输入组别" />
</el-form-item>
<el-form-item label="线别" prop="lineCode">
<!-- <el-select v-model="queryParams.lineCode" placeholder="全部">
<el-option label="全部" value="" />
<el-option v-for="(item, index) in allRouteOptions" :key="index" :label="item.label"
:value="item.value" />
</el-select> -->
<el-input v-model="queryParams.lineCode" placeholder="请输入线别" />
</el-form-item>
</div>
@ -29,9 +19,6 @@
<el-form-item label="产品名称" prop="productionName">
<el-input v-model.trim="queryParams.productionName" clearable placeholder="请输入产品名称" />
</el-form-item>
<!-- <el-form-item label="客户编码" prop="customCode">
<el-input v-model.trim="queryParams.customCode" clearable placeholder="请输入客户编码" />
</el-form-item> -->
<el-form-item>
<el-button icon="search" type="primary" @click="handleQuery">{{ $t('btn.search') }}</el-button>
@ -45,16 +32,6 @@
<el-button class="tool-box" type="primary" v-hasPermi="['productManagement:proworkorder:add']"
icon="plus" @click="handleAdd(-1)"> 手动新增工单 </el-button>
</el-col>
<!-- <el-col :span="1.5">
<el-button
class="tool-box"
type="warning"
v-hasPermi="['productManagement:proworkorder:edit']"
icon="Expand"
@click="handleCreateWorkOrder">
生成工单号
</el-button>
</el-col> -->
<el-col :span="1.5">
<el-button class="tool-box" color="#626aef" v-hasPermi="['productManagement:proworkorder:list']"
@ -72,14 +49,6 @@
<el-button class="tool-box" color="#55557f" v-hasPermi="['productManagement:proworkorder:list']"
icon="Printer" @click="handlePrint"> 打印 </el-button>
</el-col>
<!-- <el-col :span="1.5">
<el-button class="tool-box" color="#0077cc" icon="Refresh" @click="syncPaintBOM"> 更新涂装BOM
</el-button>
</el-col>
<el-col :span="1.5">
<el-button class="tool-box" color="#aa00ff" icon="List" @click="openCreateMaterialPlanDialog"> 更新MRP
</el-button>
</el-col> -->
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
</el-row>
@ -132,22 +101,8 @@
<el-link @click="showBOM(scope.row)" type="primary">{{ scope.row.productionCode }}</el-link>
</template>
</el-table-column>
<!-- <el-table-column
prop="productionName"
label="物料描述"
min-width="200"
align="center"
:show-overflow-tooltip="true"
v-if="columns.showColumn('productionName')" /> -->
<el-table-column prop="specification" label="规格" width="160" align="center" :show-overflow-tooltip="true"
v-if="columns.showColumn('specification')" />
<!-- <el-table-column
prop="customCode"
label="客户编码"
width="140"
align="center"
:show-overflow-tooltip="true"
v-if="columns.showColumn('customCode')" /> -->
<el-table-column prop="deliveryNum" label="计划数量" align="center" v-if="columns.showColumn('deliveryNum')" />
<el-table-column prop="unit" label="单位" align="center" :show-overflow-tooltip="true"
v-if="columns.showColumn('unit')" />
@ -189,26 +144,6 @@
v-if="columns.showColumn('updatedBy')" />
<el-table-column prop="updatedTime" label="更新时间" :show-overflow-tooltip="true"
v-if="columns.showColumn('updatedTime')" />
<!-- <el-table-column label="排序" width="120" fixed="right" align="center">
<template #default="scope">
<el-button
@click="handleMove(scope.row.id, 1)"
:disabled="moveLoading"
color="#b67900"
size="small"
plain
icon="ArrowUpBold"
title="上移"></el-button>
<el-button
@click="handleMove(scope.row.id, 2)"
:disabled="moveLoading"
color="#3f7f00"
size="small"
plain
icon="ArrowDownBold"
title="下移"></el-button>
</template>
</el-table-column> -->
<el-table-column label="操作" align="center" fixed="right" width="80">
<template #default="scope">
<el-dropdown>
@ -250,13 +185,13 @@
</el-col>
<el-col :lg="12">
<el-form-item label="物料名称" prop="productionName">
<el-input v-model.trim="form.productionName" placeholder="请输入物料名称" />
<el-input v-model.trim="form.productionName" placeholder="请输入物料名称" />
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item label="物料编号" prop="productionCode">
<el-input v-model.trim="form.productionCode" placeholder="请输入物料编号" />
<el-input v-model.trim="form.productionCode" placeholder="请输入物料编号" />
</el-form-item>
</el-col>
@ -265,28 +200,6 @@
<el-input v-model.trim="form.specification" placeholder="请输入规格" />
</el-form-item>
</el-col>
<!-- <el-col :lg="24">
<el-form-item label="客户搜索" prop="search02">
<el-select
v-model="search02"
filterable
value-key="id"
remote
reserve-keyword
placeholder="请输入物料名称或物料编号"
:remote-method="querySearch02"
@change="search02Change"
:loading="search02Loading"
class="select">
<el-option v-for="item in search02Options" :key="item.id" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item label="客户编码" prop="customCode">
<el-input disabled v-model.trim="form.customCode" placeholder="请输入客户编码" />
</el-form-item>
</el-col> -->
<el-col :lg="12">
<el-form-item label="工单日期" prop="workorderDate">
<el-date-picker @change="getFormLineOptions(true)" style="width: 100%"
@ -315,19 +228,11 @@
</el-col>
<el-col :lg="12">
<el-form-item label="线别" prop="lineCode">
<!-- <el-select v-model="form.lineCode" placeholder="请选择线别" class="select">
<el-option v-for="(item, index) in allRouteOptions" :key="index" :label="item.label"
:value="item.value" />
</el-select> -->
<el-input v-model="form.lineCode" placeholder="请输入线别" />
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item label="组别" prop="groupCode">
<!-- <el-select v-model="form.groupCode" placeholder="请选择组别" class="select">
<el-option v-for="(item, index) in groupOptions" :key="index" :label="item.label"
:value="item.value" />
</el-select> -->
<el-input v-model="form.groupCode" placeholder="请输入组别" />
</el-form-item>
</el-col>
@ -374,6 +279,15 @@
<el-input v-model.number="form.sort" placeholder="请输入序号" />
</el-form-item>
</el-col>
<el-form-item label="选择时段" prop="workOrderNum">
<el-date-picker
v-model="value1"
type="datetimerange"
range-separator="To"
start-placeholder="开始"
end-placeholder="结束时间"
/>
</el-form-item>
<el-col :lg="24">
<el-form-item label="备注" prop="remark">
<el-input type="textarea" v-model="form.remark" placeholder="请输入备注" />
@ -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()
</script>
@ -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;
/* 隐藏超出的部分 */
}
}
</style>