陈薪名
1 year ago
14 changed files with 603 additions and 1471 deletions
@ -1,202 +0,0 @@ |
|||||
<template> |
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible"> |
|
||||
<div class="p-20px m--10px" style="max-height: 600px;overflow-y: auto;"> |
|
||||
<el-form |
|
||||
ref="formRef" |
|
||||
:model="formData" |
|
||||
:rules="formRules" |
|
||||
label-width="100px" |
|
||||
v-loading="formLoading" |
|
||||
> |
|
||||
<el-row> |
|
||||
<el-col :span="12"> |
|
||||
|
|
||||
<el-form-item label="父物料代码" prop="productItemCode"> |
|
||||
<el-input v-model="formData.productItemCode" placeholder="请输入父物料代码" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
<el-col :span="12"> |
|
||||
|
|
||||
<el-form-item label="子物料代码" prop="componentItemCode"> |
|
||||
<el-input v-model="formData.componentItemCode" placeholder="请输入子物料代码" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="子物料计量单位" prop="componentUom"> |
|
||||
<el-select v-model="formData.componentUom" placeholder="请选择子物料计量单位"> |
|
||||
<el-option |
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.UOM)" |
|
||||
:key="dict.value" |
|
||||
:label="dict.label" |
|
||||
:value="dict.value" |
|
||||
/> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
<el-col :span="12"> |
|
||||
|
|
||||
<el-form-item label="子物料数量" prop="componentQty"> |
|
||||
<el-input v-model="formData.componentQty" placeholder="请输入子物料数量" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
<el-col :span="12"> |
|
||||
|
|
||||
<el-form-item label="工序代码" prop="processCode"> |
|
||||
<el-input v-model="formData.processCode" placeholder="请输入工序代码" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
<el-col :span="12"> |
|
||||
|
|
||||
<el-form-item label="版本" prop="version"> |
|
||||
<el-input v-model="formData.version" placeholder="请输入版本" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
<el-col :span="12"> |
|
||||
|
|
||||
<el-form-item label="层级" prop="layer"> |
|
||||
<el-input v-model="formData.layer" placeholder="请输入层级" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="是否可用" prop="available"> |
|
||||
<el-select v-model="formData.available" placeholder="请选择是否可用"> |
|
||||
<el-option |
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.TRUE_FALSE)" |
|
||||
:key="dict.value" |
|
||||
:label="dict.label" |
|
||||
:value="dict.value" |
|
||||
/> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="生效时间" prop="activeTime"> |
|
||||
<el-date-picker |
|
||||
v-model="formData.activeTime" |
|
||||
type="date" |
|
||||
value-format="x" |
|
||||
placeholder="选择生效时间" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="失效时间" prop="expireTime"> |
|
||||
<el-date-picker |
|
||||
v-model="formData.expireTime" |
|
||||
type="date" |
|
||||
value-format="x" |
|
||||
placeholder="选择失效时间" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
<el-col :span="12"> |
|
||||
|
|
||||
<el-form-item label="备注" prop="remark"> |
|
||||
<el-input v-model="formData.remark" placeholder="请输入备注" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
</el-row> |
|
||||
</el-form> |
|
||||
</div> |
|
||||
<template #footer> |
|
||||
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button> |
|
||||
<el-button @click="dialogVisible = false">取 消</el-button> |
|
||||
</template> |
|
||||
</Dialog> |
|
||||
</template> |
|
||||
<script setup lang="ts"> |
|
||||
import { DICT_TYPE, getStrDictOptions, getIntDictOptions } from '@/utils/dict' |
|
||||
import * as BomApi from '@/api/wms/bom' |
|
||||
|
|
||||
const { t } = useI18n() // 国际化 |
|
||||
const message = useMessage() // 消息弹窗 |
|
||||
|
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示 |
|
||||
const dialogTitle = ref('') // 弹窗的标题 |
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 |
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改 |
|
||||
const formData = ref({ |
|
||||
productItemCode: undefined, |
|
||||
componentItemCode: undefined, |
|
||||
componentUom: undefined, |
|
||||
componentQty: undefined, |
|
||||
processCode: undefined, |
|
||||
version: undefined, |
|
||||
layer: undefined, |
|
||||
available: undefined, |
|
||||
activeTime: undefined, |
|
||||
expireTime: undefined, |
|
||||
remark: undefined |
|
||||
}) |
|
||||
const formRules = reactive({ |
|
||||
productItemCode: [{ required: true, message: '父物料代码不能为空', trigger: 'blur' }], |
|
||||
componentItemCode: [{ required: true, message: '子物料代码不能为空', trigger: 'blur' }], |
|
||||
componentUom: [{ required: true, message: '子物料计量单位不能为空', trigger: 'change' }], |
|
||||
componentQty: [{ required: true, message: '子物料数量不能为空', trigger: 'blur' }], |
|
||||
processCode: [{ required: true, message: '工序代码不能为空', trigger: 'blur' }], |
|
||||
available: [{ required: true, message: '是否可用不能为空', trigger: 'change' }] |
|
||||
}) |
|
||||
const formRef = ref() // 表单 Ref |
|
||||
|
|
||||
/** 打开弹窗 */ |
|
||||
const open = async (type: string, id?: number) => { |
|
||||
dialogVisible.value = true |
|
||||
dialogTitle.value = t('action.' + type) |
|
||||
formType.value = type |
|
||||
resetForm() |
|
||||
// 修改时,设置数据 |
|
||||
if (id) { |
|
||||
formLoading.value = true |
|
||||
try { |
|
||||
formData.value = await BomApi.getBom(id) |
|
||||
} finally { |
|
||||
formLoading.value = false |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗 |
|
||||
|
|
||||
/** 提交表单 */ |
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调 |
|
||||
const submitForm = async () => { |
|
||||
// 校验表单 |
|
||||
if (!formRef) return |
|
||||
const valid = await formRef.value.validate() |
|
||||
if (!valid) return |
|
||||
// 提交请求 |
|
||||
formLoading.value = true |
|
||||
try { |
|
||||
const data = formData.value as unknown as BomApi.BomVO |
|
||||
if (formType.value === 'create') { |
|
||||
await BomApi.createBom(data) |
|
||||
message.success(t('common.createSuccess')) |
|
||||
} else { |
|
||||
await BomApi.updateBom(data) |
|
||||
message.success(t('common.updateSuccess')) |
|
||||
} |
|
||||
dialogVisible.value = false |
|
||||
// 发送操作成功的事件 |
|
||||
emit('success') |
|
||||
} finally { |
|
||||
formLoading.value = false |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/** 重置表单 */ |
|
||||
const resetForm = () => { |
|
||||
formData.value = { |
|
||||
productItemCode: undefined, |
|
||||
componentItemCode: undefined, |
|
||||
componentUom: undefined, |
|
||||
componentQty: undefined, |
|
||||
processCode: undefined, |
|
||||
version: undefined, |
|
||||
layer: undefined, |
|
||||
available: undefined, |
|
||||
activeTime: undefined, |
|
||||
expireTime: undefined, |
|
||||
remark: undefined |
|
||||
} |
|
||||
formRef.value?.resetFields() |
|
||||
} |
|
||||
</script> |
|
@ -1,176 +0,0 @@ |
|||||
<template> |
|
||||
<ContentWrap> |
|
||||
<div class="font-size-18px"> |
|
||||
{{ detailData.code }} <span class="ml-20px font-size-16px">{{ detailData.name }}</span> |
|
||||
</div> |
|
||||
</ContentWrap> |
|
||||
<Tabs :tabsList="tabsList" :current="current" @change="change" /> |
|
||||
<div class="flex" v-if="current == 0"> |
|
||||
<!-- 详情 --> |
|
||||
<ContentWrap class="w-[73%]"> |
|
||||
<Descriptions :data="detailData" :schema="ItemBasic.allSchemas.detailSchema" :columns="2" /> |
|
||||
</ContentWrap> |
|
||||
<ContentWrap class="w-[27%] ml-16px"> |
|
||||
<!-- 附件组件 --> |
|
||||
<Annex :data="annexData" @handleImport="handleImport" @deleteAnnex="deleteAnnexSuccess" /> |
|
||||
<!-- 备注组件 --> |
|
||||
<Remarks :data="remarksData" class="mt-20px" @submitSucss="remarksSubmitSucss" /> |
|
||||
<!-- 变更记录组件 --> |
|
||||
<ChangeRecord :data="changeRecordData" class="mt-20px" /> |
|
||||
</ContentWrap> |
|
||||
<!-- 用户导入对话框 --> |
|
||||
<ImportForm ref="importFormRef" :importTemplateData="importTemplateData" @success="importSuccess" /> |
|
||||
</div> |
|
||||
<ContentWrap v-else> |
|
||||
<Table :columns="ItemBasic.allSchemas.tableColumns" :data="tableObject.tableList" :loading="tableObject.loading" |
|
||||
:pagination="{ |
|
||||
total: tableObject.total |
|
||||
}" v-model:pageSize="tableObject.pageSize" v-model:currentPage="tableObject.currentPage" /> |
|
||||
</ContentWrap> |
|
||||
</template> |
|
||||
|
|
||||
<script lang="ts" setup> |
|
||||
defineOptions({ name: 'Detail' }) |
|
||||
import Annex from '@/components/Annex/src/Annex.vue' |
|
||||
import Remarks from '@/components/Remarks/src/Remarks.vue' |
|
||||
import ImportForm from '@/components/ImportForm/src/ImportForm.vue' |
|
||||
import ChangeRecord from '@/components/ChangeRecord/src/ChangeRecord.vue' |
|
||||
import Tabs from '@/components/Tabs/src/Tabs.vue' |
|
||||
import { ItemBasic } from '@/utils/disposition/tableColumns.ts' |
|
||||
import { ItemBasicTabsList } from '@/utils/disposition/tabsList.ts' |
|
||||
import { getItembasic } from '@/api/wms/itembasic' |
|
||||
const { query } = useRoute() // 路由的查询 |
|
||||
import * as ItembasicApi from '@/api/wms/itembasic' |
|
||||
const tabsList = ref(JSON.parse(JSON.stringify(ItemBasicTabsList))) |
|
||||
tabsList.value.unshift({ |
|
||||
label: '详情', |
|
||||
prop: 'Detail' |
|
||||
}) |
|
||||
// 搜索参数 |
|
||||
const queryParams = reactive({ |
|
||||
title: '', |
|
||||
name: undefined, |
|
||||
status: undefined, |
|
||||
pageNo: 1, |
|
||||
pageSize: 100 |
|
||||
}) |
|
||||
const queryFormRef = ref() // 搜索的表单 |
|
||||
// const formLabel = ref(ItemBasic)//form表单label列表 |
|
||||
// 附件默认数据 |
|
||||
const annexData = reactive({ |
|
||||
annexList: [{ |
|
||||
title: '文件名文件名2023-12-12.docx', |
|
||||
size: '150.02KB', |
|
||||
people: '贾先生', |
|
||||
time: '2023年5月6日 17:16:00', |
|
||||
}, { |
|
||||
title: '文件名文件名2023-12-15.docx', |
|
||||
size: '242KB', |
|
||||
people: '张张', |
|
||||
time: '2022年12月12日 17:16:00', |
|
||||
}] |
|
||||
}) |
|
||||
// 备注默认数据 |
|
||||
const remarksData = reactive({ |
|
||||
remarksList: [{ |
|
||||
name: '诸葛亮', |
|
||||
text: '转朱阁,低绮户,照无眠。不应有恨,何事长向别时圆?人有悲欢离合,月有阴晴圆缺,此事古难全。但愿人长久,千里共婵娟。', |
|
||||
time: '2023年5月6日 17:16:00', |
|
||||
}, { |
|
||||
name: '刘备', |
|
||||
text: '转朱阁,低绮户,照无眠。不应有恨,何事长向别时圆?人有悲欢离合,月有阴晴圆缺,此事古难全。但愿人长久,千里共婵娟。', |
|
||||
time: '2022年12月12日 17:16:00', |
|
||||
}] |
|
||||
}) |
|
||||
|
|
||||
// 变更记录默认数据 |
|
||||
const changeRecordData = reactive({ |
|
||||
changeRecordList: [{ |
|
||||
name: '诸葛亮', |
|
||||
type: 1, |
|
||||
time: '2023年5月6日 17:16:00', |
|
||||
}, { |
|
||||
name: '刘备', |
|
||||
type: 2, |
|
||||
time: '2023年5月6日 17:16:00', |
|
||||
}, { |
|
||||
name: '曹操', |
|
||||
type: 3, |
|
||||
time: '2023年5月6日 17:16:00', |
|
||||
file: [{ |
|
||||
name: '这是个附件的名字.docx', |
|
||||
url: 'http://localhost:12080//wms/itembasic/get-import-template' |
|
||||
}, { |
|
||||
name: '这是个附件的名字.docx', |
|
||||
url: 'http://localhost:12080/wms/itembasic/get-import-template' |
|
||||
}] |
|
||||
}] |
|
||||
}) |
|
||||
const detailData = ref("")//详情数据 |
|
||||
// 导入附件弹窗所需的参数 |
|
||||
const importTemplateData = reactive({ |
|
||||
templateUrl: '', |
|
||||
templateTitle: '导入模版99.xls' |
|
||||
}) |
|
||||
onMounted(async () => { |
|
||||
// 获取详情 |
|
||||
detailData.value = await getItembasic(query.id) |
|
||||
importTemplateData.templateUrl = await ItembasicApi.importTemplate() |
|
||||
}) |
|
||||
|
|
||||
// 导入成功之后 |
|
||||
const importSuccess = () => { |
|
||||
|
|
||||
|
|
||||
} |
|
||||
/** 搜索按钮操作 */ |
|
||||
const handleQuery = () => { |
|
||||
|
|
||||
importFormRef.value.open() |
|
||||
} |
|
||||
|
|
||||
/** 重置按钮操作 */ |
|
||||
const resetQuery = () => { |
|
||||
queryParams.pageNo = 1 |
|
||||
queryFormRef.value.resetFields() |
|
||||
} |
|
||||
|
|
||||
/** 用户导入 */ |
|
||||
const importFormRef = ref() |
|
||||
const handleImport = () => { |
|
||||
importFormRef.value.open() |
|
||||
} |
|
||||
// 删除附件成功之后所走的方法 |
|
||||
const deleteAnnexSuccess = async () => { |
|
||||
console.log('删除成功'); |
|
||||
} |
|
||||
// 备注提交成功之后 |
|
||||
const remarksSubmitSucss = () => { |
|
||||
console.log('提交成功'); |
|
||||
} |
|
||||
// 供应商物品数据 |
|
||||
// const supplierItems = reactive({ |
|
||||
// supplierItemsList: [{ |
|
||||
// code: '646456', |
|
||||
// name: '978978' |
|
||||
// }], |
|
||||
// total: 20, |
|
||||
// pageSize: 1, |
|
||||
// currentPage: 2 |
|
||||
// }) |
|
||||
|
|
||||
|
|
||||
const current = ref(0) |
|
||||
// 获取表格数据 |
|
||||
const { tableObject, tableMethods } = useTable({ |
|
||||
getListApi: ItembasicApi.getItembasicPage // 分页接口 |
|
||||
}) |
|
||||
const change = (item, index) => { |
|
||||
current.value = index |
|
||||
} |
|
||||
|
|
||||
// 获得表格的各种操作 |
|
||||
const { getList, setSearchParams } = tableMethods |
|
||||
getList() |
|
||||
|
|
||||
</script> |
|
@ -1,156 +0,0 @@ |
|||||
<template> |
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible"> |
|
||||
<div class="p-20px m--10px" style="max-height: 500px;overflow-y: auto;"> |
|
||||
<Form ref="formRef" v-loading="formLoading" :rules="ItemBasicRules" :schema="ItemBasic.allSchemas.formSchema" |
|
||||
:model="formData" :is-col="true" /> |
|
||||
<div class="table"> |
|
||||
<TableForm ref="tableFormRef" :tableFields="PurchaseclaimRequestMain.allSchemas.tableFormColumns" :tableData="tableData" class="w-[100%]" @handleAdd="handleAdd" :tableFormRules="ItemBasicRules" @handleDelete="handleDelete" @inpuFocus="inpuFocus"/> |
|
||||
</div> |
|
||||
</div> |
|
||||
<template #footer> |
|
||||
<!-- 列表头部 --> |
|
||||
<TableHead :HeadButttondata="Butttondata" @buttonBaseClick="buttonBaseClick" /> |
|
||||
</template> |
|
||||
</Dialog> |
|
||||
</template> |
|
||||
<script setup lang="ts"> |
|
||||
import * as ItembasicApi from '@/api/wms/itembasic' |
|
||||
import { ItemBasic, ItemBasicRules, PurchaseclaimRequestMain } from '@/utils/disposition/tableColumns.ts' |
|
||||
import TableForm from '@/components/TableForm/src/TableForm.vue' |
|
||||
import * as defaultButtons from '@/utils/disposition/defaultButtons' |
|
||||
|
|
||||
const { t } = useI18n() // 国际化 |
|
||||
const message = useMessage() // 消息弹窗 |
|
||||
|
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示 |
|
||||
const dialogTitle = ref('') // 弹窗的标题 |
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 |
|
||||
const formData = ref('') |
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改 |
|
||||
const formRef = ref() // 表单 Ref |
|
||||
const tableFormRef = ref() |
|
||||
|
|
||||
/** 打开弹窗 */ |
|
||||
const open = async (type: string, id?: number) => { |
|
||||
dialogVisible.value = true |
|
||||
dialogTitle.value = t('action.' + type) |
|
||||
formType.value = type |
|
||||
resetForm() |
|
||||
// 修改时,设置数据 |
|
||||
if (id) { |
|
||||
formLoading.value = true |
|
||||
try { |
|
||||
const data = await ItembasicApi.getItembasic(id) |
|
||||
formRef.value.setValues(data) |
|
||||
|
|
||||
} finally { |
|
||||
formLoading.value = false |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗 |
|
||||
|
|
||||
/** 提交表单 */ |
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调 |
|
||||
const submitForm = async () => { |
|
||||
// 校验表单 |
|
||||
if (!formRef) return |
|
||||
const valid = await formRef.value.validate() |
|
||||
if (!valid) return |
|
||||
// 提交请求 |
|
||||
formLoading.value = true |
|
||||
try { |
|
||||
const data = formData.value as unknown as ItembasicApi.ItembasicVO |
|
||||
if (formType.value === 'create') { |
|
||||
await ItembasicApi.createItembasic(data) |
|
||||
message.success(t('common.createSuccess')) |
|
||||
} else { |
|
||||
await ItembasicApi.updateItembasic(data) |
|
||||
message.success(t('common.updateSuccess')) |
|
||||
} |
|
||||
dialogVisible.value = false |
|
||||
// 发送操作成功的事件 |
|
||||
emit('success') |
|
||||
} finally { |
|
||||
formLoading.value = false |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/** 重置表单 */ |
|
||||
const resetForm = () => { |
|
||||
formData.value = { |
|
||||
code: undefined, |
|
||||
name: undefined, |
|
||||
desc1: undefined, |
|
||||
desc2: undefined, |
|
||||
status: undefined, |
|
||||
uom: undefined, |
|
||||
altUom: undefined, |
|
||||
isStdPack: undefined, |
|
||||
enableBuy: undefined, |
|
||||
enableMake: undefined, |
|
||||
enableOutsourcing: undefined, |
|
||||
isRecycled: undefined, |
|
||||
isPhantom: undefined, |
|
||||
abcClass: undefined, |
|
||||
type: undefined, |
|
||||
category: undefined, |
|
||||
itemGroup: undefined, |
|
||||
color: undefined, |
|
||||
configuration: undefined, |
|
||||
project: undefined, |
|
||||
eqLevel: undefined, |
|
||||
validityDays: undefined, |
|
||||
available: undefined, |
|
||||
activeTime: undefined, |
|
||||
expireTime: undefined, |
|
||||
remark: undefined |
|
||||
} |
|
||||
formRef.value?.resetFields() |
|
||||
} |
|
||||
|
|
||||
// 弹窗按钮 |
|
||||
const Butttondata = [ |
|
||||
defaultButtons.formSaveBtn(null), // 保存 |
|
||||
defaultButtons.formCloseBtn(null), // 关闭 |
|
||||
] |
|
||||
// 按钮事件 |
|
||||
const buttonBaseClick = (val, item) => { |
|
||||
// 保存 |
|
||||
if (val == 'save') { |
|
||||
tableFormRef.value.validateForm() |
|
||||
} |
|
||||
// 关闭 |
|
||||
else if (val == 'close') { |
|
||||
dialogVisible.value = false |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
const tableFormKeys ={} |
|
||||
PurchaseclaimRequestMain.allSchemas.tableFormColumns.forEach(item=>{ |
|
||||
tableFormKeys[item.field]=item.default? item.default:'' |
|
||||
}) |
|
||||
const tableData = ref([]) |
|
||||
// 添加明细 |
|
||||
const handleAdd = ()=>{ |
|
||||
tableData.value.push(tableFormKeys) |
|
||||
} |
|
||||
// 删除明细 |
|
||||
|
|
||||
const handleDelete =(item,index)=>{ |
|
||||
tableData.value.splice(index,1) |
|
||||
} |
|
||||
// input聚焦的时候操作 |
|
||||
const inpuFocus = () => { |
|
||||
console.log(1); |
|
||||
|
|
||||
} |
|
||||
</script> |
|
||||
<style scoped> |
|
||||
.table { |
|
||||
border: 1px solid #dedede; |
|
||||
border-radius: 8px; |
|
||||
padding: 10px; |
|
||||
display: flex; |
|
||||
} |
|
||||
</style> |
|
@ -1,133 +0,0 @@ |
|||||
<template> |
|
||||
<Dialog v-model="dialogVisible" title="物品基本信息导入" width="400"> |
|
||||
<el-upload |
|
||||
ref="uploadRef" |
|
||||
v-model:file-list="fileList" |
|
||||
:action="importUrl + '?updateSupport=' + updateSupport" |
|
||||
:auto-upload="false" |
|
||||
:disabled="formLoading" |
|
||||
:headers="uploadHeaders" |
|
||||
:limit="1" |
|
||||
:on-error="submitFormError" |
|
||||
:on-exceed="handleExceed" |
|
||||
:on-success="submitFormSuccess" |
|
||||
accept=".xlsx, .xls" |
|
||||
drag |
|
||||
> |
|
||||
<Icon icon="ep:upload" /> |
|
||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> |
|
||||
<template #tip> |
|
||||
<div class="el-upload__tip text-center"> |
|
||||
<div class="el-upload__tip"> |
|
||||
<el-checkbox v-model="updateSupport" /> |
|
||||
是否更新已经存在的物品基本信息数据 |
|
||||
</div> |
|
||||
<span>仅允许导入 xls、xlsx 格式文件。</span> |
|
||||
<el-link |
|
||||
:underline="false" |
|
||||
style="font-size: 12px; vertical-align: baseline" |
|
||||
type="primary" |
|
||||
@click="importTemplate" |
|
||||
> |
|
||||
下载模板 |
|
||||
</el-link> |
|
||||
</div> |
|
||||
</template> |
|
||||
</el-upload> |
|
||||
<template #footer> |
|
||||
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button> |
|
||||
<el-button @click="dialogVisible = false">取 消</el-button> |
|
||||
</template> |
|
||||
</Dialog> |
|
||||
</template> |
|
||||
<script lang="ts" setup> |
|
||||
import * as ItembasicApi from '@/api/wms/itembasic' |
|
||||
import { getAccessToken, getTenantId } from '@/utils/auth' |
|
||||
import download from '@/utils/download' |
|
||||
|
|
||||
defineOptions({ name: 'WmsItembasicImportForm' }) |
|
||||
|
|
||||
const message = useMessage() // 消息弹窗 |
|
||||
|
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示 |
|
||||
const formLoading = ref(false) // 表单的加载中 |
|
||||
const uploadRef = ref() |
|
||||
const importUrl = |
|
||||
import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL + '/wms/itembasic/import' |
|
||||
const uploadHeaders = ref() // 上传 Header 头 |
|
||||
const fileList = ref([]) // 文件列表 |
|
||||
const updateSupport = ref(0) // 是否更新已经存在的物品基本信息数据 |
|
||||
|
|
||||
/** 打开弹窗 */ |
|
||||
const open = () => { |
|
||||
dialogVisible.value = true |
|
||||
resetForm() |
|
||||
} |
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗 |
|
||||
|
|
||||
/** 提交表单 */ |
|
||||
const submitForm = async () => { |
|
||||
if (fileList.value.length == 0) { |
|
||||
message.error('请上传文件') |
|
||||
return |
|
||||
} |
|
||||
// 提交请求 |
|
||||
uploadHeaders.value = { |
|
||||
Authorization: 'Bearer ' + getAccessToken(), |
|
||||
'tenant-id': getTenantId() |
|
||||
} |
|
||||
formLoading.value = true |
|
||||
uploadRef.value!.submit() |
|
||||
} |
|
||||
|
|
||||
/** 文件上传成功 */ |
|
||||
const emits = defineEmits(['success']) |
|
||||
const submitFormSuccess = (response: any) => { |
|
||||
if (response.code !== 0) { |
|
||||
message.error(response.msg) |
|
||||
formLoading.value = false |
|
||||
return |
|
||||
} |
|
||||
// 拼接提示语 |
|
||||
const data = response.data |
|
||||
let text = '上传成功数量:' + data.createUsernames.length + ';' |
|
||||
for (let username of data.createUsernames) { |
|
||||
text += '< ' + username + ' >' |
|
||||
} |
|
||||
text += '更新成功数量:' + data.updateUsernames.length + ';' |
|
||||
for (const username of data.updateUsernames) { |
|
||||
text += '< ' + username + ' >' |
|
||||
} |
|
||||
text += '更新失败数量:' + Object.keys(data.failureUsernames).length + ';' |
|
||||
for (const username in data.failureUsernames) { |
|
||||
text += '< ' + username + ': ' + data.failureUsernames[username] + ' >' |
|
||||
} |
|
||||
message.alert(text) |
|
||||
// 发送操作成功的事件 |
|
||||
emits('success') |
|
||||
} |
|
||||
|
|
||||
/** 上传错误提示 */ |
|
||||
const submitFormError = (): void => { |
|
||||
message.error('上传失败,请您重新上传!') |
|
||||
formLoading.value = false |
|
||||
} |
|
||||
|
|
||||
/** 重置表单 */ |
|
||||
const resetForm = () => { |
|
||||
// 重置上传状态和文件 |
|
||||
formLoading.value = false |
|
||||
uploadRef.value?.clearFiles() |
|
||||
} |
|
||||
|
|
||||
/** 文件数超出提示 */ |
|
||||
const handleExceed = (): void => { |
|
||||
message.error('最多只能上传一个文件!') |
|
||||
} |
|
||||
|
|
||||
/** 下载模板操作 */ |
|
||||
const importTemplate = async () => { |
|
||||
const res = await ItembasicApi.importUserTemplate() |
|
||||
download.excel(res, '物品基本信息导入模版.xls') |
|
||||
} |
|
||||
</script> |
|
@ -1,162 +0,0 @@ |
|||||
<template> |
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible"> |
|
||||
<div class="p-20px m--10px" style="max-height: 600px;overflow-y: auto;"> |
|
||||
<el-form |
|
||||
ref="formRef" |
|
||||
:model="formData" |
|
||||
:rules="formRules" |
|
||||
label-width="100px" |
|
||||
v-loading="formLoading" |
|
||||
> |
|
||||
<el-row> |
|
||||
<el-col :span="12"> |
|
||||
|
|
||||
<el-form-item label="完工收货库位" prop="fgLocationCode"> |
|
||||
<el-input v-model="formData.fgLocationCode" placeholder="请输入完工收货库位" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
<el-col :span="12"> |
|
||||
|
|
||||
<el-form-item label="产线代码" prop="productionLineCode"> |
|
||||
<el-input v-model="formData.productionLineCode" placeholder="请输入产线代码" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
<el-col :span="12"> |
|
||||
|
|
||||
<el-form-item label="物品代码" prop="itemCode"> |
|
||||
<el-input v-model="formData.itemCode" placeholder="请输入物品代码" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="是否可用" prop="available"> |
|
||||
<el-select v-model="formData.available" placeholder="请选择是否可用"> |
|
||||
<el-option |
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.TRUE_FALSE)" |
|
||||
:key="dict.value" |
|
||||
:label="dict.label" |
|
||||
:value="dict.value" |
|
||||
/> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="生效时间" prop="activeTime"> |
|
||||
<el-date-picker |
|
||||
v-model="formData.activeTime" |
|
||||
type="date" |
|
||||
value-format="x" |
|
||||
placeholder="选择生效时间" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="失效时间" prop="expireTime"> |
|
||||
<el-date-picker |
|
||||
v-model="formData.expireTime" |
|
||||
type="date" |
|
||||
value-format="x" |
|
||||
placeholder="选择失效时间" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
<el-col :span="12"> |
|
||||
|
|
||||
<el-form-item label="备注" prop="remark"> |
|
||||
<el-input v-model="formData.remark" placeholder="请输入备注" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
</el-row> |
|
||||
</el-form> |
|
||||
</div> |
|
||||
<template #footer> |
|
||||
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button> |
|
||||
<el-button @click="dialogVisible = false">取 消</el-button> |
|
||||
</template> |
|
||||
</Dialog> |
|
||||
</template> |
|
||||
<script setup lang="ts"> |
|
||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' |
|
||||
import * as ProductionlineitemApi from '@/api/wms/productionlineitem' |
|
||||
|
|
||||
const { t } = useI18n() // 国际化 |
|
||||
const message = useMessage() // 消息弹窗 |
|
||||
|
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示 |
|
||||
const dialogTitle = ref('') // 弹窗的标题 |
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 |
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改 |
|
||||
const formData = ref({ |
|
||||
fgLocationCode: undefined, |
|
||||
productionLineCode: undefined, |
|
||||
itemCode: undefined, |
|
||||
available: undefined, |
|
||||
activeTime: undefined, |
|
||||
expireTime: undefined, |
|
||||
remark: undefined |
|
||||
}) |
|
||||
const formRules = reactive({ |
|
||||
fgLocationCode: [{ required: true, message: '完工收货库位不能为空', trigger: 'blur' }], |
|
||||
productionLineCode: [{ required: true, message: '产线代码不能为空', trigger: 'blur' }], |
|
||||
itemCode: [{ required: true, message: '物品代码不能为空', trigger: 'blur' }], |
|
||||
available: [{ required: true, message: '是否可用不能为空', trigger: 'change' }] |
|
||||
}) |
|
||||
const formRef = ref() // 表单 Ref |
|
||||
|
|
||||
/** 打开弹窗 */ |
|
||||
const open = async (type: string, id?: number) => { |
|
||||
dialogVisible.value = true |
|
||||
dialogTitle.value = t('action.' + type) |
|
||||
formType.value = type |
|
||||
resetForm() |
|
||||
// 修改时,设置数据 |
|
||||
if (id) { |
|
||||
formLoading.value = true |
|
||||
try { |
|
||||
formData.value = await ProductionlineitemApi.getProductionlineitem(id) |
|
||||
} finally { |
|
||||
formLoading.value = false |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗 |
|
||||
|
|
||||
/** 提交表单 */ |
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调 |
|
||||
const submitForm = async () => { |
|
||||
// 校验表单 |
|
||||
if (!formRef) return |
|
||||
const valid = await formRef.value.validate() |
|
||||
if (!valid) return |
|
||||
// 提交请求 |
|
||||
formLoading.value = true |
|
||||
try { |
|
||||
const data = formData.value as unknown as ProductionlineitemApi.ProductionlineitemVO |
|
||||
if (formType.value === 'create') { |
|
||||
await ProductionlineitemApi.createProductionlineitem(data) |
|
||||
message.success(t('common.createSuccess')) |
|
||||
} else { |
|
||||
await ProductionlineitemApi.updateProductionlineitem(data) |
|
||||
message.success(t('common.updateSuccess')) |
|
||||
} |
|
||||
dialogVisible.value = false |
|
||||
// 发送操作成功的事件 |
|
||||
emit('success') |
|
||||
} finally { |
|
||||
formLoading.value = false |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/** 重置表单 */ |
|
||||
const resetForm = () => { |
|
||||
formData.value = { |
|
||||
fgLocationCode: undefined, |
|
||||
productionLineCode: undefined, |
|
||||
itemCode: undefined, |
|
||||
available: undefined, |
|
||||
activeTime: undefined, |
|
||||
expireTime: undefined, |
|
||||
remark: undefined |
|
||||
} |
|
||||
formRef.value?.resetFields() |
|
||||
} |
|
||||
</script> |
|
@ -1,177 +0,0 @@ |
|||||
<template> |
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible"> |
|
||||
<div class="p-20px m--10px" style="max-height: 600px;overflow-y: auto;"> |
|
||||
<el-form |
|
||||
ref="formRef" |
|
||||
:model="formData" |
|
||||
:rules="formRules" |
|
||||
label-width="100px" |
|
||||
v-loading="formLoading" |
|
||||
> |
|
||||
<el-row> |
|
||||
<el-col :span="12"> |
|
||||
|
|
||||
<el-form-item label="供应商代码" prop="supplierCode"> |
|
||||
<el-input v-model="formData.supplierCode" placeholder="请输入供应商代码" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
<el-col :span="12"> |
|
||||
|
|
||||
<el-form-item label="物料代码" prop="itemCode"> |
|
||||
<el-input v-model="formData.itemCode" placeholder="请输入物料代码" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="货币" prop="currency"> |
|
||||
<el-select v-model="formData.currency" placeholder="请选择货币"> |
|
||||
<el-option |
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.CURRENCY)" |
|
||||
:key="dict.value" |
|
||||
:label="dict.label" |
|
||||
:value="dict.value" |
|
||||
/> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
<el-col :span="12"> |
|
||||
|
|
||||
<el-form-item label="价格" prop="price"> |
|
||||
<el-input v-model="formData.price" placeholder="请输入价格" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="是否可用" prop="available"> |
|
||||
<el-select v-model="formData.available" placeholder="请选择是否可用"> |
|
||||
<el-option |
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.TRUE_FALSE)" |
|
||||
:key="dict.value" |
|
||||
:label="dict.label" |
|
||||
:value="dict.value" |
|
||||
/> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="生效时间" prop="activeTime"> |
|
||||
<el-date-picker |
|
||||
v-model="formData.activeTime" |
|
||||
type="date" |
|
||||
value-format="x" |
|
||||
placeholder="选择生效时间" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
<el-col :span="12"> |
|
||||
<el-form-item label="失效时间" prop="expireTime"> |
|
||||
<el-date-picker |
|
||||
v-model="formData.expireTime" |
|
||||
type="date" |
|
||||
value-format="x" |
|
||||
placeholder="选择失效时间" |
|
||||
/> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
<el-col :span="12"> |
|
||||
|
|
||||
<el-form-item label="备注" prop="remark"> |
|
||||
<el-input v-model="formData.remark" placeholder="请输入备注" /> |
|
||||
</el-form-item> |
|
||||
</el-col> |
|
||||
</el-row> |
|
||||
</el-form> |
|
||||
</div> |
|
||||
<template #footer> |
|
||||
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button> |
|
||||
<el-button @click="dialogVisible = false">取 消</el-button> |
|
||||
</template> |
|
||||
</Dialog> |
|
||||
</template> |
|
||||
<script setup lang="ts"> |
|
||||
import { DICT_TYPE, getStrDictOptions, getIntDictOptions } from '@/utils/dict' |
|
||||
import * as StdcostpriceApi from '@/api/wms/stdcostprice' |
|
||||
|
|
||||
const { t } = useI18n() // 国际化 |
|
||||
const message = useMessage() // 消息弹窗 |
|
||||
|
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示 |
|
||||
const dialogTitle = ref('') // 弹窗的标题 |
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 |
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改 |
|
||||
const formData = ref({ |
|
||||
supplierCode: undefined, |
|
||||
itemCode: undefined, |
|
||||
currency: undefined, |
|
||||
price: undefined, |
|
||||
available: undefined, |
|
||||
activeTime: undefined, |
|
||||
expireTime: undefined, |
|
||||
remark: undefined |
|
||||
}) |
|
||||
const formRules = reactive({ |
|
||||
supplierCode: [{ required: true, message: '供应商代码不能为空', trigger: 'blur' }], |
|
||||
itemCode: [{ required: true, message: '物料代码不能为空', trigger: 'blur' }], |
|
||||
currency: [{ required: true, message: '货币不能为空', trigger: 'change' }], |
|
||||
price: [{ required: true, message: '价格不能为空', trigger: 'blur' }], |
|
||||
available: [{ required: true, message: '是否可用不能为空', trigger: 'change' }] |
|
||||
}) |
|
||||
const formRef = ref() // 表单 Ref |
|
||||
|
|
||||
/** 打开弹窗 */ |
|
||||
const open = async (type: string, id?: number) => { |
|
||||
dialogVisible.value = true |
|
||||
dialogTitle.value = t('action.' + type) |
|
||||
formType.value = type |
|
||||
resetForm() |
|
||||
// 修改时,设置数据 |
|
||||
if (id) { |
|
||||
formLoading.value = true |
|
||||
try { |
|
||||
formData.value = await StdcostpriceApi.getStdcostprice(id) |
|
||||
} finally { |
|
||||
formLoading.value = false |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗 |
|
||||
|
|
||||
/** 提交表单 */ |
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调 |
|
||||
const submitForm = async () => { |
|
||||
// 校验表单 |
|
||||
if (!formRef) return |
|
||||
const valid = await formRef.value.validate() |
|
||||
if (!valid) return |
|
||||
// 提交请求 |
|
||||
formLoading.value = true |
|
||||
try { |
|
||||
const data = formData.value as unknown as StdcostpriceApi.StdcostpriceVO |
|
||||
if (formType.value === 'create') { |
|
||||
await StdcostpriceApi.createStdcostprice(data) |
|
||||
message.success(t('common.createSuccess')) |
|
||||
} else { |
|
||||
await StdcostpriceApi.updateStdcostprice(data) |
|
||||
message.success(t('common.updateSuccess')) |
|
||||
} |
|
||||
dialogVisible.value = false |
|
||||
// 发送操作成功的事件 |
|
||||
emit('success') |
|
||||
} finally { |
|
||||
formLoading.value = false |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/** 重置表单 */ |
|
||||
const resetForm = () => { |
|
||||
formData.value = { |
|
||||
supplierCode: undefined, |
|
||||
itemCode: undefined, |
|
||||
currency: undefined, |
|
||||
price: undefined, |
|
||||
available: undefined, |
|
||||
activeTime: undefined, |
|
||||
expireTime: undefined, |
|
||||
remark: undefined |
|
||||
} |
|
||||
formRef.value?.resetFields() |
|
||||
} |
|
||||
</script> |
|
Loading…
Reference in new issue