Commit 37fc3239 by lxyang

feat:部分接口调试完成

parent f9c21c59
...@@ -37,3 +37,33 @@ export function doctaskList(data) { ...@@ -37,3 +37,33 @@ export function doctaskList(data) {
params: data params: data
}) })
} }
// 提交表单
export function doctaskUpsert(data) {
return request({
url: '/api/doc/doctask/upsert',
method: 'post',
data
})
}
// 选择文档
export function doctaskDocuments() {
return request({
url: '/api/doc/doctask/documents',
method: 'get'
})
}
// 订阅文档
export function doctaskSubscription({id, sub}) {
return request({
url: '/api/doc/doctask/subscription/' + id + '?sub=' + sub,
method: 'get'
})
}
// 删除文档
export function doctaskDelete(id) {
return request({
url: '/api/doc/doctask/delete/' + id,
method: 'get'
})
}
\ No newline at end of file
...@@ -74,7 +74,7 @@ export const constantRoutes = [ ...@@ -74,7 +74,7 @@ export const constantRoutes = [
children: [ children: [
{ {
path: 'index', path: 'index',
component: () => import('../views/index'), component: () => import('@/views/index'),
name: '搜索文档', name: '搜索文档',
meta: { title: '搜索文档', icon: 'search-new', noCache: true, affix: true } meta: { title: '搜索文档', icon: 'search-new', noCache: true, affix: true }
} }
...@@ -103,7 +103,7 @@ export const constantRoutes = [ ...@@ -103,7 +103,7 @@ export const constantRoutes = [
children: [ children: [
{ {
path: 'type/data/:dictId(\\d+)', path: 'type/data/:dictId(\\d+)',
component: () => import('../views/system/dict/data'), component: () => import('@/views/system/dict/data'),
name: '字典数据', name: '字典数据',
meta: { title: '字典数据', icon: '' } meta: { title: '字典数据', icon: '' }
} }
...@@ -119,7 +119,7 @@ export const constantRoutes = [ ...@@ -119,7 +119,7 @@ export const constantRoutes = [
path: '/documentManagement', path: '/documentManagement',
children: [ children: [
{ {
component: () => import('../views/dataList/dashboard/index'), component: () => import('@/views/dataList/dashboard/index'),
meta: { meta: {
icon: '', icon: '',
title: '搜索文档详情' title: '搜索文档详情'
...@@ -129,7 +129,7 @@ export const constantRoutes = [ ...@@ -129,7 +129,7 @@ export const constantRoutes = [
hidden: true hidden: true
}, },
{ {
component: () => import('../views/system/customer/index'), component: () => import('@/views/system/customer/index'),
meta: { meta: {
icon: '', icon: '',
title: '跟踪文档' title: '跟踪文档'
...@@ -141,7 +141,7 @@ export const constantRoutes = [ ...@@ -141,7 +141,7 @@ export const constantRoutes = [
} }
}, },
{ {
component: () => import('../views/dataList/product/index'), component: () => import('@/views/dataList/product/index'),
meta: { meta: {
icon: '', icon: '',
title: '跟踪文档详情' title: '跟踪文档详情'
......
...@@ -30,9 +30,9 @@ ...@@ -30,9 +30,9 @@
<el-table-column label="订阅状态" <el-table-column label="订阅状态"
fixed="left" fixed="left"
width="90" width="90"
align="subscriptionStatus"> align="subscription">
<template slot-scope="scope"> <template slot-scope="scope">
<el-switch v-model="scope.row.subscriptionStatus" <el-switch v-model="scope.row.subscription"
active-value="0" active-value="0"
inactive-value="1" inactive-value="1"
@change="handleStatusChange(scope.row)"></el-switch> @change="handleStatusChange(scope.row)"></el-switch>
...@@ -41,11 +41,11 @@ ...@@ -41,11 +41,11 @@
<el-table-column fixed="left" <el-table-column fixed="left"
min-width="240" min-width="240"
label="任务名称" label="任务名称"
prop="taskName" prop="name"
:show-overflow-tooltip="true" :show-overflow-tooltip="true"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<div class="ellipsis-hidden"><span class="blue" @click="routerTaskListDetails(scope.row)">{{ isEmpty(scope.row, 'taskName') }}</span></div> <div class="ellipsis-hidden"><span class="blue" @click="routerTaskListDetails(scope.row)">{{ isEmpty(scope.row, 'name') }}</span></div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column min-width="160" <el-table-column min-width="160"
...@@ -59,11 +59,11 @@ ...@@ -59,11 +59,11 @@
</el-table-column> </el-table-column>
<el-table-column label="任务说明" <el-table-column label="任务说明"
min-width="280" min-width="280"
prop="explain" prop="docDesc"
:show-overflow-tooltip="true" :show-overflow-tooltip="true"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<div class="ellipsis-hidden">{{ isEmpty(scope.row, 'explain') }}</div> <div class="ellipsis-hidden">{{ isEmpty(scope.row, 'docDesc') }}</div>
</template> </template>
</el-table-column> </el-table-column>
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
prop="createTime" prop="createTime"
width="200"> width="200">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ isEmpty(scope.row, 'createTime') }}</span> <span>{{ dateFilter(scope.row.createTime) }}</span>
</template> </template>
</el-table-column> </el-table-column>
...@@ -115,14 +115,14 @@ ...@@ -115,14 +115,14 @@
:model="form" :model="form"
:rules="rules"> :rules="rules">
<el-form-item label="任务名称" <el-form-item label="任务名称"
prop="taskName"> prop="name">
<el-input v-model.trim="form.taskName" <el-input v-model.trim="form.name"
placeholder="请输入任务名称" placeholder="请输入任务名称"
:disabled="editFlag" /> :disabled="editFlag" />
</el-form-item> </el-form-item>
<el-form-item label="选择文档" <el-form-item label="选择文档"
prop="document"> prop="docDocumentId">
<el-select v-model="form.document" <el-select v-model="form.docDocumentId"
clearable clearable
placeholder="请选择文档"> placeholder="请选择文档">
<el-option v-for="item in documentOptions" <el-option v-for="item in documentOptions"
...@@ -132,19 +132,19 @@ ...@@ -132,19 +132,19 @@
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item class="second-level" v-if="form.document === '1'" label="文档链接" <el-form-item class="second-level" v-if="form.docDocumentId === 10000" label="文档链接"
prop="link"> prop="link">
<el-input v-model.trim="form.link" <el-input v-model.trim="form.link"
placeholder="请输入文档链接" /> placeholder="请输入文档链接" />
</el-form-item> </el-form-item>
<el-form-item label="邮箱通知" <el-form-item label="邮箱通知"
prop="email"> prop="emails">
<el-input v-model.trim="form.email" <el-input v-model.trim="form.emails"
placeholder="请输入要订阅和通知的邮箱" placeholder="请输入要订阅和通知的邮箱"
:disabled="editFlag" /> :disabled="editFlag" />
</el-form-item> </el-form-item>
<el-form-item label="任务说明"> <el-form-item label="任务说明">
<el-input v-model.trim="form.explain" <el-input v-model.trim="form.docDesc"
type="textarea" type="textarea"
placeholder="请输入任务说明" /> placeholder="请输入任务说明" />
</el-form-item> </el-form-item>
...@@ -175,7 +175,14 @@ ...@@ -175,7 +175,14 @@
<script> <script>
import { import {
doctaskList, doctaskList,
doctaskUpsert,
doctaskDocuments,
doctaskSubscription,
doctaskDelete
} from "@/api/system/customer"; } from "@/api/system/customer";
import {
deepClone
} from "@/utils/index";
export default { export default {
data() { data() {
return { return {
...@@ -214,23 +221,14 @@ export default { ...@@ -214,23 +221,14 @@ export default {
// 表单参数 // 表单参数
form: { form: {
id: undefined, id: undefined,
taskName: "", name: "",
document: "", docDocumentId: "",
link: "", link: "",
email: "", emails: "",
explain: "" docDesc: ""
}, },
// 选择文档 // 选择文档
documentOptions: [ documentOptions: [],
{
label: "巨量",
value: "0"
},
{
label: "其他",
value: "1"
}
],
editFlag: false, editFlag: false,
defaultProps: { defaultProps: {
children: "children", children: "children",
...@@ -238,10 +236,10 @@ export default { ...@@ -238,10 +236,10 @@ export default {
}, },
// 表单校验 // 表单校验
rules: { rules: {
taskName: [ name: [
{ required: true, message: "任务名称不能为空", trigger: "blur" } { required: true, message: "任务名称不能为空", trigger: "blur" }
], ],
email: [ emails: [
{ required: true, message: "邮箱不能为空", trigger: "blur" }, { required: true, message: "邮箱不能为空", trigger: "blur" },
{ {
validator: function (rule, value, callback) { validator: function (rule, value, callback) {
...@@ -255,7 +253,7 @@ export default { ...@@ -255,7 +253,7 @@ export default {
trigger: 'blur' trigger: 'blur'
} }
], ],
document: [ docDocumentId: [
{ required: true, message: "请选择文档", trigger: "blur" } { required: true, message: "请选择文档", trigger: "blur" }
], ],
link: [ link: [
...@@ -290,6 +288,24 @@ export default { ...@@ -290,6 +288,24 @@ export default {
} }
}, },
methods: { methods: {
dateFilter(time) {
if (!time) {
// 当时间是null或者无效格式时我们返回空
return '-'
} else {
const date = new Date(time) // 时间戳为10位需*1000,时间戳为13位的话不需乘1000
const dateNumFun = (num) => num < 10 ? `0${num}` : num // 使用箭头函数和三目运算以及es6字符串的简单操作。因为只有一个操作不需要{} ,目的就是数字小于10,例如9那么就加上一个0,变成09,否则就返回本身。 // 这是es6的解构赋值。
const [Y, M, D, h, m, s] = [
date.getFullYear(),
dateNumFun(date.getMonth() + 1),
dateNumFun(date.getDate()),
dateNumFun(date.getHours()),
dateNumFun(date.getMinutes()),
dateNumFun(date.getSeconds())
]
return `${Y}-${M}-${D} ${h}:${m}:${s}` // 一定要注意是反引号,否则无效。
}
},
tableHeight() { tableHeight() {
let height = document.documentElement.clientHeight - 128 let height = document.documentElement.clientHeight - 128
this.tableHeights = height < 580 ? 580 : height this.tableHeights = height < 580 ? 580 : height
...@@ -300,7 +316,7 @@ export default { ...@@ -300,7 +316,7 @@ export default {
path: '/documentManagement/taskListDetails', path: '/documentManagement/taskListDetails',
query: { query: {
id: row.id, id: row.id,
name: row.taskName name: row.name
} }
}) })
}, },
...@@ -311,81 +327,62 @@ export default { ...@@ -311,81 +327,62 @@ export default {
// table显示状态 // table显示状态
statusTable(row) { statusTable(row) {
let status = { let status = {
0: { '-1': {
text: "暂停中",
class: "span-table span-gray"
},
'0': {
text: "已失效", text: "已失效",
class: "span-table span-red" class: "span-table span-red"
}, },
1: { '1': {
text: "运行中", text: "运行中",
class: "span-table span-blue" class: "span-table span-blue"
}, },
2: { '2': {
text: "已完成", text: "已完成",
class: "span-table span-green" class: "span-table span-green"
} }
} }
return status[row.status] ? status[row.status] : { return status[row.status.toString()] ? status[row.status.toString()] : {
text: "", text: "",
class: "" class: ""
} }
}, },
handleStatusChange(row) { handleStatusChange(row) {
// editStatus(row.id, row.subscriptionStatus) let isTrue = row.subscription === '0' ? true : false
// .then(() => { doctaskSubscription({id: row.id, sub: isTrue})
this.searchCustomer(); .then((response) => {
this.msgSuccess("修改状态成功"); if (response.code === 200) {
// }) this.searchCustomer();
// .catch(() => this.msgError("修改状态失败")); this.msgSuccess("修改状态成功");
}
})
.catch(() => this.msgError("修改状态失败"));
}, },
searchCustomer() { searchCustomer() {
this.loading = true; this.loading = true;
this.customerList = []
doctaskList(this.queryParams) doctaskList(this.queryParams)
.then(response => { .then(response => {
console.log(response, 'response') if (response.code === 200) {
let data = [ let content = response.content
{ if (this.total !== content.totalSize) {
id: 1, this.total = content.totalSize
taskName: '任务1',
explain: '这是一个任务1',
subscriptionStatus: '1',
createTime: '2020-10-22 20:16:01',
status: 0,
document: '1',
link: 'https://element.eleme.io/#/zh-CN/component/form#form-item-methods',
email: '111111111@.qq.com'
},
{
id: 2,
taskName: '任务2',
subscriptionStatus: '1',
explain: '这是一个任务2',
createTime: '2020-10-22 20:16:01',
status: 1,
document: '0',
link: '',
email: '111111111@qq.com'
},
{
id: 3,
taskName: '任务3',
explain: '',
subscriptionStatus: '0',
createTime: '2020-10-22 20:16:01',
status: 2,
document: '0',
link: '',
email: '111111111@.qq.com'
} }
] let values = content.value
// this.customerList = response.data.records; values.forEach(item => {
this.customerList = data if (item.subscription) {
// data item.subscription = '0'
// this.total = response.data.total; } else {
this.total = 0; item.subscription = '1'
// 10; }
setTimeout(() => { });
this.loading = false; this.$set(this, 'customerList', values)
}, 2000) } else {
this.customerList = []
}
this.loading = false;
this.$nextTick(() => { this.$nextTick(() => {
this.customerListHeights = this.$refs.customerListHeight.offsetHeight this.customerListHeights = this.$refs.customerListHeight.offsetHeight
}) })
...@@ -411,11 +408,11 @@ export default { ...@@ -411,11 +408,11 @@ export default {
reset() { reset() {
this.form = { this.form = {
id: undefined, id: undefined,
taskName: "", name: "",
document: "", docDocumentId: "",
link: "", link: "",
email: "", emails: "",
explain: "" docDesc: ""
}; };
this.resetForm("form"); this.resetForm("form");
}, },
...@@ -429,13 +426,38 @@ export default { ...@@ -429,13 +426,38 @@ export default {
this.queryParams = { this.queryParams = {
current: 1, current: 1,
size: 10, size: 10,
taskName: "" name: ""
}; };
this.searchCustomer(); this.searchCustomer();
}, },
addDoctaskDocuments() {
this.documentOptions = []
doctaskDocuments()
.then(response => {
if (response.code === 200) {
this.documentOptions = response.content.map(item => {
return {
'label': item.name,
'value': item.id
}
})
}
this.documentOptions.push({
label: "其他",
value: 10000
})
})
.catch(() => {
this.documentOptions.push({
label: "其他",
value: 10000
})
});
},
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.reset(); this.reset();
this.addDoctaskDocuments();
this.open = true; this.open = true;
// this.editFlag = false; // this.editFlag = false;
this.title = "创建跟踪任务"; this.title = "创建跟踪任务";
...@@ -443,61 +465,64 @@ export default { ...@@ -443,61 +465,64 @@ export default {
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
this.reset(); this.reset();
// getCustomer(row.id).then(response => { this.addDoctaskDocuments();
// this.form = response.data; this.handleUpdateFrom(row)
this.handleUpdateFrom(row) this.open = true;
this.open = true; this.title = "修改跟踪任务";
this.title = "修改跟踪任务";
// });
}, },
// 修改from赋值 // 修改from赋值
handleUpdateFrom(row) { handleUpdateFrom(row) {
this.form.id = row.id ? row.id : undefined this.form.id = row.id ? row.id : undefined
this.form.taskName = row.taskName ? row.taskName : "" this.form.name = row.name ? row.name : ""
this.form.document = row.document ? row.document : "" this.form.docDocumentId = row.docDocumentId ? row.docDocumentId : ""
this.form.link = row.link ? row.link : "" this.form.link = row.link ? row.link : ""
this.form.email = row.email ? row.email : "" this.form.emails = row.emails ? row.emails : ""
this.form.explain = row.explain ? row.explain : "" this.form.docDesc = row.docDesc ? row.docDesc : ""
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm: function() { submitForm: function() {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
if (this.form.id) { let form = deepClone(this.form)
let fromNew = {
name: form.name,
docDocumentId: Number(form.docDocumentId),
emails: form.emails,
docDesc: form.docDesc
}
if (form.id) {
this.submitLoading = true; this.submitLoading = true;
// editCustomer(this.form) fromNew.id = form.id
// .then(response => { let doctaskUpserts = doctaskUpsert(fromNew)
// if (response.code === 200) { Promise.all([doctaskUpserts]).then((result) => {
this.msgSuccess("修改成功"); if (result[0].code === 200) {
this.open = false; this.msgSuccess("修改成功");
this.searchCustomer(); this.open = false;
// } else { this.queryParams.pageindex = 1
// this.msgError(response.msg); this.searchCustomer();
// } }
// // this.editFlag = false; this.submitLoading = false;
// this.submitLoading = false; }).catch((error) => {
// }) this.msgError(error);
// .catch(() => { this.submitLoading = false;
// this.submitLoading = false; })
// });
} }
// 否则新建 // 否则新建
else { else {
this.submitLoading = true; this.submitLoading = true;
// addCustomer(this.form) let doctaskUpserts = doctaskUpsert(fromNew)
// .then(response => { Promise.all([doctaskUpserts]).then((result) => {
// if (response.code === 200) { if (result[0].code === 200) {
this.msgSuccess("新增成功"); this.msgSuccess("新建成功");
this.open = false; this.open = false;
this.searchCustomer(); this.queryParams.pageindex = 1
// } else { this.searchCustomer();
// this.msgError(response.msg); }
// } this.submitLoading = false;
// this.submitLoading = false; }).catch((error) => {
// }) this.msgError(error);
// .catch(() => { this.submitLoading = false;
// this.submitLoading = false; })
// });
} }
} }
}); });
...@@ -505,7 +530,7 @@ export default { ...@@ -505,7 +530,7 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
this.$confirm( this.$confirm(
'是否确认删除名称为"' + row.taskName + '"的跟踪任务?', '是否确认删除名称为"' + row.name + '"的跟踪任务?',
"警告", "警告",
{ {
confirmButtonText: "确定", confirmButtonText: "确定",
...@@ -514,13 +539,16 @@ export default { ...@@ -514,13 +539,16 @@ export default {
} }
) )
.then(() => { .then(() => {
// return deleteCustomer(row.id); doctaskDelete(row.id).then(response => {
}) if (response.code === 200) {
.then(() => { this.msgSuccess("删除成功");
this.searchCustomer(); this.queryParams.pageindex = 1
this.msgSuccess("删除成功"); this.searchCustomer();
}
})
.catch((error) => this.msgError(error))
}) })
.catch(() => this.msgError("删除失败")); .catch((error) => this.msgError(error));
} }
} }
}; };
...@@ -571,6 +599,11 @@ export default { ...@@ -571,6 +599,11 @@ export default {
background: rgba(227, 77, 89, 1); background: rgba(227, 77, 89, 1);
} }
} }
.span-gray {
&::before {
background: rgb(139, 139, 139);
}
}
.span-blue { .span-blue {
&::before { &::before {
background: rgba(0, 82, 217, 1); background: rgba(0, 82, 217, 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment