Commit 852498c6 authored by 仇晓婷's avatar 仇晓婷

文档分类树封装组件

parent a4285b5c
...@@ -7,5 +7,8 @@ export default { ...@@ -7,5 +7,8 @@ export default {
serialcode(params) { serialcode(params) {
return Api.post(`${systemUrl}/cache/generate_serialcode`, params); return Api.post(`${systemUrl}/cache/generate_serialcode`, params);
}, },
//文档分类列表
list(params){
return Api.post(`${material}/documentcategory/list`,params);
},
} }
\ No newline at end of file
<template>
<div class="word-tree">
<div class="search">
<Input search placeholder="关键字" v-model="keys" clearable />
</div>
<Tree
:data="data"
ref="tree"
@on-select-change="change"
:render="renderContent"
></Tree>
</div>
</template>
<script>
import Api from "./api";
export default {
data() {
return {
keys: "",
list: [],
};
},
computed: {
data() {
let items = this.$u.clone(this.list);
let expand = this.expand;
let result = [];
search(this.keys, items);
function search(keys, data) {
data.map((u) => {
if (keys.length < u.title) {
u.expand = expand;
result.push(u);
} else {
u.expand = expand;
if (u.title.indexOf(keys) > -1) {
result.push(u);
} else if (u.children) {
search(keys, u.children);
}
}
});
}
return result;
},
},
mounted() {
this.loadTree();
},
methods: {
loadTree() {
let data = {
conditions: [
{
fieldName: "status",
fieldValue: "1",
conditionalType: "Equal",
},
],
};
Api.list(data).then((r) => {
var data = this.$u.toTree(
r.result,
0,
(u) => {
u.title = u.name;
u.value = u.id;
u.expand = true;
},
"upId"
);
this.list = this.$u.clone(data);
// console.log(this.list);
});
},
change(a, b) {
// console.log(a)
console.log(b);
// if (b.children.length == 0) { //判断最底层才能添加文档
// this.addShow = true;
// this.$refs.dataTable.$refs.grid.reload(this.easySearch);
// } else {
// this.addShow = false;
// }
let ids = [];
ids.push(b.value);
if (b.children) {
addId(b.children);
function addId(data) {
data.map((u) => {
ids.push(u.value);
if (u.children) {
addId(u.children);
}
});
}
}
this.$emit("change", b, ids);
},
renderContent(h, { root, node, data }) {
let type = "";
if (data.type == 0) {
type = "md-folder";
} else if (data.type == 1) {
type = "ios-copy";
} else {
type = "ios-book";
}
return h("span", [
h("Icon", {
props: {
type: type,
},
style: {
marginRight: "8px",
},
}),
h(
"span",
data.title
),
]);
},
},
};
</script>
\ No newline at end of file
...@@ -21,18 +21,15 @@ ...@@ -21,18 +21,15 @@
</ButtonGroup> </ButtonGroup>
</div> </div>
</h3> </h3>
<div class="search">
<Input search placeholder="关键字" v-model="keys" clearable />
</div>
<div class="fg"> <div class="fg">
<div class="tree"> <!-- <Tree
<Tree
:data="data" :data="data"
ref="tree" ref="tree"
@on-select-change="change" @on-select-change="change"
:render="renderContent" :render="renderContent"
></Tree> ></Tree> -->
</div> <WordTree @change="change" />
</div> </div>
</div> </div>
</Sider> </Sider>
...@@ -71,7 +68,6 @@ export default { ...@@ -71,7 +68,6 @@ export default {
list: [], list: [],
showMenu: true, showMenu: true,
model8: "", model8: "",
keys: "",
expand: false, expand: false,
treeId: 0, treeId: 0,
addShow: false, addShow: false,
...@@ -79,64 +75,18 @@ export default { ...@@ -79,64 +75,18 @@ export default {
workFlowIds: "", workFlowIds: "",
}; };
}, },
mounted() { mounted() {},
this.loadTree();
},
async fetch({ store, params }) { async fetch({ store, params }) {
await store.dispatch("loadDictionary"); // 加载数据字典 await store.dispatch("loadDictionary"); // 加载数据字典
}, },
computed: {
data() {
let items = this.$u.clone(this.list);
let expand = this.expand;
let result = [];
search(this.keys, items);
function search(keys, data) {
data.map((u) => {
if (keys.length < u.title) {
u.expand = expand;
result.push(u);
} else {
u.expand = expand;
if (u.title.indexOf(keys) > -1) {
result.push(u);
} else if (u.children) {
search(keys, u.children);
}
}
});
}
return result;
},
},
methods: { methods: {
loadTree() { change(item, ids) {
let data = { this.treeId = item.id;
conditions: [ this.workFlowIds = item.workFlowIds;
{ this.ids = ids;
fieldName: "status",
fieldValue: "1",
conditionalType: "Equal",
},
],
// sortBy: "code",
// isDesc: false,
};
Api.list(data).then((r) => {
var data = this.$u.toTree(
r.result,
0,
(u) => {
u.title = u.name;
u.value = u.id;
u.expand = true;
},
"upId"
);
this.list = this.$u.clone(data);
// console.log(this.list);
});
}, },
toggle() { toggle() {
if (this.model8) { if (this.model8) {
this.expand = !this.expand; this.expand = !this.expand;
...@@ -147,58 +97,6 @@ export default { ...@@ -147,58 +97,6 @@ export default {
hide() { hide() {
this.showMenu = false; this.showMenu = false;
}, },
change(a, b) {
// console.log(a)
console.log(b);
this.treeId = b.id;
this.workFlowIds = b.workFlowIds; //流程id
// if (b.children.length == 0) { //判断最底层才能添加文档
// this.addShow = true;
// this.$refs.dataTable.$refs.grid.reload(this.easySearch);
// } else {
// this.addShow = false;
// }
let ids = [];
ids.push(b.value);
if (b.children) {
addId(b.children);
function addId(data) {
data.map((u) => {
ids.push(u.value);
if (u.children) {
addId(u.children);
}
});
}
}
// console.log(ids)
this.ids = ids;
},
renderContent(h, { root, node, data }) {
let type = "";
if (data.type == 0) {
type = "md-folder";
} else if (data.type == 1) {
type = "ios-copy";
} else {
type = "ios-book";
}
return h("span", [
h("Icon", {
props: {
type: type,
},
style: {
marginRight: "8px",
},
}),
h(
"span",
data.title
),
]);
},
showMenuFn() { showMenuFn() {
//this.$Message.info("展开左侧树") //this.$Message.info("展开左侧树")
......
...@@ -67,7 +67,7 @@ import ImportExcel from '@/components/page/import/process.vue' ...@@ -67,7 +67,7 @@ import ImportExcel from '@/components/page/import/process.vue'
import CustomProperties from '@/components/page/customProperties.vue' import CustomProperties from '@/components/page/customProperties.vue'
import InputCode from '@/components/page/inputCode.vue' import InputCode from '@/components/page/inputCode.vue'
import Pictrue from '@/components/page/pictrue.vue' import Pictrue from '@/components/page/pictrue.vue'
import WordTree from '@/components/page/wordTree.vue'
...@@ -141,6 +141,8 @@ Vue.component("ImportExcel",ImportExcel) ...@@ -141,6 +141,8 @@ Vue.component("ImportExcel",ImportExcel)
Vue.component("CustomProperties",CustomProperties) Vue.component("CustomProperties",CustomProperties)
Vue.component("InputCode",InputCode) Vue.component("InputCode",InputCode)
Vue.component("Pictrue",Pictrue) Vue.component("Pictrue",Pictrue)
Vue.component("WordTree",WordTree)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment