添加组件及页面

This commit is contained in:
zhengw
2026-02-04 17:07:30 +08:00
parent e10c7bc537
commit 62039e3684
20 changed files with 756 additions and 55 deletions

View File

@@ -0,0 +1,16 @@
{
"usingComponents": {
"search-popup": "/pages/components/search-popup/search-popup",
"card-plugin": "/pages/components/card-plugin/card-plugin",
"card-item-plugin": "/pages/components/card-item-plugin/card-item-plugin",
"option-cell-plugin": "/pages/components/option-cell-plugin/option-cell-plugin",
"date-picker-plugin": "/pages/components/date-picker-plugin/date-picker-plugin",
"sort-plugin": "/pages/components/sort-plugin/sort-plugin",
"count-plugin": "/pages/components/count-plugin/count-plugin",
"total-bar-plugin": "/pages/components/total-bar-plugin/total-bar-plugin",
"pagination-plugin": "/pages/components/pagination-plugin/pagination-plugin",
"search-input": "/pages/components/search-input/search-input",
"select-plugin": "/pages/components/select-plugin/select-plugin"
},
"navigationBarTitleText": "商品信息"
}

View File

@@ -0,0 +1,166 @@
import { loginStatus, post } from '@/utils/https';
import { cloneLite, getAuthInfo, getDataSet, toArray, toNumber } from '@/utils/util';
const defaultParams = { curr_page: 1, page_count: 20 };
Page({
/**
* 页面的初始数据
*/
data: {
params: cloneLite(defaultParams) as any,
list: [] as any[],
count: 0,
sort: [{ label: '创建日期', value: 'create_date' }],
depots: [] as any[],
goodsClass: [] as any[],
},
handleLogin(e: any) {
this.setData({ isLogin: e.detail });
if (e.detail) {
this.init();
}
},
init() {
this.setData({ authInfo: getAuthInfo() });
this.getList();
this.getData();
},
searchChange(e: any) {
const key = getDataSet(e).key;
this.data.params[key] = e.detail.value;
this.setData({ params: this.data.params });
},
searchChange2(e: any) {
const key = getDataSet(e).key;
const val = `${e.detail.value || ''}`.trim();
if (val) {
this.data.params[key] = val;
} else {
delete this.data.params[key];
}
this.setData({ params: this.data.params });
},
onOptionChange(e: any) {
const key = getDataSet(e).key;
this.data.params[key] = e.detail.value;
this.setData({ params: this.data.params });
},
datePickerConfirm(e: any) {
const data = getDataSet(e);
this.data.params[data.key] = e.detail.value;
this.setData({ params: this.data.params });
},
searchOk() {
this.getList(1);
},
searchReset() {
this.data.params = cloneLite(defaultParams);
this.getList(1);
},
onSort(e: any) {
this.data.params.order = e.detail.value;
this.setData({ params: this.data.params });
this.getList(1);
},
paginationChange(e: any) {
this.getList(e.detail.curr_page);
},
getData() {
post('ErpDepot/list').then((res: any) => {
const depots = toArray(res.data?.list).map((el) => {
return { label: el.depot_name, value: el.depot_id };
});
this.setData({ depots });
});
post('GoodsCategory/list').then((res: any) => {
const goodsClass = toArray(res.data?.list).map((el) => {
return { label: el.cate_name, value: el.cate_id };
});
this.setData({ goodsClass });
});
},
getList(curr: number = 1) {
this.data.params.curr_page = curr;
this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params);
if (!temp.depot_id) {
delete temp.depot_id;
}
if (!temp.goods_class) {
delete temp.goods_class;
}
post('ErpGoods/list', temp).then((res: any) => {
const list = toArray(res.data);
if (list.length == 0 && this.data.params.curr_page > 1) {
this.getList(this.data.params.curr_page - 1);
}
this.setData({
count: toNumber(res.count),
list: list,
});
});
},
onDetail(e: any) {
const data = getDataSet(e);
const index = data.index;
const item = this.data.list[index];
wx.navigateTo({
url: `/pages/other/goodsDetail/goodsDetail?goods_id=${
item.goods_id
}&title=${encodeURIComponent(item.goods_name)}`,
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(_options) {
this.setData({ loading: true });
loginStatus()
.then(() => {
this.setData({ isLogin: true, loading: false });
this.init();
})
.catch((err) => {
this.setData({ isLogin: false, loading: false });
console.log('调用登录状态请求失败', err);
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow() {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {},
});

View File

@@ -0,0 +1,50 @@
<page-plugin isAuth="{{authInfo['SF_ERP_GOODS_VIEW']}}" loading="{{loading}}" is-login="{{isLogin}}"
bind:handleLogin="handleLogin">
<search-popup placeholder="输入商品名称" bind:change="searchChange" bind:ok="searchOk"
bind:reset="searchReset" value="{{params.goods_name}}" data-key="goods_name">
<view slot="content">
<search-input label="商品编码" value="{{params.goods_code}}" data-key="goods_code"
bind:change="searchChange2" />
<search-input label="助记码" value="{{params.sku_alias}}" data-key="sku_alias"
bind:change="searchChange2" />
<!-- <option-cell-plugin title="订单阶段" value="{{params.order_step}}" bind:change="onOptionChange"
mode="checkbox" options="{{orderStep}}" data-key="order_step" /> -->
<select-plugin title="仓库" options="{{depots}}" value="{{params.depot_id}}"
bind:change="onOptionChange" data-key="depot_id" />
<select-plugin title="商品分类" options="{{goodsClass}}" value="{{params.goods_class}}"
bind:change="onOptionChange" data-key="goods_class" />
<date-picker-plugin title="创建开始日期" value="{{params.create_dateL}}" data-key="create_dateL"
bind:confirm="datePickerConfirm" />
<date-picker-plugin title="创建结束日期" value="{{params.create_dateU}}" data-key="create_dateU"
bind:confirm="datePickerConfirm" />
</view>
</search-popup>
<count-plugin count="{{count}}">
<!-- <sort-plugin options="{{sort}}" bind:ok="onSort" value="{{params.order}}" slot="right" /> -->
</count-plugin>
<empty-plugin wx:if="{{list.length == 0}}" />
<card-plugin wx:for="{{ list }}" wx:key="goods_id">
<view slot="header">{{ item.goods_name }}</view>
<view slot="content">
<card-item-plugin label="商品别名" value="{{item.goods_alias}}" />
<card-item-plugin label="商品类别" value="{{item.cate_name}}" />
<card-item-plugin label="商品编码" value="{{item.goods_code}}" />
<card-item-plugin label="采购价格" value="{{item.purchase_price}}" />
<card-item-plugin label="零售价格" value="{{item.commodity_price}}" />
<card-item-plugin label="销售价格" value="{{item.wholesale_price}}" />
<card-item-plugin label="单位" value="{{item.unit_ch_name}}" />
<card-item-plugin label="仓库" value="{{item.depot_name}}" />
<card-item-plugin label="供应商" value="{{item.crm_name}}" />
<card-item-plugin label="备注" value="{{item.comments}}" />
<card-item-plugin label="创建日期" value="{{item.create_date}}" />
</view>
<view slot="footer" class="card-plugin-footer">
<t-button size="small" theme="primary" bind:tap="onDetail" data-index="{{index}}">子商品
</t-button>
</view>
</card-plugin>
<pagination-plugin curr_page="{{params.curr_page}}" page_count="{{params.page_count}}"
total="{{count}}" bind:change="paginationChange" />
</page-plugin>

View File