提交
This commit is contained in:
commit
2caa3e0fa0
98
src/api/orderProcessPlan.ts
Normal file
98
src/api/orderProcessPlan.ts
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
import { request } from '@/utils/request'
|
||||||
|
|
||||||
|
// 工序计划 类型定义
|
||||||
|
export interface OrderProcessPlan {
|
||||||
|
id?: number
|
||||||
|
|
||||||
|
name?: string
|
||||||
|
|
||||||
|
code?: string
|
||||||
|
|
||||||
|
sort?: number
|
||||||
|
|
||||||
|
orderItemId?: number
|
||||||
|
|
||||||
|
beginTime?: string
|
||||||
|
|
||||||
|
endTime?: string
|
||||||
|
|
||||||
|
procurement?: number
|
||||||
|
|
||||||
|
outsource?: number
|
||||||
|
|
||||||
|
quantity?: number
|
||||||
|
|
||||||
|
transferNum?: number
|
||||||
|
|
||||||
|
transferOutNum?: number
|
||||||
|
|
||||||
|
createTime?: string
|
||||||
|
|
||||||
|
createBy?: string
|
||||||
|
|
||||||
|
qualityInspection?: number
|
||||||
|
|
||||||
|
storageEntry?: number
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 工序计划 API
|
||||||
|
export const orderProcessPlanApi = {
|
||||||
|
// 分页查询
|
||||||
|
page(params:any) { //{ page: number; pageSize: number; id?: number; name?: string; code?: string; orderItemId?: number }
|
||||||
|
return request({ url: '/biz/orderProcessPlan/page', method: 'get', params })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取详情
|
||||||
|
detail(id: string) {
|
||||||
|
return request({ url: `/biz/orderProcessPlan/${id}`, method: 'get' })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 新增
|
||||||
|
create(data: any) {
|
||||||
|
return request({ url: '/biz/orderProcessPlan', method: 'post', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 修改
|
||||||
|
update(data: any) {
|
||||||
|
return request({ url: '/biz/orderProcessPlan', method: 'put', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
delete(ids: string[]) {
|
||||||
|
return request({ url: `/biz/orderProcessPlan/${ids.join(',')}`, method: 'delete' })
|
||||||
|
},
|
||||||
|
|
||||||
|
//派工
|
||||||
|
assignWork(data: any) {
|
||||||
|
return request({ url: '/biz/orderProcessPlan/assignWork', method: 'put', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 导出
|
||||||
|
export(params?: { ids?: string[]; id?: number; name?: string; code?: string; orderItemId?: number }) {
|
||||||
|
const p: Record<string, any> = {}
|
||||||
|
if (params?.ids?.length) p.ids = params.ids.join(',')
|
||||||
|
if (params?.id !== undefined && params?.id !== null) p.id = params.id
|
||||||
|
if (params?.name !== undefined && params?.name !== null) p.name = params.name
|
||||||
|
if (params?.code !== undefined && params?.code !== null) p.code = params.code
|
||||||
|
if (params?.orderItemId !== undefined && params?.orderItemId !== null) p.orderItemId = params.orderItemId
|
||||||
|
return request({ url: `/biz/orderProcessPlan/export`, method: 'get', params: p, responseType: 'blob' })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 导入
|
||||||
|
importData(file: File) {
|
||||||
|
const formData = new FormData()
|
||||||
|
formData.append('file', file)
|
||||||
|
return request<{ success: number; fail: number; errors: string[] }>({
|
||||||
|
url: `/biz/orderProcessPlan/import`,
|
||||||
|
method: 'post',
|
||||||
|
data: formData,
|
||||||
|
headers: { 'Content-Type': 'multipart/form-data' }
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
// 下载导入模板
|
||||||
|
downloadTemplate() {
|
||||||
|
return request({ url: `/biz/orderProcessPlan/template`, method: 'get', responseType: 'blob' })
|
||||||
|
}
|
||||||
|
}
|
||||||
70
src/api/submitLog.ts
Normal file
70
src/api/submitLog.ts
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
import { request } from '@/utils/request'
|
||||||
|
|
||||||
|
// 派工工单汇报记录 类型定义
|
||||||
|
export interface SubmitLog {
|
||||||
|
id?: number
|
||||||
|
|
||||||
|
assingWorkId?: number
|
||||||
|
|
||||||
|
processId?: number
|
||||||
|
|
||||||
|
quantity?: number
|
||||||
|
|
||||||
|
createTime?: string
|
||||||
|
|
||||||
|
createBy?: string
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 派工工单汇报记录 API
|
||||||
|
export const submitLogApi = {
|
||||||
|
// 分页查询
|
||||||
|
page(params: { page: number; pageSize: number; id?: number }) {
|
||||||
|
return request({ url: '/biz/submitLog/page', method: 'get', params })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取详情
|
||||||
|
detail(id: string) {
|
||||||
|
return request({ url: `/biz/submitLog/${id}`, method: 'get' })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 新增
|
||||||
|
create(data: SubmitLog) {
|
||||||
|
return request({ url: '/biz/submitLog', method: 'post', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 修改
|
||||||
|
update(data: SubmitLog) {
|
||||||
|
return request({ url: '/biz/submitLog', method: 'put', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
delete(ids: string[]) {
|
||||||
|
return request({ url: `/biz/submitLog/${ids.join(',')}`, method: 'delete' })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 导出
|
||||||
|
export(params?: { ids?: string[]; id?: number }) {
|
||||||
|
const p: Record<string, any> = {}
|
||||||
|
if (params?.ids?.length) p.ids = params.ids.join(',')
|
||||||
|
if (params?.id !== undefined && params?.id !== null) p.id = params.id
|
||||||
|
return request({ url: `/biz/submitLog/export`, method: 'get', params: p, responseType: 'blob' })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 导入
|
||||||
|
importData(file: File) {
|
||||||
|
const formData = new FormData()
|
||||||
|
formData.append('file', file)
|
||||||
|
return request<{ success: number; fail: number; errors: string[] }>({
|
||||||
|
url: `/biz/submitLog/import`,
|
||||||
|
method: 'post',
|
||||||
|
data: formData,
|
||||||
|
headers: { 'Content-Type': 'multipart/form-data' }
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
// 下载导入模板
|
||||||
|
downloadTemplate() {
|
||||||
|
return request({ url: `/biz/submitLog/template`, method: 'get', responseType: 'blob' })
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -21,6 +21,7 @@
|
|||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
<n-date-picker
|
<n-date-picker
|
||||||
v-model:value="endTime"
|
v-model:value="endTime"
|
||||||
type="datetime"
|
type="datetime"
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
<n-form-item label="物料编码">
|
<n-form-item label="物料编码">
|
||||||
<n-input v-model:value="searchForm.code" placeholder="请输入物料编码" clearable />
|
<n-input v-model:value="searchForm.code" placeholder="请输入物料编码" clearable />
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
<n-form-item label="产品名称">
|
<n-form-item label="项目名称">
|
||||||
<n-input v-model:value="searchForm.projectName" placeholder="请输入产品名称" clearable />
|
<n-input v-model:value="searchForm.projectName" placeholder="请输入产品名称" clearable />
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
<n-form-item label="开始时间">
|
<n-form-item label="开始时间">
|
||||||
@ -69,7 +69,8 @@
|
|||||||
<n-data-table
|
<n-data-table
|
||||||
size="small"
|
size="small"
|
||||||
remote
|
remote
|
||||||
:bordere="false"
|
striped
|
||||||
|
:border="false"
|
||||||
:single-line="false"
|
:single-line="false"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
:data="tableData"
|
:data="tableData"
|
||||||
@ -99,6 +100,7 @@
|
|||||||
preset="card"
|
preset="card"
|
||||||
:title="modalTitle"
|
:title="modalTitle"
|
||||||
style="width: 900px"
|
style="width: 900px"
|
||||||
|
:mask-closable="false"
|
||||||
>
|
>
|
||||||
<n-form
|
<n-form
|
||||||
ref="formRef"
|
ref="formRef"
|
||||||
@ -108,9 +110,22 @@
|
|||||||
label-width="120px"
|
label-width="120px"
|
||||||
>
|
>
|
||||||
<n-grid :cols="2">
|
<n-grid :cols="2">
|
||||||
<n-gi>
|
<!-- <n-gi>
|
||||||
<n-form-item label="生产令号" path="productionCode">
|
<n-form-item label="生产令号" path="productionCode">
|
||||||
<n-input v-model:value="formData.productionCode" @input="gongxu" placeholder="请输入生产令号" />
|
<n-input v-if="formData.id" v-model:value="formData.productionCode" placeholder="请输入生产令号" />
|
||||||
|
<n-input v-else v-model:value="formData.productionCode" @input="gongxu" placeholder="请输入生产令号" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi> -->
|
||||||
|
<n-gi>
|
||||||
|
<n-form-item label="项目名称" path="projectName">
|
||||||
|
<n-input v-if="formData.id" v-model:value="formData.projectName" disabled placeholder="请选择项目名称" />
|
||||||
|
<n-input v-else v-model:value="formData.projectName" placeholder="请选择产品名称" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi>
|
||||||
|
<n-form-item label="物料编码" path="code">
|
||||||
|
<n-input v-if="formData.id" v-model:value="formData.code" disabled placeholder="请选择物料编码" />
|
||||||
|
<n-input v-else v-model:value="formData.code" placeholder="请选择物料编码" />
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
</n-gi>
|
</n-gi>
|
||||||
<n-gi>
|
<n-gi>
|
||||||
@ -118,30 +133,19 @@
|
|||||||
<n-input v-model:value="formData.name" placeholder="请输入物料名称" />
|
<n-input v-model:value="formData.name" placeholder="请输入物料名称" />
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
</n-gi>
|
</n-gi>
|
||||||
<n-gi>
|
|
||||||
<n-form-item label="物料编码" path="code">
|
|
||||||
<n-input v-if="formData.productionCode" v-model:value="formData.code" placeholder="请输入物料编码" />
|
|
||||||
<n-input v-else v-model:value="formData.code" placeholder="请输入物料编码" disabled />
|
|
||||||
</n-form-item>
|
|
||||||
</n-gi>
|
|
||||||
<n-gi>
|
<n-gi>
|
||||||
<n-form-item label="产品序列" path="sort">
|
<n-form-item label="产品序列" path="sort">
|
||||||
<n-input v-if="formData.productionCode" v-model:value="formData.sort" placeholder="请输入产品序列" />
|
<n-input v-if="formData.id" v-model:value="formData.sort" placeholder="请输入产品序列" />
|
||||||
<n-input v-else v-model:value="formData.sort" placeholder="请输入产品序列" disabled />
|
<n-input v-else v-model:value="formData.sort" placeholder="请输入产品序列" />
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
</n-gi>
|
</n-gi>
|
||||||
<n-gi>
|
<n-gi>
|
||||||
<n-form-item label="生产数量" path="quantity">
|
<n-form-item label="生产数量" path="quantity">
|
||||||
<n-input v-if="formData.productionCode" v-model:value="formData.quantity" placeholder="请输入生产数量" />
|
<n-input v-if="formData.id" v-model:value="formData.quantity" disabled placeholder="请输入生产数量" />
|
||||||
<n-input v-else v-model:value="formData.quantity" placeholder="请输入生产数量" disabled />
|
<n-input v-else v-model:value="formData.quantity" placeholder="请输入生产数量" disabled />
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
</n-gi>
|
</n-gi>
|
||||||
<n-gi>
|
|
||||||
<n-form-item label="产品名称" path="projectName">
|
|
||||||
<n-input v-if="formData.productionCode" v-model:value="formData.projectName" placeholder="请输入产品名称" />
|
|
||||||
<n-input v-else v-model:value="formData.projectName" placeholder="请输入产品名称" disabled />
|
|
||||||
</n-form-item>
|
|
||||||
</n-gi>
|
|
||||||
<n-gi>
|
<n-gi>
|
||||||
<n-form-item label="是否半成品" path="sfProduct">
|
<n-form-item label="是否半成品" path="sfProduct">
|
||||||
<n-radio-group v-model:value="formData.sfProduct" name="radiogroup">
|
<n-radio-group v-model:value="formData.sfProduct" name="radiogroup">
|
||||||
@ -199,33 +203,39 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="sort-target">
|
<tbody class="sort-target">
|
||||||
<gxitem
|
<!-- <gxitem
|
||||||
v-for="(n,i) in planList"
|
v-for="(n,i) in planList"
|
||||||
:obj="n"
|
:obj="n"
|
||||||
:index="i"
|
:index="i"
|
||||||
@update="gxupdata"
|
@update="gxupdata"
|
||||||
/>
|
/> -->
|
||||||
<!-- <tr v-for="(n,i) in planList" :key="n.name" class="cursor-move" :style="{
|
<tr
|
||||||
|
v-for="(n,i) in planList"
|
||||||
|
:key="i"
|
||||||
|
class="cursor-move"
|
||||||
|
:style="{
|
||||||
height: '40px',
|
height: '40px',
|
||||||
}">
|
background:isEven(i)?'#fff':'#f3f3f3'
|
||||||
<td>{{ n.code }}{{n.}}</td>
|
}"
|
||||||
|
>
|
||||||
|
<td>{{ n.code }}{{n.sort}}</td>
|
||||||
<td>{{ n.name }}</td>
|
<td>{{ n.name }}</td>
|
||||||
<td>{{ n.orderItemName }}</td>
|
<td>{{ n.orderItemName }}</td>
|
||||||
<td>
|
<td>
|
||||||
<n-date-picker
|
<n-date-picker
|
||||||
v-model:value="gxsdate"
|
v-model:value="n.beginTime"
|
||||||
type="datetime"
|
type="datetime"
|
||||||
style="width: 100%;"
|
style="width: 100%;"
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<n-date-picker
|
<n-date-picker
|
||||||
v-model:value="gxsdate1"
|
v-model:value="n.endTime"
|
||||||
type="datetime"
|
type="datetime"
|
||||||
style="width: 100%;"
|
style="width: 100%;"
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
</tr> -->
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</VueDraggable>
|
</VueDraggable>
|
||||||
@ -254,16 +264,30 @@
|
|||||||
label-placement="top"
|
label-placement="top"
|
||||||
label-width="80"
|
label-width="80"
|
||||||
>
|
>
|
||||||
<n-form-item label="产品名称">
|
<n-form-item label="工单名称">
|
||||||
<n-input v-model:value="dispatchform.id" disabled />
|
<n-input v-model:value="dispatchform.name" disabled />
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
<n-form-item label="指派员工" path="userid">
|
<n-form-item label="指派员工" path="userid">
|
||||||
<n-select
|
<!-- <n-select
|
||||||
v-model:value="dispatchform.userid"
|
v-model:value="dispatchform.userid"
|
||||||
:options="yglist"
|
:options="yglist"
|
||||||
clearable
|
clearable
|
||||||
placeholder="请选择员工"
|
placeholder="请选择员工"
|
||||||
|
/> -->
|
||||||
|
|
||||||
|
<n-select
|
||||||
|
v-model:value="dispatchform.userid"
|
||||||
|
|
||||||
|
filterable
|
||||||
|
placeholder="请输入用户名称搜索"
|
||||||
|
:options="yglist"
|
||||||
|
:loading="loadingRef"
|
||||||
|
clearable
|
||||||
|
remote
|
||||||
|
:clear-filter-after-select="false"
|
||||||
|
@search="slehand"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- <n-input v-model:value="dispatchform.userid" placeholder="请选择员工" /> -->
|
<!-- <n-input v-model:value="dispatchform.userid" placeholder="请选择员工" /> -->
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
</n-form>
|
</n-form>
|
||||||
@ -348,7 +372,10 @@ import { useUserStore } from '@/stores/user'
|
|||||||
|
|
||||||
import { VueDraggable } from 'vue-draggable-plus'
|
import { VueDraggable } from 'vue-draggable-plus'
|
||||||
|
|
||||||
import Gxitem from './gxitem.vue'
|
// import Gxitem from './gxitem.vue'
|
||||||
|
|
||||||
|
|
||||||
|
import { userApi } from '@/api/system'
|
||||||
|
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const dialog = useDialog()
|
const dialog = useDialog()
|
||||||
@ -356,7 +383,9 @@ const dialog = useDialog()
|
|||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
|
|
||||||
|
|
||||||
|
function isEven(num:any) {
|
||||||
|
return num % 2 == 0
|
||||||
|
}
|
||||||
|
|
||||||
// 权限检查
|
// 权限检查
|
||||||
const hasPermission = (permission: string) => userStore.hasPermission(permission)
|
const hasPermission = (permission: string) => userStore.hasPermission(permission)
|
||||||
@ -422,9 +451,9 @@ const formRules = {
|
|||||||
|
|
||||||
// 表格列
|
// 表格列
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
// {
|
||||||
type: 'selection'
|
// type: 'selection'
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
align:'center',
|
align:'center',
|
||||||
minWidth: 150,
|
minWidth: 150,
|
||||||
@ -647,14 +676,10 @@ function tuozChange() {
|
|||||||
console.log(planList.value)
|
console.log(planList.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
function gxupdata(v:any) {
|
// function gxupdata(v:any) {
|
||||||
console.log(planList.value,'planList')
|
// console.log(planList.value,'planList')
|
||||||
console.log(v,'gx')
|
// console.log(v,'gx')
|
||||||
}
|
// }
|
||||||
|
|
||||||
let gxsdate = ref(null)
|
|
||||||
|
|
||||||
let gxsdate1 = ref(null)
|
|
||||||
|
|
||||||
|
|
||||||
// 新增
|
// 新增
|
||||||
@ -699,7 +724,6 @@ function handleEdit(row: OrderItem) {
|
|||||||
// 提交
|
// 提交
|
||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
|
|
||||||
console.log(planList.value,'planList')
|
|
||||||
await formRef.value?.validate()
|
await formRef.value?.validate()
|
||||||
try {
|
try {
|
||||||
const submitData = { ...formData } as OrderItem
|
const submitData = { ...formData } as OrderItem
|
||||||
@ -725,6 +749,12 @@ async function handleSubmit() {
|
|||||||
submitData.assingWorkOperationTime = new Date(submitData.assingWorkOperationTime).toISOString().slice(0, 19).replace('T', ' ')
|
submitData.assingWorkOperationTime = new Date(submitData.assingWorkOperationTime).toISOString().slice(0, 19).replace('T', ' ')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (submitData.id) {
|
||||||
|
await orderItemApi.update(submitData)
|
||||||
|
message.success('修改成功')
|
||||||
|
} else {
|
||||||
let savedata = Object.assign(
|
let savedata = Object.assign(
|
||||||
{},
|
{},
|
||||||
submitData,
|
submitData,
|
||||||
@ -732,11 +762,6 @@ async function handleSubmit() {
|
|||||||
planList:planList.value
|
planList:planList.value
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
if (submitData.id) {
|
|
||||||
await orderItemApi.update(savedata)
|
|
||||||
message.success('修改成功')
|
|
||||||
} else {
|
|
||||||
await orderItemApi.create(savedata)
|
await orderItemApi.create(savedata)
|
||||||
message.success('新增成功')
|
message.success('新增成功')
|
||||||
}
|
}
|
||||||
@ -751,19 +776,12 @@ async function handleSubmit() {
|
|||||||
let dispatchmodal = ref(false)
|
let dispatchmodal = ref(false)
|
||||||
let dispatchform = reactive<any>({
|
let dispatchform = reactive<any>({
|
||||||
id:'',
|
id:'',
|
||||||
userid:''
|
name:'',
|
||||||
|
userid:'',
|
||||||
|
username:''
|
||||||
})
|
})
|
||||||
|
|
||||||
let yglist = ref<any>([
|
let yglist = ref<any>([])
|
||||||
{
|
|
||||||
label: '张三',
|
|
||||||
value: '1'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '李四',
|
|
||||||
value: '2'
|
|
||||||
}
|
|
||||||
])
|
|
||||||
|
|
||||||
const dispatchrules = {
|
const dispatchrules = {
|
||||||
userid:[{ required: true, message: '请选择员工', trigger: 'blur' }]
|
userid:[{ required: true, message: '请选择员工', trigger: 'blur' }]
|
||||||
@ -773,14 +791,41 @@ let dispatchddbtn = ref(false)
|
|||||||
|
|
||||||
const dispatchformRef = ref()
|
const dispatchformRef = ref()
|
||||||
|
|
||||||
|
let loadingRef = ref(false)
|
||||||
|
|
||||||
|
function slehand(v?:any) {
|
||||||
|
loadingRef.value = true
|
||||||
|
userApi.page({
|
||||||
|
page: 1,
|
||||||
|
pageSize: 100,
|
||||||
|
username: v,
|
||||||
|
}).then((rps:any) =>{
|
||||||
|
if(rps.list && rps.list.length > 0){
|
||||||
|
yglist.value = rps.list.map((n:any) => {
|
||||||
|
return {
|
||||||
|
label:n.username,
|
||||||
|
value:n.id+''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
console.log(yglist.value,'12')
|
||||||
|
loadingRef.value = false
|
||||||
|
}).catch(() => {
|
||||||
|
loadingRef.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function disphand(v:any){
|
function disphand(v:any){
|
||||||
dispatchmodal.value = true
|
dispatchmodal.value = true
|
||||||
dispatchformRef.value?.restoreValidation()
|
dispatchformRef.value?.restoreValidation()
|
||||||
dispatchform.id = v.id
|
dispatchform.id = v.id
|
||||||
|
dispatchform.name = v.name
|
||||||
dispatchform.userid = ''
|
dispatchform.userid = ''
|
||||||
|
slehand()
|
||||||
}
|
}
|
||||||
|
|
||||||
function dispatchSubmit() {
|
function dispatchSubmit() {
|
||||||
|
console.log(dispatchform.userid,'dispatchform.userid')
|
||||||
dispatchformRef.value?.validate((v:any) => {
|
dispatchformRef.value?.validate((v:any) => {
|
||||||
if(!v){
|
if(!v){
|
||||||
// dispatchLoading.value = true
|
// dispatchLoading.value = true
|
||||||
|
|||||||
946
src/views/biz/orderProcessPlan/index.vue
Normal file
946
src/views/biz/orderProcessPlan/index.vue
Normal file
@ -0,0 +1,946 @@
|
|||||||
|
<template>
|
||||||
|
<div class="page-container">
|
||||||
|
<n-card>
|
||||||
|
<!-- 搜索表单 -->
|
||||||
|
<div class="search-form">
|
||||||
|
<n-form inline :model="searchForm" label-placement="left">
|
||||||
|
<!-- <n-form-item label="主键">
|
||||||
|
<n-input v-model:value="searchForm.id" placeholder="请输入主键" clearable />
|
||||||
|
</n-form-item> -->
|
||||||
|
<n-form-item label="工序名称">
|
||||||
|
<n-input v-model:value="searchForm.name" placeholder="请输入工序名称" clearable />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="工序编码">
|
||||||
|
<n-input v-model:value="searchForm.code" placeholder="请输入工序编码" clearable />
|
||||||
|
</n-form-item>
|
||||||
|
<!-- <n-form-item label="生产订单">
|
||||||
|
<n-input v-model:value="searchForm.orderItemId" placeholder="请输入生产订单id" clearable />
|
||||||
|
</n-form-item> -->
|
||||||
|
<n-form-item>
|
||||||
|
<n-space>
|
||||||
|
<n-button type="primary" @click="handleSearch">
|
||||||
|
<template #icon><n-icon><SearchOutline /></n-icon></template>
|
||||||
|
搜索
|
||||||
|
</n-button>
|
||||||
|
<n-button @click="handleReset">
|
||||||
|
<template #icon><n-icon><RefreshOutline /></n-icon></template>
|
||||||
|
重置
|
||||||
|
</n-button>
|
||||||
|
</n-space>
|
||||||
|
</n-form-item>
|
||||||
|
</n-form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 工具栏 -->
|
||||||
|
<div class="table-toolbar">
|
||||||
|
<n-space>
|
||||||
|
<n-button type="primary" @click="handleAdd" size="small">
|
||||||
|
<template #icon><n-icon><AddOutline /></n-icon></template>
|
||||||
|
新增
|
||||||
|
</n-button>
|
||||||
|
<n-button type="error" :disabled="selectedIds.length === 0" @click="handleBatchDelete" size="small">
|
||||||
|
<template #icon><n-icon><TrashOutline /></n-icon></template>
|
||||||
|
删除
|
||||||
|
</n-button>
|
||||||
|
</n-space>
|
||||||
|
<n-button-group size="large">
|
||||||
|
<n-button type="success" @click="importModalVisible = true" size="small">
|
||||||
|
<template #icon><n-icon><CloudUploadOutline /></n-icon></template>
|
||||||
|
导入
|
||||||
|
</n-button>
|
||||||
|
<n-button @click="handleExport" size="small">
|
||||||
|
<template #icon><n-icon><DownloadOutline /></n-icon></template>
|
||||||
|
导出{{ selectedIds.length > 0 ? `(${selectedIds.length})` : '' }}
|
||||||
|
</n-button>
|
||||||
|
</n-button-group>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 表格 -->
|
||||||
|
<n-data-table
|
||||||
|
size="small"
|
||||||
|
remote
|
||||||
|
:border="false"
|
||||||
|
:single-line="false"
|
||||||
|
striped
|
||||||
|
:columns="columns"
|
||||||
|
:data="tableData"
|
||||||
|
:loading="loading"
|
||||||
|
/>
|
||||||
|
<div class="pagination-container" style="display: flex; justify-content: flex-end; margin-top: 12px">
|
||||||
|
<n-pagination
|
||||||
|
v-model:page="pagination.page"
|
||||||
|
v-model:page-size="pagination.pageSize"
|
||||||
|
:item-count="pagination.itemCount"
|
||||||
|
:page-sizes="[10, 20, 50, 100]"
|
||||||
|
show-size-picker
|
||||||
|
show-quick-jumper
|
||||||
|
@update:page="handlePageChange"
|
||||||
|
@update:page-size="handlePageSizeChange"
|
||||||
|
>
|
||||||
|
<template #prefix>
|
||||||
|
共 {{ pagination.itemCount }} 条
|
||||||
|
</template>
|
||||||
|
</n-pagination>
|
||||||
|
</div>
|
||||||
|
<!-- :pagination="pagination"
|
||||||
|
:row-key="(row:any) => row.id"
|
||||||
|
@update:page="handlePageChange"
|
||||||
|
@update:page-size="handlePageSizeChange"
|
||||||
|
@update:checked-row-keys="handleCheck"
|
||||||
|
-->
|
||||||
|
|
||||||
|
</n-card>
|
||||||
|
|
||||||
|
<!-- 新增/编辑弹窗 -->
|
||||||
|
<n-modal
|
||||||
|
v-model:show="modalVisible"
|
||||||
|
preset="card"
|
||||||
|
:title="modalTitle"
|
||||||
|
style="width: 800px"
|
||||||
|
>
|
||||||
|
<n-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="formData"
|
||||||
|
:rules="formRules"
|
||||||
|
label-placement="left"
|
||||||
|
label-width="120px"
|
||||||
|
>
|
||||||
|
<n-grid :cols="2">
|
||||||
|
<n-gi>
|
||||||
|
<n-form-item label="工序名称" path="name">
|
||||||
|
<n-input v-model:value="formData.name" placeholder="请输入工序名称" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi>
|
||||||
|
<n-form-item label="工序编码" path="code">
|
||||||
|
<n-input v-model:value="formData.code" placeholder="请输入工序编码" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi>
|
||||||
|
<n-form-item label="工序顺序" path="sort">
|
||||||
|
<n-input v-model:value="formData.sort" placeholder="请输入工序顺序" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi>
|
||||||
|
<n-form-item label="生产订单id" path="orderItemId">
|
||||||
|
<n-input v-model:value="formData.orderItemId" placeholder="请输入生产订单id" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi>
|
||||||
|
<n-form-item label="生产开始时间" path="beginTime">
|
||||||
|
<n-date-picker v-model:value="formData.beginTime" type="datetime" clearable style="width: 100%" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi>
|
||||||
|
<n-form-item label="生产结束时间" path="endTime">
|
||||||
|
<n-date-picker v-model:value="formData.endTime" type="datetime" clearable style="width: 100%" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi>
|
||||||
|
<n-form-item label="是否采购" path="procurement">
|
||||||
|
<n-radio-group v-model:value="formData.procurement">
|
||||||
|
<n-space>
|
||||||
|
<n-radio v-for="opt in procurementOptions" :key="opt.value" :value="opt.value">{{ opt.label }}</n-radio>
|
||||||
|
</n-space>
|
||||||
|
</n-radio-group>
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi>
|
||||||
|
<n-form-item label="是否委外" path="outsource">
|
||||||
|
<n-radio-group v-model:value="formData.outsource">
|
||||||
|
<n-space>
|
||||||
|
<n-radio v-for="opt in outsourceOptions" :key="opt.value" :value="opt.value">{{ opt.label }}</n-radio>
|
||||||
|
</n-space>
|
||||||
|
</n-radio-group>
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi>
|
||||||
|
<n-form-item label="生产总数" path="quantity">
|
||||||
|
<n-input v-model:value="formData.quantity" placeholder="请输入生产总数" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi>
|
||||||
|
<n-form-item label="转入数量" path="transferNum">
|
||||||
|
<n-input v-model:value="formData.transferNum" placeholder="请输入转入数量" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi>
|
||||||
|
<n-form-item label="转出数量" path="transferOutNum">
|
||||||
|
<n-input v-model:value="formData.transferOutNum" placeholder="请输入转出数量" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi>
|
||||||
|
<n-form-item label="是否质检" path="qualityInspection">
|
||||||
|
<n-radio-group v-model:value="formData.qualityInspection">
|
||||||
|
<n-space>
|
||||||
|
<n-radio v-for="opt in qualityInspectionOptions" :key="opt.value" :value="opt.value">{{ opt.label }}</n-radio>
|
||||||
|
</n-space>
|
||||||
|
</n-radio-group>
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi>
|
||||||
|
<n-form-item label="是否直接入库" path="storageEntry">
|
||||||
|
<n-radio-group v-model:value="formData.storageEntry">
|
||||||
|
<n-space>
|
||||||
|
<n-radio v-for="opt in storageEntryOptions" :key="opt.value" :value="opt.value">{{ opt.label }}</n-radio>
|
||||||
|
</n-space>
|
||||||
|
</n-radio-group>
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
</n-grid>
|
||||||
|
</n-form>
|
||||||
|
<template #footer>
|
||||||
|
<n-space justify="end">
|
||||||
|
<n-button @click="modalVisible = false">取消</n-button>
|
||||||
|
<n-button type="primary" @click="handleSubmit">确定</n-button>
|
||||||
|
</n-space>
|
||||||
|
</template>
|
||||||
|
</n-modal>
|
||||||
|
|
||||||
|
<!--派工弹框-->
|
||||||
|
<n-modal
|
||||||
|
v-model:show="dispatchmodal"
|
||||||
|
title="派工"
|
||||||
|
preset="card"
|
||||||
|
style="width: 800px"
|
||||||
|
:mask-closable="false"
|
||||||
|
>
|
||||||
|
<n-form
|
||||||
|
ref="dispatchformRef"
|
||||||
|
:model="dispatchform"
|
||||||
|
label-placement="left"
|
||||||
|
:inline="true"
|
||||||
|
:rules="dispatchrules"
|
||||||
|
label-width="80"
|
||||||
|
>
|
||||||
|
<n-grid :cols="2">
|
||||||
|
<n-gi>
|
||||||
|
<n-form-item label="工序名称">
|
||||||
|
<n-input v-model:value="dispatchform.name" disabled />
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi>
|
||||||
|
<n-form-item label="生产数量">
|
||||||
|
<n-input v-model:value="dispatchform.quantity" disabled />
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi>
|
||||||
|
<n-form-item label="开始时间">
|
||||||
|
<n-input v-model:value="dispatchform.beginTime" disabled />
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi>
|
||||||
|
<n-form-item label="结束时间">
|
||||||
|
<n-input v-model:value="dispatchform.endTime" disabled />
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<!-- <pgitem
|
||||||
|
v-for="(n,i) in dispatchform.userlist"
|
||||||
|
:obj="n"
|
||||||
|
:index="i"
|
||||||
|
@addhand="addpgnum"
|
||||||
|
@delehand="deletenum(i)"
|
||||||
|
/> -->
|
||||||
|
<n-gi :span="24">
|
||||||
|
<pgitem
|
||||||
|
v-for="(n,i) in dispatchform.list"
|
||||||
|
:obj="n"
|
||||||
|
:index="i"
|
||||||
|
:key="i"
|
||||||
|
listname="list"
|
||||||
|
@addhand="addpgnum"
|
||||||
|
@delehand="deletenum(i)"
|
||||||
|
/>
|
||||||
|
<!-- <n-grid :cols="8">
|
||||||
|
<template v-for="(n,i) in dispatchform.userlist">
|
||||||
|
<n-gi :span="8">
|
||||||
|
<n-form-item
|
||||||
|
label="指派员工"
|
||||||
|
:rule="{
|
||||||
|
required: true,
|
||||||
|
message: '请选择员工',
|
||||||
|
trigger: 'blur'
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
|
||||||
|
<n-select
|
||||||
|
v-model:value="n.id"
|
||||||
|
filterable
|
||||||
|
placeholder="请输入用户名称搜索"
|
||||||
|
:options="yglist"
|
||||||
|
:loading="loadingRef"
|
||||||
|
clearable
|
||||||
|
remote
|
||||||
|
:clear-filter-after-select="false"
|
||||||
|
@search="slehand"
|
||||||
|
/>
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi :span="8">
|
||||||
|
<n-form-item
|
||||||
|
label="数量"
|
||||||
|
:rule="{
|
||||||
|
required: true,
|
||||||
|
message: `请输入数量`,
|
||||||
|
trigger: ['input', 'blur'],
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<n-input v-model:value="n.num" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi :span="8" style="padding-left:10px;">
|
||||||
|
<n-icon
|
||||||
|
v-if="i == 0"
|
||||||
|
size="25"
|
||||||
|
style="padding-top: 5px;cursor: pointer;" color="#1060c9"
|
||||||
|
@click="addpgnum"
|
||||||
|
>
|
||||||
|
<AddOutline />
|
||||||
|
</n-icon>
|
||||||
|
|
||||||
|
<n-icon
|
||||||
|
v-else
|
||||||
|
size="18"
|
||||||
|
style="padding:7px 0 0 2px;cursor: pointer;" color="#d03050"
|
||||||
|
@click="deletenum(i)"
|
||||||
|
>
|
||||||
|
<TrashOutline />
|
||||||
|
</n-icon>
|
||||||
|
</n-gi>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
</n-grid> -->
|
||||||
|
</n-gi>
|
||||||
|
</n-grid>
|
||||||
|
|
||||||
|
|
||||||
|
</n-form>
|
||||||
|
<template #footer>
|
||||||
|
<n-space justify="end">
|
||||||
|
<n-button size="small" @click="dispatchmodal = false">取消</n-button>
|
||||||
|
<n-button
|
||||||
|
size="small"
|
||||||
|
type="primary"
|
||||||
|
:loading="dispatchLoading"
|
||||||
|
@click="dispatchSubmit"
|
||||||
|
:disabled="dispatchddbtn"
|
||||||
|
>确定</n-button>
|
||||||
|
</n-space>
|
||||||
|
</template>
|
||||||
|
</n-modal>
|
||||||
|
|
||||||
|
<!-- 导入弹窗 -->
|
||||||
|
<n-modal v-model:show="importModalVisible" preset="card" title="导入工序计划" style="width: 500px">
|
||||||
|
<n-space vertical>
|
||||||
|
<n-alert type="info">
|
||||||
|
<template #header>导入说明</template>
|
||||||
|
<ul style="margin: 0; padding-left: 16px; line-height: 1.8">
|
||||||
|
<li>请先下载导入模板,按模板格式填写数据</li>
|
||||||
|
<li>支持 .xlsx 或 .xls 格式</li>
|
||||||
|
</ul>
|
||||||
|
</n-alert>
|
||||||
|
<n-space>
|
||||||
|
<n-button type="primary" @click="handleDownloadTemplate">
|
||||||
|
<template #icon><n-icon><DownloadOutline /></n-icon></template>
|
||||||
|
下载模板
|
||||||
|
</n-button>
|
||||||
|
</n-space>
|
||||||
|
<n-upload :max="1" accept=".xlsx,.xls" :show-file-list="true" :custom-request="handleImportUpload">
|
||||||
|
<n-upload-dragger>
|
||||||
|
<div style="margin-bottom: 12px">
|
||||||
|
<n-icon size="48" :depth="3"><CloudUploadOutline /></n-icon>
|
||||||
|
</div>
|
||||||
|
<n-text style="font-size: 16px">点击或拖拽文件到此处上传</n-text>
|
||||||
|
<n-p depth="3" style="margin: 8px 0 0 0">支持 .xlsx 或 .xls 格式</n-p>
|
||||||
|
</n-upload-dragger>
|
||||||
|
</n-upload>
|
||||||
|
</n-space>
|
||||||
|
<template #footer>
|
||||||
|
<n-button @click="importModalVisible = false">关闭</n-button>
|
||||||
|
</template>
|
||||||
|
</n-modal>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
ref,
|
||||||
|
reactive,
|
||||||
|
h,
|
||||||
|
onMounted
|
||||||
|
} from 'vue'
|
||||||
|
import {
|
||||||
|
NButton,
|
||||||
|
NSpace,
|
||||||
|
NIcon,
|
||||||
|
NUpload,
|
||||||
|
useMessage,
|
||||||
|
useDialog,
|
||||||
|
//type DataTableColumns,
|
||||||
|
type UploadCustomRequestOptions
|
||||||
|
} from 'naive-ui'
|
||||||
|
import {
|
||||||
|
SearchOutline,
|
||||||
|
RefreshOutline,
|
||||||
|
AddOutline,
|
||||||
|
TrashOutline,
|
||||||
|
//CreateOutline,
|
||||||
|
CloudUploadOutline,
|
||||||
|
DownloadOutline
|
||||||
|
} from '@vicons/ionicons5'
|
||||||
|
import {
|
||||||
|
orderProcessPlanApi,
|
||||||
|
type OrderProcessPlan
|
||||||
|
} from '@/api/orderProcessPlan'
|
||||||
|
import { dictDataApi } from '@/api/org'
|
||||||
|
|
||||||
|
import Pgitem from './pgitem.vue'
|
||||||
|
|
||||||
|
//import { userApi } from '@/api/system'
|
||||||
|
|
||||||
|
import { useUserStore } from '@/stores/user'
|
||||||
|
const userStore = useUserStore()
|
||||||
|
// 权限检查
|
||||||
|
const hasPermission = (permission: string) => userStore.hasPermission(permission)
|
||||||
|
|
||||||
|
const message = useMessage()
|
||||||
|
const dialog = useDialog()
|
||||||
|
|
||||||
|
// 搜索表单
|
||||||
|
const searchForm = reactive<any>({
|
||||||
|
id: '',
|
||||||
|
name: '',
|
||||||
|
code: '',
|
||||||
|
orderItemId: '',
|
||||||
|
})
|
||||||
|
|
||||||
|
// 表格数据
|
||||||
|
const tableData = ref<OrderProcessPlan[]>([])
|
||||||
|
const loading = ref(false)
|
||||||
|
const selectedIds = ref<number[]>([])
|
||||||
|
const pagination = reactive({
|
||||||
|
page: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
itemCount: 0,
|
||||||
|
showSizePicker: true,
|
||||||
|
pageSizes: [10, 20, 50]
|
||||||
|
})
|
||||||
|
|
||||||
|
// 弹窗
|
||||||
|
const modalVisible = ref(false)
|
||||||
|
const modalTitle = ref('')
|
||||||
|
const importModalVisible = ref(false)
|
||||||
|
const formRef = ref()
|
||||||
|
const defaultFormData = {
|
||||||
|
name: '',
|
||||||
|
code: '',
|
||||||
|
sort: '',
|
||||||
|
orderItemId: '',
|
||||||
|
beginTime: null,
|
||||||
|
endTime: null,
|
||||||
|
procurement: '',
|
||||||
|
outsource: '',
|
||||||
|
quantity: '',
|
||||||
|
transferNum: '',
|
||||||
|
transferOutNum: '',
|
||||||
|
qualityInspection: '',
|
||||||
|
storageEntry: '',
|
||||||
|
}
|
||||||
|
const formData = reactive<any>({ ...defaultFormData })
|
||||||
|
|
||||||
|
// 字典选项(下拉框/单选框/复选框关联字典时使用)
|
||||||
|
const procurementOptions = ref<{ label: string; value: any }[]>([])
|
||||||
|
const outsourceOptions = ref<{ label: string; value: any }[]>([])
|
||||||
|
const qualityInspectionOptions = ref<{ label: string; value: any }[]>([])
|
||||||
|
const storageEntryOptions = ref<{ label: string; value: any }[]>([])
|
||||||
|
|
||||||
|
// 表单校验规则
|
||||||
|
const formRules = {
|
||||||
|
}
|
||||||
|
|
||||||
|
// 表格列
|
||||||
|
const columns = [
|
||||||
|
// { type: 'selection' },
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
minWidth: 150,
|
||||||
|
title: '工序名称',
|
||||||
|
key: 'name'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
minWidth: 150,
|
||||||
|
title: '工序编码',
|
||||||
|
key: 'code'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
minWidth: 150,
|
||||||
|
title: '工序顺序',
|
||||||
|
key: 'sort'
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// align:'center',
|
||||||
|
// minWidth: 150,
|
||||||
|
// title: '生产订单id',
|
||||||
|
// key: 'orderItemId'
|
||||||
|
// },
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
minWidth: 150,
|
||||||
|
title: '生产开始时间',
|
||||||
|
key: 'beginTime'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
minWidth: 150,
|
||||||
|
title: '生产结束时间',
|
||||||
|
key: 'endTime'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
minWidth: 150,
|
||||||
|
title: '是否采购',
|
||||||
|
key: 'procurement',
|
||||||
|
render(row) {
|
||||||
|
const val = row.procurement
|
||||||
|
const opt = procurementOptions.value.find(o => o.value === val || String(o.value) === String(val))
|
||||||
|
return opt ? opt.label : (val ?? '-')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
minWidth: 150,
|
||||||
|
title: '是否委外',
|
||||||
|
key: 'outsource',
|
||||||
|
render(row) {
|
||||||
|
const val = row.outsource
|
||||||
|
const opt = outsourceOptions.value.find(o => o.value === val || String(o.value) === String(val))
|
||||||
|
return opt ? opt.label : (val ?? '-')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
minWidth: 150,
|
||||||
|
title: '生产总数',
|
||||||
|
key: 'quantity'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
minWidth: 150,
|
||||||
|
title: '转入数量',
|
||||||
|
key: 'transferNum'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
minWidth: 150,
|
||||||
|
title: '转出数量',
|
||||||
|
key: 'transferOutNum'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
minWidth: 150,
|
||||||
|
title: '是否质检',
|
||||||
|
key: 'qualityInspection',
|
||||||
|
render(row) {
|
||||||
|
const val = row.qualityInspection
|
||||||
|
const opt = qualityInspectionOptions.value.find(o => o.value === val || String(o.value) === String(val))
|
||||||
|
return opt ? opt.label : (val ?? '-')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
minWidth: 150,
|
||||||
|
title: '是否直接入库',
|
||||||
|
key: 'storageEntry',
|
||||||
|
render(row) {
|
||||||
|
const val = row.storageEntry
|
||||||
|
const opt = storageEntryOptions.value.find(o => o.value === val || String(o.value) === String(val))
|
||||||
|
return opt ? opt.label : (val ?? '-')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align:'center',
|
||||||
|
title: '操作',
|
||||||
|
key: 'actions',
|
||||||
|
width: 140,
|
||||||
|
fixed: 'right',
|
||||||
|
render(row) {
|
||||||
|
|
||||||
|
const buttons:any = []
|
||||||
|
|
||||||
|
if(hasPermission('biz:orderItem:edit')){
|
||||||
|
buttons.push(h(NButton, {
|
||||||
|
size: 'small',
|
||||||
|
type:'primary',
|
||||||
|
ghost:true,
|
||||||
|
onClick: () => { handleEdit(row) } },
|
||||||
|
//{ default: () => [h(NIcon, null, { default: () => h(CreateOutline) }), ' 编辑' ]}
|
||||||
|
{ default: () => '编辑'}
|
||||||
|
))
|
||||||
|
}
|
||||||
|
if(hasPermission('biz:orderItem:assign')){
|
||||||
|
buttons.push(h(NButton, {
|
||||||
|
size: 'small',
|
||||||
|
type:'success',
|
||||||
|
ghost:true,
|
||||||
|
onClick: () => { disphand(row) } },
|
||||||
|
{ default: () => '派工'}
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
return buttons.length > 0 ? h(NSpace, {justify:'center'}, { default: () => buttons }) : '-'
|
||||||
|
|
||||||
|
// return h('div', { style: { display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'nowrap' } }, [
|
||||||
|
// h(NButton, { size: 'small', quaternary: true, onClick: () => handleEdit(row) }, {
|
||||||
|
// default: () => [h(NIcon, null, { default: () => h(CreateOutline) }), ' 编辑']
|
||||||
|
// }),
|
||||||
|
// h(NButton, { size: 'small', quaternary: true, type: 'error', onClick: () => handleDelete(row) }, {
|
||||||
|
// default: () => [h(NIcon, null, { default: () => h(TrashOutline) }), ' 删除']
|
||||||
|
// })
|
||||||
|
// ])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
// 加载数据
|
||||||
|
async function loadData() {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const res = await orderProcessPlanApi.page({
|
||||||
|
page: pagination.page,
|
||||||
|
pageSize: pagination.pageSize,
|
||||||
|
id: searchForm.id,
|
||||||
|
name: searchForm.name,
|
||||||
|
code: searchForm.code,
|
||||||
|
orderItemId: searchForm.orderItemId
|
||||||
|
})
|
||||||
|
tableData.value = res.list
|
||||||
|
pagination.itemCount = res.total
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 搜索
|
||||||
|
function handleSearch() {
|
||||||
|
pagination.page = 1
|
||||||
|
loadData()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重置
|
||||||
|
function handleReset() {
|
||||||
|
searchForm.id = ''
|
||||||
|
|
||||||
|
searchForm.name = ''
|
||||||
|
|
||||||
|
searchForm.code = ''
|
||||||
|
|
||||||
|
searchForm.orderItemId = ''
|
||||||
|
|
||||||
|
handleSearch()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分页
|
||||||
|
function handlePageChange(page: number) {
|
||||||
|
pagination.page = page
|
||||||
|
loadData()
|
||||||
|
}
|
||||||
|
|
||||||
|
function handlePageSizeChange(pageSize: number) {
|
||||||
|
pagination.pageSize = pageSize
|
||||||
|
pagination.page = 1
|
||||||
|
loadData()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 选择
|
||||||
|
function handleCheck(keys: Array<string | number>) {
|
||||||
|
selectedIds.value = keys as number[]
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增
|
||||||
|
function handleAdd() {
|
||||||
|
modalTitle.value = '新增工序计划'
|
||||||
|
Object.assign(formData, defaultFormData)
|
||||||
|
modalVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 编辑
|
||||||
|
function handleEdit(row:any) {
|
||||||
|
modalTitle.value = '编辑工序计划'
|
||||||
|
Object.assign(formData, row)
|
||||||
|
if (formData.beginTime && typeof formData.beginTime === 'string') {
|
||||||
|
formData.beginTime = new Date(formData.beginTime.replace(' ', 'T')).getTime()
|
||||||
|
}
|
||||||
|
if (formData.endTime && typeof formData.endTime === 'string') {
|
||||||
|
formData.endTime = new Date(formData.endTime.replace(' ', 'T')).getTime()
|
||||||
|
}
|
||||||
|
if (formData.createTime && typeof formData.createTime === 'string') {
|
||||||
|
formData.createTime = new Date(formData.createTime.replace(' ', 'T')).getTime()
|
||||||
|
}
|
||||||
|
modalVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 提交
|
||||||
|
async function handleSubmit() {
|
||||||
|
await formRef.value?.validate()
|
||||||
|
try {
|
||||||
|
const submitData = { ...formData }
|
||||||
|
if (typeof submitData.beginTime === 'number') {
|
||||||
|
submitData.beginTime = new Date(submitData.beginTime).toISOString().slice(0, 19).replace('T', ' ')
|
||||||
|
}
|
||||||
|
if (typeof submitData.endTime === 'number') {
|
||||||
|
submitData.endTime = new Date(submitData.endTime).toISOString().slice(0, 19).replace('T', ' ')
|
||||||
|
}
|
||||||
|
if (typeof submitData.createTime === 'number') {
|
||||||
|
submitData.createTime = new Date(submitData.createTime).toISOString().slice(0, 19).replace('T', ' ')
|
||||||
|
}
|
||||||
|
if (submitData.id) {
|
||||||
|
await orderProcessPlanApi.update(submitData)
|
||||||
|
message.success('修改成功')
|
||||||
|
} else {
|
||||||
|
await orderProcessPlanApi.create(submitData)
|
||||||
|
message.success('新增成功')
|
||||||
|
}
|
||||||
|
modalVisible.value = false
|
||||||
|
loadData()
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//派工
|
||||||
|
let dispatchmodal = ref(false)
|
||||||
|
let dispatchform = reactive<any>({
|
||||||
|
id:'',
|
||||||
|
name:'',
|
||||||
|
beginTime:'',
|
||||||
|
endTime:'',
|
||||||
|
userid:'',
|
||||||
|
quantity:'',
|
||||||
|
list:[{
|
||||||
|
userId:'',
|
||||||
|
quantity:''
|
||||||
|
}],
|
||||||
|
username:''
|
||||||
|
})
|
||||||
|
|
||||||
|
//let yglist = ref<any>([])
|
||||||
|
|
||||||
|
const dispatchrules = {
|
||||||
|
// userid:[
|
||||||
|
// {
|
||||||
|
// required: true,
|
||||||
|
// message: '请选择员工',
|
||||||
|
// trigger: 'blur'
|
||||||
|
// }
|
||||||
|
// {
|
||||||
|
// required: true,
|
||||||
|
// validator(rule:any,value: any) {
|
||||||
|
// if(value.length == 0){
|
||||||
|
// return new Error('请选择员工')
|
||||||
|
// }
|
||||||
|
// return true
|
||||||
|
// },
|
||||||
|
// trigger: ['blur']
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
}
|
||||||
|
let dispatchLoading = ref(false)
|
||||||
|
let dispatchddbtn = ref(false)
|
||||||
|
|
||||||
|
const dispatchformRef = ref()
|
||||||
|
|
||||||
|
let loadingRef = ref(false)
|
||||||
|
|
||||||
|
function addpgnum() {
|
||||||
|
dispatchform.list.push({
|
||||||
|
userId:'',
|
||||||
|
quantity:''
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function deletenum(index:any) {
|
||||||
|
dispatchform.list.splice(index,1)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function disphand(v:any){
|
||||||
|
dispatchmodal.value = true
|
||||||
|
dispatchformRef.value?.restoreValidation()
|
||||||
|
dispatchform.id = v.id
|
||||||
|
dispatchform.name = v.name
|
||||||
|
dispatchform.beginTime = v.beginTime
|
||||||
|
dispatchform.endTime = v.endTime
|
||||||
|
dispatchform.quantity = v.quantity
|
||||||
|
dispatchform.userid = ''
|
||||||
|
dispatchform.list = [{
|
||||||
|
userId:'',
|
||||||
|
quantity:''
|
||||||
|
}]
|
||||||
|
//slehand()
|
||||||
|
}
|
||||||
|
|
||||||
|
function dispatchSubmit() {
|
||||||
|
let total = 0
|
||||||
|
dispatchform.list.forEach((n:any) => {
|
||||||
|
total = n.quantity*1+total
|
||||||
|
})
|
||||||
|
dispatchformRef.value?.validate((v:any) => {
|
||||||
|
if(!v){
|
||||||
|
if(total != dispatchform.quantity){
|
||||||
|
message.error('派工总数量需等于生产总数',{
|
||||||
|
duration:4000
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
orderProcessPlanApi.assignWork(dispatchform).then(() => {
|
||||||
|
message.success('操作成功!')
|
||||||
|
setTimeout(()=> {
|
||||||
|
dispatchmodal.value = false
|
||||||
|
dispatchLoading.value = false
|
||||||
|
dispatchddbtn.value = false
|
||||||
|
loadData()
|
||||||
|
},1000)
|
||||||
|
}).catch(() => {
|
||||||
|
dispatchddbtn.value = false
|
||||||
|
dispatchLoading.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
function handleDelete(row: OrderProcessPlan) {
|
||||||
|
dialog.warning({
|
||||||
|
title: '提示',
|
||||||
|
content: '确定要删除该记录吗?',
|
||||||
|
positiveText: '确定',
|
||||||
|
negativeText: '取消',
|
||||||
|
onPositiveClick: async () => {
|
||||||
|
try {
|
||||||
|
await orderProcessPlanApi.delete([row.id!])
|
||||||
|
message.success('删除成功')
|
||||||
|
loadData()
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量删除
|
||||||
|
function handleBatchDelete() {
|
||||||
|
dialog.warning({
|
||||||
|
title: '提示',
|
||||||
|
content: `确定要删除选中的 ${selectedIds.value.length} 条记录吗?`,
|
||||||
|
positiveText: '确定',
|
||||||
|
negativeText: '取消',
|
||||||
|
onPositiveClick: async () => {
|
||||||
|
try {
|
||||||
|
await orderProcessPlanApi.delete(selectedIds.value)
|
||||||
|
message.success('删除成功')
|
||||||
|
selectedIds.value = []
|
||||||
|
loadData()
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出
|
||||||
|
async function handleExport() {
|
||||||
|
try {
|
||||||
|
const params: Record<string, any> = {}
|
||||||
|
if (selectedIds.value.length > 0) params.ids = selectedIds.value
|
||||||
|
if (searchForm.id != null) params.id = searchForm.id
|
||||||
|
if (searchForm.name) params.name = searchForm.name
|
||||||
|
if (searchForm.code) params.code = searchForm.code
|
||||||
|
if (searchForm.orderItemId != null) params.orderItemId = searchForm.orderItemId
|
||||||
|
const blob = await orderProcessPlanApi.export(params)
|
||||||
|
const url = window.URL.createObjectURL(blob)
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.href = url
|
||||||
|
link.download = '工序计划数据.xlsx'
|
||||||
|
link.click()
|
||||||
|
window.URL.revokeObjectURL(url)
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下载导入模板
|
||||||
|
async function handleDownloadTemplate() {
|
||||||
|
try {
|
||||||
|
const blob = await orderProcessPlanApi.downloadTemplate()
|
||||||
|
const url = window.URL.createObjectURL(blob)
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.href = url
|
||||||
|
link.download = '工序计划导入模板.xlsx'
|
||||||
|
link.click()
|
||||||
|
window.URL.revokeObjectURL(url)
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导入上传
|
||||||
|
async function handleImportUpload({ file }: UploadCustomRequestOptions) {
|
||||||
|
if (!file.file) return
|
||||||
|
try {
|
||||||
|
const result = await orderProcessPlanApi.importData(file.file)
|
||||||
|
if (result.fail > 0) {
|
||||||
|
dialog.warning({
|
||||||
|
title: '导入结果',
|
||||||
|
content: `成功: ${result.success} 条,失败: ${result.fail} 条\n错误信息: ${(result.errors || []).join('\n') || '无'}`,
|
||||||
|
positiveText: '确定'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
message.success(`导入成功,共 ${result.success} 条数据`)
|
||||||
|
importModalVisible.value = false
|
||||||
|
}
|
||||||
|
loadData()
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载字典选项
|
||||||
|
async function loadDictOptions() {
|
||||||
|
try {
|
||||||
|
const data = await dictDataApi.listByType('sys_yes_no')
|
||||||
|
procurementOptions.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue) }))
|
||||||
|
} catch {}
|
||||||
|
try {
|
||||||
|
const data = await dictDataApi.listByType('sys_yes_no')
|
||||||
|
outsourceOptions.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue) }))
|
||||||
|
} catch {}
|
||||||
|
try {
|
||||||
|
const data = await dictDataApi.listByType('sys_yes_no')
|
||||||
|
qualityInspectionOptions.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue) }))
|
||||||
|
} catch {}
|
||||||
|
try {
|
||||||
|
const data = await dictDataApi.listByType('sys_yes_no')
|
||||||
|
storageEntryOptions.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue) }))
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadData()
|
||||||
|
loadDictOptions()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.search-form {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-toolbar {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
125
src/views/biz/orderProcessPlan/pgitem.vue
Normal file
125
src/views/biz/orderProcessPlan/pgitem.vue
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
<template>
|
||||||
|
<n-grid>
|
||||||
|
<n-gi :span="10">
|
||||||
|
<n-form-item
|
||||||
|
label="指派员工"
|
||||||
|
:path="`${listname}[${index}].userId`"
|
||||||
|
:rule="{
|
||||||
|
required: true,
|
||||||
|
message: '请选择员工',
|
||||||
|
trigger: 'blur'
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<!--multiple-->
|
||||||
|
<n-select
|
||||||
|
v-model:value="obj.userId"
|
||||||
|
filterable
|
||||||
|
placeholder="请输入用户名称搜索"
|
||||||
|
:options="yglist"
|
||||||
|
:loading="loadingRef"
|
||||||
|
clearable
|
||||||
|
remote
|
||||||
|
:clear-filter-after-select="false"
|
||||||
|
@search="slehand"
|
||||||
|
/>
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi :span="10">
|
||||||
|
<n-form-item
|
||||||
|
label="数量"
|
||||||
|
:path="`${listname}[${index}].quantity`"
|
||||||
|
:rule="{
|
||||||
|
required: true,
|
||||||
|
message: `请输入数量`,
|
||||||
|
trigger: 'blur',
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<n-input v-model:value="obj.quantity" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-gi>
|
||||||
|
<n-gi :span="4" style="padding-left:10px;">
|
||||||
|
<n-icon
|
||||||
|
v-if="index == 0"
|
||||||
|
size="25"
|
||||||
|
style="padding-top: 5px;cursor: pointer;" color="#1060c9"
|
||||||
|
@click="addpgnum"
|
||||||
|
>
|
||||||
|
<AddOutline />
|
||||||
|
</n-icon>
|
||||||
|
|
||||||
|
<n-icon
|
||||||
|
v-else
|
||||||
|
size="18"
|
||||||
|
style="padding:7px 0 0 2px;cursor: pointer;" color="#d03050"
|
||||||
|
@click="deletenum(index)"
|
||||||
|
>
|
||||||
|
<TrashOutline />
|
||||||
|
</n-icon>
|
||||||
|
</n-gi>
|
||||||
|
</n-grid>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import { userApi } from '@/api/system'
|
||||||
|
import {
|
||||||
|
AddOutline,
|
||||||
|
TrashOutline,
|
||||||
|
} from '@vicons/ionicons5'
|
||||||
|
const props = withDefaults(defineProps<{
|
||||||
|
listname:any
|
||||||
|
obj:any,
|
||||||
|
index:any
|
||||||
|
}>(), {
|
||||||
|
obj:{}
|
||||||
|
})
|
||||||
|
const emit = defineEmits<{
|
||||||
|
addhand:[],
|
||||||
|
delehand:[index:any],
|
||||||
|
update: [index:any,obj:any]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
// function updatehand() {
|
||||||
|
// emit('update')
|
||||||
|
// }
|
||||||
|
|
||||||
|
function addpgnum() {
|
||||||
|
emit('addhand')
|
||||||
|
}
|
||||||
|
function deletenum(index:any){
|
||||||
|
emit('delehand',index)
|
||||||
|
}
|
||||||
|
|
||||||
|
let yglist = ref<any>([])
|
||||||
|
|
||||||
|
let loadingRef = ref(false)
|
||||||
|
|
||||||
|
function slehand(v?:any) {
|
||||||
|
loadingRef.value = true
|
||||||
|
yglist.value.splice(0)
|
||||||
|
// dispatchform.userlist = [{
|
||||||
|
// id:'',
|
||||||
|
// num:''
|
||||||
|
// }]
|
||||||
|
userApi.page({
|
||||||
|
page: 1,
|
||||||
|
pageSize: 100,
|
||||||
|
username: v,
|
||||||
|
}).then((rps:any) =>{
|
||||||
|
if(rps.list && rps.list.length > 0){
|
||||||
|
yglist.value = rps.list.map((n:any) => {
|
||||||
|
return {
|
||||||
|
label:n.username,
|
||||||
|
value:n.id+''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
console.log(yglist.value,'12')
|
||||||
|
loadingRef.value = false
|
||||||
|
}).catch(() => {
|
||||||
|
loadingRef.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
slehand()
|
||||||
|
</script>
|
||||||
382
src/views/biz/submitLog/index.vue
Normal file
382
src/views/biz/submitLog/index.vue
Normal file
@ -0,0 +1,382 @@
|
|||||||
|
<template>
|
||||||
|
<div class="page-container">
|
||||||
|
<n-card>
|
||||||
|
<!-- 搜索表单 -->
|
||||||
|
<div class="search-form">
|
||||||
|
<n-form inline :model="searchForm" label-placement="left">
|
||||||
|
<n-form-item label="主键id;主键id">
|
||||||
|
<n-input v-model:value="searchForm.id" placeholder="请输入主键id;主键id" clearable />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item>
|
||||||
|
<n-space>
|
||||||
|
<n-button type="primary" @click="handleSearch">
|
||||||
|
<template #icon><n-icon><SearchOutline /></n-icon></template>
|
||||||
|
搜索
|
||||||
|
</n-button>
|
||||||
|
<n-button @click="handleReset">
|
||||||
|
<template #icon><n-icon><RefreshOutline /></n-icon></template>
|
||||||
|
重置
|
||||||
|
</n-button>
|
||||||
|
</n-space>
|
||||||
|
</n-form-item>
|
||||||
|
</n-form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 工具栏 -->
|
||||||
|
<div class="table-toolbar">
|
||||||
|
<n-space>
|
||||||
|
<n-button type="primary" @click="handleAdd">
|
||||||
|
<template #icon><n-icon><AddOutline /></n-icon></template>
|
||||||
|
新增
|
||||||
|
</n-button>
|
||||||
|
<n-button @click="importModalVisible = true">
|
||||||
|
<template #icon><n-icon><CloudUploadOutline /></n-icon></template>
|
||||||
|
导入
|
||||||
|
</n-button>
|
||||||
|
<n-button @click="handleExport">
|
||||||
|
<template #icon><n-icon><DownloadOutline /></n-icon></template>
|
||||||
|
导出{{ selectedIds.length > 0 ? `(${selectedIds.length})` : '' }}
|
||||||
|
</n-button>
|
||||||
|
<n-button type="error" :disabled="selectedIds.length === 0" @click="handleBatchDelete">
|
||||||
|
<template #icon><n-icon><TrashOutline /></n-icon></template>
|
||||||
|
删除
|
||||||
|
</n-button>
|
||||||
|
</n-space>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 表格 -->
|
||||||
|
<n-data-table
|
||||||
|
:columns="columns"
|
||||||
|
:data="tableData"
|
||||||
|
:loading="loading"
|
||||||
|
:pagination="pagination"
|
||||||
|
:row-key="(row) => row.id"
|
||||||
|
:scroll-x="1200"
|
||||||
|
@update:page="handlePageChange"
|
||||||
|
@update:page-size="handlePageSizeChange"
|
||||||
|
@update:checked-row-keys="handleCheck"
|
||||||
|
/>
|
||||||
|
</n-card>
|
||||||
|
|
||||||
|
<!-- 新增/编辑弹窗 -->
|
||||||
|
<n-modal v-model:show="modalVisible" preset="card" :title="modalTitle" style="width: 600px">
|
||||||
|
<n-form ref="formRef" :model="formData" :rules="formRules" label-placement="left" label-width="100px">
|
||||||
|
<n-form-item label="派工id;派工id" path="assingWorkId">
|
||||||
|
<n-input v-model:value="formData.assingWorkId" placeholder="请输入派工id;派工id" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="工序id;工序id" path="processId">
|
||||||
|
<n-input v-model:value="formData.processId" placeholder="请输入工序id;工序id" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="提交数量;提交数量" path="quantity">
|
||||||
|
<n-input v-model:value="formData.quantity" placeholder="请输入提交数量;提交数量" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-form>
|
||||||
|
<template #footer>
|
||||||
|
<n-space justify="end">
|
||||||
|
<n-button @click="modalVisible = false">取消</n-button>
|
||||||
|
<n-button type="primary" @click="handleSubmit">确定</n-button>
|
||||||
|
</n-space>
|
||||||
|
</template>
|
||||||
|
</n-modal>
|
||||||
|
|
||||||
|
<!-- 导入弹窗 -->
|
||||||
|
<n-modal v-model:show="importModalVisible" preset="card" title="导入派工工单汇报记录" style="width: 500px">
|
||||||
|
<n-space vertical>
|
||||||
|
<n-alert type="info">
|
||||||
|
<template #header>导入说明</template>
|
||||||
|
<ul style="margin: 0; padding-left: 16px; line-height: 1.8">
|
||||||
|
<li>请先下载导入模板,按模板格式填写数据</li>
|
||||||
|
<li>支持 .xlsx 或 .xls 格式</li>
|
||||||
|
</ul>
|
||||||
|
</n-alert>
|
||||||
|
<n-space>
|
||||||
|
<n-button type="primary" @click="handleDownloadTemplate">
|
||||||
|
<template #icon><n-icon><DownloadOutline /></n-icon></template>
|
||||||
|
下载模板
|
||||||
|
</n-button>
|
||||||
|
</n-space>
|
||||||
|
<n-upload :max="1" accept=".xlsx,.xls" :show-file-list="true" :custom-request="handleImportUpload">
|
||||||
|
<n-upload-dragger>
|
||||||
|
<div style="margin-bottom: 12px">
|
||||||
|
<n-icon size="48" :depth="3"><CloudUploadOutline /></n-icon>
|
||||||
|
</div>
|
||||||
|
<n-text style="font-size: 16px">点击或拖拽文件到此处上传</n-text>
|
||||||
|
<n-p depth="3" style="margin: 8px 0 0 0">支持 .xlsx 或 .xls 格式</n-p>
|
||||||
|
</n-upload-dragger>
|
||||||
|
</n-upload>
|
||||||
|
</n-space>
|
||||||
|
<template #footer>
|
||||||
|
<n-button @click="importModalVisible = false">关闭</n-button>
|
||||||
|
</template>
|
||||||
|
</n-modal>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, reactive, h, onMounted } from 'vue'
|
||||||
|
import { NButton, NSpace, NIcon, NUpload, useMessage, useDialog, type DataTableColumns, type UploadCustomRequestOptions } from 'naive-ui'
|
||||||
|
import { SearchOutline, RefreshOutline, AddOutline, TrashOutline, CreateOutline, CloudUploadOutline, DownloadOutline } from '@vicons/ionicons5'
|
||||||
|
import { submitLogApi, type SubmitLog } from '@/api/submitLog'
|
||||||
|
|
||||||
|
const message = useMessage()
|
||||||
|
const dialog = useDialog()
|
||||||
|
|
||||||
|
// 搜索表单
|
||||||
|
const searchForm = reactive({
|
||||||
|
id: null as number | null,
|
||||||
|
})
|
||||||
|
|
||||||
|
// 表格数据
|
||||||
|
const tableData = ref<SubmitLog[]>([])
|
||||||
|
const loading = ref(false)
|
||||||
|
const selectedIds = ref<number[]>([])
|
||||||
|
const pagination = reactive({
|
||||||
|
page: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
itemCount: 0,
|
||||||
|
showSizePicker: true,
|
||||||
|
pageSizes: [10, 20, 50]
|
||||||
|
})
|
||||||
|
|
||||||
|
// 弹窗
|
||||||
|
const modalVisible = ref(false)
|
||||||
|
const modalTitle = ref('')
|
||||||
|
const importModalVisible = ref(false)
|
||||||
|
const formRef = ref()
|
||||||
|
const defaultFormData: SubmitLog = {
|
||||||
|
assingWorkId: undefined,
|
||||||
|
processId: undefined,
|
||||||
|
quantity: undefined,
|
||||||
|
}
|
||||||
|
const formData = reactive<SubmitLog>({ ...defaultFormData })
|
||||||
|
|
||||||
|
// 字典选项(下拉框/单选框/复选框关联字典时使用)
|
||||||
|
|
||||||
|
// 表单校验规则
|
||||||
|
const formRules = {
|
||||||
|
}
|
||||||
|
|
||||||
|
// 表格列
|
||||||
|
const columns: DataTableColumns<SubmitLog> = [
|
||||||
|
{ type: 'selection' },
|
||||||
|
{ title: '主键id;主键id', key: 'id' },
|
||||||
|
{ title: '派工id;派工id', key: 'assingWorkId' },
|
||||||
|
{ title: '工序id;工序id', key: 'processId' },
|
||||||
|
{ title: '提交数量;提交数量', key: 'quantity' },
|
||||||
|
{ title: '提交时间', key: 'createTime', width: 180 },
|
||||||
|
{ title: '提交人;提交人', key: 'createBy' },
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
key: 'actions',
|
||||||
|
width: 140,
|
||||||
|
fixed: 'right',
|
||||||
|
render(row) {
|
||||||
|
return h('div', { style: { display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'nowrap' } }, [
|
||||||
|
h(NButton, { size: 'small', quaternary: true, onClick: () => handleEdit(row) }, {
|
||||||
|
default: () => [h(NIcon, null, { default: () => h(CreateOutline) }), ' 编辑']
|
||||||
|
}),
|
||||||
|
h(NButton, { size: 'small', quaternary: true, type: 'error', onClick: () => handleDelete(row) }, {
|
||||||
|
default: () => [h(NIcon, null, { default: () => h(TrashOutline) }), ' 删除']
|
||||||
|
})
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
// 加载数据
|
||||||
|
async function loadData() {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const res = await submitLogApi.page({
|
||||||
|
page: pagination.page,
|
||||||
|
pageSize: pagination.pageSize,
|
||||||
|
id: searchForm.id || undefined,
|
||||||
|
})
|
||||||
|
tableData.value = res.list
|
||||||
|
pagination.itemCount = res.total
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 搜索
|
||||||
|
function handleSearch() {
|
||||||
|
pagination.page = 1
|
||||||
|
loadData()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重置
|
||||||
|
function handleReset() {
|
||||||
|
searchForm.id = null
|
||||||
|
|
||||||
|
handleSearch()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分页
|
||||||
|
function handlePageChange(page: number) {
|
||||||
|
pagination.page = page
|
||||||
|
loadData()
|
||||||
|
}
|
||||||
|
|
||||||
|
function handlePageSizeChange(pageSize: number) {
|
||||||
|
pagination.pageSize = pageSize
|
||||||
|
pagination.page = 1
|
||||||
|
loadData()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 选择
|
||||||
|
function handleCheck(keys: Array<string | number>) {
|
||||||
|
selectedIds.value = keys as number[]
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增
|
||||||
|
function handleAdd() {
|
||||||
|
modalTitle.value = '新增派工工单汇报记录'
|
||||||
|
Object.assign(formData, defaultFormData)
|
||||||
|
modalVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 编辑
|
||||||
|
function handleEdit(row: SubmitLog) {
|
||||||
|
modalTitle.value = '编辑派工工单汇报记录'
|
||||||
|
Object.assign(formData, row)
|
||||||
|
if (formData.createTime && typeof formData.createTime === 'string') {
|
||||||
|
formData.createTime = new Date(formData.createTime.replace(' ', 'T')).getTime()
|
||||||
|
}
|
||||||
|
modalVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 提交
|
||||||
|
async function handleSubmit() {
|
||||||
|
await formRef.value?.validate()
|
||||||
|
try {
|
||||||
|
const submitData = { ...formData } as SubmitLog
|
||||||
|
if (typeof submitData.createTime === 'number') {
|
||||||
|
submitData.createTime = new Date(submitData.createTime).toISOString().slice(0, 19).replace('T', ' ')
|
||||||
|
}
|
||||||
|
if (submitData.id) {
|
||||||
|
await submitLogApi.update(submitData)
|
||||||
|
message.success('修改成功')
|
||||||
|
} else {
|
||||||
|
await submitLogApi.create(submitData)
|
||||||
|
message.success('新增成功')
|
||||||
|
}
|
||||||
|
modalVisible.value = false
|
||||||
|
loadData()
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
function handleDelete(row: SubmitLog) {
|
||||||
|
dialog.warning({
|
||||||
|
title: '提示',
|
||||||
|
content: '确定要删除该记录吗?',
|
||||||
|
positiveText: '确定',
|
||||||
|
negativeText: '取消',
|
||||||
|
onPositiveClick: async () => {
|
||||||
|
try {
|
||||||
|
await submitLogApi.delete([row.id!])
|
||||||
|
message.success('删除成功')
|
||||||
|
loadData()
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量删除
|
||||||
|
function handleBatchDelete() {
|
||||||
|
dialog.warning({
|
||||||
|
title: '提示',
|
||||||
|
content: `确定要删除选中的 ${selectedIds.value.length} 条记录吗?`,
|
||||||
|
positiveText: '确定',
|
||||||
|
negativeText: '取消',
|
||||||
|
onPositiveClick: async () => {
|
||||||
|
try {
|
||||||
|
await submitLogApi.delete(selectedIds.value)
|
||||||
|
message.success('删除成功')
|
||||||
|
selectedIds.value = []
|
||||||
|
loadData()
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出
|
||||||
|
async function handleExport() {
|
||||||
|
try {
|
||||||
|
const params: Record<string, any> = {}
|
||||||
|
if (selectedIds.value.length > 0) params.ids = selectedIds.value
|
||||||
|
if (searchForm.id != null) params.id = searchForm.id
|
||||||
|
const blob = await submitLogApi.export(params)
|
||||||
|
const url = window.URL.createObjectURL(blob)
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.href = url
|
||||||
|
link.download = '派工工单汇报记录数据.xlsx'
|
||||||
|
link.click()
|
||||||
|
window.URL.revokeObjectURL(url)
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下载导入模板
|
||||||
|
async function handleDownloadTemplate() {
|
||||||
|
try {
|
||||||
|
const blob = await submitLogApi.downloadTemplate()
|
||||||
|
const url = window.URL.createObjectURL(blob)
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.href = url
|
||||||
|
link.download = '派工工单汇报记录导入模板.xlsx'
|
||||||
|
link.click()
|
||||||
|
window.URL.revokeObjectURL(url)
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导入上传
|
||||||
|
async function handleImportUpload({ file }: UploadCustomRequestOptions) {
|
||||||
|
if (!file.file) return
|
||||||
|
try {
|
||||||
|
const result = await submitLogApi.importData(file.file)
|
||||||
|
if (result.fail > 0) {
|
||||||
|
dialog.warning({
|
||||||
|
title: '导入结果',
|
||||||
|
content: `成功: ${result.success} 条,失败: ${result.fail} 条\n错误信息: ${(result.errors || []).join('\n') || '无'}`,
|
||||||
|
positiveText: '确定'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
message.success(`导入成功,共 ${result.success} 条数据`)
|
||||||
|
importModalVisible.value = false
|
||||||
|
}
|
||||||
|
loadData()
|
||||||
|
} catch (error) {
|
||||||
|
// 错误已在拦截器处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载字典选项
|
||||||
|
async function loadDictOptions() {
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadData()
|
||||||
|
loadDictOptions()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.search-form {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-toolbar {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -454,11 +454,13 @@ const pauserules = {
|
|||||||
qcNum: [
|
qcNum: [
|
||||||
{ required: true, message: '请输报检数量', trigger: 'blur' },
|
{ required: true, message: '请输报检数量', trigger: 'blur' },
|
||||||
{
|
{
|
||||||
validator(value: number) {
|
validator(rule:any,value: any) {
|
||||||
return value > pauseform.qcNum
|
if(value > pauseform.qcNum){
|
||||||
|
return new Error(`报检数量最大为${pauseform.qcNum}`)
|
||||||
|
}
|
||||||
|
return true
|
||||||
},
|
},
|
||||||
trigger: ['blur'],
|
trigger: ['blur']
|
||||||
message: `报检数量最大为${pauseform.qcNum}`
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user