xy 2 years ago
parent 625494b3d5
commit fb67f3b60f

@ -26,19 +26,16 @@
<div class="xy-table-item">
<div class="xy-table-item-label">目录 </div>
<div class="xy-table-item-content">
<el-select
v-model="form.menu_id"
<el-cascader
:key="cascaderId_pid"
clearable
placeholder="请选择目录"
style="width: 300px"
>
<el-option
v-for="item in menu_ids"
:key="item.id"
:label="item.value"
:value="item.id"
></el-option>
</el-select>
:show-all-levels="false"
:value="form.menu_id"
:options="menu_ids"
:props="{ value: 'id', label: 'name', checkStrictly: true }"
@change="pidCascaderHandler"
></el-cascader>
</div>
</div>
</template>
@ -125,6 +122,7 @@ export default {
},
data() {
return {
cascaderId_pid: 0,
isShow: false,
id: "",
type: "",
@ -209,14 +207,20 @@ export default {
},
async getDetail() {
const res = await show({ id: this.id });
const res = await show({ regulation_article_id: this.id });
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() {
this.form.file_list = this.file_list.map(i => i.response?.id)
if (this.type === "add") {
if (this.form.hasOwnProperty("id")) {
delete this.form.id;
if (this.form.hasOwnProperty("regulation_article_id")) {
delete this.form.regulation_article_id;
}
store(this.form).then((res) => {
this.$message({
@ -229,7 +233,7 @@ export default {
});
}
if (this.type === "editor") {
Object.defineProperty(this.form, "id", {
Object.defineProperty(this.form, "regulation_article_id", {
value: this.id,
enumerable: 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: {
isShow(val) {
@ -256,11 +267,15 @@ export default {
} else {
this.id = "";
this.type = "";
this.file_list = [];
this.init();
this.$refs["dialog"].clearValidate();
delete this.form.id;
delete this.form.regulation_article_id;
}
},
menu_ids() {
++this.cascaderId_pid;
},
},
};
</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 @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>
<Poptip
@ -102,22 +102,28 @@
/>
</div>
<add ref="add" :pids="list" @refresh="getList"></add>
<add ref="add" :menu_ids="menus" @refresh="getList"></add>
<drawer ref="drawer"></drawer>
</div>
</template>
<script>
import add from "./component/addFile.vue"
import drawer from "./component/drawer.vue"
import { index, destroy } from "@/api/sysManage/article"
import { index as menuIndex } from "@/api/sysManage/menu"
export default {
components: {
add
add,
drawer
},
data() {
return {
menus: [],
total: 0,
select: {
show_tree: 1,
page: 1,
page_size: 10,
type: ""
},
@ -129,6 +135,11 @@ export default {
width: 180,
fixed: "left",
},
{
prop: "menu.name",
label: "目录",
width: 140
},
{
prop: "type",
label: "类型",
@ -153,6 +164,13 @@ export default {
};
},
methods: {
async getMenus () {
this.menus = await menuIndex({
show_tree: 1,
type: ""
})
},
init() {
for (let key in this.select) {
if (this.select[key] instanceof Array) {
@ -172,14 +190,16 @@ export default {
},
destroy(id) {
destroy({
id,
regulation_article_id: id,
}).then((_) => {
this.getList();
});
},
},
computed: {},
computed: {
},
created() {
this.getMenus();
this.getList();
},
};

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

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

Loading…
Cancel
Save