xiaohaizhao 3 недель назад
Родитель
Сommit
b5403fb2a4

+ 322 - 0
CRM/myStore/create.js

@@ -0,0 +1,322 @@
+const _Http = getApp().globalData.http;
+
+Page({
+  data: {
+    loading: false,
+    disabled: true,
+    showAll: false,
+    editMode: false,
+    form: [{
+      label: "门店序号",
+      error: false,
+      errMsg: "",
+      type: "text",
+      value: "",
+      placeholder: "请输入门店序号",
+      valueName: "storeno",
+      required: true,
+      checking: "base"
+    }, {
+      label: "门店名称",
+      error: false,
+      errMsg: "",
+      type: "text",
+      value: "",
+      placeholder: "请输入门店名称",
+      valueName: "storename",
+      required: true,
+      checking: "base"
+    }, {
+      label: "门店面积",
+      error: false,
+      errMsg: "",
+      type: "number",
+      value: "",
+      placeholder: "请输入门店面积",
+      valueName: "area",
+      required: true
+    }, {
+      label: "导购人数",
+      error: false,
+      errMsg: "",
+      type: "number",
+      value: "",
+      placeholder: "请输入导购人数",
+      valueName: "salercount",
+      required: true
+    }, {
+      label: "负责人",
+      error: false,
+      errMsg: "",
+      type: "radio",
+      value: "",
+      radioList: [],
+      valueName: "leader_hrid",
+      required: true,
+      checking: "base",
+      direction: "horizontal"
+    }, {
+      label: "售前电话",
+      error: false,
+      errMsg: "",
+      type: "number",
+      value: "",
+      placeholder: "请输入售前电话",
+      valueName: "sale_phonenmber",
+      required: true
+    }, {
+      label: "售后电话",
+      error: false,
+      errMsg: "",
+      type: "number",
+      value: "",
+      placeholder: "请输入售后电话",
+      valueName: "service_phonenmber",
+      required: true
+    }, {
+      label: "装修日期",
+      error: false,
+      errMsg: "",
+      type: "date",
+      value: "",
+      placeholder: "请选择装修日期",
+      valueName: "decorationdate",
+      required: true
+    }, {
+      label: "开店日期",
+      error: false,
+      errMsg: "",
+      type: "date",
+      value: "",
+      placeholder: "请选择开店日期",
+      valueName: "opendate",
+      required: true
+    }, {
+      label: "门店地址类型",
+      error: false,
+      errMsg: "",
+      type: "radio",
+      value: "",
+      radioList: [],
+      valueName: "markettype",
+      required: true,
+      checking: "base",
+      direction: "horizontal"
+    }, {
+      label: "门店类型",
+      error: false,
+      errMsg: "",
+      type: "radio",
+      value: "",
+      radioList: [
+        { id: "自营", name: "自营" },
+        { id: "分销", name: "分销" }
+      ],
+      valueName: "storetype",
+      required: true,
+      checking: "base",
+      direction: "horizontal"
+    }, {
+      label: "省市县",
+      error: false,
+      errMsg: "",
+      type: "region",
+      value: [],
+      placeholder: "省,市,县",
+      valueName: "region",
+      required: true
+    }, {
+      label: "详细地址",
+      error: false,
+      errMsg: "",
+      type: "textarea",
+      value: "",
+      placeholder: "请输入详细地址",
+      valueName: "address",
+      required: true,
+      checking: "base"
+    }],
+    content: {
+      sa_storeid: 0
+    }
+  },
+
+  onLoad(options) {
+    if (options.edit) {
+      wx.setNavigationBarTitle({ title: '编辑门店' });
+      this.setData({ editMode: true });
+      this.loadOptions(true);
+    } else {
+      this.loadOptions(false);
+    }
+  },
+
+  /* 加载选项列表 */
+  loadOptions(edit) {
+    let count = 0;
+    const onDone = () => {
+      count++;
+      if (count === 2 && edit) {
+        this.populateEditForm();
+      }
+    };
+    this.getLeaderList(edit ? onDone : null);
+    this.getMarketTypeList(edit ? onDone : null);
+  },
+
+  /* 编辑模式:回填表单数据 */
+  populateEditForm() {
+    const data = _Http.detail;
+    let form = this.data.form;
+    form = form.map(v => {
+      switch (v.valueName) {
+        case "region":
+          v.value = data.province ? [data.province, data.city, data.county] : [];
+          break;
+        default:
+          v.value = data[v.valueName] !== undefined ? data[v.valueName] : '';
+          break;
+      }
+      return v;
+    });
+    this.setData({
+      form,
+      "content.sa_storeid": data.sa_storeid
+    });
+    this.selectComponent("#Form").confirm();
+  },
+
+  /* 获取负责人列表 */
+  getLeaderList(cb) {
+    _Http.basic({
+      id: "20221107094704",
+      content: {
+        pageNumber: 1,
+        pageSize: 99999
+      }
+    }).then(res => {
+      if (res.code == 1 && res.data && res.data.length) {
+        let form = this.data.form;
+        let leaderField = form.find(v => v.valueName === 'leader_hrid');
+        leaderField.radioList = res.data.map(item => ({
+          id: item.sys_enterprise_hrid,
+          name: item.name
+        }));
+        if (!this.data.editMode) {
+          leaderField.value = leaderField.radioList[0].id;
+        }
+        this.setData({ form });
+        this.selectComponent("#Form").confirm();
+      }
+      if (cb) cb();
+    }).catch(err => {
+      console.error('获取负责人列表失败', err);
+      if (cb) cb();
+    });
+  },
+
+  /* 获取门店地址类型列表 */
+  getMarketTypeList(cb) {
+    _Http.basic({
+      classname: "sysmanage.develop.optiontype.optiontype",
+      method: "optiontypeselect",
+      content: {
+        pageNumber: 1,
+        pageSize: 1000,
+        typename: "markettype",
+        parameter: {}
+      }
+    }).then(res => {
+      if (res.code == 1 && res.data && res.data.length) {
+        let form = this.data.form;
+        let markettypeField = form.find(v => v.valueName === 'markettype');
+        markettypeField.radioList = res.data.map(item => ({
+          id: item.value,
+          name: item.value
+        }));
+        if (!this.data.editMode) {
+          markettypeField.value = markettypeField.radioList[0].id;
+        }
+        this.setData({ form });
+        this.selectComponent("#Form").confirm();
+      }
+      if (cb) cb();
+    }).catch(err => {
+      console.error('获取门店地址类型列表失败', err);
+      if (cb) cb();
+    });
+  },
+
+  /* 表单必填项是否完成 */
+  onConfirm({ detail }) {
+    this.setData({
+      disabled: detail
+    });
+  },
+
+  /* 表单中断回调 */
+  interrupt({ detail }) {},
+
+  /* 提交表单 */
+  submit() {
+    this.setData({ loading: true });
+    let formData = this.selectComponent("#Form").submit();
+    if (!formData) {
+      this.setData({ loading: false });
+      return;
+    }
+
+    // 获取负责人姓名
+    const leaderField = this.data.form.find(v => v.valueName === 'leader_hrid');
+    const selectedLeader = leaderField.radioList.find(v => v.id == formData.leader_hrid);
+    formData.leadername = selectedLeader ? selectedLeader.name : '';
+
+    // 处理省市县数据
+    if (formData.region && formData.region.length) {
+      formData.province = formData.region[0] || "";
+      formData.city = formData.region[1] || "";
+      formData.county = formData.region[2] || "";
+      delete formData.region;
+    }
+
+    let content = {
+      ...this.data.content,
+      ...formData
+    };
+
+    _Http.basic({
+      id: '2026031010540701',
+      content
+    }).then(res => {
+      this.setData({ loading: false });
+      if (res.code == 1) {
+        const listPage = getCurrentPages().find(v => v.__route__ == 'CRM/myStore/index');
+        if (listPage) {
+          listPage.getList(true);
+        }
+        wx.navigateBack({
+          delta: 1,
+          success: () => {
+            wx.showToast({ title: this.data.editMode ? '编辑成功' : '创建成功', icon: 'none' });
+          }
+        });
+      } else {
+        wx.showToast({ title: res.msg || '操作失败', icon: 'none' });
+      }
+    }).catch(() => {
+      this.setData({ loading: false });
+      wx.showToast({ title: '操作失败', icon: 'none' });
+    });
+  },
+
+  /* 是否显示全部 */
+  onChange({ detail }) {
+    this.setData({
+      showAll: detail
+    });
+  },
+
+  closePage() {
+    wx.navigateBack({ delta: 1 });
+  }
+});

