xiaohaizhao пре 2 месеци
родитељ
комит
94c20cc721

+ 0 - 28
CRM/warehouse/detail.js

@@ -1,28 +0,0 @@
-Page({
-  data: {
-    warehouseInfo: {}
-  },
-  onLoad(options) {
-    const id = options.id;
-    this.getWarehouseDetail(id);
-  },
-  getWarehouseDetail(id) {
-    // 模拟获取仓库详情数据
-    const mockData = {
-      id: id,
-      name: `仓库${id}`,
-      location: `位置${id}`,
-      capacity: `${id}000`,
-      manager: `管理员${id}`,
-      contact: `1380013800${id}`,
-      items: [
-        { name: '商品1', quantity: 100 },
-        { name: '商品2', quantity: 200 },
-        { name: '商品3', quantity: 300 }
-      ]
-    };
-    this.setData({
-      warehouseInfo: mockData
-    });
-  }
-});

+ 0 - 4
CRM/warehouse/detail.json

@@ -1,4 +0,0 @@
-{
-  "usingComponents": {},
-  "navigationBarTitleText": "仓库详情"
-}

+ 0 - 61
CRM/warehouse/detail.scss

@@ -1,61 +0,0 @@
-.container {
-  padding: 20rpx;
-  background-color: #f5f5f5;
-  min-height: 100vh;
-}
-
-.info-item {
-  display: flex;
-  align-items: center;
-  padding: 20rpx;
-  background-color: #fff;
-  margin-bottom: 10rpx;
-  border-radius: 8rpx;
-}
-
-.label {
-  width: 160rpx;
-  font-size: 28rpx;
-  color: #666;
-}
-
-.value {
-  flex: 1;
-  font-size: 28rpx;
-  color: #333;
-}
-
-.section-title {
-  font-size: 32rpx;
-  font-weight: bold;
-  margin: 20rpx 0;
-  color: #333;
-}
-
-.item-list {
-  background-color: #fff;
-  border-radius: 8rpx;
-  padding: 20rpx;
-}
-
-.item {
-  display: flex;
-  justify-content: space-between;
-  align-items: center;
-  padding: 15rpx 0;
-  border-bottom: 1rpx solid #f0f0f0;
-}
-
-.item:last-child {
-  border-bottom: none;
-}
-
-.item-name {
-  font-size: 28rpx;
-  color: #333;
-}
-
-.item-quantity {
-  font-size: 28rpx;
-  color: #666;
-}

+ 0 - 29
CRM/warehouse/detail.wxml

@@ -1,29 +0,0 @@
-<view class="container">
-  <view class="info-item">
-    <view class="label">仓库名称</view>
-    <view class="value">{{warehouseInfo.name}}</view>
-  </view>
-  <view class="info-item">
-    <view class="label">位置</view>
-    <view class="value">{{warehouseInfo.location}}</view>
-  </view>
-  <view class="info-item">
-    <view class="label">容量</view>
-    <view class="value">{{warehouseInfo.capacity}} 件</view>
-  </view>
-  <view class="info-item">
-    <view class="label">管理员</view>
-    <view class="value">{{warehouseInfo.manager}}</view>
-  </view>
-  <view class="info-item">
-    <view class="label">联系电话</view>
-    <view class="value">{{warehouseInfo.contact}}</view>
-  </view>
-  <view class="section-title">库存商品</view>
-  <view class="item-list">
-    <view class="item" wx:for="{{warehouseInfo.items}}" wx:key="index">
-      <view class="item-name">{{item.name}}</view>
-      <view class="item-quantity">数量: {{item.quantity}}</view>
-    </view>
-  </view>
-</view>

+ 173 - 14
CRM/warehouse/index.js

