Commit 0f53e89e by chenwq

feat: 添加审批详情和审批提交页面,更新相关路由和API接口

1 parent 0c3bc04b
......@@ -4,4 +4,13 @@ export default {
getApprovalPage(data) {
return api.post("dj.api.supervisor.mini.approval.page", data, "supervisorUrl");
},
getApprovalDetail(data) {
return api.post("dj.api.supervisor.mini.approval.getDetail", data, "supervisorUrl");
},
getDictList(data) {
return api.post("dj.api.staff.miniprogram.dict.list", data, "staffUrl");
},
submitApproval(data) {
return api.post("dj.api.supervisor.mini.approval.submit", data, "supervisorUrl");
},
};
const urlObj = {
supervisorUrl: "/rop-dj-supervisor-mini/router",
clueUrl: "/rop-scrm-clue/router",
staffUrl: "/rop-dj-staff-miniprogram/router",
};
const httpObj = {
......
......@@ -15,6 +15,24 @@ export const mineRoutes = [
showTabBar: true,
},
},
{
path: "approval-detail",
name: "mine/approvalDetail",
component: () => import("@/views/mine/view/approvalDetail.vue"),
meta: {
title: "专项带教审批",
backgroundColor: "#f2f3f7",
},
},
{
path: "approval-submit",
name: "mine/approvalSubmit",
component: () => import("@/views/mine/view/approvalSubmit.vue"),
meta: {
title: "专项带教审批",
backgroundColor: "#f2f3f7",
},
},
],
},
];
<template>
<div class="approval-page">
<div class="detail-list">
<div v-for="item in fields"
:key="item.label"
class="detail-item"
:class="{ column: item.type === 'textarea' }">
<div class="label">
{{ item.label }}
</div>
<div v-if="item.type === 'tags'" class="tag-list">
<span v-for="name in toNameList(item.value)"
:key="name"
class="name-tag">
{{ name }}
</span>
<span v-if="!toNameList(item.value).length" class="value muted">-</span>
</div>
<div v-else
class="value"
:class="{ muted: !item.value }">
{{ item.value || '-' }}
</div>
</div>
</div>
<div v-if="canAudit" class="bottom-bar">
<button class="reject-btn"
type="button"
@click="goSubmit('reject')">
驳回
</button>
<button class="approve-btn"
type="button"
@click="goSubmit('approve')">
通过
</button>
</div>
</div>
</template>
<script>
import api from "@/api/mine";
import util from "@/utils/util";
export default {
name: "MineApprovalDetail",
data() {
return {
userInfo: {},
id: "",
detail: {},
status: 0,
detailLoaded: false,
};
},
computed: {
fields() {
return [
{ label: "任务类型", value: "专项带教" },
{ label: "归属门店", value: this.detail.merchantName },
{ label: "归属业务", value: this.detail.businessTypeName },
{ label: "需带教驻店人员", value: this.detail.teachingStaffNames, type: "tags" },
{ label: "归属区域督导", value: this.detail.supervisorNames },
{ label: "申请描述", value: this.detail.applyDescription, type: "textarea" },
];
},
canAudit() {
return this.detailLoaded && Number(this.status) === 0;
},
},
created() {
this.userInfo = util.getLocalStorage("ww_userInfo") || {};
this.id = this.$route.query.id || "";
this.status = Number(this.$route.query.status || 0);
this.getDetail();
},
methods: {
async getDetail() {
if (!this.id)
return;
try {
const params = { id: this.id, phone: this.userInfo.phone };
const res = await api.getApprovalDetail(params);
if (!res) {
return;
}
this.detail = res.data || res || {};
if (this.detail.approvalStatus !== undefined) {
this.status = Number(this.detail.approvalStatus);
}
} finally {
this.detailLoaded = true;
}
},
toNameList(value) {
if (Array.isArray(value))
return value.filter(Boolean);
if (!value)
return [];
return String(value).split(/[,,]/).map(item => item.trim()).filter(Boolean);
},
goSubmit(type) {
this.$router.push({
name: "mine/approvalSubmit",
query: { id: this.id, type },
});
},
},
};
</script>
<style lang="scss" scoped>
.approval-page {
min-height: 100%;
background: #f2f3f7;
box-sizing: border-box;
padding: 0 12px 96px;
}
.page-title {
font-size: 17px;
font-weight: 600;
}
.detail-list {
padding-top: 4px;
}
.detail-item {
min-height: 50px;
background: #fff;
border-radius: 8px;
padding: 0 14px;
margin-bottom: 8px;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
&.column {
display: block;
padding-top: 14px;
padding-bottom: 14px;
.value {
margin-top: 12px;
text-align: left;
line-height: 22px;
white-space: pre-wrap;
}
}
}
.label {
flex-shrink: 0;
font-size: 14px;
color: #000000e5;
}
.value {
flex: 1;
text-align: right;
font-size: 14px;
color: #00000099;
line-height: 20px;
word-break: break-all;
&.muted {
color: #00000040;
}
}
.tag-list {
flex: 1;
display: flex;
justify-content: flex-end;
flex-wrap: wrap;
gap: 6px;
}
.name-tag {
line-height: 24px;
padding: 0 10px;
border-radius: 4px;
background: #f2f3f5;
font-size: 12px;
color: #000000a6;
}
.bottom-bar {
position: fixed;
left: 0;
right: 0;
bottom: 0;
height: 84px;
padding: 10px 12px 22px;
box-sizing: border-box;
background: #fff;
display: flex;
gap: 12px;
}
.bottom-bar button {
flex: 1;
height: 38px;
border: 0;
border-radius: 7px;
font-size: 14px;
}
.reject-btn {
background: #efefef;
color: #000000e5;
}
.approve-btn {
background: #2f66f6;
color: #fff;
}
</style>
<template>
<div class="approval-submit-page">
<!-- <div class="page-header">
<van-icon name="arrow-left" @click="$router.back()" />
<div class="page-title">
{{ pageTitle }}
</div>
<van-icon name="ellipsis" />
</div> -->
<div v-if="isApprove" class="form-card">
<div class="form-row" @click="openPicker('scene')">
<span>带教场景</span>
<div class="row-value">
<span :class="{ placeholder: !form.teachingSceneName }">{{ form.teachingSceneName || '点击选择' }}</span>
<van-icon name="arrow" />
</div>
</div>
<div class="form-row" @click="showTimePicker = true">
<span>带教时间</span>
<div class="row-value">
<span :class="{ placeholder: !form.teachingTime }">{{ form.teachingTime || '点击选择' }}</span>
<van-icon name="arrow" />
</div>
</div>
<div class="form-row" @click="openPicker('method')">
<span>带教方式</span>
<div class="row-value">
<span :class="{ placeholder: !form.teachingMethodName }">{{ form.teachingMethodName || '点击选择' }}</span>
<van-icon name="arrow" />
</div>
</div>
<div class="form-row" @click="openPicker('topic')">
<span>带教主题</span>
<div class="row-value">
<span :class="{ placeholder: !form.teachingTopicName }">{{ form.teachingTopicName || '点击选择' }}</span>
<van-icon name="arrow" />
</div>
</div>
</div>
<div v-else class="reject-card">
<div class="reject-label">
驳回理由 <span>*</span>
</div>
<van-field v-model.trim="form.rejectReason"
class="reject-field"
maxlength="500"
placeholder="请输入"
rows="4"
type="textarea"
show-word-limit />
</div>
<div class="bottom-bar">
<button class="submit-btn"
type="button"
:class="{ disabled: submitDisabled }"
@click="submit">
提交
</button>
</div>
<van-popup v-model="picker.show"
position="bottom"
round>
<van-picker value-key="name"
show-toolbar
:columns="pickerColumns"
:title="picker.title"
@cancel="picker.show = false"
@confirm="onPickerConfirm" />
</van-popup>
<van-popup v-model="showTimePicker"
position="bottom"
round>
<van-datetime-picker v-model="currentDate"
title="选择带教时间"
type="datetime"
@cancel="showTimePicker = false"
@confirm="onTimeConfirm" />
</van-popup>
</div>
</template>
<script>
import dayjs from "dayjs";
import { Toast } from "vant";
import api from "@/api/mine";
import util from "@/utils/util";
const DICT_CONFIG = {
scene: { typeCode: "teaching_scene", title: "选择带教场景" },
methodOnline: { typeCode: "teaching_method_1", title: "选择带教方式" },
methodOffline: { typeCode: "teaching_method_2", title: "选择带教方式" },
topic: { typeCode: "teaching_topic", title: "选择带教主题" },
};
export default {
name: "MineApprovalSubmit",
data() {
return {
userInfo: {},
id: "",
type: "approve",
currentDate: new Date(),
showTimePicker: false,
dicts: {
scene: [],
methodOnline: [],
methodOffline: [],
topic: [],
},
picker: {
show: false,
key: "",
title: "",
},
submitting: false,
form: {
teachingSceneCode: "",
teachingSceneName: "",
teachingTime: "",
teachingMethodCode: "",
teachingMethodName: "",
teachingTopicCode: "",
teachingTopicName: "",
rejectReason: "",
},
};
},
computed: {
isApprove() {
return this.type === "approve";
},
pageTitle() {
return this.isApprove ? "通过" : "驳回";
},
submitDisabled() {
return this.submitting || !this.id || (!this.isApprove && !this.form.rejectReason);
},
methodKey() {
const sceneText = `${this.form.teachingSceneCode}${this.form.teachingSceneName}`;
return sceneText.includes("线下") || sceneText.includes("offline") ? "methodOffline" : "methodOnline";
},
pickerColumns() {
if (this.picker.key === "method")
return this.dicts[this.methodKey];
return this.dicts[this.picker.key] || [];
},
},
created() {
this.userInfo = util.getLocalStorage("ww_userInfo") || {};
this.id = this.$route.query.id || "";
this.type = this.$route.query.type || "approve";
document.title = this.isApprove ? "通过" : "驳回";
if (this.isApprove) {
this.getDicts();
}
},
methods: {
async getDicts() {
await Promise.all([
this.getDict("scene"),
this.getDict("methodOnline"),
this.getDict("methodOffline"),
this.getDict("topic"),
]);
},
async getDict(key) {
const config = DICT_CONFIG[key];
const res = await api.getDictList({
businessCode: "supervisor",
typeCode: config.typeCode,
});
const data = res.data || res || {};
const list = data.list || data.records || data || [];
this.dicts[key] = (Array.isArray(list) ? list : []).map(this.normalizeDictItem);
},
normalizeDictItem(item) {
return {
...item,
code: item.itemValue || "",
name: item.itemName || "",
};
},
openPicker(key) {
const configKey = key === "method" ? this.methodKey : key;
this.picker.key = key;
this.picker.title = DICT_CONFIG[configKey]?.title || "";
this.picker.show = true;
},
onPickerConfirm(item) {
if (!item) {
this.picker.show = false;
return;
}
if (this.picker.key === "scene") {
this.form.teachingSceneCode = item.code;
this.form.teachingSceneName = item.name;
this.form.teachingMethodCode = "";
this.form.teachingMethodName = "";
}
if (this.picker.key === "method") {
this.form.teachingMethodCode = item.code;
this.form.teachingMethodName = item.name;
}
if (this.picker.key === "topic") {
this.form.teachingTopicCode = item.code;
this.form.teachingTopicName = item.name;
}
this.picker.show = false;
},
onTimeConfirm(value) {
this.form.teachingTime = dayjs(value).format("YYYY-MM-DD HH:mm:ss");
this.showTimePicker = false;
},
buildParams() {
const params = {
id: this.id,
approvalStatus: this.isApprove ? 1 : 2,
phone: this.userInfo.phone,
};
if (!this.isApprove) {
params.rejectReason = this.form.rejectReason;
return params;
}
return {
...params,
teachingSceneCode: this.form.teachingSceneCode,
teachingSceneName: this.form.teachingSceneName,
teachingTime: this.form.teachingTime,
teachingMethodCode: this.form.teachingMethodCode,
teachingMethodName: this.form.teachingMethodName,
teachingTopicCode: this.form.teachingTopicCode,
teachingTopicName: this.form.teachingTopicName,
};
},
async submit() {
if (this.submitting)
return;
if (!this.id) {
Toast("缺少任务信息");
return;
}
if (!this.isApprove && !this.form.rejectReason) {
Toast("请输入驳回理由");
return;
}
this.submitting = true;
try {
await api.submitApproval(this.buildParams());
Toast("提交成功");
this.$router.replace({ name: "mine/tasks" });
} finally {
this.submitting = false;
}
},
},
};
</script>
<style lang="scss" scoped>
.approval-submit-page {
min-height: 100%;
background: #f2f3f7;
box-sizing: border-box;
padding: 0 10px 96px;
}
.page-header {
height: 64px;
display: flex;
align-items: center;
justify-content: space-between;
color: #000000e5;
.van-icon {
width: 32px;
font-size: 20px;
}
}
.page-title {
font-size: 17px;
font-weight: 600;
}
.form-card,
.reject-card {
background: #fff;
border-radius: 8px;
overflow: hidden;
}
.form-row {
height: 52px;
padding: 0 14px;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: space-between;
border-bottom: 1px solid #f0f0f0;
font-size: 14px;
color: #000000e5;
&:last-child {
border-bottom: 0;
}
}
.row-value {
flex: 1;
min-width: 0;
margin-left: 14px;
display: flex;
align-items: center;
justify-content: flex-end;
color: #000000e5;
span {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.placeholder {
color: #00000040;
}
.van-icon {
margin-left: 4px;
color: #00000040;
}
}
.reject-card {
padding: 14px;
box-sizing: border-box;
}
.reject-label {
font-size: 14px;
color: #000000e5;
margin-bottom: 12px;
span {
color: #ee0a24;
}
}
.reject-field {
border: 1px solid #ebedf0;
border-radius: 6px;
padding: 10px;
}
.bottom-bar {
position: fixed;
left: 0;
right: 0;
bottom: 0;
height: 84px;
padding: 10px 12px 22px;
box-sizing: border-box;
background: #fff;
}
.submit-btn {
width: 100%;
height: 38px;
border: 0;
border-radius: 7px;
background: #2f66f6;
color: #fff;
font-size: 14px;
&.disabled {
background: #8facf8;
}
}
</style>
......@@ -128,15 +128,13 @@ export default {
return this.statusMap[Number(item.approvalStatus)] || this.statusMap[0];
},
handleTask(item) {
const url = item.approvalUrl || item.detailUrl || item.pageUrl || item.url || item.h5Url;
if (!url)
const id = item.id;
if (!id)
return;
if (/^https?:\/\//.test(url)) {
window.location.href = url;
return;
}
this.$router.push(url);
this.$router.push({
name: "mine/approvalDetail",
query: { id, status: item.approvalStatus },
});
},
},
};
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!