• zs嵩's avatar
    7 · 17870ae2
    zs嵩 authored
    17870ae2
index.vue 19.7 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 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 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 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 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516
<template>
  <div class="fee-application">
    <h1>{{ $t("批量费用申请") }}</h1>
    <el-divider></el-divider>
    <div class="flex-c-c">
      <div class="fills">费用申请</div>
      <el-button type="primary" :disabled="!!processInstanceId" @click="addCost">{{ $t("添加申请") }} </el-button>
    </div>
    <el-table border :data="batchApplyDetailsInfoVO.feeDetailsVOList" class="mt-10">
      <el-table-column :label="$t('序号')" type="index"></el-table-column>
      <el-table-column :label="$t('费用类型')">
        <template slot-scope="{ row, $index }">
          <dict-selector :type="DICT_TYPE.FEE_TYPE" v-model="row.feeType" @change="updatePayer($index)" />
        </template>
      </el-table-column>
      <el-table-column :label="$t('金额')">
        <template slot-scope="{ row, $index }">
          <el-input v-model="row.applicationFee" type="number" @input="formatAmount(row, $index)"></el-input>
        </template>
      </el-table-column>
      <el-table-column :label="$t('货币类型')">
        <template slot-scope="{ row, $index }">
          <el-select v-model="row.applicationFeeCurrency" @change="batchUpdateField($index, 'applicationFeeCurrency')">
            <el-option v-for="item in currencyList" :key="item.id" :label="isChinese ? item.titleZh : item.titleEn" :value="item.id" />
          </el-select>
        </template>
      </el-table-column>
      <el-table-column :label="$t('付款类型')">
        <template slot-scope="{ row, $index }">
          <dict-selector :type="DICT_TYPE.PAYMENT_TYPE" v-model="row.payType" @change="batchUpdateField($index, 'payType')" />
        </template>
      </el-table-column>
      <el-table-column :label="$t('付款人')">
        <template slot-scope="{ row, $index }">
          <dict-selector :type="DICT_TYPE.DRAWEE" :filter="payerDictFilter" v-model="row.payer" @change="batchUpdateField($index, 'payer')" />
        </template>
      </el-table-column>
      <el-table-column :label="$t('备注')">
        <template slot-scope="{ row, $index }">
          <el-input v-model="row.remarks" type="textarea" @input="batchUpdateField($index, 'remarks')"></el-input>
        </template>
      </el-table-column>
      <el-table-column :label="$t('确认收款')">
        <template slot-scope="{ row, $index }">
          <dict-tag :type="DICT_TYPE.ECW_RECEIVABLE_STATE" :value="row.receiveFlag" @change="batchUpdateField($index, 'receiveFlag')" />
        </template>
      </el-table-column>
      <el-table-column :label="$t('申请人')">
        <template slot-scope="{ row, $index }">
          {{ row.status === 0 ? $t("未提交") : row.applicationAuthor }}
        </template>
      </el-table-column>
      <el-table-column :label="$t('操作')" width="100">
        <template slot-scope="{ index }">
          <el-button type="text" @click="del(index)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <div class="">
      <div style="padding: 20px 0 10px 0">{{ $t("申请原因") }}</div>
      <el-input v-model="batchApplyDetailsInfoVO.reason" type="textarea" style="width: 30%"></el-input>
    </div>

    <div class="flex-c-c mt20">
      <div class="fills">订单列表</div>
    </div>
    <el-table class="mt10" ref="orderTable" border default-expand-all :data="batchApplyDetailsInfoVO.orderFeeDetailsVOList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="50"></el-table-column>
      <el-table-column :label="$t('序号')" width="50" type="index" align="center" />
      <el-table-column prop="orderNo" :label="$t('订单号')" align="center" width="150">
        <template slot-scope="{ row }">
          <router-link :to="'/order/detail?orderId=' + row.orderId"> {{ row.orderNo }}</router-link>
        </template>
      </el-table-column>
      <el-table-column :label="$t('发货人')" width="100" align="center">
        <template slot-scope="{ row }">
          <router-link :to="'/customer/query/' + row.consignorCustomerId"> {{ row.consignorCustomerNumber }}</router-link>
        </template>
      </el-table-column>
      <el-table-column :label="$t('收货人')" width="100" align="center">
        <template slot-scope="{ row }">
          <router-link :to="'/customer/query/' + row.consigneeCustomerId">{{ row.consigneeCustomerNumber }}</router-link>
        </template>
      </el-table-column>
      <el-table-column :label="$t('始发仓')" align="center" prop="startWarehouseName">
        <template slot-scope="{ row }">
          {{ row.startWarehouseName }}
          <span style="color: red" v-if="row.isExternalWarehouse">({{ $t("外部仓") }})</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('运输方式') + '-' + $t('渠道') + '/' + $t('目的仓')" align="center" width="220">
        <template slot-scope="{ row }">
          <dict-tag :type="DICT_TYPE.ECW_TRANSPORT_TYPE" :value="row.transportId" />
          <template v-if="row.channelName"> - {{ row.channelName }} </template>
          / {{ row.dstWarehouseName }}
        </template>
      </el-table-column>
      <el-table-column :label="$t('额外费用')" width="200">
        <template slot-scope="{ row }">
          <div v-for="(item, feeIndex) in row.costVO.feeDtoList" :key="feeIndex">
            <div v-if="item.amount && item.feeType !== 1 && item.feeType !== 2"><dict-tag :type="DICT_TYPE.FEE_TYPE" :value="item.feeType" />: {{ currencyMapF[item.currencyId] }}{{ item.amount }}</div>
          </div>
        </template>
      </el-table-column>
      <el-table-column :label="$t('控货')" align="center" prop="transportId">
        <template slot-scope="{ row }">
          <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="row.isCargoControl" />
        </template>
      </el-table-column>

      <el-table-column :label="$t('增值服务')" align="center" prop="status">
        <template slot-scope="{ row }">
          {{ getTypeText(row.type) }}
        </template>
      </el-table-column>
      <el-table-column prop="lastInTime" :label="$t('最后入仓时间')" align="center" width="150"></el-table-column>
      <el-table-column prop="zgDate" :label="$t('装柜时间')" align="center" width="150"></el-table-column>
      <el-table-column prop="dgDate" :label="$t('到港时间')" align="center" width="150"></el-table-column>
      <el-table-column prop="qgDate" :label="$t('清关时间')" align="center" width="150"></el-table-column>
      <el-table-column prop="unloadTime" :label="$t('到仓时间')" align="center" width="150"></el-table-column>

      <el-table-column type="expand" :label="$t('更多')">
        <template slot-scope="{ row, $index: INDEX }">
          <div style="margin: 0 20px 0 100px">
            <el-table :data="row.orderFeeApplicationBaseVOList" border size="mini" :row-class-name="rowClassname">
              <el-table-column :label="$t('序号')" type="index"></el-table-column>
              <el-table-column :label="$t('费用类型')">
                <template slot-scope="{ row }">
                  <dict-selector :type="DICT_TYPE.FEE_TYPE" v-model="row.feeType" />
                </template>
              </el-table-column>
              <el-table-column :label="$t('金额')">
                <template slot-scope="{ row }">
                  <el-input v-model="row.applicationFee" type="number" @input="formatAmount(row)"></el-input>
                </template>
              </el-table-column>
              <el-table-column :label="$t('货币类型')">
                <template slot-scope="{ row }">
                  <el-select v-model="row.applicationFeeCurrency">
                    <el-option v-for="item in currencyList" :key="item.id" :label="isChinese ? item.titleZh : item.titleEn" :value="item.id" />
                  </el-select>
                </template>
              </el-table-column>
              <el-table-column :label="$t('付款类型')">
                <template slot-scope="{ row }">
                  <dict-selector :type="DICT_TYPE.PAYMENT_TYPE" v-model="row.payType" />
                </template>
              </el-table-column>
              <el-table-column :label="$t('付款人')">
                <template slot-scope="{ row }">
                  <dict-selector :type="DICT_TYPE.DRAWEE" :filter="payerDictFilter" v-model="row.payer" />
                </template>
              </el-table-column>
              <el-table-column :label="$t('备注')">
                <template slot-scope="{ row }">
                  <el-input v-model="row.remarks" type="textarea"></el-input>
                </template>
              </el-table-column>
              <el-table-column :label="$t('确认收款')">
                <template slot-scope="{ row }">
                  <dict-tag :type="DICT_TYPE.ECW_RECEIVABLE_STATE" :value="row.receiveFlag" />
                </template>
              </el-table-column>
              <el-table-column :label="$t('申请人')">
                <template slot-scope="{ row }">
                  {{ row.status === 0 ? $t("未提交") : row.applicationAuthor }}
                </template>
              </el-table-column>
              <el-table-column :label="$t('操作')" width="100">
                <template slot-scope="{ row, $index }">
                  <el-button type="text" @click="del2(INDEX, $index)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </template>
      </el-table-column>
    </el-table>

    <div style="padding: 20px">
      <work-flow xmlkey="batch_order_free_apply" v-model="selectedUsers" />
    </div>
    <div style="text-align: center; margin-top: 20px">
      <el-button type="primary" v-if="!processInstanceId" style="margin-right: 30px" @click="submit">{{ $t("提交") }} </el-button>
      <el-button type="primary" v-if="processInstanceId" style="margin-right: 30px" @click="goProcessDetail">{{ $t("审核中") }} </el-button>
      <el-button type="primary" v-if="processInstanceId" style="margin-right: 30px" @click="cancel">{{ $t("取消审核") }} </el-button>
      <el-button @click="$emit('update:dialogVisible', false)">{{ $t("返回") }} </el-button>
    </div>
  </div>
