clrDocument.vue 5.49 KB
Newer Older
lanbaoming's avatar
lanbaoming committed
1 2 3
<template>
  <div>
    <el-form ref="cDocForm" :model="cDocObj" label-width="100px">
liuzeheng's avatar
liuzeheng committed
4
<!--       
lanbaoming's avatar
lanbaoming committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
      <el-form-item :label="$t('出单方式')">
        {{method.find(item=>item.value == cDocObj.cdOutBillType).label}}
      </el-form-item>

      <template v-if="cDocObj.cdOutBillType === '1'">
        <el-form-item :label="$t('电放时间')">
          <el-date-picker type="datetime" :placeholder="$t('请选择日期')" v-model="cDocObj.cdElectricTime" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
        </el-form-item>
        <el-form-item :label="$t('电放凭证附件')">
          <FileUpload :limit="1" :isShowTip=false v-model="cDocObj.cdElectricVoucher" :fileType="fileType" />
        </el-form-item>
      </template>

      <template v-if="cDocObj.cdOutBillType === '2'">
        <el-form-item :label="$t('清关时间')">
          <el-date-picker type="datetime" :placeholder="$t('请选择日期')" v-model="cDocObj.cdSendTime" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
        </el-form-item>

liuzeheng's avatar
liuzeheng committed
23
      </template> -->
lanbaoming's avatar
lanbaoming committed
24 25 26 27 28 29 30 31 32 33 34 35 36

      <el-form-item label="agent list">
        <el-radio-group v-model="cDocObj.cdAgentlistType">
          <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>
        <el-date-picker type="datetime" :placeholder="$t('请选择日期')" v-model="cDocObj.cdAgentlistTime" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
      </el-form-item>
      <el-form-item>
        <FileUpload :limit="1" :isShowTip=false v-model="cDocObj.cdAgentlistFile" :fileType="fileType" />
      </el-form-item>

liuzeheng's avatar
liuzeheng committed
37 38 39 40 41 42 43 44
    
      <el-form-item >
        <ol style="margin-left:-35px;margin-top:-10px;margin-bottom: -10px;">AWB文件上传</ol>
        <FileUpload :limit="1" :isShowTip=false v-model="cDocObj.cdAwbFile" :fileType="fileType" ></FileUpload>
      </el-form-item>
  


lanbaoming's avatar
lanbaoming committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
      <!-- <el-form-item label="soncap">
        <el-radio-group v-model="cDocObj.cdSoncapType">
          <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>
        <el-date-picker type="datetime" :placeholder="$t('请选择日期')" v-model="cDocObj.cdSoncapTime" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
      </el-form-item>
      <el-form-item>
        <FileUpload :limit="1" :isShowTip=false v-model="cDocObj.cdSoncapFile" :fileType="fileType" />
      </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 { clearanceDocCreate } from "@/api/ecw/boxSea";
import {
  constantDict,
  formatDateStr,
  formatNumberString,
  fileTypes,
  serviceMsg,
} from "../utils";
import FileUpload from "@/components/FileUpload";
liuzeheng's avatar
liuzeheng committed
76 77
import { uploadFile } from "@/api/infra/file";
import {getToken} from "@/utils/auth";
lanbaoming's avatar
lanbaoming committed
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
/**
 * 清关文件
 */
export default {
  name: "clrDocument",
  inheritAttrs: false,
  components: { FileUpload },
  data() {
    return {
      // 清关文件对象
      cDocObj: {},
      // 出单方式
      method: constantDict.billingMethod,
      // 选项
      status: constantDict.isFile,
      // 文件类型
      fileType: fileTypes,
liuzeheng's avatar
liuzeheng committed
95 96 97 98 99 100 101 102 103 104 105
            // 用户导入参数
      fileList: [],
      cdAwbFile: null,      
      upload: {
        open: false, // 是否显示弹出层
        title: "", // 弹出层标题
        isUploading: false, // 是否禁用上传
        url: process.env.VUE_APP_BASE_API + "/admin-api/infra/file/upload", // 请求地址
        headers: { Authorization: "Bearer " + getToken() }, // 设置上传的请求头部
        data: {} // 上传的额外数据,用于文件名
      },
lanbaoming's avatar
lanbaoming committed
106 107 108 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 139 140 141 142 143 144 145 146 147 148 149
    };
  },
  created() {
    const voName = this.$attrs.currNode.voName;
    let oldData = { ...this.$attrs.shipmentObj[voName] };
    oldData = formatDateStr(oldData, [
      "cdElectricTime",
      "cdSendTime",
      "cdAgentlistTime",
      "cdSoncapTime",
    ]);
    oldData = formatNumberString(oldData, [
      "cdOutBillType",
      "cdAgentlistType",
      "cdSoncapType",
    ]);
    this.cDocObj = {
      ...oldData,
      cdOutBillType:
        oldData.cdOutBillType === 0 ? undefined : oldData.cdOutBillType,
    };
    this.$set(this.cDocObj,'cdOutBillType','2')
  },
  methods: {
    /** 提交 */
    onSubmit(operateType) {
      this.$refs["cDocForm"].validate((valid) => {
        if (valid) {
          clearanceDocCreate({
            ...this.cDocObj,
            shipmentId: this.$attrs.shipmentObj.id,
            operateType,
          }).then((res) => {
            serviceMsg(res, this).then(() => {
              this.cancel("submit");
            });
          });
        }
      });
    },
    /** 取消 */
    cancel(type) {
      this.$emit("closeDialog", type);
    },
liuzeheng's avatar
liuzeheng committed
150 151 152 153 154 155 156 157 158 159 160 161 162 163
     /** 文件上传成功处理 */
     handleFileSuccess(response, file, fileList) {
      // 清理
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      // 提示成功,并刷新
      this.$modal.msgSuccess("上传成功");
      console.log(fileList);
      console.log(file);
      
      this.$set(this.form, 'this.$refs.cdAwbFile', response.data);
     console.log(cdAwbFile);
    },
lanbaoming's avatar
lanbaoming committed
164 165 166 167 168 169
  },
};
</script>

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