costForm.vue 6.36 KB
Newer Older
lanbaoming's avatar
lanbaoming committed
1 2
<template>
  <div class="app-costForm shippingSea-dialog">
lanbaoming's avatar
lanbaoming committed
3
    <el-form ref="costForm" :model="costObj" :rules="rules" label-width="120px">
lanbaoming's avatar
lanbaoming committed
4
      <el-form-item :label="$t('操作步骤')" prop="opStepType">
lanbaoming's avatar
lanbaoming committed
5 6 7 8 9 10 11 12 13 14
        <el-select
          v-model="costObj.opStepType"
          :placeholder="$t('请选择操作步骤')"
        >
          <el-option
            v-for="type in getDictDatas(DICT_TYPE[this.process])"
            :key="type.value"
            :label="$l(type, 'label')"
            :value="type.value"
          ></el-option>
lanbaoming's avatar
lanbaoming committed
15 16 17 18 19 20 21
        </el-select>
        <!--<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>-->
      </el-form-item>

      <el-form-item :label="$t('费用类型')" prop="costType">
lanbaoming's avatar
lanbaoming committed
22 23 24 25 26 27 28 29 30 31
        <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>
lanbaoming's avatar
lanbaoming committed
32 33 34 35
        </el-select>
      </el-form-item>

      <el-form-item :label="$t('供应商')" prop="supplierId">
lanbaoming's avatar
lanbaoming committed
36 37 38 39 40 41 42 43 44 45
        <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>
lanbaoming's avatar
lanbaoming committed
46 47
        </el-select>
      </el-form-item>
lanbaoming's avatar
lanbaoming committed
48 49 50 51 52 53 54 55 56 57 58
      <!--lanbm 2024-05-17 添加字段-->
      <el-form-item :label="$t('费用产生时间')" prop="freecsdate">
        <el-date-picker
          v-model="costObj.freecsdate"
          style="width: 200px"
          value-format="yyyy-MM-dd HH:mm:ss"
          format="yyyy-MM-dd"
          type="datetime"
          placeholder="费用产生时间"
        />
      </el-form-item>
lanbaoming's avatar
lanbaoming committed
59 60
      <el-row class="two-element-formItem">
        <el-form-item :label="$t('金额')" prop="price">
lanbaoming's avatar
lanbaoming committed
61 62 63 64 65
          <el-input-number
            v-model="costObj.price"
            controls-position="right"
            :min="1"
          ></el-input-number>
lanbaoming's avatar
lanbaoming committed
66 67
        </el-form-item>
        <el-form-item label="" label-width="0px" prop="priceUnit">
lanbaoming's avatar
lanbaoming committed
68 69 70 71 72 73 74 75 76 77
          <el-select
            v-model="costObj.priceUnit"
            :placeholder="$t('请选择单位')"
          >
            <el-option
              v-for="type in this.currencyList"
              :key="type.id"
              :label="$l(type, 'title')"
              :value="type.id"
            ></el-option>
lanbaoming's avatar
lanbaoming committed
78 79 80 81 82
          </el-select>
        </el-form-item>
      </el-row>

      <el-form-item :label="$t('备注')">
lanbaoming's avatar
lanbaoming committed
83 84 85 86 87 88
        <el-input
          v-model="costObj.remarks"
          type="textarea"
          rows="2"
          :placeholder="$t('请输入备注')"
        ></el-input>
lanbaoming's avatar
lanbaoming committed
89 90 91
      </el-form-item>
    </el-form>
    <div class="operate-button">
lanbaoming's avatar
lanbaoming committed
92 93
      <el-button type="primary" @click="submit">{{ $t("确定") }}</el-button>
      <el-button @click="$emit('closeDialog')">{{ $t("取消") }}</el-button>
lanbaoming's avatar
lanbaoming committed
94 95 96 97 98 99 100 101 102
    </div>
  </div>
</template>

<script>
import { getSupplierPage } from "@/api/ecw/supplier";
import { createCost } from "@/api/ecw/box";
import { serviceMsg } from "./shippingSea/utils";
import { getCurrencyList } from "@/api/ecw/currency";
lanbaoming's avatar
lanbaoming committed
103
import { getDictDatas } from "@/utils/dict";
lanbaoming's avatar
lanbaoming committed
104 105 106 107 108 109 110 111 112 113 114 115 116

export default {
  name: "costForm",
  inheritAttrs: false,
  data() {
    return {
      // 费用登记对象
      costObj: {},
      // 供应商
      allSupplier: [],
      currencyList: [],

      rules: {
lanbaoming's avatar
lanbaoming committed
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
        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",
          },
        ],
        freeCsDate: [
          {
            required: true,
            message: this.$t("费用产生时间不能为空"),
            trigger: "blur",
          },
        ],
lanbaoming's avatar
lanbaoming committed
155 156 157 158
      },
      // flag: 'sea'
    };
  },
lanbaoming's avatar
lanbaoming committed
159 160 161
  computed: {
    flag() {
      return this.$attrs.flag || "sea";
lanbaoming's avatar
lanbaoming committed
162
    },
lanbaoming's avatar
lanbaoming committed
163
    process() {
lanbaoming's avatar
lanbaoming committed
164
      return {
lanbaoming's avatar
lanbaoming committed
165 166 167 168 169
        air: "BOX_AIR_SHIPMENT_PROCESS",
        sea: "BOX_SHIPPING_PROCESS",
        seaAir: "BOX_SEA_AIR",
      }[this.flag];
    },
lanbaoming's avatar
lanbaoming committed
170 171 172 173 174 175 176 177 178
  },
  created() {
    // 供应商
    getSupplierPage({ pageNo: "1", pageSize: "10000" }).then((res) => {
      const { data } = res;
      this.allSupplier = data.list;
    });
    const { costDetail } = this.$attrs;
    this.costObj = { ...costDetail };
lanbaoming's avatar
lanbaoming committed
179
    //币种获取接口 lanbm 2024-05-16 添加注释
lanbaoming's avatar
lanbaoming committed
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
    getCurrencyList().then((res) => {
      this.currencyList = res.data ?? [];
    });
    /*if(this.$attrs.shipmentObj.bosType == 'seaAir'){
      this.flag = 'seaAir';
    }*/
  },
  methods: {
    getDictDatas,
    submit() {
      this.$refs["costForm"].validate((valid) => {
        if (valid) {
          createCost({
            shipmentId: this.$attrs.shipmentObj.id,
            ...this.costObj,
          }).then((res) => {
            serviceMsg(res, this).then(() => {
              this.$emit("closeDialog", "cost");
            });
          });
        }
      });
    },
  },
};
</script>

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