|
@@ -2,9 +2,10 @@
|
|
|
import { useRouter, useRoute } from 'vue-router'
|
|
import { useRouter, useRoute } from 'vue-router'
|
|
|
import partyIDSelect from './components/partyIDSelect.vue'
|
|
import partyIDSelect from './components/partyIDSelect.vue'
|
|
|
import GroupNameSelect from './components/GroupNameSelect.vue'
|
|
import GroupNameSelect from './components/GroupNameSelect.vue'
|
|
|
|
|
+import AccountSelect from './components/AccountSelect.vue'
|
|
|
import { VueDraggable } from 'vue-draggable-plus'
|
|
import { VueDraggable } from 'vue-draggable-plus'
|
|
|
import AdjustmentField from './components/AdjustmentField.vue'
|
|
import AdjustmentField from './components/AdjustmentField.vue'
|
|
|
-import { cloneDeep, uniq, uniqueId } from 'lodash'
|
|
|
|
|
|
|
+import { cloneDeep } from 'lodash'
|
|
|
|
|
|
|
|
const router = useRouter()
|
|
const router = useRouter()
|
|
|
const route = useRoute()
|
|
const route = useRoute()
|
|
@@ -107,16 +108,28 @@ const changeFieldConfig = (state: any, field: string, index: number, key: string
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const handleDeleteField = (index: number) => {
|
|
|
|
|
|
|
+const handleDeleteField = (index: number, uniqueId: string) => {
|
|
|
fieldsList.value.splice(index, 1)
|
|
fieldsList.value.splice(index, 1)
|
|
|
|
|
+
|
|
|
|
|
+ Object.keys(copyFieldsList.value).forEach((key) => {
|
|
|
|
|
+ copyFieldsList.value[key] = copyFieldsList.value[key].filter(
|
|
|
|
|
+ (item) => item.uniqueId !== uniqueId
|
|
|
|
|
+ )
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
|
|
+const copyFieldsList = ref({})
|
|
|
const handleCopyField = (index: number) => {
|
|
const handleCopyField = (index: number) => {
|
|
|
const curField = cloneDeep(fieldsList.value[index])
|
|
const curField = cloneDeep(fieldsList.value[index])
|
|
|
curField.displayName = `${curField.displayName} (Copy)`
|
|
curField.displayName = `${curField.displayName} (Copy)`
|
|
|
curField.isFilter = false
|
|
curField.isFilter = false
|
|
|
curField.isSort = false
|
|
curField.isSort = false
|
|
|
curField.uniqueId = generate8DigitUnique()
|
|
curField.uniqueId = generate8DigitUnique()
|
|
|
- fieldsList.value.splice(index + 1, 0, curField)
|
|
|
|
|
|
|
+ if (copyFieldsList.value[curField.field]) {
|
|
|
|
|
+ copyFieldsList.value[curField.field].push(cloneDeep(curField))
|
|
|
|
|
+ } else {
|
|
|
|
|
+ copyFieldsList.value[curField.field] = [cloneDeep(curField)]
|
|
|
|
|
+ }
|
|
|
|
|
+ fieldsList.value.splice(index + 1, 0, cloneDeep(curField))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const AdjustmentFieldRef = ref()
|
|
const AdjustmentFieldRef = ref()
|
|
@@ -130,11 +143,20 @@ const handleCustomizeColumns = () => {
|
|
|
serial_no: '',
|
|
serial_no: '',
|
|
|
level: infoData.value.reportLevel
|
|
level: infoData.value.reportLevel
|
|
|
}
|
|
}
|
|
|
|
|
+ const seen = new Set()
|
|
|
|
|
+ const uniqueArray = fieldsList.value.filter((item) => {
|
|
|
|
|
+ if (seen.has(item.field)) {
|
|
|
|
|
+ return false // 已存在,跳过
|
|
|
|
|
+ }
|
|
|
|
|
+ seen.add(item.field)
|
|
|
|
|
+ return true // 第一次出现,保留
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
AdjustmentFieldRef.value.openDialog(
|
|
AdjustmentFieldRef.value.openDialog(
|
|
|
params,
|
|
params,
|
|
|
-220,
|
|
-220,
|
|
|
'Drag item over to this selection or click "add" icon to show the field on report template list',
|
|
'Drag item over to this selection or click "add" icon to show the field on report template list',
|
|
|
- fieldsList.value
|
|
|
|
|
|
|
+ uniqueArray
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -198,6 +220,24 @@ const handleApplay = (data: any) => {
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
fieldsList.value = [...customizeData, ...fieldsList.value]
|
|
fieldsList.value = [...customizeData, ...fieldsList.value]
|
|
|
|
|
+
|
|
|
|
|
+ const validFields = new Set(fieldsList.value.map((item) => item.field))
|
|
|
|
|
+ for (const field in copyFieldsList.value) {
|
|
|
|
|
+ if (!validFields.has(field)) {
|
|
|
|
|
+ delete copyFieldsList.value[field]
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // === 第三步:从后往前插入副本(不修改原始项)===
|
|
|
|
|
+ for (let i = fieldsList.value.length - 1; i >= 0; i--) {
|
|
|
|
|
+ const field = fieldsList.value[i].field
|
|
|
|
|
+ const copies = copyFieldsList.value[field]
|
|
|
|
|
+
|
|
|
|
|
+ if (copies?.length) {
|
|
|
|
|
+ // 插入副本到原项后面
|
|
|
|
|
+ fieldsList.value.splice(i + 1, 0, ...copies)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const accessControlType = ref('All Users')
|
|
const accessControlType = ref('All Users')
|
|
@@ -206,7 +246,7 @@ const detailRef: Ref<HTMLElement | null> = ref(null)
|
|
|
const specificRoles = ref({
|
|
const specificRoles = ref({
|
|
|
partyId: [],
|
|
partyId: [],
|
|
|
groupName: [],
|
|
groupName: [],
|
|
|
- systemAccount: ''
|
|
|
|
|
|
|
+ systemAccount: []
|
|
|
})
|
|
})
|
|
|
const changePartyId = (val: string[]) => {
|
|
const changePartyId = (val: string[]) => {
|
|
|
specificRoles.value.partyId = val
|
|
specificRoles.value.partyId = val
|
|
@@ -215,6 +255,10 @@ const changeGroupName = (val: string[]) => {
|
|
|
specificRoles.value.groupName = val
|
|
specificRoles.value.groupName = val
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+const changeAccount = (val: string[]) => {
|
|
|
|
|
+ specificRoles.value.systemAccount = val
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const fieldLoading = ref(false)
|
|
const fieldLoading = ref(false)
|
|
|
const handleRightRemove = () => {}
|
|
const handleRightRemove = () => {}
|
|
|
|
|
|
|
@@ -238,9 +282,9 @@ const handlePageSave = () => {
|
|
|
}
|
|
}
|
|
|
if (
|
|
if (
|
|
|
accessControlType.value === 'Specific Roles' &&
|
|
accessControlType.value === 'Specific Roles' &&
|
|
|
- specificRoles.value.partyId.length === 0 &&
|
|
|
|
|
- specificRoles.value.groupName.length === 0 &&
|
|
|
|
|
- specificRoles.value.systemAccount
|
|
|
|
|
|
|
+ specificRoles.value.partyId?.length === 0 &&
|
|
|
|
|
+ specificRoles.value.groupName?.length === 0 &&
|
|
|
|
|
+ specificRoles.value.systemAccount?.length === 0
|
|
|
) {
|
|
) {
|
|
|
ElMessage.warning('Please select Party ID or Group Name for Specific Roles access control.')
|
|
ElMessage.warning('Please select Party ID or Group Name for Specific Roles access control.')
|
|
|
verified = false
|
|
verified = false
|
|
@@ -248,6 +292,7 @@ const handlePageSave = () => {
|
|
|
if (!verified) {
|
|
if (!verified) {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
+ pageLoading.value = true
|
|
|
const data = {
|
|
const data = {
|
|
|
report_name: infoData.value.reportName,
|
|
report_name: infoData.value.reportName,
|
|
|
report_level: infoData.value.reportLevel,
|
|
report_level: infoData.value.reportLevel,
|
|
@@ -255,21 +300,26 @@ const handlePageSave = () => {
|
|
|
access_type: accessControlType.value,
|
|
access_type: accessControlType.value,
|
|
|
party_ids: specificRoles.value.partyId || [],
|
|
party_ids: specificRoles.value.partyId || [],
|
|
|
group_names: specificRoles.value.groupName || [],
|
|
group_names: specificRoles.value.groupName || [],
|
|
|
- system_account: specificRoles.value.systemAccount,
|
|
|
|
|
|
|
+ system_account: specificRoles.value.systemAccount || [],
|
|
|
fieldsList: fieldsList.value
|
|
fieldsList: fieldsList.value
|
|
|
}
|
|
}
|
|
|
let serial_no = ''
|
|
let serial_no = ''
|
|
|
if (route.query.copy !== 't' && route.query.serial_no) {
|
|
if (route.query.copy !== 't' && route.query.serial_no) {
|
|
|
serial_no = String(route.query.serial_no)
|
|
serial_no = String(route.query.serial_no)
|
|
|
}
|
|
}
|
|
|
- $api.saveNewReportTemplate({ ...data, serial_no }).then((res: any) => {
|
|
|
|
|
- if (res.code === 200) {
|
|
|
|
|
- ElMessage.success('Report Template saved successfully!')
|
|
|
|
|
- router.push('/template-management')
|
|
|
|
|
- } else {
|
|
|
|
|
- ElMessage.error(res.data.msg || 'Failed to save Report Template.')
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ $api
|
|
|
|
|
+ .saveNewReportTemplate({ ...data, serial_no })
|
|
|
|
|
+ .then((res: any) => {
|
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
|
+ ElMessage.success('Report Template saved successfully!')
|
|
|
|
|
+ router.push('/template-management')
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ElMessage.error(res.data.msg || 'Failed to save Report Template.')
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .finally(() => {
|
|
|
|
|
+ pageLoading.value = false
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
</script>
|
|
</script>
|
|
|
<template>
|
|
<template>
|
|
@@ -416,7 +466,7 @@ const handlePageSave = () => {
|
|
|
class="font_family icon-icon_clone_b"
|
|
class="font_family icon-icon_clone_b"
|
|
|
></span>
|
|
></span>
|
|
|
<span
|
|
<span
|
|
|
- @click="handleDeleteField(index)"
|
|
|
|
|
|
|
+ @click="handleDeleteField(index, fieldItem.uniqueId)"
|
|
|
class="font_family icon-icon_delete_b"
|
|
class="font_family icon-icon_delete_b"
|
|
|
></span>
|
|
></span>
|
|
|
</div>
|
|
</div>
|
|
@@ -477,10 +527,10 @@ const handlePageSave = () => {
|
|
|
<span style="color: var(--color-danger)">*</span>
|
|
<span style="color: var(--color-danger)">*</span>
|
|
|
<span>KLN ONLINE Account</span>
|
|
<span>KLN ONLINE Account</span>
|
|
|
</div>
|
|
</div>
|
|
|
- <el-input
|
|
|
|
|
- placeholder="Please enter KLN ONLINE Account"
|
|
|
|
|
- v-model="specificRoles.systemAccount"
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ <AccountSelect
|
|
|
|
|
+ @change-data="changeAccount"
|
|
|
|
|
+ :data="specificRoles.systemAccount"
|
|
|
|
|
+ ></AccountSelect>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|