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.

479 lines
15 KiB

1 year ago
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
12 months ago
<Search :schema="[...InspectionQ3Main.allSchemas.searchSchema,...InspectionQ3Detail.allSchemas.searchSchema]" @search="setSearchParams" @reset="setSearchParams" />
1 year ago
</ContentWrap>
12 months ago
<!-- 列表头部 -->
<TableHead
:HeadButttondata="HeadButttondata"
@button-base-click="buttonBaseClick"
:routeName="routeName"
@updataTableColumns="updataTableColumns"
@searchFormClick="searchFormClick"
:allSchemas="InspectionQ3Main.allSchemas"
:detailAllSchemas="InspectionQ3Detail.allSchemas"
/>
1 year ago
<!-- 列表 -->
<ContentWrap>
12 months ago
<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"
>
12 months ago
<template #number="{row}">
<el-button type="primary" link @click="openDetail(row, '单据号', row.number)">
1 year ago
<span>{{ row.number }}</span>
1 year ago
</el-button>
</template>
12 months ago
<template #action="{ row,$index }">
<ButtonBase :Butttondata="butttondata(row,$index)" @button-base-click="buttonTableClick($event,row)" />
1 year ago
</template>
</Table>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<BasicForm
12 months ago
ref="formRef"
:isOpenSearchTable="true"
fieldTableColumn="itemCode"
@success="getList"
:rules="InspectionQ3MainRules"
:formAllSchemas="InspectionQ3Main.allSchemas"
:tableAllSchemas="InspectionQ3Detail.allSchemas"
:tableFormRules="InspectionQ3DetailRules"
:tableData="tableData"
:apiUpdate="InspectionQ3MainApi.updateInspectionQ3Main"
:apiCreate="InspectionQ3MainApi.createInspectionQ3Main"
:isBusiness="true"
@handleAddTable="handleAddTable"
@handleDeleteTable="handleDeleteTable"
:isShowReduceButtonSelection="true"
@tableSelectionDelete="tableSelectionDelete"
1 year ago
@searchTableSuccess="searchTableSuccess"
12 months ago
@submitForm="submitForm"
12 months ago
@onChange="onChange"
12 months ago
@clearSearchInput="onChange"
:sumFormDataByTableCustom ="(formRef,formModel,tableData)=>{
tableData.forEach(item=>{
item.qty = item.countQty*item.packQty
})
}"
>
<!-- <template #default="{row}">
<el-input-number disabled v-model="row.qty"></el-input-number>
</template> -->
</BasicForm>
1 year ago
<!-- 详情 -->
12 months ago
<Detail
ref="detailRef"
:isBasic="false"
:allSchemas="InspectionQ3Main.allSchemas"
:detailAllSchemas="InspectionQ3Detail.allSchemas"
:detailAllSchemasRules="InspectionQ3DetailRules"
:apiCreate="InspectionQ3DetailApi.createInspectionQ3Detail"
:apiUpdate="InspectionQ3DetailApi.updateInspectionQ3Detail"
:apiPage="InspectionQ3DetailApi.getInspectionQ3DetailPage"
:apiDelete="InspectionQ3DetailApi.deleteInspectionQ3Detail"
@searchTableSuccessDetail="searchTableSuccessDetail"
:detailValidate="detailValidate"
1 year ago
/>
12 months ago
1 year ago
</template>
<script setup lang="ts">
import download from '@/utils/download'
12 months ago
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
import { InspectionQ3Main,InspectionQ3MainRules,InspectionQ3Detail,InspectionQ3DetailRules } from './inspectionQ3.data'
import * as InspectionQ3MainApi from '@/api/qms/inspectionQ3/inspectionQ3Main'
import * as InspectionQ3DetailApi from '@/api/qms/inspectionQ3/inspectionQ3Detail'
1 year ago
import * as defaultButtons from '@/utils/disposition/defaultButtons'
12 months ago
import * as ProductionlineitemApi from '@/api/wms/productionlineitem'
import * as StdcostpriceApi from '@/api/wms/stdcostprice'
import { formatDate } from '@/utils/formatTime'
1 year ago
12 months ago
// 发料申请
defineOptions({ name: 'InspectionQ3Main' })
1 year ago
const message = useMessage() // 消息弹窗
const { t } = useI18n() // 国际化
const route = useRoute() // 路由信息
const routeName = ref()
routeName.value = route.name
12 months ago
const tableColumns = ref([...InspectionQ3Main.allSchemas.tableColumns,...InspectionQ3Detail.allSchemas.tableMainColumns])
// 字段设置 更新主列表字段
const updataTableColumns = (val) => {
tableColumns.value = val
}
1 year ago
// 查询页面返回
12 months ago
const priceObj = ref()
12 months ago
const searchTableSuccess = (formField, searchField, val, formRef, type, row ) => {
nextTick(async() => {
1 year ago
const setV = {}
12 months ago
if (type == 'tableForm') {
// 明细查询页赋值
if (formField == 'itemCode') {
val.forEach(item=>{
let tableForm = JSON.parse(JSON.stringify(tableFormKeys))
if(tableData.value.find(item1=>item1['itemCode'] == item['itemCode'])) return
const newRow = JSON.parse(JSON.stringify({...tableForm,...item}))
newRow['itemCode'] = item['code']
newRow['uom'] = item['uom']
tableData.value.push(newRow)
12 months ago
})
12 months ago
// row['uom'] = val[0]['uom']
// console.log(formRef.formModel.qty)
// // let res = await ProductionlineitemApi.selectItemCodeToProductionLineCode(val[0].code)
// ProductionlineitemApi.selectItemCodeToProductionLineCode(val[0].code).then((res) => {
// console.log(res)
// if (res?.length > 0) {
// formRef.formModel.defectLocation = res[0].productionLineCode
// InspectionQ3Detail.allSchemas.formSchema.forEach(item=>{
// if (item.field == 'defectLocation') {
// item.componentProps.options = res
// }
// })
// }
// })
// const params = {
// by: "ASC",
// filters: [{column: "itemCode", action: "==", value: val[0].code}],
// pageNo: 1,
// pageSize: 500,
// sort: ""
// }
// params.isSearch = true
// StdcostpriceApi.getStdcostpricePage(params).then((res) => {
// if (res.list?.length > 0) {
// priceObj.value = res.list[0]
// formRef.setValues({
// amount: (parseFloat(formRef.formModel.qty) * parseFloat(priceObj.value.price)).toFixed(6)
// })
// }
// })
12 months ago
}
12 months ago
if (formField == 'costCode') {
console.log(11111)
row['costCode'] = val[0]['costcentreCode']
12 months ago
}
12 months ago
if (formField == 'q1Number') {
1 year ago
//Q1通知单号
let list = []
1 year ago
val.forEach((item) => {
1 year ago
list.push(item[searchField])
})
setV[formField] = list.join(',')
formRef.setValues(setV)
12 months ago
}
1 year ago
} else {
12 months ago
const setV = {}
1 year ago
setV[formField] = val[0][searchField]
formRef.setValues(setV)
}
1 year ago
})
1 year ago
}
12 months ago
const onChange =(field,e)=>{
if (field == 'qty') {
12 months ago
formRef.value.formRef.formModel.amount = (parseFloat( formRef.value.formRef.formModel.qty) * parseFloat( priceObj.value.price)).toFixed(6)
12 months ago
}
}
12 months ago
// 查询页面返回——详情
const searchTableSuccessDetail = (formField, searchField, val, formRef ) => {
nextTick(() => {
const setV = {}
if (formField == 'itemCode') {
setV['itemCode'] = val[0]['code']
setV['uom'] = val[0]['uom']
} else {
setV[formField] = val[0][searchField]
}
formRef.setValues(setV)
})
1 year ago
}
const { tableObject, tableMethods } = useTable({
12 months ago
getListApi: InspectionQ3DetailApi.getInspectionQ3DetailPage // 分页接口
1 year ago
})
// 获得表格的各种操作
const { getList, setSearchParams } = tableMethods
// 列表头部按钮
const HeadButttondata = [
12 months ago
defaultButtons.defaultAddBtn({hasPermi:'qms:inspection-Q3-main:create'}), // 新增
defaultButtons.defaultExportBtn({hasPermi:'qms:inspection-Q3-main:export'}), // 导出
1 year ago
defaultButtons.defaultFreshBtn(null), // 刷新
defaultButtons.defaultFilterBtn(null), // 筛选
12 months ago
defaultButtons.defaultSetBtn(null), // 设置
1 year ago
]
// 头部按钮事件
const buttonBaseClick = (val, item) => {
12 months ago
if (val == 'add') { // 新增
1 year ago
openForm('create')
12 months ago
} else if (val == 'export') { // 导出
1 year ago
handleExport()
12 months ago
} else if (val == 'refresh') { // 刷新
getList()
} else if (val == 'filtrate') { // 筛选
} else { // 其他按钮
1 year ago
console.log('其他按钮', item)
}
}
12 months ago
// 根据状态返回该按钮是否显示
1 year ago
const isShowMainButton = (row, val) => {
if (val.indexOf(row.status) > -1) {
return false
} else {
return true
}
}
1 year ago
// 列表-操作按钮
12 months ago
const butttondata = (row,$index) => {
const findIndex = row['masterId']?tableObject.tableList.findIndex(item=>item['masterId'] == row['masterId']):-1
if(findIndex>-1&&findIndex<$index){
return []
}
return [
1 year ago
defaultButtons.mainListEditBtn({
hide: isShowMainButton(row, ['0']),
12 months ago
hasPermi: 'qms:inspection-Q3-main:update'
1 year ago
}), // 编辑
defaultButtons.mainListDeleteBtn({
hide: isShowMainButton(row, ['0']),
12 months ago
hasPermi: 'qms:inspection-Q3-main:delete'
1 year ago
}), // 删除
defaultButtons.mainListFinishBtn({
hide: isShowMainButton(row, ['0']),
12 months ago
hasPermi: 'qms:inspection-Q3-main:finish'
1 year ago
}) // 完成
]
}
1 year ago
12 months ago
1 year ago
// 列表-操作按钮事件
const buttonTableClick = async (val, row) => {
12 months ago
if (val == 'edit') {
1 year ago
// 编辑
1 year ago
openForm('update', row)
1 year ago
} else if (val == 'delete') {
// 删除
1 year ago
handleDelete(row.id)
1 year ago
} else if (val == 'finish') {
12 months ago
// 完成
handleFinish(row.id)
1 year ago
}
}
const handleFinish = async (id: number) => {
try {
12 months ago
await InspectionQ3MainApi.finishInspectionQ3Main(id)
message.success(t('common.updateSuccess'))
// 刷新列表
await getList()
} catch {}
}
1 year ago
/** 添加/修改操作 */
12 months ago
const formRef = ref()
const openForm =async (type: string, row?: number) => {
tableData.value = [] // 重置明细数据
// 编辑时 车间代码不可修改
if (type == 'update') {
// 修改 tableform 属性
InspectionQ3Main.allSchemas.formSchema.map(itemColumns => {
if(itemColumns.field == 'workshopCode') {
itemColumns.componentProps.isSearchList = false
itemColumns.componentProps.disabled = true
}
})
} else {
// 修改 tableform 属性
InspectionQ3Main.allSchemas.formSchema.map(itemColumns => {
if(itemColumns.field == 'workshopCode') {
itemColumns.componentProps.isSearchList = true
itemColumns.componentProps.disabled = false
}
1 year ago
})
}
12 months ago
formRef.value.open(type, row)
1 year ago
}
12 months ago
// 获取部门 用于详情 部门回显
const { wsCache } = useCache()
1 year ago
/** 详情操作 */
const detailRef = ref()
const openDetail = (row: any, titleName: any, titleValue: any) => {
12 months ago
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,"requestIssueMain")
1 year ago
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
// 删除的二次确认
await message.delConfirm()
12 months ago
tableObject.loading = true
1 year ago
// 发起删除
12 months ago
await InspectionQ3MainApi.deleteInspectionQ3Main(id)
tableObject.loading = false
1 year ago
message.success(t('common.delSuccess'))
// 刷新列表
12 months ago
buttonBaseClick('refresh',null)
1 year ago
} catch {}
}
/** 导出按钮操作 */
const exportLoading = ref(false) // 导出的加载中
const handleExport = async () => {
try {
// 导出的二次确认
await message.exportConfirm()
// 发起导出
exportLoading.value = true
12 months ago
const data = await InspectionQ3MainApi.exportInspectionQ3Main(tableObject.params)
download.excel(data, `${route.meta.title}】【${formatDate(new Date())}】.xlsx`)
1 year ago
} catch {
} finally {
exportLoading.value = false
}
}
12 months ago
/**
* tableForm方法
*/
const tableFormKeys = {}
InspectionQ3Detail.allSchemas.tableFormColumns.forEach(item => {
tableFormKeys[item.field] = item.default ? item.default : ''
})
const tableData = ref([])
// 添加明细
const handleAddTable = () => {
// 添加明细 已有数据 添加的明细 生产线 工位按照之前数据进行添加
let tableForm = JSON.parse(JSON.stringify(tableFormKeys))
if (tableData.value.length > 0) {
// tableForm.productionLineCode = tableData.value[0].productionLineCode
// tableForm.workStationCode = tableData.value[0].workStationCode
}
tableData.value.push(tableForm)
}
// 删除明细
const handleDeleteTable = (item, index) => {
let itemIndex = tableData.value.indexOf(item)
if(itemIndex>-1){
tableData.value.splice(itemIndex, 1)
}
}
const tableSelectionDelete = (selection) => {
tableData.value = tableData.value.filter(item => !selection.includes(item))
}
// 主子数据 提交
const submitForm = async (formType, submitData) => {
let data = {...submitData}
if(data.masterId){
data.id = data.masterId
}
data.subList = tableData.value // 拼接子表数据参数
if(tableData.value.find(item => (item.qty <= 0))) {
message.warning('数量必须大于0')
formRef.value.formLoading = false
return
}
// 判断子表中,是否有不同的生产线和工位
// if (tableData.value.length > 0) {
// let productionLineCode = tableData.value[0].productionLineCode
// let workStationCode = tableData.value[0].workStationCode
// for(var i=0;i<tableData.value.length;i++) {
// if(productionLineCode !== tableData.value[i].productionLineCode){
// message.warning('子表数据:生产线存在不同数据,请修改成统一数据!')
// formRef.value.formLoading = false
// return;
// }
// if(workStationCode !== tableData.value[i].workStationCode){
// message.warning('子表数据:工位存在不同数据,请修改成统一数据!')
// formRef.value.formLoading = false
// return;
// }
// }
// }
formRef.value.formLoading = true
try {
if (formType === 'create') {
await InspectionQ3MainApi.createInspectionQ3Main(data)
message.success(t('common.createSuccess'))
} else {
await InspectionQ3MainApi.updateInspectionQ3Main(data)
message.success(t('common.updateSuccess'))
}
formRef.value.dialogVisible = false
// 刷新当前列表
if (formType === 'create') {
getList()
}else{
buttonBaseClick('refresh',null)
}
} finally {
formRef.value.formLoading = false
}
}
// 子表新增/编辑校验
const detailValidate = async (data) => {
// let rs = false
// TODO: 单一新编/编辑,校验是否与其他子数据存在生产线工位有不同数据情况
return true
}
1 year ago
/** 导入 */
const importFormRef = ref()
const handleImport = () => {
importFormRef.value.open()
}
12 months ago
1 year ago
// 导入附件弹窗所需的参数
const importTemplateData = reactive({
templateUrl: '',
templateTitle: `${route.meta.title}】导入模版.xlsx`
1 year ago
})
12 months ago
1 year ago
// 导入成功之后
const importSuccess = () => {
getList()
}
// 筛选提交
const searchFormClick = (searchData) => {
tableObject.params = {
isSearch: true,
filters: searchData.filters
}
getList() // 刷新当前列表
}
/** 初始化 **/
onMounted(async () => {
getList()
})
</script>