|
@@ -4,8 +4,8 @@
|
|
<!-- 单个新增(事件) -->
|
|
<!-- 单个新增(事件) -->
|
|
<div v-if="type == 1">
|
|
<div v-if="type == 1">
|
|
<el-form :model="formData[0]" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
|
|
<el-form :model="formData[0]" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
|
|
- <el-form-item label="事件名称" prop="questionName">
|
|
|
|
- <el-autocomplete class="inline-input" v-model="formData[0].questionName"
|
|
|
|
|
|
+ <el-form-item label="事件名称" prop="name">
|
|
|
|
+ <el-autocomplete class="inline-input" v-model="formData[0].name" v-SelectLazyLoading="load"
|
|
:fetch-suggestions="querySearchQuestion"
|
|
:fetch-suggestions="querySearchQuestion"
|
|
placeholder="请输入或选择事件" :trigger-on-focus="false"
|
|
placeholder="请输入或选择事件" :trigger-on-focus="false"
|
|
@select="handleSelectQuestion" @change="change1($event, { $index: 0 })" @focus="focus($event, { $index: 0 })"
|
|
@select="handleSelectQuestion" @change="change1($event, { $index: 0 })" @focus="focus($event, { $index: 0 })"
|
|
@@ -16,17 +16,18 @@
|
|
</el-autocomplete>
|
|
</el-autocomplete>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item label="事件日期" prop="eventDate">
|
|
<el-form-item label="事件日期" prop="eventDate">
|
|
- <el-date-picker style="width: 100%" v-model="formData[0].eventDate"
|
|
|
|
- type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
|
|
|
|
- placeholder="选择事件日期时间">
|
|
|
|
|
|
+ <el-date-picker
|
|
|
|
+ style="width: 100%" v-model="formData[0].eventDate"
|
|
|
|
+ type="date" value-format="yyyy-MM-dd" placeholder="请选择事件日期"
|
|
|
|
+ >
|
|
</el-date-picker>
|
|
</el-date-picker>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item label="事件描述" prop="description">
|
|
<el-form-item label="事件描述" prop="description">
|
|
<el-input type="textarea" :rows="1" v-model="formData[0].description" autocomplete="off" placeholder="请输入事件描述"
|
|
<el-input type="textarea" :rows="1" v-model="formData[0].description" autocomplete="off" placeholder="请输入事件描述"
|
|
></el-input>
|
|
></el-input>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
- <el-form-item label="事件场景" prop="assistPerson">
|
|
|
|
- <el-select v-model="formData[0].applicationScenarios[0]" :disabled="(formData[0].id && !this.row) ? true : false"
|
|
|
|
|
|
+ <el-form-item label="事件场景" prop="scenarioId">
|
|
|
|
+ <el-select v-model="formData[0].scenarioId"
|
|
style="width: 100%;" placeholder="请选择事件场景">
|
|
style="width: 100%;" placeholder="请选择事件场景">
|
|
<el-option
|
|
<el-option
|
|
v-for="item in commonData.ENTERPRISE_APPLICATION_SCENARIO ? commonData.ENTERPRISE_APPLICATION_SCENARIO : []"
|
|
v-for="item in commonData.ENTERPRISE_APPLICATION_SCENARIO ? commonData.ENTERPRISE_APPLICATION_SCENARIO : []"
|
|
@@ -39,7 +40,7 @@
|
|
<!-- 批量新增(事件) -->
|
|
<!-- 批量新增(事件) -->
|
|
<div v-else-if="type == 2">
|
|
<div v-else-if="type == 2">
|
|
<el-table :data="formData" style="width: 100%" class="twj-table">
|
|
<el-table :data="formData" style="width: 100%" class="twj-table">
|
|
- <el-table-column prop="questionName" label="事件名称" align="center">
|
|
|
|
|
|
+ <el-table-column prop="name" label="事件名称" align="center">
|
|
<template slot="header">
|
|
<template slot="header">
|
|
<div>
|
|
<div>
|
|
<el-tooltip class="item" effect="dark" content="事件:商业目标/解决问题/对应项目" placement="top">
|
|
<el-tooltip class="item" effect="dark" content="事件:商业目标/解决问题/对应项目" placement="top">
|
|
@@ -49,7 +50,7 @@
|
|
</template>
|
|
</template>
|
|
<template slot-scope="scope">
|
|
<template slot-scope="scope">
|
|
<div>
|
|
<div>
|
|
- <el-autocomplete class="inline-input" v-model="scope.row.questionName"
|
|
|
|
|
|
+ <el-autocomplete class="inline-input" v-model="scope.row.name"
|
|
:fetch-suggestions="querySearchQuestion" placeholder="请输入或选择事件" :trigger-on-focus="false"
|
|
:fetch-suggestions="querySearchQuestion" placeholder="请输入或选择事件" :trigger-on-focus="false"
|
|
@select="handleSelectQuestion" @focus="focus($event, scope)" style="width: 100%;">
|
|
@select="handleSelectQuestion" @focus="focus($event, scope)" style="width: 100%;">
|
|
</el-autocomplete>
|
|
</el-autocomplete>
|
|
@@ -59,8 +60,8 @@
|
|
<el-table-column prop="eventDate" label="事件时间" align="center">
|
|
<el-table-column prop="eventDate" label="事件时间" align="center">
|
|
<template slot-scope="scope">
|
|
<template slot-scope="scope">
|
|
<div>
|
|
<div>
|
|
- <el-date-picker style="width: 100%" v-model="scope.row.eventDate" :disabled="scope.row.id ? true : false"
|
|
|
|
- type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择事件日期时间">
|
|
|
|
|
|
+ <el-date-picker style="width: 100%" v-model="scope.row.eventDate"
|
|
|
|
+ type="datetime" value-format="yyyy-MM-dd" placeholder="选择事件日期时间">
|
|
</el-date-picker>
|
|
</el-date-picker>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
@@ -69,15 +70,15 @@
|
|
<template slot-scope="scope">
|
|
<template slot-scope="scope">
|
|
<div>
|
|
<div>
|
|
<el-input type="textarea" :rows="1" v-model="scope.row.description" autocomplete="off"
|
|
<el-input type="textarea" :rows="1" v-model="scope.row.description" autocomplete="off"
|
|
- placeholder="请输入事件描述" :disabled="scope.row.id ? true : false"></el-input>
|
|
|
|
|
|
+ placeholder="请输入事件描述"></el-input>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
- <el-table-column prop="applicationScenarios" label="事件场景" align="center">
|
|
|
|
|
|
+ <el-table-column prop="scenarioId" label="事件场景" align="center">
|
|
<template slot-scope="scope">
|
|
<template slot-scope="scope">
|
|
<div>
|
|
<div>
|
|
<!-- multiple -->
|
|
<!-- multiple -->
|
|
- <el-select v-model="scope.row.applicationScenarios[0]" :disabled="scope.row.id ? true : false"
|
|
|
|
|
|
+ <el-select v-model="scope.row.scenarioId"
|
|
style="width: 100%;" placeholder="请选择事件场景">
|
|
style="width: 100%;" placeholder="请选择事件场景">
|
|
<el-option
|
|
<el-option
|
|
v-for="item in commonData.ENTERPRISE_APPLICATION_SCENARIO ? commonData.ENTERPRISE_APPLICATION_SCENARIO : []"
|
|
v-for="item in commonData.ENTERPRISE_APPLICATION_SCENARIO ? commonData.ENTERPRISE_APPLICATION_SCENARIO : []"
|
|
@@ -125,28 +126,32 @@ export default {
|
|
//表格数据
|
|
//表格数据
|
|
formData: [
|
|
formData: [
|
|
{
|
|
{
|
|
- questionName: '',
|
|
|
|
|
|
+ name: '',
|
|
eventDate: '',
|
|
eventDate: '',
|
|
description: '',
|
|
description: '',
|
|
- applicationScenarios: [],
|
|
|
|
|
|
+ scenarioId: '',
|
|
}
|
|
}
|
|
],
|
|
],
|
|
//检验规则
|
|
//检验规则
|
|
rules: {
|
|
rules: {
|
|
- questionName: [ { required: true, message: '请输入事件名称', trigger: 'blur' },],
|
|
|
|
|
|
+ name: [ { required: true, message: '请输入事件名称', trigger: 'blur' },],
|
|
|
|
+ scenarioId: [ { required: true, message: '请选择事件场景', trigger: 'change' },],
|
|
},
|
|
},
|
|
//应用场景数据
|
|
//应用场景数据
|
|
commonData: {},
|
|
commonData: {},
|
|
//弹窗类型
|
|
//弹窗类型
|
|
type: 1,
|
|
type: 1,
|
|
|
|
+ queryParams: {
|
|
|
|
+ current: 1,
|
|
|
|
+ size:2,
|
|
|
|
+ },
|
|
|
|
+ eventInput:'',
|
|
}
|
|
}
|
|
},
|
|
},
|
|
watch: {},
|
|
watch: {},
|
|
async mounted() {
|
|
async mounted() {
|
|
// 应用场景(是通过字典还是接口待定)
|
|
// 应用场景(是通过字典还是接口待定)
|
|
await this.getCommonData()
|
|
await this.getCommonData()
|
|
- // 查询所有事件
|
|
|
|
- // await this.questionEventList()
|
|
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
//打开弹窗,判断是编辑还是添加,同时判断是批量添加还是添加单个事件(type==1是单个,type==2是批量)
|
|
//打开弹窗,判断是编辑还是添加,同时判断是批量添加还是添加单个事件(type==1是单个,type==2是批量)
|
|
@@ -154,8 +159,9 @@ export default {
|
|
this.type = type
|
|
this.type = type
|
|
if (data) {
|
|
if (data) {
|
|
this.title = '编辑事件'
|
|
this.title = '编辑事件'
|
|
- this.formData[0] = JSON.parse(JSON.stringify(data))
|
|
|
|
- console.log(this.formData);
|
|
|
|
|
|
+ let form = JSON.parse(JSON.stringify(data))
|
|
|
|
+ this.$set(this.formData, 0, form)
|
|
|
|
+ // console.log(this.formData);
|
|
} else {
|
|
} else {
|
|
if (this.type == 1) {
|
|
if (this.type == 1) {
|
|
this.title='新增事件'
|
|
this.title='新增事件'
|
|
@@ -164,10 +170,10 @@ export default {
|
|
}
|
|
}
|
|
this.formData = [
|
|
this.formData = [
|
|
{
|
|
{
|
|
- questionName: '',
|
|
|
|
|
|
+ name: '',
|
|
eventDate: '',
|
|
eventDate: '',
|
|
description: '',
|
|
description: '',
|
|
- applicationScenarios: [],
|
|
|
|
|
|
+ scenarioId: '',
|
|
}
|
|
}
|
|
]
|
|
]
|
|
}
|
|
}
|
|
@@ -196,18 +202,18 @@ export default {
|
|
this.formData.forEach(item => {
|
|
this.formData.forEach(item => {
|
|
var a = false
|
|
var a = false
|
|
for (let key in item) {
|
|
for (let key in item) {
|
|
- if (key != 'applicationScenarios') {
|
|
|
|
|
|
+ // if (key != 'scenarioId') {
|
|
if (item[key] != '' && item[key] != null) {
|
|
if (item[key] != '' && item[key] != null) {
|
|
a = true
|
|
a = true
|
|
}
|
|
}
|
|
- }else {
|
|
|
|
- if (item[key].length > 0) {
|
|
|
|
- a = true
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ // }else {
|
|
|
|
+ // if (item[key].length > 0) {
|
|
|
|
+ // a = true
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
}
|
|
}
|
|
if (a == true) {
|
|
if (a == true) {
|
|
- if (item.questionName != '') {
|
|
|
|
|
|
+ if (item.name != '') {
|
|
list.push(item)
|
|
list.push(item)
|
|
} else {
|
|
} else {
|
|
throw new Error('事件名称不能为空')
|
|
throw new Error('事件名称不能为空')
|
|
@@ -215,7 +221,7 @@ export default {
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- var arr = [...new Set(list.map(item => { return item.questionName }))]
|
|
|
|
|
|
+ var arr = [...new Set(list.map(item => { return item.name }))]
|
|
if (arr.length < list.length) {
|
|
if (arr.length < list.length) {
|
|
this.$message.error(`存在重复的事件名称,请重定义事件名称`)
|
|
this.$message.error(`存在重复的事件名称,请重定义事件名称`)
|
|
return false
|
|
return false
|
|
@@ -233,31 +239,43 @@ export default {
|
|
// 提交保存事件
|
|
// 提交保存事件
|
|
addFormData(val) {
|
|
addFormData(val) {
|
|
let lists = JSON.parse(JSON.stringify(val.list))
|
|
let lists = JSON.parse(JSON.stringify(val.list))
|
|
- let forms = {
|
|
|
|
- projectId: this.projectId,
|
|
|
|
- eventAddNewDTOs:lists
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
if (this.type=='1') {//单个事件新增
|
|
if (this.type=='1') {//单个事件新增
|
|
this.$refs.ruleForm.validate(valid => {
|
|
this.$refs.ruleForm.validate(valid => {
|
|
if (valid) {
|
|
if (valid) {
|
|
- this.addInterface(forms)
|
|
|
|
|
|
+ this.addInterface(lists)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
} else {//多个事件新增
|
|
} else {//多个事件新增
|
|
- this.addInterface(forms)
|
|
|
|
|
|
+ this.addInterface(lists)
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- //提交保存事件接口
|
|
|
|
|
|
+ //提交保存、编辑事件接口
|
|
addInterface(forms) {
|
|
addInterface(forms) {
|
|
- this.$api.eventAddNew(forms).then(res => {
|
|
|
|
- if (res.code == 200) {
|
|
|
|
- this.$emit('isSuccess','新增成功')
|
|
|
|
- this.$message.success('事件新增成功')
|
|
|
|
- this.handleClose()
|
|
|
|
- }
|
|
|
|
- }).catch(error => {
|
|
|
|
- this.$message.error(error.message)
|
|
|
|
- })
|
|
|
|
|
|
+ let formData = new FormData()
|
|
|
|
+ // formData.append('file')//文件数据
|
|
|
|
+ formData.append('event', JSON.stringify(forms[0]))
|
|
|
|
+ if (forms[0].id) {//编辑
|
|
|
|
+ this.$api.eventEditEvent(formData).then(res => {
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
+ this.$emit('isSuccess','编辑成功')
|
|
|
|
+ this.$message.success('事件编辑成功')
|
|
|
|
+ this.handleClose()
|
|
|
|
+ }
|
|
|
|
+ }).catch(error => {
|
|
|
|
+ this.$message.error(error.message)
|
|
|
|
+ })
|
|
|
|
+ } else {//新增
|
|
|
|
+ this.$api.eventAddEvent(formData).then(res => {
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
+ this.$emit('isSuccess','新增成功')
|
|
|
|
+ this.$message.success('事件新增成功')
|
|
|
|
+ this.handleClose()
|
|
|
|
+ }
|
|
|
|
+ }).catch(error => {
|
|
|
|
+ this.$message.error(error.message)
|
|
|
|
+ })
|
|
|
|
+ }
|
|
},
|
|
},
|
|
//重置全部事件
|
|
//重置全部事件
|
|
resetForm() {
|
|
resetForm() {
|
|
@@ -271,10 +289,10 @@ export default {
|
|
}
|
|
}
|
|
this.formData = [
|
|
this.formData = [
|
|
{
|
|
{
|
|
- questionName: '',
|
|
|
|
|
|
+ name: '',
|
|
eventDate: '',
|
|
eventDate: '',
|
|
description: '',
|
|
description: '',
|
|
- applicationScenarios: [],
|
|
|
|
|
|
+ scenarioId: '',
|
|
}
|
|
}
|
|
]
|
|
]
|
|
// this.$emit('formData', {list:this.formData,option:1})
|
|
// this.$emit('formData', {list:this.formData,option:1})
|
|
@@ -287,10 +305,10 @@ export default {
|
|
addRow() {
|
|
addRow() {
|
|
this.formData.push(
|
|
this.formData.push(
|
|
{
|
|
{
|
|
- questionName: '',
|
|
|
|
|
|
+ name: '',
|
|
eventDate: '',
|
|
eventDate: '',
|
|
description: '',
|
|
description: '',
|
|
- applicationScenarios: [],
|
|
|
|
|
|
+ scenarioId: '',
|
|
}
|
|
}
|
|
)
|
|
)
|
|
},
|
|
},
|
|
@@ -298,30 +316,36 @@ export default {
|
|
deleteRow(row) {
|
|
deleteRow(row) {
|
|
this.formData.splice(row.$index, 1)
|
|
this.formData.splice(row.$index, 1)
|
|
},
|
|
},
|
|
- // 查询所有事件
|
|
|
|
|
|
+ // 懒加载方法
|
|
|
|
+ load() {
|
|
|
|
+ this.queryParams.size += 2
|
|
|
|
+ this.questionEventList()
|
|
|
|
+ },
|
|
|
|
+ // 查询事件
|
|
async questionEventList() {
|
|
async questionEventList() {
|
|
- await this.$api.eventQuery({}).then(res => {
|
|
|
|
|
|
+ let searchValue={name:this.eventInput}
|
|
|
|
+ let params = {
|
|
|
|
+ ...this.queryParams,//分页信息
|
|
|
|
+ searchQuery:this.$commonJS.objectToString(searchValue)//输入的建议
|
|
|
|
+ }
|
|
|
|
+ await this.$api.queryEvent(params).then(res => {
|
|
if (res.code == 200) {
|
|
if (res.code == 200) {
|
|
- this.questionNameArr = res.data.list
|
|
|
|
|
|
+ this.questionNameArr = res.data.data
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
//获取下拉建议数据
|
|
//获取下拉建议数据
|
|
- querySearchQuestion(queryString, cb) {
|
|
|
|
- var restaurants = this.questionNameArr.map(item => {
|
|
|
|
- item.value = item.questionName;
|
|
|
|
- return item;
|
|
|
|
- });
|
|
|
|
- var results = queryString ? restaurants.filter(this.createFilterQuestion(queryString)) : restaurants;
|
|
|
|
|
|
+ async querySearchQuestion(queryString, cb) {
|
|
|
|
+ this.eventInput=queryString
|
|
|
|
+ await this.questionEventList()
|
|
|
|
+ console.log(this.questionNameArr, cb);
|
|
|
|
+ var records=[]
|
|
|
|
+ this.questionNameArr.forEach(item => {
|
|
|
|
+ item.value = item.name
|
|
|
|
+ records.push(item)
|
|
|
|
+ })
|
|
// 调用 callback 返回建议列表的数据
|
|
// 调用 callback 返回建议列表的数据
|
|
- cb(results);
|
|
|
|
- },
|
|
|
|
- // 对下拉建议列表的数据进行处理
|
|
|
|
- createFilterQuestion(queryString) {
|
|
|
|
- return (restaurant) => {
|
|
|
|
- console.log(restaurant);
|
|
|
|
- return (restaurant.value.indexOf(queryString) != -1);
|
|
|
|
- };
|
|
|
|
|
|
+ cb(records);
|
|
},
|
|
},
|
|
// input框切换选择
|
|
// input框切换选择
|
|
handleSelectQuestion(val) {
|
|
handleSelectQuestion(val) {
|
|
@@ -348,6 +372,7 @@ export default {
|
|
change1(val) {
|
|
change1(val) {
|
|
// console.log(val);
|
|
// console.log(val);
|
|
},
|
|
},
|
|
|
|
+
|
|
},
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|