123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- <template>
- <el-dialog
- :visible.sync="show"
- :close-on-click-modal="false"
- :modal-append-to-body="false"
- @close="cancelHandle"
- custom-class="knowledge-import-dialog"
- top="10vh"
- v-dialogDrag
- title="事件信息"
- width="650px"
- >
- <el-form
- ref="formRef"
- hide-required-asterisk
- :model="eventForm"
- :rules="formRules"
- label-width="100px"
- >
- <el-form-item prop="title" label="标题">
- <el-input
- v-model="eventForm.title"
- placeholder="请输入标题"
- style="width:80%"
- />
- </el-form-item>
- <el-form-item prop="classifyId" label="分类">
- <el-cascader
- :options="classifyOptions"
- v-model="eventForm.classifyId"
- :props="{
- value: 'ClassifyId',
- label: 'ClassifyName',
- children: 'Child',
- emitPath:false
- }"
- clearable
- placeholder="请选择分类"
- style="width:80%"
- ></el-cascader>
- </el-form-item>
- <el-form-item prop="source" label="来源">
- <el-input
- v-model="eventForm.source"
- placeholder="请输入来源"
- style="width:80%"
- clearable
- />
- </el-form-item>
- <el-form-item prop="tagId" label="标签">
- <el-select
- v-model="eventForm.tagId"
- placeholder="请选择标签"
- size="medium"
- clearable
- style="width:80%"
- >
- <el-option
- v-for="item in tagsOptions"
- :key="item.TagId"
- :label="item.TagName"
- :value="item.TagId"
- />
- </el-select>
- </el-form-item>
- <el-form-item prop="startTime" label="开始时间">
- <el-date-picker
- v-model="eventForm.startTime"
- :value-format="formatTime"
- :format="formatTime"
- :type="[2,3,4].includes(ResourceType)?'date':'datetime'"
- placeholder="请选择开始时间"
- style="width:80%"
- />
- </el-form-item>
- <el-form-item prop="endTime" v-if="![2,3,4].includes(ResourceType)" label="结束时间">
- <el-date-picker
- v-model="eventForm.endTime"
- :value-format="formatTime"
- :format="formatTime"
- :type="[2,3,4].includes(ResourceType)?'date':'datetime'"
- placeholder="请选择结束时间"
- style="width:80%"
- />
- </el-form-item>
- </el-form>
- <div class="btn-bottom">
- <el-button type="primary" plain @click="cancelHandle">取消</el-button>
- <el-button type="primary" @click="handleConfirmEvent">确定</el-button>
- </div>
- </el-dialog>
- </template>
- <script>
- import { eventInterface } from '@/api/modules/knowledge';
- export default {
- props: {
- show: {
- type: Boolean
- },
- ResourceType: {
- type: Number
- },
- importFileUrl: {
- type: String
- },
- fileName: {
- type: String
- },
- },
- computed: {
- formatTime() {
- return [2,3,4].includes(this.ResourceType) ? 'yyyy-MM-dd' : 'yyyy-MM-dd HH:mm:ss'
- }
- },
- watch: {
- show(nval) {
- if(!nval) return
- this.eventForm.title=this.fileName
- this.getClassifyList();
- this.getTagsList();
- }
- },
- data() {
- return {
- eventForm: {
- title: '',
- classifyId: 0,
- source:'',
- tagId:'',
- startTime:'',
- endTime:''
- },
- formRules:{
- title:[
- { required: true, message: '标题不能为空', trigger: 'blur' },
- ],
- classifyId:[
- { required: true, message: '分类不能为空', trigger: 'blur' },
- ],
- source:[
- { required: true, message: '来源不能为空', trigger: 'blur' },
- ],
- startTime:[
- { required: true, message: '开始时间不能为空', trigger: 'blur' },
- ],
- },
-
- classifyOptions: [],
- sourcesOptions:[],
- tagsOptions:[],
- }
- },
- mounted(){
- },
- methods:{
- async getClassifyList() {
- const res = await eventInterface.getClassify({
- ResourceType: this.ResourceType
- })
- if(res.Ret !== 200) return
- this.classifyOptions = res.Data.List || []
- },
- async getSourceList() {
- const res = await eventInterface.getSourcesList({
- ResourceType: this.ResourceType
- })
- if(res.Ret !== 200) return
- this.sourcesOptions = res.Data.List || []
- },
- async getTagsList() {
- const res = await eventInterface.getTagList({ResourceType:this.ResourceType})
- if(res.Ret !== 200) return
- this.tagsOptions=res.Data.List || []
- },
- async handleConfirmEvent() {
- await this.$refs.formRef.validate()
-
- const {
- title,
- classifyId,
- source,
- tagId,
- startTime,
- endTime
- } = this.eventForm;
- let params = {
- ResourceType: this.ResourceType,
- ClassifyId: classifyId,
- Title: title,
- Content: '',
- SourceFrom: source,
- TagId: tagId || 0,
- StartTime: startTime,
- EndTime: endTime || '',
- FileUrl: this.importFileUrl ? [this.importFileUrl] : [],
- }
- const res = await eventInterface.addEvent(params)
- if(res.Ret !== 200) return
- this.$message.success('添加成功')
- this.$emit('confirm')
- this.cancelHandle()
- },
- cancelHandle() {
- this.$refs.formRef.resetFields()
- this.$emit('update:show',false)
- }
- },
- }
- </script>
- <style scoped lang='scss'>
- .el-form {
- padding: 0 40px;
- }
- .btn-bottom {
- display: flex;
- justify-content: center;
- margin: 30px 0;
- .el-button {
- width: 130px;
- }
- }
- </style>
|