Browse Source

feat: 编辑订单逻辑添加

cuiyalong 3 months ago
parent
commit
1af8a1d07e
26 changed files with 563 additions and 94 deletions
  1. 6 3
      src/store/order.js
  2. 5 0
      src/views/create-order/components/ProductInfoCard.vue
  3. 26 5
      src/views/create-order/components/ProductInfoCardList.vue
  4. 1 1
      src/views/create-order/components/baseInfoModule.vue
  5. 8 1
      src/views/create-order/components/contractInfoModule.vue
  6. 3 6
      src/views/create-order/components/create.vue
  7. 163 0
      src/views/create-order/components/edit.vue
  8. 14 6
      src/views/create-order/components/product-info-submodule/ContractAmount.vue
  9. 7 0
      src/views/create-order/components/product-info-submodule/ProductTypeSelector.vue
  10. 5 1
      src/views/create-order/components/product-info-submodule/ValidityDateTime.vue
  11. 7 1
      src/views/create-order/components/productInfoModule.vue
  12. 2 1
      src/views/create-order/components/schema-form/params/common.js
  13. 41 0
      src/views/create-order/components/schema-form/resort/bigmember.js
  14. 108 0
      src/views/create-order/components/schema-form/resort/common.js
  15. 18 0
      src/views/create-order/components/schema-form/resort/data-count-pack.js
  16. 48 6
      src/views/create-order/components/schema-form/resort/index.js
  17. 5 0
      src/views/create-order/components/schema-form/resort/marketing.js
  18. 13 0
      src/views/create-order/components/schema-form/resort/one-spec.js
  19. 13 0
      src/views/create-order/components/schema-form/resort/svip.js
  20. 23 3
      src/views/create-order/components/schema-form/schema-form.vue
  21. 0 2
      src/views/create-order/data/interface.js
  22. 1 1
      src/views/create-order/data/var.js
  23. 17 9
      src/views/create-order/hooks/utils.js
  24. 21 23
      src/views/order/components/OrderReviewCard.vue
  25. 4 6
      src/views/order/components/OrderReviewDialog.vue
  26. 4 19
      src/views/order/orderReview.vue

+ 6 - 3
src/store/order.js

