添加组件

This commit is contained in:
zhengw
2026-01-28 16:00:56 +08:00
parent 7ff1a911dd
commit 193856ccdb
15 changed files with 259 additions and 13 deletions

View File

@@ -0,0 +1,8 @@
{
"component": true,
"usingComponents": {
"t-picker": "tdesign-miniprogram/picker/picker",
"t-picker-item": "tdesign-miniprogram/picker-item/picker-item",
"t-cell": "tdesign-miniprogram/cell/cell"
}
}

View File

@@ -0,0 +1,75 @@
import { post } from '@/utils/https';
import { getAuthInfo, toArray } from '@/utils/util';
Component({
options: { multipleSlots: true },
/**
* 组件的属性列表
*/
properties: {
value: {
type: null,
},
},
observers: {
value: function () {
this.setData({ label: this.data.listToObj[this.data.value]?.label });
},
},
/**
* 组件的初始数据
*/
data: {
visible: false,
list: [] as any[],
listToObj: {} as any,
label: '',
},
lifetimes: {
attached() {
const auth = getAuthInfo();
const SF_ERP_ACCOUNT_VIEW = auth.SF_ERP_ACCOUNT_VIEW;
post('ErpAccount/list', { state: 1 }).then((res: any) => {
let accountDefaultObj: any = {};
const list = toArray(res?.data?.list).map((el) => {
if (el.if_default == 2) {
accountDefaultObj = el;
}
const label = `${el.account_name}${
SF_ERP_ACCOUNT_VIEW ? `(余额: ${el.current_amount})` : ''
}`;
el.label = label;
this.data.listToObj[el.account_id] = el;
return {
label: label,
value: el.account_id,
};
});
if (!accountDefaultObj) {
accountDefaultObj = list[0] || {};
}
this.setData({ list: list, label: this.data.listToObj[this.data.value]?.label });
this.triggerEvent('default', accountDefaultObj);
});
},
},
/**
* 组件的方法列表
*/
methods: {
onShowPicker() {
this.setData({ visible: true });
},
onPickerCancel() {
this.setData({ visible: false });
},
onPickerConfirm(e: any) {
// console.log(e);
const item = this.data.listToObj[e.detail.value[0]];
this.triggerEvent('ok', item);
this.setData({ visible: false });
},
},
});

View File

@@ -0,0 +1,13 @@
<t-cell arrow note="{{label}}" hover bind:click="onShowPicker">
<view slot="title" class="custom-label">选择账户</view>
</t-cell>
<t-picker visible="{{visible}}" value="{{value}}" title="选择账户" cancelBtn="取消" confirmBtn="确认"
bindconfirm="onPickerConfirm" bindcancel="onPickerCancel">
<t-picker-item options="{{list}}">
<block wx:for="{{list}}" wx:key="index" wx:for-item="option">
<view wx:if="{{option.tag}}" slot="label-suffix--{{index}}" class="label-suffix">
<t-tag size="small" theme="primary">{{option.tag}}</t-tag>
</view>
</block>
</t-picker-item>
</t-picker>

View File

@@ -0,0 +1,10 @@
.custom-label {
display: inline-flex;
}
.custom-label::after {
content: '*';
color: red;
font-size: 32rpx;
margin-left: 4rpx;
}

View File

@@ -0,0 +1,8 @@
{
"component": true,
"usingComponents": {
"t-date-time-picker": "tdesign-miniprogram/date-time-picker/date-time-picker",
"t-cell": "tdesign-miniprogram/cell/cell",
"t-icon": "tdesign-miniprogram/icon/icon"
}
}

View File

@@ -0,0 +1,43 @@
Component({
options: { multipleSlots: true },
/**
* 组件的属性列表
*/
properties: {
title: null,
mode: null,
placeholder: null,
value: null,
},
/**
* 组件的初始数据
*/
data: {
visible: false,
format: {
date: 'YYYY-MM-DD',
second: 'YYYY-MM-DD HH:mm:ss',
},
now: Date.now(),
},
/**
* 组件的方法列表
*/
methods: {
showPicker() {
this.setData({ visible: true });
},
hidePicker() {
this.setData({ visible: false });
},
onConfirm(e: any) {
this.triggerEvent('confirm', { value: e.detail.value });
this.hidePicker();
},
onClear() {
this.triggerEvent('confirm', { value: '' });
},
},
});

View File

@@ -0,0 +1,10 @@
<t-cell title="{{title || ''}}" hover arrow bindtap="showPicker">
<view slot="note" style="display: flex;align-items: center;column-gap: 12rpx;">
<view>{{value || ''}}</view>
<t-icon wx:if="{{value}}" name="close-circle-filled" catch:tap="onClear"></t-icon>
</view>
</t-cell>
<!-- 年月日时分 -->
<t-date-time-picker title="{{placeholder || '选择日期'}}" visible="{{visible}}"
mode="{{mode || 'date'}}" format="{{format[mode|| 'date'] || 'YYYY-MM-DD HH:mm:ss'}}"
value="{{value || now}}" bindconfirm="onConfirm" auto-close="{{true}}" bindcancel="hidePicker" />

View File

