15 changed files with 454 additions and 253 deletions
@ -1,14 +1,37 @@ |
|||
// noinspection SpellCheckingInspection
|
|||
|
|||
import http from 'apis/axios'; |
|||
|
|||
const apiUrl = import.meta.env.VITE_API_URL; |
|||
console.log('apiUrl: ', apiUrl); |
|||
const ptccsens = `${apiUrl}/ptccsens/v1.0`; |
|||
const finance = `${ptccsens}/finance`; |
|||
const projectFinance = `${ptccsens}/projectFinance`; |
|||
|
|||
// 发起申请
|
|||
export const apply = params => http.post(`${finance}/apply`, params); |
|||
|
|||
// 审批
|
|||
export const audit = params => http.post(`${finance}/audit`, params); |
|||
|
|||
// 查询申请详情
|
|||
export const getApplyDetail = params => http.post(`${finance}/getApplyDetail`, params); |
|||
|
|||
// 通过任务id查看任务关联的财务信息
|
|||
export const getByTask = params => http.post(`${finance}/getByTask`, params); |
|||
|
|||
// 查询费用申请类型
|
|||
export const queryType = params => http.post(`${finance}/queryType`, params); |
|||
|
|||
|
|||
// 追加预算
|
|||
export const addBudget = params => http.post(`${projectFinance}/addBudget`, params); |
|||
|
|||
// 查看项目下的财务信息
|
|||
export const queryFinanceOfProject = params => http.post(`${projectFinance}/queryFinanceOfProject`, params); |
|||
|
|||
// 查看项目下的所有任务对应的财务信息
|
|||
export const financeInfo = params => http.post(`${finance}/getByTask`, params); |
|||
export const queryProjectFinance = params => http.post(`${projectFinance}/queryProjectFinance`, params); |
|||
|
|||
// 修改任务或项目的预算和奖金信息
|
|||
// export const edit = params => http.post(`${finance}/info`, params);
|
|||
export const updateFinance = params => http.post(`${projectFinance}/updateFinance`, params); |
|||
|
|||
// 查看自己需要审批的申请
|
|||
export const queryNeedCheckByMe = params => http.post(`${projectFinance}/queryNeedCheckByMe`, params); |
|||
|
@ -1,3 +1,53 @@ |
|||
<template> |
|||
<NuxtPage /> |
|||
</template> |
|||
|
|||
<script setup> |
|||
import { reactive } from 'vue'; |
|||
import { useRouter } from 'vue-router'; |
|||
import { getToken } from 'apis/index' |
|||
|
|||
const router = useRouter(); |
|||
|
|||
const user = useUser() |
|||
const userId = useUserId() |
|||
const projectId = useProjectId() |
|||
const taskId = useTaskId() |
|||
|
|||
// 获取路径上的参数 |
|||
const routeValue = router.currentRoute.value; |
|||
console.log('routeValue: ', routeValue); |
|||
userId.value = routeValue && routeValue.query && routeValue.query.userId ? routeValue.query.userId : ''; |
|||
projectId.value = routeValue && routeValue.query && routeValue.query.projectId ? routeValue.query.projectId : ''; |
|||
taskId.value = routeValue && routeValue.query && routeValue.query.id ? routeValue.query.id : ''; |
|||
|
|||
// const userString = sessionStorage.getItem('user') || null; |
|||
// if (userString) { |
|||
// const userInfo = JSON.parse(userString); |
|||
// user.value = userInfo; |
|||
// } else { |
|||
getTokenByUserId(userId.value) |
|||
// } |
|||
|
|||
/** |
|||
* 根据userId获取token级user信息 |
|||
* @param {*} param |
|||
* @param {string} userId 用户id |
|||
*/ |
|||
async function getTokenByUserId(userId) { |
|||
try { |
|||
const data = await getToken(userId); |
|||
user.value = data || null; |
|||
console.log('data: ', data); |
|||
if (data) { |
|||
sessionStorage.setItem('token', data.token); |
|||
sessionStorage.setItem('user', JSON.stringify(data)); |
|||
} else { |
|||
sessionStorage.removeItem('token'); |
|||
sessionStorage.removeItem('user'); |
|||
} |
|||
} catch (error) { |
|||
console.error('error: ', error); |
|||
} |
|||
} |
|||
</script> |
|||
|
@ -1,109 +1,127 @@ |
|||
<template> |
|||
<div> |
|||
<table class="w-full text-gray-500 mt-4 text-ms"> |
|||
<tr class="bg-gray-100"> |
|||
<td class="">任务名称</td> |
|||
<td class="">预算(元)</td> |
|||
<td class="">奖金(元)</td> |
|||
</tr> |
|||
<tr v-for="item in arrayData"> |
|||
<td>{{item.name}}</td> |
|||
<td> |
|||
<div v-if="!item.showBudgetEdit" @click="item.showBudgetEdit = true">{{item.budget}}</div> |
|||
<van-field v-else v-model="item.budget" type="number" class="input-box" @blur="item.showBudgetEdit = false" /> |
|||
</td> |
|||
<td> |
|||
<div v-if="!item.showBonusEdit" @click="item.showBonusEdit = true">{{item.bonus}}</div> |
|||
<van-field v-else v-model="item.bonus" type="number" class="input-box" @blur="item.showBonusEdit = false" /> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td>合计</td> |
|||
<td>{{sumBudget}}</td> |
|||
<td>{{sumBonus}}</td> |
|||
</tr> |
|||
</table> |
|||
<div class="w-1/2 mt-4 ml-48"> |
|||
<van-pagination v-model="currentPage" :page-count="12" mode="simple" /> |
|||
<div v-if="data.info.taskFinanceList && data.info.taskFinanceList.list && data.info.taskFinanceList.list.length"> |
|||
<table class="w-full text-gray-500 mt-4 text-ms"> |
|||
<tr class="bg-gray-100"> |
|||
<td class="name">任务名称</td> |
|||
<td class="">预算(元)</td> |
|||
<td class="">奖金(元)</td> |
|||
</tr> |
|||
<tr v-for="item in data.info.taskFinanceList.list"> |
|||
<td>{{item.name}}</td> |
|||
<td> |
|||
<div v-if="!item.showBudgetEdit" @click="item.showBudgetEdit = true">{{item.budget}}</div> |
|||
<van-field v-else v-model="item.budget" type="number" class="input-box" @change="handleUpdateFinance(item)" @blur="item.showBudgetEdit = false" /> |
|||
</td> |
|||
<td> |
|||
<div v-if="!item.showBonusEdit" @click="item.showBonusEdit = true">{{item.bonus}}</div> |
|||
<van-field v-else v-model="item.bonus" type="number" class="input-box" @change="handleUpdateFinance(item)" @blur="item.showBonusEdit = false" /> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td>合计</td> |
|||
<td>{{data.info.budget || 0}}</td> |
|||
<td>{{data.info.bonus || 0}}</td> |
|||
</tr> |
|||
</table> |
|||
<div class="w-1/2 mt-4 ml-48"> |
|||
<van-pagination v-model="data.pageNum" :items-per-page="data.pageSize" :page-count="data.pages" mode="simple" /> |
|||
</div> |
|||
</div> |
|||
<van-empty v-else description="暂无数据" /> |
|||
</div> |
|||
</template> |
|||
|
|||
<script setup> |
|||
import {ref, reactive} from'vue' |
|||
const arrayData = ref([ |
|||
{ |
|||
name:'财务条插件界面设计', |
|||
budget:1000, |
|||
bonus:0, |
|||
showBudgetEdit: false, |
|||
showBonusEdit: false, |
|||
}, |
|||
{ |
|||
name:'财务条插件界面设计', |
|||
budget:0, |
|||
bonus:0, |
|||
showBudgetEdit: false, |
|||
showBonusEdit: false, |
|||
}, |
|||
{ |
|||
name:'财务条插件界面设计', |
|||
budget:0, |
|||
bonus:0, |
|||
showBudgetEdit: false, |
|||
showBonusEdit: false, |
|||
}, |
|||
{ |
|||
name:'财务条插件界面设计', |
|||
budget:0, |
|||
bonus:200, |
|||
showBudgetEdit: false, |
|||
showBonusEdit: false, |
|||
}, |
|||
{ |
|||
name:'财务条插件界面设计', |
|||
budget:1000, |
|||
bonus:0, |
|||
showBudgetEdit: false, |
|||
showBonusEdit: false, |
|||
}, |
|||
{ |
|||
name:'财务条插件界面设计', |
|||
budget:0, |
|||
bonus:0, |
|||
showBudgetEdit: false, |
|||
showBonusEdit: false, |
|||
}, |
|||
{ |
|||
name:'财务条插件界面设计', |
|||
budget:0, |
|||
bonus:0, |
|||
showBudgetEdit: false, |
|||
showBonusEdit: false, |
|||
}, |
|||
{ |
|||
name:'财务条插件界面设计', |
|||
budget:0, |
|||
bonus:200, |
|||
showBudgetEdit: false, |
|||
showBonusEdit: false, |
|||
} |
|||
]); |
|||
const sumBudget = arrayData.value.reduce((sum, e) => sum + e.budget, 0); |
|||
const sumBonus = arrayData.value.reduce((sum, e) => sum + e.bonus, 0); |
|||
const currentPage = ref(1); |
|||
import { queryProjectFinance, updateFinance } from 'apis/finance' |
|||
import {ref, reactive, onMounted, nextTick} from'vue' |
|||
|
|||
const data = reactive({ |
|||
info: {}, |
|||
pageNum: 1, |
|||
pageSize: 10, |
|||
pages: 0 |
|||
}) |
|||
|
|||
const projectId = useProjectId() |
|||
|
|||
|
|||
/** |
|||
* 查看项目下的所有任务对应的财务信息 |
|||
* @param { |
|||
* |
|||
|
|||
|
|||
Number } pageNum |
|||
* @param { Number } pageSize |
|||
* @param { String } projectId |
|||
* @param { String } name |
|||
*/ |
|||
async function handleProjectFinance(){ |
|||
try { |
|||
const params = { |
|||
param:{ |
|||
pageNum: data.pageNum, |
|||
pageSize: data.pageSize, |
|||
projectId: projectId.value |
|||
} |
|||
} |
|||
const res = await queryProjectFinance(params) |
|||
data.info = res |
|||
data.pageNum = res.taskFinanceList && res.taskFinanceList.pageNum ? +res.taskFinanceList.pageNum : 1 |
|||
data.pageSize = res.taskFinanceList && res.taskFinanceList.pageSize ? +res.taskFinanceList.pageSize : 10 |
|||
data.pages = res.taskFinanceList && res.taskFinanceList.pages ? +res.taskFinanceList.pages : 0 |
|||
} catch (error) { |
|||
console.error('error: ', error); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 修改任务或项目的预算和奖金信息 |
|||
* @param { Number } bonus 奖金 |
|||
* @param { Number } budget 预算 |
|||
* @param { String } taskDetailId 任务详情id |
|||
* @param { String } taskFinanceId 任务财务信息id |
|||
*/ |
|||
async function handleUpdateFinance(item){ |
|||
console.log('item: ', item); |
|||
try { |
|||
const params = { |
|||
param:{ |
|||
bonus: item.bonus, |
|||
budget: item.budget, |
|||
taskDetailId: item.taskDetailId, |
|||
taskFinanceId: item.taskFinanceId, |
|||
} |
|||
} |
|||
const res = await updateFinance(params) |
|||
handleProjectFinance() |
|||
} catch (error) { |
|||
console.error('error: ', error); |
|||
} |
|||
} |
|||
|
|||
onMounted(() => { |
|||
nextTick(() => { |
|||
handleProjectFinance() |
|||
}) |
|||
}) |
|||
</script> |
|||
|
|||
<style scoped lang="less"> |
|||
td{ |
|||
border: 0.5px solid #ccc; |
|||
padding: 0.85rem; |
|||
} |
|||
table { |
|||
td { |
|||
border: 0.5px solid #ccc; |
|||
padding: 0.85rem; |
|||
width: 5.9375rem; |
|||
} |
|||
.name{ |
|||
width:50% |
|||
} |
|||
} |
|||
|
|||
.input-box{ |
|||
padding: 0!important; |
|||
border-bottom: 1px solid #ccc |
|||
padding: 0!important; |
|||
border-bottom: 1px solid #ccc |
|||
} |
|||
</style> |
|||
|
@ -0,0 +1,21 @@ |
|||
import { useState } from '#app'; |
|||
|
|||
export const useToken = () => { |
|||
return useState('token', () => ''); |
|||
}; |
|||
|
|||
export const useUserId = () => { |
|||
return useState('userId', () => ''); |
|||
}; |
|||
|
|||
export const useProjectId = () => { |
|||
return useState('projectId', () => ''); |
|||
}; |
|||
|
|||
export const useUser = () => { |
|||
return useState('user', () => null); |
|||
}; |
|||
|
|||
export const useTaskId = () => { |
|||
return useState('taskId', () => null); |
|||
}; |
@ -0,0 +1,15 @@ |
|||
{ |
|||
"$shared": { |
|||
"version": "v1", |
|||
"identifier": "wally", |
|||
"credential": "111111" |
|||
}, |
|||
"dev": { |
|||
"name": "dev", |
|||
"url": "https://test.tall.wiki/gateway" |
|||
}, |
|||
"local": { |
|||
"version": "v2", |
|||
"url": "https://test.tall.wiki/gateway" |
|||
} |
|||
} |
@ -0,0 +1,109 @@ |
|||
@localhost = http://localhost:7320/v1.0 |
|||
@localhost_tall = http://localhost:7130/v3.0 |
|||
@test_tall = http://192.168.0.99:7130/v3.0 |
|||
@test = https://test.tall.wiki/ptccsens/v1.0 |
|||
@www_tall = http://www.tall.wiki:7130/v3.0 |
|||
@www = http://www.tall.wiki/ptccsens/v1.0 |
|||
@type = content-type: application/json;charset=utf-8 |
|||
|
|||
### 登录 |
|||
# song 1218763410024566784 |
|||
# @name login |
|||
POST {{localhost_tall}}/users/signin |
|||
{{type}} |
|||
|
|||
{ |
|||
"client": 1, |
|||
"type": 3, |
|||
"data": { |
|||
"identifier": "whj", |
|||
"credential": "123456" |
|||
} |
|||
} |
|||
|
|||
### debug |
|||
GET {{test}}/debug |
|||
{{type}} |
|||
Authorization: Bearer {{login.response.body.$.data.token}} |
|||
|
|||
###查询费用申请类型 |
|||
POST {{localhost}}/finance/queryType |
|||
{{type}} |
|||
Authorization: Bearer {{login.response.body.$.data.token}} |
|||
|
|||
{ |
|||
"param":{ |
|||
"parentId":"4", |
|||
"type":2 |
|||
} |
|||
} |
|||
|
|||
###发起申请 |
|||
POST {{localhost}}/finance/apply |
|||
{{type}} |
|||
Authorization: Bearer {{login.response.body.$.data.token}} |
|||
|
|||
{ |
|||
"param":{ |
|||
|
|||
"checkerList": [ |
|||
123 |
|||
], |
|||
"invoiceList": [ |
|||
{ |
|||
"invoiceCode": "014002100112", |
|||
"invoiceNumber": "86610940", |
|||
"invoiceTime": 1643075118954, |
|||
"money": 4190, |
|||
"remark": "业务招待支出", |
|||
"taxMoney": 126, |
|||
"url": "https://alifei04.cfp.cn/creative/vcg/800/new/VCG211363439424.jpg" |
|||
} |
|||
], |
|||
"projectId": 2, |
|||
"taskDetailId": 3, |
|||
"remark": "", |
|||
"department": "视觉传达事业部", |
|||
"submitName": "黛西", |
|||
"money": 4190, |
|||
"typeId": 1, |
|||
"categoryId": 4, |
|||
"rowId": 7 |
|||
|
|||
} |
|||
} |
|||
|
|||
###查询申请详情 |
|||
POST {{localhost}}/finance/getApplyDetail |
|||
{{type}} |
|||
Authorization: Bearer {{login.response.body.$.data.token}} |
|||
|
|||
{ |
|||
"param":{ |
|||
"applyId":"1485797754654695424" |
|||
} |
|||
} |
|||
|
|||
###审批 |
|||
POST {{localhost}}/finance/audit |
|||
{{type}} |
|||
Authorization: Bearer {{login.response.body.$.data.token}} |
|||
|
|||
{ |
|||
"param":{ |
|||
"checkStatus":"2", |
|||
"financeCheckId":"1485797754923130880", |
|||
"remark":"测试" |
|||
} |
|||
} |
|||
|
|||
###通过任务id查看任务关联的财务信息 |
|||
POST {{localhost}}/finance/getByTask |
|||
{{type}} |
|||
Authorization: Bearer {{login.response.body.$.data.token}} |
|||
|
|||
{ |
|||
"param":{ |
|||
"taskDetailId":"3" |
|||
} |
|||
} |
@ -1,10 +0,0 @@ |
|||
import { createStore } from 'vuex'; |
|||
import user from './user'; |
|||
|
|||
export default createStore({ |
|||
modules: { user }, |
|||
state: {}, |
|||
getters: {}, |
|||
mutations: {}, |
|||
actions: {}, |
|||
}); |
@ -1,61 +0,0 @@ |
|||
import { getToken } from 'apis/index'; |
|||
|
|||
export default { |
|||
namespaced: true, |
|||
|
|||
state: { user: null }, |
|||
|
|||
getters: { |
|||
token({ user }) { |
|||
if (!user) return null; |
|||
return user.token; |
|||
}, |
|||
userId({ user }) { |
|||
if (!user) return null; |
|||
return user.id; |
|||
}, |
|||
account({ user }) { |
|||
if (!user) return null; |
|||
return user.account; |
|||
}, |
|||
isAdmin({ user }) { |
|||
if (!user) return false; |
|||
return user.account === 'iacdadmin'; |
|||
}, |
|||
}, |
|||
|
|||
mutations: { |
|||
/** |
|||
* 设置state.user |
|||
* @param {*} state |
|||
* @param {object|null} user 用户信息 |
|||
*/ |
|||
setUser(state, user) { |
|||
state.user = user; |
|||
if (user) { |
|||
sessionStorage.setItem('token', user.token); |
|||
sessionStorage.setItem('user', JSON.stringify(user)); |
|||
} else { |
|||
sessionStorage.removeItem('token'); |
|||
sessionStorage.removeItem('user'); |
|||
} |
|||
}, |
|||
}, |
|||
|
|||
actions: { |
|||
/** |
|||
* 根据userId获取token级user信息 |
|||
* @param {*} param0 |
|||
* @param {string} userId 用户id |
|||
*/ |
|||
async getTokenByUserId({ commit }, userId) { |
|||
try { |
|||
const data = await getToken(userId); |
|||
commit('setUser', data || null); |
|||
return data; |
|||
} catch (error) { |
|||
throw new Error(error); |
|||
} |
|||
}, |
|||
}, |
|||
}; |
Loading…
Reference in new issue