</template>

<script>
import { getCurrencyList } from "@/api/ecw/currency"
import { getUnitList } from "@/api/ecw/unit"
import { getProductAttrList } from "@/api/ecw/productAttr"
import { getProductTypeList } from "@/api/ecw/productType"
import { getOrder, feeApplicationBatch, feeApplicationBatchGetOrderListByIds, applicationUpdate, feeApplicationCancel, getFeeApplicationApproveByOrderId, getBatchFeeByProcessId, qetBatchFeeByBusinessId, getBatchFeeByBusinessId, feeApplicationDelete, getFeeDraweeByFeeType } from "@/api/ecw/order"
import { getDictDatas, DICT_TYPE } from "@/utils/dict"
import workFlow from "@/components/WorkFlow"
import batchMarkupComList from "./batchMarkupComList"

export default {
  name: "feeApplicationBatch",
  components: { workFlow, batchMarkupComList },
  props: {
    orderList: [Array],
    dialogVisible: {
      type: Boolean,
      default: false
    },
    currencys: String
  },
  data() {
    return {
      prodTypeList: [],
      attrList: [],
      unitList: [],
      currencyList: [],
      // 审核ID,没有则表示不在审核中
      processInstanceId: null,
      DICT_TYPE,
      getDictDatas,
      STATUS: {},
      selectedUsers: [],
      batchApplyDetailsInfoVO: {
        reason: "",
        feeDetailsVOList: [],
        orderFeeDetailsVOList: []
      }
    }
  },
  computed: {
    // 增值服务文本
    getTypeText() {
      return (type) => {
        if (!type) return ""
        const arr = []
        if (type.indexOf("1") > -1) {
          arr.push(this.$t("集运"))
        }
        if (type.indexOf("2") > -1) {
          arr.push(this.$t("海外仓"))
        }
        return arr.join(",")
      }
    },
    orderIds() {
      return this.$route.query.orderIds || ""
    },
    currencyMap() {
      let map = {}
      this.currencyList.forEach((item) => {
        map[item.id] = this.$l(item, "title")
      })
      return map
    },
    currencyMapF() {
      let map = {}
      this.currencyList.forEach((item) => {
        map[item.id] = item.fuhao
      })
      return map
    },
    unitMap() {
      let map = {}
      this.unitList.forEach((item) => {
        map[item.id] = this.$l(item, "title")
      })
      return map
    },
    isChinese() {
      return this.$i18n.locale === "zh_CN"
    }
  },
  created() {
    this.getDictDatas(this.DICT_TYPE.AUDIT_STATUS).forEach((e) => {
      this.STATUS[e.value] = e.label
    })

    feeApplicationBatchGetOrderListByIds({ orderIds: this.orderIds }).then((res) => {
      this.batchApplyDetailsInfoVO.orderFeeDetailsVOList = res.data.map((item) => {
        return {
          ...item,
          orderFeeApplicationBaseVOList: []
        }
      })
    })

    // 查询是否有审核中的费用申请
    // getFeeApplicationApproveByOrderId(this.orderId).then((res) => {
    //   if (res.data) {
    //     this.processInstanceId = res.data.formId
    //     /*getBatchFeeByBusinessId(res.data.orderApprovalId).then(res => {
    //       this.list = res.data
    //     })*/
    //   }
    // })
    getUnitList().then((res) => (this.unitList = res.data))
    getCurrencyList().then((res) => (this.currencyList = res.data))
    getProductAttrList().then((response) => {
      this.attrList = response.data
    })
    getProductTypeList().then((response) => {
      this.prodTypeList = response.data
    })
  },
  methods: {
    // 表格多选
    handleSelectionChange(selection) {
      this.multipleSelection = selection
      this.ids = selection.map((item) => item.orderId)
    },
    formatAmount(row, index) {
      // 使用正则表达式限制输入为数字和小数点,并限制小数点后最多两位数字
      // row.applicationFee = row.applicationFee.replace(/[^\d.]/g, '').replace(/(\..*)\./g, '$1');
      if (row.applicationFee.indexOf(".") > -1) {
        const decimalPart = row.applicationFee.split(".")[1]
        if (decimalPart.length > 2) {
          row.applicationFee = row.applicationFee.substring(0, row.applicationFee.length - (decimalPart.length - 2))
        }
      }
      this.batchUpdateField(index, "applicationFee")
    },

    del(index) {
      this.$confirm(this.$t("确定要删除此条费用申请么?")).then(() => {
        this.batchApplyDetailsInfoVO.feeDetailsVOList.splice(index, 1)
        this.batchApplyDetailsInfoVO.orderFeeDetailsVOList.forEach((item, i) => {
          item.orderFeeApplicationBaseVOList.splice(index, 1)
        })
      })
    },
    del2(INDEX, index) {
      this.$confirm(this.$t("确定要删除此条费用申请么?")).then(() => {
        this.batchApplyDetailsInfoVO.orderFeeDetailsVOList[INDEX].orderFeeApplicationBaseVOList[index].isDel = true
      })
    },
    rowClassname({ row }) {
      return row.isDel ? "isDel" : ""
    },
    // 过滤订单状态筛选字典内容
    payerDictFilter(item) {
      if (item.value && item.value == 3) {
        return false
      }
      return true
    },
    updatePayer(index) {
      this.batchUpdateField(index, "feeType")
    },
    batchUpdateField(index, field) {
      this.$nextTick(() => {
        this.batchApplyDetailsInfoVO.orderFeeDetailsVOList.forEach((item, i) => {
          item.orderFeeApplicationBaseVOList[index][field] = this.batchApplyDetailsInfoVO.feeDetailsVOList[index][field]
        })
      })
    },
    getDraweePayer(item) {
      let feeType = item.feeType
      if (feeType) {
        getFeeDraweeByFeeType(feeType).then((res) => {
          console.log(res.data)
          let drawee = res.data
          console.log("自定义费用枚举值:", drawee)
          if (drawee) {
            if (this.orderDetails.customDraweeVOList && this.orderDetails.customDraweeVOList.length > 0) {
              let customDrawee = this.orderDetails.customDraweeVOList.find((item) => item.name == drawee)
              console.log("自定义费用类型值:", customDrawee)
              if (customDrawee) {
                console.log("返回值:", customDrawee.value)
                this.$set(item, "payer", customDrawee.value)
              }
            }
          }
        })
      }
    },

    addCost() {
      let obj = {
        feeType: undefined, //费用申请类型
        applicationFee: undefined, //金额
        applicationFeeCurrency: undefined, //	费用申请货币类型
        payer: undefined, //	费用申请付款人
        remarks: undefined,
        receiveFlag: 0,
        applicationAuthor: undefined,
        status: 0
      }
      this.batchApplyDetailsInfoVO.feeDetailsVOList.push(obj)
      this.batchApplyDetailsInfoVO.orderFeeDetailsVOList.forEach((item) => {
        item.orderFeeApplicationBaseVOList.push({ ...obj, isDel: false })
      })
    },
    deleteByFeeIsZero(id) {
      this.$confirm(this.$t("确定要删除此条费用申请么?")).then(() => {
        feeApplicationDelete(id).then((r) => {
          this.$message({
            type: "success",
            message: this.$t("删除成功")
          })
          this.$emit("update:dialogVisible", false)
        })
      })
    },
    async submit() {
      // 判断费用申请是否有未填项
      // console.log("提交的费用信息列表", this.feeList)
      await new Promise((resolve) => {
        if (
          this.batchApplyDetailsInfoVO.orderFeeDetailsVOList.some((item, index) => {
            return !item.orderFeeApplicationBaseVOList.filter((m) => !m.isDel).length
          })
        ) {
          this.$confirm(this.$t("确定要删除所有无费用的订单吗?")).then(() => {
            resolve()
          })
        } else {
          resolve()
        }
      })

      await new Promise((resolve) => {
        if (
          !this.batchApplyDetailsInfoVO.orderFeeDetailsVOList.some((item, index) => {
            return item.orderFeeApplicationBaseVOList.some((m) => {
              if (!m.isDel && (!item["feeType"] || item.applicationFee == null || item.applicationFee == undefined || !item["applicationFeeCurrency"] || !item["payType"])) {
                this.$message.error("请填写完整费用申请信息")
                return true
              }
            })
          })
        ) {
          resolve()
        }
      })

      feeApplicationBatch({
        batchApplyDetailsInfoVO: this.batchApplyDetailsInfoVO,
        copyUserId: this.selectedUsers
      }).then((r) => {
        if (r.code === 0) {
          this.$message.success(this.$t("添加成功"))
          this.selectedUsers = []
        }
      })
    },
    goProcessDetail() {
      this.$emit("update:dialogVisible", false)
      this.$router.push("/bpm/process-instance/detail?id=" + this.processInstanceId)
    },
    cancel() {
      this.$prompt(this.$t("请输入取消原因"), this.$t("提示"), {
        confirmButtonText: this.$t("确定"),
        cancelButtonText: this.$t("取消")
      })
        .then(({ value }) => {
          let item = this.list.find((e) => e.status === 1)
          feeApplicationCancel({
            huifu: value,
            bpmProcessId: this.processInstanceId
          }).then((r) => {
            this.$message({
              type: "success",
              message: this.$t("取消成功")
            })
            this.$emit("update:dialogVisible", false)
          })
        })
        .catch(() => {})
    }
  },
  watch: {
    dialogVisible(val) {
      if (val) {
        this.getOrderList()
        getOrder(this.orderId).then((r) => {
          if (r.code === 0) {
            this.orderDetails = r.data
          }
        })
      }
    }
  }
}
</script>

<style scoped lang="scss">
.fee-application {
  padding: 0 20px;

  h1 {
    font-weight: 600;
    font-size: 20px;
  }

  .content {
    width: 200px;
  }
}

.my-process-designer {
  height: calc(100vh - 200px);
}

.box-card {
  width: 100%;
  margin-bottom: 20px;
}
</style>
<style lang="scss">
.isDel {
  display: none;
}
</style>