经济事项核算

<template>

  <div class="simple">

    <power v-model="btnListData"></power>

    <div>

      <el-row :gutter="10" class="formWrap">

        <div style="margin-left:25px;" class="formTitle">查询条件</div>

        <el-col class="form-item" :span="6">

          <div class="inputLabel110">账套</div>

          <el-select v-model="condition.ledgerCode" @change="changeEffectItem()">

            <el-option

              v-for="(item,index) in ledgerList"

              :label="item.name"

              :value="item.code"

              :key="index"

              @click.native="getItemId(item)"

            ></el-option>

          </el-select>

        </el-col>

        <el-col class="form-item" :span="6">

          <div class="inputLabel6">公司段</div>

          <el-input

            v-model.trim="condition.company"

            @click.native="syndiCate()"

            icon="search"

            readonly

            class="chooseInput"

          ></el-input>

        </el-col>

        <el-col class="form-item" :span="6">

          <div class="inputLabel110">成本中心类型</div>

          <el-select v-model="condition.costType"  @click.native="isOpenCostType()">

            <el-option

              v-for="(item,index) in costTypeOption"

              :label="item.segment3Type"

              :value="item.segment3Type"

              :key="index"

            ></el-option>

          </el-select>

        </el-col>

        <el-col class="form-item" :span="6">

          <div class="inputLabel110">状态</div>

          <el-select placeholder="全部" v-model="condition.status">

            <el-option label="全部" value=''></el-option>

            <el-option label="启用" value="1"></el-option>

            <el-option label="禁用" value="0"></el-option>

          </el-select>

        </el-col>

      </el-row>

      <el-row :gutter="10" class="formWrap">

        <el-col class="form-item" :span="6">

          <div class="inputLabel6">经济事项一级</div>

          <el-input

            v-model.trim="condition.economicItemOne"

            @click.native="openEconomicDialog()"

            icon="search"

            readonly

            class="chooseInput"

          ></el-input>

        </el-col>

        <el-col class="form-item" :span="6">

          <div class="inputLabel110">经济事项二级</div>

          <el-select v-model="condition.economicItemTwo" @click.native="isOpenTwo()">

            <el-option

              v-for="(item,index) in economicTwoList"

              :label="item.name"

              :value="item.id"

              :key="index"

            ></el-option>

          </el-select>

        </el-col>

        <el-col class="form-item" :span="6">

          <div class="inputLabel110">核算科目编码/名称</div>

            <el-input

              v-model.trim="condition.check"

              @click.native="openSubject()"

              icon="search"

              readonly

              class="chooseInput"

            ></el-input>

        </el-col>

      </el-row>

      <div class="footerButtonGroup">

        <el-button @click="clearAll">重置</el-button>

        <el-button v-if="$hasPower(btnListData)('ECONOMI_CHECK_QUERY')" type="primary" @click="search">查询</el-button>

      </div>

      <div class="tabWrap">

        <div class="tableTitle">

          <font>查询结果</font>

          <div class="toolButton" style="min-width:360px">

            <span v-if="$hasPower(btnListData)('ECONOMI_CHECK_ADD')" class="toolButtonItem" @click="addEcono">

              <img src="@/icons/icon_add.png" style="margin-bottom:-3px">&nbsp;新增

            </span>

            <span v-if="$hasPower(btnListData)('ECONOMI_CHECK_EDIET')" class="toolButtonItem" @click="edit">

              <img src="@/icons/icon_edit01.png" style="margin-bottom:-3px">&nbsp;编辑

            </span>

            <span v-if="$hasPower(btnListData)('ECONOMI_CHECK_START')"  class="toolButtonItem" @click="enable">

              <img src="@/icons/icon_start01.png" style="margin-bottom:-3px">&nbsp;启用

            </span>

            <span v-if="$hasPower(btnListData)('ECONOMI_CHECK_STOP')" class="toolButtonItem" @click="disable">

              <img src="@/icons/icon_stop01.png" style="margin-bottom:-3px">&nbsp;禁用

            </span>

            <span v-if="$hasPower(btnListData)('ECONOMI_CHECK_IN')" class="toolButtonItem" @click="getIn">

              <img src="@/icons/icon_export.png" style="margin-bottom:-3px">&nbsp;导入

            </span>

            <span v-if="$hasPower(btnListData)('ECONOMI_CHECK_OUT')" class="toolButtonItem" @click="getOut">

              <img src="@/icons/icon_daochu.png" style="margin-bottom:-3px">&nbsp;导出

            </span>

          </div>

        </div>

        <el-table

          :data="tableData"

          @select="selectItem"

          @select-all="selectItemAll"

          border

          style="width:100%"

        >

          <el-table-column type="selection" header-align="center" min-width="45"></el-table-column>

          <el-table-column label="序号" width="65" align="center" type="index"></el-table-column>

          <el-table-column label="账套" prop="ledgerName" align="center" show-overflow-tooltip></el-table-column>

          <el-table-column label="公司段" prop="segment1Name" align="center" show-overflow-tooltip></el-table-column>

          <el-table-column label="成本中心类型" prop="segment3Type" align="center" show-overflow-tooltip></el-table-column>

          <el-table-column

            label="经济事项一级"

            width="100"

            prop="economic1Name"

            align="center"

            :show-overflow-tooltip="true"

          ></el-table-column>

          <el-table-column

            label="经济事项二级"

            width="100"

            prop="economic2Name"

            align="center"

            :show-overflow-tooltip="true"

          ></el-table-column>

          <el-table-column

            label="是否关联方"

            width="100"

            prop="isRelatedPartyMean"

            align="center"

            :show-overflow-tooltip="true"

          ></el-table-column>

          <el-table-column

            label="核算科目编码/名称"

            width="130"

            prop="segment5Name"

            align="center"

            :show-overflow-tooltip="true"

          ></el-table-column>

          <el-table-column label="状态" align="center" width="100">

            <template slot-scope="scope">

              <span v-if="scope.row.status==1" class="color">{{scope.row.statusMean}}</span>

              <span v-else>{{scope.row.statusMean}}</span>

            </template>

          </el-table-column>

          <el-table-column

            label="创建人"

            prop="createdBy"

            align="center"

            :show-overflow-tooltip="true"

          ></el-table-column>

          <el-table-column

            label="创建时间"

            prop="createdDate"

            align="center"

            :show-overflow-tooltip="true"

          ></el-table-column>

          <el-table-column

            label="更新人"

            prop="updatedBy"

            align="center"

            :show-overflow-tooltip="true"

          ></el-table-column>

          <el-table-column

            label="更新时间"

            prop="updatedDate"

            align="center"

            :show-overflow-tooltip="true"

          ></el-table-column>

        </el-table>

      </div>

      <div class="myPaginationBox">

        <p>

          共{{ (mainData.total / condition.pageSize) === 0 ? 0 : Math.ceil(mainData.total / condition.pageSize) }}页/

          <b>{{mainData.total}}</b>条数据

        </p>

        <el-pagination

          @size-change="handleSizeChange"

          @current-change="handleCurrentChange"

          :page-sizes="[10,20,50,100]"

          :page-size="mainData.pageSize"

          layout="sizes, prev, pager, next, jumper"

          :total="mainData.total"

        ></el-pagination>

      </div>

      <el-dialog

        :visible.sync="addEditDialog"

        title="经济事项与核算科目匹配"

        :close-on-click-modal="false"

        custom-class="commonDialog3"

      >

        <div v-if="addEditDialog">

          <AddEdit @saveAE="saveAE" @closeAE="closeAE" :editData="forItem"></AddEdit>

        </div>

      </el-dialog>

      <el-dialog

        title="导入excel文件管理"

        custom-class="dialogFile"

        :modal-append-to-body="false"

        :visible.sync="fileDialog"

        size

      >

        <div v-if="fileDialog">

          <FileDialog @closeImportFile="closeImportFile" @cancelImportFile="cancelImportFile"></FileDialog>

        </div>

      </el-dialog>

      <el-dialog

        :visible.sync="companyDialog"

        custom-class="commonDialog"

        :modal-append-to-body="false"

        title="公司段"

        :close-on-click-modal="false"

        :close-on-press-escape="false"

      >

        <div v-if="companyDialog">

          <SegmentCompany

            :ledgerCode="condition.ledgerCode"

            @saveCompanyData="saveCompanyData"

            @closeCompany="closeCompany"

          ></SegmentCompany>

        </div>

      </el-dialog>

      <el-dialog

        :visible.sync="subjectDialog"

        custom-class="commonDialog"

        :modal-append-to-body="false"

        title="核算科目编码/名称"

        :close-on-click-modal="false"

        :close-on-press-escape="false"

      >

        <div v-if="subjectDialog">

          <Subject

            :ledgerCode="condition.ledgerCode"

            @saveSubjectData="saveSubjectData"

            @closeSubject="closeSubject"

          ></Subject>

        </div>

      </el-dialog>

      <el-dialog

        :visible.sync="economicDialog"

        custom-class="commonDialog"

        :modal-append-to-body="false"

        title="经济事项一级"

        :close-on-click-modal="false"

        :close-on-press-escape="false"

      >

        <div v-if="economicDialog">

          <TableCommon @closeEconomic="closeEconomic" @saveEconomicData="saveEconomicData"></TableCommon>

        </div>

      </el-dialog>

    </div>

  </div>

