Discounts.vue 10.2 KB
Newer Older
1 2 3 4 5 6 7
<template>
  <el-dialog visible :close-on-click-modal="false" width="80%" :before-close="closeDialog" :title="applyType == 32 ? $t('管理折扣') : $t('优惠申请')">
    <el-form ref="form" :model="order" label-width="80px">
      <el-form-item :label="$t('订单号')">
        <span>{{ order.orderNo }}</span>
      </el-form-item>
      <el-form-item :label="$t('线路')">{{ $t('') }}<dict-tag :type="DICT_TYPE.TRANSPORT_TYPE" :value="order.transportId" />
8
        {{ order.channelName }}
9 10 11 12 13 14 15 16 17 18
        {{$t("从【{departureName}】发往【{objectiveName}", {departureName: $l(order.logisticsInfoDto, 'startTitle'), objectiveName: $l(order.logisticsInfoDto, 'destTitle')})}}
      </el-form-item>
    </el-form>
      <el-table  border :data="form.batchApplyOrderItemDetailVOList">
       <el-table-column :label="$t('品名')" align="center">
          <template  v-slot="{row}">
            {{row.prodTitleZh+'/'+row.prodTitleEn}}
          </template>
        </el-table-column>
       <el-table-column :label="$t('填单货物属性')" align="center">
19 20 21 22 23
          <template v-slot="{row}">
            {{$t('品牌')}}<dict-tag :type="DICT_TYPE.ECW_IS_BRAND" :value="row.brandType" /><br>
            {{$t('箱数')}}{{ row.num }}<br>
            {{$t('体积')}}{{ row.volume }}m³<br>
            {{$t('重量')}}{{ row.weight }}Kg
24 25 26 27 28
          </template>
        </el-table-column>
        <el-table-column
          prop="address"
          :label="$t('入库货物属性')">
29 30
          <template v-slot="{row}">
            <template v-if="row.warehouseInInfoVO">
31
              {{$t('品牌')}}
32 33 34 35 36
              <template v-if="row.brandName">{{row.brandName}}</template>
              <dict-tag v-else :type="DICT_TYPE.ECW_IS_BRAND" :value="row.feeType" /><br>
              {{$t('箱数')}}{{ row.warehouseInInfoVO.cartonsNum }}<br>
              {{$t('体积')}}{{ row.warehouseInInfoVO.volume }}m³<br>
              {{$t('重量')}}{{ row.warehouseInInfoVO.weight }}Kg
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
            </template>
            <span v-else>{{$t('暂时没有入库信息')}}</span>
          </template>
        </el-table-column>
       <el-table-column :label="$t('旧费用')" align="center">
          <template v-slot="{row}">
            <div v-if="!row.charging">
              <div>{{$t('旧运费')}}:{{row.orgFreight}} {{ currentMap[row.freightCurrency] }} / {{ unitMap[row.freightVolume] }}</div>
              <div>{{$t('旧清关费')}}:{{row.orgClearanceFreight}} {{ currentMap[row.clearanceFreightCurrency] }} / {{ unitMap[row.clearanceFreightVolume] }}</div>
            </div>
            <div v-else>
              {{$t('旧全包价')}}:{{row.orgFreight}} {{ currentMap[row.freightCurrency] }} / {{ unitMap[row.freightVolume] }}
            </div>
          </template>
        </el-table-column>
       <el-table-column :label="$t('新费用')" align="center" width="300px">
          <template v-slot="{row}">
            <div v-if="!row.charging">
              <div>{{$t('新运费')}}: <el-input v-model="row.freight" type="number" class="w-100" /> {{ currentMap[row.freightCurrency] }} / {{ unitMap[row.freightVolume] }}</div>
              <div>{{$t('新清关费')}}: <el-input v-model="row.clearanceFreight" type="number" class="w-100" /> {{ currentMap[row.clearanceFreightCurrency] }} / {{ unitMap[row.clearanceFreightVolume] }}</div>
            </div>
            <div v-else>
              {{$t('新全包价')}}: <el-input v-model="row.freight" type="number" class="w-100" />{{ currentMap[row.freightCurrency] }} / {{ unitMap[row.freightVolume] }}
            </div>
          </template>
        </el-table-column>
      </el-table>

    <div class="page-title">{{ $t('审批流程') }}</div>
    <work-flow xmlkey="special_apply" v-model="ccIdArr" />
    <div v-if="form.applyStatus != 1">
      <el-button type="primary" @click="handleSubmit" >{{ $t('提交') }}</el-button>
    </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>
      <el-button type="primary" @click="cancelAudit">{{ $t('取消审核') }}</el-button>
      <el-button type="default" @click="closeDialog">{{ $t('返回') }}</el-button>
    </div>
  </el-dialog>
</template>

<script>
import {createOrderSpecialBatch, getOrderSpecialBatch} from "@/api/ecw/order"
import {getUnitList} from "@/api/ecw/unit"
import {getChannel, getChannelList} from "@/api/ecw/channel"
import { getCurrencyList } from '@/api/ecw/currency'
import { getProductType } from '@/api/ecw/productType'
import {cancelProcessInstance} from '@/api/bpm/processInstance'
import WorkFlow from '@/components/WorkFlow'

