Commit 37fc3239 by lxyang

feat:部分接口调试完成

parent f9c21c59
......@@ -37,3 +37,33 @@ export function doctaskList(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 = [
children: [
{
path: 'index',
component: () => import('../views/index'),
component: () => import('@/views/index'),
name: '搜索文档',
meta: { title: '搜索文档', icon: 'search-new', noCache: true, affix: true }
}
......@@ -103,7 +103,7 @@ export const constantRoutes = [
children: [
{
path: 'type/data/:dictId(\\d+)',
component: () => import('../views/system/dict/data'),
component: () => import('@/views/system/dict/data'),
name: '字典数据',
meta: { title: '字典数据', icon: '' }
}
......@@ -119,7 +119,7 @@ export const constantRoutes = [
path: '/documentManagement',
children: [
{
component: () => import('../views/dataList/dashboard/index'),
component: () => import('@/views/dataList/dashboard/index'),
meta: {
icon: '',
title: '搜索文档详情'
......@@ -129,7 +129,7 @@ export const constantRoutes = [
hidden: true
},
{
component: () => import('../views/system/customer/index'),
component: () => import('@/views/system/customer/index'),
meta: {
icon: '',
title: '跟踪文档'
......@@ -141,7 +141,7 @@ export const constantRoutes = [
}
},
{
component: () => import('../views/dataList/product/index'),
component: () => import('@/views/dataList/product/index'),
meta: {
icon: '',
title: '跟踪文档详情'
......
......@@ -30,9 +30,9 @@
<el-table-column label="订阅状态"
fixed="left"
width="90"
align="subscriptionStatus">
align="subscription">
<template slot-scope="scope">
<el-switch v-model="scope.row.subscriptionStatus"
<el-switch v-model="scope.row.subscription"
active-value="0"
inactive-value="1"
@change="handleStatusChange(scope.row)"></el-switch>
......@@ -41,11 +41,11 @@
<el-table-column fixed="left"
min-width="240"
label="任务名称"
prop="taskName"
prop="name"
:show-overflow-tooltip="true"
>
<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>
</el-table-column>
<el-table-column min-width="160"
......@@ -59,11 +59,11 @@
</el-table-column>
<el-table-column label="任务说明"
min-width="280"
prop="explain"
prop="docDesc"
:show-overflow-tooltip="true"
>
<template slot-scope="scope">
<div class="ellipsis-hidden">{{ isEmpty(scope.row, 'explain') }}</div>
<div class="ellipsis-hidden">{{ isEmpty(scope.row, 'docDesc') }}</div>
</template>
</el-table-column>
......@@ -71,7 +71,7 @@
prop="createTime"
width="200">
<template slot-scope="scope">
<span>{{ isEmpty(scope.row, 'createTime') }}</span>
<span>{{ dateFilter(scope.row.createTime) }}</span>
</template>
</el-table-column>
......@@ -115,14 +115,14 @@
:model="form"
:rules="rules">
<el-form-item label="任务名称"
prop="taskName">
<el-input v-model.trim="form.taskName"
prop="name">
<el-input v-model.trim="form.name"
placeholder="请输入任务名称"
:disabled="editFlag" />
</el-form-item>
<el-form-item label="选择文档"
prop="document">
<el-select v-model="form.document"
prop="docDocumentId">
<el-select v-model="form.docDocumentId"
clearable
placeholder="请选择文档">
<el-option v-for="item in documentOptions"
......@@ -132,19 +132,19 @@
</el-option>
</el-select>
</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">
<el-input v-model.trim="form.link"
placeholder="请输入文档链接" />
</el-form-item>
<el-form-item label="邮箱通知"
prop="email">
<el-input v-model.trim="form.email"
prop="emails">
<el-input v-model.trim="form.emails"
placeholder="请输入要订阅和通知的邮箱"
:disabled="editFlag" />
</el-form-item>
<el-form-item label="任务说明">
<el-input v-model.trim="form.explain"
<el-input v-model.trim="form.docDesc"
type="textarea"
placeholder="请输入任务说明" />
</el-form-item>
......@@ -175,7 +175,14 @@
<script>
import {
doctaskList,
doctaskUpsert,
doctaskDocuments,
doctaskSubscription,
doctaskDelete
} from "@/api/system/customer";
import {
deepClone
} from "@/utils/index";
export default {
data() {
return {
......@@ -214,23 +221,14 @@ export default {
// 表单参数
form: {
id: undefined,
taskName: "",
document: "",
name: "",
docDocumentId: "",
link: "",
email: "",
explain: ""
emails: "",
docDesc: ""
},
// 选择文档
documentOptions: [
{
label: "巨量",
value: "0"
},
{
label: "其他",
value: "1"
}
],
documentOptions: [],
editFlag: false,
defaultProps: {
children: "children",
......@@ -238,10 +236,10 @@ export default {
},
// 表单校验
rules: {
taskName: [
name: [
{ required: true, message: "任务名称不能为空", trigger: "blur" }
],
email: [
emails: [
{ required: true, message: "邮箱不能为空", trigger: "blur" },
{
validator: function (rule, value, callback) {
......@@ -255,7 +253,7 @@ export default {
trigger: 'blur'
}
],
document: [
docDocumentId: [
{ required: true, message: "请选择文档", trigger: "blur" }
],
link: [
......@@ -290,6 +288,24 @@ export default {
}
},
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() {
let height = document.documentElement.clientHeight - 128
this.tableHeights = height < 580 ? 580 : height
......@@ -300,7 +316,7 @@ export default {
path: '/documentManagement/taskListDetails',
query: {
id: row.id,
name: row.taskName
name: row.name
}
})
},
......@@ -311,81 +327,62 @@ export default {
// table显示状态
statusTable(row) {
let status = {
0: {
'-1': {
text: "暂停中",
class: "span-table span-gray"
},
'0': {
text: "已失效",
class: "span-table span-red"
},
1: {
'1': {
text: "运行中",
class: "span-table span-blue"
},
2: {
'2': {
text: "已完成",
class: "span-table span-green"
}
}
return status[row.status] ? status[row.status] : {
return status[row.status.toString()] ? status[row.status.toString()] : {
text: "",
class: ""
}
},
handleStatusChange(row) {
// editStatus(row.id, row.subscriptionStatus)
// .then(() => {
this.searchCustomer();
this.msgSuccess("修改状态成功");
// })
// .catch(() => this.msgError("修改状态失败"));
let isTrue = row.subscription === '0' ? true : false
doctaskSubscription({id: row.id, sub: isTrue})
.then((response) => {
if (response.code === 200) {
this.searchCustomer();
this.msgSuccess("修改状态成功");
}
})
.catch(() => this.msgError("修改状态失败"));
},
searchCustomer() {
this.loading = true;
this.customerList = []
doctaskList(this.queryParams)
.then(response => {
console.log(response, 'response')
let data = [
{
id: 1,
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'
if (response.code === 200) {
let content = response.content
if (this.total !== content.totalSize) {
this.total = content.totalSize
}
]
// this.customerList = response.data.records;
this.customerList = data
// data
// this.total = response.data.total;
this.total = 0;
// 10;
setTimeout(() => {
this.loading = false;
}, 2000)
let values = content.value
values.forEach(item => {
if (item.subscription) {
item.subscription = '0'
} else {
item.subscription = '1'
}
});
this.$set(this, 'customerList', values)
} else {
this.customerList = []
}
this.loading = false;
this.$nextTick(() => {
this.customerListHeights = this.$refs.customerListHeight.offsetHeight
})
......@@ -411,11 +408,11 @@ export default {
reset() {
this.form = {
id: undefined,
taskName: "",
document: "",
name: "",
docDocumentId: "",
link: "",
email: "",
explain: ""
emails: "",
docDesc: ""
};
this.resetForm("form");
},
......@@ -429,13 +426,38 @@ export default {
this.queryParams = {
current: 1,
size: 10,
taskName: ""
name: ""
};
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() {
this.reset();
this.addDoctaskDocuments();
this.open = true;
// this.editFlag = false;
this.title = "创建跟踪任务";
......@@ -443,61 +465,64 @@ export default {
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
// getCustomer(row.id).then(response => {
// this.form = response.data;
this.handleUpdateFrom(row)
this.open = true;
this.title = "修改跟踪任务";
// });
this.addDoctaskDocuments();
this.handleUpdateFrom(row)
this.open = true;
this.title = "修改跟踪任务";
},
// 修改from赋值
handleUpdateFrom(row) {
this.form.id = row.id ? row.id : undefined
this.form.taskName = row.taskName ? row.taskName : ""
this.form.document = row.document ? row.document : ""
this.form.name = row.name ? row.name : ""
this.form.docDocumentId = row.docDocumentId ? row.docDocumentId : ""
this.form.link = row.link ? row.link : ""
this.form.email = row.email ? row.email : ""
this.form.explain = row.explain ? row.explain : ""
this.form.emails = row.emails ? row.emails : ""
this.form.docDesc = row.docDesc ? row.docDesc : ""
},
/** 提交按钮 */
submitForm: function() {
this.$refs["form"].validate(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;
// editCustomer(this.form)
// .then(response => {
// if (response.code === 200) {
this.msgSuccess("修改成功");
this.open = false;
this.searchCustomer();
// } else {
// this.msgError(response.msg);
// }
// // this.editFlag = false;
// this.submitLoading = false;
// })
// .catch(() => {
// this.submitLoading = false;
// });
fromNew.id = form.id
let doctaskUpserts = doctaskUpsert(fromNew)
Promise.all([doctaskUpserts]).then((result) => {
if (result[0].code === 200) {
this.msgSuccess("修改成功");
this.open = false;
this.queryParams.pageindex = 1
this.searchCustomer();
}
this.submitLoading = false;
}).catch((error) => {
this.msgError(error);
this.submitLoading = false;
})
}
// 否则新建
else {
this.submitLoading = true;
// addCustomer(this.form)
// .then(response => {
// if (response.code === 200) {
this.msgSuccess("新增成功");
this.open = false;
this.searchCustomer();
// } else {
// this.msgError(response.msg);
// }
// this.submitLoading = false;
// })
// .catch(() => {
// this.submitLoading = false;
// });
let doctaskUpserts = doctaskUpsert(fromNew)
Promise.all([doctaskUpserts]).then((result) => {
if (result[0].code === 200) {
this.msgSuccess("新建成功");
this.open = false;
this.queryParams.pageindex = 1
this.searchCustomer();
}
this.submitLoading = false;
}).catch((error) => {
this.msgError(error);
this.submitLoading = false;
})
}
}
});
......@@ -505,7 +530,7 @@ export default {
/** 删除按钮操作 */
handleDelete(row) {
this.$confirm(
'是否确认删除名称为"' + row.taskName + '"的跟踪任务?',
'是否确认删除名称为"' + row.name + '"的跟踪任务?',
"警告",
{
confirmButtonText: "确定",
......@@ -514,13 +539,16 @@ export default {
}
)
.then(() => {
// return deleteCustomer(row.id);
})
.then(() => {
this.searchCustomer();
this.msgSuccess("删除成功");
doctaskDelete(row.id).then(response => {
if (response.code === 200) {
this.msgSuccess("删除成功");
this.queryParams.pageindex = 1
this.searchCustomer();
}
})
.catch((error) => this.msgError(error))
})
.catch(() => this.msgError("删除失败"));
.catch((error) => this.msgError(error));
}
}
};
......@@ -571,6 +599,11 @@ export default {
background: rgba(227, 77, 89, 1);
}
}
.span-gray {
&::before {
background: rgb(139, 139, 139);
}
}
.span-blue {
&::before {
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