修改测试bug 优化页面
This commit is contained in:
@@ -1,214 +1,229 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
draggable
|
||||
:title="title"
|
||||
v-model.trim="dialogVisible"
|
||||
width="500px"
|
||||
:before-close="handleClose"
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form ref="formRef" :rules="rules" :model="form" label-width="90px" class="form">
|
||||
<el-form-item label="项目名称:" prop="name">
|
||||
<el-input
|
||||
maxlength="32"
|
||||
show-word-limit
|
||||
v-model.trim="form.name"
|
||||
placeholder="请输入项目名称"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="工程项目:" class="top" prop="projectIds">
|
||||
<el-tree-select
|
||||
v-model.trim="form.projectIds"
|
||||
default-expand-all
|
||||
show-checkbox
|
||||
node-key="id"
|
||||
:props="defaultProps"
|
||||
multiple
|
||||
:data="Engineering"
|
||||
collapse-tags
|
||||
style="width: 100%"
|
||||
/>
|
||||
<!-- <el-cascader v-model.trim="form.projectIds" :options="Engineering" :props="defaultProps"
|
||||
:show-all-levels="false" collapse-tags collapse-tags-tooltip clearable style="width: 100%;"/> -->
|
||||
</el-form-item>
|
||||
<el-form-item label="项目排序:" prop="orderBy">
|
||||
<el-input
|
||||
maxlength="32"
|
||||
show-word-limit-number
|
||||
v-model.trim="form.orderBy"
|
||||
:min="0"
|
||||
:step="1"
|
||||
step-strictly
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="备注:" class="top">
|
||||
<el-input
|
||||
maxlength="300"
|
||||
show-word-limit
|
||||
type="textarea"
|
||||
:rows="2"
|
||||
placeholder="请输入内容"
|
||||
v-model.trim="form.remark"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="addFn">确定</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from 'vue'
|
||||
import { deviceTree, add, audit, getztProjectTree } from '@/api/cs-harmonic-boot/mxgraph'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
const title = ref('')
|
||||
const formRef = ref()
|
||||
const Engineering = ref([])
|
||||
const dialogVisible = ref(false)
|
||||
const emit = defineEmits(['submit'])
|
||||
const defaultProps = {
|
||||
children: 'children',
|
||||
value: 'id',
|
||||
label: 'name',
|
||||
multiple: true,
|
||||
expandTrigger: 'hover' as const
|
||||
}
|
||||
const form: any = reactive({
|
||||
name: '',
|
||||
projectIds: [],
|
||||
orderBy: '100',
|
||||
remark: ''
|
||||
})
|
||||
const rules = {
|
||||
name: [{ required: true, message: '请输入项目名称', trigger: 'blur' }],
|
||||
projectIds: [{ required: true, message: '请选择工程项目', trigger: 'change' }],
|
||||
orderBy: [{ required: true, message: '请输入排序', trigger: 'blur' }]
|
||||
}
|
||||
const addFn = () => {
|
||||
console.log('🚀 ~ add ~ form:', form)
|
||||
|
||||
formRef.value.validate((valid: boolean) => {
|
||||
if (valid) {
|
||||
if (title.value == '新增项目') {
|
||||
add(form).then((res: any) => {
|
||||
ElMessage.success('新增项目成功!')
|
||||
dialogVisible.value = false
|
||||
emit('submit')
|
||||
})
|
||||
} else {
|
||||
audit(form).then((res: any) => {
|
||||
ElMessage.success('修改项目成功!')
|
||||
dialogVisible.value = false
|
||||
emit('submit')
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
const handleTree = (data: any) => {
|
||||
if (data && data.length != 0) {
|
||||
data.map((item: any) => {
|
||||
if (item.level != 2) {
|
||||
item.disabled = true
|
||||
} else {
|
||||
item.disabled = false
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
const open = ref((row: any) => {
|
||||
formRef.value?.resetFields()
|
||||
// deviceTree({}).then((res: any) => {
|
||||
// res.data.forEach((item: any) => {
|
||||
// item.children.forEach((child: any) => {
|
||||
// child.children = []
|
||||
// })
|
||||
// })
|
||||
// Engineering.value = res.data
|
||||
// })
|
||||
getztProjectTree().then((res: any) => {
|
||||
res.data.forEach((item: any, index: any) => {
|
||||
if (!item.children || item.children.length == 0) {
|
||||
res.data.splice(index, 1)
|
||||
return
|
||||
}
|
||||
item.newList = []
|
||||
item.children.forEach((vv: any, vvs: any) => {
|
||||
vv.children.forEach((ss: any, ssIndex: any) => {
|
||||
if (ss.level == 1) {
|
||||
item.newList.push(ss)
|
||||
}
|
||||
})
|
||||
})
|
||||
item.disabled = true
|
||||
if (item.children && item.children.length != 0) {
|
||||
item.children.forEach((vv: any, vvs: any) => {
|
||||
vv.disabled = true
|
||||
if (item.name.includes('治理')) {
|
||||
if (vv.level === 0) {
|
||||
vv.disabled = true
|
||||
} else {
|
||||
vv.disabled = false
|
||||
}
|
||||
// item.children = item.newList
|
||||
}
|
||||
if (item.name.includes('便携式')) {
|
||||
if (vv.level === 1) {
|
||||
vv.disabled = false
|
||||
} else {
|
||||
vv.disabled = true
|
||||
}
|
||||
}
|
||||
if (vv.children && vv.children.length != 0) {
|
||||
vv.children.forEach((kk: any, kks: any) => {
|
||||
if (item.name.includes('便携式') && kk.level === 2) {
|
||||
kk.disabled = true
|
||||
vv.children.splice(kks, 1)
|
||||
}
|
||||
// else {
|
||||
// kk.disabled = true
|
||||
// }
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
Engineering.value = removeData(res.data)
|
||||
})
|
||||
title.value = row.title
|
||||
dialogVisible.value = true
|
||||
if (row.title == '新增项目') {
|
||||
form.name = ''
|
||||
form.projectIds = []
|
||||
form.orderBy = '100'
|
||||
form.remark = ''
|
||||
} else {
|
||||
for (let key in form) {
|
||||
form[key] = row.row[key] || ''
|
||||
}
|
||||
form.id = row.row.id
|
||||
}
|
||||
})
|
||||
const removeData = arr => {
|
||||
return arr
|
||||
.map(item => {
|
||||
if (item.children) {
|
||||
item.children = removeData(item.children)
|
||||
}
|
||||
return item.level <= 1 ? item : {}
|
||||
})
|
||||
.filter(item => Object.keys(item).length > 0)
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
dialogVisible.value = false
|
||||
}
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
<template>
|
||||
<el-dialog
|
||||
draggable
|
||||
:title="title"
|
||||
v-model.trim="dialogVisible"
|
||||
width="500px"
|
||||
:before-close="handleClose"
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form ref="formRef" :rules="rules" :model="form" label-width="90px" class="form-one">
|
||||
<el-form-item label="项目名称:" prop="name">
|
||||
<el-input
|
||||
maxlength="32"
|
||||
show-word-limit
|
||||
v-model.trim="form.name"
|
||||
placeholder="请输入项目名称"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否全局:" class="top" v-if="hasAdmin">
|
||||
<el-switch
|
||||
v-model="form.scope"
|
||||
inline-prompt
|
||||
width="60px"
|
||||
:active-value="1"
|
||||
:inactive-value="0"
|
||||
active-text="是 "
|
||||
inactive-text="否 "
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="工程项目:" class="top" prop="projectIds" v-if="!hasAdmin || form.scope == 0">
|
||||
<el-tree-select
|
||||
v-model.trim="form.projectIds"
|
||||
default-expand-all
|
||||
show-checkbox
|
||||
node-key="id"
|
||||
:props="defaultProps"
|
||||
multiple
|
||||
:data="Engineering"
|
||||
collapse-tags
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="项目排序:" prop="orderBy">
|
||||
<el-input
|
||||
maxlength="32"
|
||||
show-word-limit-number
|
||||
v-model.trim="form.orderBy"
|
||||
:min="0"
|
||||
:step="1"
|
||||
step-strictly
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="备注:" class="top">
|
||||
<el-input
|
||||
maxlength="300"
|
||||
show-word-limit
|
||||
type="textarea"
|
||||
:rows="2"
|
||||
placeholder="请输入内容"
|
||||
v-model.trim="form.remark"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="addFn">确定</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from 'vue'
|
||||
import { deviceTree, add, audit, getztProjectTree } from '@/api/cs-harmonic-boot/mxgraph'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { useAdminInfo } from '@/stores/adminInfo'
|
||||
const adminInfo = useAdminInfo()
|
||||
const hasAdmin = adminInfo.roleCode.some(item => item.includes('operation_manager')|| item.includes('root'))
|
||||
const title = ref('')
|
||||
const formRef = ref()
|
||||
const Engineering = ref([])
|
||||
const dialogVisible = ref(false)
|
||||
const emit = defineEmits(['submit'])
|
||||
const defaultProps = {
|
||||
children: 'children',
|
||||
value: 'id',
|
||||
label: 'name',
|
||||
multiple: true,
|
||||
expandTrigger: 'hover' as const
|
||||
}
|
||||
const form: any = reactive({
|
||||
name: '',
|
||||
projectIds: [],
|
||||
scope: 1,
|
||||
orderBy: '100',
|
||||
remark: ''
|
||||
})
|
||||
const rules = {
|
||||
name: [{ required: true, message: '请输入项目名称', trigger: 'blur' }],
|
||||
projectIds: [{ required: true, message: '请选择工程项目', trigger: 'change' }],
|
||||
orderBy: [{ required: true, message: '请输入排序', trigger: 'blur' }]
|
||||
}
|
||||
const addFn = () => {
|
||||
console.log('🚀 ~ add ~ form:', form)
|
||||
|
||||
formRef.value.validate((valid: boolean) => {
|
||||
if (valid) {
|
||||
if (title.value == '新增项目') {
|
||||
add({ ...form, projectIds: form.scope == 1 ? ['WIRELESS_PROJECT_ID'] : form.projectIds }).then(
|
||||
(res: any) => {
|
||||
ElMessage.success('新增项目成功!')
|
||||
dialogVisible.value = false
|
||||
emit('submit')
|
||||
}
|
||||
)
|
||||
} else {
|
||||
audit({ ...form, projectIds: form.scope == 1 ? ['WIRELESS_PROJECT_ID'] : form.projectIds }).then((res: any) => {
|
||||
ElMessage.success('修改项目成功!')
|
||||
dialogVisible.value = false
|
||||
emit('submit')
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
const handleTree = (data: any) => {
|
||||
if (data && data.length != 0) {
|
||||
data.map((item: any) => {
|
||||
if (item.level != 2) {
|
||||
item.disabled = true
|
||||
} else {
|
||||
item.disabled = false
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
const open = ref((row: any) => {
|
||||
formRef.value?.resetFields()
|
||||
// deviceTree({}).then((res: any) => {
|
||||
// res.data.forEach((item: any) => {
|
||||
// item.children.forEach((child: any) => {
|
||||
// child.children = []
|
||||
// })
|
||||
// })
|
||||
// Engineering.value = res.data
|
||||
// })
|
||||
getztProjectTree().then((res: any) => {
|
||||
res.data.forEach((item: any, index: any) => {
|
||||
if (!item.children || item.children.length == 0) {
|
||||
res.data.splice(index, 1)
|
||||
return
|
||||
}
|
||||
item.newList = []
|
||||
item.children.forEach((vv: any, vvs: any) => {
|
||||
vv.children.forEach((ss: any, ssIndex: any) => {
|
||||
if (ss.level == 1) {
|
||||
item.newList.push(ss)
|
||||
}
|
||||
})
|
||||
})
|
||||
item.disabled = true
|
||||
if (item.children && item.children.length != 0) {
|
||||
item.children.forEach((vv: any, vvs: any) => {
|
||||
vv.disabled = true
|
||||
if (item.name.includes('治理')) {
|
||||
if (vv.level === 0) {
|
||||
vv.disabled = true
|
||||
} else {
|
||||
vv.disabled = false
|
||||
}
|
||||
// item.children = item.newList
|
||||
}
|
||||
if (item.name.includes('便携式')) {
|
||||
if (vv.level === 1) {
|
||||
vv.disabled = false
|
||||
} else {
|
||||
vv.disabled = true
|
||||
}
|
||||
}
|
||||
if (vv.children && vv.children.length != 0) {
|
||||
vv.children.forEach((kk: any, kks: any) => {
|
||||
if (item.name.includes('便携式') && kk.level === 2) {
|
||||
kk.disabled = true
|
||||
vv.children.splice(kks, 1)
|
||||
}
|
||||
// else {
|
||||
// kk.disabled = true
|
||||
// }
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
Engineering.value = removeData(res.data)
|
||||
})
|
||||
title.value = row.title
|
||||
dialogVisible.value = true
|
||||
if (row.title == '新增项目') {
|
||||
form.name = ''
|
||||
form.projectIds = []
|
||||
form.orderBy = '100'
|
||||
form.remark = ''
|
||||
} else {
|
||||
for (let key in form) {
|
||||
form[key] = row.row[key] || ''
|
||||
}
|
||||
form.id = row.row.id
|
||||
}
|
||||
})
|
||||
const removeData = arr => {
|
||||
return arr
|
||||
.map(item => {
|
||||
if (item.children) {
|
||||
item.children = removeData(item.children)
|
||||
}
|
||||
return item.level <= 1 ? item : {}
|
||||
})
|
||||
.filter(item => Object.keys(item).length > 0)
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
dialogVisible.value = false
|
||||
}
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<span style="display: flex; align-items: center">
|
||||
{{ item.name }}
|
||||
|
||||
<el-tooltip class="item" effect="dark" content="修改项目" placement="top">
|
||||
<el-tooltip class="item" effect="dark" content="修改项目" placement="top" v-if="hasAdmin || item.createBy == adminInfo.id">
|
||||
<Edit
|
||||
style="margin-left: 5px; width: 16px"
|
||||
class="xiaoshou color"
|
||||
@@ -36,28 +36,43 @@
|
||||
/>
|
||||
</el-tooltip>
|
||||
</span>
|
||||
<div style="display: flex; justify-content: end">
|
||||
<el-button
|
||||
class="color"
|
||||
icon="el-icon-Share"
|
||||
style="padding: 3px 0"
|
||||
type="text"
|
||||
@click="Aclick(item)"
|
||||
<div style="height: 32px">
|
||||
<div
|
||||
style="display: flex; justify-content: end"
|
||||
v-if="hasAdmin || item.createBy == adminInfo.id"
|
||||
>
|
||||
设计
|
||||
</el-button>
|
||||
<!-- <el-button icon="el-icon-share" style="padding: 3px 0; color: green"
|
||||
<!-- <el-button
|
||||
class="color"
|
||||
icon="el-icon-Promotion"
|
||||
style="padding: 3px 0"
|
||||
type="text"
|
||||
v-if="bindId != item.id"
|
||||
@click="activate(item)"
|
||||
>
|
||||
绑定
|
||||
</el-button> -->
|
||||
<el-button
|
||||
class="color"
|
||||
icon="el-icon-Share"
|
||||
style="padding: 3px 0"
|
||||
type="text"
|
||||
@click="Aclick(item)"
|
||||
>
|
||||
设计
|
||||
</el-button>
|
||||
<!-- <el-button icon="el-icon-share" style="padding: 3px 0; color: green"
|
||||
type="text" @click="shejid(item)">设计</el-button> -->
|
||||
<!-- <el-button icon="el-icon-edit" style="padding: 3px 0; color: blue" type="text"
|
||||
<!-- <el-button icon="el-icon-edit" style="padding: 3px 0; color: blue" type="text"
|
||||
@click="shejid(item)">编辑</el-button> -->
|
||||
<el-button
|
||||
icon="el-icon-Delete"
|
||||
style="padding: 3px 0; color: red"
|
||||
type="text"
|
||||
@click="deleted(item)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
<el-button
|
||||
icon="el-icon-Delete"
|
||||
style="padding: 3px 0; color: red"
|
||||
type="text"
|
||||
@click="deleted(item)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<img
|
||||
@@ -95,15 +110,18 @@ import TableStore from '@/utils/tableStore'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { deleteTopoTemplate, uploadTopo } from '@/api/cs-device-boot/topologyTemplate'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { audit, add } from '@/api/cs-harmonic-boot/mxgraph'
|
||||
import { audit, add, savePageIdWithUser, getByUserId } from '@/api/cs-harmonic-boot/mxgraph'
|
||||
import { Edit } from '@element-plus/icons-vue'
|
||||
import popup from './components/popup.vue'
|
||||
|
||||
import { useAdminInfo } from '@/stores/adminInfo'
|
||||
const VITE_FLAG = import.meta.env.VITE_NAME == 'ypt'
|
||||
|
||||
defineOptions({
|
||||
name: 'mxgraph/graph-list'
|
||||
})
|
||||
const adminInfo = useAdminInfo()
|
||||
|
||||
const hasAdmin = adminInfo.roleCode.some(item => item.includes('operation_manager')|| item.includes('root'))
|
||||
const tableRef = ref()
|
||||
const popupRef = ref()
|
||||
let DOMIN = window.location.origin
|
||||
@@ -120,8 +138,12 @@ const tableStore = new TableStore({
|
||||
})
|
||||
provide('tableStore', tableStore)
|
||||
tableStore.table.params.searchValue = ''
|
||||
tableStore.table.params.currentUserId = adminInfo.id
|
||||
// let aa=['operation_manager',]
|
||||
tableStore.table.params.roleCode = adminInfo.roleCode.join(',')
|
||||
onMounted(() => {
|
||||
tableStore.table.ref = tableRef.value
|
||||
getBindId()
|
||||
tableStore.index()
|
||||
tableStore.table.loading = false
|
||||
})
|
||||
@@ -131,6 +153,31 @@ const onSubmitadd = () => {
|
||||
title: '新增项目'
|
||||
})
|
||||
}
|
||||
const bindId = ref('')
|
||||
const activate = (e: any) => {
|
||||
ElMessageBox.confirm('是否绑定?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
.then(() => {
|
||||
savePageIdWithUser({ pageId: e.id, userId: adminInfo.id }).then(res => {
|
||||
if (res.code == 'A0000') {
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: '操作成功'
|
||||
})
|
||||
bindId.value = e.id
|
||||
}
|
||||
})
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
const getBindId = () => {
|
||||
getByUserId({ userId: adminInfo.id }).then(res => {
|
||||
bindId.value = res.data.pageId
|
||||
})
|
||||
}
|
||||
const querdata = (e: any) => {}
|
||||
const editd = (e: any) => {
|
||||
popupRef.value.open({
|
||||
@@ -142,7 +189,7 @@ const editd = (e: any) => {
|
||||
const Aclick = (e: any) => {
|
||||
//window.open(window.location.origin + `/zutai/?id=${e.id}&&name=${e.name}&&preview=false&&graphicDisplay=zl`)
|
||||
window.open(
|
||||
window.location.origin +
|
||||
window.location.origin +
|
||||
`/zutai/?id=${e.id}&&name=${e.name}&&preview=false&&graphicDisplay=${VITE_FLAG ? 'ypt' : 'zl'}`
|
||||
)
|
||||
}
|
||||
@@ -179,7 +226,10 @@ const deleted = (e: any) => {
|
||||
|
||||
const imgData = (e: any) => {
|
||||
window.open(
|
||||
window.location.origin + `/zutai/?id=${e.id}&&name=${e.name}&&preview=true&&graphicDisplay=${VITE_FLAG ? 'ypt' : 'zl'}#/preview_ZL`
|
||||
window.location.origin +
|
||||
`/zutai/?id=${e.id}&&name=${e.name}&&preview=true&&graphicDisplay=${VITE_FLAG ? 'ypt' : 'zl'}#/preview_${
|
||||
VITE_FLAG ? 'YPT' : 'ZL'
|
||||
}`
|
||||
)
|
||||
// window.open('http://192.168.1.128:4001' + `/zutai/?id=${e.id}&&name=${e.name}&&preview=true&&graphicDisplay=zl#/preview_ZL`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user