经济事项申请1

<template>

  <div class="simple">

    <div>

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

        <div class="tableTitle titleHeigth tabWrap">

          <font>经济事项信息</font>

          <div class="fr" v-if="sendAEData.edit != true">

            <span class="toolButtonItem" @click.prevent="addList('dataList')">

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

            </span>

            <span class="toolButtonItem" @click.prevent="delList('checkedList','dataList')">

              <img src="@/icons/icon_delete.png" style="margin-bottom:-3px">&nbsp;删除行

            </span>

            <span  v-if = 'false' class="toolButtonItem" @click.prevent="getIn">

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

            </span>

          </div>

        </div>

      </el-row>

      <el-row :gutter="10">

        <template>

          <el-table

            :data="dataList"

            @select="selectItemTick"

            @select-all="selectAllTick"

            border

            center="true"

            max-height="650"

            style="width: 100%;"

          >

            <el-table-column

              type="selection"

              header-align="center"

              width="34"

              v-if="sendAEData.edit != true"

            ></el-table-column>

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

            <el-table-column label="一级经济事项编码" min-width="180" show-overflow-tooltip>

              <template slot-scope="scope">

                <el-input

                  v-model.trim="scope.row.economic1Code"

                  readonly

                ></el-input>

              </template>

            </el-table-column>

            <el-table-column label="一级经济事项名称" min-width="180" show-overflow-tooltip>

              <template slot-scope="scope">

                <el-input

                  v-model.trim="scope.row.economic1Name"

                  @change="oneChange(scope.row,scope.$index)"

                  class="chooseInput"

                  :disabled="scope.row.economic1NameAllow"

                ></el-input>

              <img src="@/icons/icon_query3.png" @click="openEconomicDialogOne(scope.row,scope.$index)"  style="width:18px;height:18px;position:relative;left:-34px;margin-bottom:-3px">

              </template>

            </el-table-column>

            <el-table-column label="二级经济事项编码" min-width="180" show-overflow-tooltip>

              <template slot-scope="scope">

                <el-input v-model.trim="scope.row.economic2Code" readonly class="chooseInput"></el-input>

              </template>

            </el-table-column>

            <el-table-column label="二级经济事项名称" min-width="180" show-overflow-tooltip>

              <template slot-scope="scope">

                <el-input

                  v-model.trim="scope.row.economic2Name"

                  @focus='checkTwoConditon(scope.row,scope.$index)'

                  @change="twoChange(scope.row,scope.$index)"

                  class="chooseInput"

                  :disabled="scope.row.economic2NameAllow"

                ></el-input>

                <img src="@/icons/icon_query3.png" @click="openEconomicDialogTwo(scope.row,scope.$index)"  style="width:18px;height:18px;position:relative;left:-34px;margin-bottom:-3px">

              </template>

            </el-table-column>

            <el-table-column

              label="三级经济事项编码"

              prop="economic3Code"

              min-width="180"

              show-overflow-tooltip

            ></el-table-column>

            <el-table-column label="三级经济事项名称" min-width="180" show-overflow-tooltip>

              <template slot-scope="scope">

                <el-input v-model.trim="scope.row.economic3Name" class="chooseInput"  @focus='checkThreeConditon(scope.row,scope.$index)' :disabled="scope.row.economic3NameAllow"></el-input>

              </template>

            </el-table-column>

            <el-table-column label="标签" width="80" show-overflow-tooltip>

              <template slot-scope="scope">

                <el-select v-model.trim="scope.row.tag" :disabled="scope.row.tagAllow" @change="toggleCaliber(scope.row.tag,scope.$index)">

                  <el-option label="通用" value="1" :disabled="scope.row.limitAllow"></el-option>

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

                </el-select>

              </template>

            </el-table-column>

            <el-table-column label="管理口径" width="250" multiple show-overflow-tooltip>

              <template slot-scope="scope">

                <el-select v-model.trim="scope.row.mgmCaliberCode" multiple :disabled="scope.row.caliberSwatch">

                  <el-option

                    v-for="(item,index) in scope.row.caliberOption"

                    :label="item.managementCaliberName"

                    :value="item.managementCaliberCode+','+item.managementCaliberName"

                    :key="index"

                  ></el-option>

                </el-select>

              </template>

            </el-table-column>

            <el-table-column label="释义" min-width="120" show-overflow-tooltip >

              <template slot-scope="scope">

                <el-input  v-model.trim="scope.row.comment" :disabled="scope.row.commentAllow"  style="padding-right:0px"></el-input>

                <img src="@/icons/icon_closegrey.png" @click="clearComment(scope.row,scope.$index)" style="width:10px;heigth:10px;position:relative;left:-34px;margin-bottom:-3px;">

              </template>

            </el-table-column>

          </el-table>

        </template>

      </el-row>

      <div class="footerButtonGroup">

        <!-- <i-button type="primary" :handler='upData' v-if="sendAEData.edit == true" >保存</i-button>

        <i-button type="primary" :handler='saveData' v-else>保存</i-button>-->

        <el-button type="primary" @click="openCause">提交</el-button>

        <el-button @click="clearnAction()">关闭</el-button>

      </div>

    </div>

    <el-dialog

      title="导入excel文件管理"

      custom-class="dialogFile"

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

      :visible.sync="dialogGetIn"

      size

    >

      <div v-if="dialogGetIn">

        <GetInDialog

          :commonUrl="URL"

          :importUrl="importUrl"

          :downloadUrl="downloadUrl"

          @closeImportFile="closeImportFile"

          @cancelImportFile="cancelImportFile"

        ></GetInDialog>

      </div>

    </el-dialog>

    <el-dialog

      :visible.sync="economicDialogOne"

      custom-class="commonDialog"

      title="经济事项一级"

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

    >

      <div v-if="economicDialogOne">

        <Economic1 @closeEconomic1="closeEconomic1" @saveEconomicData1="saveEconomicData1"></Economic1>

      </div>

    </el-dialog>

    <el-dialog

      :visible.sync="economicDialogTwo"

      custom-class="commonDialog"

      title="经济事项二级"

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

    >

      <div v-if="economicDialogTwo">

        <Economic2

          :pCode="pCode"

          @closeEconomic2="closeEconomic2"

          @saveEconomicData2="saveEconomicData2"

        ></Economic2>

      </div>

    </el-dialog>

    <el-dialog

      title="请选择审批链"

      :visible.sync="showIndicate"

      size="large"

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

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

    >

      <el-row class="boxAlign simple">

        <el-steps :space="200" :align-center="true" v-for="(ot,index) in stepData" :key="index">

          <!--这里需要加一个v-for 循环获取多条审批链-->

          <!-- <p class="msgspan">{{ot.msg}}</p> -->

          <el-step

            v-for="(item, index2) in ot.approvalChainPostList"

            :key="item.id"

            :title="item.postName || item.roleName"

          >

            <el-input

              v-if="item.umAccountList.length == 1 && item.umAccountList[0].umAccLength == 0"

              slot="description"

              v-model.trim="item.umAccountList[0].name"

              @click.native="showApprovalDialog(index2,index)"

              icon="search"

            ></el-input>

            <el-input

              v-else-if="item.umAccountList.length == 1 && item.isSubmitterUpdate == 0"

              slot="description"

              v-model.trim="item.umAccountList[0].name"

              readonly

            ></el-input>

            <!--<budget-approval-input v-if='item.umAccountList.length == 1' slot="description" :tabDatas="item" :tabIndex="index" @getSubApprovalData="getSubApprovalData"></budget-approval-input>-->

            <el-select v-else slot="description" v-model="item.name">

              <el-option

                v-for="value in item.umAccountList"

                :label="value.name"

                :key="value.umNo"

                :value="value.name"

              ></el-option>

            </el-select>

          </el-step>

        </el-steps>

      </el-row>

      <el-row class="dialog-footer2 margintop20">

        <span>

          <el-button @click="colseAction()">取 消</el-button>

          <i-button type="primary" :handler="saveAction">确认提交</i-button>

        </span>

      </el-row>

    </el-dialog>

    <el-dialog

      :visible.sync="showApplier"

      title="查询审批人"

      custom-class="commonDialog850"

      size="small"

      :modal="false"

    >

      <budget-approval-input

        :tabIndex="sendIndex"

        :index2="sendIndex2"

        @closedApproval="closedApproval"

        @getSubApprovalData="getSubApprovalData"

      ></budget-approval-input>

    </el-dialog>

    <el-dialog title="审批事由" :visible.sync="showCauseOfDeclare" size="large" :modal-append-to-body='false' :close-on-press-escape='false'>

      <el-row>

        <div class="inputLabelCause">申请事由:</div>

        <el-input type="textarea" :maxlength="200" v-model="causeOfDeclare" :rows="4" style="width:80%;resize:none"></el-input>

      </el-row>

      <el-row class="dialog-footer2 margintop20">

        <span>

          <el-button @click='colseCause'>取 消</el-button>

          <el-button type="primary" @click="saveCause">确认</el-button>

        </span>

      </el-row>

    </el-dialog>

  </div>

