Files
laws-sinotruk-client/src/views/standardRegulationLibrary/profileCenter/modules/ProfileCenterModal.vue
T
2024-03-05 11:01:55 +08:00

152 lines
5.0 KiB
Vue

<template>
<j-modal
:title="title"
:maskClosable="false"
:width="width"
:visible="visible"
:confirm-loading="confirmLoading"
switchFullscreen
@ok="handleOk"
@cancel="handleCancel">
<a-form :form="form">
<!--文件名称-->
<!--<a-form-item :label="$t('fileName')" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!-- <a-input :placeholder="$t('pleaseEnter') + $t('fileName')"-->
<!-- @change="event => event.target.value = event.target.value.trim()"-->
<!-- :maxLength="50"-->
<!-- v-decorator="['fileName', validatorRules.fileName]" />-->
<!--</a-form-item>-->
<!--所属类型-->
<!--<a-form-item :label="$t('standardRegulationLibrary.profileCenter.typeOfOwnership')" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!-- <a-tree-select v-decorator="['title', validatorRules.title]"-->
<!-- :getPopupContainer="triggerNode=> triggerNode.parentNode"-->
<!-- style="width: 100%"-->
<!-- :tree-data="typeOfOwnershipTreeData"-->
<!-- :label-in-value="false"-->
<!-- :placeholder="$t('pleaseSelect')+$t('standardRegulationLibrary.profileCenter.typeOfOwnership')" />-->
<!--</a-form-item>-->
<!--上传资料-->
<a-form-item :label="$t('standardRegulationLibrary.profileCenter.uploadData')"
:labelCol="labelCol"
:wrapperCol="wrapperCol">
<j-upload v-decorator="['fileId', validatorRules.fileId]" return-id :disabled="!!modal.id" />
</a-form-item>
<!--推送范围-->
<a-form-item :label="$t('standardRegulationLibrary.dynamicMessage.pushRange')"
:labelCol="labelCol"
:wrapperCol="wrapperCol">
<user-selection v-decorator="['pushRangeIds', validatorRules.pushRangeIds]"
:name-str="modal.pushRangeIds_dictText"
type="checkbox"
:placeholder="$t('pleaseSelect')+$t('standardRegulationLibrary.dynamicMessage.pushRange')" />
</a-form-item>
<!--文件说明-->
<a-form-item :label="$t('fileDeclaration')" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input type="textarea"
:placeholder="$t('pleaseEnter') + $t('fileDeclaration')"
:maxLength="500"
v-decorator="['fileDescription', validatorRules.fileDescription]" />
</a-form-item>
</a-form>
</j-modal>
</template>
<script>
import UserSelection from '../../../../components/selection/UserSelection.vue'
import { addProfileCenter, editProfileCenter } from '../../../../api/standardRegulationLibraryApi.js'
export default {
name: 'ProfileCenterModal',
components: { UserSelection },
data () {
return {
title: this.$t('newlyAdded'),
width: 600,
visible: false,
confirmLoading: false,
modal: {},
form: this.$form.createForm(this),
labelCol: {
xs: { span: 24 },
sm: { span: 4 }
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 20 }
},
validatorRules: {
// 上传资料
fileId: {
rules: [{ required: true, message: this.$t('uploadFile.pleaseUpload') + this.$t('uploadFile.file') }],
validateTrigger: 'change'
},
// 推送范围
pushRangeIds: {
rules: [{
required: false,
message: this.$t('pleaseSelect') + this.$t('standardRegulationLibrary.dynamicMessage.pushRange')
}],
validateTrigger: 'change'
},
// 文件说明
fileDescription: {
rules: [{ required: false, message: this.$t('pleaseEnter') + this.$t('fileDeclaration') }],
validateTrigger: 'blur'
}
},
typeOfOwnershipTreeData: [] // 所属类型树形下拉
}
},
methods: {
add (params) {
this.modal = params
this.visible = true
},
edit (record) {
this.visible = true
this.modal = Object.assign({}, record)
this.$nextTick(() => {
this.form.setFieldsValue(this.modal)
})
},
handleOk () {
this.form.validateFields((errors, values) => {
if (!errors) {
this.confirmLoading = true
let submitFunc
if (this.modal.id) {
submitFunc = editProfileCenter
} else {
submitFunc = addProfileCenter
}
const formData = Object.assign(this.modal, values)
submitFunc(formData).then(res => {
if (res.success) {
this.$message.success(res.message)
this.$emit('ok')
this.close()
} else {
this.$message.warn(res.message)
}
}).finally(() => {
this.confirmLoading = false
})
}
})
},
handleCancel () {
this.close()
},
close () {
this.visible = false
}
}
}
</script>
<style scoped lang="less">
</style>