Explorar o código

新增:微信小程序设置项《发货信息管理》

萤火科技 hai 1 ano
pai
achega
7d21487391

+ 22 - 0
src/common/model/client/wxapp/setting.js

@@ -0,0 +1,22 @@
+import * as Api from '@/api/client/wxapp/setting'
+
+/**
+ * 微信小程序设置 model类
+ * WxappSettingModel
+ */
+
+// 获取微信小程序设置 (指定项)
+const item = key => {
+  return new Promise((resolve, reject) => {
+    Api.detail(key).then(result => resolve(result.data.detail))
+  })
+}
+
+// 是否开启发货信息管理
+const isEnableShipping = () => {
+  return new Promise((resolve, reject) => {
+    item('basic').then(data => resolve(Boolean(data.enableShipping)))
+  })
+}
+
+export default { item, isEnableShipping }

+ 10 - 1
src/views/client/wxapp/Setting.vue

@@ -29,6 +29,15 @@
             <small>登录微信小程序平台,开发 - 开发管理 - 开发设置,记录AppSecret (小程序密钥)</small>
           </p>
         </a-form-item>
+        <a-form-item label="发货信息管理" :labelCol="labelCol" :wrapperCol="wrapperCol">
+          <a-radio-group v-decorator="['enableShipping', { rules: [{ required: true }] }]">
+            <a-radio :value="true">开启</a-radio>
+            <a-radio :value="false">关闭</a-radio>
+          </a-radio-group>
+          <p class="form-item-help">
+            <small>登录微信小程序平台,在功能菜单中查找是否存在《发货信息管理》,如果存在则需开启</small>
+          </p>
+        </a-form-item>
 
         <a-divider orientation="left">授权域名设置</a-divider>
         <a-form-item
@@ -130,7 +139,7 @@ export default {
     setFieldsValue () {
       const { record, $nextTick, form } = this
       !isEmpty(form.getFieldsValue()) && $nextTick(() => {
-        form.setFieldsValue(pick(record, ['enabled', 'app_id', 'app_secret']))
+        form.setFieldsValue(pick(record, ['enabled', 'app_id', 'app_secret', 'enableShipping']))
       })
     },
 

+ 39 - 26
src/views/order/modules/DeliveryForm.vue

@@ -1,7 +1,7 @@
 <template>
   <a-modal
     :title="title"
-    :width="680"
+    :width="width"
     :visible="visible"
     :isLoading="isLoading"
     :confirmLoading="isLoading"
@@ -17,7 +17,12 @@
         :label-col="labelCol"
         :wrapperCol="wrapperCol"
       >
-        <a-tabs v-model="tabKey">
+        <!-- 实物订单 -->
+        <a-tabs
+          v-if="record.order_type == OrderTypeEnum.PHYSICAL.value"
+          class="physical"
+          v-model="tabKey"
+        >
           <a-tab-pane :key="1" tab="未发货的商品">
             <a-table
               rowKey="order_goods_id"
@@ -80,7 +85,7 @@
             </div>
 
             <div
-              v-if="record.pay_method === PaymentMethodEnum.WECHAT.value && record.platform === ClientEnum.MP_WEIXIN.value"
+              v-if="isEnableShipping && record.pay_method === PaymentMethodEnum.WECHAT.value && record.platform === ClientEnum.MP_WEIXIN.value"
             >
               <a-form-model-item label="同步微信平台" prop="syncMpWeixinShipping" required>
                 <a-radio-group v-model="formData.syncMpWeixinShipping">
@@ -88,7 +93,7 @@
                   <a-radio :value="0">不同步</a-radio>
                 </a-radio-group>
                 <div class="form-item-help">
-                  <p class="extra">同步至微信小程序平台的《发货信息录入》</p>
+                  <p class="extra">同步至微信小程序平台的《发货信息管理》</p>
                   <p class="extra">仅全部发货或最后一次发货时同步</p>
                 </div>
               </a-form-model-item>
@@ -131,9 +136,10 @@
 import { assignment } from '@/utils/util'
 import * as Api from '@/api/order/delivery'
 import * as ExpressApi from '@/api/setting/express'
+import WxappSettingModel from '@/common/model/client/wxapp/setting'
 import ClientEnum from '@/common/enum/Client'
 import { PaymentMethodEnum } from '@/common/enum/payment'
-import { DeliveryStatusEnum } from '@/common/enum/order'
+import { DeliveryStatusEnum, OrderTypeEnum } from '@/common/enum/order'
 import { GoodsItem } from '@/components/Table'
 
 const columns1 = [
@@ -197,6 +203,8 @@ export default {
       visible: false,
       // modal(对话框)确定按钮 loading
       isLoading: false,
+      // 对话框宽度
+      width: 680,
       // 商品表格字段
       columns1,
       columns2,
@@ -220,11 +228,13 @@ export default {
         expressId: undefined,
         // 物流单号
         expressNo: '',
-        // 同步至微信小程序《发货信息录入》
+        // 同步至微信小程序《发货信息管理》
         syncMpWeixinShipping: 1,
       },
       // 选择的商品
       selectedRowKeys: [],
+      // 是否开启发货信息管理
+      isEnableShipping: false
     }
   },
   computed: {
@@ -266,10 +276,7 @@ export default {
   },
   beforeCreate () {
     // 批量给当前实例赋值
-    assignment(this, {
-      ClientEnum,
-      PaymentMethodEnum
-    })
+    assignment(this, { ClientEnum, PaymentMethodEnum, OrderTypeEnum })
   },
   created () {
     // 获取物流公司列表
@@ -278,19 +285,23 @@ export default {
   methods: {
 
     // 显示对话框
-    show (record) {
+    async show (record) {
       // 当前记录
       this.record = record
-      if (record.order_type == 10) {
+      // 是否开启发货信息管理
+      this.isEnableShipping = await WxappSettingModel.isEnableShipping()
+      // 显示窗口
+      this.visible = true
+      this.tabKey = 1
+      // 判断订单类型
+      if (record.order_type == OrderTypeEnum.PHYSICAL.value) {
         this.showModalByPhysical()
       }
     },
 
     // 对话框:实物订单
     showModalByPhysical () {
-      // 显示窗口
-      this.visible = true
-      // 未发货的model记录
+      this.width = 680
       this.initPackGoodsData()
     },
 
@@ -318,20 +329,22 @@ export default {
     // 确认按钮
     handleSubmit (e) {
       e.preventDefault()
-      this.tabKey = 1
-      // 验证是否选择了商品
-      if (!this.selectedRowKeys.length) {
-        this.$message.error('您还没有选择要发货的商品')
-        return false
+      const app = this
+      app.tabKey = 1
+      // 实物订单
+      if (app.record.order_type == OrderTypeEnum.PHYSICAL.value) {
+        // 验证是否选择了商品
+        if (!app.selectedRowKeys.length) {
+          app.$message.error('您还没有选择要发货的商品')
+          return false
+        }
+        // 生成分包商品数据
+        app.formData.packGoodsData = app.packGoodsData.filter(item => app.selectedRowKeys.includes(item.orderGoodsId))
       }
-      // 生成分包商品数据
-      this.formData.packGoodsData = this.packGoodsData.filter(item => {
-        return this.selectedRowKeys.includes(item.orderGoodsId)
-      })
       // 表单验证
-      this.$refs.ruleForm.validate(valid => {
+      app.$refs.ruleForm.validate(valid => {
         // 提交到后端api
-        valid && this.onFormSubmit()
+        valid && app.onFormSubmit()
       })
     },