@@ -28,8 +28,8 @@
一键登录
</t-button>
<t-checkbox borderless style="padding: 0;margin: 1em 0;" value="{{isAgree}}"
bind:change="changeAgreementCheck">
<t-checkbox borderless style="padding: 0;margin: 1em 0; background: transparent;"
value="{{isAgree}}" bind:change="changeAgreementCheck">
我已阅读并同意
</t-checkbox>
<t-link theme="primary" bindtap="navAgreement" data-type="user" style="margin-bottom: 16rpx;">

View File

@@ -0,0 +1,8 @@
{
"component": true,
"usingComponents": {
"t-cell": "tdesign-miniprogram/cell/cell",
"t-icon": "tdesign-miniprogram/icon/icon",
"popup-plugin": "/pages/components/popup-plugin/popup-plugin"
}
}

View File

@@ -0,0 +1,39 @@
import { getDataSet } from '@/utils/util';
Component({
/**
* 组件的属性列表
*/
properties: {
options: Array,
value: null,
},
/**
* 组件的初始数据
*/
data: {
visible: false,
},
/**
* 组件的方法列表
*/
methods: {
open() {
this.setData({ visible: true });
},
onClose() {
this.setData({ visible: false });
},
select(e: any) {
const dataset = getDataSet(e);
const index = dataset.index;
const item = this.data.options[index];
const order = dataset.order;
this.triggerEvent('ok', { value: item.value + ' ' + order });
this.onClose();
},
},
});

View File

@@ -0,0 +1,18 @@
<t-button bind:tap="open" size="small" variant="outline" theme="primary">
排序
<t-icon slot="suffix" name="{{ visible ? 'chevron-up' : 'chevron-down'}}" size="34rpx" />
</t-button>
<popup-plugin visible="{{ visible }}" title="排序" bind:close="onClose">
<t-cell title="{{item.label}}" wx:for="{{options}}" wx:key="value">
<view slot="note" style="display: flex;align-items: center;">
<t-button size="small" theme="primary"
variant="{{value != (item.value || '') + ' asc' ? 'outline': 'base'}}"
style="margin-right: 24rpx;" bind:tap="select" data-index="{{index}}" data-order="asc">升序
</t-button>
<t-button size="small" theme="primary" variant="outline"
variant="{{value != (item.value || '') + ' desc' ? 'outline': 'base'}}" bind:tap="select"
data-index="{{index}}" data-order="desc">降序</t-button>
</view>
</t-cell>
</popup-plugin>

View File

@@ -0,0 +1,9 @@
.sort-plugin {
display: inline-flex;
align-items: center;
height: 64rpx;
box-sizing: border-box;
border: 1rpx solid #ddd;
border-radius: 8rpx;
padding: 0 16rpx;
}

View File

@@ -4,7 +4,6 @@
"t-icon": "tdesign-miniprogram/icon/icon",
"tab-bar-plugin": "/pages/components/tab-bar-plugin/tab-bar-plugin",
"pagination-plugin": "/pages/components/pagination-plugin/pagination-plugin",
"select-plugin": "/pages/components/select-plugin/select-plugin",
"search-popup": "/pages/components/search-popup/search-popup"
}
}

View File

@@ -3,23 +3,30 @@
<t-cell-group title="企业信息">
<t-cell title="{{company_info.company_name}}" use-label-slot>
<view slot="image" style="margin-right: 12rpx;">
<t-image width="200rpx" height="200rpx" fit="cover"
src="{{host}}{{company_info.company_logo}}" />
<t-image width="200rpx" height="200rpx" mode="aspectFill"
src="{{host}}{{company_info.company_logo}}" error="slot">
<view slot="error" style="font-size: 120rpx;color: #999;line-height: 1.1;">
<block wx:if="{{company_info.company_name}}">
{{company_info.company_name[0]}}
</block>
</view>
</t-image>
</view>
<view slot="description">{{company_info.company_desc}}</view>
</t-cell>
</t-cell-group>
<!-- <block wx:if="{{company_list.length> 1}}">
<t-cell-group>
<t-cell title="切换企业" bind:tap="showPopup" is-link />
</t-cell-group>
</block> -->
<t-cell-group title="账号信息">
<t-cell>
<view slot="image" style="margin-right: 12rpx;">
<t-image width="200rpx" height="200rpx" fit="cover" src="{{host}}{{user_info.logo}}" />
<t-image width="200rpx" height="200rpx" mode="aspectFill" error="slot"
src="{{host}}{{user_info.logo}}">
<view slot="error" style="font-size: 120rpx;color: #999;line-height: 1.1;">
<block wx:if="{{user_info.login_name}}">
{{user_info.login_name[0]}}
</block>
</view>
</t-image>
</view>
<view slot="title" style="display: flex;align-items: center;flex-wrap: wrap;">
<view style="margin-right: 16rpx;">{{user_info.login_name}}</view>
@@ -32,6 +39,5 @@
</t-cell-group>
<t-cell title="退出登录" bind:tap="loginOut" hover bordered arrow />
<t-cell title="版本" note="{{version}}" hover bind:tap="txDoc" bordered arrow />
</page-plugin>
<tab-bar-plugin active="my" />