经济事项预算

<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="inputLabel80">账套</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="inputLabel80">公司段</div>

          <el-input

            v-model.trim="condition.company"

            @click.native="openCompany()"

            icon="search"

            readonly

            class="chooseInput"

          ></el-input>

        </el-col>

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

          <div class="inputLabel80">成本中心</div>

          <el-input

            v-model.trim="condition.cost"

            @click.native="openSegment3()"

            icon="search"

            readonly

            class="chooseInput"

          ></el-input>

        </el-col>

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

          <div class="inputLabel80">状态</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="inputLabel80">经济事项一级</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="inputLabel80">经济事项二级</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.budget"

              @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_BUDGET_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_BUDGET_ADD')" class="toolButtonItem" @click="addEcono">

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

            </span>

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

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

            </span>

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

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

            </span>

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

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

            </span>

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

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

            </span>

            <span v-if="$hasPower(btnListData)('ECONOMI_BUDGET_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

          ref="table"

          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="segment3Name" 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="bisFlagMean"

            align="center"

            :show-overflow-tooltip="true"

          ></el-table-column>

          <el-table-column

            label="预算子目编码/名称"

            width="130"

            prop="segment6Name"

            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="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="costDialog"

        custom-class="commonDialog"

        title="查询成本中心"

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

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

      >

        <div v-if="costDialog">

          <SegmentCost

            :ledgerCode="condition.ledgerCode"

            @saveCostData="saveCostData"

            @closedCost="closedCost"

          ></SegmentCost>

        </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>

      <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>

    </div>

  </div>

</template>

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

<style>

</style>

<script>

import SegmentCost from "./segmentCost.vue";

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: {

    SegmentCost, // 成本中心

    AddEdit, // 新增/编辑

    FileDialog, //导入弹窗

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

    Subject,

    SegmentCompany

  },

  data() {

    return {

      uploadUrl: "",

      condition: {

        ledgerCode: "",

        ledgerId: "", //账套id

        company: "",

        companyId: "",

        cost: "",

        costId: "",

        status: "",

        economicItemOne: "",

        economicItemOneId:'',

        economicItemOneCode:'',

        economicItemTwo: "",

        budget: "",

        budgetId: "",

        pageNum: 1,

        pageSize: 10

      },

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

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

      btnListData:'',

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

      editData: "", //编辑数据

      forItem: [], //选择的item

      idList: [], //选择记录id集合

      tableData: [],

      ledgerList: [], //账套list

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

      companyDialog: false, //公司段弹窗

      subjectDialog: false, //科目弹窗

      costDialog: 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;

        }

      });

    },

    getItemId(item) {

      this.condition.ledgerId = item.id;

    },

    changeEffectItem() {

      this.condition.company = "";

      this.condition.cost = "";

      this.condition.budget = "";

    },

    getEconomicTwoList() {

      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) {

      this.multipleSelection = val;

      let aList = []; //选择数据的id集合,因为每选择一次,这个方法就会执行一次吧。

      this.forItem = val;

      val.forEach(it => {

        aList.push(it.id);

      });

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

    },

    //对选择的记录进行去重后保存到data数据中心中.

    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);

    },

    //公司段保存

    saveCompanyData(val) {

      var arrId = "";

      var arrName = "";

      val.ids.forEach(item => {

        arrId += item + ",";

      });

      val.names.forEach(item => {

        arrName += item + ",";

      });

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

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

      this.companyDialog = false;

    },

    //公司段数据

    openCompany() {

      if (

        this.condition.ledgerCode == "" ||

        this.condition.ledgerCode == undefined

      ) {

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

        return;

      } else {

        this.companyDialog = true;

      }

    },

    closeCompany() {

      this.companyDialog = 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

        segment3: this.condition.costId, //部分3,成本中心

        segment6: this.condition.budgetId, //科目id

        status: this.condition.status,

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

        pageSize: this.condition.pageSize

      };

      this.$Http

        .post(this.uploadUrl + "/economicBudgetRelation/listPage", params) //等新接口

        .then(data => {

          var result = data.body;

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

            this.tableData = result.data.list;

            this.mainData = result.data;

            // setTimeout(() => {

            //  this.setSelectRow();

            // }, 200);

          } else {

            this.$message({

              showClose: true,

              message: result.message,

              type: "error",

              duration: 5000

            });

          }

        });

    },

    handleCurrentChange(val) {

      this.condition.pageNum = val;

      this.search();

    },

    //条数切换

    handleSizeChange(val) {

      this.condition.pageSize = val;

      this.search();

    },

    //成本中心弹窗

    openSegment3() {

      if (

        this.condition.ledgerCode == "" ||

        this.condition.ledgerCode == undefined

      ) {

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

        return;

      } else {

        this.costDialog = true;

      }

    },

    //关闭成本中心弹窗

    closedCost() {

      this.costDialog = false;

    },

    //保存成本中心传值

    saveCostData(val) {

      this.condition.cost = val.name;

      this.condition.costId = val.id;

      this.costDialog = false;

    },

    //经济事项一级弹窗

    openEconomicDialog() {

      this.condition.economicItemTwo = "";

      this.economicDialog = true;

    },

    //经济事项二级

    isOpenTwo() {

      if (

        this.condition.economicItemOne == "" ||

        this.condition.economicItemOne == undefined

      ) {

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

        return;

      }

    },

    //打开科目数据

    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.budgetId = arrId.slice(0, arrId.length - 1);

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

      this.subjectDialog = false;

    },

    closeSubject() {

      this.subjectDialog = false;

    },

    //关闭经济事项对话框

    closeEconomic() {

      this.economicDialog = false;

    },

    //经济对话框的保存

    saveEconomicData(val) {

      console.log(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() {

      if (true) {

        let sData = {

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

          status: 1

        };

        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 + "/economicBudgetRelation/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请求

      if (true) {

        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 + "/economicBudgetRelation/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");

    },

    closeImportFile() {

      this.fileDialog = false;

    },

    cancelImportFile() {

      this.fileDialog = false;

    },

    getOut() {

          var option = {

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

          data: {

            requestData: {

              "economic1": this.condition.economicItemOneId,

              "economic2": this.condition.economicItemTwo,

              "ledgerId": this.condition.ledgerId,

              "segment1": this.condition.companyId,

              "segment3": this.condition.costId,

              "segment6": this.condition.budgetId,

              "status": this.condition.status,

              "pageNum": this.condition.pageNum,

              "pageSize": this.condition.pageSize

            }

          },

          method: 'post'

        };

        downLoadFile(option);

    }

  }

};

</script>

<style>

  .commonDialog{

    width: 500px;

  }

</style>

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容