| | |
| | | <template> |
| | | <basic-container> |
| | | <basic-container class="hasButTwo"> |
| | | <avue-crud |
| | | :option="optionParent" |
| | | :table-loading="loading" |
| | |
| | | v-if="permission.dict_delete" |
| | | plain |
| | | @click="handleDelete" |
| | | >删 除 |
| | | >删 除 |
| | | </el-button> |
| | | </template> |
| | | <template slot-scope="scope" slot="menu"> |
| | |
| | | size="small" |
| | | @click.stop="handleRowClick(scope.row)" |
| | | v-if="userInfo.role_name.includes('admin')" |
| | | >字典配置 |
| | | >字典配置 |
| | | </el-button> |
| | | </template> |
| | | <template slot-scope="{row}" slot="code"> |
| | | <el-tag @click="handleRowClick(row)" style="cursor:pointer">{{ row.code }}</el-tag> |
| | | <template slot-scope="{ row }" slot="code"> |
| | | <el-tag @click="handleRowClick(row)" style="cursor: pointer">{{ |
| | | row.code |
| | | }}</el-tag> |
| | | </template> |
| | | <template slot-scope="{row}" slot="isSealed"> |
| | | <el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag> |
| | | <template slot-scope="{ row }" slot="isSealed"> |
| | | <el-tag>{{ row.isSealed === 0 ? "否" : "是" }}</el-tag> |
| | | </template> |
| | | </avue-crud> |
| | | <el-dialog :title="`[${dictValue}]字典配置`" |
| | | append-to-body |
| | | :visible.sync="box" |
| | | width="1000px"> |
| | | <el-dialog |
| | | :title="`[${dictValue}]字典配置`" |
| | | append-to-body |
| | | :visible.sync="box" |
| | | width="1000px" |
| | | > |
| | | <avue-crud |
| | | :option="optionChild" |
| | | :table-loading="loadingChild" |
| | |
| | | v-if="permission.dict_delete" |
| | | plain |
| | | @click="handleDelete" |
| | | >删 除 |
| | | >删 除 |
| | | </el-button> |
| | | </template> |
| | | <template slot-scope="scope" slot="menu"> |
| | |
| | | type="text" |
| | | icon="el-icon-circle-plus-outline" |
| | | size="small" |
| | | @click.stop="handleAdd(scope.row,scope.index)" |
| | | @click.stop="handleAdd(scope.row, scope.index)" |
| | | v-if="userInfo.role_name.includes('admin')" |
| | | >新增子项 |
| | | >新增子项 |
| | | </el-button> |
| | | </template> |
| | | <template slot-scope="{row}" slot="isSealed"> |
| | | <el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag> |
| | | <template slot-scope="{ row }" slot="isSealed"> |
| | | <el-tag>{{ row.isSealed === 0 ? "否" : "是" }}</el-tag> |
| | | </template> |
| | | </avue-crud> |
| | | </el-dialog> |
| | |
| | | update, |
| | | add, |
| | | getDict, |
| | | getDictTree |
| | | getDictTree, |
| | | } from "@/api/system/dict"; |
| | | import {optionParent, optionChild} from "@/option/system/dict"; |
| | | import {mapGetters} from "vuex"; |
| | | import { optionParent, optionChild } from "@/option/system/dict"; |
| | | import { mapGetters } from "vuex"; |
| | | |
| | | export default { |
| | | data() { |
| | | return { |
| | | dictValue: '暂无', |
| | | dictValue: "暂无", |
| | | parentId: -1, |
| | | formParent: {}, |
| | | formChild: {}, |
| | |
| | | pageSize: 10, |
| | | pageSizes: [10, 30, 50, 100, 200], |
| | | currentPage: 1, |
| | | total: 0 |
| | | total: 0, |
| | | }, |
| | | pageChild: { |
| | | pageSize: 10, |
| | | pageSizes: [10, 30, 50, 100, 200], |
| | | currentPage: 1, |
| | | total: 0 |
| | | total: 0, |
| | | }, |
| | | dataParent: [], |
| | | dataChild: [], |
| | |
| | | }, |
| | | ids() { |
| | | let ids = []; |
| | | this.selectionList.forEach(ele => { |
| | | this.selectionList.forEach((ele) => { |
| | | ids.push(ele.id); |
| | | }); |
| | | return ids.join(","); |
| | | } |
| | | }, |
| | | }, |
| | | mounted() { |
| | | this.initData(); |
| | | }, |
| | | methods: { |
| | | initData() { |
| | | getDictTree().then(res => { |
| | | getDictTree().then((res) => { |
| | | const column = this.findObject(this.optionChild.column, "parentId"); |
| | | column.dicData = res.data.data; |
| | | }); |
| | |
| | | ...row, |
| | | dictKey: -1, |
| | | }; |
| | | add(form).then(() => { |
| | | this.onLoadParent(this.pageParent); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "操作成功!" |
| | | }); |
| | | done(); |
| | | }, error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | }); |
| | | add(form).then( |
| | | () => { |
| | | this.onLoadParent(this.pageParent); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "操作成功!", |
| | | }); |
| | | done(); |
| | | }, |
| | | (error) => { |
| | | window.console.log(error); |
| | | loading(); |
| | | } |
| | | ); |
| | | }, |
| | | rowUpdate(row, index, done, loading) { |
| | | update(row).then(() => { |
| | | this.onLoadParent(this.pageParent); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "操作成功!" |
| | | }); |
| | | this.onLoadChild(this.pageChild); |
| | | done(); |
| | | }, error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | }); |
| | | update(row).then( |
| | | () => { |
| | | this.onLoadParent(this.pageParent); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "操作成功!", |
| | | }); |
| | | this.onLoadChild(this.pageChild); |
| | | done(); |
| | | }, |
| | | (error) => { |
| | | window.console.log(error); |
| | | loading(); |
| | | } |
| | | ); |
| | | }, |
| | | rowDel(row) { |
| | | this.$confirm("确定将选择数据删除?", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning" |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | return remove(row.id); |
| | |
| | | this.onLoadParent(this.pageParent); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "操作成功!" |
| | | message: "操作成功!", |
| | | }); |
| | | }); |
| | | }, |
| | |
| | | this.$confirm("确定将选择数据删除?", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning" |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | return remove(this.ids); |
| | |
| | | this.onLoadParent(this.pageParent); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "操作成功!" |
| | | message: "操作成功!", |
| | | }); |
| | | this.$refs.crud.toggleSelection(); |
| | | }); |
| | | }, |
| | | beforeOpen(done, type) { |
| | | if (["edit", "view"].includes(type)) { |
| | | getDict(this.formParent.id).then(res => { |
| | | getDict(this.formParent.id).then((res) => { |
| | | this.formParent = res.data.data; |
| | | }); |
| | | } |
| | |
| | | this.onLoadParent(this.pageParent, this.query); |
| | | }, |
| | | rowSaveChild(row, done, loading) { |
| | | add(row).then(() => { |
| | | this.onLoadChild(this.pageChild); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "操作成功!" |
| | | }); |
| | | done(); |
| | | }, error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | }); |
| | | add(row).then( |
| | | () => { |
| | | this.onLoadChild(this.pageChild); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "操作成功!", |
| | | }); |
| | | done(); |
| | | }, |
| | | (error) => { |
| | | window.console.log(error); |
| | | loading(); |
| | | } |
| | | ); |
| | | }, |
| | | rowUpdateChild(row, index, done, loading) { |
| | | update(row).then(() => { |
| | | this.onLoadChild(this.pageChild); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "操作成功!" |
| | | }); |
| | | done(); |
| | | }, error => { |
| | | window.console.log(error); |
| | | loading(); |
| | | }); |
| | | update(row).then( |
| | | () => { |
| | | this.onLoadChild(this.pageChild); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "操作成功!", |
| | | }); |
| | | done(); |
| | | }, |
| | | (error) => { |
| | | window.console.log(error); |
| | | loading(); |
| | | } |
| | | ); |
| | | }, |
| | | rowDelChild(row) { |
| | | this.$confirm("确定将选择数据删除?", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning" |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | return remove(row.id); |
| | |
| | | this.onLoadChild(this.pageChild); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "操作成功!" |
| | | message: "操作成功!", |
| | | }); |
| | | }); |
| | | }, |
| | |
| | | this.$confirm("确定将选择数据删除?", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning" |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | return remove(this.ids); |
| | |
| | | this.onLoadChild(this.pageChild); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "操作成功!" |
| | | message: "操作成功!", |
| | | }); |
| | | this.$refs.crudChild.toggleSelection(); |
| | | }); |
| | |
| | | this.initData(); |
| | | } |
| | | if (["edit", "view"].includes(type)) { |
| | | getDict(this.formChild.id).then(res => { |
| | | getDict(this.formChild.id).then((res) => { |
| | | this.formChild = res.data.data; |
| | | }); |
| | | } |
| | |
| | | }, |
| | | beforeCloseChild(done) { |
| | | this.$refs.crudChild.value.parentId = this.parentId; |
| | | this.$refs.crudChild.option.column.filter(item => { |
| | | this.$refs.crudChild.option.column.filter((item) => { |
| | | if (item.prop === "parentId") { |
| | | item.value = this.parentId; |
| | | } |
| | |
| | | page.currentPage, |
| | | page.pageSize, |
| | | Object.assign(params, this.query) |
| | | ).then(res => { |
| | | ).then((res) => { |
| | | const data = res.data.data; |
| | | this.pageParent.total = data.total; |
| | | this.dataParent = data.records; |
| | |
| | | page.pageSize, |
| | | this.parentId, |
| | | Object.assign(params, this.query) |
| | | ).then(res => { |
| | | ).then((res) => { |
| | | this.dataChild = res.data.data; |
| | | this.loadingChild = false; |
| | | this.selectionClear(); |
| | | }); |
| | | } |
| | | } |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |
| | | |