Browse Source

主子表接口

master
zhangli 1 year ago
parent
commit
5a7217512d
  1. 56
      src/api/wms/purchaseclaimRequestDetail/index.ts
  2. 28
      src/components/BasicForm/src/BasicForm.vue
  3. 169
      src/components/Detail/src/Detail.vue
  4. 124
      src/utils/disposition/tableColumns.ts
  5. 9
      src/utils/formatTime.ts
  6. 40
      src/views/wms/purchaseclaimRequestMain/index.vue

56
src/api/wms/purchaseclaimRequestDetail/index.ts

@ -0,0 +1,56 @@
import request from '@/config/axios'
export interface PurchaseclaimRequestMainVO {
altBatch: string
amount: Number
batch: Number
id: string
itemCode: string
itemDesc1: string
itemDesc2: string
itemName: string
number: string
poLine: string
poNumber: string
projectCode: string
qty: Number
reason: string
remark: string
singlePrice: Number
uom: string
}
// 查询采购索赔申请子列表
export const getPurchaseclaimRequestDetailPage = async (params) => {
return await request.get({ url: `/wms/purchaseclaim-request-detail/page`, params })
}
// 查询采购索赔申请子详情
export const getPurchaseclaimRequesDetail = async (id: number) => {
return await request.get({ url: `/wms/purchaseclaim-request-detail/get?id=` + id })
}
// 新增采购索赔申请子
export const createPurchaseclaimRequestDetail = async (data: PurchaseclaimRequestMainVO) => {
return await request.post({ url: `/wms/purchaseclaim-request-detail/create`, data })
}
// 修改采购索赔申请子
export const updatePurchaseclaimRequestDetail = async (data: PurchaseclaimRequestMainVO) => {
return await request.put({ url: `/wms/purchaseclaim-request-detail/update`, data })
}
// 删除采购索赔申请子
export const deletePurchaseclaimRequestDetail = async (id: number) => {
return await request.delete({ url: `/wms/purchaseclaim-request-detail/delete?id=` + id })
}
// 导出采购索赔申请子 Excel
export const exportPurchaseclaimRequestDetail = async (params) => {
return await request.download({ url: `/wms/purchaseclaim-request-detail/export-excel`, params })
}
// 下载用户导入模板
export const importTemplate = () => {
return request.download({ url: '/wms/purchaseclaim-request-detail/get-import-template' })
}

28
src/components/BasicForm/src/BasicForm.vue

