Discount.vue 7.54 KB
Newer Older
1
<template>
dragondean@qq.com's avatar
dragondean@qq.com committed
2 3 4 5 6 7 8 9 10 11 12
  <el-dialog visible :close-on-click-modal="false" :before-close="closeDialog" :title="applyType == 2 ? $t('管理折扣') : $t('优惠申请')">
    <el-form ref="form" :model="form" label-width="80px" :rules="rules">
      <el-form-item :label="$t('商品类型')">
        <span>{{ $l(productType, 'title') }}</span>
      </el-form-item>
      <el-form-item :label="$t('商品名称')">
        <span>{{ orderItem.prodTitleZh }}</span>
      </el-form-item>
      <el-form-item :label="$t('英文名称')">
        <span>{{ orderItem.prodTitleEn }}</span>
      </el-form-item>
Marcus's avatar
Marcus committed
13
      <el-form-item :label="$t('线路')">{{ $t('') }}<dict-tag :type="DICT_TYPE.TRANSPORT_TYPE" :value="order.transportId" />
dragondean@qq.com's avatar
dragondean@qq.com committed
14 15 16 17 18 19
        {{ channel ? $l(channel, 'title') : '' }}
        {{$t("从【{departureName}】发往【{objectiveName}", {departureName: $l(order.logisticsInfoDto, 'startTitle'), objectiveName: $l(order.logisticsInfoDto, 'destTitle')})}}
      </el-form-item>
      <el-form-item :label="$t('是否预付')">
        <dict-tag :type="DICT_TYPE.ECW_YESNO" :value="orderItem.isPayAdvance" />
      </el-form-item>
20

