接口对接完成

This commit is contained in:
bestlee 2026-06-25 10:44:30 +08:00
parent d784e10bcf
commit a2388c1b0d
7 changed files with 214 additions and 24 deletions

View File

@ -12,4 +12,12 @@ export function waitListApi(params) {
export function detailsApi(id) {
return axios.get('/api/chain-remove-applies/'+id);
}
// 通过、驳回、保存
export function approvalApi(id,params) {
return axios.post('/api/chain-remove-applies/'+id+'/audit',params);
}
// 获取待审批数量
export function taskCountApi() {
return axios.get('/api/users/role', {});
}

View File

@ -37,10 +37,10 @@ axios.interceptors.response.use(
},
(error) => {
if (error.response.status === 401) {
showNotify({ type: 'danger', message: '账号已过期,请重新登录!' });
showNotify({ message: '账号已过期,请重新登录!', background: '#ff7d00' });
router.push({ path: '/login' });
} else {
showNotify({ type: 'danger', message: error.response.data.message || '服务错误' });
showNotify({ message: error.response.data.message || '服务错误', background: '#ff7d00' });
}
return Promise.reject(error);;
}

View File

@ -1,10 +1,10 @@
import './assets/main.css'
import 'vant/lib/index.css'
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
import 'amfe-flexible'
import 'vant/lib/index.css'
import '@/api/request';
const app = createApp(App)

View File

@ -3,12 +3,15 @@ import { ref,onMounted } from 'vue'
import router from '@/router'
import { useRoute } from 'vue-router'
import { showNotify } from 'vant'
import { detailsApi } from '@/api/apply';
import { detailsApi,approvalApi,taskCountApi } from '@/api/apply';
const route = useRoute()
const loading = ref(false);
const params = ref(null)
const info = ref(null)
const showReject = ref(false)
const rejectComment = ref('')
const taskCount = ref(0);
//
const statusList = ref([
{text:'草稿',value:0},
@ -45,14 +48,62 @@ const jumpTo = (val) => {
if(val===2){
router.push({
path: '/lockDetail',
query: { id: params.value.id, type: params.value.type },
query: { id: params.value.id, type: params.value.type,isMyself: params.value.isMyself },
})
}
}
//
const agree = () => {
showNotify({ type: 'success', message: '同意成功' });
const agree = async () => {
loading.value = true;
try {
await approvalApi(params.value?.id,{
action: 'approve',
comment: '',
risk_description: info.value?.risk_description,
safety_measures: info.value?.safety_measures,
cosign_item_id: info.value?.cosign_item_id,//id
});
showNotify({ message: '同意成功', background: '#00b42a' });
jumpTo(params.value?.type==='wait'?1:0);
} finally {
loading.value = false;
}
}
//
const reject = async () => {
rejectComment.value = '';
showReject.value = true;
}
//
const rejectConfirm = (action) => new Promise(async (resolve) => {
//
if(action==='cancel'){
showReject.value = false;
resolve(true);
}
//
if(action==='confirm'){
if(rejectComment.value==''){
showNotify({ message: '请输入驳回理由', background: '#ff7d00' });
resolve(false);
return;
}
try {
await approvalApi(params.value?.id,{
action: 'reject',
comment: rejectComment.value,//
risk_description: info.value?.risk_description,
safety_measures: info.value?.safety_measures,
cosign_item_id: info.value?.cosign_item_id,//id
});
showNotify({ message: '驳回成功', background: '#00b42a' });
resolve(true);
jumpTo(params.value?.type==='wait'?1:0);
} catch (error) {
resolve(false);
}
}
});
//
const getDetail = async () => {
loading.value = true;
@ -69,12 +120,23 @@ const getDetail = async () => {
}else{
info.value.steps = res.data?.apply_steps;
}
console.log(info.value)
} finally {
loading.value = false;
}
}
//
const getTaskCount = async () => {
try {
const res = await taskCountApi();
taskCount.value = res.data?.chain_remove?.count || 0;
} catch (error) {
}
}
onMounted(() => {
getTaskCount();
if(route.query){
params.value = route.query;
getDetail();
@ -90,7 +152,7 @@ onMounted(() => {
<div class="main">
<div class="tab-box">
<p class="tab" :class="{'active':params?.type==='finish'}" @click="jumpTo(0)">已审批</p>
<p class="tab" :class="{'active':params?.type==='wait'}" @click="jumpTo(1)">待审批</p>
<p class="tab" :class="{'active':params?.type==='wait'}" @click="jumpTo(1)">待审批<span v-if="taskCount>0">{{taskCount}}</span></p>
</div>
<template v-if="info">
<div class="detail">
@ -156,18 +218,34 @@ onMounted(() => {
</template>
</div>
</div>
<div class="row" v-if="info?.status==99 && info?.reject">
<p>驳回{{info?.reject?.comment}}</p>
</div>
</div>
<div class="btns">
<p class="btn" @click="jumpTo(params?.type==='finish'?0:1)">返回列表</p>
<p class="btn" @click="jumpTo(2)">联锁详情</p>
<p class="btn" v-if="params?.type==='wait'" @click="agree">同意</p>
<p class="btn" v-if="params?.type==='wait'">驳回</p>
<div class="op" v-if="
params?.type==='wait' && info?.status!=99 && params?.isMyself==='pending' &&
(info?.status==1 || info?.status==2 || info?.status==3 || info?.status==4) &&
(((info?.template_id==1 || info?.template_id==4) && (info?.current_step>=1 && info?.current_step<=3)) ||
((info?.template_id==2 || info?.template_id)==3 && (info?.current_step>=1 && info?.current_step<=4)))
">
<p class="btn" @click="agree">同意</p>
<p class="btn" @click="reject">驳回</p>
</div>
</div>
</template>
<template v-else>
<van-empty description="暂无数据" />
</template>
</div>
<!-- 驳回弹框 -->
<van-dialog v-model:show="showReject" title="驳回" show-cancel-button :before-close="rejectConfirm" @cancel="rejectConfirm">
<div style="padding: 10px 0;">
<van-field v-model="rejectComment" label="驳回理由" type="textarea" rows="1" autosize required clearable placeholder="请输入驳回理由" />
</div>
</van-dialog>
</template>
<style scoped>
@ -234,6 +312,11 @@ onMounted(() => {
border: 1px solid #eee;
border-radius: 2px;
}
.btns .op {
width: 100%;
display: flex;
gap: 12px;
}
/* 时间线 */
.timeline {
width: 100%;

View File

@ -1,12 +1,13 @@
<script setup>
import { ref,onMounted } from 'vue'
import router from '@/router'
import { applyListApi } from '@/api/apply';
import { applyListApi,taskCountApi } from '@/api/apply';
const loading = ref(false);
const isAll = ref('1');
const currentPage = ref(1);
const total = ref(0);
const taskCount = ref(0);
//
const statusList = ref([
{text:'草稿',value:0},
@ -74,8 +75,18 @@ const pageChange = (val) => {
currentPage.value = val;
getList();
}
//
const getTaskCount = async () => {
try {
const res = await taskCountApi();
taskCount.value = res.data?.chain_remove?.count || 0;
} catch (error) {
}
}
onMounted(() => {
getTaskCount();
getList();
});
</script>
@ -88,7 +99,7 @@ onMounted(() => {
<div class="main">
<div class="tab-box">
<p class="tab active">已审批</p>
<p class="tab" @click="jumpTo('wait',null)">待审批</p>
<p class="tab" @click="jumpTo('wait',null)">待审批<span v-if="taskCount>0">{{taskCount}}</span></p>
</div>
<div class="radio-box">
<van-radio-group v-model="isAll" direction="horizontal" @change="radioChange">

View File

@ -3,13 +3,15 @@ import { ref, onMounted } from 'vue'
import router from '@/router'
import { useRoute } from 'vue-router'
import { showNotify } from 'vant'
import { detailsApi } from '@/api/apply';
import { detailsApi,approvalApi,taskCountApi } from '@/api/apply';
const route = useRoute()
const loading = ref(false);
const params = ref(null)
const info = ref(null)
const list = ref([{}])
const showReject = ref(false)
const rejectComment = ref('')
const taskCount = ref(0);
//
const jumpTo = (val) => {
//
@ -28,7 +30,7 @@ const jumpTo = (val) => {
if(val===3){
router.push({
path: '/detail',
query: { id: params.value.id, type: params.value.type },
query: { id: params.value.id, type: params.value.type,isMyself: params.value.isMyself },
})
}
}
@ -46,9 +48,57 @@ const getOrg = (data) => {
}
//
const agree = () => {
showNotify({ type: 'success', message: '同意成功' });
const agree = async () => {
loading.value = true;
try {
await approvalApi(params.value?.id,{
action: 'approve',
comment: '',
risk_description: info.value?.risk_description,
safety_measures: info.value?.safety_measures,
cosign_item_id: info.value?.cosign_item_id,//id
});
showNotify({ message: '同意成功', background: '#00b42a' });
jumpTo(params.value?.type==='wait'?1:0);
} finally {
loading.value = false;
}
}
//
const reject = async () => {
rejectComment.value = '';
showReject.value = true;
}
//
const rejectConfirm = (action) => new Promise(async (resolve) => {
//
if(action==='cancel'){
showReject.value = false;
resolve(true);
}
//
if(action==='confirm'){
if(rejectComment.value==''){
showNotify({ message: '请输入驳回理由', background: '#ff7d00' });
resolve(false);
return;
}
try {
await approvalApi(params.value?.id,{
action: 'reject',
comment: rejectComment.value,//
risk_description: info.value?.risk_description,
safety_measures: info.value?.safety_measures,
cosign_item_id: info.value?.cosign_item_id,//id
});
showNotify({ message: '驳回成功', background: '#00b42a' });
resolve(true);
jumpTo(params.value?.type==='wait'?1:0);
} catch (error) {
resolve(false);
}
}
});
//
const getDetail = async () => {
@ -56,13 +106,22 @@ const getDetail = async () => {
try {
const res = await detailsApi(params.value?.id);
info.value = res.data;
console.log(info.value);
} finally {
loading.value = false;
}
}
//
const getTaskCount = async () => {
try {
const res = await taskCountApi();
taskCount.value = res.data?.chain_remove?.count || 0;
} catch (error) {
}
}
onMounted(() => {
getTaskCount();
if(route.query){
params.value = route.query;
getDetail();
@ -78,9 +137,9 @@ onMounted(() => {
<div class="main">
<div class="tab-box">
<p class="tab" :class="{'active':params?.type==='finish'}" @click="jumpTo(0)">已审批</p>
<p class="tab" :class="{'active':params?.type==='wait'}" @click="jumpTo(1)">待审批</p>
<p class="tab" :class="{'active':params?.type==='wait'}" @click="jumpTo(1)">待审批<span v-if="taskCount>0">{{taskCount}}</span></p>
</div>
<template v-if="list.length">
<template v-if="info && info?.items && info?.items.length">
<div class="detail">
<div class="item" v-for="(item, index) in info?.items" :key="index">
<div class="row">
@ -117,14 +176,27 @@ onMounted(() => {
<div class="btns">
<p class="btn" @click="jumpTo(params?.type==='finish'?0:1)">返回列表</p>
<p class="btn" @click="jumpTo(3)">返回申请</p>
<p class="btn" v-if="params?.type==='wait'" @click="agree">同意</p>
<p class="btn" v-if="params?.type==='wait'">驳回</p>
<div class="op" v-if="
params?.type==='wait' && info?.status!=99 && params?.isMyself==='pending' &&
(info?.status==1 || info?.status==2 || info?.status==3 || info?.status==4) &&
(((info?.template_id==1 || info?.template_id==4) && (info?.current_step>=1 && info?.current_step<=3)) ||
((info?.template_id==2 || info?.template_id)==3 && (info?.current_step>=1 && info?.current_step<=4)))
">
<p class="btn" @click="agree">同意</p>
<p class="btn" @click="reject">驳回</p>
</div>
</div>
</template>
<template v-else>
<van-empty description="暂无数据" />
</template>
</div>
<!-- 驳回弹框 -->
<van-dialog v-model:show="showReject" title="驳回" show-cancel-button :before-close="rejectConfirm" @cancel="rejectConfirm">
<div style="padding: 10px 0;">
<van-field v-model="rejectComment" label="驳回理由" type="textarea" rows="1" autosize required clearable placeholder="请输入驳回理由" />
</div>
</van-dialog>
</template>
<style scoped>
@ -212,4 +284,9 @@ onMounted(() => {
border: 1px solid #eee;
border-radius: 2px;
}
.btns .op {
width: 100%;
display: flex;
gap: 12px;
}
</style>

View File

@ -16,6 +16,7 @@ const statusList = ref([
{text:'已撤回',value:98},
{text:'已驳回',value:99},
]);
const taskCount = ref(0);
const list = ref([])
//
@ -36,7 +37,7 @@ const jumpTo = (type,item) => {
if(type==='detail'){
router.push({
path: '/detail',
query: {id: item.id,type: 'wait'}
query: {id: item.id,type: 'wait',isMyself: item.type}
})
}
}
@ -60,8 +61,18 @@ const getList = async () => {
loading.value = false;
}
}
//
const getTaskCount = async () => {
try {
const res = await taskCountApi();
taskCount.value = res.data?.chain_remove?.count || 0;
} catch (error) {
}
}
onMounted(() => {
getTaskCount();
getList();
});
</script>
@ -74,7 +85,7 @@ onMounted(() => {
<div class="main">
<div class="tab-box">
<p class="tab" @click="jumpTo('finish',null)">已审批</p>
<p class="tab active">待审批</p>
<p class="tab active">待审批<span v-if="taskCount>0">{{taskCount}}</span></p>
</div>
<div class="list">
<template v-if="list.length">