Infsea.vue 13.1 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 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474
<template>
  <div class="eibs-tab">
    <!-- ----------左 ---------->
    <c-col :span="12" class="col-left">
      <c-col :span="24">
        <el-form-item label="客户号" prop="extkey">
          <c-input
            v-model="ptyCondition.extkey"
            placeholder="请输入客户号"
          ></c-input>
        </el-form-item>
      </c-col>
      <c-col :span="24">
        <el-form-item label="客户中文名称" prop="cnnam">
          <c-input
            v-model="ptyCondition.cnnam"
            placeholder="请输入客户中文名称"
          ></c-input>
        </el-form-item>
      </c-col>
    </c-col>
    <!-- ----------右 ---------->
    <c-col :span="12" class="col-left">
      <c-col :span="24">
        <el-form-item label="客户所属机构" prop="branchcode">
          <el-select
            v-model="ptyCondition.branchcode" clearable 
            placeholder="请输入客户所属机构" filterable
            :isShowKeyAndLabel="true"
          >
            <el-option v-for="item in bchcodelist" :key="item.branch" :label="item.bchname"
                      :value="item.branch">
              <span style="float: left">{{ item.branch }} - {{ item.bchname }}</span>
            </el-option>
           </el-select>
        </el-form-item>
      </c-col>
      <c-col :span="24">
        <el-form-item label="客户英文名称" prop="ennam">
          <c-input
            v-model="ptyCondition.ennam"
            placeholder="请输入客户英文名称"
          ></c-input>
        </el-form-item>
      </c-col>
    </c-col>
    <!--新增/重置/查询按钮-->
    <c-col :span="24">
      <span style="float: left">
        <el-button type="primary" size="small" v-if="showInsertBtn" :disabled="true" @click="ptyAdd">新增</el-button>
      </span>
      <span style="float: right">
        <el-button size="small" @click="handleReset">重置</el-button>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="small"
          @click="onSearch()"
          :loading="loadingPtyStatus" 
          >查询
        </el-button>
      </span>
    </c-col>
    <!--列表以及操作栏-->
    <c-col :span="24">
      <c-paging-table 
        :data="ptyData"
        :columns="ptyColumns"
        :pageNumber="ptyCondition.pageNum"
        :pageSize="ptyCondition.pageSize"
        :total="ptyCondition.total"
        v-on:queryFunc="queryFunc"
        :border="true"
      >
        <c-table-column fixed="right" prop="op" label="操作" width="240px">
          <template slot-scope="{ scope }">
            <c-button
              style="margin-left: 0"
              size="small"
              @click="ptyInfo(scope.$index, scope.row)"
              >详情</c-button
            >
            <c-button
              style="margin-left: 5px"
              size="small"
              type="primary"
              @click="ptyEdit(scope.$index, scope.row)"
              v-if="showUpdateBtn"
              >修改</c-button
            >
            <c-button
              size="small"
              style="margin-left: 5px"
              @click="ptyDelete(scope.$index, scope.row)"
              v-if="showDeleteBtn"
              >删除</c-button
            >
          </template>
        </c-table-column>
      </c-paging-table>
    </c-col>
  </div>
</template>

<script>
import codes from "~/config/CodeTable";

import { queryByPage, deleteById, getBchcodlist } from "~/service/manage/pty.js";
import Pty from '../Dbipty/Pty.js';
import Api from "~/service/Api";
import commonFunctions from "~/mixin/commonFunctions.js";

