于宏哲PHP 9 months ago
parent
commit
278723e0b3
  1. 12
      api/apiRoute.js
  2. 68
      pages/market/data/statistics.vue
  3. 480
      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 = {}) { async scheduleList(data = {}) {
return await http.get('/course/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);
},

68
pages/market/data/statistics.vue

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

480
pages/market/reimbursement/add.vue

@ -1,222 +1,272 @@
<template> <template>
<view class="reim-add-page"> <view class="reim-add-page">
<view class="header-bar"> <view class="header-bar">
<view class="title">{{ pageTitle }}</view> <view class="title">{{ pageTitle }}</view>
</view> </view>
<view class="form-box"> <view class="form-box">
<!-- 金额 --> <!-- 金额 -->
<view class="form-row"> <view class="form-row">
<view class="label">报销金额</view> <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"
</view> :disabled="disabled" />
<!-- 描述 --> </view>
<view class="form-row-top"> <!-- 描述 -->
<view class="label">报销描述</view> <view class="form-row-top">
<textarea class="textarea" v-model="form.description" placeholder="请输入报销事由" :disabled="disabled" /> <view class="label">报销描述</view>
</view> <textarea class="textarea" v-model="form.description" placeholder="请输入报销事由" :disabled="disabled" />
<!-- 附件 --> </view>
<view class="form-row"> <!-- 附件 -->
<view class="label">发票/收据</view> <view class="form-row">
<view class="file-upload-wrapper"> <view class="label">发票/收据</view>
<view v-if="form.receipt_url" class="preview-box" @click="previewImage"> <view class="file-upload-wrapper">
<image v-if="isImage(form.receipt_url)" :src="form.receipt_url" class="preview-img" mode="aspectFit" /> <view v-if="form.receipt_url" class="preview-box" @click="previewImage">
<view v-else class="file-link">{{ getFileName(form.receipt_url) }}</view> <image v-if="isImage(form.receipt_url)" :src="form.receipt_url" class="preview-img"
</view> mode="aspectFit" />
<button class="upload-btn" @click="chooseFile" :disabled="disabled"> <view v-else class="file-link">{{ getFileName(form.receipt_url) }}</view>
{{ form.receipt_url ? '重新选择' : '选择附件' }} </view>
</button> <button class="upload-btn" @click="chooseFile" :disabled="disabled">
</view> {{ form.receipt_url ? '重新选择' : '选择附件' }}
</view> </button>
</view> </view>
<view class="save-btn-box" v-if="!disabled"> </view>
<fui-button background="#434544" color="#24BA9F" borderColor="#24BA9F" @click="submit">提交</fui-button> </view>
</view> <view class="save-btn-box" v-if="!disabled">
</view> <fui-button background="#434544" color="#24BA9F" borderColor="#24BA9F" @click="submit">提交</fui-button>
</view>
</view>
</template> </template>
<script> <script>
export default { import apiRoute from '@/api/apiRoute.js';
data() { import {
return { Api_url
pageTitle: '新增报销', } from "@/common/config.js";
disabled: false, export default {
form: { data() {
id: null, return {
amount: '', uploadUrl: `${Api_url}/uploadImage`,
description: '', pageTitle: '新增报销',
receipt_url: '', disabled: false,
} form: {
} id: null,
}, amount: '',
onLoad(options) { description: '',
if (options.id) { receipt_url: '',
this.form.id = options.id; }
this.fetchDetail(options.id); }
} },
}, onLoad(options) {
methods: { if (options.id) {
fetchDetail(id) { this.form.id = options.id;
uni.showLoading({ title: '加载中...' }); this.fetchDetail(options.id);
setTimeout(() => { }
const mockData = { },
id: id, methods: {
amount: 120.50, async fetchDetail(id) {
description: '差旅交通费', uni.showLoading({
receipt_url: '', title: '加载中...'
status: 'pending', });
};
let res = await apiRoute.reimbursement_info({id:id})
if (mockData.status !== 'pending') { let mockData = res.data
this.disabled = true;
this.pageTitle = '查看报销'; if (mockData.status !== 'pending') {
} else { this.disabled = true;
this.pageTitle = '编辑报销'; this.pageTitle = '查看报销';
} } else {
this.pageTitle = '编辑报销';
this.form.amount = mockData.amount; }
this.form.description = `${mockData.description} (${this.disabled ? '不可编辑' : '待审批'})`;
this.form.receipt_url = mockData.receipt_url; this.form.amount = mockData.amount;
uni.hideLoading(); this.form.description = mockData.description;
}, 500); this.form.receipt_url = mockData.receipt_url;
}, uni.hideLoading();
chooseFile() { },
uni.chooseImage({ chooseFile() {
count: 1,
success: (res) => { uni.chooseImage({
this.form.receipt_url = res.tempFilePaths[0]; count: 1,
} success: (res) => {
}); const tempFilePath = res.tempFilePaths[0]
}, //
isImage(url) { this.uploadFilePromise(tempFilePath)
if (!url) return false; }
return /\.(jpg|jpeg|png|gif|bmp)$/i.test(url); })
}, },
getFileName(path) { uploadFilePromise(url) {
if (!path) return ''; let token = uni.getStorageSync('token') || ''
return path.split('/').pop(); let a = uni.uploadFile({
}, url: this.uploadUrl, //
previewImage() { filePath: url,
if (this.form.receipt_url && this.isImage(this.form.receipt_url)) { name: 'file',
uni.previewImage({ header: {
urls: [this.form.receipt_url] 'token': `${token}`, //token
}); },
} success: (e) => {
}, let res = JSON.parse(e.data.replace(/\ufeff/g, "") || "{}")
submit() {
if (!this.form.amount || !this.form.description) { if (res.code == 1) {
uni.showToast({ title: '请填写完整', icon: 'none' }); this.form.receipt_url = res.data.url
return; } else {
} uni.showToast({
title: res.msg,
if (this.form.id) { icon: 'none'
uni.showToast({ title: '修改成功(待对接接口)', icon: 'success' }); })
} else { }
uni.showToast({ title: '提交成功(待对接接口)', icon: 'success' }); },
} });
},
setTimeout(() => { isImage(url) {
uni.navigateBack(); if (!url) return false;
}, 1000); return /\.(jpg|jpeg|png|gif|bmp)$/i.test(url);
} },
} getFileName(path) {
} if (!path) return '';
return path.split('/').pop();
},
previewImage() {
if (this.form.receipt_url && this.isImage(this.form.receipt_url)) {
uni.previewImage({
urls: [this.form.receipt_url]
});
}
},
submit() {
if (!this.form.amount || !this.form.description) {
uni.showToast({
title: '请填写完整',
icon: 'none'
});
return;
}
let res = apiRoute.reimbursement_add(this.form)
if (res['code'] == 1) {
uni.showToast({
title: '提交成功',
icon: 'success'
});
}
setTimeout(() => {
uni.navigateBack();
}, 1000);
}
}
}
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.reim-add-page { .reim-add-page {
min-height: 100vh; min-height: 100vh;
background: #292929; background: #292929;
padding-bottom: 120rpx; padding-bottom: 120rpx;
} }
.header-bar {
padding: 32rpx; .header-bar {
.title { padding: 32rpx;
font-size: 44rpx;
color: #fff; .title {
font-weight: bold; font-size: 44rpx;
} color: #fff;
} font-weight: bold;
.form-box { }
margin: 0 32rpx; }
background: #434544;
border-radius: 18rpx; .form-box {
padding: 0 24rpx; margin: 0 32rpx;
} background: #434544;
.form-row, .form-row-top { border-radius: 18rpx;
display: flex; padding: 0 24rpx;
padding: 32rpx 0; }
border-bottom: 1rpx solid #3a3a3a;
&:last-of-type { .form-row,
border-bottom: none; .form-row-top {
} display: flex;
} padding: 32rpx 0;
.form-row { border-bottom: 1rpx solid #3a3a3a;
align-items: center;
} &:last-of-type {
.form-row-top { border-bottom: none;
align-items: flex-start; }
} }
.label {
color: #aaa; .form-row {
font-size: 28rpx; align-items: center;
width: 180rpx; }
flex-shrink: 0;
} .form-row-top {
.input-amount { align-items: flex-start;
flex: 1; }
color: #fff;
font-size: 28rpx; .label {
text-align: right; color: #aaa;
} font-size: 28rpx;
.textarea { width: 180rpx;
flex: 1; flex-shrink: 0;
height: 180rpx; }
color: #fff;
font-size: 28rpx; .input-amount {
background-color: transparent; flex: 1;
padding: 0; color: #fff;
width: 100%; font-size: 28rpx;
} text-align: right;
.file-upload-wrapper { }
flex: 1;
display: flex; .textarea {
justify-content: flex-end; flex: 1;
align-items: center; height: 180rpx;
gap: 20rpx; color: #fff;
} font-size: 28rpx;
.upload-btn { background-color: transparent;
background: #24BA9F; padding: 0;
color: #fff; width: 100%;
border: none; }
border-radius: 8rpx;
padding: 0 32rpx; .file-upload-wrapper {
line-height: 64rpx; flex: 1;
height: 64rpx; display: flex;
font-size: 26rpx; justify-content: flex-end;
margin: 0; align-items: center;
} gap: 20rpx;
.preview-box { }
.preview-img {
width: 120rpx; .upload-btn {
height: 120rpx; background: #24BA9F;
border-radius: 8rpx; color: #fff;
background: #222; border: none;
border: 1rpx solid #333; border-radius: 8rpx;
} padding: 0 32rpx;
.file-link { line-height: 64rpx;
color: #24BA9F; height: 64rpx;
font-size: 26rpx; font-size: 26rpx;
word-break: break-all; margin: 0;
} }
}
.save-btn-box { .preview-box {
position: fixed; .preview-img {
left: 0; width: 120rpx;
right: 0; height: 120rpx;
bottom: 0; border-radius: 8rpx;
z-index: 100; background: #222;
background: #292929; border: 1rpx solid #333;
padding: 20rpx 40rpx 40rpx 40rpx; }
box-shadow: 0 -2rpx 8rpx rgba(0,0,0,0.12);
} .file-link {
</style> color: #24BA9F;
font-size: 26rpx;
word-break: break-all;
}
}
.save-btn-box {
position: fixed;
left: 0;
right: 0;
bottom: 0;
z-index: 100;
background: #292929;
padding: 20rpx 40rpx 40rpx 40rpx;
box-shadow: 0 -2rpx 8rpx rgba(0, 0, 0, 0.12);
}
</style>

28
pages/market/reimbursement/list.vue

@ -43,27 +43,11 @@
</template> </template>
<script> <script>
import apiRoute from '@/api/apiRoute.js';
export default { export default {
data() { data() {
return { return {
list: [ 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',
},
],
statusMap: { statusMap: {
pending: '待审批', pending: '待审批',
approved: '已批准', approved: '已批准',
@ -71,7 +55,15 @@ export default {
}, },
} }
}, },
async onShow() {
await this.reimbursementList();
},
methods: { methods: {
async reimbursementList(){
let res = await apiRoute.reimbursement_list({})
this.list = res.data;
},
goAdd() { goAdd() {
uni.navigateTo({ uni.navigateTo({
url: '/pages/market/reimbursement/add' url: '/pages/market/reimbursement/add'

Loading…
Cancel
Save