|
@@ -11,8 +11,8 @@
|
|
|
:total="total"
|
|
|
:page-info="query"
|
|
|
@pageHandleChange="handleChangePage"
|
|
|
- @add="handleAdd"
|
|
|
- @edit="handleEdit"
|
|
|
+ @add="handle"
|
|
|
+ @edit="handle"
|
|
|
@del="handleDelete"
|
|
|
>
|
|
|
</CtTable>
|
|
@@ -71,13 +71,12 @@ const query = ref({
|
|
|
const CtFormRef = ref()
|
|
|
const show = ref(false)
|
|
|
const editId = ref(null)
|
|
|
-
|
|
|
-
|
|
|
+const editInfo = ref(null)
|
|
|
|
|
|
const personKeys = ['category', 'type', 'title']
|
|
|
const enterpriseKeys = ['category', 'type', 'certificationTip', 'invoiceHeaderTip', 'title', 'code', 'enterpriseBankTitle', 'enterpriseBankNo', 'enterpriseAddress', 'enterprisePhone']
|
|
|
// 抬头类型
|
|
|
-const handleChangeCategory = (categoryType) => { // 0: 个人, 1: 企业
|
|
|
+const handleChangeCategory = (categoryType = 0) => { // 0: 个人, 1: 企业
|
|
|
formItems.value.options = []
|
|
|
const keyArr = categoryType ? enterpriseKeys : personKeys
|
|
|
const arr = keyArr.map(key => {
|
|
@@ -91,7 +90,11 @@ const handleChangeCategory = (categoryType) => { // 0: 个人, 1: 企业
|
|
|
}
|
|
|
} else { // 企业
|
|
|
if (optionsItem.key === 'category') optionsItem.value = 1
|
|
|
- if (business.value[key]) optionsItem.value = business.value[key]
|
|
|
+ if (editInfo.value) {
|
|
|
+ if (editInfo.value[key]) optionsItem.value = editInfo.value[key]
|
|
|
+ } else {
|
|
|
+ if (business.value[key]) optionsItem.value = business.value[key]
|
|
|
+ }
|
|
|
}
|
|
|
return optionsItem
|
|
|
})
|
|
@@ -249,25 +252,12 @@ const getEnterpriseBusinessInfo = async () => {
|
|
|
}
|
|
|
getEnterpriseBusinessInfo()
|
|
|
|
|
|
-// 新增
|
|
|
-const handleAdd = () => {
|
|
|
- // 初始化表单
|
|
|
- handleChangeCategory(0)
|
|
|
- handleChangeType(0)
|
|
|
- show.value = true
|
|
|
- editId.value = null
|
|
|
-}
|
|
|
-
|
|
|
-// 编辑
|
|
|
-const handleEdit = (item) => {
|
|
|
- editId.value = item.id
|
|
|
- formItems.value.options.forEach(e => {
|
|
|
- e.value = item[e.key]
|
|
|
- if (e.key === 'category' || e.key === 'type') {
|
|
|
- e.value = item[e.key] || 0
|
|
|
- e.change(e.value)
|
|
|
- }
|
|
|
- })
|
|
|
+// 新增 编辑
|
|
|
+const handle = (item) => {
|
|
|
+ editId.value = item?.id || null
|
|
|
+ editInfo.value = item || null
|
|
|
+ handleChangeCategory(item?.category || 0)
|
|
|
+ handleChangeType(item?.type || 0)
|
|
|
show.value = true
|
|
|
}
|
|
|
|