¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div class="menu-container"> |
| | | <!-- <el-input/> --> |
| | | <vol-box |
| | | :width="940" |
| | | :mask="true" |
| | | :height="500" |
| | | title="徿 å表" |
| | | v-model="model" |
| | | > |
| | | <Icons :onSelect="onSelect"></Icons> |
| | | <template #footer> |
| | | <el-button type="primary" size="mini" @click="model = false" |
| | | >确 认</el-button |
| | | > |
| | | </template> |
| | | </vol-box> |
| | | <vol-box |
| | | :width="600" |
| | | :mask="true" |
| | | :height="270" |
| | | title="å
¶ä»æé" |
| | | v-model="actionModel" |
| | | > |
| | | <vol-form |
| | | ref="actionForm" |
| | | :formRules="actionOptions" |
| | | :formFields="actionFields" |
| | | > |
| | | <template #header> |
| | | <div> |
| | | <el-alert show-icon type="success"> |
| | | é
ç½®çå
¶ä»æé |
| | | <br />1ãæ·»å æ°çæéå请å¨vue项ç®ä¸configæä»¶å¤¹ä¸buttns.jsæ·»å æ¤æéçæé®ã |
| | | <br />2ã妿æéåªå¨æå°æ°å 个åè½ä¸ä½¿ç¨,å¨vueç对åºé¡µé¢æ©å±extensionæä»¶æ¾å°å¯¹åºjs,æ·»å å°el-buttons对象ä¸,æ ¼å¼åconfigæä»¶å¤¹ä¸buttns.js䏿 ·ã |
| | | </el-alert> |
| | | </div> |
| | | </template> |
| | | </vol-form> |
| | | <template #footer> |
| | | <el-button type="primary" size="mini" @click="otherAction" |
| | | >确 认</el-button |
| | | > |
| | | </template> |
| | | </vol-box> |
| | | |
| | | <!-- v-if="tree.length" --> |
| | | <div class="menu-left"> |
| | | <div class="m-title"><i class="el-icon-warning-outline"></i>èåå表</div> |
| | | <el-scrollbar style="height: 100%; width: 200px"> |
| | | <VolMenu |
| | | :onSelect="getTreeItem" |
| | | :list="tree" |
| | | :isCollapse="false" |
| | | ></VolMenu> |
| | | </el-scrollbar> |
| | | </div> |
| | | <div class="menu-right"> |
| | | <el-scrollbar style="height: 100%"> |
| | | <el-alert |
| | | title="èåé
置说æ" |
| | | type="warning" |
| | | :closable="false" |
| | | show-icon |
| | | > |
| | | <div> |
| | | 1ã妿æ¯ç¨ä»£ç çå¨çæçVue页é¢,Url为Vue项ç®ä¸src->router->viewGrid.js对åºè¡¨åçpath屿§ |
| | | </div> |
| | | <div style="padding-top: 5px"> |
| | | 2ã å¦æåªæ¯å»ºä¸çº§èåæç©ºèåurlä¸ç¨å¡«å,ãè§å¾/表åãå¡«å.æè
/ |
| | | </div> |
| | | </el-alert> |
| | | <div style="padding: 0px 30px 0 20px"> |
| | | <vol-form |
| | | class="form-content" |
| | | ref="form" |
| | | :formRules="options" |
| | | :formFields="fields" |
| | | > |
| | | </vol-form> |
| | | <div> |
| | | <div class="auth-group"> |
| | | <label style="width: 100px">æéæé®ï¼</label> |
| | | <div class="ck"> |
| | | <el-checkbox-group v-model="actions"> |
| | | <el-checkbox |
| | | v-for="(item, index) in action" |
| | | :key="index" |
| | | :label="item.value" |
| | | >{{ item.text + "(" + item.value + ")" }}</el-checkbox |
| | | > |
| | | </el-checkbox-group> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div style="padding-left: 100px"> |
| | | <el-button @click="handleCheckAll" size="mini" type="success" plain |
| | | ><i class="el-icon-check"></i>å
¨ é</el-button |
| | | > |
| | | <el-button |
| | | @click="actionModel = true" |
| | | size="mini" |
| | | type="primary" |
| | | plain |
| | | ><i class="el-icon-plus"></i>å
¶ä»æé</el-button |
| | | > |
| | | </div> |
| | | <div class="m-btn"> |
| | | <el-button type="primary" @click="save" |
| | | ><i class="el-icon-check"></i>ä¿å</el-button |
| | | > |
| | | <el-button type="success" @click="add" |
| | | ><i class="el-icon-plus"></i>æ°å»º</el-button |
| | | > |
| | | <el-button type="warning" @click="addChild" |
| | | ><i class="el-icon-plus"></i>æ·»å å级</el-button |
| | | > |
| | | <el-button type="primary" plain @click="addBrother" |
| | | ><i class="el-icon-circle-plus"></i> æ·»å å级</el-button |
| | | > |
| | | <el-button type="warning" plain @click="delMenu" |
| | | ><i class="el-icon-delete"></i> å é¤èå</el-button |
| | | > |
| | | </div> |
| | | </div> |
| | | </el-scrollbar> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | <script> |
| | | import VolForm from "@/components/basic/VolForm.vue"; |
| | | import VolBox from "@/components/basic/VolBox.vue"; |
| | | import Icons from "@/components/basic/Icons.vue"; |
| | | import VolMenu from "@/components/basic/VolElementMenu.vue"; |
| | | import { |
| | | defineComponent, |
| | | reactive, |
| | | ref, |
| | | toRefs, |
| | | onMounted, |
| | | h, |
| | | resolveComponent, |
| | | } from "vue"; |
| | | |
| | | import http from "@/api/http"; |
| | | export default defineComponent({ |
| | | components: { |
| | | VolForm: VolForm, |
| | | VolBox: VolBox, |
| | | Icons: Icons, |
| | | VolMenu, |
| | | }, |
| | | methods: { |
| | | otherAction() { |
| | | this.$refs.actionForm.validate(() => { |
| | | let exist = this.action.some((x) => { |
| | | return ( |
| | | x.text == this.actionFields.name || |
| | | x.value == this.actionFields.value |
| | | ); |
| | | }); |
| | | if (exist) { |
| | | return this.$message.error("æéåç§°ææéå¼å·²åå¨"); |
| | | } |
| | | this.actionModel = false; |
| | | this.action.push({ |
| | | text: this.actionFields.name, |
| | | value: this.actionFields.value, |
| | | }); |
| | | }); |
| | | }, |
| | | handleCheckAll() { |
| | | if (this.actions == this.action.length) { |
| | | this.checkAll = false; |
| | | } else { |
| | | this.checkAll = !this.checkAll; |
| | | } |
| | | if (this.checkAll) { |
| | | this.actions = this.action.map((x) => { |
| | | return x.value; |
| | | }); |
| | | } else { |
| | | this.actions = []; |
| | | } |
| | | }, |
| | | checkAllGroupChange(data) { |
| | | if (data.length === this.action.length) { |
| | | this.checkAll = true; |
| | | } else if (data.length > 0) { |
| | | this.checkAll = false; |
| | | } else { |
| | | this.checkAll = false; |
| | | } |
| | | }, |
| | | add(obj) { |
| | | this.$refs.form.reset( |
| | | Object.assign({ enable: 1 }, obj || { parentId: 0 }) |
| | | ); |
| | | this.icon = ""; |
| | | // this.actions = []; |
| | | //2020.08.07æ°å»ºèåæ¶ï¼é»è®¤é䏿¥è¯¢æé®æé |
| | | this.actions = ["Search"]; |
| | | }, |
| | | addChild() { |
| | | if (!this.isSelect()) return; |
| | | this.add({ parentId: this.fields.menuId }); |
| | | }, |
| | | addBrother() { |
| | | if (!this.isSelect()) return; |
| | | this.add({ parentId: this.fields.parentId }); |
| | | }, |
| | | delMenu() { |
| | | //2020.08.07å¢å èåå é¤åè½ |
| | | if (this.fields.menuId == 0) { |
| | | return this.$Message.error("è¯·éæ©èå"); |
| | | } |
| | | |
| | | let tigger = false; |
| | | this.$confirm( |
| | | "确认è¦å é¤ã" + this.fields.menuName + "ãèååï¼", |
| | | "è¦å", |
| | | { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning", |
| | | center: true, |
| | | } |
| | | ).then(() => { |
| | | if (tigger) return; |
| | | tigger = true; |
| | | let menuId = this.fields.menuId; |
| | | this.http |
| | | .post( |
| | | "/api/Sys_Menu/delMenu?menuId=" + menuId, |
| | | {}, |
| | | "æ£å¨å 餿°æ®...." |
| | | ) |
| | | .then((x) => { |
| | | if (!x.status) return this.$Message.error(x.message); |
| | | this.$refs.form.reset(); |
| | | this.$Message.info(x.message); |
| | | this.initTree(); |
| | | }); |
| | | }); |
| | | }, |
| | | save() { |
| | | this.$refs.form.validate(() => { |
| | | this.fields.auth = ""; |
| | | if (this.actions) { |
| | | this.fields.auth = this.action.filter((x) => { |
| | | return this.actions.indexOf(x.value) != -1; |
| | | }); |
| | | } |
| | | if ( |
| | | this.fields.auth && |
| | | this.fields.auth instanceof Array && |
| | | this.fields.auth.length > 0 |
| | | ) { |
| | | this.fields.auth = JSON.stringify(this.fields.auth); |
| | | } else { |
| | | this.fields.auth = ""; |
| | | } |
| | | this.http.post("/api/Sys_Menu/save", this.fields, true).then((x) => { |
| | | if (!x.status) { |
| | | this.$Message.error(x.message); |
| | | return; |
| | | } |
| | | |
| | | this.$Message.info(x.message); |
| | | if (this.fields.menuId) { |
| | | this.tree.forEach((t) => { |
| | | if (t.id == this.fields.menuId) { |
| | | t.name = this.fields.menuName; |
| | | t.orderNo = this.fields.orderNo; |
| | | t.parentId = this.fields.parentId; |
| | | } |
| | | }); |
| | | return; |
| | | } |
| | | this.fields.menuId = x.data.menuId; |
| | | this.fields.createDate = x.data.createDate; |
| | | this.tree.push({ |
| | | id: x.data.menuId, |
| | | name: this.fields.menuName, |
| | | orderNo: this.fields.orderNo, |
| | | parentId: this.fields.parentId, |
| | | }); |
| | | console.log(this.tree); |
| | | }); |
| | | }); |
| | | }, |
| | | isSelect() { |
| | | let id = this.fields.menuId; |
| | | if (!id) { |
| | | this.$message.error("è¯·éæ©èç¹"); |
| | | return false; |
| | | } |
| | | return true; |
| | | }, |
| | | onSelect(icon) { |
| | | this.fields.icon = icon; |
| | | this.$message.info(icon); |
| | | }, |
| | | onOpenChange(node) { |
| | | if (node.length == 0) return; |
| | | this.getTreeItem(node[node.length > 1 ? node.length - 1 : 0]); |
| | | }, |
| | | }, |
| | | created() {}, |
| | | setup() { |
| | | const tree = ref([]); |
| | | const actionValues = ref([]); |
| | | const action = ref([ |
| | | { text: "æ¥è¯¢", value: "Search" }, |
| | | { text: "æ°å»º", value: "Add" }, |
| | | { text: "å é¤", value: "Delete" }, |
| | | { text: "ç¼è¾", value: "Update" }, |
| | | { text: "导å
¥", value: "Import" }, |
| | | { text: "导åº", value: "Export" }, |
| | | // { text: "ä¸ä¼ ", value: "Upload" }, |
| | | // { text: "å®¡æ ¸", value: "Audit" }, |
| | | ]); |
| | | const actions = ref([]); |
| | | actionValues.value = action.value.map((x) => { |
| | | return x.value; |
| | | }); |
| | | const initTree = () => { |
| | | http.post("/api/Sys_Menu/getMenu", {}, true).then((x) => { |
| | | x.forEach((item) => { |
| | | item.icon = "el-icon-menu"; |
| | | }); |
| | | |
| | | tree.value = x; |
| | | }); |
| | | }; |
| | | onMounted(() => { |
| | | initTree(); |
| | | }); |
| | | const actionModel = ref(false); |
| | | const checkAll = ref(false); |
| | | const model = ref(false); |
| | | |
| | | const fields = ref({ |
| | | menuId: 0, |
| | | parentId: 0, |
| | | menuName: "", |
| | | tableName: "", |
| | | url: "", |
| | | auth: "", |
| | | icon: "", |
| | | orderNo: "", |
| | | enable: 1, |
| | | menuType: 0, |
| | | }); |
| | | |
| | | const actionFields = ref({ |
| | | name: "", |
| | | value: "", |
| | | }); |
| | | const actionOptions = ref([ |
| | | [ |
| | | { |
| | | title: "æéåç§°", |
| | | field: "name", |
| | | placeholder: "æéåç§°,å¦ï¼æ°å¢", |
| | | required: true, |
| | | }, |
| | | ], |
| | | [ |
| | | { |
| | | title: "æ é å¼", |
| | | field: "value", |
| | | placeholder: "æéå¼,å¦ï¼Add", |
| | | required: true, |
| | | }, |
| | | ], |
| | | ]); |
| | | |
| | | const options = ref([ |
| | | [ |
| | | { |
| | | title: "è å ID", |
| | | field: "menuId", |
| | | placeholder: "èåID", |
| | | min: 0, |
| | | disabled: true, |
| | | }, |
| | | { |
| | | title: "ç¶ çº§ ID", |
| | | required: true, |
| | | type: "number", |
| | | min: 0, |
| | | field: "parentId", |
| | | // min: 0, max: 50 |
| | | }, |
| | | { |
| | | title: "èååç§°", |
| | | field: "menuName", |
| | | required: true, |
| | | }, |
| | | ], |
| | | [ |
| | | { |
| | | title: "è§å¾/表å", |
| | | field: "tableName", |
| | | placeholder: "ä¸ä»£ç çæå¨ä½¿ç¨çåç§°ç¸å", |
| | | required: true, |
| | | }, |
| | | { |
| | | title: "(è·¯ç±)Url", |
| | | field: "url", |
| | | placeholder: "è§:ä¸é¢èåé
置说æ", |
| | | }, |
| | | { |
| | | title: "æåºå·", |
| | | field: "orderNo", |
| | | type: "number", |
| | | min: 0, |
| | | placeholder: "å¼è¶å¤§æ¾ç¤ºè¶é å", |
| | | required: true, |
| | | }, |
| | | ], |
| | | [ |
| | | { |
| | | title: "æ¯å¦å¯ç¨", |
| | | field: "enable", |
| | | required: true, |
| | | type: "select", |
| | | colSize: 4, |
| | | data: [ |
| | | { key: 1, value: "å¯ç¨" }, |
| | | { key: 2, value: "å¯ç¨ä¸æ¾ç¤º" }, |
| | | { key: 0, value: "ç¦ç¨" }, |
| | | ], |
| | | }, |
| | | { |
| | | title: "èåç±»å", |
| | | field: "menuType", |
| | | required: true, |
| | | type: "select", |
| | | colSize: 4, |
| | | data: [ |
| | | { key: 0, value: "PC端èå" }, |
| | | { key: 1, value: "ç§»å¨ç«¯èå" }, |
| | | ], |
| | | }, |
| | | { |
| | | title: "徿 Icon", |
| | | field: "icon", |
| | | render: (h) => { |
| | | return h("div", {}, [ |
| | | h("i", { |
| | | style: { |
| | | "font-size": "25px", |
| | | margin: "0px 9px", |
| | | position: "relative", |
| | | top: "4px", |
| | | }, |
| | | class: [fields.value.icon], |
| | | }), |
| | | h( |
| | | resolveComponent("el-button"), |
| | | { |
| | | size: "small", |
| | | style: { padding: "0px 9px" }, |
| | | type: "primary", |
| | | plain: true, |
| | | onClick: () => { |
| | | model.value = true; |
| | | }, |
| | | }, |
| | | "鿩徿 " |
| | | ), |
| | | ]); |
| | | }, |
| | | }, |
| | | ], |
| | | ]); |
| | | const refForm = ref(); |
| | | const getTreeItem = (node) => { |
| | | http |
| | | .post("api/Sys_Menu/getTreeItem?menuId=" + node, {}, true) |
| | | .then((x) => { |
| | | try { |
| | | fields.value.icon = x.icon; |
| | | if (x.auth) { |
| | | x.auth = JSON.parse(x.auth); |
| | | action.value.splice(8, action.value.length); |
| | | |
| | | actions.value = x.auth.map((element) => { |
| | | if (actionValues.value.indexOf(element.value) == -1) { |
| | | action.value.push(element); |
| | | } |
| | | return element.value; |
| | | }); |
| | | } else { |
| | | action.value.splice(8, action.value.length); |
| | | x.auth = []; |
| | | fields.value.icon = ""; |
| | | actions.value = []; |
| | | } |
| | | } catch (error) { |
| | | console.log("èååè½æéè½¬æ¢æJSON失败:" + x.auth); |
| | | x.auth = []; |
| | | // this.icon = ""; |
| | | actions.value = []; |
| | | } |
| | | refForm.value.reset(x); |
| | | }); |
| | | }; |
| | | return { |
| | | tree, |
| | | initTree, |
| | | action, |
| | | actions, |
| | | actionValues, |
| | | actionModel, |
| | | checkAll, |
| | | model, |
| | | fields, |
| | | actionFields, |
| | | actionOptions, |
| | | options, |
| | | form: refForm, |
| | | getTreeItem, |
| | | }; |
| | | }, |
| | | data() { |
| | | return {}; |
| | | }, |
| | | }); |
| | | </script> |
| | | |
| | | <style lang="less" scoped> |
| | | .on-icon { |
| | | line-height: 20px; |
| | | position: relative; |
| | | |
| | | .remove { |
| | | display: none; |
| | | color: red; |
| | | right: 7px; |
| | | position: absolute; |
| | | top: -14px; |
| | | font-size: 13px; |
| | | } |
| | | } |
| | | |
| | | .on-icon:hover { |
| | | cursor: pointer; |
| | | |
| | | .remove { |
| | | display: block; |
| | | } |
| | | } |
| | | |
| | | .action { |
| | | width: 100%; |
| | | display: flex; |
| | | |
| | | margin-bottom: 15px; |
| | | |
| | | .ivu-checkbox-wrapper { |
| | | margin-right: 20px; |
| | | } |
| | | |
| | | .ck { |
| | | line-height: 33px; |
| | | display: inline-block; |
| | | display: flex; |
| | | |
| | | label:first-child { |
| | | min-width: 58px; |
| | | float: left; |
| | | margin-top: 1px; |
| | | } |
| | | |
| | | > div { |
| | | float: left; |
| | | } |
| | | } |
| | | } |
| | | |
| | | .menu-container { |
| | | display: flex; |
| | | position: absolute; |
| | | width: 100%; |
| | | height: 100%; |
| | | padding: 8px; |
| | | background: #f7f7f7; |
| | | |
| | | .menu-left { |
| | | height: 100%; |
| | | width: 201px; |
| | | border: 1px solid #eee; |
| | | display: flex; |
| | | background: white; |
| | | flex-direction: column; |
| | | |
| | | .module-name { |
| | | border-radius: 0px; |
| | | /* height: 5%; */ |
| | | line-height: 21px; |
| | | margin-bottom: 0; |
| | | } |
| | | } |
| | | |
| | | .menu-right { |
| | | flex: 1; |
| | | border-radius: 3px; |
| | | border: 1px solid #eee; |
| | | background: white; |
| | | margin-left: 9px; |
| | | margin-right: 3px; |
| | | } |
| | | } |
| | | |
| | | .m-btn { |
| | | margin-top: 20px; |
| | | text-align: center; |
| | | } |
| | | |
| | | .m-title { |
| | | line-height: 40px; |
| | | font-size: 15px; |
| | | background: #66b1ff0f; |
| | | font-weight: bold; |
| | | padding: 6px 16px; |
| | | border-bottom: 1px solid #eee; |
| | | |
| | | i { |
| | | padding-right: 5px; |
| | | } |
| | | } |
| | | |
| | | .form-content { |
| | | margin-top: 30px; |
| | | } |
| | | |
| | | .menu-left ::v-deep(.el-scrollbar__bar.is-vertical) { |
| | | width: 2px; |
| | | } |
| | | |
| | | .auth-group { |
| | | display: flex; |
| | | |
| | | label { |
| | | display: inline-block; |
| | | width: 100px; |
| | | text-align: right; |
| | | color: #797979; |
| | | font-size: 14px; |
| | | } |
| | | |
| | | .ck { |
| | | flex: 1; |
| | | } |
| | | |
| | | .el-checkbox { |
| | | min-width: 105px; |
| | | width: auto !important; |
| | | margin-right: 5px; |
| | | display: inline-block; |
| | | padding-bottom: 10px; |
| | | } |
| | | } |
| | | |
| | | .auth-group ::v-deep(.el-checkbox__label) { |
| | | padding-left: 4px; |
| | | } |
| | | </style> |
| | | |