Files
laws_chery_client/src/views/enterpriseStandardLibrary/standard/modules/TreeNodeModal.vue
T

127 lines
3.4 KiB
Vue

<template>
<j-modal
:title="title"
:maskClosable="false"
: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('enterpriseStandardLibrary.standard.nodeName')">
<a-input :placeholder="$t('pleaseEnter') + $t('enterpriseStandardLibrary.standard.nodeName')"
:maxLength="50"
v-decorator.trim="[ 'nodeName', validatorRules.nodeName ]" />
</a-form-item>
<!-- <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('standardRegulationLibrary.nodeOrder')">-->
<!-- <a-input-number style="width: 100%"-->
<!-- :placeholder="$t('pleaseEnter') + $t('standardRegulationLibrary.nodeOrder')"-->
<!-- v-decorator="['nodeOrder', validatorRules.nodeOrder]" />-->
<!-- </a-form-item>-->
</a-form>
</a-spin>
</j-modal>
</template>
<script>
import pick from 'lodash.pick'
import { postAction } from '@/api/manage'
export default {
name: 'TreeNodeModal',
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: {
nodeName: {
rules: [
{ required: true, message: this.$t('pleaseEnter') + this.$t('enterpriseStandardLibrary.standard.nodeName') }
],
validateTrigger: 'blur'
}
},
url: {
edit: '/laws/standard/lawsTreeNode/enterprise/edit',
add: '/laws/standard/lawsTreeNode/enterprise/add'
}
}
},
methods: {
add (nodeObj) {
console.log(nodeObj)
this.visible = true
this.form.resetFields()
this.model.key = nodeObj.id
this.model.nodeCode = nodeObj.nodeCode
},
edit (record) {
this.visible = true
this.form.resetFields()
this.model = Object.assign({}, record)
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model, 'nodeName'))
})
},
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({}, values)
if (!this.model.id) {
param.parentId = this.model.key
param.parentCode = this.model.nodeCode
} else {
param.id = this.model.id
}
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>