costForm.vue 4.73 KB
Newer Older
1
<template>
huhaiqing's avatar
huhaiqing committed
2
  <div class="app-costForm shippingSea-dialog">
wanglianghe's avatar
wanglianghe committed
3
    <el-form ref="costForm" :model="costObj" :rules="rules" label-width="80px">
4

5
      <el-form-item :label="$t('操作步骤')" prop="opStepType">
6
        <el-select v-if="flag=='sea'" v-model="costObj.opStepType" :placeholder="$t('请选择操作步骤')">
7
          <el-option v-for="type in this.getDictDatas(DICT_TYPE.BOX_SHIPPING_PROCESS)" :key="type.value" :label="$l(type, 'label')" :value="type.value"></el-option>
8
        </el-select>
9 10 11
        <el-select v-if="flag=='seaAir'" v-model="costObj.opStepType" :placeholder="$t('请选择操作步骤')">
          <el-option v-for="type in this.getDictDatas(DICT_TYPE.BOX_SEA_AIR)" :key="type.value" :label="$l(type, 'label')" :value="type.value"></el-option>
        </el-select>
12 13
      </el-form-item>

14 15 16
      <el-form-item :label="$t('费用类型')" prop="costType">
        <el-select v-model="costObj.costType" :placeholder="$t('请选择费用类型')">
          <el-option v-for="type in this.getDictDatas(DICT_TYPE.FEE_TYPE)" :key="type.value" :label="$l(type, 'label')" :value="type.value"></el-option>
17 18 19
        </el-select>
      </el-form-item>

20 21 22
      <el-form-item :label="$t('供应商')" prop="supplierId">
        <el-select v-model="costObj.supplierId" :placeholder="$t('请选择供应商')">
          <el-option v-for="supplier in allSupplier" :key="supplier.id" :label="$l(supplier, 'company')" :value="supplier.id"></el-option>
23 24 25
        </el-select>
      </el-form-item>

huhaiqing's avatar
huhaiqing committed
26
      <el-row class="two-element-formItem">
27
        <el-form-item :label="$t('金额')" prop="price">
28 29
          <el-input-number v-model="costObj.price" controls-position="right" :min="1"></el-input-number>
        </el-form-item>
wanglianghe's avatar
wanglianghe committed
30
        <el-form-item label="" label-width="0px" prop="priceUnit">
31
          <el-select v-model="costObj.priceUnit" :placeholder="$t('请选择单位')">
huhaiqing's avatar
huhaiqing committed
32
            <el-option v-for="type in this.currencyList" :key="type.id" :label="$l(type, 'title')" :value="type.id"></el-option>
33 34 35 36
          </el-select>
        </el-form-item>
      </el-row>

37 38
      <el-form-item :label="$t('备注')">
        <el-input v-model="costObj.remarks" type="textarea" rows="2" :placeholder="$t('请输入备注')"></el-input>
39 40 41
      </el-form-item>

    </el-form>
huhaiqing's avatar
huhaiqing committed
42
    <div class="operate-button">
43 44
      <el-button type="primary" @click="submit">{{$t('确定')}}</el-button>
      <el-button @click="$emit('closeDialog')">{{$t('取消')}}</el-button>
45 46 47 48 49 50 51
    </div>
  </div>
</template>

<script>
import { getSupplierPage } from "@/api/ecw/supplier";
import { createCost } from "@/api/ecw/box";
huhaiqing's avatar
huhaiqing committed
52
import { serviceMsg } from "./shippingSea/utils";
huhaiqing's avatar
huhaiqing committed
53
import { getCurrencyList } from "@/api/ecw/currency";
54 55 56 57 58 59 60 61 62 63

export default {
  name: "costForm",
  inheritAttrs: false,
  data() {
    return {
      // 费用登记对象
      costObj: {},
      // 供应商
      allSupplier: [],
huhaiqing's avatar
huhaiqing committed
64
      currencyList: [],
wanglianghe's avatar
wanglianghe committed
65 66

      rules: {
67 68 69 70 71
        opStepType: [{ required: true, message: this.$t("操作步骤不能为空"), trigger: "change" }],
        costType: [{ required: true, message: this.$t("费用类型不能为空"), trigger: "change" }],
        supplierId: [{ required: true, message: this.$t("供应商不能为空"), trigger: "blur" }],
        price: [{ required: true, message: this.$t("金额不能为空"), trigger: "blur" }],
        priceUnit: [{ required: true, message: this.$t("金额单位不能为空"), trigger: "blur" }]
wanglianghe's avatar
wanglianghe committed
72
      },
73
      flag: 'sea'
74 75 76 77 78 79 80 81
    };
  },
  created() {
    // 供应商
    getSupplierPage({ pageNo: "1", pageSize: "10000" }).then((res) => {
      const { data } = res;
      this.allSupplier = data.list;
    });
huhaiqing's avatar
huhaiqing committed
82 83
    const { costDetail } = this.$attrs;
    this.costObj = { ...costDetail };
huhaiqing's avatar
huhaiqing committed
84 85 86
    getCurrencyList().then((res) => {
      this.currencyList = res.data ?? [];
    });
87 88 89
    if(this.$attrs.shipmentObj.bosType == 'seaAir'){
      this.flag = 'seaAir';
    }
90 91 92 93 94 95
  },
  methods: {
    submit() {
      this.$refs["costForm"].validate((valid) => {
        if (valid) {
          createCost({
huhaiqing's avatar
huhaiqing committed
96
            shipmentId: this.$attrs.shipmentObj.id,
97 98 99
            ...this.costObj,
          }).then((res) => {
            serviceMsg(res, this).then(() => {
huhaiqing's avatar
huhaiqing committed
100
              this.$emit("closeDialog", "cost");
101 102 103 104 105 106 107 108
            });
          });
        }
      });
    },
  },
};
</script>
huhaiqing's avatar
huhaiqing committed
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

<style lang="scss">
// 海运操作统一弹窗样式
.shippingSea-dialog {
  // 页面内元素弹窗form控件宽度设置
  .el-form-item__content {
    > div:not(.el-input-number) {
      width: 100%;
    }
  }
  .operate-button {
    text-align: center;
  }
  .two-element-formItem {
    display: flex;
    > :last-child {
      width: 100%;
      margin-left: 10px;
    }
  }
  .two-element {
    .el-form-item__content {
      display: flex;
      > :last-child {
        margin-left: 10px;
      }
    }
  }
}
</style>