[update] 文档拆分的弹框拆分出来
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
<template>
|
||||
<a-modal
|
||||
class="add-menus"
|
||||
:title="title"
|
||||
:visible="visible"
|
||||
:confirm-loading="confirmLoading"
|
||||
@cancel="handleCancel"
|
||||
@ok="handleOk"
|
||||
>
|
||||
<a-form-model
|
||||
class="split-click-right-form"
|
||||
ref="ruleForm"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="labelCol"
|
||||
:wrapper-col="wrapperCol"
|
||||
>
|
||||
<a-form-model-item :label="$t('docTool.split.clauseNo')" prop="name">
|
||||
<a-input class="box-input" v-model="form.name" :placeholder="$t('pleaseEnter')+$t('docTool.split.clauseNo')" :maxLength="200" />
|
||||
</a-form-model-item>
|
||||
<a-form-model-item :label="$t('docTool.split.clauseName')" prop="itemName">
|
||||
<a-input class="box-input" v-model="form.itemName" :placeholder="$t('pleaseEnter')+$t('docTool.split.clauseName')" :maxLength="200" />
|
||||
</a-form-model-item>
|
||||
<a-form-model-item :label="$t('serialNumber')" prop="displaySeq">
|
||||
<a-input-number v-model="form.displaySeq" :min="1" :max="99999"
|
||||
class="box-input"
|
||||
:placeholder="$t('pleaseEnter')+$t('serialNumber')"
|
||||
:formatter="limitNumber"
|
||||
:parser="limitNumber" style="width: 100%" />
|
||||
</a-form-model-item>
|
||||
</a-form-model>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { postAction, putAction } from '@/api/manage'
|
||||
export default {
|
||||
name: 'SplitDetailNodeAdd',
|
||||
data () {
|
||||
return {
|
||||
title: this.$t('add'),
|
||||
visible: false,
|
||||
confirmLoading: false,
|
||||
labelCol: { span: 6 },
|
||||
wrapperCol: { span: 16 },
|
||||
form: {},
|
||||
rules: {
|
||||
name: [
|
||||
// { required: true, message: this.$t('PleaseEnter') + this.$t('clauseNo'), trigger: 'blur' },
|
||||
],
|
||||
itemName: [
|
||||
{ required: true, message: this.$t('pleaseEnter') + this.$t('docTool.split.clauseName'), trigger: 'blur' }
|
||||
],
|
||||
displaySeq: [
|
||||
{ required: true, message: this.$t('pleaseEnter') + this.$t('serialNumber'), trigger: 'blur' }
|
||||
// { min: 1, max: 99999, message: this.$t('cantExeed') + '99999' + this.$t('characters'), trigger: 'blur' },
|
||||
]
|
||||
},
|
||||
isEdit: false,
|
||||
nodeItem: {},
|
||||
infoId: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
add (nodeItem, infoId) {
|
||||
this.title = this.$t('add')
|
||||
this.isEdit = false
|
||||
this.form = {}
|
||||
this.visible = true
|
||||
this.nodeItem = nodeItem
|
||||
this.infoId = infoId
|
||||
},
|
||||
edit (nodeItem, infoId) {
|
||||
this.title = this.$t('edit')
|
||||
this.isEdit = true
|
||||
this.nodeItem = nodeItem
|
||||
this.form.id = nodeItem.id
|
||||
this.form.pid = nodeItem.pid
|
||||
this.form.name = nodeItem.name
|
||||
this.form.itemName = nodeItem.itemName
|
||||
this.form.displaySeq = nodeItem.displaySeq
|
||||
this.infoId = infoId
|
||||
this.visible = true
|
||||
},
|
||||
handleCancel () {
|
||||
this.visible = false
|
||||
},
|
||||
// 增加节点确定
|
||||
handleOk () {
|
||||
if (this.confirmLoading) {
|
||||
return
|
||||
}
|
||||
const expandId = []
|
||||
expandId.push(this.form.pid)
|
||||
if (!this.isEdit) {
|
||||
this.$refs.ruleForm.validate(valid => {
|
||||
if (valid) {
|
||||
this.confirmLoading = true
|
||||
const params = {
|
||||
infoId: this.infoId,
|
||||
pid: this.nodeItem.id,
|
||||
...this.form
|
||||
}
|
||||
postAction(`split/sarFileSplitMenu/addMenu`, params).then(res => {
|
||||
if (res.success) {
|
||||
this.$message.success(this.$t('operationSuccessful'))
|
||||
// this.onExpand(expandId)
|
||||
this.form = {}
|
||||
this.visible = false
|
||||
this.$emit('ok')
|
||||
} else {
|
||||
this.$message.warning(this.$t('operationFailed'))
|
||||
}
|
||||
}).finally(() => {
|
||||
this.confirmLoading = false
|
||||
})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.$refs.ruleForm.validate(valid => {
|
||||
if (valid) {
|
||||
this.confirmLoading = true
|
||||
const params = {
|
||||
info_id: this.infoId,
|
||||
...this.form
|
||||
}
|
||||
putAction(`split/sarFileSplitMenu/updateMenu`, params).then(res => {
|
||||
if (res.success) {
|
||||
this.$message.success(this.$t('operationSuccessful'))
|
||||
this.form = {}
|
||||
this.visible = false
|
||||
this.$emit('update', expandId)
|
||||
} else {
|
||||
this.$message.warning(this.$t('operationFailed'))
|
||||
}
|
||||
}).finally(() => {
|
||||
this.confirmLoading = false
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
// 正则替换小数点
|
||||
limitNumber (value) {
|
||||
if (typeof value === 'string') {
|
||||
return !isNaN(Number(value)) ? value.replace(/\./g, '') : 0
|
||||
} else if (typeof value === 'number') {
|
||||
return !isNaN(value) ? String(value).replace(/\./g, '') : 0
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user