+ 8 - 0
CRM/myStore/create.json

@@ -0,0 +1,8 @@
+{
+  "usingComponents": {
+    "Yl_Field": "/components/Yl_Field/index",
+    "Yl_Headline": "/components/Yl_Headline/index",
+    "van-button": "@vant/weapp/button/index"
+  },
+  "navigationBarTitleText": "新建门店"
+}

+ 18 - 0
CRM/myStore/create.scss

@@ -0,0 +1,18 @@
+.new-footer {
+  position: fixed;
+  bottom: 0;
+  left: 0;
+  right: 0;
+  padding: 20rpx 30rpx;
+  background-color: #fff;
+  box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.1);
+  z-index: 999;
+}
+
+.new-submit {
+  width: 100% !important;
+  height: 80rpx !important;
+  line-height: 80rpx !important;
+  border-radius: 8rpx !important;
+  font-size: 32rpx !important;
+}

+ 8 - 0
CRM/myStore/create.wxml

@@ -0,0 +1,8 @@
+<view class="container">
+  <Yl_Headline title='基本信息' type='switch' switchLabel='仅显示必填信息' switch='{{showAll}}' bind:callBack='onChange' />
+  <Yl_Field id='Form' form='{{form}}' showAll='{{!showAll}}' bind:onConfirm='onConfirm' bind:interrupt="interrupt" />
+  <view style="height: 150rpx;" />
+  <view class="new-footer">
+    <van-button custom-class='new-submit' color='#3874F6' disabled='{{disabled || loading}}' loading='{{loading}}' bindtap='submit'>确定</van-button>
+  </view>
+</view>

