|
@@ -1,26 +1,336 @@
|
|
|
<script setup lang="ts">
|
|
|
-import HeaderCard from '@/components/dataAnalysis/HeaderCard.vue'
|
|
|
+import Form from '@/components/form/Form.vue'
|
|
|
+import Table from '@/components/Table.vue'
|
|
|
+import Dialog from '@/components/common/Dialog.vue'
|
|
|
+import type { ReqConfig } from '@/types/dataAnalysis'
|
|
|
+import { type FormField, FormFieldType } from '@/types/form'
|
|
|
+import type { FormRules } from 'element-plus'
|
|
|
+import type { FormConfig } from '@/types/form'
|
|
|
+import {
|
|
|
+ type TablePaginationSetting,
|
|
|
+ type TableFieldInfo,
|
|
|
+ FieldSpecialEffectType
|
|
|
+} from '@/types/table'
|
|
|
+import type { DialogConfig } from '@/types/dialog'
|
|
|
import { reactive, onMounted, ref } from 'vue'
|
|
|
-import { initLoadResouce } from '@/utils/resource'
|
|
|
-import { copyText } from '@/utils/common'
|
|
|
import { useRoute } from 'vue-router'
|
|
|
+import { useRequest } from '@/hooks/useRequest'
|
|
|
+
|
|
|
+const { AllApi } = useRequest()
|
|
|
+
|
|
|
+const eventEditState = ref(false)
|
|
|
+
|
|
|
+// 属性对话框
|
|
|
+const attrDialog = ref()
|
|
|
+
|
|
|
+// 表单规则字段
|
|
|
+const ruleForm = reactive({
|
|
|
+ eventID: '',
|
|
|
+ eventDisplayName: '',
|
|
|
+ useageStatus: '',
|
|
|
+ triggerTimingDesc: ''
|
|
|
+})
|
|
|
+
|
|
|
+// 表单规则
|
|
|
+const rules = reactive<FormRules<typeof ruleForm>>({
|
|
|
+ eventID: [
|
|
|
+ { required: true, message: '事件ID是必填项', trigger: 'blur' },
|
|
|
+ {
|
|
|
+ min: 1,
|
|
|
+ max: 20,
|
|
|
+ message: '事件ID长度必须在1到20个字符之间',
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ eventDisplayName: [
|
|
|
+ { required: true, message: '事件显示名是必填项', trigger: 'blur' },
|
|
|
+ {
|
|
|
+ min: 5,
|
|
|
+ max: 10,
|
|
|
+ message: '事件显示名长度必须在5到10个字符之间',
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ useageStatus: [{ required: true, message: '使用状态是必填项', trigger: 'change' }],
|
|
|
+ triggerTimingDesc: [
|
|
|
+ {
|
|
|
+ min: 1,
|
|
|
+ max: 255,
|
|
|
+ message: '描述长度必须在1到255个字符之间',
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
+ ]
|
|
|
+})
|
|
|
+
|
|
|
+// 表单字段信息
|
|
|
+const FormFields: Array<FormField> = [
|
|
|
+ {
|
|
|
+ name: 'eventID',
|
|
|
+ cnName: '事件ID',
|
|
|
+ type: FormFieldType.INPUT
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'eventDisplayName',
|
|
|
+ cnName: '事件显示',
|
|
|
+ type: FormFieldType.INPUT
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'useageStatus',
|
|
|
+ cnName: '使用状态',
|
|
|
+ type: FormFieldType.SELECT,
|
|
|
+ otherOptions: {
|
|
|
+ placeholder: '请选择状态',
|
|
|
+ options: [
|
|
|
+ {
|
|
|
+ name: 'disabled',
|
|
|
+ label: '已禁用',
|
|
|
+ value: false
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'abled',
|
|
|
+ label: '已启用',
|
|
|
+ value: true
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'triggerTimingDesc',
|
|
|
+ cnName: '触发时机描述',
|
|
|
+ type: FormFieldType.RICHTEXT,
|
|
|
+ otherOptions: {
|
|
|
+ placeholder: '请输入描述'
|
|
|
+ }
|
|
|
+ }
|
|
|
+]
|
|
|
+
|
|
|
+// 表单请求参数
|
|
|
+const formReq = reactive<ReqConfig>({
|
|
|
+ url: AllApi.mockEvent,
|
|
|
+ otherOptions: {}
|
|
|
+})
|
|
|
+
|
|
|
+// 表单设置
|
|
|
+const formConfig = reactive<FormConfig>({
|
|
|
+ reqConfig: formReq,
|
|
|
+ fieldsInfo: FormFields,
|
|
|
+ rules
|
|
|
+})
|
|
|
+
|
|
|
+// 表格分页设置
|
|
|
+const pageConfig = reactive<TablePaginationSetting>({
|
|
|
+ limit: 20,
|
|
|
+ currentPage: 1,
|
|
|
+ total: 0,
|
|
|
+ pagesizeList: [20, 30]
|
|
|
+})
|
|
|
+
|
|
|
+// 表格字段信息
|
|
|
+const tableFieldConfig = reactive<Array<TableFieldInfo>>([
|
|
|
+ {
|
|
|
+ name: 'attrID',
|
|
|
+ cnName: '参数ID',
|
|
|
+ isShow: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'useStatus',
|
|
|
+ cnName: '使用状态',
|
|
|
+ isShow: true,
|
|
|
+ specialEffect: {
|
|
|
+ othnerInfo: {
|
|
|
+ text: ['已使用', '已弃用']
|
|
|
+ },
|
|
|
+ type: FieldSpecialEffectType.DROPDOWN
|
|
|
+ }
|
|
|
+ }
|
|
|
+])
|
|
|
+
|
|
|
+// 表格请求配置
|
|
|
+const tableReqConfig = reactive<ReqConfig>({
|
|
|
+ url: AllApi.mockEvent,
|
|
|
+ otherOptions: {
|
|
|
+ eventID: ''
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+// 对话框请求参数
|
|
|
+const dialogReqConfig = reactive<ReqConfig>({
|
|
|
+ url: AllApi.mockEvent,
|
|
|
+ otherOptions: {}
|
|
|
+})
|
|
|
+
|
|
|
+// 对话框表单规则字段
|
|
|
+const dilogRuleForm = reactive({
|
|
|
+ attrID: '',
|
|
|
+ useStatus: false
|
|
|
+})
|
|
|
+
|
|
|
+// 表单规则
|
|
|
+const dialogRules = reactive<FormRules<typeof dilogRuleForm>>({
|
|
|
+ attrID: [
|
|
|
+ { required: true, message: '属性ID是必填项', trigger: 'blur' },
|
|
|
+ {
|
|
|
+ min: 1,
|
|
|
+ max: 20,
|
|
|
+ message: '属性ID长度必须在1到20个字符之间',
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ useStatus: [{ required: true, message: '使用状态是必填项', trigger: 'change' }]
|
|
|
+})
|
|
|
+
|
|
|
+// 表单字段信息
|
|
|
+const dialogFormFields: Array<FormField> = [
|
|
|
+ {
|
|
|
+ name: 'attrID',
|
|
|
+ cnName: '属性ID',
|
|
|
+ type: FormFieldType.INPUT
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'useStatus',
|
|
|
+ cnName: '使用状态',
|
|
|
+ type: FormFieldType.SELECT,
|
|
|
+ otherOptions: {
|
|
|
+ placeholder: '请选择状态',
|
|
|
+ options: [
|
|
|
+ {
|
|
|
+ name: 'disabled',
|
|
|
+ label: '已禁用',
|
|
|
+ value: false
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'abled',
|
|
|
+ label: '已启用',
|
|
|
+ value: true
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+]
|
|
|
+
|
|
|
+// 对话框设置
|
|
|
+const dialogConfig = reactive<DialogConfig>({
|
|
|
+ title: '自定义属性',
|
|
|
+ reqConfig: dialogReqConfig,
|
|
|
+ rules: dialogRules,
|
|
|
+ fieldsInfo: dialogFormFields
|
|
|
+})
|
|
|
+
|
|
|
+// 新增属性
|
|
|
+const addNewAttr = () => {
|
|
|
+ attrDialog.value.changeVisable()
|
|
|
+}
|
|
|
+
|
|
|
+// 改变编辑状态
|
|
|
+const changeEditState = (state: boolean) => {
|
|
|
+ eventEditState.value = state
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @description: 取消编辑
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+const cancelEdit = () => {
|
|
|
+ changeEditState(false)
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @description: 保存编辑
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+const saveEdit = () => {
|
|
|
+ changeEditState(false)
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @description: 开始编辑
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+const startEdit = () => {
|
|
|
+ changeEditState(true)
|
|
|
+}
|
|
|
|
|
|
onMounted(() => {
|
|
|
- const route = useRoute()
|
|
|
- let query = route.query
|
|
|
+ const routes = useRoute()
|
|
|
+ let query = routes.query
|
|
|
+
|
|
|
console.log(query)
|
|
|
})
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
- <div class="eventDetail">okok</div>
|
|
|
+ <div class="eventDetail">
|
|
|
+ <div class="header">
|
|
|
+ <span>基本信息</span>
|
|
|
+ <div class="headerBtn">
|
|
|
+ <span v-if="eventEditState">
|
|
|
+ <el-button class="handleBtn" @click="cancelEdit" color="#626aef" plain>取消</el-button>
|
|
|
+ <el-button class="handleBtn" @click="saveEdit" color="#626aef">保存</el-button>
|
|
|
+ </span>
|
|
|
+ <span v-else>
|
|
|
+ <el-button class="handleBtn" @click="startEdit" color="#626aef">编辑</el-button>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="eventForm">
|
|
|
+ <div class="formBox">
|
|
|
+ <Form :inline="true" :config="formConfig"></Form>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="attrList">
|
|
|
+ <div class="header">
|
|
|
+ <span>属性列表</span>
|
|
|
+ </div>
|
|
|
+ <div class="list">
|
|
|
+ <Table
|
|
|
+ :need-left-tools="true"
|
|
|
+ :pagination-config="pageConfig"
|
|
|
+ :table-fields-info="tableFieldConfig"
|
|
|
+ :request-config="tableReqConfig"
|
|
|
+ @add-new-item="addNewAttr"
|
|
|
+ ></Table>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="addAttrDialo">
|
|
|
+ <Dialog ref="attrDialog" :config="dialogConfig"></Dialog>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<style scoped>
|
|
|
-.eventDetail {
|
|
|
+.eventDetail,
|
|
|
+.eventForm,
|
|
|
+.attrList {
|
|
|
width: 98%;
|
|
|
- margin: 1% auto;
|
|
|
+ margin: 0 auto;
|
|
|
+ background-color: white;
|
|
|
+ box-sizing: border-box;
|
|
|
+}
|
|
|
|
|
|
+.header {
|
|
|
+ width: 100%;
|
|
|
box-sizing: border-box;
|
|
|
+ background-color: white;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ height: 56px;
|
|
|
+ box-shadow: inset 0 -1px 0 0 rgba(23, 35, 61, 0.1);
|
|
|
+ font-weight: 600;
|
|
|
+ font-size: 14px;
|
|
|
+ color: #17233d;
|
|
|
+ padding: 12px 24px;
|
|
|
+}
|
|
|
+
|
|
|
+.headerBtn {
|
|
|
+ box-sizing: border-box;
|
|
|
+}
|
|
|
+
|
|
|
+.handleBtn {
|
|
|
+ margin-right: 15px;
|
|
|
+}
|
|
|
+
|
|
|
+.eventForm {
|
|
|
+ padding: 24px;
|
|
|
}
|
|
|
</style>
|