This commit is contained in:
quantulr
2023-09-01 17:14:27 +08:00
parent a09291a1c8
commit cf3e2db09d
27 changed files with 308 additions and 330 deletions

View File

@ -1,4 +1,7 @@
/* pages/add-affairs/add-affairs.wxss */
.t-navbar__content {
--td-navbar-bg-color: rgba(0, 0, 0, 0);
}
.add-affairs {
padding-top: 32rpx;
.add-affairs-form {

View File

@ -3,6 +3,9 @@
<wxs module="times" src="../../utils/time.wxs" />
<wxs module="dict" src="../../utils/dict.wxs" />
<wxs module="utils" src="../../utils/utils.wxs" />
<view class="block">
<t-navbar left-arrow title="添加事项" t-class="nav" t-class-title="nav-title" />
</view>
<view class="add-affairs">
<view class="add-affairs-form">
<t-input label="事项" bind:change="onChange" data-field="event" value="{{form.event}}" align="right" placeholder="请输入事项"></t-input>

View File

@ -1,4 +1,7 @@
/* pages/add-stock/add-stock.wxss */
.t-navbar__content {
--td-navbar-bg-color: rgba(0, 0, 0, 0);
}
.add-stock {
padding: 32rpx 0;
.add-stock-form {

View File

@ -2,6 +2,9 @@
<wxs module="dict" src="../../utils/dict.wxs" />
<wxs module="times" src="../../utils/time.wxs" />
<t-message id="t-message" />
<view class="block">
<t-navbar left-arrow title="添加出入库记录" t-class="nav" t-class-title="nav-title" />
</view>
<view class="add-stock">
<view class="add-stock-form">
<t-cell title="产品" note="{{dict.getDictLabel(form.productId, productOptions)}}" data-picker-key="productPickerVisible" bind:click="showPicker" arrow />

View File

@ -3,7 +3,8 @@
"t-fab": "tdesign-miniprogram/fab/fab",
"t-swipe-cell": "tdesign-miniprogram/swipe-cell/swipe-cell",
"statistics-card": "/components/statistics-card",
"t-dialog": "tdesign-miniprogram/dialog/dialog"
"t-dialog": "tdesign-miniprogram/dialog/dialog",
"load-more": "/components/load-more"
},
"enablePullDownRefresh": true
}

View File

@ -3,6 +3,9 @@ page {
padding: 32rpx 0;
background-color: #f6f6f6;
}
.t-navbar__content {
--td-navbar-bg-color: rgba(0, 0, 0, 0);
}
.home-page {
.t-fab {
z-index: 99;
@ -92,16 +95,16 @@ page {
}
.finance-list {
.left-icon {
width: 48rpx;
height: 48rpx;
width: 72rpx;
height: 72rpx;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
color: #fff;
font-size: larger;
}
.btn-wrapper {
// height: 100%;
.btn {
display: inline-flex;
justify-content: center;

View File

@ -13,6 +13,7 @@ Page({
*/
data: {
showConfirmDelete: false,
loadStatus: 1,
permissions: [],
queryParams: {
pageNum: 1,
@ -47,6 +48,7 @@ Page({
async getList() {
this.setData({
loading: true,
loadStatus: 0,
});
const { queryParams } = this.data;
try {
@ -60,6 +62,7 @@ Page({
}
this.setData({
completed,
loadStatus: completed ? 3 : 1,
total: resp.total,
list: resp.rows,
});
@ -69,6 +72,9 @@ Page({
});
}
} catch (e) {
this.setData({
loadStatus: 2,
});
console.log(e);
}
this.setData({

View File

@ -3,6 +3,9 @@
<wxs module="times" src="../../utils/time.wxs" />
<wxs module="dict" src="../../utils/dict.wxs" />
<wxs module="utils" src="../../utils/utils.wxs" />
<view class="block">
<t-navbar title="财务管理" t-class="nav" t-class-title="nav-title" />
</view>
<view class="home-page">
<t-fab wx:if="{{utils.hasPermission('finance:detail:add', permissions)}}" class="float-button" icon="add" aria-label="增加" bind:click="handleAddAffairs" />
<statistics-card statistics-data="{{statistics}}" />
@ -22,47 +25,8 @@
</view>
</t-swipe-cell>
</t-cell-group>
<load-more status="{{loadStatus}}" />
</view>
<!-- <view wx:if="{{authToken}}" class="list">
<view wx:for="{{list}}" wx:key="account" data-finance-id="{{item.financeId}}" bind:longpress="handleLongTap" data-index="{{index}}" bind:tap="handleUpdateFinance" class="{{ index === deleteIndex ? 'card shake' : 'card' }}">
<view class="field">
<view class="indicator"></view>
<view class="content">
<text class="title">事项</text>
<text class="value">{{item.event}}</text>
</view>
</view>
<view class="field">
<view class="indicator"></view>
<view class="content">
<text class="title">类别</text>
<text class="value">{{dict.getDictLabel(item.type, types)}}</text>
</view>
</view>
<view class="field">
<view class="indicator"></view>
<view class="content">
<text class="title">时间</text>
<text class="value">{{times.formatDate(item.date) || "-"}}</text>
</view>
</view>
<view class="field">
<view class="indicator"></view>
<view class="content">
<text class="title">对方账户</text>
<text class="value">{{item.oppositeCompany}}</text>
</view>
</view>
<view class="field">
<view class="indicator"></view>
<view class="content">
<text class="title">金额</text>
<text class="value">{{item.amount}}</text>
</view>
</view>
<t-icon wx:if="{{index === deleteIndex}}" name="close-circle-filled" color="red" size="56rpx" data-finance-id="{{item.financeId}}" data-index="{{index}}" catchtap="handleDeleteFinance" class="close-button"></t-icon>
</view>
</view> -->
<view wx:else class="to-login">
<t-button icon="login" theme="primary" bind:tap="toLogin">前往登录</t-button>
</view>

View File

@ -24,7 +24,9 @@
z-index: -1;
}
.avatar_login {
margin-left: 64rpx;
position: absolute;
left: 64rpx;
bottom: 140rpx;
display: flex;
align-items: center;

View File

@ -1,4 +1,5 @@
import { getInfo, login } from "../../api/login";
import { getInfo, getProfile, login } from "../../api/login";
import httpClient from "../../utils/request";
import { setToken } from "../../utils/settings";
// pages/login/login.ts
@ -9,6 +10,7 @@ Page({
data: {
authToken: null,
user: null,
profile: null,
},
loginWithWeChat(e: any) {
@ -21,10 +23,8 @@ Page({
setToken(response.token);
getInfo(response.token).then((resp: any) => {
getApp().globalData.permissions = resp.permissions;
this.setData({
user: resp.user,
});
});
this.loadProfile();
});
},
handleLogout() {
@ -34,6 +34,28 @@ Page({
getApp().globalData.permissions = undefined;
setToken(undefined);
},
loadProfile() {
getProfile().then((resp: any) => {
const { data } = resp;
let avatar;
if (data.avatar) {
if (
data.avatar.startsWith("https://") ||
data.avatar.startsWith("http://")
) {
avatar = data.avatar;
} else {
avatar = `${httpClient.baseUrl}${data.avatar}`;
}
}
this.setData({
profile: {
...data,
avatar,
},
});
});
},
/**
* 生命周期函数--监听页面加载
*/
@ -43,12 +65,7 @@ Page({
authToken,
});
if (authToken) {
getInfo(authToken).then((resp: any) => {
const { user } = resp;
this.setData({
user,
});
});
this.loadProfile();
}
},

View File

@ -6,9 +6,9 @@
<view class="login-container">
<t-image class="login-bg" width="100%" height="100%" src="/assets/login_bg.jpg" />
<view class="avatar_login">
<t-avatar icon="user" />
<t-avatar icon="user" image="{{profile.avatar}}" />
<t-button wx:if="{{!authToken}}" open-type="getPhoneNumber" bindgetphonenumber="loginWithWeChat" class="login-button" size="medium" theme="primary" variant="text">登录</t-button>
<view class="nickname" wx:else>{{user.nickname}}</view>
<view class="nickname" wx:else>{{profile.nickname}}</view>
</view>
<view class="vip-card">
<text>中科九章管理层</text>

View File

@ -1,8 +1,9 @@
{
"usingComponents": {
"t-fab": "tdesign-miniprogram/fab/fab",
"t-sticky": "tdesign-miniprogram/sticky/sticky",
"statistics-card": "/components/statistics-card"
"statistics-card": "/components/statistics-card",
"t-tag": "tdesign-miniprogram/tag/tag",
"load-more": "/components/load-more"
},
"enablePullDownRefresh": true
}

View File

@ -5,92 +5,47 @@
page {
padding-top: 32rpx;
}
.stock-stick {
.t-navbar__content {
--td-navbar-bg-color: rgba(0, 0, 0, 0);
}
.stock-tabs {
margin: 16rpx 32rpx 0;
.stock-tabs {
border-radius: 18rpx;
overflow: hidden;
}
border-radius: 18rpx;
overflow: hidden;
}
.stock-stick {
// TODO:
}
.stock-list {
padding: 16rpx 0 32rpx;
.scroll-container {
// height: calc(100vh - 96rpx - 64rpx - 64rpx);
.grid {
margin: 0 32rpx;
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 32rpx;
.card {
box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1),
0 1px 2px -1px rgb(0 0 0 / 0.1);
// position: relative;
min-height: 300rpx;
background-color: #fff;
border-radius: 18rpx;
padding: 18rpx;
.prove-pic {
width: 100%;
height: 200rpx;
.description {
view {
display: flex;
align-items: center;
}
.spec {
.divider {
margin: 0 8rpx;
}
.close-button {
position: absolute;
top: -24rpx;
right: -24rpx;
}
.fields {
margin-top: 12rpx;
.field {
margin-top: 12rpx;
display: flex;
.indicator {
margin-top: 12rpx;
height: 24rpx;
width: 8rpx;
background-color: #ea7e41;
border-radius: 50rpx;
margin-right: 12rpx;
}
.content {
display: flex;
flex-direction: column;
.title {
font-size: large;
}
.value {
margin-top: 6rpx;
font-size: small;
}
}
&:nth-of-type(1) {
.indicator {
background-color: #ea7e41;
}
}
&:nth-of-type(2) {
.indicator {
background-color: #12b3a8;
}
}
&:nth-of-type(3) {
.indicator {
background-color: #dc7d85;
}
}
&:nth-of-type(4) {
.indicator {
background-color: #e0d2fd;
}
}
&:nth-of-type(5) {
.indicator {
background-color: #dc7d85;
}
}
}
}
.date {
text {
margin-left: 12rpx;
}
}
}
.description {
// font-size: small;
}
.note.storage {
color: #38a169;
}
.note.in {
color: #38a169;
}
.note.out {
color: #dd6b20;
}
}
}

View File

@ -10,6 +10,9 @@ Page({
data: {
permissions: [],
authToken: undefined,
storageLoadingStatus: 1,
inLoadingStatus: 1,
outLoadingStatus: 1,
stockType: 0, // 库存类型
// 统计数据
statisticsData: {
@ -47,6 +50,16 @@ Page({
storageCompleted: false,
inStockCompleted: false,
outStockCompleted: false,
types: [
{
label: "入库",
value: "1",
},
{
label: "出库",
value: "2",
},
],
},
onTabsChange(e: any) {
const { value: stockType } = e.detail;
@ -91,11 +104,13 @@ Page({
if (stockType == 1) {
this.setData({
inStockLoading: true,
inLoadingStatus: 0,
});
query = inStockQuery;
} else if (stockType == 2) {
this.setData({
outStockLoading: true,
outLoadingStatus: 0,
});
query = outStockQuery;
} else {
@ -117,6 +132,7 @@ Page({
this.setData({
inStockCompleted: completed,
inLoadingStatus: completed ? 3 : 1,
// @ts-ignore
inStockList: [
...this.data.inStockList,
@ -147,6 +163,7 @@ Page({
}
this.setData({
outStockCompleted: completed,
outLoadingStatus: completed ? 3 : 1,
// @ts-ignore
outStockList: [
...this.data.outStockList,
@ -170,46 +187,77 @@ Page({
}
}
} catch (error) {
if (stockType == 1) {
this.setData({
inLoadingStatus: 2,
});
} else if (stockType == 2) {
this.setData({
outLoadingStatus: 2,
});
}
console.log(error);
}
if (this.data.stockType == 1) {
if (stockType == 1) {
this.setData({
inStockLoading: false,
});
} else if (this.data.stockType == 2) {
} else if (stockType == 2) {
this.setData({
outStockLoading: false,
});
}
},
/**
* 获取库存列表
*/
async getStorageList() {
this.setData({
storageLoading: false,
storageLoading: true,
storageLoadingStatus: 0,
});
const { storageQuery } = this.data;
try {
const resp: any = await storageList(storageQuery);
let completed = false;
if (
Math.ceil(resp.total / storageQuery.pageSize) == storageQuery.pageNum
) {
completed = true;
}
const rows = resp.rows.map((el: any) => {
const specUrls = el.specPic?.split(",") ?? [];
const specPics = specUrls.map((pic: string) => {
let url;
if (pic.startsWith("https://") || pic.startsWith("http://")) {
url = pic;
} else {
url = `${httpClient.baseUrl}${pic}`;
}
return url;
});
return {
...el,
specPics,
};
});
this.setData({
// @ts-ignore
storageList: [...this.data.storageList, ...resp.rows],
storageList: [...this.data.storageList, ...rows],
storageCompleted: completed,
storageLoadingStatus: completed ? 3 : 1,
});
if (!completed) {
this.setData({
[`storageQuery.pageNum`]: storageQuery.pageNum + 1,
});
}
} catch (error) {}
} catch (error) {
this.setData({
storageLoadingStatus: 2,
});
}
this.setData({
storageLoading: false,
});

View File

@ -3,144 +3,105 @@
<t-message id="t-message" />
<wxs module="times" src="../../utils/time.wxs" />
<wxs module="utils" src="../../utils/utils.wxs" />
<view class="block">
<t-navbar title="库存管理" t-class="nav" t-class-title="nav-title" />
</view>
<statistics-card statistics-data="{{statisticsData}}" />
<t-sticky class="stock-stick">
<view class="stock-tabs">
<t-tabs defaultValue="{{0}}" value="{{stockType}}" bind:change="onTabsChange" theme="tag">
<t-tab-panel label="库" value="{{0}}" />
<t-tab-panel label="库" value="{{1}}" />
<t-tab-panel label="出库" value="{{2}}" />
</t-tabs>
</view>
</t-sticky>
<view class="stock-tabs">
<t-tabs defaultValue="{{0}}" value="{{stockType}}" bind:change="onTabsChange" theme="tag">
<t-tab-panel label="库存" value="{{0}}" />
<t-tab-panel label="库" value="{{1}}" />
<t-tab-panel label="库" value="{{2}}" />
</t-tabs>
</view>
<view class="stock-list">
<t-fab wx:if="{{stockType > 0 && utils.hasPermission('product:product:add', permissions)}}" class="float-button" icon="add" aria-label="增加" bind:click="handleAddStock"></t-fab>
<view hidden="{{stockType!=0}}" class="scroll-container">
<view class="grid">
<view wx:for="{{storageList}}" wx:key="specId" class="card">
<view class="fields">
<view class="field">
<view class="indicator"></view>
<view class="content">
<text class="title">产品</text>
<text class="value">{{item.productName}}</text>
<t-cell-group theme="card">
<t-swipe-cell wx:for="{{storageList}}" wx:key="specId">
<t-cell data-spec-id="{{item.specId}}" hover>
<view class="left-icon" slot="left-icon">
<t-image src="{{item.specPics[0]}}" shape="round" error="slot" width="120rpx" height="120rpx">
<t-icon name="image-error" slot="error" />
</t-image>
</view>
<view slot="title" class="title">
<view>{{item.productName}}</view>
</view>
<view slot="description" class="description">
<view class="spec">
<text>{{item.modelName}}</text>
<view class="divider">|</view>
<text>{{item.specName}}</text>
</view>
</view>
<view class="field">
<view class="indicator"></view>
<view class="content">
<text class="title">型号</text>
<text class="value">{{item.modelName}}</text>
</view>
<view slot="note" class="note storage">
{{item.stock}}
</view>
<view class="field">
<view class="indicator"></view>
<view class="content">
<text class="title">规格</text>
<text class="value">{{item.specName}}</text>
</view>
</view>
<view class="field">
<view class="indicator"></view>
<view class="content">
<text class="title">库存</text>
<text class="value">{{item.stock}}</text>
</view>
</view>
</view>
</view>
</view>
</t-cell>
</t-swipe-cell>
</t-cell-group>
<load-more status="{{storageLoadingStatus}}" />
</view>
<view hidden="{{stockType!=1}}" class="scroll-container">
<view class="grid">
<view wx:for="{{inStockList}}" wx:key="logId" class="card">
<t-image class="prove-pic" mode="aspectFill" error="slot" src="{{item.provePic[0]}}">
<t-icon name="image-error" slot="error" />
</t-image>
<view class="fields">
<view class="field">
<view class="indicator"></view>
<view class="content">
<text class="title">产品</text>
<text class="value">{{item.productName}}</text>
<t-cell-group theme="card">
<t-swipe-cell wx:for="{{inStockList}}" wx:key="logId">
<t-cell data-spec-id="{{item.specId}}" hover>
<view class="left-icon" slot="left-icon">
<t-image src="{{item.provePic[0]}}" shape="round" error="slot" width="120rpx" height="120rpx">
<t-icon name="image-error" slot="error" />
</t-image>
</view>
<view slot="title" class="title">
<view>{{item.productName}}</view>
</view>
<view slot="description" class="description">
<view class="spec">
<text>{{item.modelName}}</text>
<view class="divider">|</view>
<text>{{item.specName}}</text>
</view>
<view class="date">
<t-tag theme="success" size="small">入库</t-tag> <text>{{times.formatDate(item.date) || ''}}</text>
</view>
</view>
<view class="field">
<view class="indicator"></view>
<view class="content">
<text class="title">型号</text>
<text class="value">{{item.modelName}}</text>
</view>
<view slot="note" class="note in">
{{item.total}}
</view>
<view class="field">
<view class="indicator"></view>
<view class="content">
<text class="title">规格</text>
<text class="value">{{item.specName}}</text>
</view>
</view>
<view class="field">
<view class="indicator"></view>
<view class="content">
<text class="title">数量</text>
<text class="value">{{item.total}}</text>
</view>
</view>
<view class="field">
<view class="indicator"></view>
<view class="content">
<text class="title">日期</text>
<text class="value">{{times.formatDate(item.date) || "-"}}</text>
</view>
</view>
</view>
</view>
</view>
</t-cell>
</t-swipe-cell>
</t-cell-group>
<load-more status="{{inLoadingStatus}}" />
</view>
<view hidden="{{stockType!=2}}" class="scroll-container">
<view class="grid">
<view wx:for="{{outStockList}}" wx:key="logId" class="card">
<t-image class="prove-pic" mode="aspectFill" error="slot" src="{{item.provePic[0]}}">
<t-icon name="image-error" slot="error" width="100rpx" height="100rpx" />
</t-image>
<view class="fields">
<view class="field">
<view class="indicator"></view>
<view class="content">
<text class="title">产品</text>
<text class="value">{{item.productName}}</text>
<t-cell-group theme="card">
<t-swipe-cell wx:for="{{outStockList}}" wx:key="logId">
<t-cell data-spec-id="{{item.specId}}" hover>
<view class="left-icon" slot="left-icon">
<t-image src="{{item.provePic[0]}}" shape="round" error="slot" width="120rpx" height="120rpx">
<t-icon name="image-error" slot="error" />
</t-image>
</view>
<view slot="title" class="title">
<view>{{item.productName}}</view>
</view>
<view slot="description" class="description">
<view class="spec">
<text>{{item.modelName}}</text>
<view class="divider">|</view>
<text>{{item.specName}}</text>
</view>
<view class="date">
<t-tag theme="warning" size="small">出库</t-tag> <text>{{times.formatDate(item.date) || ''}}</text>
</view>
</view>
<view class="field">
<view class="indicator"></view>
<view class="content">
<text class="title">型号</text>
<text class="value">{{item.modelName}}</text>
</view>
<view slot="note" class="note out">
{{item.total}}
</view>
<view class="field">
<view class="indicator"></view>
<view class="content">
<text class="title">规格</text>
<text class="value">{{item.specName}}</text>
</view>
</view>
<view class="field">
<view class="indicator"></view>
<view class="content">
<text class="title">数量</text>
<text class="value">{{item.total}}</text>
</view>
</view>
<view class="field">
<view class="indicator"></view>
<view class="content">
<text class="title">日期</text>
<text class="value">{{times.formatDate(item.date) || "-"}}</text>
</view>
</view>
</view>
</view>
</view>
</t-cell>
</t-swipe-cell>
</t-cell-group>
<load-more status="{{outLoadingStatus}}" />
</view>
</view>