Files
laws-sinotruk-client/src/views/enterpriseStandardLibrary/standard/modules/TemporaryPermissionSet.vue
T

132 lines
3.8 KiB
Vue

<template>
<j-modal
:title="title"
:maskClosable="true"
:width="800"
: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.authorizationDepart')">
<j-select-depart
v-decorator.trim="[ 'deptIds', validatorRules.deptIds]"
:multi="true"
:backDepart="true"
:treeOpera="true">
</j-select-depart>
</a-form-item>
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('enterpriseStandardLibrary.standard.authorizationUser')">
<user-selection
type="checkbox"
v-decorator.trim="[ 'userIds', validatorRules.userIds]"
:nameStr="model.userNames"
:placeholder="$t('pleaseSelect') + $t('enterpriseStandardLibrary.standard.authorizationUser')"
@nameChange="userSelectNameChange">
</user-selection>
</a-form-item>
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('enterpriseStandardLibrary.standard.maturityDate')">
<a-date-picker
v-decorator.trim="[ 'authDate', validatorRules.authDate]"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
>
</a-date-picker>
</a-form-item>
</a-form>
</a-spin>
</j-modal>
</template>
<script>
import { temporaryPermissionSet } from '@/api/enterpriseStandardLibraryApi'
import UserSelection from '@/components/selection/UserSelection'
export default {
name: 'TemporaryPermissionSet',
components: { UserSelection },
data () {
return {
title: this.$t('enterpriseStandardLibrary.standard.temporaryPermissionSet'),
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: {
deptIds: {
rules: [
{ required: false, message: this.$t('pleaseEnter') + this.$t('enterpriseStandardLibrary.standard.authorizationDepart') }
],
validateTrigger: 'change'
},
userIds: {
rules: [
{ required: false, message: this.$t('pleaseEnter') + this.$t('enterpriseStandardLibrary.standard.authorizationUser') }
],
validateTrigger: 'change'
},
authDate: {
rules: [
{ required: true, message: this.$t('pleaseEnter') + this.$t('enterpriseStandardLibrary.standard.maturityDate') }
],
validateTrigger: 'change'
}
}
}
},
methods: {
open (standards) {
this.visible = true
this.form.resetFields()
this.model.standards = standards
},
userSelectNameChange (value) {
this.model.userNames = value
},
handleCancel () {
this.close()
},
handleOk () {
if (this.confirmLoading) return
this.form.validateFields((err, values) => {
if (!err) {
this.confirmLoading = true
const param = Object.assign({}, values)
param.standardIds = this.model.standards
temporaryPermissionSet(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
})
}
})
},
close () {
this.visible = false
this.model = {}
}
}
}
</script>
<style scoped>
</style>