@@ -1,25 +1,184 @@
+const _Http = getApp().globalData.http;
+
 Page({
   data: {
-    warehouseList: []
+    list: [],
+    loading: false,
+    showModal: false,
+    isEdit: false,
+    formData: {
+      sys_enterprise_stockid: 0,
+      stockno: '',
+      stockname: '',
+      isused: '1'
+    },
+    content: {
+      nocache: true,
+      pageNumber: 1,
+      pageSize: 20,
+      pageTotal: 1,
+      total: null
+    }
   },
   onLoad() {
-    this.getWarehouseList();
-  },
-  getWarehouseList() {
-    // 模拟获取仓库列表数据
-    const mockData = [
-      { id: 1, name: '仓库1', location: '位置1', capacity: '1000' },
-      { id: 2, name: '仓库2', location: '位置2', capacity: '2000' },
-      { id: 3, name: '仓库3', location: '位置3', capacity: '3000' }
-    ];
+    this.getList(true);
+  },
+  onSearch(e) {
+    const keyword = e.detail.value || "";
     this.setData({
-      warehouseList: mockData
+      "content.pageNumber": 1,
+      "content.where": {
+        condition: keyword
+      }
     });
+    this.getList(true);
+  },
+  getList(init) {
+    if (this.data.loading) return;
+    if (init.detail != undefined) init = init.detail;
+    let content = this.data.content;
+    if (init) {
+      content.pageNumber = 1;
+    }
+    this.setData({ loading: true });
+    _Http.basic({
+      "id": "2026031714375701",
+      content
+    }).then(res => {
+      this.setData({ loading: false });
+      console.log("仓库列表", res)
+      this.selectComponent('#ListBox').RefreshToComplete();
+      if (res.code != 1) return wx.showToast({
+        title: res.msg,
+        icon: "none"
+      })
+      this.setData({
+        list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
+        "content.pageNumber": res.pageNumber + 1,
+        "content.pageSize": res.pageSize,
+        "content.pageTotal": res.pageTotal,
+        "content.total": res.total
+      })
+    })
   },
-  goToDetail(e) {
+  deleteWarehouse(e) {
     const id = e.currentTarget.dataset.id;
-    wx.navigateTo({
-      url: `./detail?id=${id}`
+    wx.showModal({
+      title: '确认删除',
+      content: '确定要删除这个仓库吗?',
+      success: (res) => {
+        if (res.confirm) {
+          // 调用API删除仓库
+          _Http.basic({
+            "id": "2026031714454901",
+            content: {
+              sys_enterprise_stockid: id
+            }
+          }).then(res => {
+            console.log("删除仓库", res)
+            if (res.code != 1) {
+              return wx.showToast({
+                title: res.msg,
+                icon: "none"
+              });
+            }
+            
+            // 删除成功,刷新列表
+            wx.showToast({ title: '删除成功', icon: 'success' });
+            this.getList(true);
+          }).catch(() => {
+            wx.showToast({ title: '网络错误', icon: 'none' });
+          })
+        }
+      }
+    });
+  },
+  addWarehouse() {
+    // 重置表单数据
+    this.initFormData();
+    this.setData({
+      showModal: true,
+      isEdit: false
+    });
+  },
+  editWarehouse(e) {
+    const id = e.currentTarget.dataset.id;
+    // 查找要编辑的仓库数据
+    const warehouse = this.data.list.find(item => item.sys_enterprise_stockid == id);
+    if (warehouse) {
+      this.setData({
+        showModal: true,
+        isEdit: true,
+        formData: {
+          sys_enterprise_stockid: warehouse.sys_enterprise_stockid,
+          stockno: warehouse.stockno || '',
+          stockname: warehouse.stockname || '',
+          isused: warehouse.isused.toString()
+        }
+      });
+    }
+  },
+  closeModal() {
+    this.setData({ showModal: false });
+    // 关闭后初始化表单
+    this.initFormData();
+  },
+  initFormData() {
+    this.setData({
+      formData: {
+        sys_enterprise_stockid: 0,
+        stockno: '',
+        stockname: '',
+        isused: '1'
+      }
+    });
+  },
+  handleInput(e) {
+    const field = e.currentTarget.dataset.field;
+    const value = e.detail;
+    this.setData({
+      [`formData.${field}`]: value
     });
+  },
+  handleRadioChange(e) {
+    this.setData({
+      'formData.isused': e.detail
+    });
+  },
+  saveWarehouse() {
+    const { stockno, stockname } = this.data.formData;
+
+    // 验证必填字段
+    if (!stockno) {
+      return wx.showToast({ title: '请输入仓库编码', icon: 'none' });
+    }
+    if (!stockname) {
+      return wx.showToast({ title: '请输入仓库名称', icon: 'none' });
+    }
+
+    // 调用API保存仓库
+    _Http.basic({
+      "id": "2026031714422501",
+      content: {
+        ...this.data.formData,
+        isused: parseInt(this.data.formData.isused)
+      }
+    }).then(res => {
+      console.log("保存仓库", res)
+      if (res.code != 1) {
+        return wx.showToast({
+          title: res.msg,
+          icon: "none"
+        });
+      }
+
+      // 保存成功,关闭模态框并刷新列表
+      wx.showToast({ title: '保存成功', icon: 'success' });
+      this.setData({ showModal: false });
+      this.initFormData();
+      this.getList(true);
+    }).catch(() => {
+      wx.showToast({ title: '网络错误', icon: 'none' });
+    })
   }
 });

+ 3 - 2
CRM/warehouse/index.json

@@ -1,4 +1,5 @@
 {
-  "usingComponents": {},
-  "navigationBarTitleText": "仓库管理"
+  "usingComponents": {
+  },
+  "navigationBarTitleText": "仓库列表"
 }

+ 126 - 26
CRM/warehouse/index.scss

@@ -1,42 +1,142 @@
 .container {
-  padding: 10rpx;
+  background-color: #f5f5f5;
+  min-height: 100vh;
+
+  .text-red {
+    color: #ff0000;
+  }
+
+  .item {
+    background-color: #fff;
+    border-radius: 12rpx;
+    padding: 24rpx;
+    display: block;
+    width: 375px;
+    margin: 0 auto;
+    margin-bottom: 20rpx;
+
+    .top {
+      display: flex;
+      justify-content: space-between;
+      align-items: center;
+      margin-bottom: 16rpx;
+
+      .name {
+        font-size: 32rpx;
+        font-weight: bold;
+        flex: 1;
+      }
+
+      .actions {
+        display: flex;
+        gap: 12rpx;
+
+        .van-button {
+          margin: 0;
+        }
+      }
+
+      .statu {
+        font-size: 24rpx;
+        padding: 4rpx 12rpx;
+        border-radius: 8rpx;
+      }
+    }
+
+    .content {
+      .row {
+        display: flex;
+        flex-wrap: wrap;
+        margin-bottom: 12rpx;
+
+        .exp {
+          flex: 1;
+          font-size: 26rpx;
+          color: #666;
+          line-height: 1.5;
+
+          &.full-width {
+            width: 100%;
+          }
+        }
+      }
+    }
+  }
+
+  .header {
+    background-color: #f5f5f5;
+  }
+
+  .loading {
+    text-align: center;
+    color: #999;
+    padding: 20rpx 0;
+    font-size: 24rpx;
+  }
+
+  .no-more {
+    text-align: center;
+    color: #999;
+    padding: 20rpx 0;
+    font-size: 24rpx;
+  }
 }
 
-.warehouse-item {
-  display: flex;
-  align-items: center;
+.bottom-btn {
+  position: fixed;
+  bottom: 0;
+  left: 0;
+  right: 0;
   padding: 20rpx;
   background-color: #fff;
-  margin-bottom: 10rpx;
-  border-radius: 8rpx;
-  box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.1);
+  box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.1);
+  z-index: 999;
+
+  .van-button {
+    width: 100%;
+  }
 }
 
-.warehouse-name {
-  font-size: 32rpx;
-  font-weight: bold;
-  margin-bottom: 8rpx;
-  flex: 1;
+.footer {
+	display: flex;
+	justify-content: center;
+	position: fixed;
+	bottom: 0;
+	width: 100vw;
+	min-height: 130rpx;
+	background-color: #fff;
+	box-shadow: 0px -2px 6px 1px rgba(0, 0, 0, 0.16);
+
+	.but {
+		width: 690rpx;
+		height: 90rpx;
+		background: #FA8C16;
+		border-radius: 16rpx;
+		font-size: 28rpx;
+		font-weight: 600;
+		color: #FFFFFF;
+		margin-top: 10rpx;
+	}
 }
 
-.warehouse-info {
-  flex: 1;
-  margin-left: 20rpx;
+.modal-content {
+  padding: 20rpx;
 }
 
-.location {
-  font-size: 26rpx;
-  color: #666;
-  margin-bottom: 4rpx;
+.radio-group {
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  margin-top: 20rpx;
+  margin-bottom: 20rpx;
 }
 
-.capacity {
-  font-size: 26rpx;
-  color: #666;
+.radio-label {
+  margin-right: 20rpx;
+  font-size: 28rpx;
+  color: #333;
 }
 
-.arrow {
-  font-size: 32rpx;
-  color: #999;
-  margin-left: 20rpx;
+.van-radio {
+  margin-right: 32rpx;
 }

+ 51 - 6
CRM/warehouse/index.wxml

@@ -1,10 +1,55 @@
 <view class="container">
-  <view class="warehouse-item" wx:for="{{warehouseList}}" wx:key="id" bindtap="goToDetail" data-id="{{item.id}}">
-    <view class="warehouse-name">{{item.name}}</view>
-    <view class="warehouse-info">
-      <view class="location">位置: {{item.location}}</view>
-      <view class="capacity">容量: {{item.capacity}} 件</view>
+  <van-search use-action-slot placeholder='请输入搜索关键词' shape='round' bind:search="onSearch" bind:clear="onSearch" />
+  <view class="header" style="height: 20rpx;"></view>
+  <Yl_ListBox id='ListBox' bind:getlist='getList'>
+    <view class="item" wx:for="{{list}}" wx:key="sys_enterprise_stockid">
+      <view class="top">
+        <view class="name">{{item.stockname || '--'}}</view>
+        <view class="actions">
+          <van-button size="small" type="primary" bindtap="editWarehouse" data-id="{{item.sys_enterprise_stockid}}">编辑
+          </van-button>
+          <van-button size="small" type="danger" bindtap="deleteWarehouse" data-id="{{item.sys_enterprise_stockid}}" wx:if="{{item.issystem != 1}}">删除
+          </van-button>
+        </view>
+      </view>
+      <view class="content">
+        <view class="row">
+          <view class="exp">
+            仓库编码:{{item.stockno || '--'}}
+          </view>
+          <view class="exp">
+            是否启用:{{item.isused == 1 ? '是' : '否'}}
+          </view>
+        </view>
+        <view class="row">
+          <view class="exp">
+            {{item.issystem == 1 ? '系统预设' : '自建'}}
+          </view>
+        </view>
+      </view>
     </view>
-    <view class="arrow">></view>
+    <Yl_Empty wx:if="{{list.length==0}}" />
+    <view style="height:150rpx;" />
+  </Yl_ListBox>
+  <view class="footer">
+    <van-button custom-class='but' bindtap="addWarehouse">新增仓库</van-button>
   </view>
+
+  <!-- 新增/编辑仓库模态框 -->
+  <van-dialog show="{{showModal}}" title="{{isEdit ? '编辑仓库' : '新增仓库'}}" use-slot show-cancel-button
+    confirm-button-text="确定" cancel-button-text="取消" bind:confirm="saveWarehouse" bind:cancel="closeModal"
+    confirm-button-color="#3874F6" custom-style="width: 90%;">
+    <view class="modal-content">
+      <van-field value="{{formData.stockname}}" label="仓库名称" placeholder="请输入仓库名称" bind:change="handleInput"
+        data-field="stockname" required />
+      <van-field value="{{formData.stockno}}" label="仓库编码" placeholder="请输入仓库编码" bind:change="handleInput"
+        data-field="stockno" required />
+      <view class="radio-group">
+        <van-radio-group value="{{formData.isused}}" bind:change="handleRadioChange" direction="horizontal">
+          <van-radio name="1">启用</van-radio>
+          <van-radio name="0">停用</van-radio>
+        </van-radio-group>
+      </view>
+    </view>
+  </van-dialog>
 </view>

+ 5 - 2
app.json

@@ -119,7 +119,6 @@
         "order/index",
         "order/detail",
         "warehouse/index",
-        "warehouse/detail",
         "lead/index",
         "lead/detail",
         "customer/modules/order/details"
@@ -160,7 +159,11 @@
     "van-tab": "@vant/weapp/tab/index",
     "van-tabs": "@vant/weapp/tabs/index",
     "van-search": "@vant/weapp/search/index",
-    "record": "/components/record/index"
+    "record": "/components/record/index",
+    "van-dialog": "@vant/weapp/dialog/index",
+    "van-field": "@vant/weapp/field/index",
+    "van-radio-group": "@vant/weapp/radio-group/index",
+    "van-radio": "@vant/weapp/radio/index"
   },
   "window": {
     "backgroundTextStyle": "light",

+ 9 - 2
project.private.config.json

@@ -24,12 +24,19 @@
   "condition": {
     "miniprogram": {
       "list": [
+        {
+          "name": "CRM/warehouse/index",
+          "pathName": "CRM/warehouse/index",
+          "query": "",
+          "scene": null,
+          "launchMode": "default"
+        },
         {
           "name": "CRM/customer/detail",
           "pathName": "CRM/customer/detail",
           "query": "id=-12170327",
-          "scene": null,
-          "launchMode": "default"
+          "launchMode": "default",
+          "scene": null
         },
         {
           "name": "CRM/customer/detail",