Authored by 王涛

结构优化

Showing 31 changed files with 146 additions and 1256 deletions
@import "../icon/iconfont.css";
@import "../css/assets.css";
.el-loading-spinner .icon-mj{
width: 70px;
height: 70px;
background: url(../../../start/layui/css/modules/layer/default/loading-mj.png) no-repeat center;
background-size: 70px 70px;
animation: sk-chase-dot 2.0s infinite ease-in-out both;
opacity: 0.65;
display: block;
margin-left: calc((100% - 70px)/2);
}
@keyframes sk-chase-dot {
80%, 100% {
transform: rotate(360deg)
}
}
@import "../css/base.css";
... ...
@import "../icon/iconfont.css";
@import "../css/assets.css";
@import "../css/components.css";
/*最外层样式*/
.container{
background: white;
background-color: #CCCCCC;
padding: 3px 3px;
}
/*
共通弹框配置样式
custom-class="config-dialog"
*/
.config-dialog .el-dialog__header{
text-align: left!important;
}
.config-dialog .el-dialog__body{
padding: 5px 10px!important;
padding-bottom: 20px!important;
min-height: 500px;
}
/*加载图标*/
.el-loading-spinner .icon-mj{
width: 70px;
height: 70px;
background: url(../../../start/layui/css/modules/layer/default/loading-mj.png) no-repeat center;
background-size: 70px 70px;
animation: sk-chase-dot 2.0s infinite ease-in-out both;
opacity: 0.65;
display: block;
margin-left: calc((100% - 70px)/2);
}
@keyframes sk-chase-dot {
80%, 100% {
transform: rotate(360deg)
}
}
... ...
.tree-container{
background-color: white;
padding: 0px 0px;
border-radius: 3px;
text-align: left;
height: 100%;
}
... ...
export default {
template: '',
name: 'restypetree',
name: 'res-type-tree-input',
props: {
// echoObj 可以用于回显,它的值为需要回显的对象,多个时可以使用数组
echoObj: {},
... ... @@ -114,9 +114,6 @@ export default {
},
watch: {},
mounted() {
},
created() {
console.log(111111111111);
let that = this;
//加载资源列表
... ... @@ -128,6 +125,9 @@ export default {
console.log("getTree:",that.list);
}
})
},
created() {
}
}
... ...
<div>
<el-select @visible-change="selectClose" v-model="modelValueLabel" :filter-method="selectFilterMethod"
style="min-width: 120px;" :size="size" placeholder="资源类型" :filterable="isFilter" clearable
:collapse-tags="true" @change="selectChangeMethod">
<el-option :value="modelValue" style="height: auto;padding: 0;">
<el-tree ref="resTypeTree" :data="list" :check-on-click-node="true" :default-expand-all="isDefaultAll"
:expand-on-click-node="true" :filter-node-method="filterNode" :check-strictly="false"
:empty-text="emptyText" :show-checkbox="isMultiple" node-key="id" :show-checkbox="checkbox"
@check-change="handleCheckChange" node-key="id" :props="defaultProps">
<div class="tree-container" :style="{'height':height+'px','max-height':height+'px','overflow':'hidden','padding':'0px'}">
<div class="filter-view">
<el-input v-model="filterText" size="samll" placeholder="请输入关键字" />
</div>
<div :style="{'height':height+'px','max-height':(height - 54)+'px','overflow':'auto','padding':'0px'}">
<el-tree ref="tree" style="padding:6px;" :props="props" :data="treeData" node-key="id" default-expand-all :expand-on-click-node="false">
<template #default="{ node, data }">
<div class="tree-node">
<div class="tree-node-label">{{ node.label }}</div>
<div class="tree-node-tools">
<a @click="append(data)">
<i class="el-icon-plus"></i>
</a>
<a @click="remove(node, data)">
<i class="el-icon-delete"></i>
</a>
</div>
</div>
</template>
</el-tree>
</el-option>
</el-select>
</div>
</div>
... ...
/**
* 未完成
*/
export default {
template: '',
name: 'restypetree',
props: {
// echoObj 可以用于回显,它的值为需要回显的对象,多个时可以使用数组
echoObj: {},
// 是否开启搜索
isFilter: {
default: true
},
// 尺寸
size: {
default: ''
},
placeholderText: {
default: '资源类型'
},
isTag: {
default: true
},
isDefaultAll: {
default: true
},
// 点击节点是否展开
expandClickNode: {
default: false
},
// 字段key,用于取出数据中的名字
fieldName: {
default: 'title'
},
emptyText: {
default: '无匹配项'
},
// 字段key, 数据中的id
fieldId: {
default: ''
},
// 配置是否可多选
isMultiple: {
type: Boolean,
default: true
},
},
template: '',
components: {},
data() {
return {
defaultProps: {
children: 'children',
label: 'title'
},
list:[],
// 实际选中值
modelValue: [],
// 下拉框绑定值(选中值名字)
modelValueLabel: []
props : {
label:'title',
children:'children'
}
},
methods: {
selectClose(bool) {
if (bool) {
this.selectFilterMethod('')
}
},
selectFilterMethod(val) {
// 下拉框调用tree树筛选
this.$refs.resTypeTree.filter(val)
},
selectChangeMethod(e) {
var arrNew = []
var dataLength = this.modelValue.length
var eLength = e.length
for (var i = 0; i < dataLength; i++) {
for (var j = 0; j < eLength; j++) {
if (e[j] === JSON.parse('this.modelValue[i].' + this.fieldName)) {
arrNew.push(this.modelValue[i])
setup() {
let height = Vue.ref(window.innerHeight - 130);
const filterText = Vue.ref('');
const {proxy} = Vue.getCurrentInstance();
const treeData = Vue.ref([]);
// 添加树节点
let append = (data) => {
treeNodeData.value = data;
const newChild = {
id: 1111,
title: 'testtest',
children: []
}
if (!data.children) {
data.children = []
}
data.children.push(newChild)
this.dataSource = [...this.dataSource]
}
// 设置勾选的值
this.$refs.resTypeTree.setCheckedNodes(arrNew)
},
filterNode(value, data) {
if (!value) return true
return data[this.fieldName].indexOf(value) !== -1
},
handleCheckChange(data, checked, indeterminate) {
let that = this;
// 删除树节点
let remove = (node, data) => {
const parent = node.parent
const children = parent.data.children || parent.data
const index = children.findIndex((d) => d.id === data.id)
children.splice(index, 1)
this.dataSource = [...this.dataSource]
}
var selectArr = [];
selectArr.push(data);
// data[that.defaultProps.children].forEach(function (v) {
// selectArr.push(data);
// });
// 筛选
let filterNode = (value) => {
if (!value) return true
if (checked) {
// 已选中
that.modelValue = that.modelValue.concat(selectArr)
} else {
that.modelValue.forEach(function(v, i) {
selectArr.forEach(function(v1) {
if (v.id == v1.id) {
that.modelValue.splice(i, 1);
let arr = data.filter(function (v) {
if (v.label.indexOf(value) != -1) {
return v;
}
})
})
console.log(arr);
return arr;
}
that.modelValueLabel = that.modelValue.map(function(v) {
return v[that.defaultProps.label];
// 监听编辑状态
Vue.watch(() => filterText.value, (newValue, oldVlaue) => {
proxy.$refs.tree.filter(newValue)
});
that.$emit('callback', this.modelValue)
}
},
watch: {},
mounted() {
},
created() {
console.log(111111111111);
let that = this;
//加载资源列表
const { proxy } = Vue.getCurrentInstance()
// 加载列表
proxy.$http.get("/api-web/home/resType/getTree?typeParentFlag=1", {}, function(res) {
if (res && res.data) {
that.list = res.data;
console.log("getTree:",that.list);
}
// 挂载完
Vue.onMounted(() => {
})
return {
height,
treeData,
append,
remove,
filterText,
filterNode,
}
}
}
... ...
... ... @@ -13,8 +13,6 @@ Promise.all([
.use(res[0].default) // 挂载vuex
.use(res[1].default) // 挂载路由
.use(ElementPlus, {
locale: ElementPlus.lang.zhCn
})
... ... @@ -23,9 +21,13 @@ Promise.all([
.use(vant.Lazyload) // 加载vant
// 全局注册公共组件
.component('res-type-tree', Vue.defineAsyncComponent(() => myImport('components/common/restypetree/index')))
.component('machine-room',Vue.defineAsyncComponent(() => myImport('components/common/machineroom/index')));
// 下拉列表资源树
.component('res-type-tree-input', Vue.defineAsyncComponent(() => myImport('components/common/inputrestypetree/index')))
// 机房下拉
.component('machine-room',Vue.defineAsyncComponent(() => myImport('components/common/machineroom/index')))
// 资源类型树
.component('res-type-tree-view',Vue.defineAsyncComponent(() => myImport('components/common/restypetree/index')));
app.config.globalProperties.$global = res[3].default
app.config.globalProperties.$http = res[4].default
... ...
... ... @@ -5,7 +5,7 @@
</el-input>
</el-form-item>
<el-form-item label="" :disabled="initFlga">
<res-type-tree multiple clearable collapseTags @callback="getResType" />
<res-type-tree-input multiple clearable collapseTags @callback="getResType" />
</el-form-item>
<el-form-item label="">
... ...
@import "../icon/iconfont.css";
@import "../css/assets.css";
@import "../css/base.css";
/*资源配置*/
@import "../css/res.css";
@import "../css/operationMaintenance.css";
/*最外层样式*/
.container{
background: white;
background-color: #CCCCCC;
padding: 3px 3px;
}
/*
共通弹框配置样式
custom-class="config-dialog"
*/
.config-dialog .el-dialog__header{
text-align: left!important;
}
.config-dialog .el-dialog__body{
padding: 5px 10px!important;
padding-bottom: 20px!important;
min-height: 500px;
}
/*加载图标*/
.el-loading-spinner .icon-mj{
width: 70px;
height: 70px;
background: url(../../../start/layui/css/modules/layer/default/loading-mj.png) no-repeat center;
background-size: 70px 70px;
animation: sk-chase-dot 2.0s infinite ease-in-out both;
opacity: 0.65;
display: block;
margin-left: calc((100% - 70px)/2);
}
@keyframes sk-chase-dot {
80%, 100% {
transform: rotate(360deg)
}
}
/*乙方运维*/
@import "../css/operationMaintenance.css";
... ...
/* 属性配置 -- start */
.assets-configmanager {
padding: 6px 3px;
background: white;
}
.assets-configmanager .config-tools {
text-align: left;
margin-left: 2%;
margin-bottom: 6px;
}
.assets-configmanager .tbl-header-class {
color: #1E9FFF;
font-weight: bold;
}
.assets-configmanager .tbl-header-class th {
background: #EBF5F9 !important;
text-align: center;
}
.assets-configmanager .tbl-header-class th .cell {
text-align: center !important;
}
.assets-configmanager .el-table__row td{
padding: 2px 0px;!important;
text-align: center;
}
.config-view {
display: flex;
flex-wrap: wrap;
width: 96%;
margin: 0 2% 0 2%;
}
.assets-configmanager .config-header-title {
width: 40%;
height: 40px;
line-height: 40px;
color: rgb(30, 159, 255);
text-align: center;
font-weight: bold;
background-color: #D0DDEC;
border: solid 1px #efefef;
}
.assets-configmanager .config-header-content {
width: 60%;
height: 40px;
line-height: 40px;
color: rgb(30, 159, 255);
text-align: center;
font-weight: bold;
background-color: #D0DDEC;
border: solid 1px #efefef;
}
.assets-configmanager .config-content-title {
width: 40%;
background-color: rgb(241, 246, 249);
height: 40px;
line-height: 40px;
border: solid 1px #efefef;
}
.assets-configmanager .config-content-content {
width: 60%;
height: 40px;
line-height: 40px;
border: solid 1px #efefef;
}
/*.assets-configmanager .config-content-content::hover {*/
/*background-color: rgb(249, 249, 249);*/
/*}*/
/* 属性配置 -- end */
<el-select @change="changeOption" v-model="machineroom" :multiple="false" collapse-tags clearable filterable
:placeholder="placeholderText">
<el-option v-for="item in options" :key="item.machineRoomId" :label="item.machineRoomName"
:value="item.machineRoomCode" >
</el-option>
</el-select>
\ No newline at end of file
export default {
template: '',
name: 'machineroom',
props: {
placeholderText: {
default: '所属机房'
},
},
data() {
return {
loadding:true,
machineroom: '',
options: [],
}
},
methods: {
changeOption(e) {
this.$emit('callback', this.machineroom)
}
},
watch: {},
mounted() {
let that = this;
const { proxy } = Vue.getCurrentInstance()
// 加载列表
proxy.$http.get("/api-web/manage/machineroom/page", {}, function(res) {
if (res && res.data) {
that.options = res.data;
that.loadding = false;
}
})
},
created() {}
}
\ No newline at end of file
<div>
<!-- 展示文本 -->
<div v-if="!isEdit" style="max-height: 40px;overflow: hidden;text-overflow:ellipsis;white-space: nowrap;">
<el-tooltip placement="top" effect="light">
<template #content>{{detail.propValueText == undefined ? '' : detail.propValueText}}</template>
<span > {{detail.propValueText == undefined ? '' : detail.propValueText}}</span>
</el-tooltip>
</div>
<div v-else style="padding: 0px 2px;margin-top: -2px;display: flex">
<div :style="{width: detail.propertyEditInfo.tips && detail.propertyEditInfo.tips != '' ? 'calc(100% - 20px)' :'100%'}">
<div v-if="detail.propertyEditInfo.propertyType == 'LIST'">
<!-- 展示下拉选项 -->
<el-select :placeholder="detail.propName" size="small" style="width: 100%"
@change="changeProperty(detail.propKey)" v-model="detail.propValue" :multiple="false"
collapse-tags clearable filterable placeholder="请选择">
<el-option v-if="detail.propertyEditInfo.object != undefined"
v-for="(item,index) in detail.propertyEditInfo.object" :key="index"
:label="item[detail.propertyEditInfo.text]"
:value="item[detail.propertyEditInfo.value]">
</el-option>
</el-select>
</div>
<div v-else-if="detail.propertyEditInfo.propertyType == 'INPUT'" style="width: 100%">
<el-input @blur="changeProperty(detail.propKey)" size="small" :placeholder="detail.propName"
prefix-icon="el-icon-edit" v-model="detail.propValue">
</el-input>
</div>
</div>
<div style="line-height: 40px;margin: 0 0px;width: 20px;"
v-if="detail.propertyEditInfo.tips && detail.propertyEditInfo.tips != ''">
<el-tooltip placement="top">
<template #content>{{detail.propertyEditInfo.tips}}</template>
<i class="el-icon-warning-outline"></i>
</el-tooltip>
</div>
</div>
</div>
export default {
name: 'propertyedit',
template: '',
props: {
// 属性配置信息
detail: Object,
// 操作类型 true 编辑 false undefined 预览,默认预览
operates: false
},
setup(props, {attrs, slots, emit}) {
const isEdit = Vue.ref(false);
const oldVal = Vue.ref('');
if(props.detail){
oldVal.value = props.detail.propValue == undefined ? '' : props.detail.propValue;
}
let changeProperty = (key) => {
let detail = props.detail;
detail.propValueText = detail[detail.propertyEditInfo.text];
emit('callback', key, detail.propValue,oldVal.value,detail.propValueText)
}
// 监听编辑状态
Vue.watch(() => props.operates, (newValue, oldVlaue) => {
if (newValue && newValue == true) {
// 编辑
isEdit.value = true;
} else {
isEdit.value = false;
props.detail.propValue = oldVal.value;
}
});
return {
isEdit,
oldVal,
changeProperty
};
},
}
<div>
<br>
这是 组件测试<br>
父组件传递参数:{{str}}<br>
setup 获取参数:{{str1}}<br>
<van-field
v-model="fieldValue"
is-link
readonly
label="地区"
placeholder="请选择所在地区"
@click="show = true"
/>
<van-popup v-model:show="show" round position="bottom">
<van-cascader
v-model="cascaderValue"
title="请选择所在地区"
:options="options"
@close="show = false"
@finish="onFinish"
/>
</van-popup>
</div>
\ No newline at end of file
export default {
name: 'component-test',
template: '',
props: {
str: String
},
setup(props) {
// 在setup里面获取参数值
let str1 = Vue.ref(props.str)
str1.value += '--内部改一下。'
return {
str1,
placeholderText:'所属机房'
}
},
setup() {
const show = Vue.ref(false);
const fieldValue = Vue.ref('');
const cascaderValue = Vue.ref('');
// 选项列表,children 代表子选项,支持多级嵌套
const options = [
{
text: '浙江省',
value: '330000',
children: [{ text: '杭州市', value: '330100' }],
},
{
text: '江苏省',
value: '320000',
children: [{ text: '南京市', value: '320100' }],
},
];
// 全部选项选择完毕后,会触发 finish 事件
const onFinish = ({ selectedOptions }) => {
show.value = false;
fieldValue.value = selectedOptions.map((option) => option.text).join('/');
};
return {
show,
options,
onFinish,
fieldValue,
cascaderValue,
};
},
}
\ No newline at end of file
<div class="assets-configmanager">
<el-form :inline="true" :model="formInline" class="demo-form-inline" style="text-align: left;padding-left: 6px;">
<el-form-item label="" >
<el-input :disabled="initFlag" placeholder="输入关键字" v-model="pageInfo.keyWords" prefix-icon="el-icon-search">
</el-input>
</el-form-item>
<el-form-item label="" :disabled="initFlga">
<res-type-tree multiple clearable collapseTags @callback="getResType" />
</el-form-item>
<el-form-item label="">
<machine-room @callback="getMachineRoom"></machine-room>
</el-form-item>
<el-form-item>
<el-button :disabled="initFlag" type="primary" @click="onBtnSearch()">查询</el-button>
</el-form-item>
</el-form>
<!-- <div style="text-align: right" v-if="loadHead">
<el-popover placement="bottom" trigger="click">
<template #reference>
<el-button icon="el-icon-set-up" plain hairline size="small"></el-button>
</template>
<div slot="content" style="width: 100px;">
<div style="display: flex;flex-direction: column">
{{checkList}}
<el-checkbox-group v-model="checkList">
<el-checkbox :label="item.propName" borderv-for="item in columns"
style="margin: 3px;width: 100px;"></el-checkbox>
</el-checkbox-group>
</div>
</div>
</el-popover>
</div> -->
<el-table :max-height="height" v-loading="loading" :data="tableList" border style="width: 100%;" header-row-class-name="tbl-header-class"
:empty-text="emptyText" :stripe="true">
<el-table-column fixed type="index" v-if="columns.length > 0" :index="(index) => {return index + 1}" label="序号" width="60" align="center"> </el-table-column>
<el-table-column v-for="item in columns" :prop="item.propKey" :label="item.propName"
:width="widths[item.propKey] ? widths[item.propKey] : '120'">
<template #default="scope" v-if="item.propKey =='resName'">
<el-link type="primary" @click="openDetailPage(scope.row)">{{scope.row.resName}}</el-link>
</template>
</el-table-column>
</el-table>
<div style="text-align: center">
<el-pagination @size-change="handleSizeChange"
@prev-click="prePage"
@next-click="nextPage"
@current-change="handleCurrentChange"
:current-page="pageInfo.page" :page-sizes="[50,100, 150, 200]" :page-size="pageInfo.limit"
layout="total, sizes, prev, pager, next, jumper" :total="pageInfo.total" />
</div>
<el-dialog top="2vh" :title="row.title" v-model="centerDialogVisible" custom-class="config-dialog" width="80%" destroy-on-close>
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane label="基本信息" name="jbxx">
<div class="config-tools">
<el-button-group>
<el-button size="mini" icon="el-icon-edit-outline" @click="editConfig('jbxx')"></el-button>
<el-button size="mini" v-if="edits['jbxx'] && edits['jbxx'] === true" icon="el-icon-check" @click="saveConfig('jbxx')"></el-button>
<el-button size="mini" v-if="edits['jbxx'] && edits['jbxx'] === true" icon="el-icon-close" @click="cancelConfig('jbxx')"></el-button>
</el-button-group>
</div>
<div class="config-view">
<div style="display: flex;flex-direction: row;width: 100%;">
<div class="config-header-title">属性</div>
<div class="config-header-content">内容</div>
<div class="config-header-title">属性</div>
<div class="config-header-content">内容</div>
</div>
<div v-if="row.detail.jbxx != undefined" v-for="(item,index) in row.detail.jbxx"
style="display: flex;flex-direction: row;width: 50%;">
<div class="config-content-title">
{{item.propName}} &nbsp;
<i v-if="editKey[item.propKey] && editKey[item.propKey].edit === true" class="el-icon-edit" style="color: #409eff;" />
</div>
<div class="config-content-content">
<property-edit :detail="item" @callback="callback"
:operates="edits['jbxx']"></property-edit>
</div>
</div>
</div>
</el-tab-pane>
<el-tab-pane v-if="row.detail.name != undefined" v-for="(item,index) in row.detail.name"
:label="item.propName" :name="item.parentPropKey">
<div class="config-tools">
<el-button-group>
<el-button size="mini" @click="addTabDetail(item.parentPropKey)" icon="el-icon-plus"></el-button>
<el-button size="mini" @click="editConfig(item.parentPropKey)" icon="el-icon-edit-outline"></el-button>
<el-button size="mini" @click="saveTabConfig(item.parentPropKey)" v-if="edits[item.parentPropKey] && edits[item.parentPropKey] === true" icon="el-icon-check"></el-button>
<el-button size="mini" @click="cancelConfig(item.parentPropKey)" v-if="tabDelete[item.parentPropKey] && tabDelete[item.parentPropKey] === true" icon="el-icon-close"></el-button>
</el-button-group>
</div>
<div class="config-view">
<div style="display: flex;flex-direction: row;width: 100%;">
<div class="config-header-title"
v-if="row[item.parentPropKey] != undefined && row[item.parentPropKey].name != undefined "
:style="'width:calc(' + 1/row[item.parentPropKey].name.length*100 +'% - ' + 40/row[item.parentPropKey].name.length + 'px)'"
v-for="(propName,index) in row[item.parentPropKey].name" >
{{propName}}
</div>
<div class="config-header-title" style="width: 40px">操作</div>
</div>
<div style="display: flex;flex-direction: row;width: 100%;"
v-if="row[item.parentPropKey] != undefined && row[item.parentPropKey].data != undefined "
v-for="(propList,index) in row[item.parentPropKey].data">
<div class="config-content-content"
:style="'width:calc(' + 1/row[item.parentPropKey].name.length*100 +'% - ' + 40/row[item.parentPropKey].name.length + 'px)'"
v-for="(propInfo,index2) in propList">
<property-edit :detail="propInfo" @callback="callback"
:operates="edits[item.parentPropKey]"></property-edit>
<!--<div v-if="index2 == (propList.length -1) && propInfo.addItem && propInfo.addItem == 1"
style="position: absolute;width: 20px;right: 15px;" >
<el-button size="mini" circle icon="el-icon-delete" @click="deleConfigItem(propList,index,item.parentPropKey)"></el-button>
</div>-->
</div>
<div class="config-content-content" style="width: 40px;">
<el-button size="mini" type="text" icon="el-icon-delete"
v-if="propList[0] && propList[0].addItem && propList[0].addItem == 1"
@click="deleConfigItem(propList,index,item.parentPropKey)"></el-button>
</div>
</div>
</div>
</el-tab-pane>
</el-tabs>
</el-dialog>
</div>
export default {
name: 'configmanager',
template: '',
components: {
'property-edit': Vue.defineAsyncComponent(
() => myImport('components/page/assets/propertyedit/index')
),
},
setup() {
const { proxy } = Vue.getCurrentInstance()
let columns = Vue.ref([]);
let tableList = Vue.ref([]);
let emptyText = Vue.ref('数据加载中...');
let resTypeArr = Vue.ref([]);
let machineRoom = Vue.ref('');
let centerDialogVisible = Vue.ref(false);
let loadHead = Vue.ref(false);
let initFlag = Vue.ref(false);
let height = Vue.ref(window.innerHeight - 130);
// 分页信息
const pageInfo = Vue.reactive({
total: 0,
limit: 50,
page: 1,
keyWords:''
})
// 编辑信息
const row = Vue.ref({})
let tabDelete = Vue.ref({});
// 属性列表属性宽度
let widths = Vue.ref({
resName: '350',
admin: "150",
ip: "120",
maintenanceBegin: "180",
maintenanceEnd: "180",
resourceSN: "200",
cabinetPosition: "120",
parentResName:'300',
ULocation: "200"
});
// 筛选列选中的 TODO
let checkList = Vue.ref({})
// 活跃页签
let activeName = Vue.ref('jbxx');
let edits = Vue.ref({})
let editKey = Vue.ref({})
// 搜索
let onSearch = () => {
if(initFlag.value){
return;
}
initFlag.value = true;
// // 加载列表
// proxy.$http.get("/api-web/home/getUserProperties", {
// resTypes: resTypeArr.value
// }, function (res) {
// if (res && res.data) {
// columns.value = res.data;
// emptyText.value = '数据加载中...'
// loadHead.value = true;
// }
// });
//
// // 加载数据
// var params = {
// page: pageInfo.page,
// limit: pageInfo.limit,
// resName: pageInfo.keyWords,
// sortKey: '',
// resType: resTypeArr.value.join(','),
// resPositon: machineRoom.value,
// addr: '',
// maintenanceTimeEnd: '',
// maintenanceTimeStart: '',
// resCategory: 'assets'
// };
// proxy.$http.get("/api-web/home/assets/page/all", params, function (res) {
// if (res && res.data) {
// tableList.value = res.data;
// emptyText.value = "加载完成";
// pageInfo.total = res.count;
// } else {
// emptyText.value = "暂无数据";
// }
// initFlag.value = false;
// })
// 加载数据
var params = {
page: pageInfo.page,
limit: pageInfo.limit,
resName: pageInfo.keyWords,
sortKey: '',
resType: resTypeArr.value.join(','),
resPositon: machineRoom.value,
addr: '',
maintenanceTimeEnd: '',
maintenanceTimeStart: '',
resCategory: 'assets'
};
proxy.$http.get("/api-web/assets/configmanager/list", params, function (res) {
if (res && res.data) {
columns.value = res.map.header;
tableList.value = res.data;
emptyText.value = "加载完成";
pageInfo.total = res.count;
} else {
emptyText.value = "暂无数据";
tableList.value = [];
proxy.$global.showMsg('暂无数据!');
}
initFlag.value = false;
},function (){
proxy.$global.showMsg('没有查询到记录!');
initFlag.value = false;
});
}
// 点击按钮搜索
let onBtnSearch = () =>{
pageInfo.page = 1;
onSearch();
}
let getResType = (arr) => {
console.log(arr);
var types = arr.map(function (v) {
return v.id;
});
resTypeArr.value = types;
onSearch();
}
let getMachineRoom = (code) => {
console.log(code);
machineRoom.value = code;
onSearch();
}
// 每页展示多少条
let handleSizeChange = (val) => {
console.log(`每页 ${val} 条`)
pageInfo.limit = val;
onSearch();
}
// 切换页码
let handleCurrentChange = (val) => {
console.log(`当前页: ${val}`)
pageInfo.page = val;
onSearch();
}
// 切换页码
let prePage = (val) => {
console.log(`当前页: ${val}`)
pageInfo.page = val - 1;
onSearch();
}
// 切换页码
let nextPage = (val) => {
console.log(`当前页: ${val}`)
pageInfo.page = val + 1;
onSearch();
}
// 打开详情页配置
let openDetailPage = (rowDetail) => {
edits.value['jbxx'] = false;
if(row.value.detail && row.value.detail.name){
row.value.detail.name.forEach(function (v) {
edits.value[v] = false;
})
}
let resId = rowDetail.resId;
// 默认基本信息
activeName.value = 'jbxx';
row.value['title'] = rowDetail.resName + '_' + rowDetail.ip;
row.value['resId'] = resId;
let id = encodeURIComponent(resId);
// 获取配置信息
proxy.$http.get(`/api-web/assets/configmanager/resource/assets?resId=${id}`, {}, function (res) {
if (res && res.map) {
row.value['detail'] = res.map;
// 清空其他页签得数据
if(res.map.name){
res.map.name.forEach(function(tab) {
delete row.value[tab.parentPropKey];
})
}
centerDialogVisible.value = true;
}
})
}
// 加载其他页签数据
let handleClick = (tab, event) => {
let tabName = tab.props.name;
let resId = row.value['resId'];
// 已加载
if (row.value[tabName]) {
return;
}
let id = encodeURIComponent(resId);
// 查询其他页签信息
proxy.$http.get(`/api-web/assets/configmanager/tab/detail?resId=${id}&parentKey=${tabName}`, {}, function (
res) {
if (res && res.map) {
edits.value[tabName] = false;
row.value[tabName] = res.map;
}
})
}
// 二维表格添加
let addTabDetail = (tabName) => {
tabDelete.value[tabName] = true;
// // 设置取消状态
// tabDelete.value[tabName] = false;
// 设置编辑状态
edits.value[tabName] = false;
let val = row.value[tabName];
if(val && val.map && val.data){
let rowData = val.map;
let keys = Object.keys(rowData);
let propGroup = (new Date()).getTime();
let arr = [];
keys.forEach(function (k) {
var newProp = Object.create({});
Object.assign(newProp,rowData[k]);
newProp.propGroup = propGroup;
newProp.addItem = 1;
arr.push(newProp);
});
val.data.push(arr);
}
console.log(val);
}
// 点击编辑按钮
let editConfig = (tabName) => {
edits.value[tabName] = true;
}
// 点击取消
let cancelConfig = (tabName) => {
edits.value[tabName] = false;
// 还原数据
let detail = row.value.detail[tabName];
if(detail){
// 基本信息
detail.forEach(function (v) {
var e = editKey.value[v.propKey];
if(e){
detail.propValue = e.oldValue;
detail.propValueText = e.propValueText;
e.edit = false;
}
})
}
// 二维列表信息
detail = row.value[tabName];
if(detail && detail.data){
tabDelete.value[tabName] = false;
let newArr = [];
detail.data.forEach(function (v,i) {
let addItem = detail.data[i][0].addItem;
if(addItem && addItem == 1){
//detail.data.splice(i, 1);
} else {
if(v && v.length > 0){
v.forEach(function(configItem){
var e = editKey.value[configItem.propKey];
if(e){
configItem.propValue = e.oldValue;
configItem.propValueText = e.propValueText;
e.edit = false;
}
})
newArr.push(v);
}
}
});
detail.data = newArr;
}
}
// 点击保存
let saveConfig = (tabName) => {
let resId = row.value['resId'];
let arr = [];
let detail = row.value.detail[tabName];
if(detail){
detail.forEach(function (v) {
arr.push({
resId:resId,
key:v.propKey,
val:v.propValue,
type:v.propType,
parentKey:v.parentPropKey,
parentGroup:v.propGroup,
sort:v.sort
})
});
proxy.$http.post(`/api-web/assets/configmanager/saveConfig`, arr, function (res) {
proxy.$global.showMsg('保存成功!');
editKey.value = {};
centerDialogVisible.value = false;
onSearch();
})
}
}
// 保存二维属性
let saveTabConfig = (tabName) => {
let resId = row.value['resId'];
let arr = [];
let detail = row.value[tabName];
if(detail && detail.data){
detail.data.forEach(function (v) {
if(v && v.length > 0){
v.forEach(function(configItem){
arr.push({
resId:resId,
key:configItem.propKey,
val:configItem.propValue,
type:configItem.propType,
parentKey:configItem.parentPropKey,
parentGroup:configItem.propGroup,
sort:configItem.sort
})
})
}
});
proxy.$http.post(`/api-web/assets/configmanager/saveConfig`, arr, function (res) {
proxy.$global.showMsg('保存成功!');
editKey.value = {};
centerDialogVisible.value = false;
onSearch();
})
}
}
// 二维删除新增得选项
let deleConfigItem = (list,index,tabName) =>{
let detail = row.value[tabName];
if(detail && detail.data){
detail.data.splice(index,1);
}
}
let callback = ( key, propValue,oldValue,propValueText) => {
let resId = row.value['resId'];
console.log("回调", resId, key, propValue,oldValue)
if(propValue == null || propValue == '' || propValue == oldValue){
return;
}
editKey.value[key] = {
edit:true,
val:propValue,
oldValue: oldValue,
propValueText:propValueText == undefined ? oldValue : propValueText
};
}
// 挂载完
Vue.onMounted(() => {
onSearch();
console.log('onMounted');
})
return {
loadHead,
columns,
tableList,
pageInfo,
emptyText,
resTypeArr,
machineRoom,
widths,
onSearch,
getResType,
getMachineRoom,
openDetailPage,
centerDialogVisible,
row,
checkList,
activeName,
handleClick,
edits,
editConfig,
cancelConfig,
saveConfig,
callback,
editKey,
addTabDetail,
deleConfigItem,
saveTabConfig,
tabDelete,
handleSizeChange,
initFlag,
handleCurrentChange,
height,
onBtnSearch
}
}
}
... ... @@ -8,7 +8,10 @@ export default {
},
data() {
return {
props : {
label:'title',
children:'children'
}
}
},
setup() {
... ... @@ -28,10 +31,9 @@ export default {
dialogVisible.value = true;
}
// 获取左侧树结构
let loadTree = () => {
proxy.$http.get("/api-web/home/resType/getTree?notExist=machineroom&table=resources&exist=HOST_MINICOMPUTER_SERVER", {}, function (res) {
proxy.$http.get("/api-web/res/list/tree", {}, function (res) {
if (res && res.data) {
treeData.value = res.data
}
... ... @@ -40,7 +42,7 @@ export default {
// 挂载完
Vue.onMounted(() => {
loadTree();
console.log('onMounted');
})
... ...
<div>
<el-form :inline="true" :model="formInline" class="demo-form-inline">
<el-form-item label="">
<el-input placeholder="输入关键字" prefix-icon="el-icon-search" v-model="input2">
</el-input>
</el-form-item>
<el-form-item label="">
<res-type-list multiple clearable collapseTags @callback="getResType" />
</el-form-item>
<el-form-item label="">
<machine-room @callback="getMachineRoom"></machine-room>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit">查询</el-button>
</el-form-item>
</el-form>
<el-table :data="tableData" style="width: 100%">
<el-table-column v-for="item in columns" :prop="item.propKey" :label="item.propName">
</el-table-column>
</el-table>
</div>
export default {
name: 'About',
template: '',
setup () {
const value = Vue.ref('数据绑定的演示')
return {
value
}
}
}
\ No newline at end of file
<div>
演示一下组件里面使用组件的方式<br>
<test :str="value"></test>
</div>
export default {
name: 'template',
template: ``,
components: {
test: Vue.defineAsyncComponent(
() => myImport('components/test/test')
)
},
setup () {
const value = Vue.ref('传入组件的参数')
return {
value
}
}
}
\ No newline at end of file
<div class="assets-configmanager">
https://echarts.apache.org/examples/zh/index.html
<div id="main" style="width: 600px;height:400px;"></div>
</div>
export default {
name: 'testEcharts',
template: '',
setup() {
const {
proxy
} = Vue.getCurrentInstance()
let init = () => {
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('main'));
// 指定图表的配置项和数据
var option = {
title: {
text: 'ECharts 入门示例'
},
tooltip: {},
legend: {
data: ['销量']
},
xAxis: {
data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
},
yAxis: {},
series: [{
name: '销量',
type: 'bar',
data: [5, 20, 36, 10, 10, 20]
}]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
}
// 挂载完
Vue.onMounted(() => {
init();
console.log('onMounted');
})
return {
}
}
}
const { ref, reactive } = Vue
const testManage = () => {
const hello = ref('你好,世界')
const clickMe = () => {
hello.value = '好的,收到,现在时间:' + new Date()
}
return {
hello,
clickMe
}
}
// vue3的对象
export default {
template: `
<h2>我是 {{value.name}}</h2>
<div>
老规矩:{{hello}}<br>
<el-button type="primary" @click="clickMe">快点我</el-button><br>
<br>
这里是一种CND的开发方式<br>
vue全家桶和UI库用 CND方式 加载。<br>
js代码用 import 方式加载。<br>
目录结构参考了vue-cli建立的项目。<br>
支持组件、路由、状态管理等功能。<br>
不用webpacknpm等,建立网站就可以用。<br><br>
状态计数:{{$store.state.count}}
</div>
`,
setup() {
// 使用外面的定义,分解setup内部的代码
const { hello, clickMe } = testManage()
const value = reactive({
name: 'jyk'
})
return {
value,
hello,
clickMe
}
}
}
<div>
这里演示一下 vuex 的一些操作:<br>
ref的count :{{refCount}} <br>
计算属性的Count :{{comCount}} <br>
只读对象 :{{readonlyObject}} <br>
</div>
\ No newline at end of file
// 获取状态
const indirectManage = () => {
const store = Vuex.useStore()
// 用toRef获取 count,有相应性,可以直接修改state
const refCount = Vue.toRef(store.state, 'count')
// 计算属性获取count,有相应性,不可以直接修改state
const comCount = Vue.computed(() => store.state.count + 10)
// 只读的对象,有响应性,浅层不可以修改,但是深层还是可以修改。
const readonlyObject = Vue.readonly(store.state.myObject)
console.log('refCount:', refCount)
console.log('comCount:', comCount)
console.log('readonlyObject:', readonlyObject)
console.log('================')
// 定时修改 count 看响应性
setTimeout(() => {
// store.commit('setCount')
// refCount.value += 200 // 会直接改vuex的state
}, 2000)
return {
refCount,
comCount,
readonlyObject
}
}
export default {
name: 'vuex_store',
template: '',
components: {
},
setup () {
const value = Vue.ref('状态管理的演示')
// 获取状态
const { refCount, comCount, readonlyObject } = indirectManage()
return {
value,
refCount, comCount, readonlyObject
}
}
}
\ No newline at end of file