dragondean@qq.com's avatar
dragondean@qq.com committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34
      <el-row v-if="!orderItem.charging">
        <el-col :span="12">
          <el-form-item :label="$t('旧运费')">
            {{form.orgFreight}} {{ currentMap[form.freightCurrency] }} / {{ unitMap[form.freightVolume] }}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('旧清关费')">
            {{form.orgClearanceFreight}} {{ currentMap[form.clearanceFreightCurrency] }} / {{ unitMap[form.clearanceFreightVolume] }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row v-if="!orderItem.charging">
        <el-col :span="12">
35 36
          <el-form-item :label="$t('新运费')" style="width: 400px" prop="freight">
            <el-input v-model="form.freight" type="number" class="w-100" />
dragondean@qq.com's avatar
dragondean@qq.com committed
37 38 39 40 41 42 43 44 45 46
            {{ currentMap[form.freightCurrency] }} / {{ unitMap[form.freightVolume] }}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('新清关费')" style="width: 400px" prop="clearanceFreight">
            <el-input v-model="form.clearanceFreight" type="number" class="w-100" />
            {{ currentMap[form.clearanceFreightCurrency] }} / {{ unitMap[form.clearanceFreightVolume] }}
          </el-form-item>
        </el-col>
      </el-row>
47

dragondean@qq.com's avatar
dragondean@qq.com committed
48
      <el-form-item :label="$t('旧全包价')" v-if="orderItem.charging">
49
        {{form.orgFreight}} {{ currentMap[form.freightCurrency] }} / {{ unitMap[form.freightVolume] }}
dragondean@qq.com's avatar
dragondean@qq.com committed
50 51 52 53 54
      </el-form-item>
      <el-form-item :label="$t('新全包价')" style="width: 400px" prop="clearanceFreight"  v-if="orderItem.charging">
        <el-input v-model="form.freight" type="number" class="w-100" />
        {{ currentMap[form.freightCurrency] }} / {{ unitMap[form.freightVolume] }}
      </el-form-item>
55

dragondean@qq.com's avatar
dragondean@qq.com committed
56
    </el-form>
Marcus's avatar
Marcus committed
57
    <div class="page-title">{{ $t('审批流程') }}</div>
dragondean@qq.com's avatar
dragondean@qq.com committed
58
    <work-flow xmlkey="special_apply" v-model="ccIdArr" />
dragondean@qq.com's avatar
dragondean@qq.com committed
59
    <div v-if="form.applyStatus != 1">
Marcus's avatar
Marcus committed
60
      <el-button type="primary" @click="handleSubmit" :disabled="!submitable">{{ $t('提交') }}</el-button>
dragondean@qq.com's avatar
dragondean@qq.com committed
61 62 63 64 65
    </div>
    <div v-else>
      <el-button type="primary" @click="$router.push('/bpm/process-instance/detail?id=' + form.formId)">
        <dict-tag :type="DICT_TYPE.APPLY_STATUS" :value="form.applyStatus" />
      </el-button>
Marcus's avatar
Marcus committed
66 67
      <el-button type="primary" @click="cancelAudit">{{ $t('取消审核') }}</el-button>
      <el-button type="default" @click="closeDialog">{{ $t('返回') }}</el-button>
dragondean@qq.com's avatar
dragondean@qq.com committed
68 69
    </div>
  </el-dialog>
70 71 72
</template>

<script>
dragondean@qq.com's avatar
dragondean@qq.com committed
73
import {createOrderSpecial, getOrderSpecial} from "@/api/ecw/order"
74
import {getUnitList} from "@/api/ecw/unit"
dragondean@qq.com's avatar
dragondean@qq.com committed
75
import {getChannel, getChannelList} from "@/api/ecw/channel"
76
import { getCurrencyList } from '@/api/ecw/currency'
dragondean@qq.com's avatar
dragondean@qq.com committed
77
import { getProductType } from '@/api/ecw/productType'
dragondean@qq.com's avatar
dragondean@qq.com committed
78
import {cancelProcessInstance} from '@/api/bpm/processInstance'
dragondean@qq.com's avatar
dragondean@qq.com committed
79
import WorkFlow from '@/components/WorkFlow'
80

81
export default {
dragondean@qq.com's avatar
dragondean@qq.com committed
82
  name: "OrderSpecialDiscount",
83
  props: {
dragondean@qq.com's avatar
dragondean@qq.com committed
84 85 86 87 88
    order: Object,
    orderItem: Object,
    applyType:{ // // 1是优惠申请2是管理折扣3是佣金设置4是重货优惠5是泡货优惠, 默认是优惠申请,可以设置为2表示管理折扣,公用一个组件
      type: Number,
      default: 1
89 90 91
    }
  },
  components: {
92
    WorkFlow
93 94 95
  },
  created() {
    // 查看详情,列表进来的
dragondean@qq.com's avatar
dragondean@qq.com committed
96
    this.getOrderSpecial()
97 98 99 100

    getUnitList().then(res => this.unitList = res.data)
    getCurrencyList().then(res => this.currencyList = res.data)

dragondean@qq.com's avatar
dragondean@qq.com committed
101 102 103 104 105 106 107 108
    getProductType(this.orderItem.prodType).then(res => {
      this.productType = res.data
    })
    if(this.order.channelId){
      getChannel(this.order.channelId).then(res => {
        this.channel = res.data
      })
    }
109 110 111
  },
  data() {
    return {
dragondean@qq.com's avatar
dragondean@qq.com committed
112
      // applyType: 1, // 1是优惠申请2是管理折扣3是佣金设置4是重货优惠5是泡货优惠
113
      unitList:[],
dragondean@qq.com's avatar
dragondean@qq.com committed
114
      // channelList:[],
115
      currencyList:[],
dragondean@qq.com's avatar
dragondean@qq.com committed
116 117 118 119
      // productTypeList:[],
      ccIdArr: [],
      form: { },
      rules:{
Marcus's avatar
Marcus committed
120 121
        freight      : {required: true, message: this.$t('运费不能为空')},
        clearanceFreight: {required: true, message: this.$t('清关费不能为空')}
Marcus's avatar
Marcus committed
122
      },
dragondean@qq.com's avatar
dragondean@qq.com committed
123 124 125 126 127 128 129
      productType: null,
      channel: null
    }
  },
  watch:{
    ccIdArr(){
      this.$set(this.form, 'ccIds', this.ccIdArr.join(','))
130 131 132 133
    }
  },
  methods: {
    handleSubmit(){
dragondean@qq.com's avatar
dragondean@qq.com committed
134 135 136 137 138
      this.$refs.form.validate().then(res => {
        createOrderSpecial(Object.assign({}, this.form, {applyType: this.applyType})).then(res => {
          this.$message.success(this.$t('提交成功'))
          this.$emit('success')
        })
139 140 141
      })
    },
    getOrderSpecial(){
dragondean@qq.com's avatar
dragondean@qq.com committed
142
      getOrderSpecial(this.order.orderId, this.applyType, {orderItemId: this.orderItem.orderItemId}).then(r => {
143 144 145
        this.form = r.data
      })
    },
dragondean@qq.com's avatar
dragondean@qq.com committed
146 147 148
    /* getProductTypeNameById(id){
      return this.$l(this.productTypeList.find(e => e.id === id), 'title')
    }, */
dragondean@qq.com's avatar
dragondean@qq.com committed
149 150 151 152 153 154 155 156 157 158 159 160 161 162
    cancelAudit(){
      this.$prompt(this.$t('请输入取消原因?'), this.$t("取消审批"), {
        type: 'warning',
        confirmButtonText: this.$t("确定"),
        cancelButtonText: this.$t("取消"),
        inputPattern: /^[\s\S]*.*[^\s][\s\S]*$/, // 判断非空,且非空格
        inputErrorMessage: this.$t("取消原因不能为空"),
      }).then(({ value }) => {
        return cancelProcessInstance(this.form.formId, value);
      }).then(() => {
        this.$modal.msgSuccess(this.$t("取消成功"));
        this.closeDialog()
      })
    },
dragondean@qq.com's avatar
dragondean@qq.com committed
163 164
    closeDialog(){
      this.$emit('close')
165 166 167
    }
  },
  computed: {
168 169 170
    // 是否可以提交
    submitable(){
      let submitable = false;
171
      if(!this.form.freight || (!this.form.clearanceFreight && !this.form.charging)){
dragondean@qq.com's avatar
dragondean@qq.com committed
172 173
        return false
      }
174 175 176 177 178 179 180 181 182 183
      [
        ['orgClearanceFreight', 'clearanceFreight'],
        ['orgFreight', 'freight']
      ].forEach(item => {
        if(this.form[item[0]] != this.form[item[1]]){
          submitable = true
        }
      })
      return submitable
    },
184 185 186 187
    // 根据渠道id显示渠道名
    getChannelNameById(){
      return channelId => {
        const s = this.channelList.find(item => item.channelId == channelId) ?. nameZh
Marcus's avatar
Marcus committed
188
        return s ? this.$t('') + s + this.$t('') : ''
189 190 191 192 193
      }
    },
    currentMap(){
      let map = {}
      this.currencyList.forEach(item => {
dragondean@qq.com's avatar
dragondean@qq.com committed
194
        map[item.id] = this.$l(item, 'title')
195 196 197 198 199 200
      })
      return map
    },
    unitMap(){
      let map = {}
      this.unitList.forEach(item => {
dragondean@qq.com's avatar
dragondean@qq.com committed
201
        map[item.id] = this.$l(item, 'title')
202 203 204 205 206 207
      })
      return map
    }
  }
}
</script>