</template>

<style src="../../css/common.css"></style>

<style>

</style>

<!-- <script src="./ledger.js"></script> -->

<script>

import SegmentCompany from "./segmentCompany.vue";

import Subject from "./Subject.vue";

import AddEdit from "./addEdit.vue";

import FileDialog from "./fileDialog.vue";

import TableCommon from "./commonTable.vue";

import {

  tipMsg,

  justOne,

  downLoadFile,

} from "../../js/common.js";

export default {

  components: {

    AddEdit, // 新增/编辑

    FileDialog, //导入弹窗

    TableCommon, //经济事项一级弹窗

    SegmentCompany,

    Subject

  },

  data() {

    return {

      uploadUrl: "",

      condition: {

        ledgerCode: "",

        ledgerId: "", //账套id

        company: "",

        companyId: "",

        costType: "",

        costId: "",

        status: "",

        economicItemOne: "",

        economicItemOneId:'',

        economicItemOneCode:'',

        economicItemTwo: "",

        check: "",//核算科目

        checkId: "",//核算id

        pageNum: 1,

        pageSize: 10

      },

      // nodeIdListcheck: [], //公司段用

      btnListData:'',

      multipleSelection: [], // 当前页选中的数据

      multipleSelectionAll: [], // 所有选中的数据包含跨页数据

      editData: "", //编辑数据

      forItem: [], //选择的item

      idList: [], //id集合

      tableData: [],

      IdKey: "id", //设定行数据key

      ledgerList: [], //账套list

      checkOption: [], //预算科目option

      costTypeOption: [], //成本中心类型option

      economicTwoList: [], //经济事项二级的列表

      companyDialog: false, //公司段弹窗

      subjectDialog: false, //科目弹窗

      economicDialog: false, //经济事项弹窗开关

      addEditDialog: false, //新增编辑弹窗开关

      fileDialog: false, //导入弹窗

      managementCaliberId: "", //管理口径id

      mainData: {

        total: 0

      }

    };

  },

  created() {

    //this.URL = `${this.$root.loadUrl}/mdm-service`;  //部署环境

    this.uploadUrl = `${this.$root.loadUrl}`; //后台链接测试环境

    this.getledger();

  },

  mounted() {

    this.search();

  },

  methods: {

    getledger() {

      let url = `${this.$root.loadUrl}/ledger/queryLedger`;

      this.$Http.post(url, {}).then(rsp => {

        if (rsp.body.code == "000000") {

          this.ledgerList = rsp.body.data;

        }

      });

    },

    //更新相关联动项

    changeEffectItem() {

      this.condition.company = "";

      this.condition.costType = "";

      this.condition.check = "";

      let params = { ledgerCode: this.condition.ledgerCode };

      let url2 = `${this.$root.loadUrl}/economicAccountRelation/querySegment3Type`;

      this.$Http.post(url2, params).then(rsp => {

        if (rsp.body.code == "000000") {

          this.costTypeOption = rsp.body.data;

        }

      });

    },

    getItemId(item) {

      this.condition.ledgerId = item.id;

    },

    getEconomicTwoList() {

      console.log("2级");

      let url = `${

        this.$root.loadUrl

      }/economicAccountRelation/queryEconomicEvent`;

      let params = {

        pcode: this.condition.economicItemOneCode,

        managementCaliberId: this.managementCaliberId

      };

      this.$Http.post(url, params).then(rsp => {

        if (rsp.body.code == "000000") {

          this.economicTwoList = rsp.body.data.list;

        }

      });

    },

    //选中一条数据

    selectItem(val) {

      console.log(val);

      this.multipleSelection = val;

      let aList = [];

      this.forItem = val;

      val.forEach(it => {

        aList.push(it.id);

      });

      setTimeout(this.idListckeck(aList), 100);

    },

    idListckeck(arr) {

      this.idList = [];

      for (var i = 0; i < arr.length; i++) {

        if (this.idList.indexOf(arr[i]) == -1) {

          this.idList.push(arr[i]);

        }

      }

      return this.idList;

    },

    //选中多条数据

    selectItemAll(val) {

      this.multipleSelection = val;

      let aList = [];

      this.forItem = val;

      val.forEach(it => {

        aList.push(it.id);

      });

      setTimeout(this.idListckeck(aList), 100);

    },

    //打开公司段数据

    syndiCate() {

      if (

        this.condition.ledgerCode == "" ||

        this.condition.ledgerCode == undefined

      ) {

        this.$message({ type: "warning", message: "请先选择账套" });

        return;

      } else {

        this.companyDialog = true;

      }

    },

    //公司段保存

    saveCompanyData(val) {

      var arrId = "";

      var arrName = "";

      val.ids.forEach(item => {

        arrId += item + ",";

      });

      val.names.forEach(item => {

        arrName += item + ",";

      });

      // this.condition.delegationContent=arrId.slice(0,arrId.length-1);

      this.condition.companyId = arrId.slice(0, arrId.length - 1);

      this.condition.company = arrName.slice(0, arrName.length - 1);

      this.companyDialog = false;

    },

    closeCompany() {

      this.companyDialog = false;

    },

        //打开科目数据

    openSubject() {

      if (

        this.condition.ledgerCode == "" ||

        this.condition.ledgerCode == undefined

      ) {

        this.$message({ type: "warning", message: "请先选择账套" });

        return;

      } else {

        this.subjectDialog = true;

      }

    },

    //科目保存

    saveSubjectData(val) {

      var arrId = "";

      var arrName = "";

      val.ids.forEach(item => {

        arrId += item + ",";

      });

      val.names.forEach(item => {

        arrName += item + ",";

      });

      // this.condition.delegationContent=arrId.slice(0,arrId.length-1);

      this.condition.checkId = arrId.slice(0, arrId.length - 1);

      this.condition.check = arrName.slice(0, arrName.length - 1);

      this.subjectDialog = false;

    },

    closeSubject() {

      this.subjectDialog = false;

    },

    clearAll() {

      for (var prop in this.condition) {

        this.condition[prop] = "";

      }

      this.condition.pageNum = 1;

      this.condition.pageSize = 10;

    },

    search() {

      // 分页查询数据方法,在成功返回数据方法里调用setSelectRow方法,使每次分页查询都能勾选中

      let params = {

        economic1: this.condition.economicItemOneId, //经济事项一级id

        economic2: this.condition.economicItemTwo, //经济事项二级id

        ledgerId: this.condition.ledgerId, //账套id

        segment1: this.condition.companyId, //公司id

        segment3Type: this.condition.costType, //部分3,成本中心类型

        segment5: this.condition.checkId, //核算科目id

        status: this.condition.status,

        pageNum: this.condition.pageNum, //第几页

        pageSize: this.condition.pageSize

      };

      this.$Http

        .post(this.uploadUrl + "/economicAccountRelation/listPage", params)

        .then(data => {

          var result = data.body;

          if (result.code == "000000") {

            this.tableData = result.data.list;

            this.mainData = result.data;

          } else {

            this.$message({

              showClose: true,

              message: result.message,

              type: "error",

              duration: 5000

            });

          }

        });

    },

    // //选中一条数据

    // handleSelectionChange(val) {

    //  // table组件选中事件,记得加上@selection-change="handleSelectionChange"

    //  this.multipleSelection = val;

    // },

    handleCurrentChange(val) {

      this.condition.pageNum = val;

      this.search();

    },

    handleSizeChange(val) {

      this.condition.pageSize = val;

      this.search();

    },

    //经济事项一级弹窗

    openEconomicDialog() {

      this.condition.economicItemTwo = "";

      this.economicDialog = true;

    },

    //经济事项二级

    isOpenTwo() {

      if (

        this.condition.economicItemOne == "" ||

        this.condition.economicItemOne == undefined

      ) {

        this.$message({ type: "warning", message: "请先选择一级经济事项" });

        return;

      }

    },

    //成本中心类型提示

    isOpenCostType() {

      if (

        this.condition.ledgerCode == "" ||

        this.condition.ledgerCode == undefined

      ) {

        this.$message({ type: "warning", message: "请先选择账套" });

        return;

      }

    },

    //预算科目

    isOpenCheck() {

      if (

        this.condition.ledgerCode == "" ||

        this.condition.ledgerCode == undefined

      ) {

        this.$message({ type: "warning", message: "请先选择账套" });

        return;

      }

    },

    //关闭经济事项对话框

    closeEconomic() {

      this.economicDialog = false;

    },

    //经济对话框的保存

    saveEconomicData(val) {

      this.economicDialog = false;

      this.condition.economicItemOne = val.name; //

      this.condition.economicItemOneId = val.id; //传入经济项目一级id

      this.condition.economicItemOneCode = val.code; //传入经济项目一级code

      this.managementCaliberId = val.managementCaliberId; //传入经济项目一级id

      this.getEconomicTwoList();

    },

    //新增

    addEcono() {

      this.forItem = [];

      this.addEditDialog = true;

    },

    //编辑

    edit() {

      if (this.forItem.length == 1) {

        this.addEditDialog = true;

      } else if (this.forItem.length == 0) {

        tipMsg("请先选择一条数据!", "warning");

      } else {

        tipMsg("不能选择多条,只能选择一条!", "warning");

      }

    },

    //保存新增/编辑

    saveAE() {

      this.addEditDialog = false;

      this.search();

    },

    //关闭新增/编辑弹窗

    closeAE() {

      this.addEditDialog = false;

    },

    // //检查状态

    // checkStatus(staVal, act, mean) {

    //  for (var i = 0; i < this.forItem.length; i++) {

    //    if (this.forItem[i].status == staVal) {

    //      tipMsg("不能" + act + mean + "数据", "warning");

    //      return false;

    //    }

    //  }

    //  return true;

    // },

    //启用

    enable() {

        let sData = {

          idList: JSON.parse(JSON.stringify(this.idList)),

          status: 1

        };

        let params = new FormData();

        this.$Http

          .post(

            this.uploadUrl + "/economicAccountRelation/updateStatusBatch",

            sData,

            {

              headers: {

                "Content-Type": "multipart/form-data" //hearder 很重要,Content-Type 要写对

              }

            }

          )

          .then(data => {

            var result = data.body;

            if (result.code == "000000") {

              this.idList = [];

              this.forItem = [];

              tipMsg(result.message, "success");

              this.search();

            } else {

              tipMsg(result.message, "error");

            }

          });

    },

    //禁用

    disable() {

      //form-data post请求

      let sData = {

        idList: JSON.parse(JSON.stringify(this.idList)),

        status: 0

      };

      let params = new FormData();

      //   params.append('appName', this.search.appName);//这里是要传的参数

      // for( let it in sData){

      //    params.append(it,sData[it])

      // }

      this.$Http

        .post(

          this.uploadUrl + "/economicAccountRelation/updateStatusBatch",

          sData,

          {

            headers: {

              "Content-Type": "multipart/form-data" //hearder 很重要,Content-Type 要写对

            }

          }

        )

        .then(data => {

          var result = data.body;

          if (result.code == "000000") {

            this.idList = [];

            this.forItem = [];

            tipMsg(result.message, "success");

            this.search();

          } else {

            tipMsg(result.message, "error");

          }

        });

    },

    getIn() {

      this.fileDialog = true;

      console.log(this.multipleSelectionAll, "all");

    },

    cancelImportFile() {

      this.fileDialog = false;

    },

    closeImportFile() {

      this.fileDialog = false;

    },

    getOut() {

          var option = {

          url: this.uploadUrl + '/economicAccountRelation/export',

          data: {

            requestData: {

              "economic1": this.condition.economicItemOneId,

              "economic2": this.condition.economicItemTwo,

              "ledgerId": this.condition.ledgerId,

              "segment1": this.condition.companyId,

              "segment3Type": this.condition.costId,

              "segment5": this.condition.checkId,

              "status": this.condition.status,

              "pageNum": this.condition.pageNum,

              "pageSize": this.condition.pageSize

            }

          },

          method: 'post'

        };

        downLoadFile(option);

    }


  }

};

</script>

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • pyspark.sql模块 模块上下文 Spark SQL和DataFrames的重要类: pyspark.sql...
    mpro阅读 13,214评论 0 13
  • <template> <el-row type="flex" class="row-bg ...
    南漂一枚阅读 3,051评论 0 0
  • <template> <el-row :gutter="10" class="formWrap"> <e...
    南漂一枚阅读 1,652评论 0 0
  • 姓名:邓宁宁 公司:蔚蓝时代实业有限公司 【日精进打卡第251天】 【知-学习】 1.大纲1遍 2.大学0遍 3....
    啊宁_9332阅读 36评论 0 0
  • 已经在简书持续发文章一个月多了。发的诗篇和短篇故事大多数都是以前写的,然后最近再进行修改和整理的。现在已经把差不多...
    Yuy_H阅读 4,969评论 20 19

友情链接更多精彩内容