export default {
  name: "",
  props: ["model"],
  inject: ["root"],
  mixins: [commonFunctions],
  data() {
    return {
      showUpdateBtn:false,
      showDeleteBtn:false,
      showInsertBtn: false,
      ptyData: [],
      bchcodelist: [],
      ptyCondition: {
        extkey: "",
        cnnam: "",
        ennam: "",
        branchcode: "",
        pageSize:PageSize,
        pageNum: 1,
        total: 0,
      },
      loadingPtyStatus:false,
      ptyColumns: [
				{ label: '客户号', prop: 'extkey', width: 'auto' },
        { label: '中文名称', prop: 'cnnam', width: 'auto' },
        { label: '中文地址', prop: 'cnadr', width: 'auto' },
        { label: '英文名称', prop: 'ennam', width: 'auto' },
        { label: '英文地址', prop: 'enadr', width: 'auto' },
        { label: '停用状态', prop: 'oitsubtyp_lab', width: 'auto' }
      ],
      canMod: true,
      bchAuthMod:{
        _cod:"",
        _msg:"",
        maaFlg:"N",
        maaMsg:"",
        mabFlg:"N",
        mabMsg:"",

        cod_:"",
        msg_:"",
        zFlg:"N",
        zMsg:"",
        zBchList:[],
        zBchkeyList:[],
        zBranchList:[],

        xFlg:"N",
        xMsg:"",
        xBchList:[],
        xBchkeyList:[],
        xBranchList:[],
      },
      PtyUsedInPts:{
        cod:"",
        msg:"",
      },
    };
  },
  created() {
    this.ptyCondition.pageSize=PageSize,
    this.ptyCondition.pageNum=1,
    this.getCodelist()
    //this.onInfptySearch()
  },
  watch: {
    '$store.state.UserContext.currentOrg': {
      handler(newVal) {
        this.getCodelist()
      }
    }
  },
  computed: {
  },
  activated() {
    const { update } = this.$route.params
    if (update) {
      this.onInfptySearch()
    }
  },
  mounted(){
    this.getHiddenButtonVue();
	},
  methods: {
    getHiddenButtonVue(){
        const loading = this.loading();
        this.$buttonControlService.hiddenBtnList()
          .then((res) => {
            // 新增
            let hasInsert = res.some((item) => {
              return item.ITEMID === 'ptyInsertBtn';
            })
            if (hasInsert) {
              this.showInsertBtn = false;
            } else {
              this.showInsertBtn = true;
            }
            // 修改
            let hasUpdate = res.some((item) => {
              return item.ITEMID === 'ptyUpdateBtn';
            })
            if (hasUpdate) {
              this.showUpdateBtn = false;
            } else {
              this.showUpdateBtn = true;
            }
            // 删除
            let hasDelete = res.some((item) => {
              return item.ITEMID === 'ptyDeleteBtn';
            })
            if (hasDelete) {
              this.showDeleteBtn = false;
            } else {
              this.showDeleteBtn = true;
            }
            loading.close();
          })
      },
    //重置查询条件
    handleReset() {
      this.ptyCondition = {
        extkey: "",
        cnnam: "",
        ennam: "",
        branchcode: "",
        pageSize:PageSize,
        pageNum: 1,
        total: 0,
        ptytyp:"C",
      };
    },
    getCodelist() {
      getBchcodlist({}).then((res) => {
        if (res.respCode == "AAAAAA") {
          const list = res.data
          this.bchcodelist = list
        }
      })
    },

    //点击查询,插叙PTY列表
    onSearch(){
        this.ptyCondition.pageNum = 1;
        this.ptyCondition.pageSize=PageSize;
        this.onInfptySearch();
    },
    
    onInfptySearch() {
      this.loadingPtyStatus=true;
			queryByPage(this.ptyCondition).then(res => {
        /**
         * pageNumber: 0
         * pageSize:	0
         * total: 69
         * totalPage: 0
         */
        if(res.respCode == SUCCESS) {
          if (res.data.list.length<=0){
            this.$notify.warning({
            	title: '提示:',
              message: "未查询到客户信息!",
              dangerouslyUseHTMLString: true 
            });
          }
          const list = res.data.list
          this.ptyData = list
          this.ptyCondition.pageNum = res.data.pageNumber
          this.ptyCondition.pageSize = res.data.pageSize
          this.ptyCondition.total = res.data.total
          
        }
        this.loadingPtyStatus=false;
      }) 
		},
    queryFunc(pageNumber, pageSize) {
      this.ptyCondition.pageNum = pageNumber
      this.ptyCondition.pageSize = pageSize
      if (!this.ptyCondition.pageNum) {
        this.ptyCondition.pageNum = 1;
      }
      if (!this.ptyCondition.pageSize) {
        this.ptyCondition.pageSize=PageSize;
      }
      this.onInfptySearch()
    },
    ptytypeChange(val) {
      this.model.ptytyp = val;
    },
    getCodesByKey(key) {
      return codes[key] || [];
    },
    ptyAdd() {
			this.$router.push({ name: "StaticsDbapty"})
		},
    ptyInfo(index, row) {
			this.$router.push( { name: "StaticsDbipty", query: { inr: row.inr,ptainr: row.ptainr} })
		},
    
    async ptyEdit(index, row) {
      //await this.checkZXbanForExtkeyBySSTF(row.inr)
      await this.checkZXbanForExtkeyByEcif0930(row.extkey)
      
        if (this.bchAuthMod.zFlg != "Y" && this.bchAuthMod.xFlg != "Y"){
          let tmpMsg=this.bchAuthMod.msg_ +"<br/>"+this.bchAuthMod.zMsg +"<br/>"+this.bchAuthMod.xMsg
          this.$notify.warning({
            	title: '提示:',
              message: tmpMsg,
              dangerouslyUseHTMLString: true 
            });
          return 0;
        }
      
      
      //cache写入ECIF主协办机构信息
      localStorage.setItem("bchAuthMod",JSON.stringify(this.bchAuthMod))
      let bchAuthMod=JSON.parse(localStorage.getItem("bchAuthMod"))

      let data= { 
        inr: row.inr,
        ptainr: row.ptainr,
        maaFlg:this.bchAuthMod.maaFlg,
        mabFlg:this.bchAuthMod.mabFlg,
        zFlg:this.bchAuthMod.zFlg,
        xFlg:this.bchAuthMod.xFlg,
      }
			this.$router.push( { name: `StaticsDbepty`, query:data})
		},

    async ptyDelete(index, row) {
      //await this.checkZXbanForExtkeyBySSTF(row.inr)
      await this.checkZXbanForExtkeyByEcif0930(row.extkey)
      if (this.bchAuthMod.zFlg != "Y"){
        let zBchkeyMsg="" 
        if (this.bchAuthMod.zBchkeyList !=null && this.bchAuthMod.zBchkeyList.length>0){
          for (let j of this.bchAuthMod.zBchkeyList){
            let tmp=j.branch +" - "+j.bchname
            zBchkeyMsg=zBchkeyMsg+"<br/>"+tmp
          }
        }
        
        this.$notify.warning({
            	title: '提示:',
              message: "无权删除! 管户机构:"+zBchkeyMsg,
              dangerouslyUseHTMLString: true 
            });
        return 0;
      }

      await this.checkPtyUsedInPts(row.inr)
      if (this.PtyUsedInPts.cod == "Y"){
        this.$notify.warning({
            	title: '提示:',
              message: this.PtyUsedInPts.msg,
              dangerouslyUseHTMLString: true 
            });
          return 0;
      }


      this.$confirm("是否确认删除?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          deleteById( {inr : row.inr} )
            .then((res) => {
              if(res.respCode == "AAAAAA") {
                this.$notify.success("删除成功!");
                this.onSearch()
              }
            })
            .catch((err) => {
              this.$notify.error("删除失败!");
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },


    async checkZXbanForExtkeyBySSTF(ptyinr){
      
      let data={
        "orgBch":this.$store.state.UserContext.currentOrg.departmentNumber,
        "ptyInr": ptyinr
        };
      await Api.post('/manager/pty/checkZXbanForExtkeyBySSTF',data).then(res => {
        if (res.respCode == SUCCESS) {
          this.bchAuthMod.maaFlg = res.data.maaFlg
          this.bchAuthMod.mabFlg = res.data.mabFlg
        }
      });
    },

    async checkPtyUsedInPts(ptyinr){
      
      let data={
        "ptyinr": ptyinr
        };
      await Api.post('/manager/pty/checkPtyUsedInPts',data).then(res => {
        if (res.respCode == SUCCESS) {
          this.PtyUsedInPts.cod = res.data.cod
          this.PtyUsedInPts.msg = res.data.msg
        }
      });
    },

    async checkZXbanForExtkeyByEcif0930(extkey){
      
      let data={
        "orgBch":this.$store.state.UserContext.currentOrg.departmentNumber,
        "orgNo": extkey
        };
      await Api.post('/manager/pty/checkZXbanForExtkeyByEcif0930',data).then(res => {
        if (res.respCode == SUCCESS) {
          
          this.bchAuthMod.cod_ = res.data.cod
          this.bchAuthMod.msg_ = res.data.msg

          this.bchAuthMod.zFlg = res.data.zFlg
          this.bchAuthMod.zMsg = res.data.zMsg
          this.bchAuthMod.zBchList = res.data.zBchList
          this.bchAuthMod.zBchkeyList = res.data.zBchkeyList
          this.bchAuthMod.zBranchList = res.data.zBranchList

          this.bchAuthMod.xFlg = res.data.xFlg
          this.bchAuthMod.xMsg = res.data.xMsg
          this.bchAuthMod.xBchList = res.data.xBchList
          this.bchAuthMod.xBchkeyList = res.data.xBchkeyList
          this.bchAuthMod.xBranchList = res.data.xBranchList

          if (res.data.cod=="Y-C"){
              this.$notify.warning({
            	title: '提示:',
              message: res.data.msg,
              dangerouslyUseHTMLString: true 
            });
          }
        }
      });
    },
  },
};
</script>

<style scoped>
.table-button-item-list {
  padding: 0;
  margin: 0;
}
.table-button-item-list li {
  list-style: none;
  padding: 5px 0;
  text-align: center;
  color: #606266;
  cursor: pointer;
}</style>