export default {
  name: "OrderSpecialDiscount",
  props: {
    order: Object,
93
    ids:Array,
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
    applyType:{ // // 31是优惠申请32是管理折扣
      type: Number,
      default: 31
    }
  },
  components: {
    WorkFlow
  },
  created() {
    // 查看详情,列表进来的
    this.getOrderSpecial()

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

    // getProductType(this.orderItem.prodType).then(res => {
    //   this.productType = res.data
    // })
112
    /*if(this.order.channelId){
113 114 115
      getChannel(this.order.channelId).then(res => {
        this.channel = res.data
      })
116
    }*/
117 118 119 120 121 122 123 124 125 126 127
  },
  data() {
    return {
      // applyType: 1, // 1是优惠申请2是管理折扣3是佣金设置4是重货优惠5是泡货优惠
      unitList:[],
      // channelList:[],
      currencyList:[],
      // productTypeList:[],
      ccIdArr: [],
      form: { },
      productType: null,
128
      // channel: null
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
    }
  },
  watch:{
    ccIdArr(){
      this.$set(this.form, 'ccIds', this.ccIdArr.join(','))
    }
  },
  methods: {
    handleSubmit(){
      var fee = false
      var msg = ''
      this.form.batchApplyOrderItemDetailVOList.map(v=>{
        if(v.charging){
          if(!v.freight){
            fee = true
            msg = this.$t('新全包价不能为空')
          }else if(v.freight==v.orgFreight){
            fee = true
            msg = this.$t('新全包价不能与旧全包价一致')
          }

        }else{
          if(!v.clearanceFreight){
            fee = true
            msg = this.$t('新清关费不能为空')
          }
          if(!v.freight){
            fee = true
            msg = this.$t('新运费不能为空')
          }
          if(v.freight&&v.clearanceFreight){
            if(v.freight==v.orgFreight&&v.clearanceFreight==v.orgClearanceFreight){
              fee = true
              msg = this.$t('新费用不能与旧费用一致')
            }
          }
        }
      })
      if(fee){
        this.$message.error(msg)
        return
      }
        createOrderSpecialBatch(Object.assign({}, this.form, {orderId:this.order.orderId,orderNo:this.order.orderNo},{applyType: this.applyType})).then(res => {
          this.$message.success(this.$t('提交成功'))
          this.$emit('success')
        })
    },
    getOrderSpecial(){
      getOrderSpecialBatch(this.order.orderId, this.applyType).then(r => {
        this.form = r.data
179 180 181 182 183 184 185 186 187
        var volist = r.data.batchApplyOrderItemDetailVOList
        if(this.form.applyStatus==1){
          this.form.batchApplyOrderItemDetailVOList.map(v=>{
            var item = this.order.orderItemVOList.find(vs=>vs.orderItemId==v.orderItemId)
            if(item){
              v.brandType = item.brandType
              v.num = item.num
              v.volume = item.volume
              v.weight = item.weight
我在何方's avatar
我在何方 committed
188
              v.brandName = item.brandName
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
              v.warehouseInInfoVO = item.warehouseInInfoVO
            }
          })
        }else{
          this.form.batchApplyOrderItemDetailVOList = []
          var list = []
          console.log(this.ids)
          volist.map(v=>{
            console.log(v.orderItemId)
            if(this.ids.indexOf(v.orderItemId)>-1){
              var item = this.order.orderItemVOList.find(vs=>vs.orderItemId==v.orderItemId)
              if(item){
                v.brandType = item.brandType
                v.num = item.num
                v.volume = item.volume
                v.weight = item.weight
我在何方's avatar
我在何方 committed
205
                v.brandName = item.brandName
206 207 208 209 210 211 212 213
                v.warehouseInInfoVO = item.warehouseInInfoVO
              }
              list.push(v)
            }
          })
          console.log(list)
          this.$set(this.form,'batchApplyOrderItemDetailVOList',list)
        }
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
      })
    },
    /* getProductTypeNameById(id){
      return this.$l(this.productTypeList.find(e => e.id === id), 'title')
    }, */
    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()
      })
    },
    closeDialog(){
      this.$emit('close')
    }
  },
  computed: {
    // 是否可以提交
    submitable(){
      let submitable = false;
      if(!this.form.freight || (!this.form.clearanceFreight && !this.form.charging)){
        return false
      }
      [
        ['orgClearanceFreight', 'clearanceFreight'],
        ['orgFreight', 'freight']
      ].forEach(item => {
        if(this.form[item[0]] != this.form[item[1]]){
          submitable = true
        }
      })
      return submitable
    },
    // 根据渠道id显示渠道名
    getChannelNameById(){
      return channelId => {
        const s = this.channelList.find(item => item.channelId == channelId) ?. nameZh
        return s ? this.$t('') + s + this.$t('') : ''
      }
    },
    currentMap(){
      let map = {}
      this.currencyList.forEach(item => {
        map[item.id] = this.$l(item, 'title')
      })
      return map
    },
    unitMap(){
      let map = {}
      this.unitList.forEach(item => {
        map[item.id] = this.$l(item, 'title')
      })
      return map
    }
  }
}
</script>