costForm.vue 4.2 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 6 7
      <el-form-item :label="$t('操作步骤')" prop="opStepType">
        <el-select v-model="costObj.opStepType" :placeholder="$t('请选择操作步骤')">
          <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 9 10
        </el-select>
      </el-form-item>

11 12 13
      <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>
14 15 16
        </el-select>
      </el-form-item>

17 18 19
      <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>
20 21 22
        </el-select>
      </el-form-item>

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

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

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

<script>
import { getSupplierPage } from "@/api/ecw/supplier";
import { createCost } from "@/api/ecw/box";
huhaiqing's avatar
huhaiqing committed
49
import { serviceMsg } from "./shippingSea/utils";
50 51 52 53 54 55 56 57 58 59

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

      rules: {
62 63 64 65 66
        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
67
      },
68 69 70 71 72 73 74 75
    };
  },
  created() {
    // 供应商
    getSupplierPage({ pageNo: "1", pageSize: "10000" }).then((res) => {
      const { data } = res;
      this.allSupplier = data.list;
    });
huhaiqing's avatar
huhaiqing committed
76 77
    const { costDetail } = this.$attrs;
    this.costObj = { ...costDetail };
78 79 80 81 82 83
  },
  methods: {
    submit() {
      this.$refs["costForm"].validate((valid) => {
        if (valid) {
          createCost({
huhaiqing's avatar
huhaiqing committed
84
            shipmentId: this.$attrs.shipmentObj.id,
85 86 87
            ...this.costObj,
          }).then((res) => {
            serviceMsg(res, this).then(() => {
huhaiqing's avatar
huhaiqing committed
88
              this.$emit("closeDialog", "cost");
89 90 91 92 93 94 95 96
            });
          });
        }
      });
    },
  },
};
</script>
huhaiqing's avatar
huhaiqing committed
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

<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>