+ 174 - 0
CRM/myStore/index.js

@@ -0,0 +1,174 @@
+const _Http = getApp().globalData.http;
+
+Page({
+  data: {
+    "id": "2026031010523201",
+    list: [],
+    content: {
+      isAll: false,
+      nocache: true,
+      pageNumber: 1,
+      pageSize: 20,
+      pageTotal: 1,
+      where: {
+        condition: ""
+      }
+    }
+  },
+  onLoad() {
+    this.getList();
+  },
+  onShow() {
+    if (this.data._loaded) {
+      this.getList(true);
+    }
+    this.setData({ _loaded: true });
+  },
+  /* 获取门店列表 */
+  getList(init = false) {
+    if (init.detail != undefined) init = init.detail;
+    if (init) {
+      this.setData({
+        'content.pageNumber': 1
+      });
+    }
+    if (this.data.content.pageNumber > this.data.content.pageTotal) return;
+    this.setListHeight();
+
+    _Http.basic({
+      id: this.data.id,
+      content: this.data.content
+    }).then(res => {
+      console.log("门店列表数据", res);
+      this.selectComponent('#ListBox').RefreshToComplete();
+      this.setData({
+        'content.pageNumber': res.pageNumber + 1,
+        'content.pageTotal': res.pageTotal,
+        list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
+        total: res.total
+      });
+    }).catch(err => {
+      console.error("获取门店列表失败", err);
+      this.selectComponent('#ListBox').RefreshToComplete();
+      wx.showToast({
+        title: '获取门店列表失败',
+        icon: 'none'
+      });
+    });
+  },
+  /* 设置页面高度 */
+  setListHeight() {
+    this.selectComponent("#ListBox").setHeight(".header", this);
+  },
+  /* 搜索 */
+  onSearch({ detail }) {
+    this.setData({
+      'content.where.condition': detail
+    });
+    this.getList(true);
+  },
+  /* 跳转到详情页 */
+  goToDetail(e) {
+    const id = e.currentTarget.dataset.id;
+    wx.navigateTo({
+      url: `./detail?id=${id}`
+    });
+  },
+  /* 跳转新建门店 */
+  goToCreate() {
+    wx.navigateTo({
+      url: '/CRM/myStore/create'
+    });
+  },
+  /* 编辑 */
+  onEdit(e) {
+    const item = e.currentTarget.dataset.item;
+    _Http.detail = item;
+    wx.navigateTo({
+      url: '/CRM/myStore/create?edit=true'
+    });
+  },
+  /* 启用申请 */
+  onApplyEnable(e) {
+    const item = e.currentTarget.dataset.item;
+    wx.showModal({
+      title: '门店启用申请',
+      content: '确定要启用该门店吗?',
+      success: (res) => {
+        if (res.confirm) {
+          _Http.basic({
+            id: '2026031011291801',
+            content: {
+              shoplistid: item.sa_storeid,
+              type: 'enable'
+            }
+          }).then(res => {
+            if (res.code == 1) {
+              wx.showToast({ title: '申请提交成功', icon: 'none' });
+              this.getList(true);
+            } else {
+              wx.showToast({ title: res.msg || '操作失败', icon: 'none' });
+            }
+          }).catch(() => {
+            wx.showToast({ title: '网络错误', icon: 'none' });
+          });
+        }
+      }
+    });
+  },
+  /* 停用申请 */
+  onApplyDisable(e) {
+    const item = e.currentTarget.dataset.item;
+    wx.showModal({
+      title: '门店停用申请',
+      content: '确定要停用该门店吗?',
+      success: (res) => {
+        if (res.confirm) {
+          _Http.basic({
+            id: '2026031011291801',
+            content: {
+              shoplistid: item.sa_storeid,
+              type: 'disable'
+            }
+          }).then(res => {
+            if (res.code == 1) {
+              wx.showToast({ title: '申请提交成功', icon: 'none' });
+              this.getList(true);
+            } else {
+              wx.showToast({ title: res.msg || '操作失败', icon: 'none' });
+            }
+          }).catch(() => {
+            wx.showToast({ title: '网络错误', icon: 'none' });
+          });
+        }
+      }
+    });
+  },
+  /* 删除 */
+  onDelete(e) {
+    const item = e.currentTarget.dataset.item;
+    wx.showModal({
+      title: '提示',
+      content: '确定要删除该门店吗?',
+      success: (res) => {
+        if (res.confirm) {
+          _Http.basic({
+            id: '2026031013094201',
+            content: {
+              sa_storeid: item.sa_storeid
+            }
+          }).then(res => {
+            if (res.code == 1) {
+              wx.showToast({ title: '删除成功', icon: 'none' });
+              this.getList(true);
+            } else {
+              wx.showToast({ title: res.msg || '操作失败', icon: 'none' });
+            }
+          }).catch(() => {
+            wx.showToast({ title: '网络错误', icon: 'none' });
+          });
+        }
+      }
+    });
+  }
+});

