You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

874 lines
27 KiB

1 year ago
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<Search
:schema="[...SupplierdeliverRequestMain.allSchemas.searchSchema,...SupplierdeliverRequestDetail.allSchemas.searchSchema]"
1 year ago
@search="setSearchParams"
@reset="setSearchParams"
/>
</ContentWrap>
<!-- 列表头部 -->
<TableHead
:HeadButttondata="HeadButttondata"
@button-base-click="buttonBaseClick"
:routeName="routeName"
@updataTableColumns="updataTableColumns"
@searchFormClick="searchFormClick"
:allSchemas="SupplierdeliverRequestMain.allSchemas"
:detailAllSchemas="SupplierdeliverRequestDetail.allSchemas"
1 year ago
/>
<!-- 列表 -->
<ContentWrap>
<Table
:columns="tableColumns"
:data="tableObject.tableList"
:loading="tableObject.loading"
:pagination="{
total: tableObject.total
}"
v-model:pageSize="tableObject.pageSize"
v-model:currentPage="tableObject.currentPage"
v-model:sort="tableObject.sort"
>
<template #number="{ row }">
<el-button type="primary" link @click="openDetail(row, '单据号', row.number)">
<span>{{ row.number }}</span>
</el-button>
</template>
<template #action="{ row }">
<ButtonBase :Butttondata="butttondata(row)" @button-base-click="buttonTableClick($event, row)" />
</template>
</Table>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<BasicForm
ref="formRef"
:isOpenSearchTable="true"
:indexTableColumn="0"
1 year ago
@success="getList"
:rules="SupplierdeliverRequestMainRules"
:formAllSchemas="SupplierdeliverRequestMain.allSchemas"
:tableAllSchemas="SupplierdeliverRequestDetail.allSchemas"
:tableFormRules="SupplierdeliverRequestDetailRules"
:tableData="tableData"
:apiUpdate="SupplierdeliverRequestMainApi.updateSupplierdeliverRequestMain"
:apiCreate="SupplierdeliverRequestMainApi.createSupplierdeliverRequestMain"
:isBusiness="true"
@handleAddTable="handleAddTable"
@handleDeleteTable="handleDeleteTable"
@searchTableSuccess="searchTableSuccess"
@submitForm="submitForm"
@formFormDateChange="formFormDateChange"
>
<template v-slot="{row}">
<el-date-picker v-bind:modelValue="row['expireTime']?addDay(row['produceDate'],row['expireTime']).format('YYYY-MM-DD'):'2099-12-31'"
:clearable="true"
style="width: 100%"
:disabled="true"
placeholder="选择日期"/>
</template>
</BasicForm>
1 year ago
<!-- 详情 -->
<Detail
ref="detailRef"
12 months ago
:annexTable="[{
label: '质检明细',
prop: 'uploadFile',
tableName:'SupplierdeliverInspectionDetail',
hasSubDetail:true, // 附件中是否展示明细表
12 months ago
align:'left',
//明细表数据
subDetailTableData:{
queryParams:[{
queryField:'masterId',
rowField:'id'
}], // 查询参数
getSubList:SupplierdeliverInspectionDetailApi.getSupplierdeliverInspectionDetailPage,//请求接口
tableColumns:SupplierdeliverInspectionDetail.allSchemas.tableColumns,
tableList:[],//表格数据
total:1,
pageSize:10,
currentPage:1,
}
12 months ago
}]"
1 year ago
:isBasic="false"
:allSchemas="SupplierdeliverRequestMain.allSchemas"
:detailAllSchemas="SupplierdeliverRequestDetail.allSchemas"
:detailAllSchemasRules="SupplierdeliverRequestDetailRules"
:apiCreate="SupplierdeliverRequestDetailApi.createSupplierdeliverRequestDetail"
:apiUpdate="SupplierdeliverRequestDetailApi.updateSupplierdeliverRequestDetail"
:apiPage="SupplierdeliverRequestDetailApi.getSupplierdeliverRequestDetailPage"
:apiDelete="SupplierdeliverRequestDetailApi.deleteSupplierdeliverRequestDetail"
@searchTableSuccessDetail="searchTableSuccessDetail"
/>
<!-- 导入 -->
<ImportForm
ref="importFormRef"
url="/wms/supplierdeliver-request-main/import"
:importTemplateData="importTemplateData"
@success="importSuccess"
:updateIsDisable="true"
:coverIsDisable="true"
:mode="2"
/>
<!-- 创建标签 -->
<BasicForm
ref="formLabelRef"
@success="getList"
:tableAllSchemas="SupplierdeliverRequestDetailLabel.allSchemas"
:tableFormRules="SupplierdeliverRequestDetailRules"
:tableData="detatableData.tableList"
:isBusiness="true"
:isShowButton="false"
@searchTableSuccess="searchTableSuccessLabel"
@submitForm="submitFormLabel"
:isShowReduceButton="false"
/>
<!-- 上传质量报告 -->
<BasicForm
ref="ploadQualityReportRef"
@success="getList"
:formAllSchemas="SupplierdeliverInspectionDetail.allSchemas"
:tableAllSchemas="SupplierdeliverInspectionDetail.allSchemas"
:tableData="ploadQualityReportTableData"
@handleAddTable="SupplierdeliverInspectionDetailApi.createSupplierdeliverInspectionDetail"
@handleDeleteTable="SupplierdeliverInspectionDetailApi.deleteSupplierdeliverInspectionDetail"
@submitForm="submitFormUploadQualityReport"
:isShowReduceButton="true"
>
<template #SupplierdeliverInspectionDetail>
<span>1111</span>
</template>
</BasicForm>
1 year ago
</template>
<script setup lang="ts">
import download from '@/utils/download'
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
import { getAccessToken } from '@/utils/auth'
import { formatDate } from '@/utils/formatTime'
1 year ago
import {
SupplierdeliverRequestMain,
SupplierdeliverRequestMainRules,
SupplierdeliverRequestDetail,
SupplierdeliverRequestDetailRules,
SupplierdeliverRequestDetailLabel
1 year ago
} from './supplierdeliverRequestMain.data'
import {   SupplierdeliverInspectionDetail} from '../supplierdeliverInspectionDetail/supplierdeliverInspectionDetail.data'
1 year ago
import * as SupplierdeliverRequestMainApi from '@/api/wms/supplierdeliverRequestMain'
import * as SupplierdeliverRequestDetailApi from '@/api/wms/supplierdeliverRequestDetail'
import * as defaultButtons from '@/utils/disposition/defaultButtons'
import * as PurchasePlanDetailApi from '@/api/wms/purchasePlanDetail'
import * as ItembasicApi from '@/api/wms/itembasic'
import * as SupplierdeliverInspectionDetailApi from '@/api/wms/supplierdeliverInspectionDetail'
import { PurchasePlanDetail } from '../purchasePlanMain/purchasePlanMain.data'
import { addDay } from '@/utils/formatTime'
1 year ago
// 供应商发货申请
defineOptions({ name: 'SupplierdeliverRequestMain' })
const message = useMessage() // 消息弹窗
const { t } = useI18n() // 国际化
const genLabelId = ref();
const route = useRoute() // 路由信息
const routeName = ref()
routeName.value = route.name
const tableColumns = ref([...SupplierdeliverRequestMain.allSchemas.tableColumns,...SupplierdeliverRequestDetail.allSchemas.tableMainColumns])
1 year ago
// 字段设置 更新主列表字段
const updataTableColumns = (val) => {
tableColumns.value = val
}
const planArriveTimeStr = ref()
// 查询页面返回
const searchTableSuccess = (formField, searchField, val, formRef, type, row) => {
nextTick(() => {
console.log("type:",type)
1 year ago
console.log("formField:",formField)
console.log(formField, searchField, val, formRef, type, row)
1 year ago
if (type == 'tableForm') {
// 明细查询页赋值
// row[formField] = val[0][searchField]
// if (formField == 'poNumber') {
// row['poNumber'] = val[0]['poNumber']
// row['itemCode'] = val[0]['itemCode']
// row['poLine'] = val[0]['poLine']
// row['orderQty'] = val[0]['orderQty']
// row['uom'] = val[0]['uom']
// }
//添加费用明细--点击确定
const itemCodes = []
val.forEach(item=>{
if(tableData.value.find(item1=>item1['id'] == item['id'])) return
const newRow = {...row}
newRow[formField] = item[searchField]
newRow['poNumber'] = item['poNumber']
newRow['itemCode'] = item['itemCode']
newRow['poLine'] = item['poLine']
newRow['orderQty'] = item['orderQty']
newRow['uom'] = item['uom']
itemCodes.push(item['itemCode'])
tableData.value.push(newRow)
})
//有效期
ItembasicApi.getItembasicPage({
code:itemCodes.join(',')
}).then((res)=>{
res.list.forEach((item,index)=>{
const findItem = tableData.value.find(item1=>item1['itemCode']==item['code'])
findItem['expireTime'] = findItem['expireTime']
})
})
1 year ago
} else {
const setV = {}
setV[formField] = val[0][searchField]
if(formField == 'ppNumber'){
//新增--选择完要货计划,自动展示明细
getSearchTableData(val[0]['number'],formField,searchField)
1 year ago
// 设置计划到货时间
let beginTime = val[0]['endTime']
let deliveryDate = formatDate(val[0]['deliveryDate'],'YYYY-MM-DD')
planArriveTimeStr.value = deliveryDate + ' '+ beginTime+":00"
setV['planArriveTime']= new Date(planArriveTimeStr.value).valueOf();
// 清空子表数据
tableData.value = []
}
if(formField == 'supplierCode'){
setV['contactName'] = val[0]['contacts']
setV['contactPhone'] = val[0]['phone']
setV['contactEmail'] = val[0]['email']
}
formRef.setValues(setV)
}
})
}
const getSearchTableData = async (number,formField,searchField)=>{
const {tableObject ,tableMethods} = useTable({
defaultParams:{number},
getListApi: PurchasePlanDetailApi.getPurchasePlanDetailPage // 分页接口
})
// 获得表格的各种操作
const { getList:getList1 } = tableMethods
await getList1()
const tableColumns = PurchasePlanDetail.allSchemas.tableFormColumns
tableColumns.forEach((item) => {
item.width = item.table?.width || 150
})
tableData.value = []
const itemCodes = []
tableObject.tableList.forEach(row=>{
const newRow = JSON.parse(JSON.stringify({...tableFormKeys,...row}))
newRow[formField] = row[searchField]
newRow['poNumber'] = row['poNumber']
newRow['itemCode'] = row['itemCode']
newRow['poLine'] = row['poLine']
newRow['orderQty'] = row['orderQty']
newRow['uom'] = row['uom']
tableData.value.push(newRow)
itemCodes.push(row['itemCode'])
})
//有效期
ItembasicApi.getItembasicPage({
code:itemCodes.join(',')
}).then((res)=>{
res.list.forEach((item,index)=>{
const findItem = tableData.value.find(item1=>item1['itemCode']==item['code'])
findItem['expireTime'] = findItem['expireTime']
})
})
}
1 year ago
// 查询页面返回——详情
const searchTableSuccessDetail = (formField, searchField, val, formRef) => {
nextTick(() => {
const setV = {}
setV[formField] = val[0][searchField]
if (formField == 'poNumber') {
setV['poNumber'] = val[0]['poNumber']
setV['itemCode'] = val[0]['itemCode']
setV['poLine'] = val[0]['poLine']
setV['uom'] = val[0]['uom']
setV['orderQty'] = val[0]['orderQty']
}
formRef.setValues(setV)
})
}
// 查询页面返回
const searchTableSuccessLabel = (formField, searchField, val, formRef, type, row) => {
nextTick(() => {
console.log("formField:",formField)
console.log("val:",val)
if (type == 'tableForm') {
// 明细查询页赋值
row[formField] = val[0][searchField]
if (formField == 'packUnit') {
row['packUnit'] = val[0]['packUnit']
row['packQty'] = val[0]['packQty']
}
if (formField == 'secondPackUnit') {
row['secondPackUnit'] = val[0]['packUnit']
row['secondPackQty'] = val[0]['packQty']
}
}
})
}
1 year ago
const { tableObject, tableMethods } = useTable({
getListApi: SupplierdeliverRequestMainApi.getSupplierdeliverRequestMainPage // 分页接口
})
// 获得表格的各种操作
const { getList, setSearchParams } = tableMethods
// 列表头部按钮
const HeadButttondata = [
defaultButtons.defaultAddBtn({ hasPermi: 'wms:supplierdeliver-request-main:create' }), // 新增
defaultButtons.defaultImportBtn({ hasPermi: 'wms:supplierdeliver-request-main:import' }), // 导入
defaultButtons.defaultExportBtn({ hasPermi: 'wms:supplierdeliver-request-main:export' }), // 导出
defaultButtons.defaultFreshBtn(null), // 刷新
defaultButtons.defaultFilterBtn(null), // 筛选
defaultButtons.defaultSetBtn(null) // 设置
// {
// label: '自定义扩展按钮',
// name: 'zdy',
// hide: false,
// type: 'primary',
// icon: 'Select',
// color: ''
// },
]
// 头部按钮事件
const buttonBaseClick = (val, item) => {
if (val == 'add') {
// 新增
openForm('create')
} else if (val == 'import') {
// 导入
handleImport()
} else if (val == 'export') {
// 导出
handleExport()
} else if (val == 'refresh') {
// 刷新
if (tableObject.params.filters && tableObject.params.filters.length > 0 ) {
searchFormClick({
filters: tableObject.params.filters
})
} else {
getList()
}
} else if (val == 'filtrate') {
// 筛选
}
}
// 根据状态返回该按钮是否显示
const isShowMainButton = (row, val) => {
if (val.indexOf(row.status) > -1) {
return false
} else {
return true
}
}
// 根据状态返回该按钮是否显示
const isShowMainButtonLabel = (row, val) => {
if (val.indexOf(row.status) > -1) {
if(row.labelStatus == '2'){
return true
}else{
return false
}
} else {
return true
}
}
// 列表-操作按钮
const butttondata = (row) => {
return [
defaultButtons.mainListPurchasePlanOpeBtn({ hide: isShowMainButton(row, ['5']) }), // 打开
defaultButtons.mainListPlanUploadQualityReportBtn({ hide: isShowMainButton(row, ['1','2','3']) }), // 上传质检审批
1 year ago
defaultButtons.mainListPlanSubBtn({ hide: isShowMainButton(row, ['1']) }), // 提交审批
defaultButtons.mainListPlanAppBtn({ hide: isShowMainButton(row, ['2']) }), // 审批通过
defaultButtons.mainListPlanTurBtn({ hide: isShowMainButton(row, ['2']) }), // 驳回按钮
defaultButtons.mainListEditBtn({
hide: isShowMainButton(row, ['1']),
hasPermi: 'wms:supplierdeliver-request-main:update'
}), // 编辑
// defaultButtons.mainListDeleteBtn({ hasPermi: 'wms:supplierdeliver-request-main:delete' }), // 删除
{
label: '生成标签',
name: 'ssbq',
hide: isShowMainButtonLabel(row, ['3']),
type: 'primary',
icon: '',
color: '',
hasPermi: '',
link: true // 文本展现按钮
},
defaultButtons.mainListPointBtn({ hide: isShowMainButton(row, ['3','8']) }), // 标签打印
//defaultButtons.mainListDocumentPrintBtn({ hide: isShowMainButton(row, ['3','8']) }), // 单据打印
// 生成记录
{
label: '发货',
name: 'genRecords',
hide: isShowMainButton(row, ['3']),
type: 'primary',
icon: '',
color: '',
hasPermi: '',
link: true // 文本展现按钮
},
defaultButtons.mainListPurchasePlanCloBtn({ hide: isShowMainButton(row, ['1', '2', '4','3']) }), // 关闭
1 year ago
]
}
// 列表-操作按钮事件
const buttonTableClick = async (val, row) => {
if (val == 'mainPurPlanOpe') {
// 打开
handleOpe(row.id)
} else if (val == 'mainPurPlanClo') {
// 关闭
handleClo(row.id)
} else if (val == 'mainPlanUploadQualityReport') {
// 上传质量报告
handleUploadQualityReport(row)
} else if (val == 'mainPlanSub') {
1 year ago
// 提交审批
handleSub(row.id)
} else if (val == 'mainPlanApp') {
// 审批通过
handleApp(row.id)
} else if (val == 'mainPlanTur') {
// 驳回按钮
handleTur(row.id)
} else if (val == 'genRecords') {
// 处理
genRecords(row.id)
} else if (val == 'edit') {
// 编辑
openForm('update', row)
} else if (val == 'delete') {
// 删除
handleDelete(row.id)
} else if (val == 'ssbq') {
await SupplierdeliverRequestMainApi.selfCheckReport(row.id).then(async (res) => {
if(!res){
message.warning("请先上传自检报告!")
return
}else{
// 生成标签
detatableData.params = {
masterId:row.id
}
genLabelId.value = row.id
await getDetailList()
formLabelRef.value.open('create', row, null,'createLabel')//创建标签页面 createLabel 标题
}
}).catch(err => {
console.log("自检报告校验异常",err)
})
} else if (val == 'point') {
// 标签打印
labelPrint(row)
} else if (val == 'documentPrint') {
// 单据打印
handleDocumentPrint(row.id)
}
}
// 获取部门 用于详情 部门回显
const { wsCache } = useCache()
/** 详情操作 */
const detailRef = ref()
const openDetail = (row: any, titleName: any, titleValue: any) => {
const departmentCode = wsCache.get(CACHE_KEY.DEPT).find((account) => account.id == row.departmentCode)?.name
if (departmentCode) row.departmentCode = JSON.parse(JSON.stringify(departmentCode))
detailRef.value.openDetail(row, titleName, titleValue,'requestSupplierdeliverMain')
}
//添加/修改操作
const formRef = ref()
const openForm = async (type: string, row?: number) => {
if(type == "update"){
SupplierdeliverRequestMain.allSchemas.formSchema.forEach((item) => {
if(item.field == 'supplierCode'){
item.componentProps.isSearchList = false
item.componentProps.disabled = true
}
if(item.field == 'ppNumber'){
item.componentProps.isSearchList = false
item.componentProps.disabled = true
}
if(item.field == 'asnNumber'){
item.componentProps.disabled = true
}
if(item.field == 'planArriveTime'){
item.componentProps.disabled = true
}
})
}else {
SupplierdeliverRequestMain.allSchemas.formSchema.forEach((item) => {
if(item.field == 'supplierCode'){
item.componentProps.isSearchList = true
}
if(item.field == 'ppNumber'){
item.componentProps.isSearchList = true
}
if(item.field == 'asnNumber'){
item.componentProps.disabled = false
}
if(item.field == 'planArriveTime'){
item.componentProps.disabled = false
}
})
}
tableData.value = [] // 重置明细数据
formRef.value.open(type, row)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
// 删除的二次确认
await message.delConfirm()
tableObject.loading = true
// 发起删除
await SupplierdeliverRequestMainApi.deleteSupplierdeliverRequestMain(id)
message.success(t('common.delSuccess'))
// 刷新列表
await getList()
} catch {}finally{
tableObject.loading = false
}
}
/** 关闭按钮操作 */
const handleClo = async (id: number) => {
try {
// 关闭的二次确认
await message.confirm('是否关闭所选中数据?')
tableObject.loading = true
// 发起关闭
await SupplierdeliverRequestMainApi.cloSupplierdeliverRequestMain(id)
message.success(t('关闭成功!'))
// 刷新列表
await getList()
} catch {}finally{
tableObject.loading = false
}
}
/** 打开按钮操作 */
const handleOpe = async (id: number) => {
try {
// 打开的二次确认
await message.confirm('是否打开所选中数据?')
tableObject.loading = true
// 发起打开
await SupplierdeliverRequestMainApi.opeSupplierdeliverRequestMain(id)
message.success(t('打开成功!'))
// 刷新列表
await getList()
} catch {}finally{
tableObject.loading = false
}
}
const ploadQualityReportRef = ref()
const ploadQualityReportTableData = ref([])
/** 上传质量报告 */
const handleUploadQualityReport = async (row) => {
console.log('SupplierdeliverInspectionDetail',SupplierdeliverInspectionDetail.allSchemas)
const uploadFile = SupplierdeliverInspectionDetail.allSchemas.formSchema.find(item=>item.field=='uploadFile')
if(uploadFile){
uploadFile['componentProps']['upData']['tableId'] = row.id
}
ploadQualityReportRef.value.open('create', null, {masterId:row.id},'上传质量报告')//创建标签页面 createLabel 标题
const tableFormKeys = {}
SupplierdeliverInspectionDetail.allSchemas.tableFormColumns.forEach((item) => {
tableFormKeys[item.field] = item.default ? item.default : ''
})
ploadQualityReportTableData.value = [tableFormKeys]
}
const submitFormUploadQualityReport = async (formType, data) => {
delete data.number
12 months ago
data.subList = ploadQualityReportTableData.value // 拼接子表数据参数
if (formType === 'create') {
await SupplierdeliverInspectionDetailApi.createSupplierdeliverInspectionDetail(data)
message.success(t('common.createSuccess'))
} else {
await SupplierdeliverInspectionDetailApi.updateSupplierdeliverInspectionDetail(data)
message.success(t('common.updateSuccess'))
}
ploadQualityReportRef.value.dialogVisible = false
getList()
}
1 year ago
/** 提交审批按钮操作 */
const handleSub = async (id: number) => {
try {
// 提交审批的二次确认
await message.confirm('是否提交审批所选中数据?')
tableObject.loading = true
// 发起提交审批
await SupplierdeliverRequestMainApi.subSupplierdeliverRequestMain(id)
message.success(t('提交审批成功!'))
// 刷新列表
await getList()
} catch {}finally{
tableObject.loading = false
}
}
/** 审批通过按钮操作 */
const handleApp = async (id: number) => {
try {
// 审批通过的二次确认
await message.confirm('是否审批通过所选中数据?')
tableObject.loading = true
// 发起审批通过
await SupplierdeliverRequestMainApi.appSupplierdeliverRequestMain(id)
message.success(t('审批通过成功!'))
// 刷新列表
await getList()
} catch {}finally{
tableObject.loading = false
}
}
/** 驳回按钮操作 */
const handleTur = async (id: number) => {
try {
// 驳回的二次确认
await message.confirm('是否驳回所选中数据?')
tableObject.loading = true
// 发起驳回
await SupplierdeliverRequestMainApi.rejSupplierdeliverRequestMain(id)
message.success(t('驳回成功!'))
// 刷新列表
await getList()
} catch {}finally{
tableObject.loading = false
}
}
/** 处理按钮操作 */
const genRecords = async (id: number) => {
try {
await SupplierdeliverRequestMainApi.selfCheckReport(id).then(res => {
if(!res){
message.warning("请先上传自检报告!")
return
}else{
// 处理的二次确认
message.confirm('是否处理所选中数据?')
tableObject.loading = true
// 发起处理
SupplierdeliverRequestMainApi.genRecordsSupplierdeliverRequestMain(id).then(res => {
message.success(t('处理成功!'))
// 单据打印
handleDocumentPrint(res)
})
// 刷新列表
getList()
}
}).catch(err => {
console.log("自检报告校验异常",err)
})
} catch {}finally{
tableObject.loading = false
}
}
/** 导出按钮操作 */
const exportLoading = ref(false) // 导出的加载中
const handleExport = async () => {
try {
// 导出的二次确认
await message.exportConfirm()
// 发起导出
exportLoading.value = true
const data = await SupplierdeliverRequestMainApi.exportSupplierdeliverRequestMain(
tableObject.params
)
download.excel(data, '供应商发货申请主.xlsx')
} catch {
} finally {
exportLoading.value = false
}
}
// 生成标签
const isCreateLabel = ref(false)
const formLabelRef = ref()
const { tableObject: detatableData, tableMethods: detatableMethods } =useTable({
getListApi: SupplierdeliverRequestDetailApi.getSupplierdeliverRequestDetailPage
})
const { getList:getDetailList } = detatableMethods
// 生成标签按钮操作
const submitFormLabel = async (formType, data) => {
try {
console.log("formType==",formType)
console.log("data==",data)
data.subList = detatableData.tableList
console.log("detatableData",detatableData)
await message.confirm('是否为此数据生成标签?')
await SupplierdeliverRequestMainApi.genLabel(data)
isCreateLabel.value = true
message.success('创建标签成功')
} finally {
formLabelRef.value.formLoading = false
formLabelRef.value.dialogVisible = false
}
}
const BASE_URL = import.meta.env.VITE_JMREPORT_BASE_URL
const src = ref(BASE_URL + '/jmreport/view/922729953438072832?token=' + getAccessToken())
// 标签打印
const labelPrint = async (row) => {
window.open(src.value + '&asn_number=' + row.asnNumber)
}
const print = async () => {
window.open(src.value + '&number=' + detatableData.tableList[0].number)
}
// 单据打印
// const documentSrc = ref(BASE_URL + '/jmreport/view/884680688168280064?token=' + getAccessToken())
const documentSrc = ref(BASE_URL + '/jmreport/view/932556833517789184?token=' + getAccessToken())
const handleDocumentPrint = async (id) => {
window.open(documentSrc.value + '&id=' + id)
}
/**
* tableForm方法
*/
const tableFormKeys = {}
SupplierdeliverRequestDetail.allSchemas.tableFormColumns.forEach((item) => {
tableFormKeys[item.field] = item.default ? item.default : ''
})
const tableData = ref([])
// 添加明细
const handleAddTable = () => {
tableData.value.push(JSON.parse(JSON.stringify(tableFormKeys)))
}
// 删除明细
const handleDeleteTable = (item, index) => {
tableData.value.splice(index, 1)
}
// 主子数据 提交
const submitForm = async (formType, data) => {
data.subList = tableData.value // 拼接子表数据参数
let isHave = data.subList.some((item) => {
console.log("CCCCC",item.expireDate)
if(item.expireDate != null){
item.produceDate > item.expireDate
}
})
if (isHave) {
message.error('生产日期不可以大于过期日期')
formRef.value.formLoading = false
return
}
try {
if (formType === 'create') {
let planArriveStr = formatDate(data.planArriveTime);
if(planArriveStr > planArriveTimeStr.value){
let confirmFlag = false;
await message.confirm("计划到货时间大于要货计划送达日期是否继续?").then(() => {
console.log("选择了OK")
//选择OK
}).catch(() => {
//选择取消
console.log("选择了cancel")
confirmFlag = true;
formRef.value.formLoading = false
return;
})
if(confirmFlag){
return;
}
}
if(tableData.value.length <= 0){
message.warning(`子表明细不能为空!`)
formRef.value.formLoading = false
return;
}
await SupplierdeliverRequestMainApi.createSupplierdeliverRequestMain(data)
message.success(t('common.createSuccess'))
} else {
await SupplierdeliverRequestMainApi.updateSupplierdeliverRequestMain(data)
message.success(t('common.updateSuccess'))
}
formRef.value.dialogVisible = false
// 刷新当前列表
getList()
} finally {
formRef.value.formLoading = false
}
}
/** 导入 */
const importFormRef = ref()
const handleImport = () => {
importFormRef.value.open()
}
// 导入附件弹窗所需的参数
const importTemplateData = reactive({
templateUrl: '',
templateTitle: '供应商发货申请主导入模版.xlsx'
})
// 导入成功之后
const importSuccess = () => {
getList()
}
// 筛选提交
const searchFormClick = (searchData) => {
tableObject.params = {
isSearch: true,
filters: searchData.filters
}
getList() // 刷新当前列表
}
const formFormDateChange = (field, val,row, index) => {
if(field == 'produceDate'){
let produceDateStr = formatDate(val,'YYYYMMDD');
row.batch = produceDateStr
}
}
/** 初始化 **/
onMounted(async () => {
getList()
importTemplateData.templateUrl = await SupplierdeliverRequestMainApi.importTemplate()
})
</script>