基础分类修改

This commit is contained in:
2023-03-17 18:21:21 +08:00
parent 801162e0e4
commit 33f27bfc81
8 changed files with 246 additions and 117 deletions

View File

@@ -2,33 +2,49 @@
<div class="app-container">
<!--工具栏-->
<div class="head-container">
<el-row>
<el-col :span="8">
<el-row>
<el-col :span="9">
<span style="line-height:36px;text-align: center">基础分类</span>
</el-col>
<el-col :span="15">
<el-select
v-model="query.base_data_type"
placeholder="请选择"
>
<el-option
v-for="item in dict.base_data"
:key="item.id"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-col>
</el-row>
</el-col>
<el-col :span="4">
<rrOperation />
</el-col>
</el-row>
<div v-if="crud.props.searchToggle">
<!-- 搜索 -->
<el-form
:inline="true"
class="demo-form-inline"
label-position="right"
label-width="90px"
label-suffix=":"
>
<el-form-item label="分类名称">
<el-select
v-model="query.class_code"
placeholder="请选择分类名称"
clearable
filterable
size="mini"
class="filter-item"
style="width: 185px;"
@change="hand">
<el-option
v-for="item in classNames"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<rrOperation :crud="crud" />
</el-form>
</div>
<!--如果想在工具栏加入更多按钮可以使用插槽方式 slot = 'left' or 'right'-->
<crudOperation :permission="permission" />
<crudOperation :permission="permission">
<el-button
slot="right"
class="filter-item"
size="mini"
type="success"
icon="el-icon-s-operation"
@click="ToExpandall"
>
全部展开
</el-button>
</crudOperation>
<!--表单组件-->
<el-dialog
:close-on-click-modal="false"
@@ -44,21 +60,6 @@
<el-form-item label="分类名称" prop="class_name">
<el-input v-model="form.class_name" style="width: 370px;" />
</el-form-item>
<el-form-item label="基础分类" prop="base_data_type">
<el-select
v-model="form.base_data_type"
placeholder=""
@change="dataTypeChange"
>
<el-option
v-for="item in dict.base_data"
:key="item.id"
:label="item.label"
:value="item.value"
/>
</el-select>
<span style="color: #C0C0C0;margin-left: 10px;" />
</el-form-item>
<el-form-item label="简要描述" prop="class_desc">
<el-input v-model="form.class_desc" style="width: 370px;" />
</el-form-item>
@@ -105,17 +106,20 @@
<el-table-column
v-permission="['admin','Classstandard:edit','Classstandard:del']"
label="操作"
width="150px"
width="250px"
align="center"
>
<template slot-scope="scope">
<udOperation
style="display: inline"
:data="scope.row"
:permission="permission"
:disabled-edit="scope.row.is_modify === '0'"
:disabled-dle="scope.row.is_modify === '0'"
msg="确定删除吗,如果存在下级节点则一并删除此操作不能撤销"
/>
<el-button slot="right" size="mini" type="text" icon="el-icon-circle-plus-outline" @click="crud.toAddAndData(addSibling(scope.row))">新增同级</el-button>
<el-button slot="right" size="mini" type="text" icon="el-icon-circle-plus" @click="crud.toAddAndData(addChildren(scope.row))">新增子级</el-button>
</template>
</el-table-column>
</el-table>
@@ -135,7 +139,7 @@ import udOperation from '@crud/UD.operation'
import rrOperation from '@crud/RR.operation'
import pagination from '@crud/Pagination'
const defaultForm = {
let defaultForm = {
class_id: null,
base_data_type: null,
path_code: null,
@@ -180,14 +184,12 @@ export default {
data() {
return {
classes: [],
classNames: [],
permission: {},
rules: {
class_id: [
{ required: true, message: '不能为空', trigger: 'blur' }
],
base_data_type: [
{ required: true, message: '不能为空', trigger: 'blur' }
],
path_code: [
{ required: true, message: '不能为空', trigger: 'blur' }
],
@@ -218,7 +220,15 @@ export default {
}
}
},
created() {
this.getClassNames() // 获取分类
},
methods: {
getClassNames() {
crudClassstandard.getClassName().then((res) => { // 获取分类名称,查询根据分类编码查找对应分支树
this.classNames = res
})
},
getClassDatas(tree, treeNode, resolve) {
const params = { pid: tree.id }
setTimeout(() => {
@@ -318,6 +328,72 @@ export default {
}, 100)
})
}
},
clearFrom() {
defaultForm = {
id: null,
class_id: null,
base_data_type: null,
path_code: null,
class_code: null,
long_class_code: null,
class_name: null,
class_desc: null,
parent_class_id: null,
is_leaf: null,
sub_count: null,
is_modify: null,
is_delete: null,
class_level: null,
ext_id: null,
ext_parent_id: null,
create_id: null,
create_name: null,
create_time: null,
update_optid: null,
update_optname: null,
update_time: null,
isTop: null
}
},
addSibling(row) {
this.clearFrom() // 将默认的表单数据清除
defaultForm.id = row.id // 获取分类树的id - 懒加载依赖此id不可为空
defaultForm.class_id = row.class_id
defaultForm.parent_class_id = row.parent_class_id // 同级为父类class_id
defaultForm.isTop = row.isTop
return defaultForm
},
addChildren(row) {
this.clearFrom()
defaultForm.id = row.id // 获取分类树的id
defaultForm.class_id = row.parent_class_id
defaultForm.parent_class_id = row.id // 子级为本身的class_id
defaultForm.isTop = row.isTop
return defaultForm
},
// 全部展开 参考https://www.cnblogs.com/toughy/p/12667805.html
ToExpandall() {
const els = document.getElementsByClassName('el-table__expand-icon')
if (this.crud.data.length !== 0 && els.length !== 0) {
for (let j1 = 0; j1 < els.length; j1++) {
els[j1].classList.add('dafult')
}
if (this.$el.getElementsByClassName('el-table__expand-icon--expanded')) {
const open = this.$el.getElementsByClassName('el-table__expand-icon--expanded')
for (let j = 0; j < open.length; j++) {
open[j].classList.remove('dafult')
}
const dafult = this.$el.getElementsByClassName('dafult')
for (let a = 0; a < dafult.length; a++) {
debugger
dafult[a].click()
}
}
}
},
hand(value) {
this.crud.toQuery()
}
}
}