<template>
  <el-dialog v-dialogDrag width="80%" title="待分配业务" v-if="visiable" :visible.sync="visiable" :before-close="handleClose">
    <div v-if="!loadingFlag && stmData.data.length === 0">暂无数据</div>
    <div v-else style="height: 100%;">
      <el-table id='tableRef' size="small" :data="stmData.data" height="calc(100% - 36px)" v-loading="loadingFlag" >
              <el-table-column label="交易品种" prop="frm" sortable  width="150px">
                <template slot-scope="scope">{{scope.row.frm}}</template>
              </el-table-column>
              <el-table-column label="业务编号" prop="objref" sortable  width="150px">
                <template slot-scope="scope">{{scope.row.objref}}</template>
              </el-table-column>
               <el-table-column label="币种" prop="relcur" sortable width="80px"  >
                <template slot-scope="scope">{{scope.row.relcur}}</template>
              </el-table-column>
              <el-table-column label="金额" prop="relamt" sortable  width="150px" >
                <template slot-scope="scope">{{moneyFormat(scope.row.relamt)}}</template>
              </el-table-column>
              <el-table-column label="交易状态" prop="status" sortable width="150px" >
                <template slot-scope="scope">{{getCodelabel(scope.row.status,'status')}}</template>
              </el-table-column>
              <el-table-column label="创建时间" prop="createTime" sortable width="150px" >
                <template slot-scope="scope">{{scope.row.createTime}}</template>
              </el-table-column>
              <el-table-column label="经办机构" prop="bchkeyinr" sortable width="210px"  >
                <template slot-scope="scope">{{bchFormat(scope.row.bchkeyinr)}}</template>
              </el-table-column>
                <el-table-column label="分配柜员" prop="usr" sortable width="150px" show-overflow-tooltip>
                <template slot-scope="scope">{{scope.row.usr}}</template>
                 </el-table-column>
               <el-table-column label="分配状态" prop="distStatus" sortable width="150px" show-overflow-tooltip >
                <template slot-scope="scope">{{getCodelabel(scope.row.distStatus,'distStatus')}}</template>
              </el-table-column>
              <el-table-column label="备注" prop="remark" sortable width="150px" show-overflow-tooltip >
                <template slot-scope="scope">{{scope.row.remark}}</template>
              </el-table-column>
      </el-table>
      <el-pagination :current-page.sync="pagination.pageIndex" :page-sizes="[5, 10, 20]" :page-size="pagination.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="pagination.total" @size-change="handleSizeChange" @current-change="handleCurrentChange"></el-pagination>
    </div>
  </el-dialog>
</template>
<script>
import Api from '~/service/Api';
export default {
	name: 'manualAssignDialog',
	props: {
		isShowManualAssign: {
			type: Boolean,
			default: false
		},
		multipleSelection: {
			type: Array,
			default: () => []
    },
    distTyp:{

    },
    dbCodes:{
      
    }
	},
	data () {
		return {
       stmData: {
        columns: [
          { label: "交易品种", prop: "frm", width: "100px" },
          { label: "业务编号", prop: "objref", width: "170px" },
          { label: "币种", prop: "relcur", width: "80px" },
          { label: "金额", prop: "relamt", width: "80px" },
          { label: "分配柜员", prop: "usr", width: "100px" },
          { label: "交易状态", prop: "status", width: "100px" },
          { label: "创建时间", prop: "createTime", width: "160px" },
          { label: "归属机构", prop: "branchinr", width: "240px" },
          { label: "经办机构", prop: "bchkeyinr", width: "210px" },
          { label: "备注", prop: "remark", width: "210px" },
          { label: "业务类型", prop: "cla", width: "100px" },
        ],
        data: []
      },
			visiable: false,
			loadingFlag: false,
      tableList: [],
      bchtypList: [],
      pagination: {
        pageIndex: 1,
        pageSize: 10,
        total: 0
      },
		}
	},
	watch: {
		isShowManualAssign (newVal) {
			if (newVal) {
        this.visiable = true
        this.getBranchList();
				this.searchUnAssign()
			}
		}
	},
	methods: {
     async getBranchList() {
      const res = await Api.post("/public/quesel/getBranchList");
      if (res.respCode == SUCCESS) {
        this.bchtypList = res.data.list;
      }
    },
    getCodelabel(value,codenam) {
          const codeobj = this.dbCodes[codenam].find(obj => obj.value === value)
          return codeobj ? codeobj.label : value;
    },
    bchFormat(value){
      const codeobj = this.bchtypList.find(obj => obj.inr === value)
      return codeobj ? codeobj.bchname : value;
    },
    async searchUnAssign() {
			let params = {
				pageNo: this.pagination.pageIndex,
				pageSize: this.pagination.pageSize,
			};
			const loading = this.$loading();
			const res = await Api.post('/public/quesel/manUnTaskList', params);
			if (res.respCode === SUCCESS) {
				this.stmData.data = res.data.list;
        this.pagination.total = Number(res.data.total);
			}
			loading.close();
    },
    //格式化表格码表
    getCodeTableValue(value,codenam){
      const codeobj = this.dbCodes[codenam].find(obj => obj.value === value)
      return codeobj ? codeobj.label : value;
    },
    handleSizeChange(val) {
			this.pagination.pageIndex = 1;
			this.pagination.pageSize = val;
			this.queryTableData();
    },
    handleCurrentChange(val) {
			this.pagination.pageIndex = val;
			this.queryTableData();
		},
		handleClose () {
			this.visiable = false
			this.$emit('closeDialog')
		},
	}
}
</script>
<style lang="less" scoped>
</style>