xiaohaizhao пре 1 месец
родитељ
комит
dd1a794296

+ 123 - 89
CRM/contract/create.js

@@ -1,125 +1,159 @@
+const _Http = getApp().globalData.http;
+
 Page({
   data: {
-    year: '',
-    taskname: '',
-    templateName: '',
-    remarks: '',
-    selectedTemplateId: '',
-    showYearPicker: false,
-    showTemplatePicker: false,
-    yearColumns: [],
-    templateList: [],
-    loading: false
+    loading: false,
+    disabled: true,
+    showAll: false,
+    form: [{
+      label: "年度",
+      error: false,
+      errMsg: "",
+      type: "selector",
+      value: "",
+      placeholder: "请选择年份",
+      valueName: "year",
+      required: true,
+      range: [],
+      rangeKey: "name",
+      rangeIndex: 0
+    }, {
+      label: "任务名称",
+      error: false,
+      errMsg: "",
+      type: "text",
+      value: "",
+      placeholder: "请输入任务名称",
+      valueName: "taskname",
+      required: true,
+      checking: "base"
+    }, {
+      label: "合同模版",
+      error: false,
+      errMsg: "",
+      type: "radio",
+      value: "",
+      radioList: [],
+      valueName: "sa_esign_contract_templateid",
+      required: true,
+      checking: "base",
+      direction: "horizontal"
+    }, {
+      label: "备注",
+      error: false,
+      errMsg: "",
+      type: "textarea",
+      value: "",
+      placeholder: "请输入备注信息",
+      valueName: "remarks",
+      required: false,
+      checking: "base"
+    }],
+    content: {
+      sa_esign_contract_taskid: 0
+    }
   },
 
-  onLoad() {
-    const currentYear = new Date().getFullYear();
-    this.setData({ year: currentYear.toString() });
-    this.generateYearColumns();
-    this.loadTemplates();
+  onLoad(options) {
+    this.getYearList();
+    this.getTemplateList();
   },
 
-  generateYearColumns() {
+  /* 生成年份列表 */
+  getYearList() {
     const currentYear = new Date().getFullYear();
     const years = [];
     for (let i = currentYear - 5; i <= currentYear + 5; i++) {
-      years.push(i.toString());
+      years.push({ id: i.toString(), name: i.toString() });
     }
-    this.setData({ yearColumns: years });
+    let form = this.data.form;
+    let yearField = form.find(v => v.valueName === 'year');
+    yearField.range = years;
+    yearField.rangeIndex = 5;
+    yearField.value = currentYear.toString();
+    this.setData({ form });
   },
 
-  loadTemplates() {
-    getApp().globalData.http.basic({
-      id: '2026041309474202',
+  /* 获取合同模版列表 */
+  getTemplateList() {
+    _Http.basic({
+      id: '2026042013062102',
       content: {
         pageNumber: 1,
         pageSize: 100
       }
     }).then(res => {
-      if (res.msg === '成功') {
-        this.setData({ templateList: res.data || [] });
-      } else {
-        wx.showToast({ title: res.msg || '加载合同模版失败', icon: 'none' });
+      if (res.code == 1 && res.data && res.data.length) {
+        let form = this.data.form;
+        let templateField = form.find(v => v.valueName === 'sa_esign_contract_templateid');
+        templateField.radioList = res.data.map(item => ({
+          id: item.sa_esign_contract_templateid,
+          name: item.name
+        }));
+        templateField.value = res.data[0].sa_esign_contract_templateid;
+        this.setData({ form });
+        this.selectComponent("#Form").confirm();
       }
-    }).catch(() => {
-      wx.showToast({ title: '加载合同模版失败', icon: 'none' });
     });
   },
 
-  selectYear() {
-    this.setData({ showYearPicker: true });
-  },
-
-  closeYearPicker() {
-    this.setData({ showYearPicker: false });
-  },
-
-  onYearConfirm(e) {
-    this.setData({ year: e.detail.value[0] });
-    this.closeYearPicker();
-  },
-
-  selectTemplate() {
-    this.setData({ showTemplatePicker: true });
-  },
-
-  closeTemplatePicker() {
-    this.setData({ showTemplatePicker: false });
-  },
-
-  selectTemplateItem(e) {
-    const { id, name } = e.currentTarget.dataset;
-    this.setData({ selectedTemplateId: id, templateName: name });
-  },
-
-  onTemplateConfirm() {
-    this.closeTemplatePicker();
-  },
-
-  onTasknameChange(e) {
-    this.setData({ taskname: e.detail });
+  /* 表单必填项是否完成 */
+  onConfirm({ detail }) {
+    this.setData({
+      disabled: detail
+    });
   },
 
-  onRemarksChange(e) {
-    this.setData({ remarks: e.detail });
+  /* 表单中断回调 */
+  interrupt({ detail }) {
+    // 处理条件变化
   },
 
-  submitForm() {
-    if (!this.data.year) {
-      wx.showToast({ title: '请选择年度', icon: 'none' });
-      return;
-    }
-    if (!this.data.taskname) {
-      wx.showToast({ title: '请输入任务名称', icon: 'none' });
-      return;
-    }
-    if (!this.data.selectedTemplateId) {
-      wx.showToast({ title: '请选择合同模版', icon: 'none' });
+  /* 提交表单 */
+  submit() {
+    this.setData({ loading: true });
+    let formData = this.selectComponent("#Form").submit();
+    if (!formData) {
+      this.setData({ loading: false });
       return;
     }
-
-    this.setData({ loading: true });
-    getApp().globalData.http.basic({
+    let content = {
+      ...this.data.content,
+      ...formData
+    };
+    _Http.basic({
       id: '2026041309401702',
-      content: {
-        taskname: this.data.taskname,
-        year: this.data.year,
-        remarks: this.data.remarks,
-        sa_esign_contract_templateid: this.data.selectedTemplateId
-      }
+      content
     }).then(res => {
-      if (res.msg === '成功') {
-        wx.showToast({ title: '创建成功', icon: 'success' });
-        setTimeout(() => {
-          wx.navigateBack();
-        }, 1500);
+      this.setData({ loading: false });
+      if (res.code == 1) {
+        const listPage = getCurrentPages().find(v => v.__route__ == 'CRM/contract/index');
+        if (listPage) {
+          listPage.getList(true);
+        }
+        wx.redirectTo({
+          url: '/CRM/contract/detail?id=' + res.data.sa_esign_contract_taskid,
+          success: () => {
+            wx.showToast({ title: '创建成功', icon: 'none' });
+          }
+        });
       } else {
         wx.showToast({ title: res.msg || '创建失败', icon: 'none' });
       }
     }).catch(() => {
-      wx.showToast({ title: '创建失败', icon: 'none' });
-    }).finally(() => {
       this.setData({ loading: false });
+      wx.showToast({ title: '创建失败', icon: 'none' });
     });
+  },
+
+  /* 是否显示全部 */
+  onChange({ detail }) {
+    this.setData({
+      showAll: detail
+    });
+  },
+
+  closePage() {
+    wx.navigateBack({ delta: 1 });
   }
-});
+});

+ 6 - 8
CRM/contract/create.json

@@ -1,10 +1,8 @@
 {
   "usingComponents": {
-    "Yl_HeadNav": "/components/Yl_HeadNav/index",
-    "van-field": "@vant/weapp/field/index",
-    "van-button": "@vant/weapp/button/index",
-    "van-popup": "@vant/weapp/popup/index",
-    "van-picker": "@vant/weapp/picker/index",
-    "van-icon": "@vant/weapp/icon/index"
-  }
-}
+    "Yl_Field": "/components/Yl_Field/index",
+    "Yl_Headline": "/components/Yl_Headline/index",
+    "van-button": "@vant/weapp/button/index"
+  },
+  "navigationBarTitleText": "新建合同任务"
+}

+ 15 - 48
CRM/contract/create.scss

@@ -1,51 +1,18 @@
-.container {
-  min-height: 100vh;
-  background-color: #f5f5f5;
+.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;
 }
 
-.content {
-  padding: 20rpx;
+.new-submit {
+  width: 100% !important;
+  height: 80rpx !important;
+  line-height: 80rpx !important;
+  border-radius: 8rpx !important;
+  font-size: 32rpx !important;
 }
-
-.submit-button {
-  margin-top: 30rpx;
-  border-radius: 8rpx;
-  font-size: 32rpx;
-}
-
-.picker-header {
-  display: flex;
-  justify-content: space-between;
-  align-items: center;
-  padding: 20rpx;
-  border-bottom: 1rpx solid #eee;
-  .cancel,
-  .confirm {
-    font-size: 28rpx;
-    color: #666;
-  }
-  .title {
-    font-size: 32rpx;
-    font-weight: bold;
-    color: #333;
-  }
-  .confirm {
-    color: #085CDF;
-  }
-}
-
-.template-list {
-  max-height: 600rpx;
-  overflow-y: auto;
-  .template-item {
-    display: flex;
-    justify-content: space-between;
-    align-items: center;
-    padding: 20rpx;
-    border-bottom: 1rpx solid #eee;
-    .template-name {
-      font-size: 28rpx;
-      color: #333;
-    }
-  }
-}

+ 6 - 71
CRM/contract/create.wxml

@@ -1,73 +1,8 @@
 <view class="container">
-  <Yl_HeadNav title="新建合同任务" showBack="true" />
-  <view class="content">
-    <view class="form">
-      <van-field
-        label="年度"
-        value="{{ year }}"
-        placeholder="请选择年份"
-        bind:tap="selectYear"
-        readonly
-        required
-      />
-      <van-field
-        label="任务名称"
-        value="{{ taskname }}"
-        placeholder="请输入任务名称"
-        bind:change="onTasknameChange"
-        required
-      />
-      <van-field
-        label="合同模版"
-        value="{{ templateName }}"
-        placeholder="请选择合同模版"
-        bind:tap="selectTemplate"
-        readonly
-        required
-      />
-      <van-field
-        label="备注"
-        value="{{ remarks }}"
-        placeholder="请输入备注"
-        bind:change="onRemarksChange"
-        type="textarea"
-      />
-    </view>
-    <van-button
-      type="primary"
-      class="submit-button"
-      bindtap="submitForm"
-      loading="{{ loading }}"
-    >提交</van-button>
+  <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>
-  <van-popup
-    show="{{ showYearPicker }}"
-    position="bottom"
-    bind:close="closeYearPicker"
-  >
-    <van-picker
-      columns="{{ yearColumns }}"
-      bind:confirm="onYearConfirm"
-      bind:cancel="closeYearPicker"
-    />
-  </van-popup>
-  <van-popup
-    show="{{ showTemplatePicker }}"
-    position="bottom"
-    bind:close="closeTemplatePicker"
-  >
-    <view class="picker-header">
-      <text class="cancel" bindtap="closeTemplatePicker">取消</text>
-      <text class="title">选择合同模版</text>
-      <text class="confirm" bindtap="onTemplateConfirm">确定</text>
-    </view>
-    <view class="template-list">
-      <block wx:for="{{ templateList }}" wx:key="id">
-        <view class="template-item" bindtap="selectTemplateItem" data-id="{{ item.id }}" data-name="{{ item.name }}">
-          <view class="template-name">{{ item.name }}</view>
-          <van-icon wx:if="{{ selectedTemplateId === item.id }}" name="success" color="#67C23A" />
-        </view>
-      </block>
-    </view>
-  </van-popup>
-</view>
+</view>

+ 273 - 101
CRM/contract/detail.js

@@ -1,15 +1,20 @@
+const _Http = getApp().globalData.http;
+
 Page({
   data: {
     taskId: '',
     detail: {},
     list: [],
-    showAddDistributor: false,
+    tabbarList: [],
     showEditTerm: false,
-    distributorList: [],
-    selectedDistributors: [],
     beginDate: '',
     endDate: '',
-    currentDetailId: ''
+    currentDetailId: '',
+    showEditAmount: false,
+    editS1: '',
+    editS2: '',
+    editS3: '',
+    editS4: ''
   },
 
   onLoad(options) {
@@ -19,53 +24,82 @@ Page({
   },
 
   loadTaskDetail() {
-    getApp().globalData.http.basic({
+    _Http.basic({
       id: '2026041309443002',
       content: {
         sa_esign_contract_taskid: this.data.taskId
       }
     }).then(res => {
       if (res.msg === '成功') {
-        this.setData({ detail: res.data || {} });
+        const detail = res.data || {};
+        this.setData({
+          detail
+        });
+        this.generateTabbarList(detail);
       } else {
-        wx.showToast({ title: res.msg || '加载详情失败', icon: 'none' });
+        wx.showToast({
+          title: res.msg || '加载详情失败',
+          icon: 'none'
+        });
       }
     }).catch(() => {
-      wx.showToast({ title: '加载详情失败', icon: 'none' });
+      wx.showToast({
+        title: '加载详情失败',
+        icon: 'none'
+      });
     });
   },
 
-  loadDetailList() {
-    getApp().globalData.http.basic({
-      id: '2026041315403802',
-      content: {
-        sa_esign_contract_taskid: this.data.taskId,
-        pageNumber: 1,
-        pageSize: 100
-      }
-    }).then(res => {
-      if (res.msg === '成功') {
-        this.setData({ list: res.data || [] });
-      } else {
-        wx.showToast({ title: res.msg || '加载明细失败', icon: 'none' });
-      }
-    }).catch(() => {
-      wx.showToast({ title: '加载明细失败', icon: 'none' });
-    });
-  },
+  // 生成底部操作按钮
+  generateTabbarList(detail) {
+    const tabbarList = [];
 
-  addDistributor() {
-    this.loadDistributorList();
-    this.setData({ showAddDistributor: true, selectedDistributors: [] });
+    if (detail.status === '新建' || detail.status === '撤回') {
+      tabbarList.push({
+        icon: "icon-tabkaipiaoxinxi",
+        label: "发布任务"
+      });
+    }
+
+    if (detail.status === '发布') {
+      tabbarList.push({
+        icon: "icon-tabxiangxixinxi1",
+        label: "撤回任务"
+      });
+    }
+
+    if (detail.status !== '发布') {
+      tabbarList.push({
+        icon: "icon-tabchanpin",
+        label: "添加经销商"
+      });
+    }
+
+    this.setData({
+      tabbarList
+    });
   },
 
-  closeAddDistributor() {
-    this.setData({ showAddDistributor: false });
+  // 底部按钮点击事件
+  tabbarOnClick(e) {
+    switch (e.detail.label) {
+      case '发布任务':
+        this.publishTask();
+        break;
+      case '撤回任务':
+        this.withdrawTask();
+        break;
+      case '添加经销商':
+        this.addDistributor();
+        break;
+      default:
+        break;
+    }
   },
 
-  loadDistributorList() {
-    getApp().globalData.http.basic({
-      id: '2026041315545602',
+  loadDetailList() {
+    _Http.basic({
+      id: '2026041315403802',
       content: {
         sa_esign_contract_taskid: this.data.taskId,
         pageNumber: 1,
@@ -73,134 +107,263 @@ Page({
       }
     }).then(res => {
       if (res.msg === '成功') {
-        this.setData({ distributorList: res.data || [] });
+        this.setData({
+          list: res.data || []
+        });
       } else {
-        wx.showToast({ title: res.msg || '加载经销商列表失败', icon: 'none' });
+        wx.showToast({
+          title: res.msg || '加载明细失败',
+          icon: 'none'
+        });
       }
     }).catch(() => {
-      wx.showToast({ title: '加载经销商列表失败', icon: 'none' });
+      wx.showToast({
+        title: '加载明细失败',
+        icon: 'none'
+      });
     });
   },
 
-  selectDistributor(e) {
-    const distributorId = e.currentTarget.dataset.id;
-    let selectedDistributors = this.data.selectedDistributors;
-    if (selectedDistributors.includes(distributorId)) {
-      selectedDistributors = selectedDistributors.filter(id => id !== distributorId);
-    } else {
-      selectedDistributors.push(distributorId);
-    }
-    this.setData({ selectedDistributors });
+  addDistributor() {
+    getApp().globalData.handleSelect = (res) => {
+      if (!res.result || res.result.length === 0) return;
+      _Http.basic({
+        id: '2026041315394702',
+        content: {
+          sa_esign_contract_taskid: this.data.taskId,
+          sa_agentsids: res.result
+        }
+      }).then(res => {
+        if (res.msg === '成功') {
+          setTimeout(() => {
+            wx.showToast({ title: '添加成功', icon: 'success' });
+          }, 300);
+          this.loadDetailList();
+        } else {
+          wx.showToast({
+            title: res.msg || '添加失败',
+            icon: 'none'
+          });
+        }
+      }).catch(() => {
+        wx.showToast({
+          title: '添加失败',
+          icon: 'none'
+        });
+      });
+    };
+    const params = {
+      "id": "2026041315545602",
+      "content": {
+        "sa_esign_contract_taskid": this.data.taskId,
+        "pageNumber": 1,
+        "pageSize": 20,
+        "pageTotal": 1,
+        "where": {
+          "condition": ""
+        }
+      }
+    };
+    wx.navigateTo({
+      url: '/select/agent/index?idname=sa_agentsid&showName=enterprisename&params=' + JSON.stringify(params)
+    });
   },
 
-  confirmAddDistributor() {
-    if (this.data.selectedDistributors.length === 0) {
-      wx.showToast({ title: '请选择经销商', icon: 'none' });
+  publishTask() {
+    if (!this.data.list || this.data.list.length === 0) {
+      wx.showToast({
+        title: '请先添加经销商明细',
+        icon: 'none'
+      });
       return;
     }
-
-    getApp().globalData.http.basic({
-      id: '2026041315394702',
-      content: {
-        sa_esign_contract_taskid: this.data.taskId,
-        sa_agentsids: this.data.selectedDistributors
-      }
-    }).then(res => {
-      if (res.msg === '成功') {
-        wx.showToast({ title: '添加成功', icon: 'success' });
-        this.closeAddDistributor();
-        this.loadDetailList();
-      } else {
-        wx.showToast({ title: res.msg || '添加失败', icon: 'none' });
+    wx.showModal({
+      title: '确认发布',
+      content: '确定要发布此合同任务吗?',
+      confirmColor: '#52C41A',
+      success: (res) => {
+        if (res.confirm) {
+          this.doPublishTask();
+        }
       }
-    }).catch(() => {
-      wx.showToast({ title: '添加失败', icon: 'none' });
     });
   },
 
-  publishTask() {
-    getApp().globalData.http.basic({
+  doPublishTask() {
+    _Http.basic({
       id: '2026041309482202',
       content: {
         sa_esign_contract_taskid: this.data.taskId
       }
     }).then(res => {
       if (res.msg === '成功') {
-        wx.showToast({ title: '发布成功', icon: 'success' });
+        wx.showToast({
+          title: '发布成功',
+          icon: 'success'
+        });
         this.loadTaskDetail();
+        this.loadDetailList();
       } else {
-        wx.showToast({ title: res.msg || '发布失败', icon: 'none' });
+        wx.showToast({
+          title: res.msg || '发布失败',
+          icon: 'none'
+        });
       }
     }).catch(() => {
-      wx.showToast({ title: '发布失败', icon: 'none' });
+      wx.showToast({
+        title: '发布失败',
+        icon: 'none'
+      });
     });
   },
 
   withdrawTask() {
-    getApp().globalData.http.basic({
+    wx.showModal({
+      title: '确认撤回',
+      content: '确定要撤回此合同任务吗?',
+      confirmColor: '#FA8C16',
+      success: (res) => {
+        if (res.confirm) {
+          this.doWithdrawTask();
+        }
+      }
+    });
+  },
+
+  doWithdrawTask() {
+    _Http.basic({
       id: '2026041309485902',
       content: {
         sa_esign_contract_taskid: this.data.taskId
       }
     }).then(res => {
       if (res.msg === '成功') {
-        wx.showToast({ title: '撤回成功', icon: 'success' });
+        wx.showToast({
+          title: '撤回成功',
+          icon: 'success'
+        });
         this.loadTaskDetail();
+        this.loadDetailList();
       } else {
-        wx.showToast({ title: res.msg || '撤回失败', icon: 'none' });
+        wx.showToast({
+          title: res.msg || '撤回失败',
+          icon: 'none'
+        });
       }
     }).catch(() => {
-      wx.showToast({ title: '撤回失败', icon: 'none' });
+      wx.showToast({
+        title: '撤回失败',
+        icon: 'none'
+      });
     });
   },
 
   editTerm(e) {
-    const detailId = e.currentTarget.dataset.id;
-    this.setData({ showEditTerm: true, currentDetailId: detailId, beginDate: '', endDate: '' });
+    const dataset = e.currentTarget.dataset;
+    this.setData({
+      showEditTerm: true,
+      currentDetailId: dataset.id,
+      beginDate: dataset.begin || '',
+      endDate: dataset.end || ''
+    });
   },
 
   closeEditTerm() {
-    this.setData({ showEditTerm: false });
+    this.setData({
+      showEditTerm: false
+    });
   },
 
-  selectBeginDate() {
-    wx.datePicker({
-      start: '2020-01-01',
-      end: '2030-12-31',
-      success: (res) => {
-        this.setData({ beginDate: res.value });
-      }
+  onBeginDateChange(e) {
+    this.setData({
+      beginDate: e.detail.value
     });
   },
 
-  selectEndDate() {
-    wx.datePicker({
-      start: '2020-01-01',
-      end: '2030-12-31',
-      success: (res) => {
-        this.setData({ endDate: res.value });
-      }
+  onEndDateChange(e) {
+    this.setData({
+      endDate: e.detail.value
     });
   },
 
   confirmEditTerm() {
     if (!this.data.beginDate || !this.data.endDate) {
-      wx.showToast({ title: '请选择日期', icon: 'none' });
+      wx.showToast({
+        title: '请选择日期',
+        icon: 'none'
+      });
       return;
     }
 
-    getApp().globalData.http.basic({
+    _Http.basic({
       id: '2026041415245302',
       content: {
-        sa_esign_contract_taskmxids: [this.data.currentDetailId],
-        begindate: this.data.beginDate,
-        enddate: this.data.endDate
+        items: [{
+          sa_esign_contract_taskmxid: this.data.currentDetailId,
+          begindate: this.data.beginDate,
+          enddate: this.data.endDate
+        }]
       }
     }).then(res => {
       if (res.msg === '成功') {
-        wx.showToast({ title: '修改成功', icon: 'success' });
+        wx.showToast({
+          title: '修改成功',
+          icon: 'success'
+        });
         this.closeEditTerm();
         this.loadDetailList();
+      } else {
+        wx.showToast({
+          title: res.msg || '修改失败',
+          icon: 'none'
+        });
+      }
+    }).catch(() => {
+      wx.showToast({
+        title: '修改失败',
+        icon: 'none'
+      });
+    });
+  },
+
+  editAmount(e) {
+    const dataset = e.currentTarget.dataset;
+    this.setData({
+      showEditAmount: true,
+      currentDetailId: dataset.id,
+      editS1: dataset.s1 || '',
+      editS2: dataset.s2 || '',
+      editS3: dataset.s3 || '',
+      editS4: dataset.s4 || ''
+    });
+  },
+
+  closeEditAmount() {
+    this.setData({ showEditAmount: false });
+  },
+
+  onS1Change(e) { this.setData({ editS1: e.detail.value != null ? e.detail.value : e.detail }); },
+  onS2Change(e) { this.setData({ editS2: e.detail.value != null ? e.detail.value : e.detail }); },
+  onS3Change(e) { this.setData({ editS3: e.detail.value != null ? e.detail.value : e.detail }); },
+  onS4Change(e) { this.setData({ editS4: e.detail.value != null ? e.detail.value : e.detail }); },
+
+  confirmEditAmount() {
+    _Http.basic({
+      id: '2026042113202402',
+      content: {
+        items: [{
+          sa_esign_contract_taskmxid: this.data.currentDetailId,
+          s1: Number(this.data.editS1) || 0,
+          s2: Number(this.data.editS2) || 0,
+          s3: Number(this.data.editS3) || 0,
+          s4: Number(this.data.editS4) || 0
+        }]
+      }
+    }).then(res => {
+      if (res.msg === '成功') {
+        wx.showToast({ title: '修改成功', icon: 'success' });
+        this.closeEditAmount();
+        this.loadDetailList();
       } else {
         wx.showToast({ title: res.msg || '修改失败', icon: 'none' });
       }
@@ -216,20 +379,29 @@ Page({
       content: '确定要删除这个经销商吗?',
       success: (res) => {
         if (res.confirm) {
-          getApp().globalData.http.basic({
+          _Http.basic({
             id: '2026041315414702',
             content: {
               sa_esign_contract_taskmxids: [detailId]
             }
           }).then(res => {
             if (res.msg === '成功') {
-              wx.showToast({ title: '删除成功', icon: 'success' });
+              wx.showToast({
+                title: '删除成功',
+                icon: 'success'
+              });
               this.loadDetailList();
             } else {
-              wx.showToast({ title: res.msg || '删除失败', icon: 'none' });
+              wx.showToast({
+                title: res.msg || '删除失败',
+                icon: 'none'
+              });
             }
           }).catch(() => {
-            wx.showToast({ title: '删除失败', icon: 'none' });
+            wx.showToast({
+              title: '删除失败',
+              icon: 'none'
+            });
           });
         }
       }

+ 5 - 9
CRM/contract/detail.json

@@ -1,11 +1,7 @@
 {
   "usingComponents": {
-    "Yl_HeadNav": "/components/Yl_HeadNav/index",
-    "van-tag": "@vant/weapp/tag/index",
-    "van-button": "@vant/weapp/button/index",
-    "Yl_Empty": "/components/Yl_Empty/index",
-    "van-popup": "@vant/weapp/popup/index",
-    "van-checkbox": "@vant/weapp/checkbox/index",
-    "van-field": "@vant/weapp/field/index"
-  }
-}
+    "Yl_Tabbar": "/components/Yl_Tabbar/index",
+    "van-icon": "@vant/weapp/icon/index"
+  },
+  "navigationBarTitleText": "合同任务详情"
+}

+ 305 - 131
CRM/contract/detail.scss

@@ -1,133 +1,307 @@
-.contract-detail {
-  min-height: 100vh;
-  background-color: #f5f5f5;
+page {
+  background-color: #f5f6fa;
+}
+
+.container {
   padding: 20rpx;
+  min-height: 100vh;
+}
+
+/* 顶部信息卡 */
+.info-card {
+  background: linear-gradient(135deg, #3874F6 0%, #5B9BFF 100%);
+  border-radius: 20rpx;
+  padding: 32rpx;
+  color: #fff;
+  margin-bottom: 20rpx;
+  box-shadow: 0 8rpx 24rpx rgba(56, 116, 246, 0.3);
+}
+
+.info-top {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  margin-bottom: 28rpx;
+  padding-bottom: 24rpx;
+  border-bottom: 1rpx solid rgba(255, 255, 255, 0.2);
+}
+
+.task-name {
+  font-size: 36rpx;
+  font-weight: bold;
+  flex: 1;
+  margin-right: 16rpx;
+}
+
+.status-tag {
+  font-size: 24rpx;
+  padding: 10rpx 28rpx;
+  border-radius: 24rpx;
+  font-weight: 600;
+  white-space: nowrap;
+  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.15);
+}
+
+.info-grid {
+  display: grid;
+  grid-template-columns: repeat(2, 1fr);
+  gap: 20rpx 32rpx;
+}
+
+.info-cell {
+  .info-label {
+    font-size: 22rpx;
+    color: rgba(255, 255, 255, 0.7);
+    margin-bottom: 6rpx;
+  }
+
+  .info-value {
+    font-size: 26rpx;
+    font-weight: 500;
+  }
+}
+
+.info-remark {
+  margin-top: 24rpx;
+  padding-top: 20rpx;
+  border-top: 1rpx solid rgba(255, 255, 255, 0.2);
+
+  .info-label {
+    font-size: 22rpx;
+    color: rgba(255, 255, 255, 0.7);
+    margin-bottom: 8rpx;
+  }
+
+  .remark-text {
+    font-size: 26rpx;
+    line-height: 40rpx;
+    opacity: 0.9;
+  }
+}
+
+/* 区块卡片 */
+.section-card {
+  background-color: #fff;
+  border-radius: 20rpx;
+  padding: 28rpx;
+  box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.05);
+}
+
+.section-header {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  margin-bottom: 24rpx;
+  padding-bottom: 20rpx;
+  border-bottom: 1rpx solid #f0f0f0;
+}
+
+.section-title {
+  font-size: 32rpx;
+  font-weight: bold;
+  color: #1a1a1a;
+  position: relative;
+  padding-left: 20rpx;
+
+  &::before {
+    content: '';
+    position: absolute;
+    left: 0;
+    top: 50%;
+    transform: translateY(-50%);
+    width: 6rpx;
+    height: 28rpx;
+    background: #3874F6;
+    border-radius: 3rpx;
+  }
+}
+
+.section-count {
+  font-size: 24rpx;
+  color: #999;
+  background: #f5f6fa;
+  padding: 4rpx 16rpx;
+  border-radius: 12rpx;
+}
+
+/* 经销商卡片 */
+.distributor-card {
+  background: #fafbfc;
+  border-radius: 16rpx;
+  padding: 24rpx;
+  margin-bottom: 20rpx;
+  border: 1rpx solid #eef0f5;
+
+  &:last-child {
+    margin-bottom: 0;
+  }
+}
+
+.dist-top {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  margin-bottom: 20rpx;
+}
+
+.dist-name {
+  font-size: 30rpx;
+  font-weight: 600;
+  color: #1a1a1a;
+  flex: 1;
+  margin-right: 16rpx;
+}
+
+.dist-status {
+  font-size: 22rpx;
+  padding: 4rpx 16rpx;
+  border-radius: 16rpx;
+  font-weight: 500;
+}
+
+.dist-info {
+  margin-bottom: 20rpx;
+}
+
+.dist-row {
+  display: flex;
+  margin-bottom: 12rpx;
+
+  &:last-child {
+    margin-bottom: 0;
+  }
+}
+
+.dist-cell {
+  flex: 1;
+  display: flex;
+  align-items: center;
+
+  &.full {
+    flex: none;
+    width: 100%;
+  }
+
+  .dist-label {
+    font-size: 24rpx;
+    color: #999;
+    margin-right: 8rpx;
+  }
+
+  .dist-val {
+    font-size: 24rpx;
+    color: #333;
+  }
+}
+
+/* 任务网格 */
+.task-grid {
+  display: grid;
+  grid-template-columns: repeat(5, 1fr);
+  gap: 8rpx;
+  background: #fff;
+  border-radius: 12rpx;
+  padding: 20rpx 12rpx;
+  margin-bottom: 20rpx;
+  border: 1rpx solid #eef0f5;
+}
+
+.task-cell {
+  text-align: center;
+
+  .task-num {
+    font-size: 28rpx;
+    font-weight: 700;
+    color: #3874F6;
+    line-height: 1.2;
+  }
+
+  .task-label {
+    font-size: 20rpx;
+    color: #999;
+    margin-top: 6rpx;
+  }
+}
+
+/* 操作按钮 */
+.dist-actions {
+  display: flex;
+  gap: 16rpx;
+  justify-content: flex-end;
+}
+
+.action-btn {
+  display: flex;
+  align-items: center;
+  gap: 6rpx;
+  padding: 12rpx 24rpx;
+  border-radius: 28rpx;
+  font-size: 24rpx;
+  font-weight: 500;
+  transition: all 0.2s ease;
 
-  .content {
-    padding-bottom: 20rpx;
-  }
-
-  .card-item {
-    background-color: #fff;
-    border-radius: 12rpx;
-    padding: 24rpx;
-    margin-bottom: 20rpx;
-
-    .card-header {
-      font-size: 32rpx;
-      font-weight: bold;
-      color: #333;
-      margin-bottom: 15rpx;
-      border-bottom: 1rpx solid #eee;
-      padding-bottom: 10rpx;
-    }
-
-    .exp {
-      font-size: 26rpx;
-      color: #666;
-      line-height: 1.5;
-      margin-top: 8rpx;
-    }
-
-    .exp.full-width {
-      width: 100%;
-    }
-  }
-
-  .action-buttons {
-    display: flex;
-    gap: 10rpx;
-    margin-bottom: 20rpx;
-    van-button {
-      flex: 1;
-      font-size: 28rpx;
-    }
-  }
-
-  .detail-item {
-    border-bottom: 1rpx solid #eee;
-    padding: 15rpx 0;
-
-    &:last-child {
-      border-bottom: none;
-    }
-
-    .detail-header {
-      display: flex;
-      justify-content: space-between;
-      align-items: center;
-      margin-bottom: 10rpx;
-      .distributor-name {
-        font-size: 28rpx;
-        font-weight: bold;
-        color: #333;
-      }
-    }
-
-    .detail-info {
-      margin-left: 10rpx;
-      .exp {
-        font-size: 24rpx;
-        color: #666;
-        line-height: 1.4;
-        margin-top: 6rpx;
-      }
-    }
-
-    .detail-action {
-      margin-top: 15rpx;
-      display: flex;
-      gap: 10rpx;
-      justify-content: flex-end;
-    }
-  }
-
-  .popup-header {
-    display: flex;
-    justify-content: space-between;
-    align-items: center;
-    padding: 20rpx;
-    border-bottom: 1rpx solid #eee;
-    .cancel,
-    .confirm {
-      font-size: 28rpx;
-      color: #666;
-    }
-    .title {
-      font-size: 32rpx;
-      font-weight: bold;
-      color: #333;
-    }
-    .confirm {
-      color: #085CDF;
-    }
-  }
-
-  .distributor-list {
-    max-height: 600rpx;
-    overflow-y: auto;
-    .distributor-item {
-      display: flex;
-      justify-content: space-between;
-      align-items: center;
-      padding: 20rpx;
-      border-bottom: 1rpx solid #eee;
-      .distributor-info {
-        .name {
-          font-size: 28rpx;
-          color: #333;
-          margin-bottom: 5rpx;
-          display: block;
-        }
-        .code {
-          font-size: 24rpx;
-          color: #666;
-        }
-      }
-    }
-  }
-
-  .form {
-    padding: 20rpx;
-  }
-}
+  &:active {
+    opacity: 0.7;
+    transform: scale(0.96);
+  }
+
+  &.edit-btn {
+    color: #3874F6;
+    background: rgba(56, 116, 246, 0.08);
+    border: 1rpx solid rgba(56, 116, 246, 0.2);
+  }
+
+  &.amount-btn {
+    color: #E6A23C;
+    background: rgba(230, 162, 60, 0.08);
+    border: 1rpx solid rgba(230, 162, 60, 0.2);
+  }
+
+  &.delete-btn {
+    color: #FF4D4F;
+    background: rgba(255, 77, 79, 0.08);
+    border: 1rpx solid rgba(255, 77, 79, 0.2);
+  }
+}
+
+/* 模态弹窗 */
+.modal-header {
+  text-align: center;
+  font-size: 32rpx;
+  font-weight: bold;
+  color: #333;
+  padding: 36rpx 24rpx 24rpx;
+}
+
+.modal-body {
+  padding: 0 8rpx;
+}
+
+.field-unit {
+  font-size: 26rpx;
+  color: #999;
+  padding-left: 8rpx;
+}
+
+.modal-footer {
+  display: flex;
+  border-top: 1rpx solid #eee;
+  margin-top: 12rpx;
+}
+
+.modal-btn {
+  flex: 1;
+  text-align: center;
+  font-size: 30rpx;
+  line-height: 88rpx;
+  color: #666;
+
+  &.confirm {
+    color: #3874F6;
+    font-weight: 500;
+  }
+
+  &:active {
+    background-color: #f5f5f5;
+  }
+}

+ 210 - 107
CRM/contract/detail.wxml

@@ -1,132 +1,235 @@
-<view class="contract-detail">
-  <Yl_HeadNav title="合同任务详情" showBack="true" />
-  <view class="content">
-    <!-- 表头信息 -->
-    <view class="card-item">
-      <view class="card-header">
-        合同任务信息
+<view class="container">
+  <!-- 顶部信息卡 -->
+  <view class="info-card">
+    <view class="info-top">
+      <view class="task-name">{{detail.taskname || '--'}}</view>
+      <view class="status-tag" style="background: {{set.color(detail.status)}}; color: #fff;">
+        {{detail.status || '--'}}
       </view>
-      <view class="exp">任务名称:{{ detail.taskname || '--' }}</view>
-      <view class="exp">合同模版名称:{{ detail.template_name || '--' }}</view>
-      <view class="exp">年度:{{ detail.year || '--' }}</view>
-      <view class="exp">合同类型:{{ detail.contract_type || '--' }}</view>
-      <view class="exp">电子合同模版id:{{ detail.sa_esign_contract_templateid || '--' }}</view>
-      <view class="exp">创建人:{{ detail.create_user || '--' }}</view>
-      <view class="exp">创建时间:{{ detail.create_time || '--' }}</view>
-      <view class="exp" wx:if="{{ detail.publish_time }}">发布时间:{{ detail.publish_time || '--' }}</view>
-      <view class="exp">
-        状态:
-        <van-tag wx:if="{{ detail.status === '新建' }}" color="#909399">新建</van-tag>
-        <van-tag wx:elif="{{ detail.status === '发布' }}" color="#67C23A">发布</van-tag>
-        <van-tag wx:elif="{{ detail.status === '撤回' }}" color="#F56C6C">撤回</van-tag>
-        <text wx:else>--</text>
+    </view>
+    <view class="info-grid">
+      <view class="info-cell">
+        <view class="info-label">合同模版</view>
+        <view class="info-value">{{detail.name || '--'}}</view>
+      </view>
+      <view class="info-cell">
+        <view class="info-label">年度</view>
+        <view class="info-value">{{detail.year || '--'}}</view>
+      </view>
+      <view class="info-cell">
+        <view class="info-label">合同类型</view>
+        <view class="info-value">{{detail.type || '--'}}</view>
+      </view>
+      <view class="info-cell">
+        <view class="info-label">创建人</view>
+        <view class="info-value">{{detail.createby || '--'}}</view>
+      </view>
+      <view class="info-cell" wx:if="{{detail.sendby}}">
+        <view class="info-label">发布人</view>
+        <view class="info-value">{{detail.sendby || '--'}}</view>
       </view>
-      <view class="exp full-width">备注:{{ detail.remarks || '--' }}</view>
+      <view class="info-cell">
+        <view class="info-label">创建时间</view>
+        <view class="info-value">{{detail.createdate || '--'}}</view>
+      </view>
+    </view>
+    <view class="info-remark" wx:if="{{detail.remarks}}">
+      <view class="info-label">备注</view>
+      <view class="remark-text">{{detail.remarks}}</view>
     </view>
+  </view>
 
-    <!-- 操作按钮 -->
-    <view class="action-buttons">
-      <van-button type="primary" bindtap="addDistributor">添加经销商</van-button>
-      <van-button 
-        type="success" 
-        wx:if="{{ detail.status === '新建' || detail.status === '撤回' }}" 
-        bindtap="publishTask"
-      >发布</van-button>
-      <van-button 
-        type="warning" 
-        wx:if="{{ detail.status === '发布' }}" 
-        bindtap="withdrawTask"
-      >撤回</van-button>
+  <!-- 经销商明细 -->
+  <view class="section-card">
+    <view class="section-header">
+      <view class="section-title">经销商明细</view>
+      <view class="section-count" wx:if="{{list.length}}">共{{list.length}}家</view>
     </view>
 
-    <!-- 明细列表 -->
-    <view class="card-item">
-      <view class="card-header">
-        经销商明细
-      </view>
-      <block wx:for="{{ list }}" wx:key="id">
-        <view class="detail-item">
-          <view class="detail-header">
-            <view class="distributor-name">{{ item.distributor_name || '--' }}</view>
-            <van-tag wx:if="{{ item.status === '待开始' }}" color="#909399">待开始</van-tag>
-            <van-tag wx:elif="{{ item.status === '待签署' }}" color="#E6A23C">待签署</van-tag>
-            <van-tag wx:elif="{{ item.status === '部分签署' }}" color="#409EFF">部分签署</van-tag>
-            <van-tag wx:elif="{{ item.status === '已签署' }}" color="#67C23A">已签署</van-tag>
-            <van-tag wx:elif="{{ item.status === '已拒签' }}" color="#F56C6C">已拒签</van-tag>
-            <text wx:else>--</text>
+    <block wx:for="{{list}}" wx:key="sa_esign_contract_taskmxid">
+      <view class="distributor-card">
+        <view class="dist-top">
+          <view class="dist-name">{{ item.enterprisename || '--' }}</view>
+          <view class="dist-status" wx:if="{{item.status}}" style="background: {{set.distributorColor(item.status)}}20; color: {{set.distributorColor(item.status)}};">
+            {{item.status}}
           </view>
-          <view class="detail-info">
-            <view class="exp">编号:{{ item.distributor_code || '--' }}</view>
-            <view class="exp">区域:{{ item.area || '--' }}</view>
-            <view class="exp">联系人:{{ item.contact || '--' }}</view>
-            <view class="exp">联系方式:{{ item.contact_phone || '--' }}</view>
-            <view class="exp">合同期限:{{ item.begindate || '--' }} 至 {{ item.enddate || '--' }}</view>
-            <view class="exp">年度任务(万元):{{ item.year_task || '--' }}</view>
-            <view class="exp">一季度任务(万元):{{ item.quarter1_task || '--' }}</view>
-            <view class="exp">二季度任务(万元):{{ item.quarter2_task || '--' }}</view>
-            <view class="exp">三季度任务(万元):{{ item.quarter3_task || '--' }}</view>
-            <view class="exp">四季度任务(万元):{{ item.quarter4_task || '--' }}</view>
+        </view>
+        <view class="dist-info">
+          <view class="dist-row">
+            <view class="dist-cell">
+              <text class="dist-label">编号</text>
+              <text class="dist-val">{{ item.agentnum || '--' }}</text>
+            </view>
+            <view class="dist-cell">
+              <text class="dist-label">区域</text>
+              <text class="dist-val">{{ item.areaname || '--' }}</text>
+            </view>
           </view>
-          <view class="detail-action">
-            <van-button size="small" bindtap="editTerm" data-id="{{ item.id }}">编辑期限</van-button>
-            <van-button size="small" type="danger" bindtap="deleteDetail" data-id="{{ item.id }}">删除</van-button>
+          <view class="dist-row">
+            <view class="dist-cell">
+              <text class="dist-label">法人</text>
+              <text class="dist-val">{{ item.legal_rep || '--' }}</text>
+            </view>
+            <view class="dist-cell">
+              <text class="dist-label">联系方式</text>
+              <text class="dist-val">{{ item.phonenumber || '--' }}</text>
+            </view>
+          </view>
+          <view class="dist-row" wx:if="{{item.begindate || item.enddate}}">
+            <view class="dist-cell full">
+              <text class="dist-label">合同期限</text>
+              <text class="dist-val">{{ item.begindate || '--' }} 至 {{ item.enddate || '--' }}</text>
+            </view>
           </view>
         </view>
-      </block>
-      <Yl_Empty wx:if="{{ list.length === 0 }}" text="暂无经销商" />
-    </view>
-  </view>
-
-  <!-- 添加经销商弹窗 -->
-  <van-popup
-    show="{{ showAddDistributor }}"
-    position="bottom"
-    bind:close="closeAddDistributor"
-  >
-    <view class="popup-header">
-      <text class="cancel" bindtap="closeAddDistributor">取消</text>
-      <text class="title">选择经销商</text>
-      <text class="confirm" bindtap="confirmAddDistributor">确定</text>
-    </view>
-    <view class="distributor-list">
-      <block wx:for="{{ distributorList }}" wx:key="id">
-        <view class="distributor-item" bindtap="selectDistributor" data-id="{{ item.id }}" data-name="{{ item.name }}">
-          <view class="distributor-info">
-            <text class="name">{{ item.name }}</text>
-            <text class="code">{{ item.code }}</text>
+        <!-- 季度任务 -->
+        <view class="task-grid">
+          <view class="task-cell">
+            <view class="task-num">{{ item.y1 || 0 }}</view>
+            <view class="task-label">年度(万)</view>
+          </view>
+          <view class="task-cell">
+            <view class="task-num">{{ item.s1 || 0 }}</view>
+            <view class="task-label">Q1</view>
+          </view>
+          <view class="task-cell">
+            <view class="task-num">{{ item.s2 || 0 }}</view>
+            <view class="task-label">Q2</view>
+          </view>
+          <view class="task-cell">
+            <view class="task-num">{{ item.s3 || 0 }}</view>
+            <view class="task-label">Q3</view>
+          </view>
+          <view class="task-cell">
+            <view class="task-num">{{ item.s4 || 0 }}</view>
+            <view class="task-label">Q4</view>
           </view>
-          <van-checkbox value="{{ selectedDistributors.includes(item.id) }}" />
         </view>
-      </block>
-    </view>
-  </van-popup>
+        <!-- 操作 -->
+        <view class="dist-actions" wx:if="{{detail.status !== '发布'}}">
+          <view bind:tap="editTerm" data-id="{{ item.sa_esign_contract_taskmxid }}" data-begin="{{ item.begindate }}" data-end="{{ item.enddate }}" class="action-btn edit-btn">
+            <text>编辑期限</text>
+          </view>
+          <view bind:tap="editAmount" data-id="{{ item.sa_esign_contract_taskmxid }}" data-s1="{{ item.s1 }}" data-s2="{{ item.s2 }}" data-s3="{{ item.s3 }}" data-s4="{{ item.s4 }}" class="action-btn amount-btn">
+            <text>编辑金额</text>
+          </view>
+          <view bind:tap="deleteDetail" data-id="{{ item.sa_esign_contract_taskmxid }}" class="action-btn delete-btn">
+            <text>删除</text>
+          </view>
+        </view>
+      </view>
+    </block>
 
-  <!-- 编辑期限弹窗 -->
-  <van-popup
-    show="{{ showEditTerm }}"
-    position="bottom"
-    bind:close="closeEditTerm"
-  >
-    <view class="popup-header">
-      <text class="cancel" bindtap="closeEditTerm">取消</text>
-      <text class="title">编辑合同期限</text>
-      <text class="confirm" bindtap="confirmEditTerm">确定</text>
-    </view>
-    <view class="form">
+    <Yl_Empty wx:if="{{list.length === 0}}" text="暂无经销商" />
+  </view>
+</view>
+
+<view style="height: 130rpx;" />
+
+<!-- 底部操作栏 -->
+<Yl_Tabbar wx:if="{{tabbarList.length}}" list='{{tabbarList}}' bind:callback="tabbarOnClick" />
+
+<!-- 编辑期限弹窗 -->
+<van-popup
+  show="{{ showEditTerm }}"
+  round
+  z-index="9999"
+  custom-style="width: 80%; max-width: 600rpx; overflow: hidden;"
+  bind:close="closeEditTerm"
+>
+  <view class="modal-header">编辑合同期限</view>
+  <view class="modal-body">
+    <picker mode="date" value="{{ beginDate }}" start="2020-01-01" end="2030-12-31" bind:change="onBeginDateChange">
       <van-field
         label="开始日期"
         value="{{ beginDate }}"
         placeholder="请选择开始日期"
-        bind:tap="selectBeginDate"
         readonly
+        is-link
       />
+    </picker>
+    <picker mode="date" value="{{ endDate }}" start="2020-01-01" end="2030-12-31" bind:change="onEndDateChange">
       <van-field
         label="结束日期"
         value="{{ endDate }}"
         placeholder="请选择结束日期"
-        bind:tap="selectEndDate"
         readonly
+        is-link
       />
-    </view>
-  </van-popup>
-</view>
+    </picker>
+  </view>
+  <view class="modal-footer">
+    <view class="modal-btn cancel" bindtap="closeEditTerm">取消</view>
+    <view class="modal-btn confirm" bindtap="confirmEditTerm">确定</view>
+  </view>
+</van-popup>
+
+<!-- 编辑金额弹窗 -->
+<van-popup
+  show="{{ showEditAmount }}"
+  round
+  z-index="9999"
+  custom-style="width: 80%; max-width: 600rpx; overflow: hidden;"
+  bind:close="closeEditAmount"
+>
+  <view class="modal-header">编辑季度金额</view>
+  <view class="modal-body">
+    <van-field label="季度1" value="{{ editS1 }}" type="digit" confirm-type="next" placeholder="请输入金额" bind:change="onS1Change">
+      <view slot="button" class="field-unit">万</view>
+    </van-field>
+    <van-field label="季度2" value="{{ editS2 }}" type="digit" confirm-type="next" placeholder="请输入金额" bind:change="onS2Change">
+      <view slot="button" class="field-unit">万</view>
+    </van-field>
+    <van-field label="季度3" value="{{ editS3 }}" type="digit" confirm-type="next" placeholder="请输入金额" bind:change="onS3Change">
+      <view slot="button" class="field-unit">万</view>
+    </van-field>
+    <van-field label="季度4" value="{{ editS4 }}" type="digit" confirm-type="done" placeholder="请输入金额" bind:change="onS4Change">
+      <view slot="button" class="field-unit">万</view>
+    </van-field>
+  </view>
+  <view class="modal-footer">
+    <view class="modal-btn cancel" bindtap="closeEditAmount">取消</view>
+    <view class="modal-btn confirm" bindtap="confirmEditAmount">确定</view>
+  </view>
+</van-popup>
+
+<wxs module="set">
+  module.exports = {
+    color: function (statu) {
+      var color = '#999999';
+      switch (statu) {
+        case "新建":
+          color = '#FA8C16';
+          break;
+        case "发布":
+          color = '#52C41A';
+          break;
+        case "撤回":
+          color = '#FF4D4F';
+          break;
+      };
+      return color;
+    },
+    distributorColor: function (statu) {
+      var color = '#999999';
+      switch (statu) {
+        case "待开始":
+          color = '#909399';
+          break;
+        case "待签署":
+          color = '#E6A23C';
+          break;
+        case "部分签署":
+          color = '#409EFF';
+          break;
+        case "已签署":
+          color = '#67C23A';
+          break;
+        case "已拒签":
+          color = '#F56C6C';
+          break;
+      };
+      return color;
+    }
+  }
+</wxs>

+ 71 - 50
CRM/contract/index.js

@@ -1,67 +1,88 @@
+const _Http = getApp().globalData.http;
+
 Page({
   data: {
     list: [],
-    searchValue: '',
-    pageNumber: 1,
-    pageSize: 20,
     loading: false,
-    hasMore: true
+    content: {
+      nocache: true,
+      pageNumber: 1,
+      pageSize: 20,
+      pageTotal: 1,
+      total: null,
+      where: {
+        condition: "",
+        tablefilter: {
+          taskname: null,
+          name: null,
+          year: null,
+          status: null,
+          createby: null
+        }
+      }
+    }
   },
-
   onLoad() {
-    this.getList();
+    this.getList(true);
+  },
+  onShow() {
+    if (this.data._loaded) {
+      this.getList(true);
+    }
+    this.setData({ _loaded: true });
+  },
+  onPullDownRefresh() {
+    this.getList(true);
+    wx.stopPullDownRefresh();
   },
-
   onReachBottom() {
-    if (!this.data.loading && this.data.hasMore) {
-      this.setData({
-        pageNumber: this.data.pageNumber + 1
-      });
-      this.getList();
+    if (this.data.content.pageNumber <= this.data.content.pageTotal) {
+      this.getList(false);
     }
   },
-
-  getList() {
-    this.setData({ loading: true });
-    getApp().globalData.http.basic({
-      id: '2026041309474202',
-      content: {
-        pageNumber: this.data.pageNumber,
-        pageSize: this.data.pageSize
-      }
+  onSearch(e) {
+    const keyword = typeof e.detail === 'string' ? e.detail : (e.detail.value || "");
+    this.setData({
+      "content.where.condition": keyword,
+      "content.pageNumber": 1
+    });
+    this.getList(true);
+  },
+  getList(init) {
+    if (init.detail != undefined) init = init.detail;
+    let content = this.data.content;
+    if (init) {
+      content.pageNumber = 1;
+      this.setData({ loading: true });
+    }
+    if (content.pageNumber > content.pageTotal) return;
+    _Http.basic({
+      "id": "2026041309474202",
+      content
     }).then(res => {
-      if (res.msg === '成功') {
-        const newList = res.data || [];
-        const list = this.data.pageNumber === 1 ? newList : [...this.data.list, ...newList];
-        this.setData({
-          list,
-          hasMore: newList.length === this.data.pageSize,
-          loading: false
-        });
-      } else {
-        wx.showToast({ title: res.msg || '加载失败', icon: 'none' });
-        this.setData({ loading: false });
-      }
+      this.setData({ loading: false });
+      console.log("合同任务列表", res);
+      this.selectComponent('#ListBox').RefreshToComplete();
+      if (res.msg !== '成功') 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
+      });
     }).catch(() => {
-      wx.showToast({ title: '加载失败', icon: 'none' });
       this.setData({ loading: false });
+      this.selectComponent('#ListBox').RefreshToComplete();
+      wx.showToast({ title: '加载失败', icon: 'none' });
     });
   },
-
-  onSearch(e) {
-    this.setData({ 
-      pageNumber: 1,
-      searchValue: e.detail 
-    });
-    this.getList();
-  },
-
   goToCreate() {
-    wx.navigateTo({ url: '/CRM/contract/create' });
-  },
-
-  goToDetail(e) {
-    const taskId = e.currentTarget.dataset.id;
-    wx.navigateTo({ url: `/CRM/contract/detail?id=${taskId}` });
+    wx.navigateTo({
+      url: '/CRM/contract/create'
+    });
   }
-});
+});

+ 2 - 10
CRM/contract/index.json

@@ -1,11 +1,3 @@
 {
-  "usingComponents": {
-    "Yl_HeadNav": "/components/Yl_HeadNav/index",
-    "van-search": "@vant/weapp/search/index",
-    "van-tabs": "@vant/weapp/tabs/index",
-    "van-tab": "@vant/weapp/tab/index",
-    "van-tag": "@vant/weapp/tag/index",
-    "Yl_Empty": "/components/Yl_Empty/index",
-    "van-button": "@vant/weapp/button/index"
-  }
-}
+  "navigationBarTitleText": "合同任务列表"
+}

+ 45 - 42
CRM/contract/index.scss

@@ -1,81 +1,84 @@
 .container {
-  min-height: 100vh;
   background-color: #f5f5f5;
-
-  .header {
-    width: 100%;
-  }
+  min-height: 100vh;
 
   .item {
     background-color: #fff;
-    border-radius: 12rpx;
+    border-radius: 16rpx;
     padding: 24rpx;
     margin-bottom: 20rpx;
+    display: block;
+    box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
 
     .top {
       display: flex;
       justify-content: space-between;
       align-items: center;
-      margin-bottom: 15rpx;
+      margin-bottom: 16rpx;
 
       .name {
-        font-size: 32rpx;
-        font-weight: bold;
-        color: #333;
+        font-size: 34rpx;
+        font-weight: 600;
+        color: #1a1a1a;
         flex: 1;
       }
 
       .statu {
         font-size: 24rpx;
-        padding: 4rpx 12rpx;
-        border-radius: 4rpx;
+        padding: 6rpx 20rpx;
+        border-radius: 8rpx;
+        font-weight: 500;
+        background-color: #fff;
+        border: 2rpx solid;
+        flex-shrink: 0;
       }
     }
 
     .content {
       .row {
         display: flex;
-        margin-bottom: 10rpx;
+        flex-wrap: wrap;
+        margin-bottom: 12rpx;
 
         .exp {
+          flex: 1;
           font-size: 26rpx;
           color: #666;
-          flex: 1;
+          line-height: 1.5;
 
           &.full-width {
             width: 100%;
-            flex: none;
-          }
-
-          .link {
-            color: #3874F6;
-            text-decoration: underline;
-          }
-
-          .text-green {
-            color: #52C41A;
-          }
-
-          .text-red {
-            color: #FF4D4F;
           }
         }
       }
     }
   }
 
-  .create-order-button {
-    position: fixed;
-    bottom: 30rpx;
-    left: 50%;
-    transform: translateX(-50%);
-    width: 90%;
-    
-    .create-btn {
-      width: 100%;
-      height: 80rpx;
-      font-size: 32rpx;
-      border-radius: 8rpx;
-    }
+  .header {
+    background-color: #f5f5f5;
   }
-}
+}
+
+/* 新建按钮样式 */
+.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;
+}

+ 16 - 28
CRM/contract/index.wxml

@@ -2,46 +2,34 @@
   <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'>
-    <navigator url="/CRM/contract/detail?id={{item.sa_esign_contract_taskid}}" class="item" wx:for="{{ list }}" wx:key="sa_esign_contract_taskid">
+    <navigator url="/CRM/contract/detail?id={{item.sa_esign_contract_taskid}}" class="item" wx:for="{{list}}" wx:key="sa_esign_contract_taskid">
       <view class="top">
         <view class="name">{{item.taskname || '--'}}</view>
-        <view class="statu" style="background-color: {{set.color(item.status)}}; color: #fff;">
+        <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">
-          <view class="exp">
-            合同模版:{{item.template_name || '--'}}
-          </view>
-          <view class="exp">
-            年度:{{item.year || '--'}}
-          </view>
+          <view class="exp">合同模版:{{item.name || '--'}}</view>
         </view>
         <view class="row">
-          <view class="exp">
-            合同类型:{{item.contract_type || '--'}}
-          </view>
-          <view class="exp">
-            创建人:{{item.create_user || '--'}}
-          </view>
+          <view class="exp">年度:{{item.year || '--'}}</view>
+          <view class="exp">合同类型:{{item.type || '--'}}</view>
         </view>
         <view class="row">
-          <view class="exp">
-            创建时间:{{item.create_time || '--'}}
-          </view>
-          <view class="exp" wx:if="{{ item.publish_time }}">
-            发布时间:{{item.publish_time || '--'}}
-          </view>
+          <view class="exp">创建人:{{item.createby || '--'}}</view>
+          <view class="exp">创建时间:{{item.createdate || '--'}}</view>
         </view>
         <view class="row">
-          <view class="exp full-width">
-            备注:{{item.remarks || '--'}}
-          </view>
+          <view class="exp full-width" wx:if="{{item.sendby}}">发布人:{{item.sendby || '--'}}</view>
+        </view>
+        <view class="row">
+          <view class="exp full-width">备注:{{item.remarks || '--'}}</view>
         </view>
       </view>
     </navigator>
-    <Yl_Empty wx:if="{{list.length==0}}" text="暂无合同任务" />
+    <Yl_Empty wx:if="{{list.length==0}}" />
     <view style="height:150rpx;" />
   </Yl_ListBox>
   <!-- 新建按钮 -->
@@ -55,16 +43,16 @@
       var color = '#999999';
       switch (statu) {
         case "新建":
-          color = '#909399';
+          color = '#FA8C16';
           break;
         case "发布":
-          color = '#67C23A';
+          color = '#52C41A';
           break;
         case "撤回":
-          color = '#F56C6C';
+          color = '#FF4D4F';
           break;
       };
       return color;
     }
   }
-</wxs>
+</wxs>

+ 100 - 0
CRM/contract/modules/templateSelect/index.js

@@ -0,0 +1,100 @@
+const _Http = getApp().globalData.http;
+
+Page({
+  data: {
+    list: [],
+    result: [],
+    total: 0,
+    condition: "",
+    content: {
+      nocache: true,
+      pageNumber: 1,
+      pageSize: 20,
+      pageTotal: 1,
+      where: {
+        condition: ""
+      }
+    }
+  },
+
+  onLoad(options) {
+    this.getList();
+  },
+
+  getList(init = false) {
+    if (init.detail != undefined) init = init.detail;
+    let content = this.data.content;
+    if (init) {
+      content.pageNumber = 1;
+    }
+    if (content.pageNumber > content.pageTotal) return;
+
+    _Http.basic({
+      id: '2026041309474202',
+      content
+    }).then(res => {
+      this.selectComponent('#ListBox').RefreshToComplete();
+      if (res.msg !== '成功') 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.pageTotal': res.pageTotal,
+        'content.total': res.total,
+        total: res.total
+      });
+    });
+  },
+
+  /* 选中 */
+  changeResult(e) {
+    let {
+      id,
+      item
+    } = e.currentTarget.dataset, result = this.data.result;
+    // 单选模式
+    if (result.includes(id)) {
+      result = result.filter(v => v != id);
+    } else {
+      result = [id]; // 单选
+    }
+    this.setData({ result });
+  },
+
+  /* 提交 */
+  submit() {
+    let result = this.data.result;
+    let selectedItem = this.data.list.find(v => v.sa_esign_contract_templateid == result[0]);
+    let obj = {
+      id: result[0],
+      item: selectedItem,
+      value: [selectedItem ? selectedItem.name : '', result[0]]
+    };
+    getApp().globalData.handleSelect && getApp().globalData.handleSelect(obj);
+  },
+
+  /* 搜索 */
+  startSearch(e) {
+    let condition = e.detail;
+    this.setData({
+      'content.where.condition': condition,
+      'content.pageNumber': 1
+    });
+    this.getList(true);
+  },
+
+  /* 清空搜索 */
+  onClear() {
+    this.setData({
+      'content.where.condition': "",
+      'content.pageNumber': 1
+    });
+    this.getList(true);
+  },
+
+  onUnload() {
+    getApp().globalData.handleSelect = null;
+  }
+});

+ 10 - 0
CRM/contract/modules/templateSelect/index.json

@@ -0,0 +1,10 @@
+{
+  "usingComponents": {
+    "van-search": "@vant/weapp/search/index",
+    "van-checkbox": "@vant/weapp/checkbox/index",
+    "van-button": "@vant/weapp/button/index",
+    "Yl_ListBox": "/components/Yl_ListBox/index",
+    "Yl_Empty": "/components/Yl_Empty/index"
+  },
+  "navigationBarTitleText": "选择合同模版"
+}

+ 80 - 0
CRM/contract/modules/templateSelect/index.scss

@@ -0,0 +1,80 @@
+.search {
+  background-color: #f5f5f5;
+}
+
+.total {
+  padding: 10rpx 20rpx;
+  font-size: 24rpx;
+  color: #999;
+  background-color: #f5f5f5;
+  border-bottom: 1rpx solid #e8e8e8;
+}
+
+.list-item {
+  background-color: #fff;
+  margin-bottom: 10rpx;
+}
+
+.main {
+  display: flex;
+  padding: 20rpx;
+  position: relative;
+}
+
+.checkbox {
+  margin-right: 20rpx;
+  display: flex;
+  align-items: center;
+}
+
+.dec {
+  flex: 1;
+}
+
+.title {
+  font-size: 32rpx;
+  font-weight: bold;
+  color: #333;
+  margin-bottom: 10rpx;
+}
+
+.subfield {
+  font-size: 24rpx;
+  color: #666;
+  margin-bottom: 8rpx;
+}
+
+.line-1 {
+  overflow: hidden;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+}
+
+.footer {
+  position: fixed;
+  bottom: 0;
+  left: 0;
+  right: 0;
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  padding: 20rpx;
+  background-color: #fff;
+  border-top: 1rpx solid #e8e8e8;
+  box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.1);
+}
+
+.count {
+  font-size: 28rpx;
+  color: #333;
+}
+
+.but {
+  width: 180rpx;
+  height: 80rpx;
+  line-height: 80rpx;
+  border-radius: 8rpx !important;
+  font-size: 32rpx;
+  background-color: #3874F6;
+  color: #fff;
+}

+ 33 - 0
CRM/contract/modules/templateSelect/index.wxml

@@ -0,0 +1,33 @@
+<van-search class="search" value="{{ condition }}" shape="round" placeholder="请输入模版名称" bind:search='startSearch' bind:clear='onClear' />
+<view class="total">共{{total}}个</view>
+<Yl_ListBox id='ListBox' bind:getlist='getList'>
+  <view class="list-item" wx:for="{{list}}" wx:key="sa_esign_contract_templateid">
+    <navigator url="#" class="main" data-id="{{item.sa_esign_contract_templateid}}" data-item="{{item}}" bindtap="changeResult">
+      <view class="checkbox">
+        <van-checkbox value="{{ handle.isCheck(item.sa_esign_contract_templateid, result) }}" shape="square" icon-size='28rpx' />
+      </view>
+      <view class="dec">
+        <view class="title line-1">{{item.name || '--'}}</view>
+        <view class="subfield line-1">合同类型:{{item.contract_type || '--'}}</view>
+        <view class="subfield">创建时间:{{item.create_time || '--'}}</view>
+      </view>
+    </navigator>
+  </view>
+  <view style="height: 130rpx;" />
+  <Yl_Empty wx:if="{{list.length==0}}" />
+</Yl_ListBox>
+
+<view class="footer">
+  <view class="count">已选:{{result.length}}</view>
+  <van-button custom-class='but' color='#3874F6' disabled='{{result.length==0}}' bind:click="submit">确定</van-button>
+</view>
+
+<wxs module="handle">
+  module.exports = {
+    isCheck: function (id, list) {
+      return list.some(function (v) {
+        return v == id
+      });
+    },
+  }
+</wxs>

+ 1 - 1
pages/index/index.js

@@ -237,7 +237,7 @@ Page({
 					path: "/CRM/lead/index",
 					icon: "work-xiaoshouxiansuo"
 				}, {
-					name: "合同",
+					name: "合同任务",
 					key: "wcrmsign",
 					path: "/CRM/contract/index",
 					icon: "work-hehuoren"

+ 6 - 6
select/agent/index.js

@@ -83,15 +83,16 @@ Page({
       }
       console.log(obj);
     getApp().globalData.handleSelect && getApp().globalData.handleSelect(obj)
+    wx.navigateBack();
   },
   /* 开始搜索 */
-  startSearch({
-    detail
-  }) {
-    let condition = this.data.content ? this.data.content.where.condition : this.data.params.content.where.condition;
+  startSearch(e) {
+    let detail = e.detail;
+    // blur事件e.detail是{value: "..."},search事件e.detail是字符串
+    if (typeof detail === 'object' && detail.value !== undefined) detail = detail.value;
+    let condition = this.data.params.content.where.condition;
     if (detail == condition) return;
     this.setData({
-      'content.where.condition': detail,
       'params.content.where.condition': detail
     });
     this.getList(true);
@@ -99,7 +100,6 @@ Page({
   /* 取消搜索 */
   onClear() {
     this.setData({
-      'content.where.condition': "",
       'params.content.where.condition': ""
     });
     this.getList(true);

+ 2 - 1
select/agent/index.json

@@ -1,3 +1,4 @@
 {
-  "usingComponents": {}
+  "usingComponents": {},
+  "navigationBarTitleText": "选择经销商"
 }

+ 4 - 4
select/agent/index.wxml

@@ -1,7 +1,7 @@
 <import src="index.skeleton.wxml" />
 <template is="skeleton" wx:if="{{loading}}" />
 
-<van-search class="search" value="{{ params.content.where.condition }}" shape="round" placeholder="请输入搜索关键词" bind:search='startSearch' bind:clear='onClear' />
+<van-search class="search" value="{{ params.content.where.condition }}" shape="round" placeholder="请输入搜索关键词" bind:search='startSearch' bind:blur='startSearch' bind:clear='onClear' />
 <view class="total">共{{params.content.total}}个</view>
 
 <Yl_ListBox id='ListBox' bind:getlist='getList'>
@@ -10,13 +10,13 @@
         <view class="main" style="padding-left: {{!radio?'10rpx':''}};">
             <view class="title line-1">{{item.enterprisename || ' --'}}</view>
             <view class="subfield line-1">
-                经销商编号:{{item.agentnum||' --'}}
+                简称:{{item.abbreviation || ' --'}} | 编号:{{item.agentnum || ' --'}}
             </view>
             <view class="subfield line-1">
-                联系人:{{item.contact}} {{item.phonenumber}}
+                区域:{{item.salearea || ' --'}} | {{item.type || ' --'}}
             </view>
             <view class="subfield line-1">
-                地址:{{item.province?item.province + item.city + item.county +item.address:item.address||' --'}}
+                状态:{{item.signingstate || ' --'}}
             </view>
         </view>
     </navigator>