Commit 727f13eb by lxyang

feat:接口调用

parent 43a78ca2
...@@ -49,7 +49,7 @@ export function doctaskUpsert(data) { ...@@ -49,7 +49,7 @@ export function doctaskUpsert(data) {
// 选择文档 // 选择文档
export function doctaskDocuments() { export function doctaskDocuments() {
return request({ return request({
url: '/api/doc/doctask/documents', url: '/api/doc/document/list',
method: 'get' method: 'get'
}) })
} }
...@@ -67,3 +67,11 @@ export function doctaskDelete(id) { ...@@ -67,3 +67,11 @@ export function doctaskDelete(id) {
method: 'get' method: 'get'
}) })
} }
// 创建跟踪任务添加文档接口
export function documentUpsert(data) {
return request({
url: '/api/doc/document/upsert',
method: 'post',
data
})
}
\ No newline at end of file
...@@ -19,18 +19,19 @@ ...@@ -19,18 +19,19 @@
<div v-if="deleteCenter.length && !loading"> <div v-if="deleteCenter.length && !loading">
<div class="delete-center" v-for="(item, index) in deleteCenter" :key="index"> <div class="delete-center" v-for="(item, index) in deleteCenter" :key="index">
<div class="title"> <div class="title">
<span class="title-span">{{item.docTitle}}</span>
<span>更新日期:</span> <span>更新日期:</span>
<span class="time">{{item.data}}</span> <span class="time">{{dateFilter(item.updateTime)}}</span>
<span>{{item.change}}处更新</span> <span>1处更新</span>
</div> </div>
<div class="center"> <div class="center">
<div class="center-delete"> <div class="center-delete">
<div class="center-delete-tab green">新版</div> <div class="center-delete-tab green">新版</div>
<div class="center-delete-text" v-for="(items, indexs) in item.content" :key="indexs" v-html="items.contentText"></div> <div class="center-delete-text" v-html="item.paragraphAfter"></div>
</div> </div>
<div class="center-delete"> <div class="center-delete">
<div class="center-delete-tab gray">旧版</div> <div class="center-delete-tab gray">旧版</div>
<div class="center-delete-text" v-for="(items, indexs) in item.contentOld" :key="indexs" v-html="items.contentText"></div> <div class="center-delete-text" v-html="item.paragraphBefore"></div>
</div> </div>
</div> </div>
</div> </div>
...@@ -69,7 +70,6 @@ export default { ...@@ -69,7 +70,6 @@ export default {
}, },
created() { created() {
this.init() this.init()
console.log(this.$route.query)
this.$nextTick(() => { this.$nextTick(() => {
this.tableHeight(); this.tableHeight();
}) })
...@@ -93,86 +93,50 @@ export default { ...@@ -93,86 +93,50 @@ export default {
path: '/documentManagement/taskList' path: '/documentManagement/taskList'
}) })
}, },
searchCustomer() { dateFilter(time) {
this.loading = true; if (!time) {
// doctaskFinddifference(this.queryParams) // 当时间是null或者无效格式时我们返回空
// .then(response => { return '-'
for (let i = 0; i < 10; i++) { } else {
let data = { const date = new Date(time) // 时间戳为10位需*1000,时间戳为13位的话不需乘1000
data: '2022-10-18', const dateNumFun = (num) => num < 10 ? `0${num}` : num // 使用箭头函数和三目运算以及es6字符串的简单操作。因为只有一个操作不需要{} ,目的就是数字小于10,例如9那么就加上一个0,变成09,否则就返回本身。 // 这是es6的解构赋值。
change: '4', const [Y, M, D, h, m, s] = [
content: [ // 新数据及变化 date.getFullYear(),
{ dateNumFun(date.getMonth() + 1),
contentText: '通常情况下,应当处理 input 事件,并更新组件的绑定值(或使用v-model)。否则,输入框内显示的值将不会改变。', // 这是完整的一段话 dateNumFun(date.getDate()),
contentTextOld: '', dateNumFun(date.getHours()),
contentChange:[ // 这段话里有多少变化以及链接出处 dateNumFun(date.getMinutes()),
{ dateNumFun(date.getSeconds())
text: '或使用v-model',
url: 'https://www.baidu.com/'
},
{
text: '输入框内显示的值',
url: 'https://www.cnblogs.com/1234wu/p/11055005.html'
},
]
},
{
contentText: '视频或直播加热的功能,提升视频或直播间热度。121212', // 这是完整的一段话
contentChange: [
{
text: '提升视频或直播间热度',
url: 'https://element.eleme.io/#/zh-CN/component/pagination#events'
},
]
},
{
contentText: '视频或直播加热的功能,提升视频或直播间热度。121212', // 这是完整的一段话
contentChange: [
{
text: '视频或直播加热的功能',
url: 'https://element.eleme.io/#/zh-CN/component/pagination#events'
},
] ]
return `${Y}-${M}-${D} ${h}:${m}:${s}` // 一定要注意是反引号,否则无效。
} }
],
contentOld: [ // 旧数据
{
contentText: '通常情况下,应当处理 input 事件,并更新组件的绑定值。否则,输入框内显示的值将不会改变。'
}, },
{ searchCustomer() {
contentText: '视频或直播加热的功能,提升视频或直播间热度。' this.loading = true;
}, doctaskFinddifference(this.deleteId)
{ .then(response => {
contentText: '视频或直播加热的功能,提升视频或直播间热度。' if (response.code === 200) {
} let content = response.content.value
]
}
let content = data.content
for (let a = 0; a < content.length; a++) { for (let a = 0; a < content.length; a++) {
let contentChange = content[a].contentChange let difWordAfter = content[a].difWordAfter
for (let b = 0; b < contentChange.length; b++) { let url = content[a].docUrl
let text = contentChange[b].text if (content[a].paragraphAfter.indexOf(difWordAfter) >= 0) {
let url = contentChange[b].url let values = content[a].paragraphAfter.split(difWordAfter);
if (content[a].contentText.indexOf(text) >= 0) { content[a].paragraphAfter = values.join(
let values = content[a].contentText.split(text); `<a style="color: rgba(250, 0, 0, 1);" href="${url}" target="_blank">${difWordAfter}</a>`
content[a].contentText = values.join(
`<a style="color: rgba(250, 0, 0, 1);" href="${url}" target="_blank">${text}</a>`
) )
} }
} }
this.$set(this, 'deleteCenter', content)
} }
this.deleteCenter.push(data)
}
setTimeout(() => {
this.loading = false this.loading = false
}, 1000);
this.$nextTick(() => { this.$nextTick(() => {
this.customerListHeights = this.$refs.customerListHeight.offsetHeight this.customerListHeights = this.$refs.customerListHeight.offsetHeight
}) })
// }) })
// .catch(error => { .catch(error => {
// this.loading = false; this.loading = false;
// }); });
}, },
// 计算高度 // 计算高度
tableHeight() { tableHeight() {
...@@ -218,6 +182,9 @@ export default { ...@@ -218,6 +182,9 @@ export default {
.time { .time {
margin-right: 24px; margin-right: 24px;
} }
.title-span {
margin-right: 16px;
}
} }
.center { .center {
width: 100%; width: 100%;
......
...@@ -132,6 +132,11 @@ ...@@ -132,6 +132,11 @@
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item class="second-level" v-if="form.docDocumentId === 10000" label="文档链接名称"
prop="linkName">
<el-input v-model.trim="form.linkName"
placeholder="请输入文档名称" />
</el-form-item>
<el-form-item class="second-level" v-if="form.docDocumentId === 10000" 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"
...@@ -178,7 +183,8 @@ import { ...@@ -178,7 +183,8 @@ import {
doctaskUpsert, doctaskUpsert,
doctaskDocuments, doctaskDocuments,
doctaskSubscription, doctaskSubscription,
doctaskDelete doctaskDelete,
documentUpsert
} from "@/api/system/customer"; } from "@/api/system/customer";
import { import {
deepClone deepClone
...@@ -256,6 +262,9 @@ export default { ...@@ -256,6 +262,9 @@ export default {
docDocumentId: [ docDocumentId: [
{ required: true, message: "请选择文档", trigger: "blur" } { required: true, message: "请选择文档", trigger: "blur" }
], ],
linkName: [
{ required: true, message: "文档链接名称不能为空", trigger: "blur" }
],
link: [ link: [
{ required: true, message: "文档链接不能为空", trigger: "blur" }, { required: true, message: "文档链接不能为空", trigger: "blur" },
{ {
...@@ -315,7 +324,7 @@ export default { ...@@ -315,7 +324,7 @@ export default {
this.$router.push({ this.$router.push({
path: '/documentManagement/taskListDetails', path: '/documentManagement/taskListDetails',
query: { query: {
id: row.id, id: row.docDocumentId,
name: row.name name: row.name
} }
}) })
...@@ -430,7 +439,7 @@ export default { ...@@ -430,7 +439,7 @@ export default {
}; };
this.searchCustomer(); this.searchCustomer();
}, },
addDoctaskDocuments() { addDoctaskDocuments(isChange) {
this.documentOptions = [] this.documentOptions = []
doctaskDocuments() doctaskDocuments()
.then(response => { .then(response => {
...@@ -442,22 +451,26 @@ export default { ...@@ -442,22 +451,26 @@ export default {
} }
}) })
} }
if (isChange === 0) {
this.documentOptions.push({ this.documentOptions.push({
label: "其他", label: "其他",
value: 10000 value: 10000
}) })
}
}) })
.catch(() => { .catch(() => {
if (isChange === 0) {
this.documentOptions.push({ this.documentOptions.push({
label: "其他", label: "其他",
value: 10000 value: 10000
}) })
}
}); });
}, },
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.reset(); this.reset();
this.addDoctaskDocuments(); this.addDoctaskDocuments(0);
this.open = true; this.open = true;
// this.editFlag = false; // this.editFlag = false;
this.title = "创建跟踪任务"; this.title = "创建跟踪任务";
...@@ -465,7 +478,7 @@ export default { ...@@ -465,7 +478,7 @@ export default {
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
this.reset(); this.reset();
this.addDoctaskDocuments(); this.addDoctaskDocuments(1);
this.handleUpdateFrom(row) this.handleUpdateFrom(row)
this.open = true; this.open = true;
this.title = "修改跟踪任务"; this.title = "修改跟踪任务";
...@@ -486,7 +499,6 @@ export default { ...@@ -486,7 +499,6 @@ export default {
let form = deepClone(this.form) let form = deepClone(this.form)
let fromNew = { let fromNew = {
name: form.name, name: form.name,
docDocumentId: Number(form.docDocumentId),
emails: form.emails, emails: form.emails,
docDesc: form.docDesc docDesc: form.docDesc
} }
...@@ -510,6 +522,8 @@ export default { ...@@ -510,6 +522,8 @@ export default {
// 否则新建 // 否则新建
else { else {
this.submitLoading = true; this.submitLoading = true;
if (form.docDocumentId !== 10000) {
fromNew.docDocumentId = Number(form.docDocumentId)
let doctaskUpserts = doctaskUpsert(fromNew) let doctaskUpserts = doctaskUpsert(fromNew)
Promise.all([doctaskUpserts]).then((result) => { Promise.all([doctaskUpserts]).then((result) => {
if (result[0].code === 200) { if (result[0].code === 200) {
...@@ -523,6 +537,34 @@ export default { ...@@ -523,6 +537,34 @@ export default {
this.msgError(error); this.msgError(error);
this.submitLoading = false; this.submitLoading = false;
}) })
} else {
let documentUpsertData = {
name: form.linkName,
docUrl: form.link
}
let documentUpserts = documentUpsert(documentUpsertData)
Promise.all([documentUpserts]).then((result) => {
if (result[0].code === 200) {
fromNew.docDocumentId = result[0].content.id
doctaskUpsert(fromNew).then(response => {
if (response.code === 200) {
this.msgSuccess("新建成功");
this.open = false;
this.queryParams.pageindex = 1
this.searchCustomer();
}
this.submitLoading = false;
})
.catch((error) => {
this.msgError(error);
this.submitLoading = false;
})
}
}).catch((error) => {
this.msgError(error);
this.submitLoading = false;
})
}
} }
} }
}); });
......
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