Browse Source

HL-5247 Q3通知单改为主从表

hella_online_20240816
zhang_li 3 months ago
parent
commit
231df666d5
  1. 317
      src/views/qms/inspectionQ3/index.vue
  2. 18
      src/views/qms/inspectionQ3/inspectionQ3.data.ts

317
src/views/qms/inspectionQ3/index.vue

@ -1,23 +1,31 @@
<template> <template>
<ContentWrap> <ContentWrap>
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<Search :schema="[...InspectionQ3Main.allSchemas.searchSchema,...InspectionQ3Detail.allSchemas.searchSchema]" @search="setSearchParams" @reset="setSearchParams" /> <Search
:schema="[
...InspectionQ3Main.allSchemas.searchSchema,
...InspectionQ3Detail.allSchemas.searchSchema
]"
@search="setSearchParams"
@reset="setSearchParams"
/>
</ContentWrap> </ContentWrap>
<!-- 列表头部 --> <!-- 列表头部 -->
<TableHead <TableHead
:HeadButttondata="HeadButttondata" :HeadButttondata="HeadButttondata"
@button-base-click="buttonBaseClick" @button-base-click="buttonBaseClick"
:routeName="routeName" :routeName="routeName"
@updataTableColumns="updataTableColumns" @updataTableColumns="updataTableColumns"
@searchFormClick="searchFormClick" @searchFormClick="searchFormClick"
:allSchemas="InspectionQ3Main.allSchemas" :allSchemas="InspectionQ3Main.allSchemas"
:detailAllSchemas="InspectionQ3Detail.allSchemas" :detailAllSchemas="InspectionQ3Detail.allSchemas"
/> />
<!-- 列表 --> <!-- 列表 -->
<ContentWrap> <ContentWrap>
<Table v-clientTable <Table
v-clientTable
:columns="tableColumns" :columns="tableColumns"
:data="tableObject.tableList" :data="tableObject.tableList"
:loading="tableObject.loading" :loading="tableObject.loading"
@ -28,13 +36,16 @@
v-model:currentPage="tableObject.currentPage" v-model:currentPage="tableObject.currentPage"
v-model:sort="tableObject.sort" v-model:sort="tableObject.sort"
> >
<template #number="{row}"> <template #number="{ row }">
<el-button type="primary" link @click="openDetail(row, '单据号', row.number)"> <el-button type="primary" link @click="openDetail(row, '单据号', row.number)">
<span>{{ row.number }}</span> <span>{{ row.number }}</span>
</el-button> </el-button>
</template> </template>
<template #action="{ row,$index }"> <template #action="{ row, $index }">
<ButtonBase :Butttondata="butttondata(row,$index)" @button-base-click="buttonTableClick($event,row)" /> <ButtonBase
:Butttondata="butttondata(row, $index)"
@button-base-click="buttonTableClick($event, row)"
/>
</template> </template>
</Table> </Table>
</ContentWrap> </ContentWrap>
@ -59,15 +70,17 @@
@tableSelectionDelete="tableSelectionDelete" @tableSelectionDelete="tableSelectionDelete"
@searchTableSuccess="searchTableSuccess" @searchTableSuccess="searchTableSuccess"
@submitForm="submitForm" @submitForm="submitForm"
@onChange="onChange" @inputNumberChange="inputNumberChange"
@clearSearchInput="onChange" @clearSearchInput="onChange"
:sumFormDataByTableCustom ="(formRef,formModel,tableData)=>{ :sumFormDataByTableCustom="
tableData.forEach(item=>{ (formRef, formModel, tableData) => {
item.qty = item.countQty*item.packQty tableData.forEach((item) => {
}) item.qty = item.countQty * item.packQty
}" })
}
"
> >
<!-- <template #default="{row}"> <!-- <template #default="{row}">
<el-input-number disabled v-model="row.qty"></el-input-number> <el-input-number disabled v-model="row.qty"></el-input-number>
</template> --> </template> -->
</BasicForm> </BasicForm>
@ -86,19 +99,26 @@
@searchTableSuccessDetail="searchTableSuccessDetail" @searchTableSuccessDetail="searchTableSuccessDetail"
:detailValidate="detailValidate" :detailValidate="detailValidate"
/> />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import download from '@/utils/download' import download from '@/utils/download'
import { CACHE_KEY, useCache } from '@/hooks/web/useCache' import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
import { InspectionQ3Main,InspectionQ3MainRules,InspectionQ3Detail,InspectionQ3DetailRules } from './inspectionQ3.data' import {
InspectionQ3Main,
InspectionQ3MainRules,
InspectionQ3Detail,
InspectionQ3DetailRules
} from './inspectionQ3.data'
import * as InspectionQ3MainApi from '@/api/qms/inspectionQ3/inspectionQ3Main' import * as InspectionQ3MainApi from '@/api/qms/inspectionQ3/inspectionQ3Main'
import * as InspectionQ3DetailApi from '@/api/qms/inspectionQ3/inspectionQ3Detail' import * as InspectionQ3DetailApi from '@/api/qms/inspectionQ3/inspectionQ3Detail'
import * as defaultButtons from '@/utils/disposition/defaultButtons' import * as defaultButtons from '@/utils/disposition/defaultButtons'
import * as ProductionlineitemApi from '@/api/wms/productionlineitem' import * as ProductionlineitemApi from '@/api/wms/productionlineitem'
import * as StdcostpriceApi from '@/api/wms/stdcostprice' import * as StdcostpriceApi from '@/api/wms/stdcostprice'
import { formatDate } from '@/utils/formatTime' import { formatDate } from '@/utils/formatTime'
import { async } from '@antv/x6/lib/registry/marker/async'
import { useUserStore } from '@/store/modules/user'
const userStore = useUserStore()
// //
defineOptions({ name: 'InspectionQ3Main' }) defineOptions({ name: 'InspectionQ3Main' })
@ -109,7 +129,10 @@ const { t } = useI18n() // 国际化
const route = useRoute() // const route = useRoute() //
const routeName = ref() const routeName = ref()
routeName.value = route.name routeName.value = route.name
const tableColumns = ref([...InspectionQ3Main.allSchemas.tableColumns,...InspectionQ3Detail.allSchemas.tableMainColumns]) const tableColumns = ref([
...InspectionQ3Main.allSchemas.tableColumns,
...InspectionQ3Detail.allSchemas.tableMainColumns
])
// //
const updataTableColumns = (val) => { const updataTableColumns = (val) => {
@ -118,69 +141,63 @@ const updataTableColumns = (val) => {
// //
const priceObj = ref() const priceObj = ref()
const searchTableSuccess = (formField, searchField, val, formRef, type, row ) => { const searchTableSuccess = (formField, searchField, val, formRef, type, row) => {
nextTick(async() => { nextTick(async () => {
const setV = {} const setV = {}
if (type == 'tableForm') { if (type == 'tableForm') {
// //
if (formField == 'itemCode') { if (formField == 'itemCode') {
val.forEach(item=>{ // 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})) const index1 = 0
newRow['itemCode'] = item['code'] setTableFormsValues(val, index1)
newRow['uom'] = item['uom']
tableData.value.push(newRow) // 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) {
// row['uom'] = val[0]['uom'] // formRef.formModel.defectLocation = res[0].productionLineCode
// console.log(formRef.formModel.qty) // InspectionQ3Detail.allSchemas.formSchema.forEach(item=>{
// // let res = await ProductionlineitemApi.selectItemCodeToProductionLineCode(val[0].code) // if (item.field == 'defectLocation') {
// ProductionlineitemApi.selectItemCodeToProductionLineCode(val[0].code).then((res) => { // item.componentProps.options = res
// console.log(res) // }
// if (res?.length > 0) { // })
// formRef.formModel.defectLocation = res[0].productionLineCode // }
// InspectionQ3Detail.allSchemas.formSchema.forEach(item=>{ // })
// if (item.field == 'defectLocation') { // const params = {
// item.componentProps.options = res // by: "ASC",
// } // filters: [{column: "itemCode", action: "==", value: val[0].code}],
// }) // pageNo: 1,
// } // pageSize: 500,
// }) // sort: ""
// const params = { // }
// by: "ASC", // params.isSearch = true
// filters: [{column: "itemCode", action: "==", value: val[0].code}], // StdcostpriceApi.getStdcostpricePage(params).then((res) => {
// pageNo: 1, // if (res.list?.length > 0) {
// pageSize: 500, // priceObj.value = res.list[0]
// sort: "" // formRef.setValues({
// } // amount: (parseFloat(formRef.formModel.qty) * parseFloat(priceObj.value.price)).toFixed(6)
// 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) if (formField == 'costCode') {
// }) console.log(11111)
// } row['costCode'] = val[0]['costcentreCode']
}
// }) if (formField == 'q1Number') {
//Q1
let list = []
val.forEach((item) => {
list.push(item[searchField])
})
setV[formField] = list.join(',')
formRef.setValues(setV)
} }
if (formField == 'costCode') {
console.log(11111)
row['costCode'] = val[0]['costcentreCode']
}
if (formField == 'q1Number') {
//Q1
let list = []
val.forEach((item) => {
list.push(item[searchField])
})
setV[formField] = list.join(',')
formRef.setValues(setV)
}
} else { } else {
const setV = {} const setV = {}
setV[formField] = val[0][searchField] setV[formField] = val[0][searchField]
@ -188,13 +205,55 @@ const searchTableSuccess = (formField, searchField, val, formRef, type, row ) =>
} }
}) })
} }
const onChange =(field,e)=>{ const setTableFormsValues = async (val, index1) => {
if (field == 'qty') { if (index1 <= val.length - 1) {
formRef.value.formRef.formModel.amount = (parseFloat( formRef.value.formRef.formModel.qty) * parseFloat( priceObj.value.price)).toFixed(6) let tableForm = JSON.parse(JSON.stringify(tableFormKeys))
if (tableData.value.find((item1) => item1['itemCode'] == val[index1]['itemCode'])) return
const newRow = JSON.parse(JSON.stringify({ ...tableForm, ...val[index1] }))
newRow['itemCode'] = val[index1]['itemCode']
newRow['uom'] = val[index1]['uom']
newRow['qty'] = 0
newRow.defectLocation = val[index1]['productionLineCode']
await ProductionlineitemApi.selectItemCodeToProductionLineCode(val[index1].itemCode).then(
(res) => {
console.log(res)
if (res?.length > 0) {
newRow.defectLocationInitOptions = res
}
}
)
const params = {
by: 'ASC',
filters: [{ column: 'itemCode', action: '==', value: val[index1].itemCode }],
pageNo: 1,
pageSize: 500,
sort: ''
}
params.isSearch = true
await StdcostpriceApi.getStdcostpricePage(params).then((res) => {
if (res.list?.length > 0) {
priceObj.value = res.list[0]
newRow['price'] = parseFloat(priceObj.value.price)
newRow['amount']=(parseFloat(newRow['qty']) * parseFloat(priceObj.value.price)).toFixed(6)
}
})
tableData.value.push(newRow)
index1++
setTableFormsValues(val, index1)
}
} }
const inputNumberChange = (field, index, row, val) => {
if (field == 'qty') {
row.amount = (parseFloat(row['qty']) * parseFloat(row.price)).toFixed(6)
}
formRef.value.formRef.formModel.summaryAmount =0
tableData.value.forEach(item=>{
formRef.value.formRef.formModel.summaryAmount += parseFloat(item.amount)
})
} }
// //
const searchTableSuccessDetail = (formField, searchField, val, formRef ) => { const searchTableSuccessDetail = (formField, searchField, val, formRef) => {
nextTick(() => { nextTick(() => {
const setV = {} const setV = {}
if (formField == 'itemCode') { if (formField == 'itemCode') {
@ -216,23 +275,28 @@ const { getList, setSearchParams } = tableMethods
// //
const HeadButttondata = [ const HeadButttondata = [
defaultButtons.defaultAddBtn({hasPermi:'qms:inspection-Q3-main:create'}), // defaultButtons.defaultAddBtn({ hasPermi: 'qms:inspection-Q3-main:create' }), //
defaultButtons.defaultExportBtn({hasPermi:'qms:inspection-Q3-main:export'}), // defaultButtons.defaultExportBtn({ hasPermi: 'qms:inspection-Q3-main:export' }), //
defaultButtons.defaultFreshBtn(null), // defaultButtons.defaultFreshBtn(null), //
defaultButtons.defaultFilterBtn(null), // defaultButtons.defaultFilterBtn(null), //
defaultButtons.defaultSetBtn(null), // defaultButtons.defaultSetBtn(null) //
] ]
// //
const buttonBaseClick = (val, item) => { const buttonBaseClick = (val, item) => {
if (val == 'add') { // if (val == 'add') {
//
openForm('create') openForm('create')
} else if (val == 'export') { // } else if (val == 'export') {
//
handleExport() handleExport()
} else if (val == 'refresh') { // } else if (val == 'refresh') {
getList() //
} else if (val == 'filtrate') { // getList()
} else { // } else if (val == 'filtrate') {
//
} else {
//
console.log('其他按钮', item) console.log('其他按钮', item)
} }
} }
@ -247,12 +311,14 @@ const isShowMainButton = (row, val) => {
} }
// - // -
const butttondata = (row,$index) => { const butttondata = (row, $index) => {
const findIndex = row['masterId']?tableObject.tableList.findIndex(item=>item['masterId'] == row['masterId']):-1 const findIndex = row['masterId']
if(findIndex>-1&&findIndex<$index){ ? tableObject.tableList.findIndex((item) => item['masterId'] == row['masterId'])
: -1
if (findIndex > -1 && findIndex < $index) {
return [] return []
} }
return [ return [
defaultButtons.mainListEditBtn({ defaultButtons.mainListEditBtn({
hide: isShowMainButton(row, ['0']), hide: isShowMainButton(row, ['0']),
hasPermi: 'qms:inspection-Q3-main:update' hasPermi: 'qms:inspection-Q3-main:update'
@ -268,11 +334,9 @@ const butttondata = (row,$index) => {
] ]
} }
// - // -
const buttonTableClick = async (val, row) => { const buttonTableClick = async (val, row) => {
if (val == 'edit') { if (val == 'edit') {
// //
openForm('update', row) openForm('update', row)
} else if (val == 'delete') { } else if (val == 'delete') {
@ -295,21 +359,21 @@ const handleFinish = async (id: number) => {
/** 添加/修改操作 */ /** 添加/修改操作 */
const formRef = ref() const formRef = ref()
const openForm =async (type: string, row?: number) => { const openForm = async (type: string, row?: any) => {
tableData.value = [] // tableData.value = [] //
// //
if (type == 'update') { if (type == 'update') {
// tableform // tableform
InspectionQ3Main.allSchemas.formSchema.map(itemColumns => { InspectionQ3Main.allSchemas.formSchema.map((itemColumns) => {
if(itemColumns.field == 'workshopCode') { if (itemColumns.field == 'workshopCode') {
itemColumns.componentProps.isSearchList = false itemColumns.componentProps.isSearchList = false
itemColumns.componentProps.disabled = true itemColumns.componentProps.disabled = true
} }
}) })
} else { } else {
// tableform // tableform
InspectionQ3Main.allSchemas.formSchema.map(itemColumns => { InspectionQ3Main.allSchemas.formSchema.map((itemColumns) => {
if(itemColumns.field == 'workshopCode') { if (itemColumns.field == 'workshopCode') {
itemColumns.componentProps.isSearchList = true itemColumns.componentProps.isSearchList = true
itemColumns.componentProps.disabled = false itemColumns.componentProps.disabled = false
} }
@ -323,9 +387,11 @@ const { wsCache } = useCache()
/** 详情操作 */ /** 详情操作 */
const detailRef = ref() const detailRef = ref()
const openDetail = (row: any, titleName: any, titleValue: any) => { const openDetail = (row: any, titleName: any, titleValue: any) => {
const departmentCode = wsCache.get(CACHE_KEY.DEPT).find((account) => account.id == row.departmentCode)?.name const departmentCode = wsCache
.get(CACHE_KEY.DEPT)
.find((account) => account.id == row.departmentCode)?.name
if (departmentCode) row.departmentCode = JSON.parse(JSON.stringify(departmentCode)) if (departmentCode) row.departmentCode = JSON.parse(JSON.stringify(departmentCode))
detailRef.value.openDetail(row, titleName, titleValue,"requestIssueMain") detailRef.value.openDetail(row, titleName, titleValue, 'requestIssueMain')
} }
/** 删除按钮操作 */ /** 删除按钮操作 */
@ -339,7 +405,7 @@ const handleDelete = async (id: number) => {
tableObject.loading = false tableObject.loading = false
message.success(t('common.delSuccess')) message.success(t('common.delSuccess'))
// //
buttonBaseClick('refresh',null) buttonBaseClick('refresh', null)
} catch {} } catch {}
} }
@ -360,10 +426,10 @@ const handleExport = async () => {
} }
/** /**
* tableForm方法 * tableForm方法
*/ */
const tableFormKeys = {} const tableFormKeys = {}
InspectionQ3Detail.allSchemas.tableFormColumns.forEach(item => { InspectionQ3Detail.allSchemas.tableFormColumns.forEach((item) => {
tableFormKeys[item.field] = item.default ? item.default : '' tableFormKeys[item.field] = item.default ? item.default : ''
}) })
const tableData = ref([]) const tableData = ref([])
@ -381,21 +447,22 @@ const handleAddTable = () => {
// //
const handleDeleteTable = (item, index) => { const handleDeleteTable = (item, index) => {
let itemIndex = tableData.value.indexOf(item) let itemIndex = tableData.value.indexOf(item)
if(itemIndex>-1){ if (itemIndex > -1) {
tableData.value.splice(itemIndex, 1) tableData.value.splice(itemIndex, 1)
} }
} }
const tableSelectionDelete = (selection) => { const tableSelectionDelete = (selection) => {
tableData.value = tableData.value.filter(item => !selection.includes(item)) tableData.value = tableData.value.filter((item) => !selection.includes(item))
} }
// //
const submitForm = async (formType, submitData) => { const submitForm = async (formType, submitData) => {
let data = {...submitData} let data = { ...submitData }
if(data.masterId){ if (data.masterId) {
data.id = data.masterId data.id = data.masterId
} }
data.responUser = userStore.getUser.nickname
data.subList = tableData.value // data.subList = tableData.value //
if(tableData.value.find(item => (item.qty <= 0))) { if (tableData.value.find((item) => item.qty <= 0)) {
message.warning('数量必须大于0') message.warning('数量必须大于0')
formRef.value.formLoading = false formRef.value.formLoading = false
return return
@ -430,8 +497,8 @@ const submitForm = async (formType, submitData) => {
// //
if (formType === 'create') { if (formType === 'create') {
getList() getList()
}else{ } else {
buttonBaseClick('refresh',null) buttonBaseClick('refresh', null)
} }
} finally { } finally {
formRef.value.formLoading = false formRef.value.formLoading = false
@ -440,10 +507,10 @@ const submitForm = async (formType, submitData) => {
// / // /
const detailValidate = async (data) => { const detailValidate = async (data) => {
// let rs = false // let rs = false
// TODO: /线 // TODO: /线
return true return true
} }
/** 导入 */ /** 导入 */
const importFormRef = ref() const importFormRef = ref()

18
src/views/qms/inspectionQ3/inspectionQ3.data.ts

@ -7,6 +7,10 @@ import { Q1 } from '@/views/qms/inspectionQ1/inspectionQ1.data'
import * as ItembasicApi from '@/api/wms/itembasic' import * as ItembasicApi from '@/api/wms/itembasic'
import { Itembasic } from '@/views/wms/basicDataManage/itemManage/itembasic/itembasic.data' import { Itembasic } from '@/views/wms/basicDataManage/itemManage/itembasic/itembasic.data'
import * as ProductionlineitemApi from '@/api/wms/productionlineitem'
import { Productionlineitem } from '@/views/wms/basicDataManage/itemManage/productionlineitem/productionlineitem.data'
import * as QadCostcentreApi from '@/api/wms/qadCostcentre' import * as QadCostcentreApi from '@/api/wms/qadCostcentre'
import { QadCostcentre } from '@/views/wms/basicDataManage/subject/qadCostcentre/qadCostcentre.data' import { QadCostcentre } from '@/views/wms/basicDataManage/subject/qadCostcentre/qadCostcentre.data'
@ -149,7 +153,7 @@ export const InspectionQ3Main = useCrudSchemas(
component: 'InputNumber', component: 'InputNumber',
componentProps: { componentProps: {
min: 0, min: 0,
precision: 2 precision: 6
} }
} }
}, },
@ -394,9 +398,9 @@ export const InspectionQ3Detail = useCrudSchemas(
disabled:true, disabled:true,
searchListPlaceholder: '请选择物料代码', // 输入框占位文本 searchListPlaceholder: '请选择物料代码', // 输入框占位文本
searchField: 'code', // 查询弹窗赋值字段 searchField: 'code', // 查询弹窗赋值字段
searchTitle: '物料基础信息', // 查询弹窗标题 searchTitle: '物料信息', // 查询弹窗标题
searchAllSchemas: Itembasic.allSchemas, // 查询弹窗所需类 searchAllSchemas: Productionlineitem.allSchemas, // 查询弹窗所需类
searchPage: ItembasicApi.getItembasicPage, // 查询弹窗所需分页方法 searchPage: ProductionlineitemApi.getProductionlineitemPage, // 查询弹窗所需分页方法
searchCondition: [ searchCondition: [
{ {
key: 'available', key: 'available',
@ -571,6 +575,12 @@ export const InspectionQ3Detail = useCrudSchemas(
}, },
filterable: true filterable: true
} }
},
tableForm: {
type: 'Select',
valueField: 'productionLineName',
labelField: 'productionLineCode'
} }
}, },
{ {

Loading…
Cancel
Save