|
@@ -1,42 +1,63 @@
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
-import { useRouter } 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 { VueDraggable } from 'vue-draggable-plus'
|
|
import { VueDraggable } from 'vue-draggable-plus'
|
|
|
import AdjustmentField from './components/AdjustmentField.vue'
|
|
import AdjustmentField from './components/AdjustmentField.vue'
|
|
|
|
|
|
|
|
const router = useRouter()
|
|
const router = useRouter()
|
|
|
-const filterRef: Ref<HTMLElement | null> = ref(null)
|
|
|
|
|
-const searchData = ref({
|
|
|
|
|
- text_search: '',
|
|
|
|
|
- request_date_start: '',
|
|
|
|
|
- request_date_end: '',
|
|
|
|
|
- ai_model: '',
|
|
|
|
|
- response_duration_type: '',
|
|
|
|
|
- response_duration_num: null
|
|
|
|
|
-})
|
|
|
|
|
|
|
+const route = useRoute()
|
|
|
|
|
|
|
|
const infoData = ref({
|
|
const infoData = ref({
|
|
|
reportName: '',
|
|
reportName: '',
|
|
|
reportLevel: '',
|
|
reportLevel: '',
|
|
|
reportDescription: ''
|
|
reportDescription: ''
|
|
|
})
|
|
})
|
|
|
|
|
+const pageLoading = ref(false)
|
|
|
|
|
+onMounted(() => {
|
|
|
|
|
+ if (route.query.serial_no) {
|
|
|
|
|
+ pageLoading.value = true
|
|
|
|
|
+ $api
|
|
|
|
|
+ .editReportTemplate({ serial_no: route.query.serial_no })
|
|
|
|
|
+ .then((res) => {
|
|
|
|
|
+ console.log('editReportTemplate', res)
|
|
|
|
|
+ infoData.value = {
|
|
|
|
|
+ reportName: res.data.reportName,
|
|
|
|
|
+ reportLevel: res.data.reportLevel,
|
|
|
|
|
+ reportDescription: res.data.reportDescription
|
|
|
|
|
+ }
|
|
|
|
|
+ fieldsList.value = res.data.reportFields
|
|
|
|
|
+ accessControlType.value = res.data.reportAccess.type
|
|
|
|
|
+ specificRoles.value = {
|
|
|
|
|
+ partyId: res.data.reportAccess.partyId,
|
|
|
|
|
+ groupName: res.data.reportAccess.groupName
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .finally(() => {
|
|
|
|
|
+ pageLoading.value = false
|
|
|
|
|
|
|
|
-const tableRef = ref()
|
|
|
|
|
-
|
|
|
|
|
-const Search = () => {
|
|
|
|
|
- tableRef.value.SearchOperationLog(searchData.value)
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-const handleCreate = () => {
|
|
|
|
|
- // Navigate to the Create Report Template page
|
|
|
|
|
- router.push('/create-report-template')
|
|
|
|
|
-}
|
|
|
|
|
|
|
+ watch(accessControlType, (newVal) => {
|
|
|
|
|
+ if (newVal === 'Specific Roles') {
|
|
|
|
|
+ // 等待下一个渲染周期结束后,获取detailRef的高度
|
|
|
|
|
+ nextTick(() => {
|
|
|
|
|
+ if (detailRef.value) {
|
|
|
|
|
+ detailRef.value.scrollIntoView({
|
|
|
|
|
+ behavior: 'smooth', // 平滑滚动
|
|
|
|
|
+ block: 'start' // 滚动到顶部对齐
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+})
|
|
|
|
|
|
|
|
interface Field {
|
|
interface Field {
|
|
|
field: string
|
|
field: string
|
|
|
title: string
|
|
title: string
|
|
|
displayName: string
|
|
displayName: string
|
|
|
|
|
+ fieldType: string
|
|
|
value?: string
|
|
value?: string
|
|
|
isFilter: boolean
|
|
isFilter: boolean
|
|
|
isSort: boolean
|
|
isSort: boolean
|
|
@@ -64,6 +85,10 @@ const handleDeleteField = (field: string) => {
|
|
|
const AdjustmentFieldRef = ref()
|
|
const AdjustmentFieldRef = ref()
|
|
|
// 打开定制表格弹窗
|
|
// 打开定制表格弹窗
|
|
|
const handleCustomizeColumns = () => {
|
|
const handleCustomizeColumns = () => {
|
|
|
|
|
+ if (!infoData.value.reportLevel) {
|
|
|
|
|
+ ElMessage.warning('Please select the report level.')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
const params = {
|
|
const params = {
|
|
|
serial_no: '',
|
|
serial_no: '',
|
|
|
level: infoData.value.reportLevel
|
|
level: infoData.value.reportLevel
|
|
@@ -74,8 +99,6 @@ const handleCustomizeColumns = () => {
|
|
|
'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'
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
-// 定制表格
|
|
|
|
|
-const customizeColumns = async () => {}
|
|
|
|
|
|
|
|
|
|
const newFieldInfo = ref<{
|
|
const newFieldInfo = ref<{
|
|
|
name: string
|
|
name: string
|
|
@@ -95,60 +118,105 @@ const handleFieldTypeChange = () => {
|
|
|
newFieldInfo.value.value = ''
|
|
newFieldInfo.value.value = ''
|
|
|
}
|
|
}
|
|
|
const addNewField = () => {
|
|
const addNewField = () => {
|
|
|
- if (newFieldInfo.value.name) {
|
|
|
|
|
- fieldsList.value.push({
|
|
|
|
|
- field: newFieldInfo.value.name,
|
|
|
|
|
- title: newFieldInfo.value.name,
|
|
|
|
|
- value: newFieldInfo.value.value,
|
|
|
|
|
- displayName: '',
|
|
|
|
|
- isFilter: false,
|
|
|
|
|
- isSort: false
|
|
|
|
|
- })
|
|
|
|
|
- newFieldInfo.value = {
|
|
|
|
|
- name: '',
|
|
|
|
|
- fieldType: 'Blank',
|
|
|
|
|
- value: ''
|
|
|
|
|
- }
|
|
|
|
|
- addNewFieldVisible.value = false
|
|
|
|
|
- } else {
|
|
|
|
|
|
|
+ console.log(newFieldInfo.value.name?.trim(), 'newFieldInfo', newFieldInfo.value)
|
|
|
|
|
+ if (!newFieldInfo.value.name?.trim()) {
|
|
|
ElMessage.warning('Please enter the new field name.')
|
|
ElMessage.warning('Please enter the new field name.')
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if (newFieldInfo.value.fieldType === 'Fixed Value' && !newFieldInfo.value.value?.trim()) {
|
|
|
|
|
+ ElMessage.warning('Please enter the fixed value.')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ fieldsList.value.unshift({
|
|
|
|
|
+ field: newFieldInfo.value.name,
|
|
|
|
|
+ title: newFieldInfo.value.name,
|
|
|
|
|
+ displayName: newFieldInfo.value.name,
|
|
|
|
|
+ value: newFieldInfo.value.value,
|
|
|
|
|
+ fieldType: 'Custom',
|
|
|
|
|
+ isFilter: false,
|
|
|
|
|
+ isSort: false
|
|
|
|
|
+ })
|
|
|
|
|
+ newFieldInfo.value = {
|
|
|
|
|
+ name: '',
|
|
|
|
|
+ fieldType: 'Blank',
|
|
|
|
|
+ value: ''
|
|
|
|
|
+ }
|
|
|
|
|
+ addNewFieldVisible.value = false
|
|
|
}
|
|
}
|
|
|
// 调整应用字段
|
|
// 调整应用字段
|
|
|
const handleApplay = (data: any) => {
|
|
const handleApplay = (data: any) => {
|
|
|
console.log('data', data)
|
|
console.log('data', data)
|
|
|
|
|
+ const customizeData = fieldsList.value.filter((item: any) => item.field_type === 'Custom')
|
|
|
|
|
+ fieldsList.value = data.map((item: any) => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ field: item.field,
|
|
|
|
|
+ title: item.label,
|
|
|
|
|
+ displayName: item.label,
|
|
|
|
|
+ fieldType: item.fieldType,
|
|
|
|
|
+ isFilter: false,
|
|
|
|
|
+ isSort: false,
|
|
|
|
|
+ fieldLevel: item.fieldLevel,
|
|
|
|
|
+ groupName: item.groupName,
|
|
|
|
|
+ ids: item.ids,
|
|
|
|
|
+ dataType: item.dataType
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ fieldsList.value = [...customizeData, ...fieldsList.value]
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const reportAccessControlRadio = ref('All Users')
|
|
|
|
|
|
|
+const accessControlType = ref('All Users')
|
|
|
const detailRef: Ref<HTMLElement | null> = ref(null)
|
|
const detailRef: Ref<HTMLElement | null> = ref(null)
|
|
|
-watch(reportAccessControlRadio, (newVal) => {
|
|
|
|
|
- if (newVal === 'Specific Roles') {
|
|
|
|
|
- // 等待下一个渲染周期结束后,获取detailRef的高度
|
|
|
|
|
- nextTick(() => {
|
|
|
|
|
- if (detailRef.value) {
|
|
|
|
|
- detailRef.value.scrollIntoView({
|
|
|
|
|
- behavior: 'smooth', // 平滑滚动
|
|
|
|
|
- block: 'start' // 滚动到顶部对齐
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+const specificRoles = ref({
|
|
|
|
|
+ partyId: [],
|
|
|
|
|
+ groupName: []
|
|
|
})
|
|
})
|
|
|
|
|
+const changePartyId = (val: string[]) => {
|
|
|
|
|
+ specificRoles.value.partyId = val
|
|
|
|
|
+}
|
|
|
|
|
+const changeGroupName = (val: string[]) => {
|
|
|
|
|
+ specificRoles.value.groupName = val
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
-const loading = ref(false)
|
|
|
|
|
|
|
+const fieldLoading = ref(false)
|
|
|
const handleRightRemove = () => {}
|
|
const handleRightRemove = () => {}
|
|
|
|
|
+
|
|
|
|
|
+const handleCancel = () => {
|
|
|
|
|
+ router.push('/template-management')
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const handleSave = () => {
|
|
|
|
|
+ const data = {
|
|
|
|
|
+ report_name: infoData.value.reportName,
|
|
|
|
|
+ report_level: infoData.value.reportLevel,
|
|
|
|
|
+ report_description: infoData.value.reportDescription,
|
|
|
|
|
+ access_type: accessControlType.value,
|
|
|
|
|
+ party_ids: specificRoles.value.partyId || [],
|
|
|
|
|
+ group_names: specificRoles.value.groupName || [],
|
|
|
|
|
+ fieldsList: fieldsList.value,
|
|
|
|
|
+ serial_no: route.query.serial_no || ''
|
|
|
|
|
+ }
|
|
|
|
|
+ console.log('Saved Data:', data)
|
|
|
|
|
+ $api.saveNewReportTemplate(data).then((res: any) => {
|
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
|
+ ElMessage.success('Report Template saved successfully!')
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ElMessage.error(res.message || 'Failed to save Report Template.')
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
</script>
|
|
</script>
|
|
|
<template>
|
|
<template>
|
|
|
- <div class="dashboard">
|
|
|
|
|
|
|
+ <div class="dashboard" v-vloading="pageLoading">
|
|
|
<div class="Title">
|
|
<div class="Title">
|
|
|
<span>Create New Report Template</span>
|
|
<span>Create New Report Template</span>
|
|
|
<div class="button-group">
|
|
<div class="button-group">
|
|
|
- <el-button type="default" @click="handleCreate">
|
|
|
|
|
|
|
+ <el-button type="default" @click="handleCancel">
|
|
|
<span class="font_family icon-icon_return_b" style="margin-right: 3px"></span
|
|
<span class="font_family icon-icon_return_b" style="margin-right: 3px"></span
|
|
|
>Cancel</el-button
|
|
>Cancel</el-button
|
|
|
>
|
|
>
|
|
|
- <el-button :disabled="true" class="el-button--main" @click="handleCreate">
|
|
|
|
|
|
|
+ <el-button class="el-button--main" @click="handleSave">
|
|
|
<span class="font_family icon-icon_save_b" style="margin-right: 3px"></span
|
|
<span class="font_family icon-icon_save_b" style="margin-right: 3px"></span
|
|
|
>Save</el-button
|
|
>Save</el-button
|
|
|
>
|
|
>
|
|
@@ -227,7 +295,7 @@ const handleRightRemove = () => {}
|
|
|
</div>
|
|
</div>
|
|
|
<div class="fields-list" v-else>
|
|
<div class="fields-list" v-else>
|
|
|
<VueDraggable
|
|
<VueDraggable
|
|
|
- v-vloading="loading"
|
|
|
|
|
|
|
+ v-vloading="fieldLoading"
|
|
|
v-model="fieldsList"
|
|
v-model="fieldsList"
|
|
|
class="column-list"
|
|
class="column-list"
|
|
|
ghost-class="ghost-column"
|
|
ghost-class="ghost-column"
|
|
@@ -243,10 +311,8 @@ const handleRightRemove = () => {}
|
|
|
style="margin-right: 12px; font-size: 16px"
|
|
style="margin-right: 12px; font-size: 16px"
|
|
|
></span>
|
|
></span>
|
|
|
<div class="label">
|
|
<div class="label">
|
|
|
- <span style="font-weight: 700">[{{ fieldItem.title }}]</span>
|
|
|
|
|
- <span style="margin-left: 8px">{{
|
|
|
|
|
- fieldItem.displayName || fieldItem.title
|
|
|
|
|
- }}</span>
|
|
|
|
|
|
|
+ <span style="font-weight: 700">[{{ fieldItem.field }}]</span>
|
|
|
|
|
+ <span style="margin-left: 8px">{{ fieldItem.title }}</span>
|
|
|
</div>
|
|
</div>
|
|
|
<el-input
|
|
<el-input
|
|
|
class="display-name"
|
|
class="display-name"
|
|
@@ -255,8 +321,16 @@ const handleRightRemove = () => {}
|
|
|
></el-input>
|
|
></el-input>
|
|
|
<div class="actions">
|
|
<div class="actions">
|
|
|
<div>
|
|
<div>
|
|
|
- <el-checkbox v-model="fieldItem.isFilter">Filter</el-checkbox>
|
|
|
|
|
- <el-checkbox v-model="fieldItem.isSort">Sort</el-checkbox>
|
|
|
|
|
|
|
+ <el-checkbox
|
|
|
|
|
+ :disabled="fieldItem.fieldType !== 'System'"
|
|
|
|
|
+ v-model="fieldItem.isFilter"
|
|
|
|
|
+ >Filter</el-checkbox
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-checkbox
|
|
|
|
|
+ :disabled="fieldItem.fieldType !== 'System'"
|
|
|
|
|
+ v-model="fieldItem.isSort"
|
|
|
|
|
+ >Sort</el-checkbox
|
|
|
|
|
+ >
|
|
|
</div>
|
|
</div>
|
|
|
<span
|
|
<span
|
|
|
@click="handleDeleteField(fieldItem.field)"
|
|
@click="handleDeleteField(fieldItem.field)"
|
|
@@ -271,7 +345,7 @@ const handleRightRemove = () => {}
|
|
|
<div class="report-access-control template-box">
|
|
<div class="report-access-control template-box">
|
|
|
<div class="header">Report Access Control</div>
|
|
<div class="header">Report Access Control</div>
|
|
|
<div class="content-box">
|
|
<div class="content-box">
|
|
|
- <el-radio-group class="radio-group" v-model="reportAccessControlRadio">
|
|
|
|
|
|
|
+ <el-radio-group class="radio-group" v-model="accessControlType">
|
|
|
<el-radio class="radio-item" value="All Users">
|
|
<el-radio class="radio-item" value="All Users">
|
|
|
<template #default>
|
|
<template #default>
|
|
|
<div class="radio-content">
|
|
<div class="radio-content">
|
|
@@ -291,7 +365,7 @@ const handleRightRemove = () => {}
|
|
|
</div>
|
|
</div>
|
|
|
<div
|
|
<div
|
|
|
class="extended-filter"
|
|
class="extended-filter"
|
|
|
- v-if="reportAccessControlRadio === 'Specific Roles'"
|
|
|
|
|
|
|
+ v-show="accessControlType === 'Specific Roles'"
|
|
|
ref="detailRef"
|
|
ref="detailRef"
|
|
|
>
|
|
>
|
|
|
<div class="dividing-line"></div>
|
|
<div class="dividing-line"></div>
|
|
@@ -300,14 +374,20 @@ const handleRightRemove = () => {}
|
|
|
<span style="color: var(--color-danger)">*</span>
|
|
<span style="color: var(--color-danger)">*</span>
|
|
|
<span>Party ID</span>
|
|
<span>Party ID</span>
|
|
|
</div>
|
|
</div>
|
|
|
- <partyIDSelect></partyIDSelect>
|
|
|
|
|
|
|
+ <partyIDSelect
|
|
|
|
|
+ @change-data="changePartyId"
|
|
|
|
|
+ :data="specificRoles.partyId"
|
|
|
|
|
+ ></partyIDSelect>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="filter-item">
|
|
<div class="filter-item">
|
|
|
<div class="label">
|
|
<div class="label">
|
|
|
<span style="color: var(--color-danger)">*</span>
|
|
<span style="color: var(--color-danger)">*</span>
|
|
|
<span>Group Name</span>
|
|
<span>Group Name</span>
|
|
|
</div>
|
|
</div>
|
|
|
- <GroupNameSelect></GroupNameSelect>
|
|
|
|
|
|
|
+ <GroupNameSelect
|
|
|
|
|
+ @change-data="changeGroupName"
|
|
|
|
|
+ :data="specificRoles.groupName"
|
|
|
|
|
+ ></GroupNameSelect>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|