xy 2 years ago
parent 625494b3d5
commit fb67f3b60f

@ -26,19 +26,16 @@
<div class="xy-table-item"> <div class="xy-table-item">
<div class="xy-table-item-label">目录 </div> <div class="xy-table-item-label">目录 </div>
<div class="xy-table-item-content"> <div class="xy-table-item-content">
<el-select <el-cascader
v-model="form.menu_id" :key="cascaderId_pid"
clearable clearable
placeholder="请选择目录"
style="width: 300px" style="width: 300px"
> :show-all-levels="false"
<el-option :value="form.menu_id"
v-for="item in menu_ids" :options="menu_ids"
:key="item.id" :props="{ value: 'id', label: 'name', checkStrictly: true }"
:label="item.value" @change="pidCascaderHandler"
:value="item.id" ></el-cascader>
></el-option>
</el-select>
</div> </div>
</div> </div>
</template> </template>
@ -125,6 +122,7 @@ export default {
}, },
data() { data() {
return { return {
cascaderId_pid: 0,
isShow: false, isShow: false,
id: "", id: "",
type: "", type: "",
@ -209,14 +207,20 @@ export default {
}, },
async getDetail() { async getDetail() {
const res = await show({ id: this.id }); const res = await show({ regulation_article_id: this.id });
this.$integrateData(this.form, res); this.$integrateData(this.form, res);
this.file_list = res.regulation_article_file.map(i => ({
name: i.files.original_name,
url: i.files.url,
response: i
}))
}, },
submit() { submit() {
this.form.file_list = this.file_list.map(i => i.response?.id)
if (this.type === "add") { if (this.type === "add") {
if (this.form.hasOwnProperty("id")) { if (this.form.hasOwnProperty("regulation_article_id")) {
delete this.form.id; delete this.form.regulation_article_id;
} }
store(this.form).then((res) => { store(this.form).then((res) => {
this.$message({ this.$message({
@ -229,7 +233,7 @@ export default {
}); });
} }
if (this.type === "editor") { if (this.type === "editor") {
Object.defineProperty(this.form, "id", { Object.defineProperty(this.form, "regulation_article_id", {
value: this.id, value: this.id,
enumerable: true, enumerable: true,
configurable: true, configurable: true,
@ -246,6 +250,13 @@ export default {
}); });
} }
}, },
pidCascaderHandler(e) {
if (e.length > 0) {
this.form.menu_id = e.at(-1);
} else {
this.form.menu_id = "";
}
},
}, },
watch: { watch: {
isShow(val) { isShow(val) {
@ -256,11 +267,15 @@ export default {
} else { } else {
this.id = ""; this.id = "";
this.type = ""; this.type = "";
this.file_list = [];
this.init(); this.init();
this.$refs["dialog"].clearValidate(); this.$refs["dialog"].clearValidate();
delete this.form.id; delete this.form.regulation_article_id;
} }
}, },
menu_ids() {
++this.cascaderId_pid;
},
}, },
}; };
</script> </script>

@ -0,0 +1,107 @@
<template>
<div>
<el-drawer
title="详情"
:visible.sync="drawer"
direction="rtl"
size="600px">
<div>
<div class="content">
<div class="content-item" v-for="(value,key) in rowLabel">
<div class="content-item__title">{{ value }}</div>
<div class="content-item__value">
<template v-if="key === 'regulation_article_file'">
<el-link target="_blank" type="primary" v-for="item in row[key]" :href="item.files ? item.files.url : ''">{{ item.files ? item.files.original_name : '' }}</el-link>
</template>
<template v-else>
<span>{{ contentValue(key) }}</span>
</template>
</div>
</div>
</div>
</div>
</el-drawer>
</div>
</template>
<script>
import { show } from "@/api/sysManage/article";
export default {
data() {
return {
row: {},
drawer: false,
id: "",
rowLabel: {
title: "标题",
"menu.name": "目录",
"type": "类型",
"content": "内容",
"admin.name": "经办人",
created_at: "创建日期",
"regulation_article_file": "文件"
}
}
},
methods: {
show () {
this.drawer = true
},
hide () {
this.drawer = false
},
setId (id) {
this.id = id
},
async getRow () {
this.row = await show({ regulation_article_id: this.id })
}
},
computed: {
contentValue () {
return function (key) {
const splitKey = key.split('.')
let res = ''
try {
for(let i = 0;i < splitKey.length;i++) {
if (i === 0) {
res = this.row[splitKey[i]]
} else {
res = res[splitKey[i]]
}
}
} catch {}
return res;
}
}
},
watch: {
drawer(newVal) {
if (newVal) {
this.getRow()
}
}
}
}
</script>
<style scoped lang="scss">
.content {
display: grid;
grid-template-columns: repeat(2,1fr);
grid-row-gap: 20px;
padding: 20px;
&-item {
&__title {
font-weight: 600;
line-height: 2;
}
&__value {
}
}
}
</style>

@ -61,7 +61,7 @@
> >
编辑 编辑
</Button> </Button>
<Button @click="$refs['add'].setId(row.id),$refs['add'].show()" size="small" type="info"> <Button @click="$refs['drawer'].setId(row.id),$refs['drawer'].show()" size="small" type="info">
查看 查看
</Button> </Button>
<Poptip <Poptip
@ -102,22 +102,28 @@
/> />
</div> </div>
<add ref="add" :pids="list" @refresh="getList"></add> <add ref="add" :menu_ids="menus" @refresh="getList"></add>
<drawer ref="drawer"></drawer>
</div> </div>
</template> </template>
<script> <script>
import add from "./component/addFile.vue" import add from "./component/addFile.vue"
import drawer from "./component/drawer.vue"
import { index, destroy } from "@/api/sysManage/article" import { index, destroy } from "@/api/sysManage/article"
import { index as menuIndex } from "@/api/sysManage/menu"
export default { export default {
components: { components: {
add add,
drawer
}, },
data() { data() {
return { return {
menus: [],
total: 0, total: 0,
select: { select: {
show_tree: 1, page: 1,
page_size: 10,
type: "" type: ""
}, },
@ -129,6 +135,11 @@ export default {
width: 180, width: 180,
fixed: "left", fixed: "left",
}, },
{
prop: "menu.name",
label: "目录",
width: 140
},
{ {
prop: "type", prop: "type",
label: "类型", label: "类型",
@ -153,6 +164,13 @@ export default {
}; };
}, },
methods: { methods: {
async getMenus () {
this.menus = await menuIndex({
show_tree: 1,
type: ""
})
},
init() { init() {
for (let key in this.select) { for (let key in this.select) {
if (this.select[key] instanceof Array) { if (this.select[key] instanceof Array) {
@ -172,14 +190,16 @@ export default {
}, },
destroy(id) { destroy(id) {
destroy({ destroy({
id, regulation_article_id: id,
}).then((_) => { }).then((_) => {
this.getList(); this.getList();
}); });
}, },
}, },
computed: {}, computed: {
},
created() { created() {
this.getMenus();
this.getList(); this.getList();
}, },
}; };

@ -31,8 +31,8 @@
clearable clearable
style="width: 300px" style="width: 300px"
:show-all-levels="false" :show-all-levels="false"
v-model="form.pid" :value="form.pid"
:options="pidsRoot" :options="pids"
:props="{ value: 'id', label: 'name', checkStrictly: true }" :props="{ value: 'id', label: 'name', checkStrictly: true }"
@change="pidCascaderHandler" @change="pidCascaderHandler"
></el-cascader> ></el-cascader>
@ -105,12 +105,11 @@ export default {
this.isShow = false; this.isShow = false;
}, },
init() { init() {
for (let key in this.form) { this.form = {
if (this.form[key] instanceof Array) { name: "",
this.form[key] = []; pid: 0,
} else { type: "",
this.form[key] = ""; remark: "",
}
} }
this.$refs["dialog"].clearValidate(); this.$refs["dialog"].clearValidate();
}, },
@ -154,7 +153,7 @@ export default {
}, },
async getDetail() { async getDetail() {
const res = await show({ id: this.id }); const res = await show({ regulation_menu_id: this.id });
this.$integrateData(this.form, res); this.$integrateData(this.form, res);
}, },
@ -193,9 +192,7 @@ export default {
}, },
}, },
computed: { computed: {
pidsRoot () {
return [{ id: 0, name: '根目录', children: this.pids }]
}
}, },
watch: { watch: {
isShow(val) { isShow(val) {

@ -12,6 +12,7 @@
<div> <div>
<span style="padding: 0 6px">类型</span> <span style="padding: 0 6px">类型</span>
<span> <span>
<el-input v-model="select.type" size="small" style="width: 160px;"></el-input>
</span> </span>
</div> </div>
@ -46,10 +47,21 @@
fixed="right" fixed="right"
header-align="center" header-align="center"
label="操作" label="操作"
width="200" minWidth="200"
> >
<template slot-scope="{ row }"> <template slot-scope="{ row }">
<div class="slot-btns"> <div class="slot-btns">
<Button
size="small"
type="primary"
@click="
$refs['add'].setForm('pid',row.id),
$refs['add'].setType('add'),
$refs['add'].show()
"
>
下级
</Button>
<Button <Button
size="small" size="small"
type="primary" type="primary"
@ -61,9 +73,6 @@
> >
编辑 编辑
</Button> </Button>
<Button @click="$refs['add'].setId(row.id),$refs['add'].show()" size="small" type="info">
查看
</Button>
<Poptip <Poptip
:transfer="true" :transfer="true"
confirm confirm
@ -161,13 +170,23 @@ export default {
}, },
destroy(id) { destroy(id) {
destroy({ destroy({
id, regulation_menu_id: id,
}).then((_) => { }).then((_) => {
this.getList(); this.getList();
}); });
}, },
}, },
computed: {}, computed: {
pidFormat() {
return [
{
id: 0,
name: "根结点",
children: this.list
}
]
}
},
created() { created() {
this.getList(); this.getList();
}, },

Loading…
Cancel
Save