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.

999 lines
32 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 v-clientTable
1 year ago
: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,$index }">
<ButtonBase :Butttondata="butttondata(row,$index)" @button-base-click="buttonTableClick($event, row)" />
1 year ago
</template>
</Table>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<supplierdeliverBasicForm ref="supplierdeliverFormRef" @getList="getList" ></supplierdeliverBasicForm>
<!-- <BasicForm
1 year ago
ref="formRef"
:isOpenSearchTable="true"
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"
@onEnter="onEnter"
> -->
<!-- <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, // 附件中是否展示明细表
11 months ago
showPreview:true, // 附件中是否展示预览按钮
fileType:['pdf','jpg','png','jpeg'],
12 months ago
align:'left',
//明细表数据
subDetailTableData:{
queryParams:[{
queryField:'masterId',
12 months ago
rowField:'masterId'
}], // 查询参数
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"
@clearInput='clearInput'
1 year ago
/>
<!-- 上传质量报告 -->
<BasicForm
ref="ploadQualityReportRef"
@success="getList"
:formAllSchemas="SupplierdeliverInspectionDetail.allSchemas"
:tableAllSchemas="SupplierdeliverInspectionDetail.allSchemas"
:tableFormRules="SupplierdeliverInspectionDetailRules"
:tableData="uploadQualityReportTableData"
@handleAddTable="handleAddQualityReport"
@handleDeleteTable="handleDeleteQualityReport"
@submitForm="submitFormUploadQualityReport"
:isShowReduceButton="false"
:isShowButton="false"
>
<template #SupplierdeliverInspectionDetail>
<span>1111</span>
</template>
</BasicForm>
<!-- 标签打印 -->
11 months ago
<SearchTable style="width:905px" ref="searchTableRef" @searchTableSuccess="searchTableSuccess1" >
<!-- <template #actions>
<el-button type="primary" @click="printAllClick">打印全部</el-button>
</template> -->
</SearchTable>
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,
SupplierdeliverRequestDetail,
SupplierdeliverRequestDetailRules,
SupplierdeliverRequestDetailLabel,
SupplierdeliverRequestPackage,
1 year ago
} from './supplierdeliverRequestMain.data'
import {   SupplierdeliverInspectionDetail,SupplierdeliverInspectionDetailRules} 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 * as PackageApi from '@/api/wms/package'
import { PurchasePlanDetail } from '../purchasePlanMain/purchasePlanMain.data'
import * as SupplierApi from '@/api/wms/supplier'
import { Supplier } from '@/views/wms/basicDataManage/supplierManage/supplier/supplier.data'
import supplierdeliverBasicForm from './supplierdeliverBasicForm.vue'
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 onEnter = async (field,value)=>{
console.log(field,value)
formRef.value.opensearchTable('supplierCode', 'code', '供应商信息', Supplier.allSchemas, SupplierApi.getSupplierPage,[{
key:'code',
value:value
}])
}
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: SupplierdeliverRequestDetailApi.getSupplierdeliverRequestDetailPage // 分页接口
1 year ago
})
// 获得表格的各种操作
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,$index) => {
const findIndex = row['masterId']?tableObject.tableList.findIndex(item=>item['masterId'] == row['masterId']):-1
10 months ago
if(findIndex>-1&&findIndex<$index){
return []
}
1 year ago
return [
12 months ago
defaultButtons.mainListPurchasePlanOpeBtn({ hide: isShowMainButton(row, ['5']),hasPermi: 'wms:supplierdeliver-request-main:open' }), // 打开
defaultButtons.mainListPlanUploadQualityReportBtn({ hide: isShowMainButton(row, ['1','2','3']),hasPermi: 'wms:supplierdeliver-request-main:uploadCheck'}), // 上传质量报告
defaultButtons.mainListPlanSubBtn({ hide: isShowMainButton(row, ['1']),hasPermi: 'wms:supplierdeliver-request-main:sub' }), // 提交审批
defaultButtons.mainListPlanAppBtn({ hide: isShowMainButton(row, ['2']),hasPermi: 'wms:supplierdeliver-request-main:app' }), // 审批通过
defaultButtons.mainListPlanTurBtn({ hide: isShowMainButton(row, ['2']),hasPermi: 'wms:supplierdeliver-request-main:rej' }), // 驳回按钮
1 year ago
defaultButtons.mainListEditBtn({
hide: isShowMainButton(row, ['1']),
hasPermi: 'wms:supplierdeliver-request-main:update'
}), // 编辑
// defaultButtons.mainListDeleteBtn({ hasPermi: 'wms:supplierdeliver-request-main:delete' }), // 删除
{
11 months ago
label: t('ts.生成标签'),
1 year ago
name: 'ssbq',
hide: isShowMainButtonLabel(row, ['3']),
type: 'primary',
icon: '',
color: '',
12 months ago
hasPermi: 'wms:supplierdeliver-request-main:genLabels',
1 year ago
link: true // 文本展现按钮
},
12 months ago
defaultButtons.mainListPointBtn({ hide: isShowMainButton(row, ['3','8']),hasPermi: 'wms:supplierdeliver-request-main:printLabel' }), // 标签打印
1 year ago
//defaultButtons.mainListDocumentPrintBtn({ hide: isShowMainButton(row, ['3','8']) }), // 单据打印
// 生成记录
{
11 months ago
label: t('ts.发货'),
1 year ago
name: 'genRecords',
hide: isShowMainButton(row, ['3']),
type: 'primary',
icon: '',
color: '',
12 months ago
hasPermi: 'wms:supplierdeliver-request-main:genRecords',
1 year ago
link: true // 文本展现按钮
},
12 months ago
defaultButtons.mainListPurchasePlanCloBtn({ hide: isShowMainButton(row, ['1', '2', '4','3']),hasPermi: 'wms:supplierdeliver-request-main:close' }), // 关闭
1 year ago
]
}
// 列表-操作按钮事件
const buttonTableClick = async (val, row) => {
if (val == 'mainPurPlanOpe') {
// 打开
handleOpe(row.masterId)
1 year ago
} else if (val == 'mainPurPlanClo') {
// 关闭
handleClo(row.masterId)
} else if (val == 'mainPlanUploadQualityReport') {
// 上传质量报告
handleUploadQualityReport(row)
} else if (val == 'mainPlanSub') {
1 year ago
// 提交审批
handleSub(row.masterId)
1 year ago
} else if (val == 'mainPlanApp') {
// 审批通过
handleApp(row.masterId)
1 year ago
} else if (val == 'mainPlanTur') {
// 驳回按钮
handleTur(row.masterId)
1 year ago
} else if (val == 'genRecords') {
// 处理
genRecords(row.masterId)
1 year ago
} else if (val == 'edit') {
// 编辑
openForm('update', row)
} else if (val == 'delete') {
// 删除
handleDelete(row.masterId)
1 year ago
} else if (val == 'ssbq') {
// 生成标签
detatableData.params = {
masterId:row.masterId
}
genLabelId.value = row.masterId
await getDetailList()
formLabelRef.value.open('create', row, null,'createLabel')//创建标签页面 createLabel 标题
1 year ago
} else if (val == 'point') {
// 标签打印
labelPrint(row)
} else if (val == 'documentPrint') {
// 单据打印
handleDocumentPrint(row.masterId)
1 year ago
}
}
// 获取部门 用于详情 部门回显
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 supplierdeliverFormRef = ref()
1 year ago
const openForm = async (type: string, row?: number) => {
supplierdeliverFormRef.value.openForm(type, row)
// 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)
1 year ago
}
/** 删除按钮操作 */
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 {
// 关闭的二次确认
11 months ago
await message.confirm(t('ts.是否关闭所选中数据?'))
1 year ago
tableObject.loading = true
// 发起关闭
await SupplierdeliverRequestMainApi.cloSupplierdeliverRequestMain(id)
11 months ago
message.success(t('ts.关闭成功!'))
1 year ago
// 刷新列表
await getList()
} catch {}finally{
tableObject.loading = false
}
}
/** 打开按钮操作 */
const handleOpe = async (id: number) => {
try {
// 打开的二次确认
11 months ago
await message.confirm(t('ts.是否打开所选中数据?'))
1 year ago
tableObject.loading = true
// 发起打开
await SupplierdeliverRequestMainApi.opeSupplierdeliverRequestMain(id)
11 months ago
message.success(t('ts.打开成功!'))
1 year ago
// 刷新列表
await getList()
} catch {}finally{
tableObject.loading = false
}
}
const ploadQualityReportRef = ref()
const uploadQualityReportTableData = ref([])
const handleAddQualityReport = ()=>{
const tableFormKeys = {}
SupplierdeliverInspectionDetail.allSchemas.tableFormColumns.forEach((item) => {
tableFormKeys[item.field] = item.default ? item.default : ''
})
uploadQualityReportTableData.value.push(tableFormKeys)
console.log('handleAddQualityReport')
}
const handleDeleteQualityReport = (row,index)=>{
uploadQualityReportTableData.value.splice(index,1)
console.log('handleDeleteQualityReport',row)
}
/** 上传质量报告 */
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.masterId
}
11 months ago
ploadQualityReportRef.value.open('create', null, {masterId:row.masterId},t('ts.上传质检报告'),t('ts.上传质检报告'))//创建标签页面 createLabel 标题
const tableFormKeys = {}
SupplierdeliverInspectionDetail.allSchemas.tableFormColumns.forEach((item) => {
tableFormKeys[item.field] = item.default ? item.default : ''
})
await SupplierdeliverInspectionDetailApi.getSupplierdeliverDetailInfo(row.masterId).then(res => {
if(res){
// console.log("返回结果:",res)
uploadQualityReportTableData.value = res;
}
})
//uploadQualityReportTableData.value = [tableFormKeys]
}
const submitFormUploadQualityReport = async (formType, data) => {
delete data.number
data.subList = uploadQualityReportTableData.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 {
// 提交审批的二次确认
11 months ago
await message.confirm(t('ts.是否提交审批所选中数据?'))
1 year ago
tableObject.loading = true
// 发起提交审批
await SupplierdeliverRequestMainApi.subSupplierdeliverRequestMain(id)
11 months ago
message.success(t('ts.提交审批成功!'))
1 year ago
// 刷新列表
await getList()
} catch {}finally{
tableObject.loading = false
}
}
/** 审批通过按钮操作 */
const handleApp = async (id: number) => {
try {
// 审批通过的二次确认
11 months ago
await message.confirm(t('ts.是否审批通过所选中数据?'))
1 year ago
tableObject.loading = true
// 发起审批通过
await SupplierdeliverRequestMainApi.appSupplierdeliverRequestMain(id)
11 months ago
message.success(t('ts.审批通过成功!'))
1 year ago
// 刷新列表
await getList()
} catch {}finally{
tableObject.loading = false
}
}
/** 驳回按钮操作 */
const handleTur = async (id: number) => {
try {
// 驳回的二次确认
11 months ago
await message.confirm(t('ts.是否驳回所选中数据?'))
1 year ago
tableObject.loading = true
// 发起驳回
await SupplierdeliverRequestMainApi.rejSupplierdeliverRequestMain(id)
11 months ago
message.success(t('ts.驳回成功!'))
1 year ago
// 刷新列表
await getList()
} catch {}finally{
tableObject.loading = false
}
}
/** 处理按钮操作 */
const genRecords = async (id: number) => {
let getLoading = null
await SupplierdeliverRequestMainApi.selfCheckReport(id).then(async res => {
1 year ago
if(!res){
11 months ago
message.warning(t('ts.请先上传自检报告!'))
1 year ago
return
}else{
// 处理的二次确认
11 months ago
await message.confirm(t('ts.是否处理所选中数据?'))
getLoading = ElLoading.service({
lock: true,
text: 'loading...',
background: 'rgba(0, 0, 0, 0.7)'
})
1 year ago
// 发起处理
SupplierdeliverRequestMainApi.genRecordsSupplierdeliverRequestMain(id).then(res => {
11 months ago
message.success(t('ts.处理成功!'))
console.log('resresresresres',res)
// 刷新列表
getList()
console.log('刷新列表')
getLoading?.close()
1 year ago
// 单据打印
handleDocumentPrint(res)
}).catch(err=>{
console.log("发起处理",err)
getLoading?.close()
1 year ago
})
1 year ago
}
}).catch(err => {
console.log("自检报告校验异常",err)
getLoading?.close()
1 year ago
})
}
/** 导出按钮操作 */
const exportLoading = ref(false) // 导出的加载中
const handleExport = async () => {
try {
// 导出的二次确认
await message.exportConfirm()
// 发起导出
exportLoading.value = true
const data = await SupplierdeliverRequestMainApi.exportSupplierdeliverRequestMain(
tableObject.params
)
11 months ago
download.excel(data, `${'ts.供应商发货申请主'}.xlsx`)
1 year ago
} 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
10 months ago
if(detatableData.tableList.find(item=>item.secondPackUnit==item.packUnit)){
message.warning(t('ts.包装规格1和包装规格2不能相同'))
return
}
10 months ago
// 校验物料包装规格数量是否修改
let flag = false;
await SupplierdeliverRequestMainApi.checkPackQty(data).then(async res => {
if(res){
await message.confirm(t('ts.是否修改物料包装标包数量')+'?').then(()=>{
flag = true; //修改标包数量
}).catch(() =>{
flag = false
})
}else{
flag = true; //修改标包数量
}
})
console.log("返回结果",flag);
if(flag){
console.log("detatableData",detatableData)
await message.confirm(t('ts.是否为此数据生成标签?'))
await SupplierdeliverRequestMainApi.genLabel(data)
isCreateLabel.value = true
message.success(t('ts.创建标签成功'))
}
getList()
1 year ago
} finally {
formLabelRef.value.formLoading = false
formLabelRef.value.dialogVisible = false
}
}
const clearInput = async (field,row,index) => {
row[field]=''
row['secondPackQty']=''
SupplierdeliverRequestDetailRules.secondPackQty[0].required = false
}
1 year ago
const BASE_URL = import.meta.env.VITE_JMREPORT_BASE_URL
const src = ref(BASE_URL + '/jmreport/view/922729953438072832?token=' + getAccessToken())
11 months ago
getListApi: PurchasePlanDetailApi.getPurchasePlanDetailPage // 分页接口
1 year ago
// 标签打印
const searchTableRef = ref()
1 year ago
const labelPrint = async (row) => {
tableObject.loading = true
11 months ago
const defaultParams = {'moduleName':'supplier','recordNumber':row.number}
const {tableObject:tableObjectPrint ,tableMethods} = useTable({
defaultParams,
getListApi: PackageApi.getLabelDetailPage // 分页接口
})
11 months ago
// 获得表格的各种操作
const { getList:getListPrint } = tableMethods
getListPrint()
tableObject.loading = false
const tableColumns = SupplierdeliverRequestPackage.allSchemas.tableFormColumns
tableColumns.forEach((item) => {
item.width = item.table?.width || 150
})
11 months ago
searchTableRef.value.openData(t('ts.标签信息'),tableObjectPrint,{tableColumns},true)
}
11 months ago
11 months ago
// 打印全部
const printAllClick = ()=>{
}
12 months ago
// 批量打印--供应商发货申请
const searchTableSuccess1 = async (formField, searchField, val, formRef, type, row) => {
12 months ago
console.log('批量打印',val)
// let rows:any = []
// val.forEach(item=>{
// rows = [...rows,...item.selectionRows.map(item1=>item1.number)]
// })
if(val.length == 0){
11 months ago
message.warning(t('ts.请先选择要打印的数据'))
return
}
12 months ago
// window.open(src.value + '&asn_number=' + val.map(item1=>item1.number).join(','))
await PackageApi.batchPrintingLable(val.map(item1=>item1.number).join(',')).then(res => {
console.log(res)
window.open(src.value + '&asn_number=' + res)
}).catch(err => {
console.log(err)
11 months ago
message.error(t('ts.创建标签失败'))
})
1 year ago
}
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) {
11 months ago
message.error(t('ts.生产日期不可以大于过期日期'))
1 year ago
formRef.value.formLoading = false
return
}
try {
if (formType === 'create') {
let planArriveStr = formatDate(data.planArriveTime);
if(planArriveStr > planArriveTimeStr.value){
let confirmFlag = false;
await message.confirm(`${t('ts.计划到货时间大于')}${planArriveTimeStr.value}${t('ts.是否继续?')}`).then(() => {
1 year ago
console.log("选择了OK")
//选择OK
}).catch(() => {
//选择取消
console.log("选择了cancel")
confirmFlag = true;
formRef.value.formLoading = false
return;
})
if(confirmFlag){
return;
}
}
if(tableData.value.length <= 0){
11 months ago
message.warning(t('ts.子表明细不能为空!'))
1 year ago
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: '',
11 months ago
templateTitle: `${t('ts.供应商发货申请主导入模版')}.xlsx`
1 year ago
})
// 导入成功之后
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
row.supplierBatch = produceDateStr
1 year ago
}
}
/** 初始化 **/
onMounted(async () => {
getList()
importTemplateData.templateUrl = await SupplierdeliverRequestMainApi.importTemplate()
})
</script>