</template>

<style>

@import "../../css/common.css";

.titleHeigth {

  height: 51px;

}

</style>

<script>

import Economic1 from "./economic1.vue";

import Economic2 from "./economic2.vue";

import GetInDialog from "../invoiceInfo/GetInDialog.vue";

import BudgetApprovalInput from "../authapply/BudgetApprovalInput.vue";

import { tipMsg, justOne, getToday } from "../../js/common.js";

export default {

  props: ["sendAEData"],

  name: "addEditEcono",

  components: {

    Economic1,

    Economic2,

    BudgetApprovalInput,

    GetInDialog

  },

  watch: {

  },

  data() {

    return {

      URL: "", //导入里面的

      loadUrl: "",

      importUrl: "",

      downloadUrl: "",

      dataList: [

        {

          economic1Code: "",

          economic1Name: "",

          economic2Code: "",

          economic2Name: "",

          economic1NameAllow: false, //一级是否允许编辑

          economic2NameAllow: false, //二级是否允许编辑

          economic3NameAllow: false, //三级是否允许编辑

          tagAllow: false, //标签是否允许编辑

          limitAllow: false, //通用选项是否禁用。默认可用

          caliberSwatch: true, //管理口径的禁用状态

          commentAllow: false, //三级是否允许编辑

          economic3Code: "",

          economic3Name: "",

          tag: "", //标签 默认通用

          tag1: "", //标签 一级标签

          tag2: "", //标签 二级标签

          status: "",

          levelNo: "", //编码等级

          completePath: "",

          pCode: "",

          mgmCaliberCode: [],

          comment: "",

          caliberOption: [], //管理口径容器

        }

      ],

      sendData: {},

      checkedList: [], //选择列表

      OneEcoList: [],

      TwoEcoList: [],

      economicDialogOne: false, //1经济事项对话框弹窗

      economicDialogTwo: false, //2经济事项对话框弹窗

      showCauseOfDeclare: false, //签报事由弹窗

      showApplier: false, //审批人弹窗

      showIndicate: false, //审批链弹窗

      dialogGetIn: false, //导入

      stepData: [], //审批步骤

      treeCode: "TREE_FAS",

      emplId: "",

      orgId: "", //审批链入参组织id

      sendIndex2: "",

      sendIndex: "",

      causeOfDeclare: "", //签报事由

      LIndex: "0", //行号

      TwoLIndex: "", //行号

      pCode: "", //父级code,即一级经济事项code

      status : 1, 

      completePath: "",

      pCode: "",

      sortTotal: 0

    };

  },

  created() {

    this.loadUrl = `${this.$root.loadUrl}`;

    this.URL = `${this.$root.loadUrl}`;

    this.mainpost();

    this.findOpenUser();

    this.getAllManagementCaliber();

  },

  mounted() {

    this.init();

  },

  methods: {

    init() {

      if (this.sendAEData.edit) {

        this.dataList[0] = this.sendAEData;

        this.dataList[0].tag = this.sendAEData.tag == 1?"通用":"专用";

        this.dataList[0].tagAllow = true;

        // this.dataList[0].commentAllow = true;

        if (this.dataList[0].levelNo == 1) {

          this.dataList[0].economic2NameAllow = true;

          this.dataList[0].economic3NameAllow = true;

        }else if (this.dataList[0].levelNo == 2) {

          this.dataList[0].economic1NameAllow = true;

          this.dataList[0].economic3NameAllow = true;

        } else {

          this.dataList[0].economic1NameAllow = true;

          this.dataList[0].economic2NameAllow = true;

        }

      }

    },

    //对管理口径禁用控制

    toggleCaliber(tag,index){

      this.LIndex = index;

      if (tag == '1'||tag == '通用') {

        this.dataList[index].caliberSwatch = true

        this.dataList[index].mgmCaliberCode = []

      } else {

        this.dataList[index].caliberSwatch = false

        if (this.dataList[index].economic1Code == ''&&this.dataList[index].economic2Code == ''&&this.dataList[index].economic3Code == '') {

          this.getAllManagementCaliber();

        }

      }

    },

    //一级经济事项改变

    oneChange(row, index) {

        if (!this.sendAEData.edit) {

          this.dataList[index].economic1Code = ''

          this.dataList[index].tag = ''

          this.dataList[index].mgmCaliberCode = []

        }

        this.dataList[index].economic2Code = ''

        this.dataList[index].economic2Name = ''

        this.dataList[index].economic3Code = ''

        this.dataList[index].economic3Name = ''

        this.dataList[index].limitAllow = false;


    },

    //二级经济事项改变

    twoChange(row, index) {

        if (!this.sendAEData.edit) {

          this.dataList[index].economic2Code = ''

            this.dataList[index].tag = ''

            this.dataList[index].mgmCaliberCode = []

        }

        this.dataList[index].economic3Code = ''

        this.dataList[index].economic3Name = ''

    },

    //清空释义

    clearComment(row, index) {

        this.dataList[index].comment = ''

    },

    //经济事项弹窗

    openEconomicDialogOne(row,index) {

      if (this.sendAEData.edit == true) {

        this.$message({ type: "warning", message: "编辑状态下不可以选择,只可修改。" });

        return

      }

      this.LIndex = index;

      this.economicDialogOne = true;

    },

    //关闭经济事项对话框

    closeEconomic1() {

      this.economicDialogOne = false;

    },

    //1经济对话框的保存

    saveEconomicData1(data) {

      console.log(data);

      let indexL = this.LIndex;

      this.dataList[indexL].economic1Name = data.name;

      this.dataList[indexL].economic1Code = data.code;

      this.dataList[indexL].tag = (data.tag == 1 ? "通用" : "专用");

      if (data.tag == 0) {

          this.dataList[indexL].limitAllow = true;

      }else{

        this.dataList[indexL].limitAllow = false;

      }

      //清空联动二级经济事项信息

      this.dataList[indexL].economic2Name = "";

      this.dataList[indexL].economic2Code = "";

      //清空联动三级级经济事项信息

      this.dataList[indexL].economic3Name = "";

      this.dataList[indexL].economic3Code = "";

      this.economicDialogOne = false;

      if (data.tag == 1) {

        this.getAllManagementCaliber()

      }

      if (data.tag == 0 && data.code != '') {

        this.getManagementCaliber(data.code);

      }

    },

    //2级经济事项弹窗

    openEconomicDialogTwo(row, index) {

      this.LIndex = index;

      // this.S2Index = index;

      if (this.sendAEData.edit == true) {

        this.$message({ type: "warning", message: "编辑状态下不可以选择,只可修改。" });

        return

      }

      if (this.dataList[index].economic1Code == ''&& this.dataList[index].economic1Name == '') {

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

      }else if(this.dataList[index].economic1Code == ''&& this.dataList[index].economic1Name != ''){

        this.$message({ type: "warning", message: "一级为新增,不可再选择二级经济事项名称。" });

      } else {

        this.pCode = this.dataList[index].economic1Code;

        this.economicDialogTwo = true;

      }

    },

    //关闭经济事项对话框

    closeEconomic2() {

      this.economicDialogTwo = false;

    },

    //经济对话框的保存

    saveEconomicData2(data) {

      console.log(data);

      let indexL = this.LIndex;

      this.dataList[indexL].economic2Name = data.name;

      this.dataList[indexL].economic2Code = data.code;

      this.dataList[indexL].tag = (data.tag == 1 ? "通用" : "专用");

      if (data.tag == 0) {

          this.dataList[indexL].limitAllow = true;

      }else{

          this.dataList[indexL].limitAllow = false;

      }

      //清空联动三级级经济事项信息

      this.dataList[indexL].economic3Name = "";

      this.dataList[indexL].economic3Code = "";

      this.economicDialogTwo = false;

      if (data.tag == 1) {

        this.getAllManagementCaliber()

      }

      if (data.tag == 0 && data.code != '') {

        this.getManagementCaliber(data.code);

      }

    },

    //获取管理口径

    getManagementCaliber(code) {

      let indexL = this.LIndex;

      let params = {

        economicCode: code

      };

      this.$http

        .post(

          this.URL + "/economicEventsApply/getTargetManagementCaliber",

          params

        )

        .then(res => {

          var result = res.body;

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

            this.dataList[indexL].caliberOption = result.data;

          }

        });

    },

    //获取全部管理口径

    getAllManagementCaliber() {

      let indexL = this.LIndex;

      this.$http

        .get(

          this.URL + "/economicEventsApply/getAllManagementCaliber",

          {})

        .then(res => {

          var result = res.body;

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

            this.dataList[indexL].caliberOption = result.data;

            if (this.sendAEData.edit == true) {

              let alterArr = []

              this.sendAEData.applyMgmList.forEach(element => {

                alterArr.push(element.managementCaliberCode+','+element.managementCaliberName)

              });

              this.dataList[0].mgmCaliberCode = alterArr;

              this.dataList[0].caliberSwatch = true;

            }

          }

        });

    },

    //导入

    closeImportFile() {

      this.dialogGetIn = false;

      this.search();

    },

    //取消导入弹窗

    cancelImportFile() {

      this.dialogGetIn = false;

    },

    getIn() {

      this.downloadUrl =

        "/template/template4EconomicEventsImport/downloadTemplate";

      this.importUrl = "/economicEvents/importEconomicEventsList";

      this.dialogGetIn = true;

    },

    //导出

    getOut() {

      var option = {

        url: this.URL + "/economicEvents/exportEconomicEventsList",

        data: {

          mdmEconomicEventsAttr: {

            mname: this.projectQueryDto.mname,

            mgmClbId: this.projectQueryDto.nodeId,

            code: this.projectQueryDto.code,

            name: this.projectQueryDto.name,

            pcode: this.projectQueryDto.pcode,

            pname: this.projectQueryDto.pname,

            status: this.projectQueryDto.status

          }

        },

        method: "post"

      };

      downLoadFile(option);

    },

    clearnAction() {

      this.$emit("closeAddEditdialog");

    },

    mainpost() {

      this.$Http

        .post(this.URL + "/emplRoleDeclare/findMainPostNode", {

          treeType: this.treeCode

        })

        .then(data => {

          var result = data.body;

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

            if (result.data == null) {

              if (this.treeCode == "TREE_FAS") {

                this.$message({

                  type: "warning",

                  message:

                    "您没有所属组织,请去组织树对应组织维护主岗为普通员工岗"

                });

              }

            } else {

              this.orgId = result.data.id;

            }

          }

        });

    },

    findOpenUser() {

      this.$Http

        .post(this.URL + "/emplRoleDeclare/findOperUsers", {})

        .then(data => {

          var result = data.body;

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

            this.emplId = result.data.id;

          } else {

            this.$message({

              showClose: true,

              message: result.message,

              type: "error",

              duration: 5000

            });

          }

        });

    },

    getLength(val) { 

        let str = new String(val); 

        let bytesCount = 0; 

        for (let i = 0 ,n = str.length; i < n; i++) { 

            let c = str.charCodeAt(i); 

            if ((c >= 0x0001 && c <= 0x007e) || (0xff60<=c && c<=0xff9f)) { 

                bytesCount += 1; 

            } else { 

                bytesCount += 2; 

            } 

        } 

        return bytesCount; 

    }, 

    //必填校验

    checkMust(){

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

        if(this.dataList[i].economic1Name == ''){

          tipMsg('一级经济事项名称不可为空', "warning");

          return false

        }

        if(this.dataList[i].tag == ''){

          tipMsg('标签必须选择', "warning");

          return false

        }

        if (this.sendAEData.edit== false) {

            if(this.dataList[i].economic1Code != ''&&this.dataList[i].economic2Name == ''){

              tipMsg('一级事项是选择,二级事项名称需要新增或选择', "warning");

              return false

            }

        }

        if (this.sendAEData.edit== false) {

            if(this.dataList[i].economic1Code != ''&&this.dataList[i].economic2Name == ''){

              tipMsg('一级事项是选择,二级事项名称需要新增或选择', "warning");

              return false

            }

        }

        if (this.sendAEData.edit== false) {

          if(this.dataList[i].economic2Code != ''&&this.dataList[i].economic3Name == ''){

            tipMsg('二级事项是选择,三级事项名称需要新增', "warning");

            return false

          }

        }

        if(this.getLength(this.dataList[i].economic1Name) >80){

          tipMsg('一级经济事项名称长度需在40个字符范围内。', "warning");

          return false

        }

        if(this.getLength(this.dataList[i].economic2Name)>80){

          tipMsg('二级经济事项名称长度需在40个字符范围内。', "warning");

          return false

        }

        if(this.getLength(this.dataList[i].comment)>500){

          tipMsg('释义字节长度需在250字符范围内。', "warning");

          return false

        }

      }

      return true;

    },

    openCause() {

      if (this.checkMust()) {

        //打开事由弹窗

        this.showCauseOfDeclare = true;

        this.causeOfDeclare ='' //置空事由。

      }

    },

    //关闭事由弹窗

      colseCause() {

        this.showCauseOfDeclare = false;

      },

      //事由填写完成,打开审批链弹窗

      saveCause() {

        if(this.causeOfDeclare == ''){

          tipMsg('填写申请事由','warning')

          return;

        }

        if(this.causeOfDeclare.length > 200){

          tipMsg('提交审批说明需要控制在200个字符内。','warning')

          return;

        }

        this.showIndicate = true;

        this.getApproval("经济事项新增/修改") //暂时使用 权限新增调试

      },

    getApproval(str) {

      let sen = {};

      sen.templateName = str; //审批链模板名称

      sen.organizationNodeId = this.orgId + ""; //公司组织id

      sen.emplId = this.emplId + "";

      this.$http.post(this.URL + "/approvalChain/findChain", sen).then(res => {

        if (res.body.code == "200") {

          this.stepData = res.body.data;

          this.stepData.forEach(it => {

            it.approvalChainPostList.forEach(ot => {

              if (ot.umAccountList.length == 0) {

                let aobj = {

                  name: "",

                  umNo: "",

                  umAccLength: 0

                };

                ot.umAccountList.push(aobj);

              }

            });

          });

        }

      });

    },

    //关闭审批链弹窗

    colseAction() {

      this.showIndicate = false;

    },

    //提交审批

    saveAction(_, enable) {

      var self = this;

      //用for循环来中止  forEach不行

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

        for (

          var o = 0;

          o < self.stepData[i].approvalChainPostList.length;

          o++

        ) {

          if (

            self.stepData[i].approvalChainPostList[o].umAccountList[0].name ==

            ""

          ) {

            tipMsg("审批人不能为空!", "error");

            enable();

            return;

          }

        }

      }

      //更新审批链数据, 整理sendData, 加入approvalChainInfoRepresentations, 主题TaskName,正文 TaskDesc字段

      self.stepData.forEach(item => {

        //只发送选中的审批人的信息,没选中的审批人去除

        item.approvalChainPostList.forEach(ot => {

          ot.umAccountList.forEach((val, index) => {

            if (ot.name == val.name) {

              ot.umAccountList[0] = ot.umAccountList[index];

              ot.umAccountList.splice(1, ot.umAccountList.length);

            }

          });

        });

      });

      let app = {};

      app.approvalChainInfos = this.stepData;

      app.causeOfDeclare = this.causeOfDeclare;

      app.orgId = this.orgId;

      let applyRecords = [];

      this.dataList.forEach(element => {

        let levelNo = "";

        let koujinRecords = [];

        if (element.economic3Name != ''&&element.economic3Name != null) {

          levelNo = 3

        } else if(element.economic2Name != ''&&element.economic2Name != null){

          levelNo = 2

        }else {

          levelNo = 1

        }

        element.mgmCaliberCode.forEach(item => {

          koujinRecords.push({

            'managementCaliberCode': item.substr(0, item.indexOf(',')), //截取前半部分

            'managementCaliberName': item.substr(item.indexOf(',')+1)

          });

        });

        //编辑页面的状态下多三个参数

        if (this.sendAEData.edit) {

            if (element.tag == "通用"||element.tag == 1) {

              applyRecords.push({

                economic1Code: element.economic1Code,

                economic1Name: element.economic1Name,

                economic2Code: element.economic2Code,

                economic2Name: element.economic2Name,

                economic3Code: element.economic3Code,

                economic3Name: element.economic3Name,

                tag: element.tag == "通用"||element.tag == 1 ? 1 : 0,

                comment: element.comment,

                levelNo: levelNo,

                status : element.status,

                completePath: element.completePath,

                pCode: element.pCode

              });

            } else {

              applyRecords.push({

                economic1Code: element.economic1Code,

                economic1Name: element.economic1Name,

                economic2Code: element.economic2Code,

                economic2Name: element.economic2Name,

                economic3Code: element.economic3Code,

                economic3Name: element.economic3Name,

                tag: element.tag == "通用"||element.tag == 1 ? 1 : 0,

                comment: element.comment,

                levelNo: levelNo,

                status : element.status,

                completePath: element.completePath,

                pCode: element.pCode,

                applyMgmList: koujinRecords

              });

            }

        }

        //新增情况下用这个。

        if (!this.sendAEData.edit) {

            if (element.tag == "通用"||element.tag == 1) {

            applyRecords.push({

              economic1Code: element.economic1Code,

              economic1Name: element.economic1Name,

              economic2Code: element.economic2Code,

              economic2Name: element.economic2Name,

              economic3Code: element.economic3Code,

              economic3Name: element.economic3Name,

              tag: element.tag == "通用"||element.tag == 1 ? 1 : 0,

              comment: element.comment,

              levelNo: levelNo

            });

          } else {

            applyRecords.push({

              economic1Code: element.economic1Code,

              economic1Name: element.economic1Name,

              economic2Code: element.economic2Code,

              economic2Name: element.economic2Name,

              economic3Code: element.economic3Code,

              economic3Name: element.economic3Name,

              tag: element.tag == "通用"||element.tag == 1 ? 1 : 0,

              comment: element.comment,

              levelNo: levelNo,

              applyMgmList: koujinRecords

            });

          }

        }

      });

      app.applyList = applyRecords;

      console.log(this.stepData);

      if (!this.sendAEData.edit) {

        this.$Http

        .post(this.URL + "/economicEventsApply/insert", app)

        .then(data => {

          enable();

          var result = data.body;

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

            tipMsg("新增提交申请成功!", "success");

            this.colseAction();

            this.closedApproval();

            this.colseCause();

            this.$emit("closeAddEditdialog");

          } else {

            tipMsg(result.message, "error");

          }

        })

        .catch(data => {

          enable();

        });

      } else {

        this.$Http

        .post(this.URL + "/economicEventsApply/update", app)

        .then(data => {

          enable();

          var result = data.body;

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

            tipMsg("编辑提交申请成功!", "success");

            this.colseAction();

            this.closedApproval();

            this.colseCause();

            this.$emit("closeAddEditdialog");

          } else {

            tipMsg(result.message, "error");

          }

        })

        .catch(data => {

          enable();

        });


      }

    },

    //打开选择审批人弹窗

    showApprovalDialog(obj2, obj) {

      this.sendIndex = obj;

      this.sendIndex2 = obj2;

      this.showApplier = true;

    },

    //关闭审批人员弹窗

    closedApproval() {

      this.showApplier = false;

    },

    //审批人弹窗选择信息

    getSubApprovalData(msg) {

      console.log(msg);

      let index1 = msg.index * 1;

      let index2 = msg.index2 * 1;

      this.stepData[index1].approvalChainPostList[

        index2

      ].umAccountList[0].name = msg.name;

      this.stepData[index1].approvalChainPostList[

        index2

      ].umAccountList[0].umNo = msg.umNo;

      this.closedApproval();

    },

    //选择

    selectItemTick(item) {

      this.checkedList = item;

    },

    //多选

    selectAllTick(item) {

      this.checkedList = item;

    },

    //新增信息行

    addList(name) {

      if (this.dataList.length == 0) {

        this.dataList.push({

          economic1Code: "",

          economic1Name: "",

          economic2Code: "",

          economic2Name: "",

          economic3Code: "",

          economic3Name: "",

          tag: "", //标签

          status: "",

          mgmCaliberCode: [],

          caliberOption: [], //管理口径容器

          caliberSwatch: true, //管理口径的禁用状态

          limitAllow: false, //通用选项是否禁用。默认可用

          comment: "" //释义

        });

      } else {

        let lastObj = this.dataList[this.dataList.length - 1];

        let copyobj = {};

        copyobj = {

          economic1Code: "",

          economic1Name: "",

          economic2Code: "",

          economic2Name: "",

          economic3Code: "",

          economic3Name: "",

          caliberSwatch: true, //管理口径的禁用状态

          limitAllow: false, //通用选项是否禁用。默认可用

          tag: "", //标签

          status: "",

          mgmCaliberCode: [],

          caliberOption: [], //管理口径容器

          comment: ""

        };

        this.dataList.push(JSON.parse(JSON.stringify(copyobj)));

      }

      this[name].forEach((item, index) => {

        item.index = index;

      });

    },

    //删除信息行

    delList(delArr, name) {

      //申请信息删除

      if (!this.checkedList.length) {

        tipMsg("请选择一条或多条数据进行删除", "warning");

      } else {

        if (

          this.dataList.length == 1 ||

          this.dataList.length == this.checkedList.length

        ) {

          tipMsg("至少要保留一条数据", "warning");

        } else {

          this[delArr].map(tempitem => {

            this[name].forEach((item, index) => {

              if (tempitem.index === item.index) {

                this[name].splice(index, 1);

                tipMsg("删除成功!", "success");

              }

            });

          });

        }

      }

    },

    checkTwoConditon(row,index){

      if (this.dataList[index].economic1Code == ""&& this.dataList[index].economic1Name == "") {

        tipMsg("请先选择或填写一级经济事项名称!", "warning");

      }

      // if (this.dataList[index].economic1Code == ""&& this.dataList[index].economic1Name != "") {

      //  tipMsg("一级为新增不能再选择或填二级经济事项", "warning");

      // }

    },

    checkThreeConditon(row,index){

      if (this.dataList[index].economic2Code == ""&& this.dataList[index].economic2Name == "") {

        tipMsg("请先选择或填写二级经济事项名称!", "warning");

      }

      // if (this.dataList[index].economic2Code == ""&& this.dataList[index].economic2Name != "") {

      //  tipMsg("二级经济事项为新增,不可再新增三级经济事项!", "warning");

      // }

    }

  }

};

</script>

<style>

</style>

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 218,204评论 6 506
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,091评论 3 395
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 164,548评论 0 354
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,657评论 1 293
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,689评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,554评论 1 305
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,302评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,216评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,661评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,851评论 3 336
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,977评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,697评论 5 347
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,306评论 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,898评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,019评论 1 270
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,138评论 3 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,927评论 2 355

推荐阅读更多精彩内容