scan.vue 6.87 KB
Newer Older
fukai committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 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 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 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
<template>
	<el-row style="height:100%;position:relative;" :style="{paddingRight:closed?'15px':'0px'}" :gutter="2">
		<el-col :span="closed?24:18" style="height:100%">
			<!-- <SunscanDialog ref="sunscan" :mode='mode' :params="sunscanParams" @refresh="getDocidList()"></SunscanDialog> -->
			<!-- <SunscanDialog v-if="scanType == 'old'" ref="sunscan" :mode='mode' :params="sunscanParams" @refresh="getDocidList()"></SunscanDialog>
			<NewSunscanDialog v-if="scanType == 'new'" ref="sunscan" :mode='mode' :params="sunscanParams" @refresh="refresh"></NewSunscanDialog> -->
      
		</el-col>
    <i :class="closed?'el-icon-d-arrow-left':'el-icon-d-arrow-right'" :style="{right:closed?'0':'calc(25% - 15px)'}" style="position:absolute;top:48%;cursor:pointer;z-index:999;font-weight:bolder" @click="toggleClosed" ></i>
		<el-col v-show="!closed" :span="6" style="height:100%;padding-top: 6px;box-sizing: border-box;background: rgb(240, 240, 240);">

			<button @click="newSunscan()">新增</button>
			<el-table class="table-small" height="calc(100vh - 115px)" :data="list" tooltip-effect="dark" fit>
				<el-table-column label="日期" min-width="25%" show-overflow-tooltip>
					<template slot-scope="scope">
						{{format(scope.row.optime)}}
					</template>
				</el-table-column>
				<el-table-column label="柜员" prop="opuser" min-width="20%" show-overflow-tooltip></el-table-column>
				<el-table-column label="批次" prop="lotnum" min-width="40%" show-overflow-tooltip></el-table-column>
				<el-table-column label="操作" min-width="15%">
					<template slot-scope="scope">
						<el-dropdown @command="handleCommand($event,scope.row,scope.$index)">
							<i class="el-icon-more"></i>
							<el-dropdown-menu slot="dropdown">
								<el-dropdown-item command="view">查看</el-dropdown-item>
								<el-dropdown-item command="edit">编辑</el-dropdown-item>
							</el-dropdown-menu>
						</el-dropdown>
					</template>
				</el-table-column>
			</el-table>
      <el-pagination
        layout="prev,pager,next"
        :page-size="20"
        :pager-count="5"
        :total="total"
        style="height: 30px;"
        @current-change="handlePageClick"
      ></el-pagination>
		</el-col>
	</el-row>
</template>
<script>

import Api from "~/service/Api";
import moment from "moment";
export default {
  name: "webScan",
  props: {
    ip: {
      type: String
    },
    port: {
      type: String
    },
    org: {
      type: String
    },
    mode:{
			type: String,//scan:批扫 view:查看 bind:绑定
    },
    scanType:String,//新老影像控件标志
  },
 // components: { SunscanDialog ,NewSunscanDialog },
  data() {
    return {
      SUCCESS: "AAAAAA",
      chooseRowIndex: -1,
      sunscanParams: {
        optionType: "0",
        ip: this.ip,
        port: this.port,
        docid: "",
        date: "",
        org: "",
        oper: "",
        refresh:false,
      },
      list: [],
      total: 0,
      pageNum: 1,
      closed:true,
    };
  },
  watch: {
    ip: {
      handler(val) {
        if (!val) return;
      },
      immediate: true
    },
    port: {
      handler(val) {
        if (!val) return;
      },
      immediate: true
    }
  },
  mounted() {
    this.getDocid();
    this.getDocidList();
    console.log(this.scanType , '进到影像页面:scan')
  },
  methods: {
    async refresh(val, docid) {
      console.log(val)
      await this.getDocidList('refresh', val, docid)
    },
    toggleClosed(){
      this.closed = !this.closed
    },
    format(date) {
      return moment(date).format("YYYYMMDD");
    },
    async handleCommand(val,row,index) {
      this.sunscanParams.refresh = !this.sunscanParams.refresh
      if (val == "edit") {
				this.sunscanParams.org = row.branch;
        this.sunscanParams.oper = row.imgusr;
        this.sunscanParams.ip = this.ip;
        this.sunscanParams.port = this.port;
        this.sunscanParams.optionType = "1";
        this.sunscanParams.docid = row.lotnum;
        this.sunscanParams.date = this.format(row.optime);
        index ? this.chooseRowIndex = index : 0
      } else if (val == "view") {
				this.sunscanParams.org = row.branch;
        this.sunscanParams.oper = row.imgusr;
        this.sunscanParams.ip = this.ip;
        this.sunscanParams.port = this.port;
        this.sunscanParams.optionType = "2";
        this.sunscanParams.docid = row.lotnum;
        this.sunscanParams.date = this.format(row.optime);
      } else if (val == "delete") {
        await this.$emit("delete", row.lotnum);
        await this.getDocidList();
      }
    },
    newSunscan() {
      this.getDocid();
    },
    getDocid() {
      Api.post("/manager/img/generateLotNum").then(res => {
        if (res.respCode == this.SUCCESS) {
          this.sunscanParams.docid = res.data.lotNum;
          this.sunscanParams.optionType = "0";
          this.sunscanParams.date = this.format();
          this.sunscanParams.ip = this.ip;
          this.sunscanParams.port = this.port;
          this.sunscanParams.org = this.org;
        }
      });
    },
    async getDocidList(str, typ, docid) {
      await Api.post("/manager/img/listUnbindLotNum",{
        branch:this.org,
        pageSize: 20,
        pageNum: this.pageNum
      }).then(res => {
        if (res.respCode == this.SUCCESS) {
          this.list = res.data.list;
          this.total = res.data.total
          console.log(res)
          if(str == 'refresh') {
						let curRowList = this.list.filter((itm) => {
							return itm.lotnum === docid
						})
						let curRow = {}
						if (curRowList && curRowList.length > 0) {
							curRow = curRowList[0]
						}
						console.log('curRow=====', curRow)
            curRow && curRow.lotnum ? this.handleCommand('view', curRow) : this.afterDoBindRefresh(docid)
          }
        }
      });
		},
		afterDoBindRefresh(docid) {
			let data = {
        ownref: this.sunscanParams.tradeCode,
        imginr: this.sunscanParams.imginr,
        trninr: null,
        msginr: this.sunscanParams.smhinr,
        branch: this.sunscanParams.org
      };
      Api.post("/manager/img/listBindLotNum", data).then(res => {
        if (res.respCode == "AAAAAA") {
					this.list = res.data;
					let curRowList = this.list.filter((itm) => {
						return itm.lotnum === docid
					})
					let curRow = {}
					if (curRowList && curRowList.length > 0) {
						curRow = curRowList[0]
					}
					this.handleCommand('view', curRow)
        }
      });
		},
    async handlePageClick(page) {
      console.log(page)
      this.pageNum = page
      await this.getDocidList();
    }
  }
};
</script>
<style scoped lang="less">
::v-deep .el-dialog {
  height: 90vh;
  margin: 5vh auto;
  .el-dialog__body {
    position: relative;
    height: calc(100% - 54px);
  }
}
::v-deep .el-tabs__content {
  height: 100%;
}
::v-deep .el-tab-pane {
  height: 100%;
}

::v-deep .el-pager li {
  min-width: 22px;
}
::v-deep .el-pagination .btn-prev {
  padding: 0 3px;
}
::v-deep .el-pagination .btn-next {
  padding: 0 3px;
}
</style>