Commit 5c5b1b42 by qinjianhui

feat: 新订单批次管理修改

parent 253f46ce
<template>
<ElDialog
v-model="visible"
:title="dialogTitle"
width="520px"
:close-on-click-modal="false"
>
<ElForm :model="form">
<ElFormItem
v-if="showAutoSwitch"
label="自动排版(烫画工艺推荐自动排版)"
style="margin-bottom: 10px"
>
<el-switch
v-model="isAuto"
inline-prompt
style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"
active-text="是"
inactive-text="否"
@change="handleAutoChange"
/>
</ElFormItem>
<template v-if="isAuto || !showAutoSwitch">
<ElFormItem label="排版类型">
<el-radio-group v-model="form.type">
<el-radio label="tiff">tiff</el-radio>
<el-radio label="png">png</el-radio>
</el-radio-group>
</ElFormItem>
<ElFormItem label="排版宽度">
<el-radio-group v-model="form.templateWidth">
<el-radio :value="42">40+2cm</el-radio>
<el-radio :value="60">60cm</el-radio>
</el-radio-group>
</ElFormItem>
</template>
</ElForm>
<template #footer>
<div style="text-align: center">
<ElButton @click="visible = false">取消</ElButton>
<ElButton type="primary" :loading="submitting" @click="handleSubmit">
确定
</ElButton>
</div>
</template>
</ElDialog>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { ElMessage } from 'element-plus'
import { arrangeFinishApi } from '@/api/podCnOrder'
type OpenPayload = {
productIdList: number[]
title?: string
showAutoSwitch?: boolean
}
const emit = defineEmits<{
success: []
}>()
const visible = ref(false)
const submitting = ref(false)
const payload = ref<OpenPayload | null>(null)
const isAuto = ref(true)
const form = ref<{ type?: string; templateWidth?: number }>({})
const showAutoSwitch = ref(true)
const dialogTitle = ref('排单')
const handleAutoChange = () => {
form.value = {}
}
const open = (p: OpenPayload) => {
payload.value = p
showAutoSwitch.value = p.showAutoSwitch ?? true
dialogTitle.value = p.title || '排单'
isAuto.value = true
form.value = {}
visible.value = true
}
const handleSubmit = async () => {
if (!payload.value?.productIdList?.length) {
return ElMessage.warning('请选择订单')
}
const { templateWidth, type } = form.value
const mustFill = isAuto.value || !showAutoSwitch.value
if (mustFill && (!templateWidth || !type)) {
return ElMessage.warning('排版类型和排版宽度为必选项')
}
if (!templateWidth && type) return ElMessage.warning('请选择排版宽度')
if (templateWidth && !type) return ElMessage.warning('请选择排版类型')
submitting.value = true
try {
await arrangeFinishApi({
productIdList: payload.value.productIdList,
templateWidth: isAuto.value ? templateWidth : undefined,
type: isAuto.value ? type : undefined,
})
ElMessage.success('操作成功')
visible.value = false
emit('success')
} catch (e: unknown) {
ElMessage.error((e as Error)?.message || '排单失败')
} finally {
submitting.value = false
}
}
defineExpose({ open })
</script>
......@@ -13,12 +13,20 @@
/>
</ElFormItem>
<ElFormItem label="创建人">
<ElInput
<ElSelect
v-model="filterForm.creator"
placeholder="创建人"
placeholder="请选择"
clearable
filterable
style="width: 120px"
/>
>
<ElOption
v-for="item in employeeList"
:key="item.id"
:label="item.account"
:value="item.account"
/>
</ElSelect>
</ElFormItem>
<ElFormItem label="工艺类型">
<ElSelect
......@@ -30,6 +38,9 @@
<ElOption label="烫画" value="TH" />
<ElOption label="直喷" value="ZP" />
<ElOption label="刺绣" value="CX" />
<ElOption label="雕刻" value="DK" />
<ElOption label="白胚" value="BP" />
<ElOption label="其他" value="QT" />
</ElSelect>
</ElFormItem>
<ElFormItem label="下载状态">
......@@ -98,21 +109,37 @@
</el-tag>
</template>
<template #operation="{ row }">
<ElButton type="primary" link size="small" @click="handleView(row)">
查看
</ElButton>
<ElButton
type="primary"
link
size="small"
@click="handleDownload(row)"
@click="handleDownload()"
>
下载
</ElButton>
<ElButton type="primary" link size="small" @click="handlePrintPick()">
拣货单
</ElButton>
<ElButton
type="primary"
link
size="small"
@click="handlePrintProduction()"
>
生产单
</ElButton>
<ElButton type="warning" link size="small" @click="handleReArrange(row)">
重排
</ElButton>
<ElButton type="danger" link size="small" @click="handleDelete()">
删除
</ElButton>
</template>
</TableView>
</div>
<ArrangeDialog ref="arrangeDialogRef" @success="loadData" />
<ElPagination
v-model:current-page="currentPage"
v-model:page-size="pageSize"
......@@ -134,6 +161,9 @@ import { getBatchManageListApi, batchDeleteApi } from '@/api/factoryOrderNew'
import type { BatchManageData } from '@/types/api/factoryOrderNew'
import type { CustomColumn } from '@/types/table'
import TableView from '@/components/TableView.vue'
import ArrangeDialog from './ArrangeDialog.vue'
import { getEmployeeListApi } from '@/api/common'
import type { userData } from '@/types/api/user'
const loading = ref(false)
const tableData = ref<BatchManageData[]>([])
......@@ -141,6 +171,8 @@ const selectedRows = ref<BatchManageData[]>([])
const currentPage = ref(1)
const pageSize = ref(50)
const total = ref(0)
const employeeList = ref<userData[]>([])
const arrangeDialogRef = ref<InstanceType<typeof ArrangeDialog>>()
const columns: CustomColumn<BatchManageData>[] = [
{ key: 'batchNo', prop: 'batchNo', label: '批次号', minWidth: 120 },
......@@ -230,6 +262,16 @@ const loadData = async () => {
}
}
const loadEmployeeList = async () => {
try {
const res = await getEmployeeListApi()
if (res.code !== 200) return
employeeList.value = res.data || []
} catch (e) {
console.error(e)
}
}
const handleSelectionChange = (rows: BatchManageData[]) => {
selectedRows.value = rows
}
......@@ -252,12 +294,30 @@ const handleBatchDelete = async () => {
}
}
const handleView = (row: BatchManageData) => {
ElMessage.info(`查看批次 ${row.batchNo}`)
const handleDownload = () => {
ElMessage.info('接口待提供')
}
const handleDownload = (row: BatchManageData) => {
ElMessage.info(`下载批次 ${row.batchNo}`)
const handlePrintPick = () => {
ElMessage.info('接口待提供')
}
const handlePrintProduction = () => {
ElMessage.info('接口待提供')
}
const handleDelete = () => {
ElMessage.info('接口待提供')
}
const handleReArrange = (row: BatchManageData) => {
// 后端未提供“批次 -> 商品ID列表”映射时,暂用行 id 作为占位
arrangeDialogRef.value?.open({
productIdList: [row.id],
title: '重排',
showAutoSwitch: false,
})
}
const handlePageSizeChange = (size: number) => {
......@@ -277,6 +337,7 @@ const refresh = () => {
}
onMounted(() => {
loadEmployeeList()
loadData()
})
......
......@@ -12,6 +12,7 @@
v-model="form.reason"
placeholder="请选择取消原因"
style="width: 100%"
clearable
>
<ElOption
v-for="item in cancelReasons"
......@@ -23,17 +24,19 @@
</ElFormItem>
</ElForm>
<template #footer>
<ElButton @click="visible = false">取消</ElButton>
<ElButton type="primary" :loading="submitLoading" @click="handleSubmit">
确认
</ElButton>
<div class="dialog-footer" style="text-align: center">
<ElButton @click="visible = false">取消</ElButton>
<ElButton type="primary" :loading="submitLoading" @click="handleSubmit">
确认
</ElButton>
</div>
</template>
</ElDialog>
</template>
<script setup lang="ts">
import { ref, reactive } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { ElMessage } from 'element-plus'
import type { FormInstance, FormRules } from 'element-plus'
import { cancelOrderWithReasonApi } from '@/api/factoryOrderNew'
......@@ -75,10 +78,8 @@ const handleSubmit = async () => {
ElMessage.success('取消订单成功')
visible.value = false
emit('success')
} catch (e: any) {
ElMessageBox.alert(e?.message || '取消订单失败', '取消订单失败', {
type: 'error',
})
} catch (e: unknown) {
console.error(e)
} finally {
submitLoading.value = false
}
......
......@@ -36,11 +36,24 @@
<div v-if="item.customizedQuantity" class="quantity-badge">
{{ item.customizedQuantity }}
</div>
<Icon name="caozuorizhi" style="width: 28px; height: 28px">
<template #title>
<title>操作日志</title>
</template>
</Icon>
<Icon name="chakanxiangqing">
<template #title>
<title>查看详情</title>
</template>
</Icon>
</template>
<template #info>
<div class="card-info-grid">
<div class="card-info-row full">
<span class="info-value ellipsis" :title="(item.productName as string) || ''">
<span
class="info-value ellipsis"
:title="(item.productName as string) || ''"
>
{{ item.productName }}
</span>
</div>
......
......@@ -58,6 +58,7 @@
:placeholder="placeholder"
readonly
clearable
:style="{ width: width }"
@clear="clearValue"
>
<template #suffix>
......@@ -81,6 +82,7 @@ const props = withDefaults(
options: ProductTypeGroup[]
multiple?: boolean
placeholder?: string
width?: string
}>(),
{
multiple: false,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment