|
|
|
|
@ -8,7 +8,13 @@
|
|
|
|
|
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>上级目录:
|
|
|
|
|
</div>
|
|
|
|
|
<div class="xy-table-item-content">
|
|
|
|
|
<el-input v-model="form.pName" disabled clearable style="width: 100%;"></el-input>
|
|
|
|
|
<el-input v-if="type==='add'" v-model="form.pName" disabled clearable style="width: 100%;"></el-input>
|
|
|
|
|
<div v-else style="height:150px;overflow: scroll;">
|
|
|
|
|
<el-tree v-if="isShow" :default-checked-keys="checkArr" :check-strictly="true" @check="getSelectedNodes"
|
|
|
|
|
:data="catalogList" show-checkbox default-expand-all node-key="id" ref="tree" highlight-current
|
|
|
|
|
:props="defaultProps">
|
|
|
|
|
</el-tree>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
@ -40,7 +46,8 @@
|
|
|
|
|
<script>
|
|
|
|
|
import {
|
|
|
|
|
save,
|
|
|
|
|
show
|
|
|
|
|
show,
|
|
|
|
|
index
|
|
|
|
|
} from "@/api/system/baseForm.js"
|
|
|
|
|
import {
|
|
|
|
|
deepCopy,
|
|
|
|
|
@ -55,6 +62,12 @@
|
|
|
|
|
isShow: false,
|
|
|
|
|
type: 'add',
|
|
|
|
|
id: '',
|
|
|
|
|
catalogList: [],
|
|
|
|
|
checkArr: [],
|
|
|
|
|
defaultProps: {
|
|
|
|
|
children: 'children',
|
|
|
|
|
label: 'name'
|
|
|
|
|
},
|
|
|
|
|
table_name: 'catalogs',
|
|
|
|
|
form: {
|
|
|
|
|
pName: '根目录',
|
|
|
|
|
@ -70,12 +83,41 @@
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
created() {},
|
|
|
|
|
methods: {
|
|
|
|
|
created() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
async getCatalogList() {
|
|
|
|
|
const res = await index({
|
|
|
|
|
page_size: 999,
|
|
|
|
|
page: 1,
|
|
|
|
|
sort_type: 'ASC',
|
|
|
|
|
sort_name: 'sort',
|
|
|
|
|
table_name: 'catalogs',
|
|
|
|
|
is_auth: 1
|
|
|
|
|
})
|
|
|
|
|
if (res.data.length > 0) {
|
|
|
|
|
this.catalogList = this.base.buildTree(res.data)
|
|
|
|
|
this.catalogList.unshift({
|
|
|
|
|
id:0,
|
|
|
|
|
name:'根目录'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
getSelectedNodes(data, node) {
|
|
|
|
|
console.log("data", data)
|
|
|
|
|
this.$refs.tree.setCheckedKeys([]); // 删除所有选中节点
|
|
|
|
|
this.$refs.tree.setCheckedNodes([data]); // 选中已选中节点
|
|
|
|
|
this.form.pName = data.name
|
|
|
|
|
this.form.pid = data.id
|
|
|
|
|
this.$forceUpdate()
|
|
|
|
|
},
|
|
|
|
|
// 子目录
|
|
|
|
|
setPid(pid, pName) {
|
|
|
|
|
console.log("pid", pid, pName)
|
|
|
|
|
this.form.pid = pid ? pid : 0
|
|
|
|
|
this.form.pName = pName ? pName : '根目录'
|
|
|
|
|
this.form.pName = pName ? pName : '根目录'
|
|
|
|
|
this.checkArr = pid ? [pid] : []
|
|
|
|
|
},
|
|
|
|
|
submit() {
|
|
|
|
|
if (this.id) {
|
|
|
|
|
@ -83,6 +125,12 @@
|
|
|
|
|
}
|
|
|
|
|
if (this.type == 'add' || this.type == "child") {
|
|
|
|
|
this.form.id = ''
|
|
|
|
|
}
|
|
|
|
|
if(this.type==='editor'){
|
|
|
|
|
if(this.form.pid===this.form.id){
|
|
|
|
|
this.$Message.warning("上级目录不能为自身")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
console.log("this.form", this.form)
|
|
|
|
|
save({
|
|
|
|
|
@ -103,13 +151,15 @@
|
|
|
|
|
id: this.id,
|
|
|
|
|
table_name: this.table_name,
|
|
|
|
|
}).then(res => {
|
|
|
|
|
this.form = this.base.requestToForm(res, this.form)
|
|
|
|
|
this.form = this.base.requestToForm(res, this.form)
|
|
|
|
|
this.checkArr = res.pid ? [res.pid] : []
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
isShow(newVal) {
|
|
|
|
|
if (newVal) {
|
|
|
|
|
if (newVal) {
|
|
|
|
|
this.getCatalogList()
|
|
|
|
|
if (this.type === 'editor') {
|
|
|
|
|
this.getDetail()
|
|
|
|
|
} else if (this.type === 'add') {
|
|
|
|
|
@ -118,7 +168,8 @@
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
this.id = ''
|
|
|
|
|
this.type = "add"
|
|
|
|
|
this.type = "add"
|
|
|
|
|
this.checkArr = []
|
|
|
|
|
this.form = {
|
|
|
|
|
pName: '根目录',
|
|
|
|
|
name: '',
|
|
|
|
|
@ -144,4 +195,8 @@
|
|
|
|
|
::v-deep .xy-table-item-content {
|
|
|
|
|
width: calc(100% - 140px);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
::v-deep .el-checkbox__input .el-checkbox__inner {
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|