Commit 275aa5cf by 张立顺

feat 对练功能开发

1 parent c2d1720f
...@@ -6,8 +6,13 @@ ...@@ -6,8 +6,13 @@
* @LastEditTime: 2024-05-08 11:32:07 * @LastEditTime: 2024-05-08 11:32:07
*/ */
import request from "./request" import request from "./request"
const path = 'dj.api.smartcarlife.ai.sparring.' const path = "dj.api.smartcarlife.ai.sparring."
// 结束任务
export function stopTask(data) {
data.method = `${path}stop.task`
return request(data)
}
// 获取练习列表 // 获取练习列表
export function getList(data) { export function getList(data) {
data.method = `${path}task.page` data.method = `${path}task.page`
...@@ -17,7 +22,7 @@ export function getList(data) { ...@@ -17,7 +22,7 @@ export function getList(data) {
// 新建任务 // 新建任务
export function createTask(data) { export function createTask(data) {
data.method = `${path}task.create` data.method = `${path}task.create`
return request(data, 'post') return request(data, "post")
} }
// 对练详情 // 对练详情
......
...@@ -234,7 +234,7 @@ export const routerName = { ...@@ -234,7 +234,7 @@ export const routerName = {
parentId: "912", parentId: "912",
cache: false cache: false
}, },
component: _import("residentManage/exercise/index"), component: _import("residentManage/exercise/exerciseTab"),
auth: [ auth: [
{ {
authId: "9120801", authId: "9120801",
......
...@@ -11,16 +11,19 @@ ...@@ -11,16 +11,19 @@
<div class="title-tag">{{ scenarioType[taskInfo.businessScenario] }}</div> <div class="title-tag">{{ scenarioType[taskInfo.businessScenario] }}</div>
<div class="title">{{ taskInfo.taskName }}</div> <div class="title">{{ taskInfo.taskName }}</div>
<div class="title-time">创建时间:{{ taskInfo.createdDate }}</div> <div class="title-time">创建时间:{{ taskInfo.createdDate }}</div>
<div class="title-time">任务时间:{{ taskInfo.startTime }} - {{ taskInfo.endTime }}</div> <div class="title-time">
任务时间:{{ taskInfo.startTime }} - {{ taskInfo.endTime }}
</div> </div>
<d2-container style="margin-top: 50px;"> </div>
<d2-container style="margin-top: 50px">
<div class="header" slot="header" style="padding: 10px 20px"> <div class="header" slot="header" style="padding: 10px 20px">
<d2-search <d2-search
ref="showSearch" ref="showSearch"
class="show-search" class="show-search"
label-width="110px" label-width="110px"
:search-form="searchForm" :search-form="searchForm"
:form-data="showFormData"> :form-data="showFormData"
>
<div class="up-btns"> <div class="up-btns">
<el-button size="small" type="primary" @click="handleSearch"> <el-button size="small" type="primary" @click="handleSearch">
查询 查询
...@@ -30,7 +33,7 @@ ...@@ -30,7 +33,7 @@
</d2-search> </d2-search>
</div> </div>
<div class="d2-container-content" style="position: positive"> <div class="d2-container-content" style="position: positive">
<span style="position: absolute; right: 41px; top: 42px; z-index: 999;"> <span style="position: absolute; right: 41px; top: 42px; z-index: 999">
<el-button @click="handleExport" size="small" type="primary"> <el-button @click="handleExport" size="small" type="primary">
导出 导出
</el-button> </el-button>
...@@ -46,35 +49,67 @@ ...@@ -46,35 +49,67 @@
:search-form="searchFormSearch" :search-form="searchFormSearch"
:table-params="tableParams" :table-params="tableParams"
:get-list-api="getListApi" :get-list-api="getListApi"
:before-search-fn="beforeSearchFn"> :before-search-fn="beforeSearchFn"
>
<template slot="auth-button-other" slot-scope="scope"> <template slot="auth-button-other" slot-scope="scope">
<!-- <el-button type="text" @click="btnClick(scope)">{{ scope.scope.sparringStatus == 1 ? '查看结果' : '提醒' }}</el-button> --> <!-- <el-button type="text" @click="btnClick(scope)">{{ scope.scope.sparringStatus == 1 ? '查看结果' : '提醒' }}</el-button> -->
<el-button v-if="isEndTimePassed && scope.scope.sparringStatus !== 1" type="text" @click="btnClick(scope)">提醒</el-button> <el-button
<el-button v-if="scope.scope.sparringStatus === 1" type="text" @click="btnClick(scope)">查看结果</el-button> v-if="scope.scope.taskState == 1"
type="text"
@click="btnClickEnd(scope)"
>结束</el-button
>
<el-button
v-if="isEndTimePassed && scope.scope.sparringStatus !== 1"
type="text"
@click="btnClick(scope)"
>提醒</el-button
>
<el-button
v-if="scope.scope.sparringStatus === 1"
type="text"
@click="btnClick(scope)"
>查看结果</el-button
>
</template> </template>
<div slot="sparringStatus" slot-scope="scope"> <div slot="sparringStatus" slot-scope="scope">
<div class="online-status"><span :class="[scope.scope.sparringStatus === 0 ? 'dot blue' : scope.scope.sparringStatus === 1 ? 'dot green' : 'dot orange']"></span>{{scope.scope.sparringStatus ? '已完成' : '未完成'}}</div> <div class="online-status">
<span
:class="[
scope.scope.sparringStatus === 0
? 'dot blue'
: scope.scope.sparringStatus === 1
? 'dot green'
: 'dot orange'
]"
></span
>{{ scope.scope.sparringStatus ? "已完成" : "未完成" }}
</div>
</div> </div>
</d2-table> </d2-table>
</div> </div>
</d2-container> </d2-container>
<quality-detail :is-quality-visible="isQualityVisible" v-if="isQualityVisible" :detail-obj="detailObj" <quality-detail
@closeDialog="closeDialog"></quality-detail> :is-quality-visible="isQualityVisible"
v-if="isQualityVisible"
:detail-obj="detailObj"
@closeDialog="closeDialog"
></quality-detail>
</div> </div>
</template> </template>
<script> <script>
import { mapActions, mapState } from 'vuex' import { mapActions, mapState } from "vuex"
import QualityDetail from "./components/dialogResult.vue" import QualityDetail from "./components/dialogResult.vue"
import { Util, deepClone } from '@/common/util' import { Util, deepClone } from "@/common/util"
import { getTaskStaffList, remindTaskStaff } from "@api/exercise" import { getTaskStaffList, remindTaskStaff, stopTask } from "@api/exercise"
import { scenarioType } from './contant' import { scenarioType } from "./contant"
export default { export default {
components: { QualityDetail }, components: { QualityDetail },
data() { data() {
return { return {
scenarioType, scenarioType,
activeName: 'all', activeName: "all",
searchForm: {}, searchForm: {},
showFormData: [ showFormData: [
{ {
...@@ -102,20 +137,28 @@ export default { ...@@ -102,20 +137,28 @@ export default {
tableParams: { tableParams: {
listName: "list", listName: "list",
tableOption: true, tableOption: true,
tableColumns: [{ tableColumns: [
{
label: "手机号", label: "手机号",
prop: "staffPhone" prop: "staffPhone"
}, { },
{
label: "员工名称", label: "员工名称",
prop: "staffName" prop: "staffName"
}, { },
label: "完成状态", {
prop: "sparringStatus", label: "客户类型",
addHtml: 'sparringStatus' prop: "roleTypeDesc"
}, { },
{
label: "得分",
prop: "score"
},
{
label: "完成时间", label: "完成时间",
prop: "completionTime" prop: "completionTime"
}] }
]
}, },
isQualityVisible: false, isQualityVisible: false,
detailObj: {}, detailObj: {},
...@@ -133,25 +176,41 @@ export default { ...@@ -133,25 +176,41 @@ export default {
} }
}, },
mounted() { mounted() {
console.log(this.$route.query, '===') console.log(this.$route.query, "===")
this.taskInfo = JSON.parse(this.$route.query.detail) this.taskInfo = JSON.parse(this.$route.query.detail)
this.searchFormSearch.taskId = this.taskInfo.id this.searchFormSearch.taskId = this.taskInfo.id
}, },
methods: { methods: {
...mapActions({ ...mapActions({
get: 'd2admin/base/get', get: "d2admin/base/get",
close: 'd2admin/page/close' close: "d2admin/page/close"
}), }),
...mapActions('d2admin/user', ['actionSetDownloadList']), ...mapActions("d2admin/user", ["actionSetDownloadList"]),
handleSearch() { handleSearch() {
console.log('search', this.searchFormSearch) console.log("search", this.searchFormSearch)
this.$refs.exerciseDetailTable.refreshTable(true, true) this.$refs.exerciseDetailTable.refreshTable(true, true)
}, },
btnClickEnd(scope) {
const { id } = scope.scope
this.$confirm("是否确认结束此任务?", "结束提醒", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then((end) => {
if (end == "confirm") {
// this.commitFn(type)
remindTaskStaff({ id }).then((res) => {
console.log(res)
this.$message.success("结束成功")
})
}
})
},
handleReset() { handleReset() {
console.log('handleReset') console.log("handleReset")
const { activeName } = this const { activeName } = this
this.searchForm = {} this.searchForm = {}
this.searchForm.sparringStatus = activeName != 'all' ? activeName : '' this.searchForm.sparringStatus = activeName != "all" ? activeName : ""
this.searchFormSearch = {} this.searchFormSearch = {}
this.$refs.exerciseDetailTable.refreshTable(true, true) this.$refs.exerciseDetailTable.refreshTable(true, true)
}, },
...@@ -161,15 +220,21 @@ export default { ...@@ -161,15 +220,21 @@ export default {
const { activeName } = this const { activeName } = this
params.taskId = this.taskInfo.id params.taskId = this.taskInfo.id
if (params.completionTime && params.completionTime.length) { if (params.completionTime && params.completionTime.length) {
params.startTime = Util.dateFormate(params.completionTime[0], 'YYYY-MM-DD HH:mm:ss') params.startTime = Util.dateFormate(
params.endTime = Util.dateFormate(params.completionTime[1], 'YYYY-MM-DD HH:mm:ss') params.completionTime[0],
"YYYY-MM-DD HH:mm:ss"
)
params.endTime = Util.dateFormate(
params.completionTime[1],
"YYYY-MM-DD HH:mm:ss"
)
delete params.completionTime delete params.completionTime
} }
params.sparringStatus = activeName != 'all' ? activeName : '' params.sparringStatus = activeName != "all" ? activeName : ""
return params return params
}, },
beforeSearchFn() { beforeSearchFn() {
return new Promise(resolve => { return new Promise((resolve) => {
this.searchFormSearch = this.getParams() this.searchFormSearch = this.getParams()
resolve() resolve()
}) })
...@@ -182,24 +247,24 @@ export default { ...@@ -182,24 +247,24 @@ export default {
}, },
// 查看结果和提醒 // 查看结果和提醒
btnClick(scope) { btnClick(scope) {
console.log(scope, '2222222') console.log(scope, "2222222")
const _row = scope.scope const _row = scope.scope
if (_row.sparringStatus == '1') { if (_row.sparringStatus == "1") {
// 查看结果 // 查看结果
this.detailObj = _row this.detailObj = _row
this.isQualityVisible = true this.isQualityVisible = true
} else { } else {
this.$confirm('是否确认发送提醒给驻店员工?', '发送提醒', { this.$confirm("是否确认发送提醒给驻店员工?", "发送提醒", {
confirmButtonText: '确定', confirmButtonText: "确定",
type: 'warning' type: "warning"
}).then(() => { }).then(() => {
console.log('dia关闭') console.log("dia关闭")
const params = { const params = {
id: _row.id id: _row.id
} }
remindTaskStaff(params).then(res => { remindTaskStaff(params).then((res) => {
console.log(res) console.log(res)
this.$message.success('提醒成功') this.$message.success("提醒成功")
}) })
}) })
} }
...@@ -210,8 +275,7 @@ export default { ...@@ -210,8 +275,7 @@ export default {
// 导出 // 导出
handleExport() { handleExport() {
var params = this.getParams() var params = this.getParams()
params.method = params.method = "dj.api.smartcarlife.ai.sparring.task.staff.list.export"
"dj.api.smartcarlife.ai.sparring.task.staff.list.export"
const list = [ const list = [
...this.dowloadList, ...this.dowloadList,
{ {
...@@ -265,14 +329,13 @@ export default { ...@@ -265,14 +329,13 @@ export default {
margin-right: 8px; margin-right: 8px;
} }
.green { .green {
background-color: #27CD5A; background-color: #27cd5a;
} }
.orange { .orange {
background-color: #FDB757; background-color: #fdb757;
} }
.blue { .blue {
background-color: #2a58ad; background-color: #2a58ad;
} }
} }
</style> </style>
<!--
* @Description: AI对练记录
* @Author: huyue
* @Date: 2024-04-15 16:26:57
* @LastEditors: huyue
* @LastEditTime: 2024-05-07 10:56:13
-->
<template>
<d2-container class="m-t-40">
<div class="header" slot="header" style="padding: 10px 20px">
<d2-search
ref="showSearch"
class="show-search"
label-width="110px"
:search-form="searchForm"
:form-data="showFormData"
>
<div class="up-btns">
<el-button size="small" type="primary" @click="handleSearch">
查询
</el-button>
<el-button size="small" @click="handleReset"> 重置 </el-button>
</div>
</d2-search>
</div>
<div class="d2-container-content" style="position: positive">
<!-- <span style="position: absolute; right: 41px; top: 42px; z-index: 999">
<auth-button :show-btn-ids="['9120801', '9120802']" category="Button" />
</span> -->
<d2-table-header>
<auth-button
category="Button"
style="
{
display: inline-block;
}
"
:show-btn-ids="['9120802']"
/>
</d2-table-header>
<!-- <el-tabs v-model="activeName" type="card" @tab-click="handleTabChange">
<el-tab-pane label="全部" name="all"> </el-tab-pane>
<el-tab-pane label="进行中" name="1"> </el-tab-pane>
<el-tab-pane label="已结束" name="2"> </el-tab-pane>
</el-tabs> -->
<d2-table
ref="exerciseTable"
:has-num="true"
:search-form="searchFormSearch"
:table-params="tableParams"
:get-list-api="getListApi"
:before-search-fn="beforeSearchFn"
>
<!-- v-if="scope.scope.sparringStatus === 1" -->
<template slot="auth-button-other" slot-scope="scope">
<el-button type="text" @click="btnClick(scope)">查看结果</el-button>
</template>
<div slot="taskState" slot-scope="scope">
<div class="online-status">
<span
:class="[
scope.scope.taskState === 0
? 'dot blue'
: scope.scope.taskState === 1
? 'dot orange'
: 'dot gray'
]"
></span
>{{ statusObj[scope.scope.taskState] }}
</div>
</div>
</d2-table>
</div>
</d2-container>
</template>
<script>
import { mapActions, mapState } from "vuex"
import { Util, deepClone } from "@/common/util"
import {
getList,
getTaskStaffList,
updateTaskPromptStatus
} from "@api/exercise"
// import { getTaskStaffList, remindTaskStaff } from "@api/exercise"
import { scenarioType } from "./contant"
export default {
data() {
return {
searchForm: {},
showFormData: [
{
label: "手机号",
name: "staffPhone",
type: "input",
isclear: true
},
{
label: "员工名称",
name: "staffName",
type: "input",
isclear: true
},
{
label: "完成时间",
name: "completionTime",
type: "datePicker",
isclear: true
}
],
statusObj: { 0: "未开始", 1: "进行中", 2: "已结束" },
activeName: "all",
// table相关
getListApi: getTaskStaffList,
searchFormSearch: {},
tableParams: {
listName: "list",
tableOption: true,
tableColumns: [
{
label: "手机号",
prop: "staffPhone"
},
{
label: "员工名称",
prop: "staffName"
},
{
label: "客户类型",
prop: "roleTypeDesc"
},
{
label: "得分",
prop: "score"
},
{
label: "对练时长",
prop: "completionTime",
formatter: (cellValue) => {
return (
Util.dateFormate(cellValue.startTime, "YYYY-MM-DD") +
"-" +
Util.dateFormate(cellValue.endTime, "YYYY-MM-DD")
)
}
},
{
label: "完成时间",
prop: "completionTime"
// formatter: (cellValue) => {
// return Util.dateFormate(
// cellValue.completionTime,
// "YYYY-MM-DD hh:mm:ss"
// )
// // "-" +
// // Util.dateFormate(cellValue.endTime, "YYYY-MM-DD")
// }
}
]
}
}
},
computed: {
...mapState({
dowloadList: (state) => state.d2admin.user.dowloadList
})
},
methods: {
...mapActions({
get: "d2admin/base/get",
close: "d2admin/page/close"
}),
...mapActions("d2admin/user", ["actionSetDownloadList"]),
handleSearch() {
this.$refs.exerciseTable.refreshTable(true, true)
},
beforeSearchFn() {
console.log(this.searchForm)
return new Promise((resolve) => {
this.searchFormSearch = this.getParams()
resolve()
})
},
getParams() {
var params = deepClone(this.searchForm)
const { activeName } = this
// params.taskId = this.taskInfo.id
if (params.completionTime && params.completionTime.length) {
params.startTime = Util.dateFormate(
params.completionTime[0],
"YYYY-MM-DD HH:mm:ss"
)
params.endTime = Util.dateFormate(
params.completionTime[1],
"YYYY-MM-DD HH:mm:ss"
)
delete params.completionTime
}
params.sparringStatus = activeName != "all" ? activeName : ""
return params
},
handleReset() {
console.log("handleReset")
this.searchForm = {}
this.activeName = "all"
this.searchFormSearch = {}
this.$refs.exerciseTable.refreshTable(true, true)
},
// tab 列表切换
handleTabChange(tab, event) {
console.log(tab, event)
this.searchForm.taskState = tab.name != "all" ? tab.name : ""
this.handleSearch()
},
// 状态改变
handleSwitch(scope, e) {
console.log(scope)
const { promptOnOff, id } = scope.scope
this.$confirm(
`是否确认${promptOnOff ? "关闭" : "开启"}提示词?`,
"提示",
{
confirmButtonText: "确定",
type: "warning"
}
).then(() => {
console.log("dia开启")
updateTaskPromptStatus({
id,
promptOnOff: !promptOnOff
})
.then((res) => {
if (res && res.id) {
this.$message.success("修改成功")
} else {
this.$message.error("修改失败")
}
this.$refs.exerciseTable.refreshTable(true)
})
.catch((err) => {
console.log(err)
this.$message.error("修改失败")
})
})
},
// 明细
handleToDetail(row) {
this.close({ tagName: "/exercise" })
this.$router.push({
path: "/exerciseDetail",
query: { detail: JSON.stringify(row) }
})
},
// 查看
handleToView(row) {
this.close({ tagName: "/exercise" })
this.$router.push({
path: "/exerciseView",
query: { detail: JSON.stringify(row) }
})
},
// 新建任务
handleToAdd() {
this.close({ tagName: "/exercise" })
this.$router.push({
path: "/exerciseAdd"
})
},
// 导出
handleExport() {
console.log("导出", this.searchFormSearch, this.getParams())
var params = this.getParams()
params.method =
"dj.api.smartcarlife.ai.sparring.task.staff.record.list.export"
const list = [
...this.dowloadList,
{
name: "对练明细记录列",
exportParam: JSON.stringify(params),
status: "waiting",
timeid: new Date().getTime()
}
]
this.actionSetDownloadList({ list, type: "dowloadList" })
}
}
}
</script>
<style scoped lang="scss">
.m-t-40 {
margin-top: 40px;
}
.online-status {
display: flex;
justify-content: center;
align-items: center;
.dot {
display: inline-block;
width: 8px;
height: 8px;
border-radius: 50%;
margin-right: 8px;
}
.gray {
background-color: #c5c5c5;
}
.orange {
background-color: #fdb757;
}
.blue {
background-color: #2a58ad;
}
}
</style>
<!-- ai对练 对练记录和任务列表 -->
<template>
<div class="in-exerciseTab-list-wrap">
<div class="header" slot="header" style="background: #e7eaec">
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane
v-for="(item, index) in tabPaneList"
:label="item.label"
:name="item.name"
:key="index"
>
</el-tab-pane>
</el-tabs>
<components :is="tabName" :scene-type="activeName"></components>
</div>
</div>
</template>
<script>
import index from "./index.vue"
import exerciseRecord from "./exerciseRecord.vue"
export default {
name: "exerciseTab",
components: {
exerciseRecord,
exerciseTask: index
},
data() {
return {
activeName: "0",
tabPaneList: [
{
label: "对练记录",
name: "0"
},
{
label: "任务列表",
name: "1"
}
],
// tabName: "exerciseTask"
tabName: "exerciseRecord"
}
},
mounted() {
if (this.$route.params.tabPane) {
this.activeName = this.$route.params.tabPane
this.tabName = this.$route.params.tabLabel
}
},
watch: {},
methods: {
handleClick() {
const arr = {
0: "exerciseRecord",
1: "exerciseTask"
}
this.tabName = arr[+this.activeName]
}
}
}
</script>
<style scoped lang="scss">
.in-exerciseTab-list-wrap {
padding: 0 24px;
.header {
::v-deep .el-tabs__header {
margin: 0;
padding: 0 20px;
}
}
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!