<template>
  <div>
    <el-form ref="blCopyForm" :model="blCopyObj" label-width="120px">
      <el-form-item label="提单Copy">
        <el-upload action="" :file-list="blCopyObj.copyUrl">
          <el-button size="small" type="primary">选择文件</el-button>
        </el-upload>
      </el-form-item>
    </el-form>
    <el-row class="operate-button">
      <el-button type="primary" @click="onSubmit(1)">保存</el-button>
      <el-button type="success" @click="onSubmit(2)">提交</el-button>
      <el-button @click="cancel">关闭</el-button>
    </el-row>
  </div>
</template>

<script>
import { ladingCopyCreate, serviceMsg } from "@/api/ecw/boxSea";
/**
 * 提单copy
 */
export default {
  name: "blCopy",
  inheritAttrs: false,
  data() {
    return {
      // 提单copy对象
      blCopyObj: {},
    };
  },
  created() {
    const voName = this.$attrs.currNode.voName;
    let oldData = { ...this.$attrs.shipmentObj[voName] };
    this.blCopyObj = oldData;
    this.blCopyObj.copyUrl = [];
  },
  methods: {
    /** 提交 */
    onSubmit(operateType) {
      this.$refs["blCopyForm"].validate((valid) => {
        if (valid) {
          ladingCopyCreate({
            ...this.blCopyObj,
            shipmentId: this.$attrs.shipmentObj.id,
            operateType,
          }).then((res) => {
            serviceMsg(res, this).then(() => {
              this.cancel("submit");
            });
          });
        }
      });
    },
    /** 取消 */
    cancel(type) {
      this.$emit("closeDialog", type);
    },
  },
};
</script>

<style lang="scss" scoped>
</style>