@ -99,8 +99,13 @@
<el-input v-model="form['asnNumber']" :placeholder="'请选择发货单号'" @click="opensearchTable('asnNumber', 'asnNumber')" /> <el-input v-model="form['asnNumber']" :placeholder="'请选择发货单号'" @click="opensearchTable('asnNumber', 'asnNumber')" />
</div> </div>
</template> </template>
<template #poNumber="form" v-if="props.searchTableParams?.find((item: any) => (item.formField == 'poNumber'))">
<div class="w-[100%] flex">
<el-input v-model="form['poNumber']" :placeholder="'请选择发货单号'" @click="opensearchTable('poNumber', 'poNumber')" />
</div>
</template>
</Form> </Form>
<div class="table" v-if="isBusiness"> <div class="table" v-if="isBusiness && formType == 'create'">
<TableForm ref="tableFormRef" <TableForm ref="tableFormRef"
class="w-[100%]" class="w-[100%]"
:tableFields="tableAllSchemas.tableFormColumns" :tableFields="tableAllSchemas.tableFormColumns"
@ -127,6 +132,7 @@ import { SearchTable } from '@/components/SearchTable';
import * as defaultButtons from '@/utils/disposition/defaultButtons' import * as defaultButtons from '@/utils/disposition/defaultButtons'
import ButtonBase from '@/components/XButton/src/ButtonBase.vue' import ButtonBase from '@/components/XButton/src/ButtonBase.vue'
import TableForm from '@/components/TableForm/src/TableForm.vue' import TableForm from '@/components/TableForm/src/TableForm.vue'
import { string } from 'vue-types';
const props = defineProps({ const props = defineProps({
// rules // rules
@ -193,7 +199,13 @@ const props = defineProps({
type: Object, type: Object,
required: true, required: true,
default: null default: null
} },
// id
masterId: {
type: String,
required: false,
default: null
},
}) })
const { t } = useI18n() // const { t } = useI18n() //
@ -233,6 +245,7 @@ const open = async (type: string, row?: any) => {
resetForm() resetForm()
// //
if (row) { if (row) {
console.log(row);
formLoading.value = true formLoading.value = true
try { try {
nextTick(() => { nextTick(() => {
@ -243,7 +256,7 @@ const open = async (type: string, row?: any) => {
} }
} }
} }
defineExpose({ open , formRef, opensearchTable, dialogVisible}) // open defineExpose({ open , formRef, opensearchTable, dialogVisible, formLoading }) // open
/** 弹窗按钮 */ /** 弹窗按钮 */
const Butttondata = [ const Butttondata = [
@ -275,7 +288,7 @@ const submitForm = async () => {
const valid = await elForm.validate() const valid = await elForm.validate()
if (!valid) return if (!valid) return
// //
if (props.isBusiness) { if (props.isBusiness && formType.value == 'create') {
const validateForm = await tableFormRef.value.validateForm() const validateForm = await tableFormRef.value.validateForm()
if (!validateForm) { if (!validateForm) {
if (props.tableData.length == 0) { if (props.tableData.length == 0) {
@ -291,7 +304,7 @@ const submitForm = async () => {
emit('submitForm', formType.value, data ) emit('submitForm', formType.value, data )
// dialogVisible.value = false // dialogVisible.value = false
} finally { } finally {
formLoading.value = false // formLoading.value = false
} }
} else { } else {
// //
@ -299,6 +312,9 @@ const submitForm = async () => {
try { try {
// const data = unref(formRef)?.formModel as ItempackagingApi.ItempackagingVO // const data = unref(formRef)?.formModel as ItempackagingApi.ItempackagingVO
const data = unref(formRef)?.formModel const data = unref(formRef)?.formModel
if(props.masterId){
data.masterId = props.masterId
}
if (formType.value === 'create') { if (formType.value === 'create') {
await props.apiCreate(data) await props.apiCreate(data)
message.success(t('common.createSuccess')) message.success(t('common.createSuccess'))
@ -334,7 +350,7 @@ const emit = defineEmits([
'inpuFocus', 'inpuFocus',
'searchTableSuccess', 'searchTableSuccess',
'opensearchTable', 'opensearchTable',
'submitForm' 'submitForm',
]) ])
// //
const formSelectChange = (field, val) => { const formSelectChange = (field, val) => {

169
src/components/Detail/src/Detail.vue

@ -1,4 +1,5 @@
<template> <template>
<div>
<el-drawer v-model="isShowDrawer" title="详情" direction="rtl" size="80%" v-loading="detailLoading"> <el-drawer v-model="isShowDrawer" title="详情" direction="rtl" size="80%" v-loading="detailLoading">
<template #header> <template #header>
<div class="font-size-18px"> <div class="font-size-18px">
@ -9,6 +10,13 @@
<Descriptions :data="detailData" labelClassName="label-class-name" label-align="left" direction="vertical" <Descriptions :data="detailData" labelClassName="label-class-name" label-align="left" direction="vertical"
:column="8" :schema="allSchemas.detailSchema" :columns="2" width="200px" /> :column="8" :schema="allSchemas.detailSchema" :columns="2" width="200px" />
</ContentWrap> </ContentWrap>
<!-- 列表头部 -->
<TableHead
:HeadButttondata="HeadButttondata"
@button-base-click="buttonBaseClick"
:routeName="routeName"
@updataTableColumns="updataTableColumns"
/>
<Tabs :tabsList="tabsList" :current="current" @change="change" /> <Tabs :tabsList="tabsList" :current="current" @change="change" />
<div class="flex" v-if="current == 0"> <div class="flex" v-if="current == 0">
<!-- 详情 --> <!-- 详情 -->
@ -21,7 +29,11 @@
:loading="tableObject.loading" :loading="tableObject.loading"
:pagination="{ total: tableObject.total }" :pagination="{ total: tableObject.total }"
v-model:pageSize="tableObject.pageSize" v-model:pageSize="tableObject.pageSize"
v-model:currentPage="tableObject.currentPage" /> v-model:currentPage="tableObject.currentPage" >
<template #action="{ row }">
<ButtonBase :Butttondata="buttondata(row)" @button-base-click="buttonTableClick($event, row)" />
</template>
</Table>
</ContentWrap> </ContentWrap>
<ContentWrap class="w-[27%] ml-16px"> <ContentWrap class="w-[27%] ml-16px">
<!-- 附件组件 --> <!-- 附件组件 -->
@ -34,6 +46,20 @@
</ContentWrap> </ContentWrap>
</div> </div>
</el-drawer> </el-drawer>
<!-- 表单弹窗添加/修改 -->
<BasicForm
ref="formRef"
@success="getList"
:rules="detailAllSchemasRules"
:formAllSchemas="detailAllSchemas"
:searchTableParams="searchTableParams"
:isBusiness="false"
:apiUpdate="apiUpdate"
:apiCreate="apiCreate"
:masterId="masterId"
@searchTableSuccess="searchTableSuccess"
/>
</div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -43,10 +69,19 @@ import ChangeRecord from '@/components/ChangeRecord/src/ChangeRecord.vue'
import Tabs from '@/components/Tabs/src/Tabs.vue' import Tabs from '@/components/Tabs/src/Tabs.vue'
import * as RemarkApi from '@/api/wms/remark' import * as RemarkApi from '@/api/wms/remark'
import * as FileApi from '@/api/wms/file' import * as FileApi from '@/api/wms/file'
import * as defaultButtons from '@/utils/disposition/defaultButtons'
import BasicForm from '@/components/BasicForm/src/BasicForm.vue'
import TableHead from '@/components/TableHead/src/TableHead.vue'
defineOptions({ name: 'Detail' })
const message = useMessage() //
const { t } = useI18n() //
const route = useRoute() //
const routeName = ref()
routeName.value = route.name
defineOptions({ name: 'Detail' })
const props = defineProps({ const props = defineProps({
// //
@ -73,18 +108,46 @@ const props = defineProps({
required: true, required: true,
default: null default: null
}, },
// API //
detailApi: { detailAllSchemasRules: {
type: Object, type: Object,
required: true, required: true,
default: null default: null
} },
//
searchTableParams: {
type: Array,
required: true,
default: null
},
// API
apiCreate: {
type: Function,
required: false,
default: null
},
// API
apiUpdate: {
type: Function,
required: false,
default: null
},
// API
apiPage: {
type: Function,
required: false,
default: null
},
// API
apiDelete: {
type: Function,
required: false,
default: null
},
}) })
console.log(props.detailAllSchemas);
const isShowDrawer = ref(false) const isShowDrawer = ref(false)
const detailLoading = ref(false) const detailLoading = ref(false)
const tabsList = ref(JSON.parse(JSON.stringify(props.tabs ? props.tabs : ''))) const tabsList = ref(JSON.parse(JSON.stringify(props.tabs ? props.tabs : '')))
if (tabsList.value && tabsList.value.length > 0) { if (tabsList.value && tabsList.value.length > 0) {
@ -144,7 +207,7 @@ const change = (item, index) => {
} }
const masterId=ref('')//id
/** 打开弹窗 */ /** 打开弹窗 */
const titleNameRef = ref() const titleNameRef = ref()
const titleValueRef = ref() const titleValueRef = ref()
@ -157,8 +220,10 @@ const openDetail = async (row: any, titleName: any, titleValue: any, tableName:
} }
// //
if(!props.isBasic) { if(!props.isBasic) {
// id
masterId.value = row.id
tableObject.params = { tableObject.params = {
id: row.id masterId: row.id
} }
getList() getList()
} }
@ -199,11 +264,93 @@ const getChangeRecordList = async () => {
} }
const { tableObject, tableMethods } = useTable({ const { tableObject, tableMethods } = useTable({
getListApi: props.detailApi?.getDetasListPage // APIID getListApi: props.apiPage //
}) })
// //
const { getList } = tableMethods const { getList } = tableMethods
//
const HeadButttondata = [
defaultButtons.defaultAddBtn({ hasPermi: 'wms:purchaseclaim-request-main:create' }), //
]
//
const buttonBaseClick = (val, item) => {
if (val == 'add') { //
openForm('create')
} else if (val == 'import') { //
handleImport()
} else if (val == 'export') { //
handleExport()
} else if (val == 'refresh') { //
getList()
} else if (val == 'filtrate') { //
} else { //
console.log('其他按钮', item)
}
}
//
const updataTableColumns = (val) => {
tableColumns.value = val
}
// -
const buttondata = (row) => {
return [
defaultButtons.mainListEditBtn({ hide: false, hasPermi: 'wms:purchaseclaim-request-main:update' }), //
defaultButtons.mainListDeleteBtn({ hide: false, hasPermi: 'wms:purchaseclaim-request-main:delete' }), //
]
}
// -
const buttonTableClick = async (val, row) => {
if (val == 'edit') { //
openForm('update', row)
} else if (val == 'delete') { //
handleDelete(row.id)
}
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = async (type: string, row?: number) => {
formRef.value.open(type, row)
}
//
const searchTableSuccess = (formField, searchField, val, formRef, type, row) => {
nextTick(() => {
if (type == 'tableForm') {
} else {
const setV = {}
setV[formField] = val[0][searchField]
setV['ppNumber'] = val[0]['ppNumber']
setV['poLine'] = val[0]['poLine']
setV['batch'] = val[0]['batch']
setV['altBatch'] = val[0]['altBatch']
setV['reason'] = val[0]['reason']
setV['singlePrice'] = val[0]['singlePrice']
setV['amount'] = val[0]['amount']
setV['number'] = val[0]['number']
setV['itemCode'] = val[0]['itemCode']
setV['itemName'] = val[0]['itemName']
setV['itemDesc1'] = val[0]['itemDesc1']
setV['itemDesc2'] = val[0]['itemDesc2']
setV['projectCode'] = val[0]['projectCode']
setV['qty'] = val[0]['qty']
setV['uom'] = val[0]['uom']
setV['remark'] = val[0]['remark']
formRef.setValues(setV)
}
})
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await props.apiDelete(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch { }
}
</script> </script>
<style lang="scss"> <style lang="scss">
.el-drawer__body { .el-drawer__body {

124
src/utils/disposition/tableColumns.ts

@ -1,5 +1,5 @@
import type { CrudSchema } from '@/hooks/web/useCrudSchemas' import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter,formatGetTime } from '@/utils/formatTime'
import * as getRequestsettingApi from '@/api/wms/requestsetting/index.ts' import * as getRequestsettingApi from '@/api/wms/requestsetting/index.ts'
// import BasicForm from '@/components/BasicForm/src/BasicForm.vue' // import BasicForm from '@/components/BasicForm/src/BasicForm.vue'
// import { h } from 'vue' // import { h } from 'vue'
@ -10556,10 +10556,11 @@ export const PurchaseclaimRequestMain = useCrudSchemas(reactive<CrudSchema[]>([
field: 'requestTime', field: 'requestTime',
formatter: dateFormatter, formatter: dateFormatter,
form: { form: {
value: new Date(),
component: 'DatePicker', component: 'DatePicker',
componentProps: { componentProps: {
type: 'datetime', type: 'datetime',
dateFormat: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'x',
} }
}, },
detail: { detail: {
@ -10577,6 +10578,8 @@ export const PurchaseclaimRequestMain = useCrudSchemas(reactive<CrudSchema[]>([
component: 'DatePicker', component: 'DatePicker',
componentProps: { componentProps: {
type: 'datetime', type: 'datetime',
dateFormat: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'x',
} }
}, },
detail: { detail: {
@ -10786,75 +10789,126 @@ export const PurchaseclaimRequestDetail = useCrudSchemas(reactive<CrudSchema[]>(
field: 'poNumber', field: 'poNumber',
tableForm:{ tableForm:{
isInpuFocusShow: true isInpuFocusShow: true
} },
table: {
width: 150
},
}, },
{ {
label: '订单行', label: '订单行',
field: 'poLine' field: 'poLine',
table: {
width: 150
},
}, },
{ {
label: '批次', label: '批次',
field: 'batch' field: 'batch',
table: {
width: 150
},
}, },
{ {
label: '替代批次', label: '替代批次',
field: 'altBatch' field: 'altBatch',
table: {
width: 150
},
}, },
{ {
label: '原因', label: '原因',
field: 'reason', field: 'reason',
dictType: DICT_TYPE.PURCHASE_RETURN_REASON, // dictType: DICT_TYPE.PURCHASE_RETURN_REASON,
dictClass: 'string' dictClass: 'string',
table: {
width: 150
},
}, },
{ {
label: '单价', label: '单价',
field: 'singlePrice' field: 'singlePrice',
table: {
width: 150
},
}, },
{ {
label: '金额', label: '金额',
field: 'amount' field: 'amount',
table: {
width: 150
},
}, },
{ {
label: '单据号', label: '单据号',
field: 'number' field: 'number',
table: {
width: 150
},
}, },
{ {
label: '物品代码', label: '物品代码',
field: 'itemCode' field: 'itemCode',
table: {
width: 150
},
}, },
{ {
label: '物品名称', label: '物品名称',
field: 'itemName' field: 'itemName',
table: {
width: 150
},
}, },
{ {
label: '物品描述1', label: '物品描述1',
field: 'itemDesc1' field: 'itemDesc1',
table: {
width: 150
},
}, },
{ {
label: '物品描述2', label: '物品描述2',
field: 'itemDesc2' field: 'itemDesc2',
table: {
width: 150
},
}, },
{ {
label: '项目代码', label: '项目代码',
field: 'projectCode' field: 'projectCode',
table: {
width: 150
},
}, },
{ {
label: '数量', label: '数量',
field: 'qty' field: 'qty',
table: {
width: 150
},
}, },
{ {
label: '计量单位', label: '计量单位',
field: 'uom' field: 'uom',
table: {
width: 150
},
}, },
{ {
label: '备注', label: '备注',
field: 'remark' field: 'remark',
table: {
width: 150
},
}, },
{ {
label: '创建者', label: '创建者',
field: 'creator', field: 'creator',
isTableForm:false isTableForm:false,
table: {
width: 150
},
isForm:false
}, },
{ {
label: '创建时间', label: '创建时间',
@ -10864,12 +10918,20 @@ export const PurchaseclaimRequestDetail = useCrudSchemas(reactive<CrudSchema[]>(
detail: { detail: {
dateFormat: 'YYYY-MM-DD HH:mm:ss' dateFormat: 'YYYY-MM-DD HH:mm:ss'
}, },
isTableForm:false isTableForm:false,
table: {
width: 150
},
isForm:false
}, },
{ {
label: '最后更新者', label: '最后更新者',
field: 'updater', field: 'updater',
isTableForm:false isTableForm:false,
table: {
width: 150
},
isForm:false
}, },
{ {
label: '最后更新时间', label: '最后更新时间',
@ -10879,8 +10941,22 @@ export const PurchaseclaimRequestDetail = useCrudSchemas(reactive<CrudSchema[]>(
detail: { detail: {
dateFormat: 'YYYY-MM-DD HH:mm:ss' dateFormat: 'YYYY-MM-DD HH:mm:ss'
}, },
isTableForm:false isTableForm:false,
table: {
width: 150
},
isForm:false
}, },
{
label: '操作',
field: 'action',
isDetail: false,
isForm: false ,
table: {
width: 150
},
isTableForm:false,
}
])) ]))
// 表单校验 // 表单校验
export const PurchaseclaimRequestDetailRules = reactive({ export const PurchaseclaimRequestDetailRules = reactive({

9
src/utils/formatTime.ts

@ -155,6 +155,15 @@ export const dateFormatter = (row, column, cellValue) => {
} }
return formatDate(cellValue) return formatDate(cellValue)
} }
// 获取时间戳
export const formatGetTime = (row, column, cellValue) => {
console.log(cellValue.getTime())
// if (!cellValue) {
// return
// }
// const time = new Date(cellValue).getTime()
// return time
}
/** /**
* element plus Formatter 使 YYYY-MM-DD * element plus Formatter 使 YYYY-MM-DD

40
src/views/wms/purchaseclaimRequestMain/index.vue

@ -57,7 +57,12 @@
:isBasic="false" :isBasic="false"
:allSchemas="PurchaseclaimRequestMain.allSchemas" :allSchemas="PurchaseclaimRequestMain.allSchemas"
:detailAllSchemas="PurchaseclaimRequestDetail.allSchemas" :detailAllSchemas="PurchaseclaimRequestDetail.allSchemas"
:detailApi="PurchaseclaimRequestMainApi" :detailAllSchemasRules="PurchaseclaimRequestDetailRules"
:searchTableParams="searchTableParams"
:apiCreate="PurchaseclaimRequestDetailApi.createPurchaseclaimRequestDetail"
:apiUpdate="PurchaseclaimRequestDetailApi.updatePurchaseclaimRequestDetail"
:apiPage="PurchaseclaimRequestDetailApi.getPurchaseclaimRequestDetailPage"
:apiDelete="PurchaseclaimRequestDetailApi.deletePurchaseclaimRequestDetail"
/> />
<!-- 导入 --> <!-- 导入 -->
@ -67,6 +72,7 @@
<script setup lang="ts"> <script setup lang="ts">
import download from '@/utils/download' import download from '@/utils/download'
import * as PurchaseclaimRequestMainApi from '@/api/wms/purchaseclaimRequestMain' import * as PurchaseclaimRequestMainApi from '@/api/wms/purchaseclaimRequestMain'
import * as PurchaseclaimRequestDetailApi from '@/api/wms/purchaseclaimRequestDetail'
import * as supplierdeliverRecordMainApi from '@/api/wms/supplierdeliverRecordMain' import * as supplierdeliverRecordMainApi from '@/api/wms/supplierdeliverRecordMain'
import * as supplierdeliverRecordDetailApi from '@/api/wms/supplierdeliverRecordDetail' import * as supplierdeliverRecordDetailApi from '@/api/wms/supplierdeliverRecordDetail'
import { PurchaseclaimRequestMain, PurchaseclaimRequestMainRules, PurchaseclaimRequestDetail, PurchaseclaimRequestDetailRules, SupplierdeliverRecordMain, SupplierdeliverRecordDetail } from '@/utils/disposition/tableColumns' import { PurchaseclaimRequestMain, PurchaseclaimRequestMainRules, PurchaseclaimRequestDetail, PurchaseclaimRequestDetailRules, SupplierdeliverRecordMain, SupplierdeliverRecordDetail } from '@/utils/disposition/tableColumns'
@ -214,9 +220,13 @@ const buttonTableClick = async (val, row) => {
/** 添加/修改操作 */ /** 添加/修改操作 */
const formRef = ref() const formRef = ref()
const openForm = (type: string, id?: number) => { const openForm =async (type: string, row?: number) => {
tableData.value = [] // tableData.value = [] //
formRef.value.open(type, id) //  if (row?.id) {
// const data= await PurchaseclaimRequestMainApi.getPurchaseclaimRequestMain(row.id)
// tableData.value = data.subList
// }
formRef.value.open(type, row)
} }
/** 详情操作 */ /** 详情操作 */
@ -273,18 +283,22 @@ const handleDeleteTable = (item, index) => {
// //
const submitForm = async (formType, data) => { const submitForm = async (formType, data) => {
data.subList = tableData.value // data.subList = tableData.value //
console.log(data); try {
if (formType === 'create') { if (formType === 'create') {
await PurchaseclaimRequestMainApi.createPurchaseclaimRequestMain(data) await PurchaseclaimRequestMainApi.createPurchaseclaimRequestMain(data)
message.success(t('common.createSuccess')) message.success(t('common.createSuccess'))
} else { } else {
await PurchaseclaimRequestMainApi.updatePurchaseclaimRequestMain(data) await PurchaseclaimRequestMainApi.updatePurchaseclaimRequestMain(data)
message.success(t('common.updateSuccess')) message.success(t('common.updateSuccess'))
}
formRef.value.dialogVisible = false
//
getList()
} finally {
formRef.value.formLoading = false
} }
formRef.value.dialogVisible = false
//
getList()
} }
/** 导入 */ /** 导入 */

Loading…
Cancel
Save