提交 6c277e63 authored 作者: pengxiaohui's avatar pengxiaohui

版本功能优化

上级 8530cf81
......@@ -36,3 +36,10 @@ export function updateCase2(id, data) {
}
return httpRequest.put(`/api/opera/v2/training/${id}/case`, data, { headers })
}
// 发布案例
export function publishCase2(id, data) {
var headers = {
'Content-Type': 'application/json'
}
return httpRequest.post(`/api/opera/v2/training/case/${id}/publish`, data, { headers })
}
......@@ -39,3 +39,10 @@ export function reachSchemeList(params) {
}
return httpRequest.get('/api/opera/v2/training/reach-schemes', { params }, { headers })
}
// 拷贝触达
export function copyReachScheme(id, data) {
var headers = {
'Content-Type': 'application/json'
}
return httpRequest.post(`/api/opera/v2/training/reach-scheme/${id}/copy`, data, { headers })
}
......@@ -21,7 +21,8 @@
</el-input>
<el-button size="mini" icon="el-icon-search" @click="list({ name: searchCaseName, page: 1, limit: limit })">搜 索</el-button>
<el-button type="primary" size="mini" icon="el-icon-refresh" @click="refresh">刷 新</el-button>
<el-button type="primary" size="mini" icon="el-icon-plus" @click="drawer = true">创建案例</el-button>
<el-button type="primary" size="mini" icon="el-icon-plus" @click="handleNewCreate">新建案例</el-button>
<el-button type="primary" size="mini" icon="el-icon-document-add" @click="handleDraftCreate" v-if="formDraftStr">通过草稿创建案例</el-button>
</div>
</el-card>
</div>
......@@ -74,8 +75,8 @@
<el-image
style="width: 100px; height: 100px;"
fit="scale-down"
:src="scope.row.url"
:preview-src-list="[scope.row.url]">
:src="scope.row.uris[0] ? scope.row.uris[0].uri: scope.row.uri"
:preview-src-list="scope.row.uris[0] ? scope.row.uris.map(item => item.uri):[scope.row.uri]">
</el-image>
</div>
</div>
......@@ -108,15 +109,34 @@
<span style="margin-left: 10px">{{ scope.row.updated_at }}</span>
</template>
</el-table-column>
<el-table-column label="发布状态" fixed="right" width="80">
<template slot-scope="scope">
<el-switch
v-model="scope.row.is_show"
active-color="#c01540"
inactive-color="#dcdfe6"
:active-value="1"
:inactive-value="0"
@change="handlePublish(scope.row)"
>
</el-switch>
</template>
</el-table-column>
<el-table-column
fixed="right"
label="操作"
width="100">
<template slot-scope="scope">
<el-select size="mini" :value="opera" @change="operation" placeholder="请选择">
<el-option :value="{ tag: 'edit', row: scope.row }" label="编辑"></el-option>
<el-option :value="{ tag: 'delete', row: scope.row }" label="删除"></el-option>
</el-select>
<el-dropdown @command="type => handleCommand(type, scope.row)">
<span class="el-dropdown-link">
<!-- 请选择<i class="el-icon-arrow-down el-icon--right"></i> -->
<el-button size="mini">请选择<i class="el-icon-arrow-down el-icon--right"></i></el-button>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="edit">编辑</el-dropdown-item>
<el-dropdown-item command="delete">删除</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
......@@ -216,7 +236,7 @@
:direction="direction"
:append-to-body="true"
:withHeader="true"
:before-close="handleClose"
:wrapperClosable="false"
ref="drawer"
size="50%">
<div class="demo-drawer__content">
......@@ -259,7 +279,8 @@
<el-upload
action="/api/opera/v1/file/upload"
list-type="picture-card"
:limit="1"
:limit="100"
:file-list="addForm.uris"
:on-success="uploadUrlSuccess"
:multiple="false"
:data="{ type: 'image' }"
......@@ -267,8 +288,8 @@
<i class="el-icon-plus"></i>
</el-upload>
<el-dialog :visible.sync="visible" append-to-body>
<img width="100%" :src="addForm.url" alt="">
<el-input :v-model="addForm.url" :value="addForm.url"></el-input>
<img width="100%" :src="imgPreview" alt="">
<el-input :v-model="imgPreview" :value="imgPreview"></el-input>
</el-dialog>
</el-form-item>
<el-form-item>
......@@ -421,7 +442,8 @@
<el-form-item>
<div class="demo-drawer__footer" style="margin-left: 60%">
<el-button @click="cancelForm">取 消</el-button>
<el-button type="primary" @click="$refs.drawer.closeDrawer()" :loading="loading">{{ loading ? '提交中 ...' : '确 定' }}</el-button>
<el-button type="primary" plain @click="handleFormDraft">暂 存</el-button>
<el-button type="primary" @click="handleFormEnsure" :loading="loading">{{ loading ? '提交中 ...' : '确 定' }}</el-button>
</div>
</el-form-item>
</el-form>
......@@ -435,10 +457,58 @@
<script>
import * as casesApi from '@/api/cases2'
import * as categoryApi from '@/api/categories'
const defaultForm = {
name: '',
level: '',
category_id: 0,
accessory: '',
uris: [],
production_detail: [
{
name: '',
show_type: 'input',
show_info: '',
keywords: [
{
name: '',
score: '0'
}
]
}
],
fund_detail: [
{
name: '',
show_type: 'input',
show_info: '',
keywords: [
{
name: '',
score: 0
}
]
}
],
invest_detail: [
{
name: '',
show_type: 'input',
show_info: '',
keywords: [
{
name: '',
score: 0
}
]
}
]
}
export default {
mounted() {
this.list({ page: this.currentPage, limit: this.limit })
this.categoryList()
this.formDraftStr = window.localStorage.getItem('caseFormDraftData')
console.log(JSON.parse(this.formDraftStr))
},
data() {
return {
......@@ -466,57 +536,14 @@ export default {
drawer: false,
direction: 'rtl',
show_types: ['input', 'textarea'],
addForm: {
name: '',
level: '',
category_id: 0,
accessory: '',
url: '',
production_detail: [
{
name: '',
show_type: 'input',
show_info: '',
keywords: [
{
name: '',
score: '0'
}
]
}
],
fund_detail: [
{
name: '',
show_type: 'input',
show_info: '',
keywords: [
{
name: '',
score: 0
}
]
}
],
invest_detail: [
{
name: '',
show_type: 'input',
show_info: '',
keywords: [
{
name: '',
score: 0
}
]
}
]
},
addForm: Object.assign({}, defaultForm),
formDraftStr: '',
pdfFileList: [],
formLabelWidth: '100px',
loading: false,
options: [],
visible: false
visible: false,
imgPreview: ''
}
},
methods: {
......@@ -556,6 +583,26 @@ export default {
}
return detail
},
handleCommand(type, rowData) {
switch (type) {
case 'edit':
this.$router.push({ path: '/training/cases/update', query: { id: rowData.id } })
break
case 'delete':
this.handleDelete(rowData)
break
}
},
handlePublish(val) {
console.log(val)
casesApi.publishCase2(val.id, { is_show: val.is_show }).then(res => {
if (res.code === 0 && res.data && res.data.status) {
this.$message.success('更新发布状态成功')
} else {
this.$message.error('更新发布状态失败')
}
})
},
operation(opera) {
switch (opera.tag) {
case 'detail':
......@@ -624,6 +671,75 @@ export default {
this.drawer = false
clearTimeout(this.timer)
},
handleNewCreate() {
this.addForm = Object.assign({}, defaultForm)
this.drawer = true
},
handleDraftCreate() {
const data = JSON.parse(this.formDraftStr)
this.addForm = data
this.drawer = true
},
handleFormDraft() {
const data = JSON.stringify(this.addForm)
this.formDraftStr = data
window.localStorage.setItem('caseFormDraftData', data)
this.$message.success('数据暂存成功')
this.drawer = false
},
handleFormEnsure() {
if (this.loading) {
return
}
this.loading = true
const form = { ...this.addForm }
const checkedPro = this.checkFormDetailsNull(form.production_detail)
const checkedFoud = this.checkFormDetailsNull(form.fund_detail)
const checkedInvest = this.checkFormDetailsNull(form.invest_detail)
if (!checkedPro) delete form.production_detail
if (!checkedFoud) delete form.fund_detail
if (!checkedInvest) delete form.invest_detail
// 提交表单
const rLoading = this.openLoading('.table-list')
casesApi.createCase2(form).then(res => {
if (res.code === 0 && res.message === 'SUCCESS') {
this.list({ page: this.currentPage, limit: this.limit })
this.initAddForm()
this.cancelForm()
this.$message.success('添加案例成功')
} else {
this.$message.warning(res.message)
}
rLoading.close()
})
this.timer = setTimeout(() => {
// 动画关闭需要一定的时间
setTimeout(() => {
this.loading = false
}, 400)
}, 2000)
},
checkFormDetailsNull(list) {
let res = true
list.forEach(item => {
if (item.name) res = false
})
for (let i = 0; i < list.length; i++) {
if (list[i].name || list[i].show_info) {
res = false
break
} else {
const keywords = list[i].keywords
for (let j = 0; j < keywords.length; j++) {
if (keywords[i].name || list[i].score !== '0') {
res = false
break
}
}
}
}
return res
},
initAddForm() {
this.addForm = {
name: '',
......@@ -672,35 +788,6 @@ export default {
]
}
},
handleClose(done) {
if (this.loading) {
return
}
this.$confirm('确定要提交表单吗?')
.then(_ => {
this.loading = true
// 提交表单
const rLoading = this.openLoading('.table-list')
casesApi.createCase2(this.addForm).then(res => {
if (res.code === 0 && res.message === 'SUCCESS') {
this.list({ page: this.currentPage, limit: this.limit })
this.initAddForm()
this.$message.success('添加案例成功')
} else {
this.$message.warning(res.message)
}
rLoading.close()
})
this.timer = setTimeout(() => {
done()
// 动画关闭需要一定的时间
setTimeout(() => {
this.loading = false
}, 400)
}, 2000)
})
.catch(_ => {})
},
searchCategory(keyword) {
categoryApi.categories({ name: keyword, page: 1, limit: 10 }).then(res => {
if (res.code === 0) {
......@@ -773,6 +860,13 @@ export default {
var data = response.data
var imageInfo = data[0]
this.addForm.url = imageInfo.url
this.addForm.uris.push({
uri: imageInfo.url,
url: imageInfo.url,
title: imageInfo.title,
size: imageInfo.size,
md5: imageInfo.md5
})
this.visible = false
} else {
console.log('文件上传失败')
......@@ -783,9 +877,7 @@ export default {
this.$message.warning(`当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`)
},
createPictureCardPreview(file) {
if (!this.addForm.url) {
this.addForm.url = file.url
}
this.imgPreview = file.url
this.visible = true
},
addNames(detailName, index) {
......@@ -856,7 +948,7 @@ export default {
}
</script>
<style>
<style scoped>
.el-drawer {
overflow: auto;
}
......
......@@ -66,11 +66,17 @@
</el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-select size="mini" :value="opera" @change="operation" placeholder="请选择">
<el-option :value="{ tag: 'edit', row: scope.row }" label="编辑"></el-option>
<el-option :value="{ tag: 'addChild', row: scope.row }" label="添加子分类"></el-option>
<el-option :value="{ tag: 'delete', row: scope.row }" label="删除"></el-option>
</el-select>
<el-dropdown @command="type => handleCommand(type, scope.row)">
<span class="el-dropdown-link">
<!-- 请选择<i class="el-icon-arrow-down el-icon--right"></i> -->
<el-button size="mini">请选择<i class="el-icon-arrow-down el-icon--right"></i></el-button>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="edit">编辑</el-dropdown-item>
<el-dropdown-item command="addChild">添加子分类</el-dropdown-item>
<el-dropdown-item command="delete">删除</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
......@@ -398,30 +404,28 @@ export default {
})
})
},
operation(opera) {
switch (opera.tag) {
case 'detail':
break
handleCommand(type, rowData) {
switch (type) {
case 'edit':
this.updateForm.id = opera.row.id
this.updateForm.name = opera.row.name
this.updateForm.tag = opera.row.tag
this.updateForm.url = opera.row.url
if (opera.row.url) {
this.updateFileList = [{ url: opera.row.url }]
this.updateForm.id = rowData.id
this.updateForm.name = rowData.name
this.updateForm.tag = rowData.tag
this.updateForm.url = rowData.url
if (rowData.url) {
this.updateFileList = [{ url: rowData.url }]
}
this.updateForm.order = opera.row.order
this.updateForm.order = rowData.order
this.editCategoryDialogFormVisible = true
break
case 'delete':
this.handleDelete(rowData.id)
break
case 'addChild':
this.childForm.tag = opera.row.tag
this.childForm.pid = opera.row.id
this.parentName = opera.row.name
this.childForm.tag = rowData.tag
this.childForm.pid = rowData.id
this.parentName = rowData.name
this.childCategoryDialogFormVisible = true
break
case 'delete':
this.handleDelete(opera.row.id)
break
}
},
add() {
......
......@@ -21,7 +21,8 @@
</el-input>
<el-button size="mini" icon="el-icon-search" @click="list({ name: searchCaseName, page: 1, limit: limit })">搜 索</el-button>
<el-button type="primary" size="mini" icon="el-icon-refresh" @click="refresh">刷 新</el-button>
<el-button type="primary" size="mini" icon="el-icon-plus" @click="drawer = true">创建特征</el-button>
<el-button type="primary" size="mini" icon="el-icon-plus" @click="handleNewCreate">新建特征</el-button>
<el-button type="primary" size="mini" icon="el-icon-document-add" @click="handleDraftCreate" v-if="formDraftStr">通过草稿创建特征</el-button>
</div>
</el-card>
</div>
......@@ -71,11 +72,17 @@
</el-table-column>
<el-table-column fixed="right" label="操作">
<template slot-scope="scope">
<el-select size="mini" :value="opera" @change="operation" placeholder="请选择">
<el-option :value="{ tag: 'edit', row: scope.row }" label="编辑"></el-option>
<el-option :value="{ tag: 'copy', row: scope.row }" label="复制"></el-option>
<el-option :value="{ tag: 'delete', row: scope.row }" label="删除"></el-option>
</el-select>
<el-dropdown @command="type => handleCommand(type, scope.row)">
<span class="el-dropdown-link">
<!-- 请选择<i class="el-icon-arrow-down el-icon--right"></i> -->
<el-button size="mini">请选择<i class="el-icon-arrow-down el-icon--right"></i></el-button>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="edit">编辑</el-dropdown-item>
<el-dropdown-item command="copy">复制</el-dropdown-item>
<el-dropdown-item command="delete">删除</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
......@@ -99,7 +106,7 @@
direction="rtl"
:append-to-body="true"
:withHeader="true"
:before-close="handleClose"
:wrapperClosable="false"
ref="drawer"
size="70%">
<div class="demo-drawer__content">
......@@ -222,7 +229,8 @@
<el-form-item>
<div class="demo-drawer__footer" style="margin-left: 60%">
<el-button @click="cancelForm">取 消</el-button>
<el-button type="primary" @click="$refs.drawer.closeDrawer()" :loading="loading">{{ loading ? '提交中 ...' : '确 定' }}</el-button>
<el-button type="primary" plain @click="handleFormDraft">暂 存</el-button>
<el-button type="primary" @click="handleFormEnsure" :loading="loading">{{ loading ? '提交中 ...' : '确 定' }}</el-button>
</div>
</el-form-item>
</el-form>
......@@ -336,6 +344,37 @@
<script>
import * as characteristicsApi from '@/api/characteristics2'
import * as casesApi from '@/api/cases2'
const defaultForm = {
case2_id: '',
options: [
{
name: '',
options: [
{
option: 'A',
option_name: '',
answer: 0,
score: 0,
warning: 0
}
]
}
],
rules: [
{
min: 0,
max: 10,
score: 0
}
],
levels: [
{
min: 0,
max: 10,
level: 1
}
]
}
export default {
name: 'index',
data() {
......@@ -372,43 +411,15 @@ export default {
rules: [],
options: [],
levels: [],
addForm: {
case2_id: '',
options: [
{
name: '',
options: [
{
option: 'A',
option_name: '',
answer: 0,
score: 0,
warning: 0
}
]
}
],
rules: [
{
min: 0,
max: 10,
score: 0
}
],
levels: [
{
min: 0,
max: 10,
level: 1
}
]
}
addForm: Object.assign({}, defaultForm),
formDraftStr: ''
}
},
mounted() {
this.list({ page: this.currentPage, limit: this.limit })
this.caseList({ page: 1, limit: 10 })
this.AZkey = this.A_Z()
this.formDraftStr = window.localStorage.getItem('characFormDraftData')
},
methods: {
A_Z() {
......@@ -442,20 +453,18 @@ export default {
handleCurrentChange(val) {
this.list({ page: val, limit: this.limit })
},
operation(opera) {
switch (opera.tag) {
case 'detail':
break
case 'copy':
this.copyDialogTableVisible = true
this.copyTitle = opera.row.case.name
this.copyId = opera.row.id + ''
break
handleCommand(type, rowData) {
switch (type) {
case 'edit':
this.$router.push({ path: '/training/characteristics/update', query: { id: opera.row.id } })
this.$router.push({ path: '/training/characteristics/update', query: { id: rowData.id } })
break
case 'delete':
this.handleDelete(opera.row.id)
this.handleDelete(rowData.id)
break
case 'copy':
this.copyDialogTableVisible = true
this.copyTitle = rowData.case.name
this.copyId = rowData.id
break
}
},
......@@ -533,39 +542,48 @@ export default {
this.drawer = false
clearTimeout(this.timer)
},
handleClose(done) {
handleNewCreate() {
this.addForm = Object.assign({}, defaultForm)
this.drawer = true
},
handleDraftCreate() {
console.log(JSON.parse(this.formDraftStr))
const data = JSON.parse(this.formDraftStr)
this.addForm = data
this.drawer = true
},
handleFormDraft() {
const data = JSON.stringify(this.addForm)
window.localStorage.setItem('characFormDraftData', data)
},
handleFormEnsure() {
if (this.loading) {
return
}
this.$confirm('确定要提交表单吗?')
.then(_ => {
this.loading = true
// 提交表单
const rLoading = this.openLoading('.table-list')
characteristicsApi.createCharacteristic2(this.addForm).then(res => {
if (res.code === 0) {
this.list({ page: 1, limit: this.limit })
this.caseList({ page: 1, limit: 10 })
this.AZkey = this.A_Z()
rLoading.close()
this.$message.success(res.message)
return true
} else {
rLoading.close()
this.$message.error(res.message)
return false
}
})
this.loading = true
// 提交表单
const rLoading = this.openLoading('.table-list')
characteristicsApi.createCharacteristic2(this.addForm).then(res => {
rLoading.close()
this.loading = false
if (res.code === 0) {
this.list({ page: 1, limit: this.limit })
this.caseList({ page: 1, limit: 10 })
this.AZkey = this.A_Z()
this.$message.success(res.message)
return true
} else {
this.$message.error(res.message)
return false
}
})
this.timer = setTimeout(() => {
done()
// 动画关闭需要一定的时间
setTimeout(() => {
this.loading = false
}, 400)
}, 2000)
})
.catch(_ => {})
this.timer = setTimeout(() => {
// 动画关闭需要一定的时间
setTimeout(() => {
this.loading = false
}, 400)
}, 2000)
},
remoteMethod(query) {
this.caseList({ name: query, page: 1, limit: 10 })
......
......@@ -59,10 +59,17 @@
</el-table-column>
<el-table-column fixed="right" label="操作">
<template slot-scope="scope">
<el-select size="mini" :value="opera" @change="operation" placeholder="请选择">
<el-option :value="{ tag: 'edit', row: scope.row }" label="编辑"></el-option>
<el-option :value="{ tag: 'delete', row: scope.row }" label="删除"></el-option>
</el-select>
<el-dropdown @command="type => handleCommand(type, scope.row)">
<span class="el-dropdown-link">
<!-- 请选择<i class="el-icon-arrow-down el-icon--right"></i> -->
<el-button size="mini">请选择<i class="el-icon-arrow-down el-icon--right"></i></el-button>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="edit">编辑</el-dropdown-item>
<el-dropdown-item command="copy">复制</el-dropdown-item>
<el-dropdown-item command="delete">删除</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
......@@ -81,12 +88,12 @@
</div>
<div>
<el-drawer
title="创建特征"
title="创建触达"
:visible.sync="drawer"
direction="rtl"
:append-to-body="true"
:withHeader="true"
:before-close="handleClose"
:wrapperClosable="false"
ref="drawer"
size="50%">
<div class="demo-drawer__content">
......@@ -129,7 +136,7 @@
<el-form-item>
<div class="demo-drawer__footer" style="margin-left: 60%">
<el-button @click="cancelForm">取 消</el-button>
<el-button type="primary" @click="$refs.drawer.closeDrawer()" :loading="loading">{{ loading ? '提交中 ...' : '确 定' }}</el-button>
<el-button type="primary" @click="handleFormEnsure" :loading="loading">{{ loading ? '提交中 ...' : '确 定' }}</el-button>
</div>
</el-form-item>
</el-form>
......@@ -152,6 +159,31 @@
</div>
</el-dialog>
</div>
<el-dialog center :title="copyTitle" :visible.sync="copyDialogVisible">
<el-form size="mini" :model="copyForm">
<el-form-item label="案例:" :label-width="formLabelWidth">
<el-select
v-model="copyForm.case2_id"
filterable
remote
reserve-keyword
placeholder="请输入案例名称"
:remote-method="remoteMethod"
:loading="caseLoading">
<el-option
v-for="casesItem in cases"
:key="casesItem.value"
:label="casesItem.name"
:value="casesItem.id">
</el-option>
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button size="mini" @click="copyDialogVisible = false">取 消</el-button>
<el-button size="mini" type="primary" @click="handleCopy">确 定</el-button>
</div>
</el-dialog>
</div>
</template>
......@@ -183,6 +215,12 @@ export default {
score: 0
}
]
},
copyTitle: '复制',
copyDialogVisible: false,
copyTargetId: '',
copyForm: {
case2_id: ''
}
}
},
......@@ -197,19 +235,33 @@ export default {
handleCurrentChange(val) {
this.list({ page: val, limit: this.limit })
},
operation(opera) {
switch (opera.tag) {
case 'detail':
break
handleCommand(type, rowData) {
switch (type) {
case 'edit':
this.$router.push({ path: '/training/reachschemes/update', query: { id: opera.row.id } })
this.$router.push({ path: '/training/reachschemes/update', query: { id: rowData.id } })
break
case 'delete':
this.delete(opera.row.id)
this.handleDelete(rowData.id)
break
case 'copy':
this.copyDialogVisible = true
this.copyTitle = rowData.case.name
this.copyTargetId = rowData.id
break
}
},
delete(id) {
handleCopy() {
reachSchemeApi.copyReachScheme(this.copyTargetId, { case2_id: this.copyForm.case2_id + '' }).then(res => {
if (res.code === 0 && res.data && res.data.case2_id) {
this.$message.success('复制案例成功')
this.copyDialogVisible = false
this.list({ page: this.currentPage, limit: this.limit })
} else {
this.$message.error(res.message || '复制案例失败')
}
})
},
handleDelete(id) {
this.$confirm('确认删除?', '提示').then(_ => {
const rLoading = this.openLoading('.table-list')
reachSchemeApi.deleteReachScheme(id).then(res => {
......@@ -259,47 +311,6 @@ export default {
this.searchCaseName = ''
this.list({ page: 1, limit: this.limit })
},
handleClose(done) {
if (this.loading) {
return
}
this.$confirm('确定要提交表单吗?')
.then(_ => {
this.loading = true
// 提交表单
const rLoading = this.openLoading('.table-list')
reachSchemeApi.createReachScheme(this.addForm).then(res => {
if (res.code === 0) {
this.list({ page: 1, limit: this.limit })
this.caseList({ page: 1, limit: 10 })
this.addForm = {
case2_id: '',
keywords: [
{
keyword: '',
score: 0
}
]
}
rLoading.close()
this.$message.success(res.message)
return true
} else {
rLoading.close()
this.$message.error(res.message)
return false
}
})
this.timer = setTimeout(() => {
done()
// 动画关闭需要一定的时间
setTimeout(() => {
this.loading = false
}, 400)
}, 2000)
})
.catch(_ => {})
},
remoteMethod(query) {
this.caseList({ name: query, page: 1, limit: 10 })
},
......@@ -308,6 +319,43 @@ export default {
this.drawer = false
clearTimeout(this.timer)
},
handleFormEnsure() {
if (this.loading) {
return
}
this.loading = true
// 提交表单
const rLoading = this.openLoading('.table-list')
reachSchemeApi.createReachScheme(this.addForm).then(res => {
if (res.code === 0) {
this.list({ page: 1, limit: this.limit })
this.caseList({ page: 1, limit: 10 })
this.addForm = {
case2_id: '',
keywords: [
{
keyword: '',
score: 0
}
]
}
rLoading.close()
this.$message.success('创建成功')
this.drawer = false
return true
} else {
rLoading.close()
this.$message.error(res.message || '创建失败')
return false
}
})
this.timer = setTimeout(() => {
// 动画关闭需要一定的时间
setTimeout(() => {
this.loading = false
}, 400)
}, 2000)
},
addKeywords(keywordIndex) {
this.addForm.keywords.push({ keyword: '', score: 0 })
},
......
......@@ -70,10 +70,16 @@
</el-table-column>
<el-table-column fixed="right" label="操作">
<template slot-scope="scope">
<el-select size="mini" :value="opera" @change="operation" placeholder="请选择">
<el-option :value="{ tag: 'edit', row: scope.row }" label="编辑"></el-option>
<el-option :value="{ tag: 'delete', row: scope.row }" label="删除"></el-option>
</el-select>
<el-dropdown @command="type => handleCommand(type, scope.row)">
<span class="el-dropdown-link">
<!-- 请选择<i class="el-icon-arrow-down el-icon--right"></i> -->
<el-button size="mini">请选择<i class="el-icon-arrow-down el-icon--right"></i></el-button>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="edit">编辑</el-dropdown-item>
<el-dropdown-item command="delete">删除</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
......@@ -97,7 +103,7 @@
direction="rtl"
:append-to-body="true"
:withHeader="true"
:before-close="handleClose"
:wrapperClosable="false"
ref="drawer"
size="50%">
<div class="demo-drawer__content">
......@@ -140,7 +146,7 @@
<el-form-item>
<div class="demo-drawer__footer" style="margin-left: 60%">
<el-button @click="cancelForm">取 消</el-button>
<el-button type="primary" @click="$refs.drawer.closeDrawer()" :loading="loading">{{ loading ? '提交中 ...' : '确 定' }}</el-button>
<el-button type="primary" @click="handleFormEnsure" :loading="loading">{{ loading ? '提交中 ...' : '确 定' }}</el-button>
</div>
</el-form-item>
</el-form>
......@@ -187,15 +193,13 @@ export default {
handleCurrentChange(val) {
this.list({ page: val, limit: this.limit })
},
operation(opera) {
switch (opera.tag) {
case 'detail':
break
handleCommand(type, rowData) {
switch (type) {
case 'edit':
this.$router.push({ path: '/training/useruseconfigs/update', query: { id: opera.row.id } })
this.$router.push({ path: '/training/useruseconfigs/update', query: { id: rowData.id } })
break
case 'delete':
this.handleDelete(opera.row.id)
this.handleDelete(rowData.id)
break
}
},
......@@ -254,6 +258,32 @@ export default {
this.drawer = false
clearTimeout(this.timer)
},
handleFormEnsure() {
if (this.loading) {
return
}
this.loading = true
// 提交表单
const rLoading = this.openLoading('.table-list')
userUseConfigApi.createUserUseConfig(this.addForm).then(res => {
if (res.code === 0) {
this.list({ page: 1, limit: this.limit })
this.caseList({ page: 1, limit: 10 })
rLoading.close()
this.$message.success('创建成功')
this.drawer = false
} else {
rLoading.close()
this.$message.error(res.message || '创建失败')
}
})
this.timer = setTimeout(() => {
// 动画关闭需要一定的时间
setTimeout(() => {
this.loading = false
}, 400)
}, 2000)
},
addOptions(addOptionIndex) {
this.addForm.options.push('')
},
......@@ -261,38 +291,6 @@ export default {
if (this.addForm.options.length > 1) {
this.addForm.options.splice(addOptionIndex, 1)
}
},
handleClose(done) {
if (this.loading) {
return
}
this.$confirm('确定要提交表单吗?')
.then(_ => {
this.loading = true
// 提交表单
const rLoading = this.openLoading('.table-list')
userUseConfigApi.createUserUseConfig(this.addForm).then(res => {
if (res.code === 0) {
this.list({ page: 1, limit: this.limit })
this.caseList({ page: 1, limit: 10 })
rLoading.close()
this.$message.success(res.message)
return true
} else {
rLoading.close()
this.$message.error(res.message)
return false
}
})
this.timer = setTimeout(() => {
done()
// 动画关闭需要一定的时间
setTimeout(() => {
this.loading = false
}, 400)
}, 2000)
})
.catch(_ => {})
}
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论