Browse Source

详情组件修改 tabs

master
陈薪名 1 year ago
parent
commit
04740f28db
  1. 186
      src/components/Detail/src/Detail.vue

186
src/components/Detail/src/Detail.vue

@ -1,18 +1,32 @@
<template> <template>
<div> <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">
{{ titleValueRef }} <span class="ml-20px font-size-16px">{{ titleNameRef }}</span> {{ titleValueRef }} <span class="ml-20px font-size-16px">{{ titleNameRef }}</span>
</div> </div>
</template> </template>
<ContentWrap v-if="!isBasic"> <ContentWrap v-if="!isBasic">
<Descriptions :data="detailData" labelClassName="label-class-name" label-align="left" direction="vertical" <Descriptions
:column="8" :schema="allSchemas.detailSchema" :columns="2" width="200px" /> :data="detailData"
labelClassName="label-class-name"
label-align="left"
direction="vertical"
:column="8"
:schema="allSchemas.detailSchema"
:columns="2"
width="200px"
/>
</ContentWrap> </ContentWrap>
<Tabs :tabsList="tabsList" :current="current" @change="change" /> <Tabs :tabsList="tabsList" :current="current" @change="change" />
<div class="flex" v-if="current == 0"> <div class="flex">
<!-- 详情 --> <!-- 详情 -->
<ContentWrap class="w-[73%]"> <ContentWrap class="w-[73%]">
<!-- 列表头部 --> <!-- 列表头部 -->
@ -25,26 +39,43 @@
@searchFormClick="searchFormClick" @searchFormClick="searchFormClick"
:allSchemas="detailAllSchemas" :allSchemas="detailAllSchemas"
/> />
<Descriptions v-if="isBasic" :data="detailData" :schema="allSchemas.detailSchema" :columns="2" /> <Descriptions
v-if="isBasic"
:data="detailData"
:schema="allSchemas.detailSchema"
:columns="2"
/>
<Table <Table
v-if="!isBasic" v-if="!isBasic"
:columns="detailAllSchemas.tableColumns" :columns="detailAllSchemasRef.tableColumns"
:data="tableObject.tableList" :data="tableObjectRef.tableList"
:loading="tableObject.loading" :loading="tableObjectRef.loading"
:pagination="{ total: tableObject.total }" :pagination="{ total: tableObjectRef.total }"
v-model:pageSize="tableObject.pageSize" v-model:pageSize="tableObjectRef.pageSize"
v-model:currentPage="tableObject.currentPage" > v-model:currentPage="tableObjectRef.currentPage"
>
<template #action="{ row }"> <template #action="{ row }">
<ButtonBase :Butttondata="buttondata" @button-base-click="buttonTableClick($event, row)" /> <ButtonBase
:Butttondata="buttondata"
@button-base-click="buttonTableClick($event, row)"
/>
</template> </template>
</Table> </Table>
</ContentWrap> </ContentWrap>
<ContentWrap class="w-[27%] ml-16px"> <ContentWrap class="w-[27%] ml-16px">
<!-- 附件组件 --> <!-- 附件组件 -->
<Annex :annexData="annexData" @handleAnnexSuccess="handleAnnexSuccess" @deleteAnnexSuccess="deleteAnnexSuccess" :upData="remarksData.data"/> <Annex
:annexData="annexData"
@handleAnnexSuccess="handleAnnexSuccess"
@deleteAnnexSuccess="deleteAnnexSuccess"
:upData="remarksData.data"
/>
<!-- 备注组件 --> <!-- 备注组件 -->
<Remarks :remarksData="remarksData" class="mt-20px" <Remarks
@remarksSubmitScuess="remarksSubmitScuess" /> :remarksData="remarksData"
class="mt-20px"
@remarksSubmitScuess="remarksSubmitScuess"
/>
<!-- 变更记录组件 --> <!-- 变更记录组件 -->
<ChangeRecord :changeRecordData="changeRecordData" class="mt-20px" /> <ChangeRecord :changeRecordData="changeRecordData" class="mt-20px" />
</ContentWrap> </ContentWrap>
@ -53,7 +84,7 @@
<!-- 表单弹窗添加/修改 --> <!-- 表单弹窗添加/修改 -->
<BasicForm <BasicForm
ref="formRef" ref="formRef"
@success="getList" @success="submitForm"
:rules="detailAllSchemasRules" :rules="detailAllSchemasRules"
:formAllSchemas="detailAllSchemas" :formAllSchemas="detailAllSchemas"
:isBusiness="false" :isBusiness="false"
@ -63,7 +94,7 @@
:detailData="detailData" :detailData="detailData"
@submitForm="submitForm" @submitForm="submitForm"
/> />
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -85,7 +116,7 @@ const { t } = useI18n() // 国际化
const route = useRoute() // const route = useRoute() //
const routeName = ref() const routeName = ref()
routeName.value = route.name routeName.value = route.name
routeName.value = routeName.value.substring(0,routeName.value.length - 4) + 'Detail' routeName.value = routeName.value.substring(0, routeName.value.length - 4) + 'Detail'
const props = defineProps({ const props = defineProps({
// //
@ -147,22 +178,31 @@ const props = defineProps({
type: Array, type: Array,
required: false, required: false,
default: null default: null
}, }
}) })
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 (props.isBasic == true) {
if (tabsList.value && tabsList.value.length > 0) {
tabsList.value.unshift({ tabsList.value.unshift({
label: '详情', label: '详情',
prop: 'Detail' prop: 'Detail'
}) })
}
} else { } else {
tabsList.value = [{ if (tabsList.value && tabsList.value.length > 0) {
} else {
tabsList.value = [
{
label: '明细', label: '明细',
prop: 'Detail' prop: 'Detail'
}] }
]
}
}
if (tabsList.value) {
} }
// //
@ -173,14 +213,14 @@ const annexData = reactive({
// //
const remarksData = reactive({ const remarksData = reactive({
remarksList: [], remarksList: [],
data:{} data: {}
}) })
// //
const changeRecordData = reactive({ const changeRecordData = reactive({
changeRecordList: [] changeRecordList: []
}) })
const detailData = ref({})// const detailData = ref({}) //
// //
const getFileList = async () => { const getFileList = async () => {
detailLoading.value = true detailLoading.value = true
@ -194,11 +234,9 @@ const getFileList = async () => {
const handleAnnexSuccess = () => { const handleAnnexSuccess = () => {
getFileList() getFileList()
getChangeRecordList() getChangeRecordList()
} }
// //
const deleteAnnexSuccess = async () => { const deleteAnnexSuccess = async () => {
getFileList() getFileList()
getChangeRecordList() getChangeRecordList()
} }
@ -207,13 +245,14 @@ const deleteAnnexSuccess = async () => {
const current = ref(0) const current = ref(0)
const change = (item, index) => { const change = (item, index) => {
current.value = index current.value = index
emit('changeTabs', item)
} }
// //
const masterParmas=ref({ const masterParmas = ref({
masterId:'',//id masterId: '', //id
number: '',// number: '', //
status: '',// status: '' //
}) })
// //
@ -229,16 +268,16 @@ const openDetail = async (row: any, titleName: any, titleValue: any, tableName:
titleValueRef.value = titleValue titleValueRef.value = titleValue
remarksData.data = { remarksData.data = {
tableId: row.id, tableId: row.id,
tableName: tableName, tableName: tableName
} }
// //
if(!props.isBasic) { if (!props.isBasic) {
// id // id
masterParmas.value.masterId = row.id masterParmas.value.masterId = row.id
masterParmas.value.number = row.number masterParmas.value.number = row.number
masterParmas.value.status = row.status masterParmas.value.status = row.status
tableObject.params = { tableObjectRef.value.params = {
masterId: row.id, masterId: row.id
} }
getList() getList()
} }
@ -252,13 +291,19 @@ const openDetail = async (row: any, titleName: any, titleValue: any, tableName:
getChangeRecordList() getChangeRecordList()
// //
HeadButttondata.value = [ HeadButttondata.value = [
defaultButtons.defaultAddBtn({hide:isShowMainButton(row,['1','1','PLAN_PURCHASE_READY','1'])}), // defaultButtons.defaultAddBtn({
defaultButtons.defaultFilterBtn(null), // hide: isShowMainButton(row, ['1'])
}), //
defaultButtons.defaultFilterBtn(null) //
] ]
// //
buttondata.value = [ buttondata.value = [
defaultButtons.mainListEditBtn({hide:isShowMainButton(row,['1','1','PLAN_PURCHASE_READY','1'])}), // defaultButtons.mainListEditBtn({
// defaultButtons.mainListDeleteBtn({hide:isShowMainButton(row,['1','1','PLAN_PURCHASE_READY','1'])}), // hide: isShowMainButton(row, ['1'])
}), //
defaultButtons.mainListDeleteBtn({
hide: isShowMainButton(row, ['1'])
}) //
] ]
} finally { } finally {
detailLoading.value = false detailLoading.value = false
@ -287,12 +332,21 @@ const getChangeRecordList = async () => {
changeRecordData.changeRecordList = await RemarkApi.getChangeRecordPage(remarksData.data) changeRecordData.changeRecordList = await RemarkApi.getChangeRecordPage(remarksData.data)
} }
const tableObjectRef = ref()
const tableMethodsRef = ref()
const detailAllSchemasRef = ref()
const { tableObject, tableMethods } = useTable({ const { tableObject, tableMethods } = useTable({
getListApi: props.apiPage // getListApi: props.apiPage //
}) })
tableObjectRef.value = tableObject
tableMethodsRef.value = tableMethods
detailAllSchemasRef.value = props.detailAllSchemas
// //
const isShowMainButton = (row,val) => { const isShowMainButton = (row, val) => {
if (val.indexOf(row.status) > -1) { if (val.indexOf(row.status) > -1) {
return false return false
} else { } else {
@ -300,22 +354,27 @@ const isShowMainButton = (row,val) => {
} }
} }
// //
const { getList } = tableMethods const { getList } = tableMethodsRef.value
// //
const buttonBaseClick = (val, item) => { const buttonBaseClick = (val, item) => {
if (val == 'add') { // if (val == 'add') {
//
openForm('create') openForm('create')
} else if (val == 'import') { // } else if (val == 'import') {
//
handleImport() handleImport()
} else if (val == 'export') { // } else if (val == 'export') {
//
handleExport() handleExport()
} else if (val == 'refresh') { // } else if (val == 'refresh') {
//
getList() getList()
} else if (val == 'filtrate') { // } else if (val == 'filtrate') {
} else { // //
} else {
//
console.log('其他按钮', item) console.log('其他按钮', item)
} }
} }
@ -327,9 +386,11 @@ const buttonBaseClick = (val, item) => {
// - // -
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') {
//
handleDelete(row.id) handleDelete(row.id)
} }
} }
@ -361,9 +422,7 @@ const searchTableSuccess = (formField, searchField, val, formRef) => {
emit('searchTableSuccessDetail', formField, searchField, val, formRef) emit('searchTableSuccessDetail', formField, searchField, val, formRef)
} }
// //
const emit = defineEmits([ const emit = defineEmits(['searchTableSuccessDetail', 'changeTabs'])
'searchTableSuccessDetail',
])
/** 删除按钮操作 */ /** 删除按钮操作 */
const handleDelete = async (id: number) => { const handleDelete = async (id: number) => {
try { try {
@ -374,16 +433,33 @@ const handleDelete = async (id: number) => {
message.success(t('common.delSuccess')) message.success(t('common.delSuccess'))
// //
await getList() await getList()
} catch { } } catch {}
} }
// //
const searchFormClick = (searchData) => { const searchFormClick = (searchData) => {
tableObject.params = { tableObjectRef.value.params = {
isSearch: true, isSearch: true,
filters: searchData.filters?searchData.filters:[{column: "masterId", action: "==", value: masterParmas.value.masterId}] filters: searchData.filters
? searchData.filters
: [{ column: 'masterId', action: '==', value: masterParmas.value.masterId }]
} }
getList() // getList() //
} }
//
watch(
() => props.apiPage,
() => {
const { tableObject, tableMethods } = useTable({
getListApi: props.apiPage //
})
detailAllSchemasRef.value = props.detailAllSchemas
tableObjectRef.value = tableObject
tableMethodsRef.value = tableMethods
const { getList } = tableMethods
getList()
}
)
</script> </script>
<style lang="scss"> <style lang="scss">
.el-drawer__body { .el-drawer__body {

Loading…
Cancel
Save