于宏哲PHP 9 months ago
parent
commit
278723e0b3
  1. 12
      api/apiRoute.js
  2. 66
      pages/market/data/statistics.vue
  3. 92
      pages/market/reimbursement/add.vue
  4. 28
      pages/market/reimbursement/list.vue

12
api/apiRoute.js

@ -346,7 +346,19 @@ export default {
async scheduleList(data = {}) {
return await http.get('/course/scheduleList', data);
},
async getStaffStatistics(data = {}) {
return await http.get('/statistics/getStaffStatistics', data);
},
async reimbursement_list(data = {}) {
return await http.get('/personnel/reimbursement_list', data);
},
async reimbursement_add(data = {}) {
return await http.post('/personnel/reimbursement_add', data);
},
async reimbursement_info(data = {}) {
return await http.get('/personnel/reimbursement_info', data);
},

66
pages/market/data/statistics.vue

@ -43,14 +43,14 @@
<view class="table-container">
<view class="table-header">
<view class="th th-channel" style="width: 100px;">渠道</view>
<view class="th" v-for="(school, index) in schoolList" :key="index">{{school.name}}</view>
<view class="th" v-for="(school, index) in schoolList" :key="index">{{school.campus_name}}</view>
<view class="th th-total">渠道合计</view>
</view>
<view class="table-body">
<view class="table-row" v-for="(channel, index) in channelSchoolData" :key="index">
<view class="table-row" v-for="(channel, index) in channelList" :key="index">
<view class="td td-channel" style="width: 100px;">{{channel.name}}</view>
<view class="td" v-for="(school, sIndex) in schoolList" :key="sIndex">
{{channel.schools[school.id] || 0}}
{{channel[school.id] || 0}}
</view>
<view class="td td-total">{{channel.total}}</view>
</view>
@ -64,14 +64,14 @@
<view class="table-container">
<view class="table-header">
<view class="th th-channel" style="width: 100px;">渠道</view>
<view class="th" v-for="(staff, index) in marketStaffList" :key="index">市场{{staff.name}}</view>
<view class="th" v-for="(staff, index) in staffData" :key="index">市场{{staff.name}}</view>
<view class="th th-total">资源合计</view>
</view>
<view class="table-body">
<view class="table-row" v-for="(channel, index) in channelStaffData" :key="index">
<view class="table-row" v-for="(channel, index) in channelList" :key="index">
<view class="td td-channel" style="width: 100px;">{{channel.name}}</view>
<view class="td" v-for="(staff, sIndex) in marketStaffList" :key="sIndex">
{{channel.staffs[staff.id] || 0}}
<view class="td" v-for="(staff, sIndex) in staffData" :key="sIndex">
{{staff['channel'][channel.value] || 0}}
</view>
<view class="td td-total">{{channel.total}}</view>
</view>
@ -90,30 +90,11 @@ export default {
currentDate: this.formatDate(new Date()),
currentMonth: new Date().getMonth() + 1,
//
staffData: [
{ name: 'A', weekCount: 0, monthCount: 0, yearCount: 0 },
{ name: 'B', weekCount: 0, monthCount: 0, yearCount: 0 },
{ name: 'C', weekCount: 0, monthCount: 0, yearCount: 0 },
{ name: 'D', weekCount: 0, monthCount: 0, yearCount: 0 },
{ name: 'E', weekCount: 0, monthCount: 0, yearCount: 0 }
],
staffData: [],
//
schoolList: [
{ id: 1, name: '校区1' },
{ id: 2, name: '校区2' },
{ id: 3, name: '校区3' },
{ id: 4, name: '校区4' },
{ id: 5, name: '校区5' }
],
schoolList: [],
//
channelList: [
{ id: 1, name: '地推' },
{ id: 2, name: '转介绍' },
{ id: 3, name: '美团/大众' },
{ id: 4, name: '抖音' },
{ id: 5, name: '小红书' },
{ id: 6, name: '其他' }
],
channelList: [],
//
marketStaffList: [
{ id: 'A', name: 'A' },
@ -147,28 +128,23 @@ export default {
},
//
initData() {
async initData() {
// API
this.getStaffStatistics();
this.getChannelSchoolStatistics();
this.getChannelStaffStatistics();
await this.getStaffStatistics();
// await this.getChannelSchoolStatistics();
// this.getChannelStaffStatistics();
},
//
getStaffStatistics() {
async getStaffStatistics() {
// API
// apiRoute.getStaffStatistics({date: this.currentDate}).then(res => {})
let res = await apiRoute.getStaffStatistics({date: this.currentDate})
console.log(res.data.staffData,"================");
this.staffData = res.data.staffData
this.schoolList = res.data.schoolList
this.channelList = res.data.channelList
//
this.staffData = this.staffData.map(staff => {
const monthCount = Math.floor(Math.random() * 100);
return {
...staff,
weekCount: Math.floor(Math.random() * 30),
monthCount: monthCount,
yearCount: monthCount + Math.floor(Math.random() * 200)
}
});
},
//

92
pages/market/reimbursement/add.vue

@ -7,7 +7,8 @@
<!-- 金额 -->
<view class="form-row">
<view class="label">报销金额</view>
<input class="input-amount" type="number" v-model="form.amount" placeholder="0.00" :disabled="disabled" />
<input class="input-amount" type="number" v-model="form.amount" placeholder="0.00"
:disabled="disabled" />
</view>
<!-- 描述 -->
<view class="form-row-top">
@ -19,7 +20,8 @@
<view class="label">发票/收据</view>
<view class="file-upload-wrapper">
<view v-if="form.receipt_url" class="preview-box" @click="previewImage">
<image v-if="isImage(form.receipt_url)" :src="form.receipt_url" class="preview-img" mode="aspectFit" />
<image v-if="isImage(form.receipt_url)" :src="form.receipt_url" class="preview-img"
mode="aspectFit" />
<view v-else class="file-link">{{ getFileName(form.receipt_url) }}</view>
</view>
<button class="upload-btn" @click="chooseFile" :disabled="disabled">
@ -35,9 +37,14 @@
</template>
<script>
import apiRoute from '@/api/apiRoute.js';
import {
Api_url
} from "@/common/config.js";
export default {
data() {
return {
uploadUrl: `${Api_url}/uploadImage`,
pageTitle: '新增报销',
disabled: false,
form: {
@ -55,16 +62,13 @@ export default {
}
},
methods: {
fetchDetail(id) {
uni.showLoading({ title: '加载中...' });
setTimeout(() => {
const mockData = {
id: id,
amount: 120.50,
description: '差旅交通费',
receipt_url: '',
status: 'pending',
};
async fetchDetail(id) {
uni.showLoading({
title: '加载中...'
});
let res = await apiRoute.reimbursement_info({id:id})
let mockData = res.data
if (mockData.status !== 'pending') {
this.disabled = true;
@ -74,17 +78,42 @@ export default {
}
this.form.amount = mockData.amount;
this.form.description = `${mockData.description} (${this.disabled ? '不可编辑' : '待审批'})`;
this.form.description = mockData.description;
this.form.receipt_url = mockData.receipt_url;
uni.hideLoading();
}, 500);
},
chooseFile() {
uni.chooseImage({
count: 1,
success: (res) => {
this.form.receipt_url = res.tempFilePaths[0];
const tempFilePath = res.tempFilePaths[0]
//
this.uploadFilePromise(tempFilePath)
}
})
},
uploadFilePromise(url) {
let token = uni.getStorageSync('token') || ''
let a = uni.uploadFile({
url: this.uploadUrl, //
filePath: url,
name: 'file',
header: {
'token': `${token}`, //token
},
success: (e) => {
let res = JSON.parse(e.data.replace(/\ufeff/g, "") || "{}")
if (res.code == 1) {
this.form.receipt_url = res.data.url
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
},
});
},
isImage(url) {
@ -104,14 +133,19 @@ export default {
},
submit() {
if (!this.form.amount || !this.form.description) {
uni.showToast({ title: '请填写完整', icon: 'none' });
uni.showToast({
title: '请填写完整',
icon: 'none'
});
return;
}
let res = apiRoute.reimbursement_add(this.form)
if (this.form.id) {
uni.showToast({ title: '修改成功(待对接接口)', icon: 'success' });
} else {
uni.showToast({ title: '提交成功(待对接接口)', icon: 'success' });
if (res['code'] == 1) {
uni.showToast({
title: '提交成功',
icon: 'success'
});
}
setTimeout(() => {
@ -128,46 +162,57 @@ export default {
background: #292929;
padding-bottom: 120rpx;
}
.header-bar {
padding: 32rpx;
.title {
font-size: 44rpx;
color: #fff;
font-weight: bold;
}
}
.form-box {
margin: 0 32rpx;
background: #434544;
border-radius: 18rpx;
padding: 0 24rpx;
}
.form-row, .form-row-top {
.form-row,
.form-row-top {
display: flex;
padding: 32rpx 0;
border-bottom: 1rpx solid #3a3a3a;
&:last-of-type {
border-bottom: none;
}
}
.form-row {
align-items: center;
}
.form-row-top {
align-items: flex-start;
}
.label {
color: #aaa;
font-size: 28rpx;
width: 180rpx;
flex-shrink: 0;
}
.input-amount {
flex: 1;
color: #fff;
font-size: 28rpx;
text-align: right;
}
.textarea {
flex: 1;
height: 180rpx;
@ -177,6 +222,7 @@ export default {
padding: 0;
width: 100%;
}
.file-upload-wrapper {
flex: 1;
display: flex;
@ -184,6 +230,7 @@ export default {
align-items: center;
gap: 20rpx;
}
.upload-btn {
background: #24BA9F;
color: #fff;
@ -195,6 +242,7 @@ export default {
font-size: 26rpx;
margin: 0;
}
.preview-box {
.preview-img {
width: 120rpx;
@ -203,12 +251,14 @@ export default {
background: #222;
border: 1rpx solid #333;
}
.file-link {
color: #24BA9F;
font-size: 26rpx;
word-break: break-all;
}
}
.save-btn-box {
position: fixed;
left: 0;

28
pages/market/reimbursement/list.vue

@ -43,27 +43,11 @@
</template>
<script>
import apiRoute from '@/api/apiRoute.js';
export default {
data() {
return {
list: [
{
id: 1,
amount: 120.50,
description: '差旅交通费',
receipt_url: '',
status: 'pending',
created_at: '2024-06-01 10:00',
},
{
id: 2,
amount: 300.00,
description: '办公用品采购',
receipt_url: 'https://cdn.uviewui.com/uview/swiper/1.jpg',
status: 'approved',
created_at: '2024-06-02 09:30',
},
],
list: [],
statusMap: {
pending: '待审批',
approved: '已批准',
@ -71,7 +55,15 @@ export default {
},
}
},
async onShow() {
await this.reimbursementList();
},
methods: {
async reimbursementList(){
let res = await apiRoute.reimbursement_list({})
this.list = res.data;
},
goAdd() {
uni.navigateTo({
url: '/pages/market/reimbursement/add'

Loading…
Cancel
Save