+ 7 - 0
CRM/myStore/index.json

@@ -0,0 +1,7 @@
+{
+  "usingComponents": {
+    "van-icon": "@vant/weapp/icon/index",
+    "van-button": "@vant/weapp/button/index"
+  },
+  "navigationBarTitleText": "门店列表"
+}

+ 180 - 0
CRM/myStore/index.scss

@@ -0,0 +1,180 @@
+.container {
+  background-color: #f5f5f5;
+  min-height: 100vh;
+}
+
+.header {
+  width: 100%;
+}
+
+.list-item {
+  margin-bottom: 24rpx;
+  border-radius: 16rpx;
+  overflow: hidden;
+  box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
+  background-color: #fff;
+}
+
+.item {
+  padding: 24rpx;
+  transition: all 0.3s ease;
+
+  &:active {
+    background-color: #f9f9f9;
+  }
+
+  .top {
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+    margin-bottom: 20rpx;
+
+    .name-row {
+      display: flex;
+      align-items: center;
+      flex: 1;
+      overflow: hidden;
+      margin-right: 16rpx;
+    }
+
+    .name {
+      font-size: 34rpx;
+      font-weight: 600;
+      color: #1a1a1a;
+      line-height: 48rpx;
+      flex-shrink: 0;
+      margin-right: 16rpx;
+    }
+
+    .storeno-tag {
+      font-size: 24rpx;
+      color: #999;
+      line-height: 40rpx;
+      overflow: hidden;
+      text-overflow: ellipsis;
+      white-space: nowrap;
+    }
+
+    .statu {
+      font-size: 24rpx;
+      padding: 6rpx 20rpx;
+      border-radius: 8rpx;
+      font-weight: 500;
+      flex-shrink: 0;
+      background-color: #fff;
+      border: 2rpx solid;
+    }
+  }
+
+  .content {
+    width: 100%;
+    margin-bottom: 8rpx;
+
+    .row {
+      display: flex;
+      margin-bottom: 14rpx;
+      flex-wrap: wrap;
+      align-items: center;
+
+      &:last-child {
+        margin-bottom: 0;
+      }
+    }
+
+    .exp {
+      flex: 1;
+      font-size: 26rpx;
+      color: #666;
+      line-height: 40rpx;
+      margin-right: 24rpx;
+
+      &.full-width {
+        flex: none;
+        width: 100%;
+        margin-right: 0;
+      }
+    }
+  }
+}
+
+/* 操作按钮区域 */
+.actions {
+  display: flex;
+  padding: 20rpx 24rpx;
+  gap: 16rpx;
+  background: linear-gradient(180deg, #fafbfc 0%, #f5f6f8 100%);
+  border-top: 1rpx solid #eef0f3;
+  flex-wrap: wrap;
+}
+
+/* 操作按钮基础样式 */
+.action-btn {
+  flex: 1;
+  min-width: 140rpx;
+  height: 76rpx;
+  border-radius: 38rpx;
+  font-size: 26rpx;
+  font-weight: 500;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  color: #fff;
+  position: relative;
+  overflow: hidden;
+  letter-spacing: 1rpx;
+  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.12);
+  transition: transform 0.15s ease, box-shadow 0.15s ease;
+
+  &:active {
+    transform: scale(0.95);
+    opacity: 0.9;
+  }
+
+  /* 编辑 */
+  &.edit {
+    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
+    box-shadow: 0 4rpx 14rpx rgba(37, 99, 235, 0.3);
+  }
+
+  /* 启用申请 */
+  &.apply-enable {
+    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
+    box-shadow: 0 4rpx 14rpx rgba(5, 150, 105, 0.3);
+  }
+
+  /* 停用申请 */
+  &.apply-disable {
+    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
+    box-shadow: 0 4rpx 14rpx rgba(217, 119, 6, 0.3);
+  }
+
+  /* 删除 */
+  &.delete {
+    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
+    box-shadow: 0 4rpx 14rpx rgba(220, 38, 38, 0.3);
+  }
+}
+
+/* 新建按钮样式 */
+.create-order-button {
+  position: fixed;
+  bottom: 0;
+  left: 0;
+  right: 0;
+  padding: 10rpx 30rpx 20rpx;
+  background-color: #fff;
+  box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.1);
+  display: flex;
+  justify-content: center;
+  z-index: 999;
+}
+
+.create-btn {
+  width: 355px;
+  height: 80rpx;
+  line-height: 80rpx;
+  border-radius: 8rpx !important;
+  font-size: 32rpx;
+  background-color: #3874F6;
+  color: #fff;
+}

