• vue


    <template>
      <div>
        <el-dialog  v-model="labelPosition"  :visible.sync="dialogVisible" title="核心企业大期信息" :callValid="callValid" :api="api" :formRules="formRules" :form="form"
               width="950px"   :closeOnClickModal="false" :editModel="editModel" class="demo-form-inline"  ref="form">
        <div class="filter-container" align="center">
         <el-form :inline="true" ref="form" :model="form" :label-position="labelPosition" :rules="rules">
            <el-row >
                <div align="left">
                    <el-form-item label="核心企业" prop="coreEnterpriseId"  label-width="150px"> 
                      <select-core-enterprise :disabled="flag" v-model="form.coreEnterpriseId"  style=" 200px" class="filter-item"></select-core-enterprise>
                    </el-form-item>
    
                    <el-form-item label="无异议函" label-width="120px"></el-form-item>
                    <el-form-item >
                    <span v-if="editModel==='C'">
                        <file-upload :uploadApi="upapi" v-on:onUpload="addUpload" :fileID="fileId"  downloadApi='321' ></file-upload>
                    </span>
    
                      <span v-else-if="editModel==='E'||editModel==='V'" >
                        
                        <span>
                          <span v-if="editModel==='V'">
                              <span v-if="letterFileId !== undefined && letterFileId !==''">
                              <el-button class="filter-item margin-l-20"  type="primary" icon="el-icon-download"  size="small" 
                              @click="showDown(form,form.letterFileId)">下载查看
                               </el-button></span>
                               <span v-else>
                                 <span >暂未上传</span>
                                 </span>
                          </span>
    
                          <span v-else-if="editModel==='E'">
                              <file-upload :uploadApi="upapi" :editModel="editModel" :fileID="letterFileId" v-on:onUpload="editAddUpload"  downloadApi='321' ></file-upload>
                          </span>
    
                        </span>
                      </span>
                    </el-form-item>
                  <el-form-item label="金融机构" prop="financialInstitutionsId" label-width="150px">
                      <select-financial :disabled="flag" v-model="form.financialInstitutionsId"  style=" 200px" class="filter-item"></select-financial>
                    </el-form-item>
    
                    <el-form-item label="期数设置" prop="periods" label-width="120px">
                        </el-form-item>
    
                      <el-form-item prop="periodsSmall" label-width="50px">
                        <el-input class="filter-item" type="text" :disabled="isEditDisable"  v-model="periodsSmall" style="70px" ></el-input>
                      </el-form-item>
    
                      <el-form-item >
                        <el-col class="line">--</el-col>
                      </el-form-item>
    
                      <el-form-item prop="periodsLarge" label-width="50px">
                        <el-input class="filter-item" type="text" :disabled="isEditDisable" v-model="periodsLarge" style="70px" ></el-input>
                      </el-form-item>
                    
                </div>
                <div align="left">
                  <el-form-item label="大期名称" prop="bigPeriodsName" label-width="150px">
                      <el-col :span="4">
                      <el-input class="filter-item" type="text" :disabled="isEditDisable" style=" 200px"  v-model="form.bigPeriodsName" ></el-input>
                      </el-col>
                    </el-form-item>
                </div>
            </el-row>
                
              <el-row style="text-align: right;">
                <el-form-item >
                  <el-button type="primary" v-if="editModel=='E'" class="filter-item margin-l-20" @click="batchDel" icon="el-icon-minus">删除费用科目</el-button>
    
                  <el-button class="filter-item margin-l-20" v-if="editModel=='E'"  @click="showAdd" type="primary" icon="el-icon-plus">添加费用科目</el-button>
                </el-form-item>
              </el-row>
                  <el-row  v-show="editModel!='C'&&editModel!='CY'">
                  <el-col>
                    <template>
                        <el-table :header-cell-style="{background:'WhiteSmoke'}" :data="tableDatas" :api="costSubjectApi" :queryParas="queryParas" :loadCount.sync="loadCount"
                       :row-class-name="tableRowClassName" :showPage=false :operateColLayout="operateColLayout" border :selectedRows.sync="selectedRows" ref="dataTable" @selection-change="delHandleSelectionChange">
                          <el-table-column v-if="editModel=='E'" width="55"  type="selection" >
                          </el-table-column>
                          <el-table-column label="费用名称">
                            <template slot-scope="scope">
                              <span hidden style="margin-left: 10px">{{ scope.row.id }}</span>
                              <span style="margin-left: 10px;" >{{ scope.row.name }}</span>
                            </template>
                          </el-table-column>
                          <el-table-column label="收款公司" width="415">
                            <template slot-scope="scope">
                              <select-biz-collection-company v-if="editModel==='E'" v-model="scope.row.companyIds"></select-biz-collection-company>
                              <span v-else style="text-align:center;display:block; ">
                                {{ scope.row.companyName }}
                              </span>
                            </template>
                          </el-table-column>
                          <el-table-column label="协议" width="330">
                            <template slot-scope="scope">
                              <span v-if="scope.row.agreementFlag ===1" > 
                                <span v-if="editModel === 'E'">
                                  <span>
                                    <div class="dataUplad">
                                      <append-file-upload  :uploadApi="upapi" v-on:onUpload="idInfo" v-on:idInfo="handleEdit(scope.row.subjectNameId)" downloadApi='321' >
                                      </append-file-upload></div>
    
                                    <div class="dataUplad">
                                      <add-upload  :uploadApi="upapi" v-on:onDataUpload="uploadIdInfo"  v-on:onSubjectId="handleUpload(scope.row.subjectNameId)"   downloadApi='321' >
                                      </add-upload>
                                    </div>
                                  </span>
                                <span>
                                  <div class="dataUplad" style="margin : 0px 0px 15px 5px;">
                                  <el-button  size="small" type="primary"  @click="dialogFormVisible = down,downLook(scope.row.subjectNameId)" icon="el-icon-download">查看下载</el-button>
                                  </div></span>
                                </span>
                              <span v-else style="text-align:center; 100%;display:block; ">
                                <el-button type="primary" size="small"  @click="dialogFormVisible = down,downLook(scope.row.id)" icon="el-icon-download">查看下载</el-button>
                              </span>
                              </span>
                              <span v-else-if="scope.row.agreementFlag === 0" style="text-align:center; 100%;display:block; ">
                                <span v-if="editModel!=='V'">
                                  <span style="text-align:center; 100%;display:block; ">
                                  <data-upload :uploadApi="upapi" :index="scope.row.index" :subjectNameId="scope.row.subjectNameId"  v-on:onDataUpload="uploadIdInfo" 
                                    v-on:onSubjectId="handleUpload(scope.row.subjectNameId)"   downloadApi='321' >
                                  </data-upload></span>
                                </span>
                                <span v-else>暂未上传
                                </span>
    
                              </span >
                              <span v-else-if="scope.row.agreementFlag === undefined"></span>
                                
                            </template>
                          </el-table-column>
                          </el-table>
                    </template>
                  </el-col>
                </el-row>
                &nbsp;
              <div>
                <el-button v-if="editModel!=='V'" type="primary" @click="save">保 存</el-button>
                <span v-if="editModel=='V'">
                  <el-button @click="dialogVisible = false">关 闭</el-button>
                </span>
                <!-- <span v-else-if="editModel === 'C'">
                  <el-button @click="dialogVisible = false,cancel()">取 消</el-button>
                </span> -->
                <span v-else>
                  <el-button @click="dialogVisible = false,resetForm('form')">取 消</el-button>
                </span>
              </div>
    
                </el-form>
            </div>
        </el-dialog>
        <costSubject-edit :visible.sync="showDetail1" v-on:onSaved="handleFilter" :form="item" :bigPeriodsName='form.bigPeriodsName' 
         :financialInstitutionsId='form.financialInstitutionsId' :coreEnterpriseId='form.coreEnterpriseId' :editModel="editModel1" :anc="item"></costSubject-edit>
    
        <el-dialog title="已上传协议文件信息列表"  :visible.sync="dialogFormVisible" :closeOnClickModal="false" >
          <el-row  v-show="editModel!='C'&&editModel!='CY'">
            <el-col>
              <template>
                  <el-table v-loading="loading" element-loading-text="下载中···" element-loading-spinner="el-icon-loading" element-loading-background="rgba(255, 255, 255, 255)"
                   :header-cell-style="{background:'WhiteSmoke'}" :data="agreementTableDatas" :api="costSubjectApi" :showPage=false  border :operateColLayout="operateColLayout" :loadCount.sync="loadCount"
                   :queryParas="queryParas" :selectedRows.sync="selectedRowsInfo" @selection-change="handleSelectionChange">
                   <el-table-column type="selection"  width="55">
                   </el-table-column>
                  <el-table-column label="协议名称">
                    <template slot-scope="scope">
                      <span style="margin-left: 10px">{{ scope.row.fileName }}</span>
                      <span hidden style="margin-left: 10px">{{ scope.row.agreementFileId }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column label="上传时间">
                    <template slot-scope="scope">
                      <span style="margin-left: 10px">
                        {{ scope.row.uploadTime }}
                      </span>
                    </template>
                  </el-table-column>
                  </el-table>
              </template>
            </el-col>
          </el-row>
          <div slot="footer" class="dialog-footer" style="text-align:center; 100%;display:block; ">
            <el-button  @click="downFile()">下载</el-button>
          </div>
        </el-dialog>
    
      </div>
    </template>
    <style>
      .dataUplad{float: left}
      .el-checkbox__inner {
        display: inline-block;
        position: relative;
        border: 1px solid #dcdfe6;
        border-radius: 2px;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
        width: 22px;
        height: 22px;
        background-color: #fff;
        z-index: 1;
        -webkit-transition: border-color .25s cubic-bezier(.71,-.46,.29,1.46),background-color .25s cubic-bezier(.71,-.46,.29,1.46);
        transition: border-color .25s cubic-bezier(.71,-.46,.29,1.46),background-color .25s cubic-bezier(.71,-.46,.29,1.46);
      }
    .el-checkbox__inner::after {
        -webkit-box-sizing: content-box;
        box-sizing: content-box;
        content: "";
        border: 1px solid #fff;
        border-left: 0;
        border-top: 0;
        height: 13px;
        left: 10px;
        position: absolute;
        top: 1px;
        -webkit-transform: rotate(45deg) scaleY(0);
        transform: rotate(45deg) scaleY(0);
        width: 3px;
        -webkit-transition: -webkit-transform .15s ease-in .05s;
        transition: -webkit-transform .15s ease-in .05s;
        transition: transform .15s ease-in .05s;
        transition: transform .15s ease-in .05s,-webkit-transform .15s ease-in .05s;
        -webkit-transform-origin: center;
        transform-origin: center;
    }
    </style>
    
    <script type="text/ecmascript-6">
    import DataTable from '@/components/element/DataTable'
    import AgainUpload from '@/components/element/AgainUpload'
    import FileUpload from '@/components/element/FileUpload'
    import DataUpload from '@/components/element/DataUpload'
    import AppendFileUpload from '@/components/element/AppendFileUpload'
    import BaseEdit from '@/pages/finance/financeBaseEditPage'
    import AddUpload from '@/components/element/AddUpload'
    import costSubjectEdit from '@/pages/finance/costSubjectEdit'
    import SelectFinancial from '@/components/element/SelectFinancial'
    import SelectCoreEnterprise from '@/components/element/SelectCoreEnterprise'
    import SelectBizCollectionCompany from '@/components/element/SelectBizCollectionCompany'
    import financeApi from '@/api/financeApi.js'
    import httpConfig from '@/api/finance/httpConfig.js'
    import { Message } from 'element-ui'
    import qhyffsApi from '@/api/qhyffsApi'
    import { downloadFromLocal } from '@/utils/download'
    export default {
      extends: new BaseEdit('coreEnterpriseMaintenanceEdit'),
      data () {
        return {
          file: {},
          fileList: [],
          operateColLayout: '',
          queryParas: {
            absId: ''
          },
          agreementName: '',
          formLabelWidth: '120px',
          selectedRowsInfo: [],
          selectedRows: [],
          loadCount: 0,
          name: '',
          editModel1: 'V',
          showDetail1: false,
          item: {
          },
          agreementFileId: {},
          labelPosition: 'right',
          title: '核心企业大期信息',
          dialogFormVisible: false,
          fileIdInfo: '',
          uploadId: '',
          region: '',
          callValid: 0,
          fileId: '',
          tableDatas: [],
          companyIdAll: [],
          saveTableDatas: [],
          agreementTableDatas: [],
          downSubjectNameId: '',
          letterFileId: '',
          selectedOptions: [],
          subjectNameIdInfo: [],
          nameMaxlength: 20,
          codeMaxlength: 20,
          coreEnterpriseName: '',
          financialInstitutionsName: '',
          showPage: false,
          costSubjectApi: financeApi.costSubjectEditInfo,
          options: [],
          loading: false,
          periodsSmall: '',
          periodsLarge: '',
          Verification: 1,
          indexInfo: '',
          upapi: process.env.BASE_API + '/api/sys/file/upload',
          rules: {
            periods: [{
              required: true,
              // message: '请填写最小值',
              trigger: 'blur'
            }],
            bigPeriodsName: [{
              required: true,
              message: '请填写大期',
              trigger: 'blur'
            }],
            financialInstitutionsId: [{
              required: true,
              // message: '请选择金融机构',
              trigger: 'blur'
            }],
            coreEnterpriseId: [{
              required: true,
              // message: '请选择核心企业',
              trigger: 'blur'
            }]
          }
          // downloads: process.env.BASE_API + '/api/finance/biz/big/periods/maintain/agreement/update'
        }
      },
      components: {
        httpConfig,
        FileUpload,
        AddUpload,
        AgainUpload,
        DataTable,
        costSubjectEdit,
        SelectFinancial,
        Message,
        DataUpload,
        AppendFileUpload,
        SelectCoreEnterprise,
        SelectBizCollectionCompany
      },
      computed: {
        down: function () {
          return true
        },
        uploadApi: function () {
          return httpConfig.MID_FILE + ''
        },
        downloadApi: function () {
          return httpConfig.MID_FILE + ''
        },
        flag () {
          if (this.editModel === 'E') {
            return true
          } else if (this.editModel === 'V') {
            return true
          } else {
            return false
          }
        },
        api: function () {
          return financeApi.coreEnterpriseMaintenance
        }
      },
      watch: {
        dialogVisible: function (val) {
          if (val) {
            this.editModel === 'E' ? this.form.name : null
            this.editModel === 'E' ? this.form.code : null
          }
          if (this.editModel !== 'C') {
            if (this.editModel === 'E') {
              financeApi.costSubjectEditInfo.getValue({absId: this.form.id}).then(res => {
                if (res && res.data) {
                  this.tableDatas = res.data.map(item => {
                    item.companyIds = item.SubjectName.map(it => it.id)
                    return item
                  })
                  let companyIds = this.tableDatas.map(item => {
                    var companyIdAll = []
                    for (var i = 0; i < item.companyIds.length; i++) {
                      companyIdAll[i] = {CompanyId: item.companyIds[i]}
                    }
                    return {bizFinancialSubjectsId: item.SubjectNameId, collectionCompanyIds: companyIdAll, subjectId: item.bizFinancialSubjectsId}
                  })
                  this.saveTableDatas = JSON.stringify(companyIds)
                }
              })
            } else {
              financeApi.coreEnterpriseMaintenanceEdit.getDetails({absId: this.form.id}).then(res => {
                if (res && res.data) {
                  this.tableDatas = res.data
                }
              })
            }
          }
          // 根据ID找到对应的核心企业名称
          qhyffsApi.coreEnterprise.getList(null).then(response => {
            for (var i = 0; i < response.data.length; i++) {
              if (this.form.coreEnterpriseId === response.data[i].id) {
                this.coreEnterpriseName = response.data[i].coreEnterpriseName
              }
            }
          })
          // 根据ID找到对应的金融机构名称
          qhyffsApi.financial.getList(null).then(response => {
            for (var i = 0; i < response.data.length; i++) {
              if (this.form.financialInstitutionsId === response.data[i].id) {
                this.financialInstitutionsName = response.data[i].financialInstitutionsName
              }
            }
          })
          this.periodsSmall = this.form.periodsSmall
          this.periodsLarge = this.form.periodsLarge
          if (this.editModel === 'C') {
            this.letterFileId = ''
          } else {
            this.letterFileId = this.form.letterFileId
          }
        }
      },
      methods: {
        resetForm (formName) {
          this.$nextTick(() => {
            this.$refs[formName].clearValidate()
          })
          this.fileId = ''
        },
        // changeCellStyle ({row, column, rowIndex, columnIndex}) {
        //   // 第1列添加 red 类
        //   if (columnIndex === 0) {
        //     return 'red'
        //   }
        // },
        // 获取选中行
        tableRowClassName ({row, rowIndex}) {
          row.index = rowIndex
        },
        showDown: async function (data, fileUuid) {
          data.excludeFs = await this.getExcludeFs()
          this.item = Object.assign({}, data)
          downloadFromLocal(fileUuid)
        },
        downFile () {
          if (this.selectedRowsInfo.length === 0) {
            this.warning(`请勾选要下载的文件`)
            return
          }
          // this.openFullScreen()
          this.loading = true
          financeApi.costSubjectEditInfo.getDown({FileUuidList: JSON.stringify(this.agreementFileId)}).then(ress => {
            if (ress && ress.data) {
              this.success(`文件下载成功!`)
              downloadFromLocal(ress.data)
            } else {
              this.error(`文件下载失败!`)
            }
            this.loading = false // 关闭帷幕
          },
          res => {
            this.loading = false
          })
        },
        handleFilter () {
          if (this.form.id) {
            financeApi.costSubjectEditInfo.getValue({absId: this.form.id}).then(res => {
              if (res && res.data) {
                this.tableDatas = res.data.map(item => {
                  item.companyIds = item.SubjectName.map(it => it.id)
                  return item
                })
              }
            })
          }
        },
        // handleDataFilter () {
        //   if (this.form.id) {
        //     financeApi.costSubjectEditInfo.getValue({absId: this.form.id}).then(res => {
        //       if (res && res.data) {
        //         this.tableDatas.agreementFlag = res.data.map(item => {
        //           return item.agreementFlag
        //         })
        //       }
        //     })
        //   }
        // },
        handleSelectionChange (val) {
          for (var i = 0; i < val.length; i++) {
            this.selectedRowsInfo[i] = val[i].subjectNameId
          }
          this.agreementFileId = val.map(item => { return {FileUuid: item.agreementFileId} })
        },
        delHandleSelectionChange (val) {
          this.selectedRows = val
          for (var i = 0; i < val.length; i++) {
            this.subjectNameIdInfo[i] = val[i].subjectNameId
          }
        },
        //  编辑时,覆盖上传获取当前科目ID
        idInfo: function (row) {
          this.fileIdInfo = row
        },
        handleEdit: function (rowSubjectNameIds) {
          financeApi.costSubjectEditInfo.getCoverUpload({absRelationId: rowSubjectNameIds, fileUuid: this.fileIdInfo}).then(res => {
            if (res.data === true) {
              this.success(`覆盖上传成功!`)
            } else {
              this.error(`覆盖上传失败!`)
            }
          })
        },
        uploadIdInfo: function (fileInfo) {
          if (fileInfo.file !== null) {
            this.tableDatas.map(res => {
              if (res.index === fileInfo.index) {
                res.agreementFlag = 1
              }
            })
          }
          this.uploadId = fileInfo.file
          this.indexInfo = fileInfo.index
          this.rowSubjectNameIds = fileInfo.subjectNameId
        },
        // handleAddUpload: function (rowSubjectNameIds) {
        //   financeApi.costSubjectEditInfo.getFileUpload({absRelationId: this.rowSubjectNameIds, fileUuid: this.uploadId}).then(res => {
        //     if (res.data === true) {
        //       this.success(`文件追加上传成功!`)
        //     } else {
        //       this.error(`文件追加上传失败!`)
        //     }
        //   })
        // },
        handleUpload: function (rowSubjectNameIds) {
          financeApi.costSubjectEditInfo.getFileUpload({absRelationId: rowSubjectNameIds, fileUuid: this.uploadId}).then(res => {
            if (res.data === true) {
              this.success(`文件上传成功!`)
              // this.handleFilter()
            } else {
              this.error(`文件上传失败!`)
            }
          })
        },
        handleData: function () {
          this.handleFilter()
        },
        // 新增上传时传值
        addUpload: function (fileId) {
          this.fileId = fileId
        },
        editAddUpload: function (fileId) {
          this.fileId = fileId
          // this.handleFilter()
        },
        downLook: function (subjectNameId) {
          this.downSubjectNameId = subjectNameId
          financeApi.costSubjectEditInfo.getUpload({absRelationId: subjectNameId}).then(ress => {
            if (ress && ress.data) {
              this.agreementTableDatas = ress.data
            }
          })
        },
        batchDel: function () {
          if (this.selectedRows.length === 0) {
            this.warning(`请勾选要删除的数据`)
            return
          }
          let $this = this
          $this.confirmWarin('确认要删除选中行的数据吗', '询问', () => {
            financeApi.coreEnterpriseMaintenanceEdit.del($this.subjectNameIdInfo).then(res => {
              if (res && res.errcode === '0') {
                $this.success(`删除成功`)
                this.selectedRows = this.selectedRows.sort((a, b) => (b.index - a.index))
                for (let item of this.selectedRows) {
                  this.tableDatas.splice(item.index, 1)
                }
                // financeApi.costSubjectEditInfo.getValue({absId: this.form.id}).then(res => {
                //   if (res && res.data) {
                //     this.tableDatas = res.data.map(item => {
                //       item.companyIds = item.SubjectName.map(it => it.id)
                //       return item
                //     })
                //   }
                // })
              } else {
                $this.error(`删除失败`)
              }
            })
          }, () => {
    
          })
        },
        blurFnNum: function (row) {
          // 验证修改金额必须为数字
          let reg = /^[0-9]*$/
          if (row.periodsSmall != null && !reg.test(row.periodsSmall)) {
            this.warning('期数最小值只能输入正整数')
            return false
          }
          if (row.periodsLarge != null && !reg.test(row.periodsLarge)) {
            this.warning('期数最大值只能输入正整数')
            return false
          }
          return true
        },
        // 保存数据
        save: function () {
          let $this = this
          this.callValid++
          if (!this.form || !this.form.coreEnterpriseId) {
            this.warning('请选择核心企业!')
            this.$refs.fwSel.focus()
            return
          } else if (!this.form || !this.form.financialInstitutionsId) {
            this.warning('请选择金融机构!')
            this.$refs.fwSel.focus()
            return
          } else if (!this.form || !this.periodsSmall) {
            this.warning('请填写期数最小值!')
            this.$refs.fwSel.focus()
            return
          } else if (!this.form || !this.periodsLarge) {
            this.warning('请填写期数最大值!')
            this.$refs.fwSel.focus()
            return
          } else if (!this.form || !this.form.bigPeriodsName) {
            this.warning('请输入大期名称!')
            this.$refs.fwSel.focus()
            return
          }
          if (parseInt(this.periodsSmall) > parseInt(this.periodsLarge)) {
            this.warning('期数的最小值【' + this.periodsSmall + '】不能大于最大值【' + this.periodsLarge + '】!')
            this.$refs.fwSel.focus()
            return
          }
          let period = {
            periodsSmall: this.periodsSmall,
            periodsLarge: this.periodsLarge
          }
          let f = this.blurFnNum(period)
          if (!f) return
          // 重置表单
          this.$refs['form'].clearValidate()
          // 新增数据的保存
          if ($this.editModel === 'C') {
            let forms = {
              coreEnterpriseId: this.form.coreEnterpriseId,
              financialInstitutionsId: this.form.financialInstitutionsId,
              periodsSmall: this.periodsSmall,
              periodsLarge: this.periodsLarge,
              letterFileId: this.fileId,
              bigPeriodsName: this.form.bigPeriodsName
            }
            financeApi.coreEnterpriseMaintenanceEdit.check(forms).then(res => {
              if (res.data === false) {
                this.warning('期数重叠,请重新输入!')
                return
              } else {
                // 校验期数漏期,并提示出来
                financeApi.coreEnterpriseMaintenanceEdit.addCheck(forms).then(res => {
                  let exfrom = ''
                  if (res.data) {
                    for (var i = 0; i < res.data.length; i++) {
                      exfrom += res.data[i]
                    }
                  }
                  if (exfrom.length > 0) {
                    this.$confirm(`当前添加的大期区间存在遗漏,遗漏的区间是[${exfrom}],请确认是否保存?`, '提示', {
                      confirmButtonText: '确定',
                      cancelButtonText: '取消',
                      type: 'warning'
                    }).then(() => {
                      $this.api.create(forms).then(res => {
                        if (res.data === true) {
                          this.form.letterFileId = ''
                          Message({
                            message: `新增${this.title}成功`,
                            type: 'success',
                            duration: 5 * 1000
                          })
                          $this.$emit('onSaved')
                          $this.dialogVisible = false
                        } else {
                          this.form.letterFileId = ''
                          Message({
                            message: `新增${this.title}失败`,
                            type: 'success',
                            duration: 5 * 1000
                          })
                          return
                        }
                      })
                    }).catch(() => {
                      this.$message({
                        type: 'info',
                        message: '已取消保存'
                      })
                    })
                  } else {
                    $this.api.create(forms).then(res => {
                      if (res.data === true) {
                        this.form.letterFileId = ''
                        Message({
                          message: `新增${this.title}成功`,
                          type: 'success',
                          duration: 5 * 1000
                        })
                        $this.$emit('onSaved')
                        $this.dialogVisible = false
                      } else {
                        this.form.letterFileId = ''
                        Message({
                          message: `新增${this.title}失败`,
                          type: 'success',
                          duration: 5 * 1000
                        })
                        return
                      }
                    })
                  }
                })
              }
              this.fileId = ''
            })
          } else if ($this.editModel === 'E') {
            if ($this.fileId === '') {
              $this.fileId = $this.form.letterFileId
            }
            // 编辑数据的保存
            financeApi.coreEnterpriseMaintenanceEdit.check({coreEnterpriseId: this.form.coreEnterpriseId, financialInstitutionsId: this.form.financialInstitutionsId, periodsSmall: this.periodsSmall, periodsLarge: this.periodsLarge, bigPeriodsId: this.form.id}).then(res => {
              if (res.data === false) {
                this.warning('期数重叠,请重新输入!')
                return
              } else {
                // 校验期数漏期,并提示出来
                financeApi.coreEnterpriseMaintenanceEdit.addCheck({coreEnterpriseId: this.form.coreEnterpriseId, financialInstitutionsId: this.form.financialInstitutionsId, periodsSmall: this.periodsSmall, periodsLarge: this.periodsLarge, bigPeriodsId: this.form.id}).then(res => {
                  let exfrom = ''
                  if (res.data) {
                    for (var i = 0; i < res.data.length; i++) {
                      exfrom += res.data[i]
                    }
                  }
                  if (exfrom.length > 0) {
                    this.$confirm(`当前添加的大期区间存在遗漏,遗漏的区间是[${exfrom}],请确认是否保存?`, '提示', {
                      confirmButtonText: '确定',
                      cancelButtonText: '取消',
                      type: 'warning'
                    }).then(() => {
                      let companyIds = this.tableDatas.map(item => {
                        var companyIdAll = []
                        for (var i = 0; i < item.companyIds.length; i++) {
                          companyIdAll[i] = {CompanyId: item.companyIds[i]}
                        }
                        return {bizFinancialSubjectsId: item.subjectNameId, collectionCompanyIds: companyIdAll, subjectId: item.bizFinancialSubjectsId}
                      })
                      this.saveTableDatas = JSON.stringify(companyIds)
                      this.api.updateData({coreEnterpriseId: this.form.coreEnterpriseId, financialInstitutionsId: this.form.financialInstitutionsId, bigPeriodsId: $this.form.id, periodsSmall: $this.periodsSmall, periodsLarge: $this.periodsLarge, bigPeriodsName: $this.form.bigPeriodsName, letterFileId: $this.fileId, ExpenseCompany: this.saveTableDatas}).then(res => {
                        if (res.data === false) {
                          Message({
                            message: `修改${$this.title}失败`,
                            type: 'error',
                            duration: 5 * 1000
                          })
                          return
                        } else {
                          Message({
                            message: `修改${$this.title}成功`,
                            type: 'success',
                            duration: 5 * 1000
                          })
                          $this.$emit('onSaved')
                          $this.dialogVisible = false
                        }
                      })
                    }).catch(() => {
                      this.$message({
                        type: 'info',
                        message: '已取消保存'
                      })
                    })
                  } else {
                    let companyIds = this.tableDatas.map(item => {
                      var companyIdAll = []
                      for (var i = 0; i < item.companyIds.length; i++) {
                        companyIdAll[i] = {CompanyId: item.companyIds[i]}
                      }
                      return {bizFinancialSubjectsId: item.subjectNameId, collectionCompanyIds: companyIdAll, subjectId: item.bizFinancialSubjectsId}
                    })
                    this.saveTableDatas = JSON.stringify(companyIds)
                    this.api.updateData({coreEnterpriseId: this.form.coreEnterpriseId, financialInstitutionsId: this.form.financialInstitutionsId, bigPeriodsId: $this.form.id, periodsSmall: $this.periodsSmall, periodsLarge: $this.periodsLarge, bigPeriodsName: $this.form.bigPeriodsName, letterFileId: $this.fileId, ExpenseCompany: this.saveTableDatas}).then(res => {
                      if (res.data === false) {
                        Message({
                          message: `修改${$this.title}失败`,
                          type: 'error',
                          duration: 5 * 1000
                        })
                        return
                      } else {
                        Message({
                          message: `修改${$this.title}成功`,
                          type: 'success',
                          duration: 5 * 1000
                        })
                        $this.$emit('onSaved')
                        $this.dialogVisible = false
                      }
                    })
                  }
                })
              }
              this.fileId = ''
            })
          }
        },
        handleExceed (files, fileList) {
          this.$message.warning(`当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`)
        },
        loadData () {
        },
        onSave () {
          this.$emit('onSave')
        },
        getExcludeFs () {
          let exfrom = []
          if (this.tableDatas.length > 0) {
            for (var i = 0; i < this.tableDatas.length; i++) {
              exfrom.push(this.tableDatas[i].name)
            }
          }
          return exfrom
        },
        showAdd: async function () {
          this.item = Object.assign({}, {
            bigPeriodsId: this.form.id,
            periodsSmall: this.form.periodsSmall,
            periodsLarge: this.form.periodsLarge,
            coreEnterpriseId: this.form.coreEnterpriseId,
            financialInstitutionsId: this.form.financialInstitutionsId,
            coreEnterpriseName: this.coreEnterpriseName,
            financialInstitutionsName: this.financialInstitutionsName,
            excludeFs: await this.getExcludeFs(),
            editable: '1',
            editModel: 'E'
          })
          this.editModel1 = 'E'
          this.showDetail1 = true
        }
      }
    }
    </script>
  • 相关阅读:
    Egret的第三方库制作,以及在大型项目中的应用
    阿里云申请免费https证书 + IIS服务器安装
    Android事件处理的2种方式:监听器与回调
    Android工具类-关于网络、状态的工具类
    Android下Notification,样式style,主题theme的功能实现
    静态工厂模式 理解
    Android下的联网下载的操作
    Android启动Activity的标准Action和标准Category
    Android RGB颜色查询对照表
    Android颜色值(RGB)所支持的四种常见形式
  • 原文地址:https://www.cnblogs.com/xiaoniuniu886/p/11094059.html
Copyright © 2020-2023  润新知