img.vue 7.47 KB
<template>
	<div class="eibs-tab">
		<c-col c-col :span="17" style="padding-right: 20px">
			<c-col :span="12">
				<el-form-item label="查验编号" label-width="80px">
					<c-fullbox>
					<c-input v-model="model.fftref" placeholder="查验编号"></c-input>
					<template slot="footer">
						<c-button  @click="getImguse" size="small" type="primary">获取</c-button>
					</template>
				</c-fullbox>
				</el-form-item>
				
			</c-col>
		</c-col>
		<c-col :span="24" style="margin-top:20px">
			<el-form ref="imgTable" :model="model" label-width="120px" label-position="right" size="small" :validate-on-rule-change="false">
				<el-table max-height="350px" style="text-align: center;" highlight-current-row :data="model.imggrdm.imguseList" :row-class-name="tableRowClassName" @row-click="handleRowClick" :paginationShow="false" :border="true">
					<!-- <el-table-column label="影像批次号" sortable width="auto" prop="imgnum">	
				</el-table-column> -->
				<!-- <el-table-column label="影像种类" sortable min-width="130px" prop="imgflg">
					<template slot-scope="scope">
						<c-select v-model="scope.row.imgflg" dbCode="imgflg" :filterKey="filterKey"></c-select>
					</template>
				</el-table-column> -->
				<el-table-column label="影像ID" sortable min-width="200px" prop="imagid">
					<template slot-scope="scope">
						<el-form-item :prop="'imggrdm.imguseList.' + scope.$index + '.imagid'" label-width="0" :rules="[{required:true,message:'必输项',trigger:['blur','change']}]">
								<c-input v-model="scope.row.imagid" ></c-input>
								</el-form-item>
					</template>
					</el-table-column>
					<el-table-column label="影像类型" sortable min-width="110px" prop="imgtyp">
						<template slot-scope="scope">
							<el-form-item :prop="'imggrdm.imguseList.' + scope.$index + '.imgtyp'" label-width="0" :rules="[{required:true,message:'必输项',trigger:['blur','change']}]">
								<c-select v-model="scope.row.imgtyp" :disabled="scope.row.imgflg == 'JDFP'">
									<el-option v-for="item in imgdbCode" :value='item.value' :label='item.label' :key='item.value'></el-option>
								</c-select>
								</el-form-item>
						</template>
					</el-table-column>
					<el-table-column label="影像描述" sortable min-width="110px" prop="imgdsp">
						<template slot-scope="scope">
							<el-form-item :prop="'imggrdm.imguseList.' + scope.$index + '.imgdsp'" label-width="0" :rules="[{required:true,message:'必输项',trigger:['blur','change']}]">
								<c-input v-model="scope.row.imgdsp" ></c-input>
								</el-form-item>
						</template>
					</el-table-column>
					<el-table-column label="有效标识" sortable min-width="110px" prop="valflg">
							<template slot-scope="scope">
								<el-form-item :prop="'imggrdm.imguseList.' + scope.$index + '.valflg'" label-width="0" :rules="[{required:true,message:'必输项',trigger:['blur','change']}]">
								<c-select v-model="scope.row.valflg" dbCode="vldflg"></c-select>
								</el-form-item>
						
						</template>
					</el-table-column>
					<el-table-column label="" prop="det"  min-width="100px" fixed="right">
						<template slot-scope="scope" slot="header">
							<c-button circle  class="el-icon-plus" size="mini" @click="addRow(scope)">
							</c-button>
							<c-button  circle class="el-icon-minus" size="mini" @click="removeRow(scope)">
							</c-button>
						</template>
					</el-table-column>
				
				</el-table>
				</el-form>
		</c-col>
	</div>
</template>
<script>