@@ -480,16 +480,16 @@ export default {
           return data
         } else {
           showNotify({ message: msg })
-          return 0
+          return ''
         }
       } catch (error) {
         console.log(error)
-        return 0
+        return ''
       }
     },
     async createOrder({ state, commit, getters }, payload = {}) {
       // save 1-暂存 2-提交
-      const { save } = payload
+      const { save, orderCode } = payload
       const pass = await checkRequired({
         pageForm: state.pageForm,
         productInfoList: state.orderInfo.productInfoList,
@@ -508,6 +508,9 @@ export default {
         throw new Error("参数为空")
       }
       params.save = save
+      if (orderCode) {
+        params.orderCode = orderCode
+      }
       commit('setLoadingState', { key: 'create', value: true })
       try {
         const { error_code: code, error_msg: msg, data } = await ajaxCreateOrder(params)

+ 5 - 0
src/views/create-order/components/ProductInfoCard.vue

@@ -22,6 +22,7 @@
               :productInfo="productTypeInfo"
               :value="productForm"
               :index="index"
+              :readonly="readonly"
               @input="onSchemaFormChange"
               @loading="changeLoading"
             />
@@ -52,6 +53,10 @@ export default {
       type: [String, Number],
       default: '0'
     },
+    readonly: {
+      type: Boolean,
+      default: false,
+    },
   },
   data() {
     return {

+ 26 - 5
src/views/create-order/components/ProductInfoCardList.vue

@@ -18,6 +18,7 @@
         <ProductInfoCard
           ref="productInfoCard"
           :index="index"
+          :readonly="readonly"
           @power="onProductInfoCardPowerCheck($event, index)"
         />
       </template>
@@ -40,7 +41,7 @@
       </div>
     </div> -->
     <div class="product-module product-actions">
-      <el-button size="medium" class="highlight-button" plain icon="el-icon-plus" @click="addProduct">添加产品</el-button>
+      <el-button size="medium" class="highlight-button" plain icon="el-icon-plus" @click="addProduct" v-if="showAddProductButton">添加产品</el-button>
     </div>
   </div>
 </template>
@@ -49,9 +50,11 @@
 import ProductInfoCard from './ProductInfoCard.vue'
 import ProductCard from '../ui/ProductCard.vue'
 import { mapState } from 'vuex'
+import { pageFormState } from '@/views/create-order/mixins'
 
 export default {
   name: 'ProductInfoCardList',
+  mixins: [pageFormState],
   components: {
     ProductCard,
     ProductInfoCard,
@@ -61,15 +64,31 @@ export default {
       type: String,
       default: ''
     },
+    readonly: {
+      type: Boolean,
+      default: false,
+    },
   },
   computed: {
     ...mapState({
-      pageForm: state => state.order.orderInfo.pageForm,
       productCardList: state => state.order.orderInfo.productInfoList
     }),
+    showAddProductButton() {
+      return !this.readonly
+    },
+    buySubject() {
+      return this.pageForm.buySubject
+    }
+  },
+  watch: {
+    buySubject: {
+      immediate: true,
+      handler() {
+        this.getProductList()
+      }
+    }
   },
   created() {
-    this.getProductList()
     this.addProduct()
   },
   methods: {
@@ -99,8 +118,10 @@ export default {
       }
     },
     showProductDelete() {
-      // 第一个产品不展示删除按钮
-      return this.productCardList.length > 1
+      if (this.readonly) {
+        return false
+      }
+      return true
     },
     isActivityProduct(index) {
       const t = this.productCardList[index]

+ 1 - 1
src/views/create-order/components/baseInfoModule.vue

@@ -47,7 +47,7 @@
         <el-input
           :value="form.accountTel"
           @input="onElInput($event, 'accountTel')"
-          placeholder="请输入联系人手机号"
+          placeholder="请输入开通权益手机号"
           size="medium"
           maxlength="11"
         ></el-input>

+ 8 - 1
src/views/create-order/components/contractInfoModule.vue

@@ -173,7 +173,14 @@ export default {
     ElOnlineContractForm,
     RadioGroup
   },
+  props: {
+    readonly: {
+      type: Boolean,
+      default: false,
+    },
+  },
   data() {
+    const defaultShowMoreXieYi = this.readonly
     return {
       conf: {
         agreeStatusOptions,
@@ -192,7 +199,7 @@ export default {
         signRemark: '',
         signType: '2',
       },
-      showMoreXieYi: false,
+      showMoreXieYi: defaultShowMoreXieYi,
       // 电子协议相关
       e_: {
         // contract_type: 1, // 电子协议类型

+ 3 - 6
src/views/create-order/components/create.vue

@@ -4,10 +4,10 @@
       <BaseInfo ref="moduleBaseInfo" />
     </ModuleCard>
     <ModuleCard class="create-order-module" title="产品信息">
-      <ProductInfoModule ref="moduleProductInfo" />
+      <ProductInfoModule ref="moduleProductInfo" :readonly="readonly" />
     </ModuleCard>
     <ModuleCard class="create-order-module" title="协议信息">
-      <ContractInfoModule ref="moduleContractInfo" />
+      <ContractInfoModule ref="moduleContractInfo" :readonly="readonly" />
     </ModuleCard>
     <!-- 合同金额为0,则不展示回款计划模块 -->
     <ModuleCard class="create-order-module" title="回款计划" v-if="showOrderMoney0Type">
@@ -59,10 +59,7 @@ export default {
     readonly: {
       type: Boolean,
       default: false,
-    }
-  },
-  data() {
-    return {}
+    },
   },
   computed: {
     ...mapState({

+ 163 - 0
src/views/create-order/components/edit.vue

@@ -0,0 +1,163 @@
+<template>
+  <div class="edit-order-content-container">
+    <createOrder ref="createOrder" :readonly="readonlyC" />
+  </div>
+</template>
+
+<script>
+import createOrder from './create.vue'
+import { mapState, mapActions } from 'vuex'
+import { pageFormState } from '@/views/create-order/mixins'
+import { ajaxGetOrderDetail } from '@/api/modules'
+import { showMessage, showNotify } from '@/views/create-order/hooks/toast'
+
+export default {
+  name: 'EditOrderContent',
+  mixins: [pageFormState],
+  components: {
+    createOrder,
+  },
+  props: {
+    type: {
+      type: String,
+      default: 'create',
+      validator(v) {
+        return ['create', 'edit', 'read'].includes(v)
+      }
+    },
+    orderCode: {
+      type: String,
+      default: '',
+    },
+    readonly: {
+      type: Boolean,
+      default: false,
+    },
+    autoGetDetail: {
+      type: Boolean,
+      default: false,
+    },
+  },
+  computed: {
+    ...mapState({
+      pageForm: state => state.order.pageForm,
+    }),
+    readonlyC() {
+      return this.type === 'read' || this.readonly
+    }
+  },
+  watch: {
+    orderCode: {
+      immediate: true,
+      handler(n) {
+        this.getOrderDetail(n)
+      }
+    }
+  },
+  methods: {
+    ...mapActions('order', ['createOrder', 'resetPageInfo', 'restorePageInfo']),
+    async getOrderDetail(orderCode) {
+      if (!orderCode) return
+      this.resetPageInfo()
+      const { error_code: code, data, error_msg: msg } = await ajaxGetOrderDetail({ orderCode })
+      if (code === 0) {
+        if (data) {
+          this.restorePageInfo(data)
+          this.emitDetail(data)
+        } else {
+          showNotify({ message: '未查询到订单数据' })
+        }
+      } else {
+        if (msg) {
+          showNotify({ message: msg || '获取订单详情失败' })
+        }
+      }
+    },
+    emitDetail(order) {
+      this.$emit('detail', order)
+    },
+    getFormRefs() {
+      return this.$refs.createOrder.getFormRefs()
+    },
+    async doSave(save) {
+      if (!this.orderCode) {
+        return console.error('未传入orderCode')
+      }
+      const id = await this.createOrder({ save, orderCode: this.orderCode })
+      if (id) {
+        this.$toast('订单创建成功')
+      }
+    },
+    async submit() {
+      // 提交
+      await this.doSave(2)
+      this.resetPageInfo()
+    },
+    async stash() {
+      // 暂存
+      await this.doSave(1)
+      this.resetPageInfo()
+    },
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+::v-deep {
+  .el-form-item {
+    margin-bottom: 12px;
+  }
+  .el-form-item__label {
+    color: #686868;
+  }
+  .el-form-item__error {
+    padding-top: 0;
+  }
+
+  .el-select-w100.el-select {
+    width: 100%;
+  }
+
+  .el-input__inner,
+  .el-textarea__inner {
+    color: $gray_10;
+    // &:focus {
+    //   outline: 0;
+    //   box-shadow: 0 0 0 2px rgba($main,.2);
+    // }
+  }
+
+  .form-item-container {
+    font-size: 14px;
+    line-height: 22px;
+    .form-item-label {
+      color: #686868;
+    }
+    .form-item-value {
+      color: $gray_10;
+    }
+  }
+}
+
+.create-order-content-container {
+  position: relative;
+  
+  &.readonly {
+    // &::after,
+    .readonly-overlay {
+      content: '';
+      position: absolute;
+      left: 0;
+      right: 0;
+      top: 0;
+      bottom: 0;
+      z-index: 99999;
+      /* 遮罩层显示时捕获所有指针事件 */
+      pointer-events: auto;
+    }
+  }
+}
+.create-order-module {
+  font-size: 14px;
+}
+</style>

+ 14 - 6
src/views/create-order/components/product-info-submodule/ContractAmount.vue

@@ -14,7 +14,7 @@
       <span class="sub-info-item no-amount-money" v-if="noStandardMoney">该产品暂无法计算标准售价</span>
       <span class="sub-info-item form-item-container" v-else>
         <span class="form-item-label">标准售价:</span>
-        <span class="form-item-value">{{ formatMoney(standardMoney || '') }}</span>
+        <span class="form-item-value">{{ formatMoney(standardMoney) }}</span>
       </span>
       <span class="sub-info-item form-item-container">
         <span class="form-item-label">折扣率:</span>
@@ -29,6 +29,10 @@ import NumberInput from '@/views/create-order/ui/NumberInput.vue'
 import { currencyFormat } from '@/utils/str'
 import { calcDiscountRate } from '@/utils/number'
 
+function hasValue (t) {
+  return t !== null && t !== undefined && t !== ''
+}
+
 export default {
   name: 'ContractAmount',
   props: {
@@ -85,8 +89,8 @@ export default {
         return
       }
       const { contractMoney, standardMoney } = e
-      this.contractMoney = contractMoney || ''
-      this.standardMoney = standardMoney || ''
+      this.contractMoney = hasValue(contractMoney) ? contractMoney : ''
+      this.standardMoney = hasValue(standardMoney) ? standardMoney : ''
     },
     onChange() {
       const e = this.getState()
@@ -99,11 +103,15 @@ export default {
       return currencyFormat(val)
     },
     formatMoney(val) {
-      val = val - 0
-      if (val && !isNaN(val)) {
+      if (typeof val === 'number') {
         return this.located(val)
       } else {
-        return '-'
+        const nVal = val - 0
+        if (nVal && !isNaN(nVal)) {
+          return this.located(val)
+        } else {
+          return '-'
+        }
       }
     }
   }

+ 7 - 0
src/views/create-order/components/product-info-submodule/ProductTypeSelector.vue

@@ -25,6 +25,7 @@
         :props="conf.cascaderProps"
         v-model="productType2"
         size="medium"
+        disabled
         @change="secondTypeChange"
         placeholder="请选择产品类型"
         filterable
@@ -99,6 +100,12 @@ export default {
         this.setState(n)
       },
     },
+    productTypeOptions: {
+      deep: true,
+      handler() {
+        this.setState(this.value)
+      },
+    },
   },
   data() {
     return {

+ 5 - 1
src/views/create-order/components/product-info-submodule/ValidityDateTime.vue

@@ -81,8 +81,12 @@ export default {
     },
     setState(e = {}) {
       if (!e) return
-      const { paybackOpenServer } = e
+      const { paybackOpenServer, start, end } = e
       this.paybackOpenServer = !!paybackOpenServer
+      if (start) {
+        this.datetimeStart = start
+        this.datetimeEnd = end
+      }
     },
     getState() {
       if (this.amountText) {

+ 7 - 1
src/views/create-order/components/productInfoModule.vue

@@ -2,7 +2,7 @@
   <!-- 产品信息 -->
   <div class="order-product-info-container">
     <div class="product-info-content">
-      <ProductInfoCardList ref="productionInfoCardList" />
+      <ProductInfoCardList :readonly="readonly" ref="productionInfoCardList" />
     </div>
     <div class="product-info-footer">
       <el-form ref="form" :model="form" :rules="rules" label-width="126px" class="order-base-info-container">
@@ -69,6 +69,12 @@ export default {
     ProductInfoCardList,
     NumberInput
   },
+  props: {
+    readonly: {
+      type: Boolean,
+      default: false,
+    },
+  },
   data() {
     return {
       conf: {

+ 2 - 1
src/views/create-order/components/schema-form/params/common.js

@@ -18,7 +18,8 @@ import { mul } from '@/utils/number'
 export function getCommonParams(pageForm, productInfo) {
   const productForm = productInfo?.productCardInfo?.form || {}
   const serviceType = productForm[schemaKeyMap.payment]
-  const linkedOrderId = productForm.relatedOrders.join('') - 0
+  const id = productForm.relatedOrders?.join('')
+  const linkedOrderId = id ? id - 0 : 0
   const paybackOpenServer = productForm.validityPeriod?.paybackOpenServer
   // const periodStart = productForm.validityPeriod?.start
   // const periodEnd = productForm.validityPeriod?.end

+ 41 - 0
src/views/create-order/components/schema-form/resort/bigmember.js

@@ -0,0 +1,41 @@
+import { sortValidityPeriod, sortSubAccountNumbers, getFilter } from './common'
+import { schemaKeyMap } from "@/views/create-order/data";
+import store from '@/store'
+
+function getCodeWithComboId(comboId) {
+  const bigServiceInfo = store.state.order.conf.bigServiceInfo || {}
+  if (Array.isArray(bigServiceInfo.comboLists) && bigServiceInfo.customService) {
+    const specList = bigServiceInfo.comboLists.concat(bigServiceInfo.customService)
+    const target = specList.filter(r => !!r).find(item => item.id === comboId)
+    if (target) {
+      return target.code
+    } else {
+      console.warn('恢复规格失败: 未找到匹配的大会员产品规格, comboId: ', comboId)
+    }
+  }
+}
+
+export function sortBigMemberProductFrom(product) {
+  const map = {}
+  
+  if (product.filter) {
+    const filter = getFilter(product)
+    // 周期
+    const period = sortValidityPeriod(filter)
+    Object.assign(map, period)
+
+    // 子账号数量
+    const sub = sortSubAccountNumbers(filter)
+    Object.assign(map, sub)
+
+    if (filter.comboId) {
+      map[schemaKeyMap.specification] = getCodeWithComboId(filter.comboId)
+    }
+
+    if (Array.isArray(filter.serviceIds)) {
+      map.serviceList = filter.serviceIds.map(id => Number(id))
+    }
+  }
+
+  return map
+}

+ 108 - 0
src/views/create-order/components/schema-form/resort/common.js

@@ -0,0 +1,108 @@
+import { productTypeMap, schemaKeyMap } from "@/views/create-order/data";
+import { div } from '@/utils/number'
+import dayjs from 'dayjs'
+
+export function getFilter(product = {}) {
+  const filter = {}
+  if (product.filter) {
+    try {
+      const f = JSON.parse(product.filter)
+      Object.assign(filter, f)
+    } catch (error) {
+      console.log(error)
+    }
+  }
+  return filter
+}
+
+// 根据 type(大会员) ->拿到 code(dyh)
+export function getProductCodeWithType(type) {
+  let r = undefined
+  for (const key in productTypeMap) {
+    const item = productTypeMap[key]
+    if (item === type) {
+      r = key
+      break
+    }
+  }
+  return r
+}
+
+export function sortCommonForm(product, order) {
+  const map = {}
+  // 销售策略saleGifts
+  if (product.tactics) {
+    map.saleGifts = product.tactics - 0
+  }
+  // 付费类型paymentType
+  if (product.service_type) {
+    map[schemaKeyMap.payment] = product.service_type - 0
+  }
+  // 关联订单relatedOrders
+
+  // 产品规格spec
+  if (product.product_code) {
+    map[schemaKeyMap.specification] = product.product_code
+  }
+
+  map.contractAmount = {
+    standardMoney: div(product.original_price, 100),
+    contractMoney: div(product.final_price, 100),
+  }
+
+  // 企业下
+  if(order && order.orderData && order.orderData.buy_subject === 2) {
+    if (product.filter) {
+      const filter = getFilter(product)
+      // 子账号数量
+      const sub = sortSubAccountNumbers(filter)
+      Object.assign(map, sub)
+    }
+  }
+
+  return map
+}
+
+export function sortSubAccountNumbers(filter = {}) {
+  return {
+    subAccountNumbers: {
+      payCount: filter.buyAccountCount || 0,
+      freeCount: filter.giftAccountCount || 0,
+    }
+  }
+}
+
+export function sortValidityPeriod(filter = {}) {
+  // 时间类有效周期
+  return {
+    validityPeriod: {
+      payCount: filter.buy_cycle,
+      payUnit: filter.buy_type,
+      freeCount: filter.give_cycle,
+      freeUnit: filter.give_type,
+      paybackOpenServer: false,
+    }
+  }
+}
+
+export function sortValidityCount(filter = {}) {
+  // 数据条数
+  return {
+    validityCount: {
+      payCount: filter.buy_cycle || filter.pNum,
+      freeCount: filter.give_cycle,
+    }
+  }
+}
+
+export function sortValidityDateTime(product = {}) {
+  // 时间类有效周期
+  return {
+    validityPeriod: {
+      start: dayjs(product.service_starttime).valueOf(),
+      end: dayjs(product.service_endtime).valueOf(),
+      paybackOpenServer: false,
+    }
+  }
+}
+

+ 18 - 0
src/views/create-order/components/schema-form/resort/data-count-pack.js

@@ -0,0 +1,18 @@
+import { sortValidityCount, sortValidityDateTime, getFilter } from './common'
+
+
+export function sortDataCountPackProductFrom(product) {
+  const map = {}
+  if (product.filter) {
+    const filter = getFilter(product)
+    // 数据条数
+    const p = sortValidityCount(filter)
+    Object.assign(map, p)
+  }
+
+  // 时间周期
+  const t = sortValidityDateTime(product)
+  Object.assign(map, t)
+
+  return map
+}

+ 48 - 6
src/views/create-order/components/schema-form/resort/index.js

@@ -1,11 +1,19 @@
 import { cloneDeep } from 'lodash'
 import { defaultPageFormValue, OrderProductCardItem, PayBackTableRow, SalePersonTableRow } from '@/views/create-order/data/interface'
 import { dateFormatter } from '@/utils/globalFun'
-import { payWayOptions } from '@/views/create-order/data/index.js'
+import { getProductCodeWithType, sortCommonForm } from './common'
+import { payWayOptions, productGroupKeyMap, productKeyMap } from '@/views/create-order/data/index.js'
 import { findUserInDeptTree, calcChannelSelectorList } from "@/views/create-order/hooks/utils"
 import dayjs from 'dayjs'
 import { div } from '@/utils/number'
 
+import { sortBigMemberProductFrom } from './bigmember'
+import { sortSvipProductFrom } from './svip'
+import { sortDataCountPackProductFrom } from './data-count-pack'
+import { sortMarketingProductFrom } from './marketing'
+import { sortOneSpecProductFrom } from './one-spec'
+
+
 function findItemInOptions(options, cb) {
   const t = options.find(r => cb(r))
   if (t) {
@@ -15,7 +23,6 @@ function findItemInOptions(options, cb) {
   }
 }
 
-
 // 将接口参数转换为store需要的参数
 export function sortOrderInfo(order = {}) {
   const pageFormValue = cloneDeep(defaultPageFormValue)
@@ -119,9 +126,11 @@ export function sortOrderInfo(order = {}) {
   let productArr = []
   if (Array.isArray(productData) && productData.length > 0) {
     productArr = productData.map(pd => {
-      const productForm = sortProductFormArr(pd)
+      const productCode = pd.productItemCode || getProductCodeWithType(pd.product_type)
+      const productForm = sortProductFormArr(productCode, pd, order)
+
       const config = {
-        productCode: pd.productItemCode,
+        productCode,
         waitingRestoreForm: productForm,
       }
       return new OrderProductCardItem(undefined, undefined, config)
@@ -134,6 +143,39 @@ export function sortOrderInfo(order = {}) {
   }
 }
 
-export function sortProductFormArr(product) {
-  // console.log(product)
+
+export function sortProductFormArr(type, product, order) {
+  const map = {}
+  if (!type) {
+    console.warn('未传入type')
+    return map
+  }
+
+  let callback = undefined
+  if (type === productKeyMap.cjdy) {
+    callback = sortSvipProductFrom
+  } else if (type === productKeyMap.dhy) {
+    callback = sortBigMemberProductFrom
+  } else if (productGroupKeyMap.oneSpecProduct.includes(type)) {
+    callback = sortOneSpecProductFrom
+  } else if (productGroupKeyMap.dataCountProduct.includes(type)) {
+    callback = sortDataCountPackProductFrom
+  } else if (
+    productGroupKeyMap.marketingProduct.includes(type) || 
+    productGroupKeyMap.ggProduct.includes(type) || 
+    productGroupKeyMap.entityProduct.includes(type)
+  ) {
+    callback = sortMarketingProductFrom
+  } else {
+    console.log('未定义calcForm')
+  }
+
+  if (callback) {
+    const common = sortCommonForm(product, order)
+    const pForm = callback(product, order)
+    Object.assign(map, common, pForm)
+    console.log(common, pForm, map)
+  }
+
+  return map
 }

+ 5 - 0
src/views/create-order/components/schema-form/resort/marketing.js

@@ -0,0 +1,5 @@
+export function sortMarketingProductFrom(product = {}) {
+  const map = {}
+  // console.log(product)
+  return map
+}

+ 13 - 0
src/views/create-order/components/schema-form/resort/one-spec.js

@@ -0,0 +1,13 @@
+import { sortValidityPeriod, getFilter } from './common'
+
+export function sortOneSpecProductFrom(product = {}) {
+  const map = {}
+  if (product.filter) {
+    const filter = getFilter(product)
+    // 周期
+    const period = sortValidityPeriod(filter)
+    Object.assign(map, period)
+  }
+
+  return map
+}

+ 13 - 0
src/views/create-order/components/schema-form/resort/svip.js

@@ -0,0 +1,13 @@
+import { sortValidityPeriod, getFilter } from './common'
+
+export function sortSvipProductFrom(product = {}) {
+  const map = {}
+  if (product.filter) {
+    const filter = getFilter(product)
+    // 周期
+    const period = sortValidityPeriod(filter)
+    Object.assign(map, period)
+  }
+
+  return map
+}

+ 23 - 3
src/views/create-order/components/schema-form/schema-form.vue

@@ -3,7 +3,7 @@
     <!-- schema-form中用到的组件,禁止在created时候立即返回一个值,会出现其他选项默认值为空的情况。应该等createSchema的默认值赋值后再进行emit -->
     <SchemaFormRenderer
       ref="schemaForm"
-      :key="productType"
+      :key="schemaRendererKey"
       :schema="schema"
       :state="value"
       @input="onInput"
@@ -61,6 +61,10 @@ export default {
       type: [String, Number],
       default: '0'
     },
+    readonly: {
+      type: Boolean,
+      default: false,
+    },
     value: {
       type: Object,
       default() {
@@ -105,6 +109,10 @@ export default {
     currentTypeSchemaKeys() {
       return this.schema.filter(r => r.show).map(r => r.key)
     },
+    schemaRendererKey() {
+      const { buySubject } = this.pageForm
+      return `${this.productType}_${buySubject}`
+    },
   },
   watch: {
     value: {
@@ -219,12 +227,19 @@ export default {
       this.changeLoading(true)
       try {
         await this.getUserPowerCheck(true)
+        this.tryToRestoreForm()
       } catch (error) {
         console.log(error)
       } finally {
         this.changeLoading(false)
       }
     },
+    tryToRestoreForm() {
+      const waitingRestoreForm = this.thisProductInfoListItem.productCardInfo?.waitingRestoreForm
+      if (waitingRestoreForm && Object.keys(waitingRestoreForm).length > 0) {
+        this.refreshValue(waitingRestoreForm)
+      }
+    },
     async getUserPowerCheck(ent = false) {
       // 判断购买主体是企业还是个人
       const { buySubject, accountTel, companyName } = this.pageForm
@@ -309,6 +324,7 @@ export default {
       this.dynamicChangeSchema(value)
     }, 100),
     getPriceRequest: debounce(async function getPrice(p) {
+      if (this.readonly) return
       console.log('准备获取价格...')
       const commonP = {
         productInfo: cloneDeep(this.thisProductInfoListItem),
@@ -320,11 +336,11 @@ export default {
         // 刷新xx组件价格
         const key = schemaKeyMap.contractAmount
         let standardMoney = ''
-        if (r) {
+        if (r !== null && r !== undefined && r !== '') {
           // r为负数。则表示暂无法计算标砖售价
           standardMoney = div(r, 100)
         } else {
-          standardMoney = 0
+          standardMoney = ''
         }
         this.refreshValue({
           [key]: Object.assign({}, this.value[key], { standardMoney }) 
@@ -944,7 +960,11 @@ export default {
         this.$set(ma.props, 'onlyShowSelected', true)
       }
     },
+    // 当form.value数据变更, 对form.value自己其他属性有影响的方法写在此处
+    // 比如, 一些数据变更需要清空某些数据
     onChangedFields(changedArr) {
+      if (this.readonly) return
+
       if (this.checkNeedRefreshPrice(changedArr)) {
         this.getPriceRequest()
       }

+ 0 - 2
src/views/create-order/data/interface.js

@@ -56,7 +56,6 @@ export class OrderProductCardItem {
 
     const {
       productCode,
-      standardPrice,
       waitingRestoreForm,
     } = conf
 
@@ -67,7 +66,6 @@ export class OrderProductCardItem {
       result: {
         productCode,
       },
-      standardPrice: standardPrice || '',
     }
   }
 

+ 1 - 1
src/views/create-order/data/var.js

@@ -76,8 +76,8 @@ export const productGroupKeyMap = {
 
 export const productTypeMap = {
   cjdy: 'VIP订阅', // 超级订阅
+  dyh: '大会员', // dyh后端使用的大会员标识(后端使用的符号放在前,在恢复数据时候优先被循环到)
   dhy: '大会员', // dhy前端在使用的
-  dyh: '大会员', // dyh后端使用的大会员标识
   sfdyb: '省份订阅包',
   rmgl: '人脉管理',
   ygcg: '阳光采购',

+ 17 - 9
src/views/create-order/hooks/utils.js

@@ -2,17 +2,25 @@ import store from '@/store'
 
 // 从部门树中,根据名字获取人员信息
 export function findUserInDeptTree(name) {
-  const list = store.getters['order/depTreeList']
+  const depTree = store.getters['order/depTreeList']
+  
   let nameObj = undefined
-  list.find(dep => {
-    if (Array.isArray(dep.children)) {
-      const t = dep.children.find(user => user.name === name)
-      if (t) {
-        nameObj = t
+
+  const findName = (list, name) => {
+    list.find(u => {
+      if (Array.isArray(u.children) && u.children.length > 0) {
+        return findName(u.children, name)
+      } else {
+        const t = u.name === name
+        if (t) {
+          nameObj = u
+        }
+        return t
       }
-    }
-    return nameObj
-  })
+    })
+  }
+
+  findName(depTree, name)
   return nameObj
 }
 

+ 21 - 23
src/views/order/components/OrderReviewCard.vue

@@ -1,5 +1,5 @@
 <template>
-  <div class="order-review-card">
+  <div class="order-review-card" v-loading="loading">
     <section class="module-container records">
       <header class="module-header">
         <h3 class="module-title">审核轨迹</h3>
@@ -14,51 +14,49 @@
         <h3 class="module-title">订单信息</h3>
       </header>
       <main class="module-content">
-        <CreateOrder readonly />
+        <EditOrder
+          readonly
+          type="read"
+          autoGetDetail
+          :orderCode="orderCode"
+          @detail="restoreTableData"
+        />
       </main>
     </section>
   </div>
 </template>
 
 <script>
-import CreateOrder from '@/views/create-order/components/create.vue'
+import EditOrder from '@/views/create-order/components/edit.vue'
 import AuditRecordsColumns from '@/views/create-order/components/order-detail-submodule/AuditRecordsColumns.vue'
-import { mapActions } from 'vuex'
-import { cloneDeep } from "lodash"
 
 export default {
   name: 'OrderReviewCard',
   components: {
-    CreateOrder,
+    EditOrder,
     AuditRecordsColumns,
   },
   props: {
-    orderDetail: {
-      type: Object,
-      default() {
-        return {}
-      }
+    orderCode: {
+      type: String,
+      default: '',
     },
   },
+  watch: {
+    orderCode() {
+      this.loading = true
+    }
+  },
   data () {
     return {
+      loading: true,
       tableData: [],
     }
   },
-  watch: {
-    orderDetail: {
-      deep: true,
-      immediate: true,
-      handler(n) {
-        this.restoreData(cloneDeep(n))
-      }
-    }
-  },
   methods: {
-    ...mapActions('order', ['restorePageInfo']),
-    restoreData(order = {}) {
+    restoreTableData(order = {}) {
+      this.loading = false
       this.tableData = order?.audit || []
-      this.restorePageInfo(order)
     },
   }
 }

+ 4 - 6
src/views/order/components/OrderReviewDialog.vue

@@ -9,7 +9,7 @@
     :visible="value"
     @update:visible="visibleUpdate"
     >
-    <OrderReviewCard ref="reviewCard" :orderDetail="orderDetail" />
+    <OrderReviewCard ref="reviewCard" :orderCode="orderCode" />
     <div class="footer-container" slot="footer" v-if="showReviewModule">
       <div class="review-form-container">
         <el-form ref="form" label-width="110px">
@@ -80,11 +80,9 @@ export default {
       type: Boolean,
       default: false
     },
-    orderDetail: {
-      type: Object,
-      default() {
-        return {}
-      }
+    orderCode: {
+      type: String,
+      default: '',
     },
   },
   data() {

+ 4 - 19
src/views/order/orderReview.vue

@@ -54,7 +54,7 @@
     <!-- 订单详情弹窗 -->
     <OrderReviewDialog
       ref="orderReviewDialog"
-      :orderDetail="reviewing.orderInfo"
+      :orderCode="reviewing.orderCode"
       :showReviewModule="reviewing.showReviewModule"
       v-model="popup.orderDetail"
       :submitLoading="dialogSubmitLoading"
@@ -65,7 +65,7 @@
 </template>
 <script>
 import OrderReviewDialog from './components/OrderReviewDialog.vue'
-import { ajaxGetOrderDetail, changeOrderExamineState } from '@/api/modules'
+import { changeOrderExamineState } from '@/api/modules'
 import { showMessage, showNotify } from '@/views/create-order/hooks/toast'
 import { mapActions } from 'vuex'
 
@@ -122,22 +122,8 @@ export default {
     },
     async operateOrder(row, opera = false) { //操作 审核or查看
       this.reviewing.showReviewModule = opera
-      const { error_code: code, data, error_msg: msg } = await ajaxGetOrderDetail({
-        orderCode: row.order_code,
-      })
-      if (code === 0) {
-        if (data) {
-          this.reviewing.orderInfo = data
-          this.reviewing.orderCode = row.order_code
-          this.popup.orderDetail = true
-        } else {
-          showNotify({ message: '未查询到订单数据' })
-        }
-      } else {
-        if (msg) {
-          showNotify({ message: msg || '获取订单详情失败' })
-        }
-      }
+      this.reviewing.orderCode = row.order_code
+      this.popup.orderDetail = true
     },
     async doCloseReviewModel(type) {
       if (type === 'cancel') {
@@ -265,7 +251,6 @@ export default {
         orderDetail: false
       }, 
       reviewing: {
-        orderInfo: {},
         orderCode: '',
       },
       filterStyle: {