|
@@ -1,172 +1,170 @@
|
|
<template>
|
|
<template>
|
|
- <div>
|
|
|
|
- <a-modal class="modalBox" :title="titleText" v-model="isshow" @cancle="cancel" width="45%">
|
|
|
|
- <a-form :form="form" @submit="handleSubmit">
|
|
|
|
- <!-- 用户名称 -->
|
|
|
|
- <a-form-item label="角色名称" :label-col="{ span: 5 }" :wrapper-col="{ span: 14 }">
|
|
|
|
- <a-input
|
|
|
|
- placeholder="请输入角色名称30个字以内"
|
|
|
|
- allowClear
|
|
|
|
- id="roleModal-name"
|
|
|
|
- v-decorator="['formData.name', {
|
|
|
|
|
|
+ <div>
|
|
|
|
+ <a-modal class="modalBox" :title="titleText" v-model="isshow" @cancle="cancel" width="45%">
|
|
|
|
+ <a-form :form="form" @submit="handleSubmit">
|
|
|
|
+ <!-- 用户名称 -->
|
|
|
|
+ <a-form-item label="角色名称" :label-col="{ span: 5 }" :wrapper-col="{ span: 14 }">
|
|
|
|
+ <a-input
|
|
|
|
+ placeholder="请输入角色名称30个字以内"allowClear :maxLength="30"
|
|
|
|
+ id="roleModal-name" v-decorator="['formData.name', {
|
|
initialValue: formData.name,
|
|
initialValue: formData.name,
|
|
- rules: [{ required: true, message: '请输入角色名称30个字以内!' },{pattern:'^[^<|>]{1,30}$',message:'请输入不含<或>的字符,最多30个字符'}] }]"
|
|
|
|
- />
|
|
|
|
- </a-form-item>
|
|
|
|
- <!-- 状态 -->
|
|
|
|
- <a-form-item label="状态" :label-col="{ span: 5 }" :wrapper-col="{ span: 14 }">
|
|
|
|
- <a-radio-group
|
|
|
|
- name="radioGroup"
|
|
|
|
- id="roleModal-isEnable"
|
|
|
|
- v-decorator="[
|
|
|
|
|
|
+ rules: [{ required: true, message: '请输入角色名称30个字以内!' },{pattern:'^[^<|>]{1,30}$',message:'请输入不含<或>的字符,最多30个字符'}] }]" />
|
|
|
|
+ </a-form-item>
|
|
|
|
+ <!-- 状态 -->
|
|
|
|
+ <a-form-item label="状态" :label-col="{ span: 5 }" :wrapper-col="{ span: 14 }">
|
|
|
|
+ <a-radio-group name="radioGroup" id="roleModal-isEnable" v-decorator="[
|
|
'formData.isEnable',
|
|
'formData.isEnable',
|
|
{
|
|
{
|
|
initialValue: formData.isEnable,
|
|
initialValue: formData.isEnable,
|
|
rules: [{ required: true, message: '请选择状态!' }] },
|
|
rules: [{ required: true, message: '请选择状态!' }] },
|
|
- ]"
|
|
|
|
- >
|
|
|
|
- <a-radio :value="1">启用</a-radio>
|
|
|
|
- <a-radio :value="0">禁用</a-radio>
|
|
|
|
- </a-radio-group>
|
|
|
|
- </a-form-item>
|
|
|
|
- <a-form-item label="角色描述" :label-col="{ span: 5 }" :wrapper-col="{ span: 14 }">
|
|
|
|
- <a-textarea
|
|
|
|
- id="roleModal-remarks"
|
|
|
|
- v-decorator="[
|
|
|
|
|
|
+ ]">
|
|
|
|
+ <a-radio :value="1">启用</a-radio>
|
|
|
|
+ <a-radio :value="0">禁用</a-radio>
|
|
|
|
+ </a-radio-group>
|
|
|
|
+ </a-form-item>
|
|
|
|
+ <a-form-item label="角色描述" :label-col="{ span: 5 }" :wrapper-col="{ span: 14 }">
|
|
|
|
+ <a-textarea id="roleModal-remarks" v-decorator="[
|
|
'formData.remarks',
|
|
'formData.remarks',
|
|
{ initialValue: formData.remarks,
|
|
{ initialValue: formData.remarks,
|
|
rules: [] },
|
|
rules: [] },
|
|
]"
|
|
]"
|
|
- style="min-height: 60px;"
|
|
|
|
- placeholder="输入内容512个字以内"
|
|
|
|
- :maxLength="512"
|
|
|
|
- autosize />
|
|
|
|
- </a-form-item>
|
|
|
|
|
|
+ style="min-height: 60px;" placeholder="输入内容512个字以内" :maxLength="512" autosize />
|
|
|
|
+ </a-form-item>
|
|
|
|
|
|
- <a-form-item :wrapper-col="{ span: 12, offset: 5 }">
|
|
|
|
- <a-button type="primary" @click="handleSubmit()" id="roleModal-handleSubmit">
|
|
|
|
- 保存
|
|
|
|
- </a-button>
|
|
|
|
- <a-button :style="{ marginLeft: '8px' }" @click="handleCancel()" id="roleModal-handleCancel">
|
|
|
|
- 取消
|
|
|
|
- </a-button>
|
|
|
|
- </a-form-item>
|
|
|
|
- </a-form>
|
|
|
|
|
|
+ <a-form-item :wrapper-col="{ span: 12, offset: 5 }">
|
|
|
|
+ <a-button type="primary" @click="handleSubmit()" id="roleModal-handleSubmit">
|
|
|
|
+ 保存
|
|
|
|
+ </a-button>
|
|
|
|
+ <a-button :style="{ marginLeft: '8px' }" @click="handleCancel()" id="roleModal-handleCancel">
|
|
|
|
+ 取消
|
|
|
|
+ </a-button>
|
|
|
|
+ </a-form-item>
|
|
|
|
+ </a-form>
|
|
|
|
|
|
- </a-modal>
|
|
|
|
- </div>
|
|
|
|
|
|
+ </a-modal>
|
|
|
|
+ </div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-import { STable, VSelect } from '@/components'
|
|
|
|
-import { saveRolePower } from '@/api/power-role.js'
|
|
|
|
-export default {
|
|
|
|
- name: 'RoleModal',
|
|
|
|
- components: {
|
|
|
|
- STable, VSelect
|
|
|
|
- },
|
|
|
|
- props: {
|
|
|
|
- visible: {
|
|
|
|
- type: Boolean,
|
|
|
|
- default: false
|
|
|
|
- },
|
|
|
|
- data: {
|
|
|
|
- type: Object,
|
|
|
|
- default: function () {
|
|
|
|
- return {}
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- data () {
|
|
|
|
- return {
|
|
|
|
- titleText: '添加角色',
|
|
|
|
- isshow: this.visible,
|
|
|
|
- formLayout: 'horizontal',
|
|
|
|
- form: this.$form.createForm(this, { name: 'roleModal' }),
|
|
|
|
- formData: {
|
|
|
|
- name: '',
|
|
|
|
- isEnable: '', // 活动状态
|
|
|
|
- remarks: ''
|
|
|
|
- }
|
|
|
|
|
|
+ import {
|
|
|
|
+ STable,
|
|
|
|
+ VSelect
|
|
|
|
+ } from '@/components'
|
|
|
|
+ import {
|
|
|
|
+ saveRolePower
|
|
|
|
+ } from '@/api/power-role.js'
|
|
|
|
+ export default {
|
|
|
|
+ name: 'RoleModal',
|
|
|
|
+ components: {
|
|
|
|
+ STable,
|
|
|
|
+ VSelect
|
|
|
|
+ },
|
|
|
|
+ props: {
|
|
|
|
+ visible: {
|
|
|
|
+ type: Boolean,
|
|
|
|
+ default: false
|
|
|
|
+ },
|
|
|
|
+ data: {
|
|
|
|
+ type: Object,
|
|
|
|
+ default: function() {
|
|
|
|
+ return {}
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ data() {
|
|
|
|
+ return {
|
|
|
|
+ titleText: '添加角色',
|
|
|
|
+ isshow: this.visible,
|
|
|
|
+ formLayout: 'horizontal',
|
|
|
|
+ form: this.$form.createForm(this, {
|
|
|
|
+ name: 'roleModal'
|
|
|
|
+ }),
|
|
|
|
+ formData: {
|
|
|
|
+ name: '',
|
|
|
|
+ isEnable: '', // 活动状态
|
|
|
|
+ remarks: ''
|
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- methods: {
|
|
|
|
- cancel (e) {
|
|
|
|
- this.clear()
|
|
|
|
- this.$emit('close')
|
|
|
|
- },
|
|
|
|
- // 保存提交
|
|
|
|
- handleSubmit () {
|
|
|
|
- const _this = this
|
|
|
|
- this.form.validateFields((err, values) => {
|
|
|
|
- if (!err) {
|
|
|
|
- saveRolePower(Object.assign(this.formData, values.formData)).then(res => {
|
|
|
|
- if (res.status == 200) {
|
|
|
|
- this.$message.success(res.message ? res.message : '保存成功')
|
|
|
|
- this.$emit('refresh')
|
|
|
|
- setTimeout(function () {
|
|
|
|
- _this.cancel()
|
|
|
|
- }, 300)
|
|
|
|
- } else {
|
|
|
|
- // this.$message.error(res.message)
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
- // 取消
|
|
|
|
- handleCancel () {
|
|
|
|
- const _this = this
|
|
|
|
- this.$confirm({
|
|
|
|
- title: '提示',
|
|
|
|
- content: '确定取消吗?',
|
|
|
|
- okText: '确定',
|
|
|
|
- cancelText: '取消',
|
|
|
|
- onOk () {
|
|
|
|
- _this.clear()
|
|
|
|
- _this.cancel()
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
- clear () {
|
|
|
|
- this.form.resetFields()
|
|
|
|
- delete this.formData.id
|
|
|
|
- this.formData.name = ''
|
|
|
|
- this.formData.isEnable = ''
|
|
|
|
- this.formData.remarks = ''
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ cancel(e) {
|
|
|
|
+ this.clear()
|
|
|
|
+ this.$emit('close')
|
|
|
|
+ },
|
|
|
|
+ // 保存提交
|
|
|
|
+ handleSubmit() {
|
|
|
|
+ const _this = this
|
|
|
|
+ this.form.validateFields((err, values) => {
|
|
|
|
+ if (!err) {
|
|
|
|
+ saveRolePower(Object.assign(this.formData, values.formData)).then(res => {
|
|
|
|
+ if (res.status == 200) {
|
|
|
|
+ this.$message.success(res.message ? res.message : '保存成功')
|
|
|
|
+ this.$emit('refresh')
|
|
|
|
+ setTimeout(function() {
|
|
|
|
+ _this.cancel()
|
|
|
|
+ }, 300)
|
|
|
|
+ } else {
|
|
|
|
+ // this.$message.error(res.message)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ // 取消
|
|
|
|
+ handleCancel() {
|
|
|
|
+ const _this = this
|
|
|
|
+ this.$confirm({
|
|
|
|
+ title: '提示',
|
|
|
|
+ content: '确定取消吗?',
|
|
|
|
+ okText: '确定',
|
|
|
|
+ cancelText: '取消',
|
|
|
|
+ onOk() {
|
|
|
|
+ _this.clear()
|
|
|
|
+ _this.cancel()
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ clear() {
|
|
|
|
+ this.form.resetFields()
|
|
|
|
+ delete this.formData.id
|
|
|
|
+ this.formData.name = ''
|
|
|
|
+ this.formData.isEnable = ''
|
|
|
|
+ this.formData.remarks = ''
|
|
|
|
+ }
|
|
|
|
|
|
- },
|
|
|
|
- beforeCreate () {
|
|
|
|
- this.form = this.$form.createForm(this, { name: 'roleModal' })
|
|
|
|
- },
|
|
|
|
- watch: {
|
|
|
|
- visible (newValue, oldValue) {
|
|
|
|
- this.isshow = newValue
|
|
|
|
- },
|
|
|
|
- isshow (newValue, oldValue) {
|
|
|
|
- if (newValue) {
|
|
|
|
- if (this.data.id) { // 编辑
|
|
|
|
- this.titleText = '编辑角色'
|
|
|
|
- this.formData = Object.assign({}, this.data)
|
|
|
|
- delete this.formData.no
|
|
|
|
- this.formData.isEnable = Number(this.formData.isEnable)
|
|
|
|
- } else {
|
|
|
|
- this.titleText = '添加角色'
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- this.cancel()
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
|
|
+ },
|
|
|
|
+ beforeCreate() {
|
|
|
|
+ this.form = this.$form.createForm(this, {
|
|
|
|
+ name: 'roleModal'
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ watch: {
|
|
|
|
+ visible(newValue, oldValue) {
|
|
|
|
+ this.isshow = newValue
|
|
|
|
+ },
|
|
|
|
+ isshow(newValue, oldValue) {
|
|
|
|
+ if (newValue) {
|
|
|
|
+ if (this.data.id) { // 编辑
|
|
|
|
+ this.titleText = '编辑角色'
|
|
|
|
+ this.formData = Object.assign({}, this.data)
|
|
|
|
+ delete this.formData.no
|
|
|
|
+ this.formData.isEnable = Number(this.formData.isEnable)
|
|
|
|
+ } else {
|
|
|
|
+ this.titleText = '添加角色'
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ this.cancel()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
</script>
|
|
</script>
|
|
|
|
|
|
-<style >
|
|
|
|
- .modalBox{
|
|
|
|
- }
|
|
|
|
- .ant-modal-footer {
|
|
|
|
- display: none;
|
|
|
|
- }
|
|
|
|
|
|
+<style>
|
|
|
|
+ .modalBox {}
|
|
|
|
+
|
|
|
|
+ .ant-modal-footer {
|
|
|
|
+ display: none;
|
|
|
|
+ }
|
|
</style>
|
|
</style>
|