|
|
@@ -0,0 +1,238 @@
|
|
|
+Page({
|
|
|
+ data: {
|
|
|
+ taskId: '',
|
|
|
+ detail: {},
|
|
|
+ list: [],
|
|
|
+ showAddDistributor: false,
|
|
|
+ showEditTerm: false,
|
|
|
+ distributorList: [],
|
|
|
+ selectedDistributors: [],
|
|
|
+ beginDate: '',
|
|
|
+ endDate: '',
|
|
|
+ currentDetailId: ''
|
|
|
+ },
|
|
|
+
|
|
|
+ onLoad(options) {
|
|
|
+ this.setData({ taskId: options.id });
|
|
|
+ this.loadTaskDetail();
|
|
|
+ this.loadDetailList();
|
|
|
+ },
|
|
|
+
|
|
|
+ loadTaskDetail() {
|
|
|
+ getApp().globalData.http.basic({
|
|
|
+ id: '2026041309443002',
|
|
|
+ content: {
|
|
|
+ sa_esign_contract_taskid: this.data.taskId
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ if (res.msg === '成功') {
|
|
|
+ this.setData({ detail: res.data || {} });
|
|
|
+ } else {
|
|
|
+ wx.showToast({ title: res.msg || '加载详情失败', icon: 'none' });
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ 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' });
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ addDistributor() {
|
|
|
+ this.loadDistributorList();
|
|
|
+ this.setData({ showAddDistributor: true, selectedDistributors: [] });
|
|
|
+ },
|
|
|
+
|
|
|
+ closeAddDistributor() {
|
|
|
+ this.setData({ showAddDistributor: false });
|
|
|
+ },
|
|
|
+
|
|
|
+ loadDistributorList() {
|
|
|
+ getApp().globalData.http.basic({
|
|
|
+ id: '2026041315545602',
|
|
|
+ content: {
|
|
|
+ sa_esign_contract_taskid: this.data.taskId,
|
|
|
+ pageNumber: 1,
|
|
|
+ pageSize: 100
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ if (res.msg === '成功') {
|
|
|
+ this.setData({ distributorList: res.data || [] });
|
|
|
+ } else {
|
|
|
+ wx.showToast({ title: res.msg || '加载经销商列表失败', icon: 'none' });
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ 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 });
|
|
|
+ },
|
|
|
+
|
|
|
+ confirmAddDistributor() {
|
|
|
+ if (this.data.selectedDistributors.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' });
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ wx.showToast({ title: '添加失败', icon: 'none' });
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ publishTask() {
|
|
|
+ getApp().globalData.http.basic({
|
|
|
+ id: '2026041309482202',
|
|
|
+ content: {
|
|
|
+ sa_esign_contract_taskid: this.data.taskId
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ if (res.msg === '成功') {
|
|
|
+ wx.showToast({ title: '发布成功', icon: 'success' });
|
|
|
+ this.loadTaskDetail();
|
|
|
+ } else {
|
|
|
+ wx.showToast({ title: res.msg || '发布失败', icon: 'none' });
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ wx.showToast({ title: '发布失败', icon: 'none' });
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ withdrawTask() {
|
|
|
+ getApp().globalData.http.basic({
|
|
|
+ id: '2026041309485902',
|
|
|
+ content: {
|
|
|
+ sa_esign_contract_taskid: this.data.taskId
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ if (res.msg === '成功') {
|
|
|
+ wx.showToast({ title: '撤回成功', icon: 'success' });
|
|
|
+ this.loadTaskDetail();
|
|
|
+ } else {
|
|
|
+ wx.showToast({ title: res.msg || '撤回失败', icon: 'none' });
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ wx.showToast({ title: '撤回失败', icon: 'none' });
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ editTerm(e) {
|
|
|
+ const detailId = e.currentTarget.dataset.id;
|
|
|
+ this.setData({ showEditTerm: true, currentDetailId: detailId, beginDate: '', endDate: '' });
|
|
|
+ },
|
|
|
+
|
|
|
+ closeEditTerm() {
|
|
|
+ this.setData({ showEditTerm: false });
|
|
|
+ },
|
|
|
+
|
|
|
+ selectBeginDate() {
|
|
|
+ wx.datePicker({
|
|
|
+ start: '2020-01-01',
|
|
|
+ end: '2030-12-31',
|
|
|
+ success: (res) => {
|
|
|
+ this.setData({ beginDate: res.value });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ selectEndDate() {
|
|
|
+ wx.datePicker({
|
|
|
+ start: '2020-01-01',
|
|
|
+ end: '2030-12-31',
|
|
|
+ success: (res) => {
|
|
|
+ this.setData({ endDate: res.value });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ confirmEditTerm() {
|
|
|
+ if (!this.data.beginDate || !this.data.endDate) {
|
|
|
+ wx.showToast({ title: '请选择日期', icon: 'none' });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ getApp().globalData.http.basic({
|
|
|
+ id: '2026041415245302',
|
|
|
+ content: {
|
|
|
+ sa_esign_contract_taskmxids: [this.data.currentDetailId],
|
|
|
+ begindate: this.data.beginDate,
|
|
|
+ enddate: this.data.endDate
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ if (res.msg === '成功') {
|
|
|
+ wx.showToast({ title: '修改成功', icon: 'success' });
|
|
|
+ this.closeEditTerm();
|
|
|
+ this.loadDetailList();
|
|
|
+ } else {
|
|
|
+ wx.showToast({ title: res.msg || '修改失败', icon: 'none' });
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ wx.showToast({ title: '修改失败', icon: 'none' });
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ deleteDetail(e) {
|
|
|
+ const detailId = e.currentTarget.dataset.id;
|
|
|
+ wx.showModal({
|
|
|
+ title: '确认删除',
|
|
|
+ content: '确定要删除这个经销商吗?',
|
|
|
+ success: (res) => {
|
|
|
+ if (res.confirm) {
|
|
|
+ getApp().globalData.http.basic({
|
|
|
+ id: '2026041315414702',
|
|
|
+ content: {
|
|
|
+ sa_esign_contract_taskmxids: [detailId]
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ if (res.msg === '成功') {
|
|
|
+ wx.showToast({ title: '删除成功', icon: 'success' });
|
|
|
+ this.loadDetailList();
|
|
|
+ } else {
|
|
|
+ wx.showToast({ title: res.msg || '删除失败', icon: 'none' });
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ wx.showToast({ title: '删除失败', icon: 'none' });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+});
|