+ 95 - 0
CRM/myStore/index.wxml

@@ -0,0 +1,95 @@
+<view class="container">
+  <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 wx:for="{{list}}" wx:key="sa_storeid" class="list-item">
+      <view class="item" bind:tap="goToDetail" data-id="{{item.sa_storeid}}">
+        <view class="top">
+          <view class="name-row">
+            <view class="name">{{item.storename || '--'}}</view>
+            <view class="storeno-tag">NO.{{item.storeno || '--'}}</view>
+          </view>
+          <view class="statu" style="border-color: {{set.color(item.status)}}; color: {{set.color(item.status)}};">
+            {{item.status || '--'}}
+          </view>
+        </view>
+        <view class="content">
+          <view class="row" wx:if="{{item.applystatus}}">
+            <view class="exp">申请状态:<text style="color: {{set.applyColor(item.applystatus)}};">{{item.applystatus}}</text></view>
+          </view>
+          <view class="row">
+            <view class="exp">导购人数:{{item.salercount || '0'}}</view>
+            <view class="exp">面积:{{item.area || '--'}}㎡</view>
+          </view>
+          <view class="row">
+            <view class="exp">类型:{{item.storetype || '--'}}</view>
+            <view class="exp">市场类型:{{item.markettype || '--'}}</view>
+          </view>
+          <view class="row">
+            <view class="exp">负责人:{{item.leadername || '--'}}</view>
+            <view class="exp">省市县:{{(item.province || '--') + (item.city || '--') + (item.county || '--')}}</view>
+          </view>
+          <view class="row">
+            <view class="exp full-width">地址:{{item.address || '--'}}</view>
+          </view>
+        </view>
+      </view>
+      <view class="actions">
+        <view class="action-btn edit" bind:tap="onEdit" data-item="{{item}}">
+          <van-icon name="edit" size="28rpx" color="#fff" custom-style="margin-right: 8rpx;" />
+          <text>编辑</text>
+        </view>
+        <view wx:if="{{item.status === '停用' && item.applystatus !== '启用申请'}}" class="action-btn apply-enable" bind:tap="onApplyEnable" data-item="{{item}}">
+          <van-icon name="add-o" size="28rpx" color="#fff" custom-style="margin-right: 8rpx;" />
+          <text>启用申请</text>
+        </view>
+        <view wx:if="{{item.status === '启用' && item.applystatus !== '停用申请'}}" class="action-btn apply-disable" bind:tap="onApplyDisable" data-item="{{item}}">
+          <van-icon name="close" size="28rpx" color="#fff" custom-style="margin-right: 8rpx;" />
+          <text>停用申请</text>
+        </view>
+        <view wx:if="{{item.status === '停用'}}" class="action-btn delete" bind:tap="onDelete" data-item="{{item}}">
+          <van-icon name="delete" size="28rpx" color="#fff" custom-style="margin-right: 8rpx;" />
+          <text>删除</text>
+        </view>
+      </view>
+    </view>
+    <Yl_Empty wx:if="{{list.length==0}}" />
+    <view style="height:150rpx;" />
+  </Yl_ListBox>
+  <!-- 新建按钮 -->
+  <view class="create-order-button">
+    <van-button custom-class="create-btn" color="#3874F6" bind:tap="goToCreate">新建门店</van-button>
+  </view>
+</view>
+
+<wxs module="set">
+   module.exports = {
+    color: function (statu) {
+      var color = '#999999';
+      switch (statu) {
+        case "启用":
+          color = '#52C41A';
+          break;
+        case "停用":
+          color = '#FF4D4F';
+          break;
+        case "":
+          color = '#999999';
+          break;
+      };
+      return color;
+    },
+    applyColor: function (statu) {
+      var color = '#999999';
+      switch (statu) {
+        case "启用申请":
+          color = '#FA8C16';
+          break;
+        case "停用申请":
+          color = '#FF4D4F';
+          break;
+      };
+      return color;
+    }
+  }
+</wxs>

+ 3 - 1
app.json

@@ -134,7 +134,9 @@
         "lead/modules/followRecord/create",
         "customer/modules/orderCreate/create",
         "customer/modules/orderCreate/productSelect/index",
-        "order/modules/paymentCreate/create"
+        "order/modules/paymentCreate/create",
+        "myStore/index",
+        "myStore/create"
       ]
     }
   ],

+ 5 - 0
pages/index/index.js

@@ -246,6 +246,11 @@ Page({
 					key: "wmycontract",
 					path: "/CRM/wmycontract/index",
 					icon: "work-hetong"
+				}, {
+					name: "我的门店",
+					key: "wMyStore",
+					path: "/CRM/myStore/index",
+					icon: "work-hetong"
 				}];
 
 				let crm = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ["CRM"], ["crm"]),