<template>
|
<div ref="container">
|
<a-modal
|
:title="title"
|
:width="800"
|
:visible="visible"
|
:confirmLoading="confirmLoading"
|
:getContainer="() => $refs.container"
|
:maskStyle="{'top':'93px','left':'154px'}"
|
:wrapClassName="wrapClassNameInfo()"
|
:mask="isDesktop()"
|
:maskClosable="false"
|
@ok="handleOk"
|
@cancel="handleCancel"
|
cancelText="取消"
|
okText="保存">
|
<a-spin :spinning="confirmLoading">
|
<a-form :form="form">
|
<a-row class="form-row" :gutter="24">
|
<a-col :span="24">
|
<a-form-item label="关键词" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
<a-input placeholder="请输入关键词" v-decorator="['keyword', validatorRules.keyword]" />
|
</a-form-item>
|
</a-col>
|
<a-col :span="24">
|
<a-form-item label="防护类型" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
<!-- <a-input placeholder="请输入防护类型" v-decorator="['type', validatorRules.type]" /> -->
|
<a-select
|
optionFilterProp="children"
|
:dropdownMatchSelectWidth="false"
|
showSearch allow-clear style="width: 100%"
|
placeholder="请选择防护类型"
|
v-decorator="['type', validatorRules.type]"
|
>
|
<a-select-option v-for="(type,index) in typeList" :value="type.itemValue" :key="index">
|
{{ type.itemText }}
|
</a-select-option>
|
</a-select>
|
</a-form-item>
|
</a-col>
|
<a-col :span="24">
|
<a-form-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
<a-radio-group v-decorator="['status', {initialValue: 1}]">
|
<a-radio :value="1">启用</a-radio>
|
<a-radio :value="0">禁用</a-radio>
|
</a-radio-group>
|
</a-form-item>
|
</a-col>
|
</a-row>
|
</a-form>
|
</a-spin>
|
</a-modal>
|
</div>
|
</template>
|
|
<script>
|
import { mixinDevice } from '@/utils/mixin'
|
import { postAction, putAction,getAction } from '@/api/manage'
|
import pick from 'lodash.pick'
|
|
export default {
|
name: "SysDictModal",
|
mixins: [mixinDevice],
|
data () {
|
return {
|
title:"操作",
|
visible: false,
|
model: {},
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 5 },
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 },
|
},
|
confirmLoading: false,
|
form: this.$form.createForm(this),
|
validatorRules:{
|
keyword: {
|
rules: [{
|
required: true,
|
message: '请输入关键词!'
|
},
|
{
|
max: 50,
|
message: '关键词长度不能超过50个字符!'
|
}
|
]
|
},
|
type: {
|
rules: [{
|
required: true,
|
message: '请输入防护类型!'
|
}]
|
}
|
},
|
url: {
|
add: "/config-security",
|
edit: "/config-security"
|
},
|
typeList:[],
|
}
|
},
|
mounted(){
|
this.loadDictData();
|
},
|
methods: {
|
loadDictData() {
|
// 安全防护类型
|
var dictCode='securityType'
|
getAction(`/sysDict/items/dict-code/${dictCode}`).then((res)=>{
|
if(res.code === 200){
|
this.typeList = res.data;
|
}else{
|
this.$message.info(res.data);
|
}
|
})
|
},
|
add () {
|
this.edit({})
|
},
|
edit (record) {
|
debugger;
|
this.form.resetFields()
|
this.model = Object.assign({}, record)
|
this.visible = true
|
this.$nextTick(() => {
|
this.form.setFieldsValue(pick(this.model,'keyword','type','status'))
|
})
|
},
|
close () {
|
this.$emit('close')
|
this.visible = false
|
},
|
handleOk () {
|
const that = this
|
this.form.validateFields((err, values) => {
|
if (!err) {
|
that.confirmLoading = true
|
let formData = Object.assign(this.model, values)
|
let obj
|
if(!this.model.id){
|
obj = postAction(this.url.add, formData)
|
}else{
|
obj = putAction(this.url.edit, formData)
|
}
|
obj.then((res)=>{
|
if(res.code === 200){
|
that.$message.success(res.msg)
|
that.$emit('ok')
|
}else{
|
that.$message.warning(res.msg)
|
}
|
}).finally(() => {
|
that.confirmLoading = false
|
that.close()
|
})
|
}
|
})
|
},
|
handleCancel () {
|
this.close()
|
}
|
}
|
}
|
</script>
|
|
<style lang="less" scoped>
|
.form-row {
|
padding: 0 24px;
|
}
|
</style>
|