templateStx.vue 4.65 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
<template>
	<div>
    <c-button style="margin: 0 0 0 10px; padding: 1px 1px" type="primary" size="small" :disabled="disabledButton" icon="el-icon-more" @click="showCommonDialog()"></c-button>
		<!-- 弹窗 -->
		<el-dialog v-dialogDrag width="80%" :visible.sync="dialogTableVisible" title="报文模版" destroy-on-close v-if="dialogTableVisible">
			<div v-if="!loading && tableList.length === 0">暂无数据</div>
			<div v-else style="width: 100%;height: 100%;">
				<el-table height="calc(100% - 32px)" :data="tableList" @row-dblclick="dbClickRow" >
					<el-table-column v-for="(item,key) in tableColumn" :key="key" :prop="item.prop" :label="item.label">
					</el-table-column>
				</el-table>
			</div>
		</el-dialog>
	</div>
</template>

<script>
import { getLcTxmBlock } from "~/service/business/common"
import commonDepend from '~/mixin/commonDepend.js'
import Api from "~/service/Api"
import _ from 'lodash'
export default {
	inject: ["root"],
	mixins: [commonDepend],
  props: {
    model: {
      type: Object,
      default: () => {}
    },
    extCodes:{
			type: Array,
			default: ()=>[]
		},
		lastModel:{
			type: String,
			default: ''
		},
    inifrm:{
			type: String,
			default: ''
		},
		isRules:{
			type: Boolean,
			default: true
		},
		//按钮和输入框同时灰显
		disabledButton: {
			type: Boolean,
			default: false
		},
		charmod: {
			type:Number,
			default: 0
		},
		isLeavl:{
			type: Boolean,
			default: true
		},
		dis:{
			type:Boolean,
			default:false
		},
		requiredExtkey:{
			type:Boolean,
			default:false
		},
		uil:{
			type:String,
			default: ''
		},
    trntyp:{
			type:String,
			default: ''
		},
    inifrm:{
      type:String,
      default:'',
    },
		title:String,
		cols: { type: Number, default: 1 },
		rows: { type: Number, default: 1 },
		minRows: { type: Number, default: 4 },
		maxRows: { type: Number, default: 4 },
	},
	computed:{
		// 额外字段处理成字符串
    formatExtCodesToStr() {
      if (this.extCodes && this.extCodes.length > 0) {
        return this.extCodes.join('.') + '.'
      } else {
        return ''
      }
		},
		modifySet(){
			let extCodes = this.extCodes || []
      return [...extCodes]
		},
		// 简化字段写法
    formatCodes () {
      let extCodes = this.extCodes || []
      return [...extCodes, this.lastModel]
    },
    // extkey的计算属性
    modelExtkey: {
      get() {
        let codesList = this.formatCodes
        return _.get(this.model, codesList)
      },
      set(val) {
        let codesList = this.formatCodes
        _.set(this.model, codesList, val)
      }
    },
	},
  data() {
    return {
      dialogTableVisible: false,
      tableList: [],
			loading: true,
			markText:'',
			canUseRow: this.rows,
      tableColumn: [ 
				{ prop: "nam", label: "名称" },
				{ prop: "swttxt",label: "Text"},
				{ prop: "extkey", label: "Text Module" },
        { prop: "ptyextkey", label: "BIC" },
			],
    };
  },
  watch:{
    modelExtkey(val,oldval){
      if(!val){
        this.markText = ''
      }else{
        this.markText = val
      }
    }
  },

  methods: {
    showCommonDialog() {
      this.getTableData();
    },
    async getTableData() {
      this.tableList = []
      if(!this.model.fremsg.othmsg.pts.extkey){
         this.$notify.error({ title: '错误', message: '请选择或输入收报行!'});
          return;
      }
			this.dialogTableVisible = true;
      this.loading = true;
      let params = {
				ptyextkey:  this.model.fremsg.othmsg.pts.extkey ,
        trntyp: this.inifrm == 'BPDFRE' ? 'FP' : this.inifrm.substr(0,2),
        dfuflg: this.model[this.trntyp + 'grp'].rec.dfuflg ? this.model[this.trntyp + 'grp'].rec.dfuflg : ''
      };
      const res = await Api.post('/manager/stx/queryTemp', params);
      if (res.respCode == SUCCESS) {
        if (res.data) {
					this.tableList = res.data;
        }
      }
      this.loading = false;
    },
    //回填数据
    dbClickRow(row) {
			this.customAddModify(_.get(this.model,this.modifySet),`${this.lastModel}`)
      if(!this.markText){
        this.markText = row.swttxt
      }else{
        this.markText = this.markText + '\n' + row.swttxt
      }
      _.set(this.model,[...this.formatCodes],this.markText) ;
      this.$emit('handelChange')
			this.dialogTableVisible = false;
		},
		changeExtkey(val){
			this.customAddModify(_.get(this.model,this.modifySet),`${this.lastModel}`)
			this.markText = val
			if(this.isLeavl){
				this.canUseRow = this.markText ? this.rows - this.markText.split('\n').length : this.rows
			}
			this.$emit('handelChange')
			
		}
  }
};
</script>

<style scoped lang="less">
::v-deep .el-dialog__body {
	height: calc(100% - 55px)
}
.el-table .cell {
  white-space: pre-wrap;
}
</style>