修改测试bug 优化页面
This commit is contained in:
@@ -1,107 +1,108 @@
|
||||
<template>
|
||||
<el-dialog width="500px" v-model.trim="dialogVisible" :title="title">
|
||||
|
||||
<el-form :model="form" class="form-one" label-width="auto">
|
||||
<el-form-item label="名称">
|
||||
<el-input maxlength="32" show-word-limit v-model.trim="form.name" placeholder="请输入名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="编码">
|
||||
<el-input maxlength="32" show-word-limit v-model.trim="form.code" placeholder="请输入编码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="类型" v-if="title == '新增'|| title == '编辑'">
|
||||
<el-select v-model.trim="form.type" placeholder="请选择类型">
|
||||
<el-option v-for="item in options" :key="item.value" :label="item.name" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input maxlength="32" show-word-limit v-model.trim="form.remark" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="排序">
|
||||
<el-input maxlength="32" show-word-limit-number v-model.trim="form.sort" :min="0" />
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="submit">确认</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ref, inject } from 'vue'
|
||||
import { reactive } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import { addDictTree, updateStatistical } from '@/api/system-boot/dictTree'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
const emits = defineEmits<{
|
||||
(e: 'over'): void
|
||||
}>()
|
||||
defineOptions({
|
||||
name: 'govern/setting/statisticalType/add'
|
||||
})
|
||||
const tableStore = inject('tableStore') as TableStore
|
||||
const form = reactive({
|
||||
name: '',
|
||||
code: '',
|
||||
remark: '',
|
||||
// type: 2,
|
||||
sort: 100,
|
||||
pid: '',
|
||||
id: ''
|
||||
})
|
||||
const options = ref([
|
||||
{ name: '通用指标', value: 2 },
|
||||
{ name: 'APF模块', value: 3 },
|
||||
{ name: '星型接线', value: 4 },
|
||||
{ name: '角型接线', value: 5 },
|
||||
{ name: 'V型接线', value: 6 },
|
||||
])
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const title = ref('新增菜单')
|
||||
const open = (text: string, data?: anyObj) => {
|
||||
title.value = text
|
||||
for (let key in form) {
|
||||
form[key] = data ? data[key] : ''
|
||||
|
||||
if (key == 'sort') {
|
||||
|
||||
form[key] = data?.sort ? data[key] : 100
|
||||
// console.log("🚀 ~ open ~ form[key]:", form[key])
|
||||
}
|
||||
}
|
||||
dialogVisible.value = true
|
||||
}
|
||||
const submit = async () => {
|
||||
// 非空校验
|
||||
for (let key in form) {
|
||||
if (key != 'pid' && key != 'id' && key != 'sort') {
|
||||
if (!form[key]) {
|
||||
ElMessage.warning('请填写完整信息')
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
if (form.id) {
|
||||
await updateStatistical(form).then(res => {
|
||||
ElMessage.success('编辑成功')
|
||||
})
|
||||
} else {
|
||||
if (!form.pid) {
|
||||
form.pid = tableStore.table.params.pid
|
||||
}
|
||||
await addDictTree(form).then(res => {
|
||||
ElMessage.success('新增成功')
|
||||
})
|
||||
}
|
||||
emits('over')
|
||||
dialogVisible.value = false
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
<template>
|
||||
<el-dialog width="500px" v-model.trim="dialogVisible" :title="title">
|
||||
|
||||
<el-form :model="form" class="form-one" label-width="auto">
|
||||
<el-form-item label="名称">
|
||||
<el-input maxlength="32" show-word-limit v-model.trim="form.name" placeholder="请输入名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="编码">
|
||||
<el-input maxlength="32" show-word-limit v-model.trim="form.code" placeholder="请输入编码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="类型" v-if="title == '新增'|| title == '编辑'">
|
||||
<el-select v-model.trim="form.type" placeholder="请选择类型">
|
||||
<el-option v-for="item in options" :key="item.value" :label="item.name" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input maxlength="32" show-word-limit v-model.trim="form.remark" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="排序">
|
||||
<el-input maxlength="32" show-word-limit-number v-model.trim="form.sort" :min="0" />
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="submit">确认</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ref, inject } from 'vue'
|
||||
import { reactive } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import { addDictTree, updateStatistical } from '@/api/system-boot/dictTree'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
const emits = defineEmits<{
|
||||
(e: 'over'): void
|
||||
}>()
|
||||
defineOptions({
|
||||
name: 'govern/setting/statisticalType/add'
|
||||
})
|
||||
const tableStore = inject('tableStore') as TableStore
|
||||
const form = reactive({
|
||||
name: '',
|
||||
code: '',
|
||||
remark: '',
|
||||
// type: 2,
|
||||
sort: 100,
|
||||
pid: '',
|
||||
id: ''
|
||||
})
|
||||
const options = ref([
|
||||
{ name: '通用指标', value: 2 },
|
||||
{ name: 'APF模块', value: 3 },
|
||||
{ name: '星型接线', value: 4 },
|
||||
{ name: '角型接线', value: 5 },
|
||||
{ name: 'V型接线', value: 6 },
|
||||
{ name: '驾驶舱指标', value: 7 },
|
||||
])
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const title = ref('新增菜单')
|
||||
const open = (text: string, data?: anyObj) => {
|
||||
title.value = text
|
||||
for (let key in form) {
|
||||
form[key] = data ? data[key] : ''
|
||||
|
||||
if (key == 'sort') {
|
||||
|
||||
form[key] = data?.sort ? data[key] : 100
|
||||
// console.log("🚀 ~ open ~ form[key]:", form[key])
|
||||
}
|
||||
}
|
||||
dialogVisible.value = true
|
||||
}
|
||||
const submit = async () => {
|
||||
// 非空校验
|
||||
for (let key in form) {
|
||||
if (key != 'pid' && key != 'id' && key != 'sort') {
|
||||
if (!form[key]) {
|
||||
ElMessage.warning('请填写完整信息')
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
if (form.id) {
|
||||
await updateStatistical(form).then(res => {
|
||||
ElMessage.success('编辑成功')
|
||||
})
|
||||
} else {
|
||||
if (!form.pid) {
|
||||
form.pid = tableStore.table.params.pid
|
||||
}
|
||||
await addDictTree(form).then(res => {
|
||||
ElMessage.success('新增成功')
|
||||
})
|
||||
}
|
||||
emits('over')
|
||||
dialogVisible.value = false
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
||||
@@ -1,154 +1,155 @@
|
||||
<template>
|
||||
<div class='default-main'>
|
||||
<TableHeader :showReset='false'>
|
||||
<template v-slot:operation>
|
||||
<el-button :icon='Plus' type='primary' @click='addMenu'>新增</el-button>
|
||||
</template>
|
||||
</TableHeader>
|
||||
<Table ref='tableRef' />
|
||||
<!-- <el-tabs type="border-card">
|
||||
<el-tab-pane v-for="item in tabPane" :label="item.name">
|
||||
|
||||
</el-tab-pane>
|
||||
</el-tabs> -->
|
||||
|
||||
|
||||
|
||||
|
||||
<PopupBinding ref='bindingRef'></PopupBinding>
|
||||
<PopupAdd ref='addRef' @over='init'></PopupAdd>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang='ts'>
|
||||
import { Plus } from '@element-plus/icons-vue'
|
||||
import { ref, onMounted, provide } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import Table from '@/components/table/index.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import PopupBinding from './binding.vue'
|
||||
import PopupAdd from './add.vue'
|
||||
import { queryByCode, queryCsDictTree } from '@/api/system-boot/dictTree'
|
||||
import { dicDelete } from '@/api/system-boot/dic'
|
||||
|
||||
defineOptions({
|
||||
name: 'govern/setting/statisticalType'
|
||||
})
|
||||
const tabPane = [{ name: '在线监测' }, { name: '治理' }, { name: '测试' }]
|
||||
const tableRef = ref()
|
||||
const bindingRef = ref()
|
||||
const addRef = ref()
|
||||
const options = ref([
|
||||
{ name: '通用指标', value: 2 },
|
||||
{ name: 'APF模块', value: 3 },
|
||||
{ name: '星型接线', value: 4 },
|
||||
{ name: '角型接线', value: 5 },
|
||||
{ name: 'V型接线', value: 6 },
|
||||
])
|
||||
const tableStore = new TableStore({
|
||||
showPage: false,
|
||||
url: '/system-boot/dictTree/query',
|
||||
method: 'POST',
|
||||
paramsPOST: true,
|
||||
// publicHeight: 60,
|
||||
column: [
|
||||
{
|
||||
title: '序号', width: 80, formatter: (row: any) => {
|
||||
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
||||
}
|
||||
},
|
||||
{ title: '统计类型', field: 'name' },
|
||||
{
|
||||
title: '类型', field: 'type',
|
||||
width: 200,
|
||||
formatter: row => {
|
||||
return options.value.filter((item: any) => item.value == row.cellValue)[0]?.name
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
align: 'center',
|
||||
width: '200',
|
||||
render: 'buttons',
|
||||
buttons: [
|
||||
{
|
||||
name: 'edit',
|
||||
title: '绑定指标',
|
||||
type: 'primary',
|
||||
icon: 'el-icon-Connection',
|
||||
render: 'basicButton',
|
||||
click: row => {
|
||||
bindingRef.value.open(row.id)
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'edit',
|
||||
title: '编辑',
|
||||
type: 'primary',
|
||||
icon: 'el-icon-EditPen',
|
||||
render: 'basicButton',
|
||||
click: row => {
|
||||
addRef.value.open('编辑', row)
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'del',
|
||||
title: '删除',
|
||||
type: 'danger',
|
||||
icon: 'el-icon-Delete',
|
||||
render: 'confirmButton',
|
||||
popconfirm: {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
confirmButtonType: 'danger',
|
||||
title: '确定删除该菜单吗?'
|
||||
},
|
||||
click: row => {
|
||||
dicDelete(row.id).then(() => {
|
||||
init()
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
loadCallback: () => {
|
||||
// // 过滤数组中type等于1的数据,children下钻
|
||||
// const filterData = (arr: any[]) => {
|
||||
// return arr.filter((item: any) => {
|
||||
// if (item.children.length) {
|
||||
// item.children = filterData(item.children)
|
||||
// }
|
||||
// return item.type != 1
|
||||
// })
|
||||
// }
|
||||
// tableStore.table.data = filterData(tableStore.table.data)
|
||||
}
|
||||
})
|
||||
provide('tableStore', tableStore)
|
||||
const init = () => {
|
||||
tableStore.table.loading = true
|
||||
queryByCode('Statistical_Type').then(res => {
|
||||
tableStore.table.params.pid = res.data.id
|
||||
queryCsDictTree(res.data.id).then(res => {
|
||||
tableStore.table.data = res.data
|
||||
tableStore.table.loading = false
|
||||
})
|
||||
})
|
||||
}
|
||||
onMounted(() => {
|
||||
tableStore.table.ref = tableRef.value
|
||||
init()
|
||||
})
|
||||
|
||||
const addMenu = () => {
|
||||
// console.log(bindingRef)
|
||||
addRef.value.open('新增', {
|
||||
sort: tableStore.table.data.length ? tableStore.table.data[tableStore.table.data.length - 1].sort + 1 : 1,
|
||||
code: '',
|
||||
pid: '',
|
||||
id: '',
|
||||
remark: '',
|
||||
name: ''
|
||||
})
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div class="default-main">
|
||||
<TableHeader :showReset="false">
|
||||
<template v-slot:operation>
|
||||
<el-button :icon="Plus" type="primary" @click="addMenu">新增</el-button>
|
||||
</template>
|
||||
</TableHeader>
|
||||
<Table ref="tableRef" />
|
||||
<!-- <el-tabs type="border-card">
|
||||
<el-tab-pane v-for="item in tabPane" :label="item.name">
|
||||
|
||||
</el-tab-pane>
|
||||
</el-tabs> -->
|
||||
|
||||
<PopupBinding ref="bindingRef"></PopupBinding>
|
||||
<PopupAdd ref="addRef" @over="init"></PopupAdd>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { Plus } from '@element-plus/icons-vue'
|
||||
import { ref, onMounted, provide } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import Table from '@/components/table/index.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import PopupBinding from './binding.vue'
|
||||
import PopupAdd from './add.vue'
|
||||
import { queryByCode, queryCsDictTree } from '@/api/system-boot/dictTree'
|
||||
import { dicDelete } from '@/api/system-boot/dic'
|
||||
|
||||
defineOptions({
|
||||
name: 'govern/setting/statisticalType'
|
||||
})
|
||||
const tabPane = [{ name: '在线监测' }, { name: '治理' }, { name: '测试' }]
|
||||
const tableRef = ref()
|
||||
const bindingRef = ref()
|
||||
const addRef = ref()
|
||||
const options = ref([
|
||||
{ name: '通用指标', value: 2 },
|
||||
{ name: 'APF模块', value: 3 },
|
||||
{ name: '星型接线', value: 4 },
|
||||
{ name: '角型接线', value: 5 },
|
||||
{ name: 'V型接线', value: 6 },
|
||||
{ name: '驾驶舱指标', value: 7 }
|
||||
])
|
||||
const tableStore = new TableStore({
|
||||
showPage: false,
|
||||
url: '/system-boot/dictTree/query',
|
||||
method: 'POST',
|
||||
paramsPOST: true,
|
||||
// publicHeight: 60,
|
||||
column: [
|
||||
{
|
||||
title: '序号',
|
||||
width: 80,
|
||||
formatter: (row: any) => {
|
||||
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
||||
}
|
||||
},
|
||||
{ title: '统计类型', field: 'name' },
|
||||
{
|
||||
title: '类型',
|
||||
field: 'type',
|
||||
width: 200,
|
||||
formatter: row => {
|
||||
return options.value.filter((item: any) => item.value == row.cellValue)[0]?.name
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
align: 'center',
|
||||
width: '200',
|
||||
render: 'buttons',
|
||||
buttons: [
|
||||
{
|
||||
name: 'edit',
|
||||
title: '绑定指标',
|
||||
type: 'primary',
|
||||
icon: 'el-icon-Connection',
|
||||
render: 'basicButton',
|
||||
click: row => {
|
||||
bindingRef.value.open(row.id)
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'edit',
|
||||
title: '编辑',
|
||||
type: 'primary',
|
||||
icon: 'el-icon-EditPen',
|
||||
render: 'basicButton',
|
||||
click: row => {
|
||||
addRef.value.open('编辑', row)
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'del',
|
||||
title: '删除',
|
||||
type: 'danger',
|
||||
icon: 'el-icon-Delete',
|
||||
render: 'confirmButton',
|
||||
popconfirm: {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
confirmButtonType: 'danger',
|
||||
title: '确定删除该菜单吗?'
|
||||
},
|
||||
click: row => {
|
||||
dicDelete(row.id).then(() => {
|
||||
init()
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
loadCallback: () => {
|
||||
// // 过滤数组中type等于1的数据,children下钻
|
||||
// const filterData = (arr: any[]) => {
|
||||
// return arr.filter((item: any) => {
|
||||
// if (item.children.length) {
|
||||
// item.children = filterData(item.children)
|
||||
// }
|
||||
// return item.type != 1
|
||||
// })
|
||||
// }
|
||||
// tableStore.table.data = filterData(tableStore.table.data)
|
||||
}
|
||||
})
|
||||
provide('tableStore', tableStore)
|
||||
const init = () => {
|
||||
tableStore.table.loading = true
|
||||
queryByCode('Statistical_Type').then(res => {
|
||||
tableStore.table.params.pid = res.data.id
|
||||
queryCsDictTree(res.data.id).then(res => {
|
||||
tableStore.table.data = res.data
|
||||
tableStore.table.loading = false
|
||||
})
|
||||
})
|
||||
}
|
||||
onMounted(() => {
|
||||
tableStore.table.ref = tableRef.value
|
||||
init()
|
||||
})
|
||||
|
||||
const addMenu = () => {
|
||||
// console.log(bindingRef)
|
||||
addRef.value.open('新增', {
|
||||
sort: tableStore.table.data.length ? tableStore.table.data[tableStore.table.data.length - 1].sort + 1 : 1,
|
||||
code: '',
|
||||
pid: '',
|
||||
id: '',
|
||||
remark: '',
|
||||
name: ''
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user