admin-vue3/src/views/crm/contract/components/ContractAAuthorizedCompanyF...

180 lines
6.6 KiB
Vue

<template>
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
v-loading="formLoading"
label-width="0px"
:inline-message="true"
>
<AuthTable v-loading="loading" :fields="formFields" :data="formData" class="-mt-10px">
<template #contractAAuthorizedCompanysother>
<el-table-column label="序号" type="index" width="100" />
</template>
<template #contractAAuthorizedCompanyscustomerName>
<el-table-column label="单位名称" min-width="150">
<template #default="{ row, $index }">
<el-form-item :prop="`${$index}.customerName`" :rules="formRules.customerName" class="mb-0px!" v-if="!type">
<el-input v-model="row.customerName" placeholder="请输入单位名称" />
</el-form-item>
<div v-else>
{{row.customerName}}
</div>
</template>
</el-table-column>
</template>
<template #contractAAuthorizedCompanysunifiedCreditCode>
<el-table-column label="统一社会信用代码" min-width="150">
<template #default="{ row, $index }">
<el-form-item :prop="`${$index}.unifiedCreditCode`" :rules="formRules.unifiedCreditCode" class="mb-0px!" v-if="!type">
<el-input v-model="row.unifiedCreditCode" placeholder="请输入统一社会信用代码" />
</el-form-item>
<div v-else>
{{row.unifiedCreditCode}}
</div>
</template>
</el-table-column>
</template>
<template #contractAAuthorizedCompanysinvoicingAddress>
<el-table-column label="开票地址" min-width="150">
<template #default="{ row, $index }">
<el-form-item :prop="`${$index}.invoicingAddress`" :rules="formRules.invoicingAddress" class="mb-0px!" v-if="!type">
<el-input v-model="row.invoicingAddress" placeholder="请输入开票地址" />
</el-form-item>
<div v-else>
{{row.invoicingAddress}}
</div>
</template>
</el-table-column>
</template>
<template #contractAAuthorizedCompanysinvoicingTelephone>
<el-table-column label="开票电话" min-width="150">
<template #default="{ row, $index }">
<el-form-item :prop="`${$index}.invoicingTelephone`" :rules="formRules.invoicingTelephone" class="mb-0px!" v-if="!type">
<el-input v-model="row.invoicingTelephone" placeholder="请输入开票电话" />
</el-form-item>
<div v-else>
{{row.invoicingTelephone}}
</div>
</template>
</el-table-column>
</template>
<template #contractAAuthorizedCompanyscompanyBank>
<el-table-column label="开户行" min-width="150">
<template #default="{ row, $index }">
<el-form-item :prop="`${$index}.companyBank`" :rules="formRules.companyBank" class="mb-0px!" v-if="!type">
<el-input v-model="row.companyBank" placeholder="请输入开户行" />
</el-form-item>
<div v-else>
{{row.companyBank}}
</div>
</template>
</el-table-column>
</template>
<template #contractAAuthorizedCompanyscompanyAccount>
<el-table-column label="开户账号" min-width="150">
<template #default="{ row, $index }">
<el-form-item :prop="`${$index}.companyAccount`" :rules="formRules.companyAccount" class="mb-0px!" v-if="!type">
<el-input v-model="row.companyAccount" placeholder="请输入开户账号" />
</el-form-item>
<div v-else>
{{row.companyAccount}}
</div>
</template>
</el-table-column>
</template>
<template #contractAAuthorizedCompanyscompanyAddress>
<el-table-column label="通讯地址" min-width="150">
<template #default="{ row, $index }">
<el-form-item :prop="`${$index}.companyAddress`" :rules="formRules.companyAddress" class="mb-0px!" v-if="!type">
<el-input v-model="row.companyAddress" placeholder="请输入通讯地址" />
</el-form-item>
<div v-else>
{{row.companyAddress}}
</div>
</template>
</el-table-column>
</template>
<template #contractAAuthorizedCompanysother2>
<el-table-column align="center" fixed="right" label="操作" width="60" v-if="!type">
<template #default="{ $index }">
<el-button @click="handleDelete($index)" link>—</el-button>
</template>
</el-table-column>
</template>
</AuthTable>
</el-form>
<el-row justify="center" class="mt-3" v-if="!type">
<el-button @click="handleAdd" round>+ 添加</el-button>
</el-row>
</template>
<script setup lang="ts">
import * as ContractApi from '@/api/crm/contract'
import { propTypes } from '@/utils/propTypes'
const formLoading = ref(false) //
const formData = ref([])
const formRules = reactive({
contractId: [{ required: true, message: 'ID', trigger: 'blur' }],
customerName: [{ required: true, message: '', trigger: 'blur' }],
unifiedCreditCode: [{ required: true, message: '', trigger: 'blur' }],
invoicingAddress: [{ required: true, message: '', trigger: 'blur' }],
invoicingTelephone: [{ required: true, message: '', trigger: 'blur' }],
companyBank: [{ required: true, message: '', trigger: 'blur' }],
companyAccount: [{ required: true, message: '', trigger: 'blur' }]
})
const formRef = ref() // Ref
const contactRef = ref() // Ref
/** */
const handleAdd = () => {
const row = {
unifiedCreditCode: undefined,
invoicingAddress: undefined,
customerName: undefined,
invoicingTelephone: undefined,
companyBank: undefined,
companyAddress: undefined,
companyAccount: undefined
}
row.contractId = props.contractId
formData.value.push(row)
}
const props = defineProps<{
data: undefined,
type: undefined,
formFields: {}
}>()
/** 监听主表的关联字段的变化,加载对应的子表数据 */
watch(
() => props.data,
async (val) => {
// 1. 重置表单
formData.value = val
},
{ immediate: true }
)
/** 删除按钮操作 */
const handleDelete = (index) => {
formData.value.splice(index, 1)
}
/** 表单校验 */
const validate = () => {
return formRef.value.validate()
}
/** 表单值 */
const getData = () => {
return formData.value
}
defineExpose({ validate, getData })
</script>