251 lines
8.5 KiB
Vue
251 lines
8.5 KiB
Vue
<template>
|
|
<a-modal
|
|
:title="title"
|
|
:maskClosable="true"
|
|
:width="800"
|
|
:closable="true"
|
|
@cancel="handleCancel"
|
|
@ok="handleOk"
|
|
:visible="visible">
|
|
|
|
<a-spin :spinning="confirmLoading">
|
|
<a-form :form="form">
|
|
<a-row :gutter="24">
|
|
<!-- 分类 -->
|
|
<a-col :span="12">
|
|
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('businessSupport.questionAnswer.classify')">
|
|
<a-select :placeholder="$t('pleaseSelect') + $t('businessSupport.questionAnswer.classify')"
|
|
allowClear
|
|
v-decorator.trim="[ 'type', validatorRules.type]">
|
|
<a-select-option :value="null" :key="-1">请选择</a-select-option>
|
|
<a-select-option value="1">国内标准</a-select-option>
|
|
<a-select-option value="2">海外标准</a-select-option>
|
|
<a-select-option value="3">企业标准</a-select-option>
|
|
<a-select-option value="4">其他问题</a-select-option>
|
|
</a-select>
|
|
</a-form-item>
|
|
</a-col>
|
|
<!-- 标准编号 -->
|
|
<a-col :span="12" v-if="['1', '2', '3'].includes(form.getFieldValue('type'))">
|
|
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('standardNumber')">
|
|
<standard-selection
|
|
v-decorator.trim="[ 'standardNumber', validatorRules.standardNumber]"
|
|
:placeholder="$t('pleaseEnterOrSelect') + $t('standardNumber')"
|
|
:source="form.getFieldValue('type')"
|
|
:disabledSourceSearch="true"
|
|
@nameChange="standardNameChange"
|
|
/>
|
|
</a-form-item>
|
|
</a-col>
|
|
<!-- 标准名称 -->
|
|
<a-col :span="12" v-if="['1', '2', '3'].includes(form.getFieldValue('type'))">
|
|
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('standardName')">
|
|
<a-input disabled :placeholder="$t('pleaseEnter') + $t('standardName')"
|
|
v-decorator.trim="[ 'standardName', validatorRules.standardName]"/>
|
|
</a-form-item>
|
|
</a-col>
|
|
<!-- 标题 -->
|
|
<a-col :span="12">
|
|
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('title')">
|
|
<a-input v-decorator.trim="[ 'title', validatorRules.title]"
|
|
:placeholder="$t('pleaseEnter') + $t('title')"/>
|
|
</a-form-item>
|
|
</a-col>
|
|
<!-- 项目 -->
|
|
<a-col :span="12">
|
|
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('project')">
|
|
<a-select :placeholder="$t('pleaseSelect') + $t('project')"
|
|
allowClear
|
|
v-decorator.trim="[ 'project', validatorRules.project]">
|
|
<a-select-option :value="null" :key="-1">请选择</a-select-option>
|
|
<a-select-option v-for="item in projectList" :value="item.id" :key="item.id">{{ item.projectName }}</a-select-option>
|
|
</a-select>
|
|
</a-form-item>
|
|
</a-col>
|
|
<!-- 提问时间 -->
|
|
<a-col :span="12">
|
|
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('businessSupport.questionAnswer.quizTime')">
|
|
<a-date-picker
|
|
v-decorator.trim="[ 'quizTime', validatorRules.quizTime]"
|
|
format="YYYY-MM-DD HH:mm:ss"
|
|
value-format="YYYY-MM-DD HH:mm:ss"
|
|
showTime
|
|
></a-date-picker>
|
|
</a-form-item>
|
|
</a-col>
|
|
<!-- 问题描述 -->
|
|
<a-col :span="24">
|
|
<a-form-item :labelCol="longLabelCol" :wrapperCol="longWrapperCol" :label="$t('businessSupport.questionAnswer.questionDesc')">
|
|
<a-textarea
|
|
v-decorator.trim="[ 'problemDescription', validatorRules.problemDescription]"
|
|
:placeholder="$t('pleaseEnter')+$t('businessSupport.questionAnswer.questionDesc')"
|
|
:maxLength="500"
|
|
:rows="4" />
|
|
<j-upload v-decorator.trim="[ 'file', validatorRules.file]"
|
|
returnId
|
|
isDownload>
|
|
</j-upload>
|
|
</a-form-item>
|
|
</a-col>
|
|
</a-row>
|
|
</a-form>
|
|
</a-spin>
|
|
|
|
</a-modal>
|
|
</template>
|
|
|
|
<script>
|
|
import { postAction } from '@/api/manage'
|
|
import { getCarTypeProjectList } from '@/api/projectLibraryApi.js'
|
|
// 双向绑定的标准选择器
|
|
import StandardSelection from '@/components/selection/StandardSelection'
|
|
import pick from 'lodash.pick'
|
|
|
|
export default {
|
|
name: 'QuizModal',
|
|
components: { StandardSelection },
|
|
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: 18 }
|
|
},
|
|
longLabelCol: {
|
|
xs: { span: 24 },
|
|
sm: { span: 3 }
|
|
},
|
|
longWrapperCol: {
|
|
xs: { span: 24 },
|
|
sm: { span: 20 }
|
|
},
|
|
validatorRules: {
|
|
classify: {
|
|
rules: [
|
|
{ required: true, message: this.$t('pleaseSelect') + this.$t('businessSupport.questionAnswer.classify') }
|
|
],
|
|
validateTrigger: 'change'
|
|
},
|
|
standardNumber: {
|
|
rules: [
|
|
{ required: true, message: this.$t('pleaseSelectOrEnter') + this.$t('standardNumber') }
|
|
],
|
|
validateTrigger: 'blur'
|
|
},
|
|
standardName: {
|
|
rules: [
|
|
{ required: true, message: this.$t('pleaseEnter') + this.$t('standardName') }
|
|
],
|
|
validateTrigger: 'blur'
|
|
},
|
|
title: {
|
|
rules: [
|
|
{ required: true, message: this.$t('pleaseEnter') + this.$t('title') }
|
|
],
|
|
validateTrigger: 'blur'
|
|
},
|
|
project: {
|
|
rules: [
|
|
{ required: false, message: this.$t('pleaseSelect') + this.$t('project') }
|
|
],
|
|
validateTrigger: 'change'
|
|
},
|
|
quizTime: {
|
|
rules: [
|
|
{ required: false, message: this.$t('pleaseSelect') + this.$t('businessSupport.questionAnswer.quizTime') }
|
|
],
|
|
validateTrigger: 'change'
|
|
},
|
|
problemDescription: {
|
|
rules: [
|
|
{ required: true, message: this.$t('pleaseEnter') + this.$t('businessSupport.questionAnswer.questionDesc') }
|
|
],
|
|
validateTrigger: 'blur'
|
|
},
|
|
file: {
|
|
rules: [
|
|
{ required: false, message: this.$t('pleaseSelect') + this.$t('businessSupport.questionAnswer.attach') }
|
|
],
|
|
validateTrigger: 'change'
|
|
}
|
|
},
|
|
url: {
|
|
quiz: '/laws/library/lawsProblemLibrary/addProblem'
|
|
},
|
|
projectList: [] // 项目下拉框数据
|
|
}
|
|
},
|
|
created () {
|
|
this.getCarTypeProjectList()
|
|
},
|
|
methods: {
|
|
open () {
|
|
this.visible = true
|
|
this.form.resetFields()
|
|
const param = {}
|
|
param.quizTime = new Date().getFullYear() + '-' + new Date().getMonth() + '-' + new Date().getDay() + ' ' +
|
|
new Date().getHours() + ':' + new Date().getMinutes() + ':' + new Date().getSeconds()
|
|
this.$nextTick(() => {
|
|
this.form.setFieldsValue(pick(param, 'quizTime'))
|
|
})
|
|
},
|
|
// 获取项目下拉框数据
|
|
getCarTypeProjectList () {
|
|
getCarTypeProjectList().then(res => {
|
|
if (res.success) {
|
|
this.projectList = res.result
|
|
} else {
|
|
this.projectList = []
|
|
}
|
|
})
|
|
},
|
|
// 标准选择名称改变的回调
|
|
standardNameChange (value) {
|
|
const param = { standardName: value }
|
|
this.$nextTick(() => {
|
|
this.form.setFieldsValue(pick(param, 'standardName'))
|
|
})
|
|
},
|
|
handleCancel () {
|
|
this.close()
|
|
},
|
|
handleOk () {
|
|
if (this.confirmLoading) return
|
|
this.form.validateFields((err, values) => {
|
|
if (!err) {
|
|
this.confirmLoading = true
|
|
const param = Object.assign({}, values)
|
|
postAction(this.url.quiz, 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
|
|
}
|
|
}
|
|
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
|
|
</style>
|