import Api from "~/service/Api";
export default {
  inject: ["root"],
  props: ["model", "regmsgtype"],
  data() {
    return {
      imgCurrentZcinvlstIndex: -1,
      imgtypList1: [
        { label: "合同影像ID", value: "CTID" },
        { label: "贸易背景审查ID", value: "TRID" },
        { label: "开证申请书影像ID", value: "LCID" },
        { label: "其他影像ID", value: "OTID" }
      ],
      imgtypList2: [
        { label: "货物收据ID", value: "GRID" },
        { label: "出库单ID", value: "OSID" },
        { label: "装箱单ID", value: "LBID" },
        { label: "入库单ID", value: "WHID" },
        { label: "运输单ID", value: "THID" },
        { label: "保险单ID", value: "ISID" },
        { label: "其他单据影像ID", value: "OTID" }
			],
    };
  },
  mounted() {
  },
  methods: {
    addRow(row) {
      let newRow = {
        imagid: "",
        valflg: "",
        imgtyp: "",
        imgdsp: "",
        isbind: "",
      };
      let start = 0;
      if (this.model.imggrdm.imguseList) {
        start = this.model.imggrdm.imguseList.length;
      }
      this.model.imggrdm.imguseList.splice(start, 0, newRow);
    },
    removeRow() {
      if (this.imgCurrentZcinvlstIndex === -1) {
        this.$notify.error({
          title: "错误",
          message: "请选择一条数据删除!"
        });
        return;
      }
      this.model.imggrdm.imguseList.splice(this.imgCurrentZcinvlstIndex, 1);
      this.imgCurrentZcinvlstIndex = -1;
    },
    handleRowClick(row) {
			console.log('rows',row)
      this.imgCurrentZcinvlstIndex = row.index;
    },
    tableRowClassName({ row, rowIndex }) {
			console.log('111',row,rowIndex)
      row.index = rowIndex;
		},
		//校验发票
		imgTable(){
			this.$refs["imgTable"].validate(async valid => {
        if (!valid) {
					this.$notify({
            title: "失败",
            message: "信用证单证影像校验失败",
            type: "error"
					});
				}
      });
		},
		async getImguse(){
			if(this.model.fftref == ''){
				this.$message.warning("请输入影像编号");
				return
			}
			let res = await Api.post("/manager/invchk/getImfInfoForElcadd",this.model.fftref)
			if(res.respCode == SUCCESS){
				if(res.data.errorMsg){
					this.$message.warning(res.data.errorMsg);
					return
				}
				if(res.data.imguseList != null){
					res.data.imguseList.forEach(e=>{
						e.imagid = '00000000-0000-0000-0000-000000000000'
					})
					if(this.regmsgtype == 'B01' || this.regmsgtype == 'B02'){
						let list = res.data.imguseList.filter((item) =>{
						return item.imgflg == 'JDDJ'
						})
						if(list.length != res.data.imguseList.length){
							this.model.imggrdm.imguseList = this.model.imggrdm.imguseList.concat(list)
							this.$message.warning('只能导入交单单据附件影像');
							return
						}else{
							this.model.imggrdm.imguseList = this.model.imggrdm.imguseList.concat(res.data.imguseList)
						}
					}
					if(this.regmsgtype == 'A01' || this.regmsgtype == 'A03'){
						let list = res.data.imguseList.filter((item) =>{
						return item.imgflg == 'FFHT'
						})
						if(list.length != res.data.imguseList.length){
							this.model.imggrdm.imguseList = this.model.imggrdm.imguseList.concat(list)
							this.$message.warning('只能导入合同影像');
							return
						}else{
							this.model.imggrdm.imguseList = this.model.imggrdm.imguseList.concat(res.data.imguseList)
						}
					}
					
				}
				
			}
		}
  },
  computed: {
    imgdbCode() {
        switch (this.regmsgtype) {
          case "A01":
					case "A03":
            return this.imgtypList1;
            break;
          case "B01":
					case "B02":
            return this.imgtypList2;
            break;
          default:
            return [];
        }
		},
		filterKey(){
			switch (this.regmsgtype) {
          case "A01":
					case "A03":
            return ['FFHT'];
            break;
          case "B01":
					case "B02":
            return ['JDDJ'];
            break;
          default:
            return [];
        }
		}
  },
  created() {}
};
</script>
<style>
</style>