| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- const _Http = getApp().globalData.http;
- Page({
- data: {
- loading: false,
- disabled: true,
- showAll: false,
- selectedProducts: [],
- sa_orderid: null,
- today: '',
- form: [{
- label: "服务类型",
- error: false,
- errMsg: "",
- hint: "",
- type: "radio",
- value: "",
- radioList: [],
- valueName: "typeclass", //绑定的字段名称
- required: true, //必填
- checking: `base`,
- }, {
- label: "原因描写",
- error: false,
- errMsg: "",
- type: "textarea",
- value: "",
- placeholder: "请填写",
- valueName: "remarks",
- required: true,
- checking: "base"
- }]
- },
- onLoad(options) {
- // 设置今天的日期,用于日期选择器的start值
- const today = new Date();
- const year = today.getFullYear();
- const month = String(today.getMonth() + 1).padStart(2, '0');
- const day = String(today.getDate()).padStart(2, '0');
- const todayStr = `${year}-${month}-${day}`;
- this.setData({
- sa_orderid: options.id,
- today: todayStr
- });
- this.getDetail();
- getApp().globalData.Language.getLanguagePackage(this, '订单变更申请');
- const form = this.data.form;
- _Http.basic({
- "classname": "sysmanage.develop.optiontype.optiontype",
- "method": "optiontypeselect",
- "content": {
- "pageNumber": 1,
- "pageSize": 1000,
- "typename": "orderchangereason",
- },
- }).then(res => {
- console.log("变更类型", res)
- if (res.code == 1) {
- let data = form.find(v => v.valueName == 'typeclass');
- data.radioList = res.data.map(v => {
- return {
- id: v.value,
- name: v.value,
- }
- });;
- data.value = data.value || data.radioList[0].id;
- this.setData({
- form
- })
- }
- })
- },
- getDetail() {
- // 从详情页面获取选中的商品
- let pages = getCurrentPages();
- let detailPage = pages.find(v => v.__route__ == 'packageA/orderForm/detail');
- this.setData({
- selectedProducts: detailPage.data.selectedProducts || []
- });
- if (this.data.selectedProducts.length == 0) {
- wx.showToast({
- title: '请先选择要变更的商品',
- icon: 'none'
- });
- setTimeout(() => {
- wx.navigateBack();
- }, 1000);
- }
- },
- onConfirm({
- detail
- }) {
- this.setData({
- disabled: detail
- })
- },
- /* 处理变更数量 */
- onChangeValue(e) {
- const {
- index
- } = e.currentTarget.dataset;
- const value = e.detail.value;
- let selectedProducts = [...this.data.selectedProducts];
- selectedProducts[index].newvalue = value;
- this.setData({
- selectedProducts
- });
- },
- /* 处理变更交期 */
- onChangeDate(e) {
- const {
- index
- } = e.currentTarget.dataset;
- const value = e.detail.value;
- let selectedProducts = [...this.data.selectedProducts];
- selectedProducts[index].newdeliverydate = value;
- this.setData({
- selectedProducts
- });
- },
- /* 取消按钮点击事件 */
- cancel() {
- wx.showModal({
- title: '提示',
- content: '确定要取消订单变更申请吗?',
- cancelText: '取消',
- confirmText: '确定',
- success: (res) => {
- if (res.confirm) {
- wx.navigateBack();
- }
- }
- });
- },
- /* 提交按钮点击事件 */
- submit() {
- // 二次确认
- wx.showModal({
- title: '提示',
- content: '确定要提交订单变更申请吗?',
- cancelText: '取消',
- confirmText: '确定',
- success: (res) => {
- if (res.confirm) {
- this.doSubmit();
- }
- }
- });
- },
- /* 执行提交操作 */
- doSubmit() {
- // 提交申请
- this.setData({
- loading: true,
- disabled: true
- });
- // 构建itemifnos数组
- let itemifnos = this.data.selectedProducts.map(item => {
- return {
- sa_orderitemsid: item.sa_orderitemsid,
- itemid: item.itemid,
- newvalue: item.newvalue || item.qty,
- newdeliverydate: item.newdeliverydate || item.deliverydate || ''
- };
- });
- _Http.basic({
- "id": "2026033114502902",
- "content": {
- sa_orderid: this.data.sa_orderid,
- type: "",
- ...this.selectComponent("#Form").submit(),
- itemifnos
- }
- }).then(res => {
- console.log('提交订单变更申请', res);
- this.setData({
- loading: false,
- disabled: false
- });
- if (res.code == '1') {
- // 获取详情页面实例
- let pages = getCurrentPages();
- let detailPage = pages.find(v => v.__route__ == 'packageA/orderForm/detail');
- if (detailPage) {
- // 调用详情页面的getDetail方法更新数据
- detailPage.getDetail(false, false);
- }
- // 先返回详情页面,在回调中显示提示
- wx.navigateBack({
- success: () => {
- // 显示提交成功的提示
- wx.showToast({
- title: '提交成功',
- icon: 'success'
- });
- }
- });
- } else {
- wx.showToast({
- title: res.msg,
- icon: 'none'
- });
- }
- }).catch(err => {
- console.error('提交订单变更申请失败', err);
- this.setData({
- loading: false,
- disabled: false
- });
- wx.showToast({
- title: '提交失败,请重试',
- icon: 'none'
- });
- });
- }
- })
|