<template> <div> <el-form ref="shipForm" :model="shipObj" :rules="rules" label-width="80px"> <el-form-item :label="$t('状态')" prop="saExmtStatus"> <el-radio-group v-model="shipObj.saExmtStatus"> <el-radio v-for="item in status" :key="item.value" :label="item.value">{{item.label}}</el-radio> </el-radio-group> </el-form-item> <el-form-item :label="$t('配船时间')" v-show="shipObj.saExmtStatus === '2'"> <el-date-picker type="datetime" :placeholder="$t('请选择日期')" v-model="shipObj.configTime" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker> </el-form-item> </el-form> <el-row class="operate-button"> <el-button type="primary" @click="onSubmit(1)">{{$t('保存')}}</el-button> <el-button type="success" @click="onSubmit(2)">{{$t('提交')}}</el-button> <el-button @click="cancel">{{$t('关闭')}}</el-button> </el-row> </div> </template> <script> import { shipConfigure } from "@/api/ecw/boxSea"; import { formatNumberString, formatDateStr, constantDict, serviceMsg, } from "../utils"; /** * 配船 */ export default { name: "ship", inheritAttrs: false, props: { shipmentObj: Object, }, data() { return { // 配船对象 shipObj: {}, // 状态 status: constantDict.saExmtStatus, // 校验 rules: { saExmtStatus: [{ required: true, message: this.$t("必填"), trigger: "change" }], }, }; }, created() { const voName = this.$attrs.currNode.voName; let oldData = { ...this.shipmentObj[voName] }; oldData = formatNumberString(oldData, ["saExmtStatus"]); oldData = formatDateStr(oldData, ["configTime"]); this.shipObj = oldData; }, methods: { /** 提交 */ onSubmit(operateType) { this.$refs["shipForm"].validate((valid) => { if (valid) { shipConfigure({ operateType, shipmentId: this.shipmentObj.id, ...this.shipObj, }).then((res) => { serviceMsg(res, this).then(() => { this.cancel("submit"); }); }); } }); }, /** 取消 */ cancel(type) { this.$emit("closeDialog", type); }, }, }; </script> <style lang="scss" scoped> </style>