diff --git a/components.d.json b/components.d.json index 9478e09..a49cf09 100644 --- a/components.d.json +++ b/components.d.json @@ -79,6 +79,7 @@ "description": "卡片组件", "attributes": { "customStyle": { "type": "String" }, + "showAll": { "type": "Boolean" }, "className": { "type": "String" }, "headerStyle": { "type": "String" }, "contentStyle": { "type": "String" } @@ -160,7 +161,8 @@ "select-plugin": { "description": "选择组件", "attributes": { - "mode": { "type": "String", "values": [ "single", "multiple" ] }, + "title": { "type": "String" }, + "value": { "type": "any" }, "options": { "type": "array" }, "bind:change": { "type": "Event" } } diff --git a/miniprogram/app.json b/miniprogram/app.json index 7d402f7..9253fe3 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -28,6 +28,9 @@ "pages/logs/operateLog/operateLog", "pages/manage/staff/staff", "pages/other/transfer/transfer", + "pages/other/goods/goods", + "pages/other/goodsDetail/goodsDetail", + "pages/other/batch/batch", "pages/base/viewAttachment/viewAttachment", "pages/other/outbound/outbound" ], diff --git a/miniprogram/assets/icons/商品信息.svg b/miniprogram/assets/icons/商品信息.svg new file mode 100644 index 0000000..563bbbf --- /dev/null +++ b/miniprogram/assets/icons/商品信息.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/miniprogram/assets/icons/批次信息.svg b/miniprogram/assets/icons/批次信息.svg new file mode 100644 index 0000000..f1e406f --- /dev/null +++ b/miniprogram/assets/icons/批次信息.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/miniprogram/pages/components/select-plugin/select-plugin.json b/miniprogram/pages/components/select-plugin/select-plugin.json index bebedff..65e0afb 100644 --- a/miniprogram/pages/components/select-plugin/select-plugin.json +++ b/miniprogram/pages/components/select-plugin/select-plugin.json @@ -1,11 +1,10 @@ { "component": true, "usingComponents": { - "popup-plugin": "/pages/components/popup-plugin/popup-plugin", - "t-radio-group": "tdesign-miniprogram/radio-group/radio-group", - "t-radio": "tdesign-miniprogram/radio/radio", - "t-checkbox": "tdesign-miniprogram/checkbox/checkbox", - "t-checkbox-group": "tdesign-miniprogram/checkbox-group/checkbox-group" + "t-picker": "tdesign-miniprogram/picker/picker", + "t-picker-item": "tdesign-miniprogram/picker-item/picker-item", + "t-cell": "tdesign-miniprogram/cell/cell", + "t-icon": "tdesign-miniprogram/icon/icon" } } diff --git a/miniprogram/pages/components/select-plugin/select-plugin.ts b/miniprogram/pages/components/select-plugin/select-plugin.ts index 3f54d10..c523d19 100644 --- a/miniprogram/pages/components/select-plugin/select-plugin.ts +++ b/miniprogram/pages/components/select-plugin/select-plugin.ts @@ -1,21 +1,19 @@ +import { toArray } from '@/utils/util'; + Component({ options: { multipleSlots: true }, /** * 组件的属性列表 */ properties: { - mode: { type: String, value: "single" }, - title: { type: String, value: "请选择" }, - options: { type: Array, value: [] }, - value: { type: null, value: [] }, + title: null, + options: null, + value: null, }, observers: { - "value,mode": function (v, m) { - if (m == "multiple") { - this.setData({ val: Array.isArray(v) ? [...v] : [] }); - } else { - this.setData({ val: v }); - } + value: function (value) { + const data = toArray(this.data.options).find((el) => el.value == value); + this.setData({ note: data?.label || '' }); }, }, @@ -23,31 +21,27 @@ Component({ * 组件的初始数据 */ data: { - visible: false, - val: [] as any[] | string | number, + show: false, + note: '', }, /** * 组件的方法列表 */ methods: { - click() { - this.setData({ visible: true }); + onOpenPicker() { + this.setData({ show: true }); }, - close() { - this.setData({ visible: false }); + onPickerCancel() { + this.setData({ show: false }); }, - radioChange(e: any) { - this.triggerEvent("change", { value: e.detail.value }); - this.setData({ val: e.detail.value, visible: false }); + onConfirm(e: any) { + this.triggerEvent('change', { value: e.detail.value?.[0] }); + this.onPickerCancel(); }, - checkboxChange(e: any) { - this.setData({ val: e.detail.value }); - }, - ok() { - this.setData({ visible: false }); - this.triggerEvent("change", { value: this.data.val }); + onClear() { + this.triggerEvent('change', { value: '' }); + this.onPickerCancel(); }, }, }); - diff --git a/miniprogram/pages/components/select-plugin/select-plugin.wxml b/miniprogram/pages/components/select-plugin/select-plugin.wxml index 26b2790..7c95bb8 100644 --- a/miniprogram/pages/components/select-plugin/select-plugin.wxml +++ b/miniprogram/pages/components/select-plugin/select-plugin.wxml @@ -1,24 +1,15 @@ - - - - - - - - - - {{item.label}} - - - - {{item.label}} - - + + + {{note || ''}} + + {{placeholder || title}} - - 确定 - - \ No newline at end of file + + + + + {{item.label}} + + + \ No newline at end of file diff --git a/miniprogram/pages/other/batch/batch.json b/miniprogram/pages/other/batch/batch.json new file mode 100644 index 0000000..6625f5c --- /dev/null +++ b/miniprogram/pages/other/batch/batch.json @@ -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", + "select-plugin": "/pages/components/select-plugin/select-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" + }, + "navigationBarTitleText": "批次信息" +} \ No newline at end of file diff --git a/miniprogram/pages/other/batch/batch.ts b/miniprogram/pages/other/batch/batch.ts new file mode 100644 index 0000000..e465034 --- /dev/null +++ b/miniprogram/pages/other/batch/batch.ts @@ -0,0 +1,171 @@ +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[], + crms: [] as any[], + depotsObj: {} as any, + crmObj: {} 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/ajaxDepotList').then((res: any) => { + const depots = toArray(res.data).map((el) => { + this.data.depotsObj[el.depot_id] = el.depot_name; + return { label: el.depot_name, value: el.depot_id }; + }); + this.setData({ + depots, + depotsObj: this.data.depotsObj, + }); + }); + post('ErpCrm/ajaxList', { crm_type: 2 }).then((res: any) => { + const crms = toArray(res.data?.list).map((el) => { + this.data.crmObj[el.crm_id] = el.crm_name; + return { label: el.crm_name, value: el.crm_id }; + }); + this.setData({ + crms, + crmObj: this.data.crmObj, + }); + }); + }, + getList(curr: number = 1) { + this.data.params.curr_page = curr; + this.setData({ params: this.data.params }); + const temp = cloneLite(this.data.params); + + post('GoodsBatch/goodsBatchList', 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) {}, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() {}, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + 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); + }); + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() {}, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() {}, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() {}, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() {}, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() {}, +}); diff --git a/miniprogram/pages/other/batch/batch.wxml b/miniprogram/pages/other/batch/batch.wxml new file mode 100644 index 0000000..bb140a4 --- /dev/null +++ b/miniprogram/pages/other/batch/batch.wxml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + {{ item.batch_no }} + + + + + + + + + + + + + + + 子商品 + + + + + \ No newline at end of file diff --git a/miniprogram/pages/other/batch/batch.wxss b/miniprogram/pages/other/batch/batch.wxss new file mode 100644 index 0000000..e69de29 diff --git a/miniprogram/pages/other/goods/goods.json b/miniprogram/pages/other/goods/goods.json new file mode 100644 index 0000000..78d4e54 --- /dev/null +++ b/miniprogram/pages/other/goods/goods.json @@ -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": "商品信息" +} \ No newline at end of file diff --git a/miniprogram/pages/other/goods/goods.ts b/miniprogram/pages/other/goods/goods.ts new file mode 100644 index 0000000..1d35c26 --- /dev/null +++ b/miniprogram/pages/other/goods/goods.ts @@ -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() {}, +}); diff --git a/miniprogram/pages/other/goods/goods.wxml b/miniprogram/pages/other/goods/goods.wxml new file mode 100644 index 0000000..a584d3a --- /dev/null +++ b/miniprogram/pages/other/goods/goods.wxml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + {{ item.goods_name }} + + + + + + + + + + + + + + + 子商品 + + + + + \ No newline at end of file diff --git a/miniprogram/pages/other/goods/goods.wxss b/miniprogram/pages/other/goods/goods.wxss new file mode 100644 index 0000000..e69de29 diff --git a/miniprogram/pages/other/goodsDetail/goodsDetail.json b/miniprogram/pages/other/goodsDetail/goodsDetail.json new file mode 100644 index 0000000..c252222 --- /dev/null +++ b/miniprogram/pages/other/goodsDetail/goodsDetail.json @@ -0,0 +1,15 @@ +{ + "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" + }, + "navigationBarTitleText": "商品详情" +} \ No newline at end of file diff --git a/miniprogram/pages/other/goodsDetail/goodsDetail.ts b/miniprogram/pages/other/goodsDetail/goodsDetail.ts new file mode 100644 index 0000000..1976f97 --- /dev/null +++ b/miniprogram/pages/other/goodsDetail/goodsDetail.ts @@ -0,0 +1,173 @@ +import { loginStatus, post } from '@/utils/https'; +import { + cloneLite, + getAuthInfo, + getDataSet, + showModal, + sleep, + toArray, + toastSuccess, +} from '@/utils/util'; + +const defaultParams = { curr_page: 1, page_count: 20 }; + +Page({ + /** + * 页面的初始数据 + */ + data: { + params: cloneLite(defaultParams) as any, + list: [] as any[], + count: 0, + goods_id: '', + sort: [], + goodsSubAttr: {} as any, + }, + handleLogin(e: any) { + this.setData({ isLogin: e.detail }); + if (e.detail) { + this.init(); + } + }, + init() { + this.setData({ authInfo: getAuthInfo() }); + + this.getGoodsAttr(); + }, + 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(); + }, + searchReset() { + this.data.params = cloneLite(defaultParams); + this.getList(); + }, + onSort(e: any) { + this.data.params.order = e.detail.value; + this.setData({ params: this.data.params }); + this.getList(); + }, + getGoodsAttr() { + post('GoodsAttr/list').then((res: any) => { + this.data.goodsSubAttr = {}; + toArray(res?.data?.list).forEach((el) => { + toArray(el.sub_attr).forEach((ell) => { + this.data.goodsSubAttr[ell.attr_id] = { + ...ell, + p_attr_name: el.attr_name, + }; + }); + }); + // console.log(this.data.goodsSubAttr); + this.setData({ goodsSubAttr: this.data.goodsSubAttr }); + this.getList(); + }); + }, + getList() { + post('ErpGoods/getSkuPrice', { goods_id: this.data.goods_id }).then((res: any) => { + const list = toArray(res.data).map((el) => { + el.attr_id_arr = `${el.attr_id || ''}`.split(','); + el.attr_name_arr = `${el.attr_name || ''}`.split(','); + return el; + }); + + // console.log(list); + this.setData({ list }); + }); + }, + + onOrderDel(e: any) { + const data = getDataSet(e); + const index = data.index; + const item = this.data.list[index]; + showModal({ content: `确认删除 ${item.order_no} 订单?` }).then(() => { + post('Orders/delSaleOrders', { order_no: JSON.stringify([item.order_no]) }).then(() => { + toastSuccess('删除成功'); + sleep(() => { + this.getList(); + }, 1000); + }); + }); + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + const { goods_id = '', title } = options; + + this.data.goods_id = goods_id; + if (title) { + wx.setNavigationBarTitle({ title: decodeURIComponent(title) }); + } + 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() {}, +}); diff --git a/miniprogram/pages/other/goodsDetail/goodsDetail.wxml b/miniprogram/pages/other/goodsDetail/goodsDetail.wxml new file mode 100644 index 0000000..cce94ff --- /dev/null +++ b/miniprogram/pages/other/goodsDetail/goodsDetail.wxml @@ -0,0 +1,40 @@ + + + + + + {{ item.sku_code }} + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/miniprogram/pages/other/goodsDetail/goodsDetail.wxss b/miniprogram/pages/other/goodsDetail/goodsDetail.wxss new file mode 100644 index 0000000..e69de29 diff --git a/miniprogram/utils/menuConfig.ts b/miniprogram/utils/menuConfig.ts index 9e4a0ea..c8d4309 100644 --- a/miniprogram/utils/menuConfig.ts +++ b/miniprogram/utils/menuConfig.ts @@ -74,6 +74,16 @@ export const menuConfig = [ icon: 'home', iconColor: iconColor, children: [ + { + title: '商品信息', + url: '/pages/other/goods/goods', + auth: 'SF_ERP_GOODS_VIEW', + }, + { + title: '批次信息', + url: '/pages/other/batch/batch', + auth: 'SF_ERP_GOODS_BATCH_VIEW', + }, { title: '原料出库', url: '/pages/other/outbound/outbound',