121 lines
3.0 KiB
Vue
121 lines
3.0 KiB
Vue
<template>
|
|
<j-modal
|
|
:title="title"
|
|
:maskClosable="true"
|
|
:width="500"
|
|
:closable="true"
|
|
switchFullscreen
|
|
@cancel="handleCancel"
|
|
@ok="handleOk"
|
|
:visible="visible">
|
|
|
|
<a-spin :spinning="confirmLoading">
|
|
<a-form :form="form">
|
|
<!-- 工作组名称 -->
|
|
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('system.internalWorkGroup.workGroupName')">
|
|
<a-input :placeholder="$t('pleaseEnter') + $t('system.internalWorkGroup.workGroupName')"
|
|
:maxLength="50"
|
|
@change="event => event.target.value = event.target.value.trim()"
|
|
v-decorator.trim="[ 'name', validatorRules.name ]" />
|
|
</a-form-item>
|
|
</a-form>
|
|
</a-spin>
|
|
|
|
</j-modal>
|
|
</template>
|
|
|
|
<script>
|
|
import pick from 'lodash.pick'
|
|
import { postAction } from '@/api/manage'
|
|
|
|
export default {
|
|
name: 'TreeNodeWorkGroupModal',
|
|
data () {
|
|
return {
|
|
title: '',
|
|
visible: false,
|
|
confirmLoading: false,
|
|
form: this.$form.createForm(this),
|
|
model: {},
|
|
labelCol: {
|
|
xs: { span: 24 },
|
|
sm: { span: 6 }
|
|
},
|
|
wrapperCol: {
|
|
xs: { span: 24 },
|
|
sm: { span: 16 }
|
|
},
|
|
validatorRules: {
|
|
name: {
|
|
rules: [
|
|
{ required: true, message: this.$t('pleaseEnter') + this.$t('system.internalWorkGroup.workGroupName') }
|
|
],
|
|
validateTrigger: 'blur'
|
|
}
|
|
},
|
|
url: {
|
|
add: '/sys/lawsWorkingGroup/addWorkGroup',
|
|
edit: '/sys/lawsWorkingGroup/editWorkGroup'
|
|
},
|
|
parentUserId: ''
|
|
}
|
|
},
|
|
methods: {
|
|
add (parentNodeKey, userId) {
|
|
this.visible = true
|
|
this.form.resetFields()
|
|
this.model.pid = parentNodeKey
|
|
this.parentUserId = userId
|
|
},
|
|
edit (nodeKey, record) {
|
|
this.visible = true
|
|
this.form.resetFields()
|
|
this.model = Object.assign({}, record)
|
|
this.model.id = nodeKey
|
|
this.$nextTick(() => {
|
|
this.form.setFieldsValue(pick(this.model, 'name'))
|
|
})
|
|
},
|
|
close () {
|
|
this.visible = false
|
|
this.model = {}
|
|
},
|
|
handleCancel () {
|
|
this.close()
|
|
},
|
|
handleOk () {
|
|
if (this.confirmLoading) return
|
|
this.form.validateFields((err, values) => {
|
|
if (!err) {
|
|
this.confirmLoading = true
|
|
const param = Object.assign({}, this.model)
|
|
param.name = values.name
|
|
param.userId = this.parentUserId
|
|
let url = ''
|
|
if (this.model.id) {
|
|
url = this.url.edit
|
|
} else {
|
|
url = this.url.add
|
|
}
|
|
postAction(url, param).then(res => {
|
|
if (res.success) {
|
|
this.$message.success(res.message)
|
|
this.$emit('ok')
|
|
this.close()
|
|
} else {
|
|
this.$message.warning(res.message)
|
|
}
|
|
}).finally(() => {
|
|
this.confirmLoading = false
|
|
})
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
|
|
</style>
|