于宏哲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 = {}) { 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);
},

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

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