开发笔记2

2021.03.01

1.未编辑某项目,则不能查看,校验(再查看按钮)

核心代码:<div v-if="scope.row.status === null">
            {{ scope.row.itemName}}
          </div>
例如:<el-table-column label="项目名称" align="center" prop="itemName" >
          <template slot-scope="scope">
              <div style="color:blue;text-decoration:underline;cursor:pointer;" 
              @click="handleView(scope.row)"
              v-if="scope.row.status!==null">{{ scope.row.itemName }}
             </div>
          <div v-if="scope.row.status === null">
              {{ scope.row.itemName}}
         </div>
        </template>
      </el-table-column>

2.点提交同时修改两种状态

int submit(String pmSubid);
//impl
@Override
    public int submit(String pmSubid){
        return pmSubcontractReviewMapper.submit(pmSubid);
    }
//controller
@GetMapping("/submit/{pmSubids}")
    public AjaxResult submit(@PathVariable String pmSubids)
    {
        return toAjax(pmSubcontractReviewService.submit(pmSubids));
    }
//xml
<update id="submit" parameterType="String">
        UPDATE pm_subcontract_review SET status = '1' , flow_status='2' where pm_subid = #{pmSubid}
 </update>
//js
export function submitPmSubcontractReview(pmSubid) {
  return request({
    url: '/project/PmSubcontractReview/submit/' + pmSubid,
    method: 'get'
  })
}

3.不用字典翻译的情况下,给定某字段某状态(提交接口)

//核心代码
<template scope="scope">
   	<span>{{scope.row.status| statusFilter}}</span>
</template>
例如:
<el-table-column label="表单状态" align="center" prop="status">
        <template scope="scope">
          <span>{{scope.row.status| statusFilter}}</span>
        </template>
 </el-table-column>
data(){
},
filters: {
      statusFilter(status) {
        const statusMap = {
          '0': '草稿',
          '1': '已处理'
        }
        return statusMap[status]
      }
    },

4.将el-select默认样式去掉

核心属性filterable remote reserve-keyword

<el-col :span="8">
       <el-form-item label="分包方式" prop="way">
              <el-select placeholder="请选择" v-model="form.way" :disabled="true" filterable  remote reserve-keyword>
                <el-option v-for="dict in wayOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
              </el-select>
        </el-form-item>
 </el-col>

在这里插入图片描述
在这里插入图片描述

5.查看项目,不展示保存和提交按钮

核心代码:v-if="!(this.action == ‘view’)"

<el-button type="primary" icon="el-icon-check" size="mini" v-if="!(this.action == 'view')" @click="submitForm">保存</el-button>
<el-button type="success" icon="el-icon-check" size="mini" v-if="!(this.action == 'view')" @click="submit">提交</el-button>

6.查看项目时若有上传附件,只能查看附近,不能上传

核心代码: isUpload: this.action == ‘add’ || this.action == ‘update’

uploadDatas(id, categoryType) {
        var uploadData = {
          busiId: id,
          createName: this.$store.state.user.name,
          categoryType: categoryType,
          isUpload: this.action == 'add' || this.action == 'update' //是否允许上传文件
        }
        return uploadData
      },

2021.03.01-04.22

1.前端form表单日期格式化

核心代码:value-format=“yyyy-MM-dd”

<el-col :span="8">
     <el-form-item label="合同开工日期" prop="commencementDate">
	      <el-date-picker
	        v-model="form.commencementDate"
	        type="date"
	        value-format="yyyy-MM-dd"
	        placeholder="选择日期"
	        style="width: 100%;"
	        :disabled="true"
	      />
     </el-form-item>
</el-col>

2.不同Table页下的同一个选择器弹框

核心代码:@click=“dialogPostVisible=true;one=‘0’;userType=1”

<el-col :span="12">
         <el-form-item label="质量目标职责岗位" prop="tResponsiblePost" label-width="25%">
              <el-input v-model="form.tResponsiblePost" placeholder="请选择质量目标职责岗位">
                    <el-button v-if="!(action === 'view')" slot="append" icon="el-icon-search" @click="dialogPostVisible=true;one='0';userType=1">选择</el-button>
              </el-input>
          </el-form-item>
</el-col>

核心代码:@click="openPerson=true;userType=1"
<el-col :span="12">
     <el-form-item label="质量目标责任人" prop="tResponsiblePerson">
           <el-input v-model="form.tResponsiblePerson" placeholder="质量目标责任人">
               <el-button v-if="!(action === 'view')" slot="append" icon="el-icon-search" @click="openPerson=true;userType=1">选择</el-button>
           </el-input>
      </el-form-item>
 </el-col>

核心代码:@click="dialogPostVisible=true;one='0';userType=2"
<el-col :span="12">
          <el-form-item label="技术创效职责岗位" prop="qResponsiblePost" label-width="25%">
                  <el-input v-model="form.qResponsiblePost" placeholder="请选择创效职责岗位">
                     <el-button v-if="!(action === 'view')" slot="append" icon="el-icon-search" @click="dialogPostVisible=true;one='0';userType=2">选择</el-button>
                  </el-input>
           </el-form-item>	
</el-col>

核心代码:@click="openPerson=true;userType=2"
              <el-col :span="12">
                <el-form-item label="技术创效责任人" prop="qResponsiblePerson">
                  <el-input v-model="form.qResponsiblePerson" placeholder="技术创效责任人">
                    <el-button v-if="!(action === 'view')" slot="append" icon="el-icon-search" @click="openPerson=true;userType=2">选择</el-button>
                  </el-input>
                </el-form-item>
              </el-col>
 //责任岗位选择器弹框
<div v-if="dialogPostVisible">
        <el-dialog :title="PostListTitle" :visible.sync="dialogPostVisible" width="80%" append-to-body>
          <postList @postOne="postOne" :one="one"></postList>
        </el-dialog>
    </div>
//责任人选择器弹框
    <div v-if="openPerson">
      <el-dialog :title="PersonTitle" :visible.sync="openPerson" width="80%" append-to-body>
        <UserPeople @closeDialog="closeUser" :postId='postId'></UserPeople>
      </el-dialog>
    </div>

//责任人
closeUser(data) {
      var postName = [];
        //质量目标责任人
      if (this.userType == 1) {
        for (let i = 0; i <data.length; i++) {
          postName.push(data[i].nickName);
        }
        this.form.tResponsiblePerson= postName.toString()
      }else{
     //技术创效责任人
        for (let i = 0; i <data.length; i++) {
          postName.push(data[i].nickName);
        }
        this.form.qResponsiblePerson= postName.toString()
      }
        this.openPerson = false;
    },

//责任岗位
postOne(data){
      if(this.userType == "1"){
        //质量目标责任岗位
        this.form.tResponsiblePost = data.postName;
        this.postId = data.postId
      }else{
        //技术创效责任岗位
        this.form.qResponsiblePost = data.postName;
        this.postId = data.postId
      }
      this.dialogPostVisible = false;
    },

3.通过自己项目模块去修改其他模块的某字段状态

public int commit(MmContractSigning mmContractSigning) {
        syncCollaborativeDept(mmContractSigning);
        mmContractSigning.setContractStates("1");
        mmContractSigning.setFlowStatus("2");
        //点提交修改客户类型为老客户
        MmEnterpriseGovernment mmEnterpriseGovernment = new MmEnterpriseGovernment();
        mmEnterpriseGovernment.setId(mmContractSigning.getCustomerId());
        mmEnterpriseGovernment.setClienttype("1");
        mmEnterpriseGovernmentMapper.updateMmEnterpriseGovernment(mmEnterpriseGovernment);
        return mmContractSigningMapper.updateMmContractSigning(mmContractSigning);
  }

4.查看项目时禁止输入(修改)

  1. 查看时不展示某按钮,再按钮加v-if=“action != ‘view’”
  2. 查看时要求手动输入的字段,只能查看不能修改
    再 标签里加:disabled=“action === ‘view’”

5.校验自动四舍五入保留两位小数

  1. 在需要自动校验的字段里加@change=“xxxx”事件
<el-col :span="8">
      <el-form-item
         label="建筑面积(㎡)"
         prop="mmItemAllVo.mmItem.floorage"
       >
         <el-input
           v-model="mMCustomerItemVo.mmItemAllVo.mmItem.floorage"
           clearable
           placeholder="请输入建筑面积"
           @change="floorageChange"
         />
       </el-form-item>
</el-col>
  1. 方法写.toFixed(2)方法
 //建筑面积保留两位
    floorageChange(val) {
   //赋值(v-modle绑定的)
      this.mMCustomerItemVo.mmItemAllVo.mmItem.floorage = parseFloat(val).toFixed(2);  //将改字段string类型转化成float
    },

6.金额校验默认以四位隔开,切自动四舍五入保留两位小数(只局限于varchar2类型的金额)

1.再工具类里写

 // 格式化金额
export const formatMoney = (num) => {
  if (parseFloat(num).toString() !== "NaN") {
    return parseFloat(num).toFixed(2).toString().split('').reverse().join('').replace(/(\d{3})/g, '$1,').replace(
      /\,$/, '').split('').reverse().join('')
  }
  return ''
}

2.(1)from表单校验金额@change="xxx事件

<el-col :span="8">
    <el-form-item label="转入金额" prop="shiftToMoney">
       <el-input v-model="formBasic.shiftToMoney" placeholder="请输入转入金额"
                 clearable style=" width: '100%'" @change="handleChange"/>
     </el-form-item>
</el-col>
 

(2)列表校验@change="xxx事件
@change=“costAmountChange(scope)”

<el-table-column align="center" label="金额" min-width="15%">
       <template slot-scope="scope">
         <el-form-item
           :prop="'measuresList.' + scope.$index + '.costAmount'"
           :rules="rules.costAmount"
         >
           <el-input
             v-model="scope.row.costAmount"
             placeholder="请输入"
             :disabled="action === 'view'"
             @change="costAmountChange(scope)"
           />
         </el-form-item>
       </template>
 </el-table-column>

3.引入工具类 import {formatMoney} from ‘@/utils/index’
4.(1)form表单校验写change方法,shiftToMoney需要加校验的字段名

 //转入金额
      handleChange(val) {
//赋值(v-modle绑定的值this.formBasic.shiftToMoney)
        this.formBasic.shiftToMoney = formatMoney(
          val.replace(/,/g, "")
        );
      },

(2)列表校验方法

核心代码:
//措施方案-人工-金额
    change绑定值(val) {
      this.form.列表绑定值data[val.$index].字段名 = formatMoney(val.row.字段名.replace(/,/g, ""));
    },
例如:
//措施方案-人工-金额
    costAmountChange(val) {
      this.form.measuresList[val.$index].costAmount = formatMoney(val.row.costAmount.replace(/,/g, ""));
    },

5.图示案例
在这里插入图片描述

2021.04.22-04.26

1.手机号校验

//校验手机号为数字
再el-input标签加
oninput = "value=value.replace(/[^\d]/g,'')"
rules:{
   "字段名"[
       { required: true, message: "请输入监理单位联系人电话" },
          { min: 11, message: "手机号长度不等于11位" },
          { max: 11, message: "长度必须为11位" },
          {
            pattern: /^1[3|4|5|7|8][0-9]\d{8}$/,
            message: "只能输入合法的手机号!",
          },
  ]
 }
例如:
"supervisionUnitContactsTel": [
          { required: true, message: "请输入监理单位联系人电话" },
          { min: 11, message: "手机号长度不等于11位" },
          { max: 11, message: "长度必须为11位" },
          {
            pattern: /^1[3|4|5|7|8][0-9]\d{8}$/,
            message: "只能输入合法的手机号!",
          },
     ],

2.列表必填项校验

需要加检验的列表默认是数组:prop="‘与列表绑定的参数.’ + scope.$index + ‘.字段名’"

核心代码:form.qualityManagementList :rules="rules.technologyContent" :prop="'qualityManagementList.' + scope.$index + '.technologyContent'"
<el-table-column align="center" label="技术创效内容">
         <template slot-scope="scope">
            <el-form-item form.qualityManagementList :rules="rules.technologyContent" :prop="'qualityManagementList.' + scope.$index + '.technologyContent'">
              <el-input
                placeholder="请输入技术创效内容"
                v-model="scope.row.technologyContent"
                autosize
                type="textarea"
                :disabled="action === 'view'"
              />
            </el-form-item>
          </template>
    </el-table-column>

3.比例(率)校验,默认带百分号,且保留两位小数

  1. 需要加校验的字段里面加@change="xxxx"事件
//例如:
// @change="estimateProfitRatioChange"
<el-col :span="8">
       <el-form-item label="预计利润率(%)" prop="estimateProfitRatio">
         <el-input
           v-model="form1.estimateProfitRatio"
           placeholder="请输入预计利润率(%)"
           :disabled="action === 'view'"
           @change="estimateProfitRatioChange"
         />
       </el-form-item>
 </el-col> 
  1. 方法
change事件绑定参数() {
      if (this.form.需要校验的字段名 === "") {
        this.form.字段名 = "0.00%";
      } else {
        let s = parseFloat(this.form.字段名);
        this.form.字段名 = s.toFixed(2) + "%";
      }
    },
   //例如:
 estimateProfitRatioChange() {
      if (this.form1.estimateProfitRatio === "") {
        this.form1.estimateProfitRatio = "0.00%";
      } else {
        let s = parseFloat(this.form1.estimateProfitRatio);
        this.form1.estimateProfitRatio = s.toFixed(2) + "%";
      }
    },

4.校验金额默认保留两位小数(普通校验)

(1)form表单

//核心代码
<el-input-number>
       :min="0"
       :max="1000000000"
       :controls="false"
       :precision="2"
</el-input-number>
//例子:
<el-col :span="8">
            <el-form-item label="合同金额" prop="contractAmount">
              <el-input-number
                class="left_input_number"
                style="width: 100%"
                :min="0"
                :max="1000000000"
                :controls="false"
                :precision="2"
                v-model="form1.contractAmount"
                :disabled="action === 'view'"
              ></el-input-number>
            </el-form-item>
 </el-col>

(2)table表格
//核心代码:

<el-input-number>
		:min="0"
		:max="1000000000"
		:controls="false"
		:precision="2"
</el-input-number>
//例子:
<el-table-column align="center" label="金额" min-width="15%">
      <template slot-scope="scope">
        <el-form-item
          :prop="'machineryList.' + scope.$index + '.costAmount'"
          :rules="rules.costAmount"
        >
          <el-input-number
            class="right_input_number"
            style="width: 100%"
            :min="0"
            :max="1000000000"
            :controls="false"
            :precision="2"
            v-model="scope.row.costAmount"
            :disabled="action === 'view'"
          ></el-input-number>
        </el-form-item>
      </template>
 </el-table-column>

5.手机号校验

核心代码: maxlength="11"
 <el-col :span="8">
            <el-col :span="8">
            <el-form-item label="联系电话" prop="phone">
              <el-input
                v-model="form.phone"
                placeholder="请输入联系电话"
                maxlength="11"
              />
            </el-form-item>
          </el-col>
  </el-col>
//手机号校验
rules:{
 phone: [
          {
            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
            message: "请输入正确的手机号码",
            trigger: "blur",
          },
        ],
}

6.js做按钮隐藏

style="display:none"

7.模糊查询日期格式化 to_char使用

年份:'yyyy '
年月日:'yyyy-mm-dd'
eg:
<if test="recruitmentYear != null  and recruitmentYear != ''"> and TO_char(re.recruitment_year, 'yyyy') like CONCAT(CONCAT('%',#{recruitmentYear}),'%')</if>

8.传值

单个字段传值
① 在父页面自定义一个组件

:子组件接收的参数名=“需要传递的参数”
eg:       :recruitmentYear="recruitmentYear"

② 在父页面将需要传的值赋值
③ 在子组件的props:{ } 里接收参数

props:{ 
    recruitmentYear:{
         type: String,
    },
 } 

④ 子页面需要接收参数的字段页面加

:label="recruitmentYear"
例子: 父页面定义组件
:recruitmentYear="recruitmentYear"
<div v-if="open">
       <el-dialog :visible.sync="open" :title="title"  width="90%" :destroy-on-close="true">
         <edit  :key="time" :action="action" :data="Data" :recruitmentYear="recruitmentYear" @closeView="closeView"></edit>
       </el-dialog>
    </div>

父页面赋值

const recruitmentYear = this.yearFormat(this.rowInfo.recruitmentYear).toString();
 this.recruitmentYear=recruitmentYear;
 /** 汇总按钮操作 */
    handleUpdate() {
      this.time=new Date().getTime();
      const monetizationId = this.rowInfo.recruitmentId;
      const recruitmentYear = this.yearFormat(this.rowInfo.recruitmentYear).toString();
      getPmAnnualMonetization(monetizationId).then(response => {
        this.Data = response.data;
        this.recruitmentYear=recruitmentYear;
        this.action = "update";
        this.title = "安装公司招工计划表";
        this.open = true;
        
      });
    },

子页面:

:label="recruitmentYear"
<el-table-column  :label="recruitmentYear" width="80" align="center"/>
props:{ 
    recruitmentYear:{
         type: String,
    },
 } 

9.做差自动计算金额,金额格式默认保留两位小数,且以千为单位(列表计算)

scope默认数组格式

(1)再被减数字段和减数字段加@input=“xxxx(scope)”
例如:@input="paymentChange(scope)"

<el-table-column
            label="预计目标成本(元)"
            align="right"
            header-align="center"
          >
            <template slot-scope="scope">
              <el-input
                placeholder="导入的模板数据/手动输入、是必输项"
                v-model="scope.row.costAmount"
                :disabled="action === 'view'"
                @change="costAmountChangeds(scope)"
                @input="paymentChange(scope)"
              />
            </template>
          </el-table-column>

(2)绑定@input=“xxxx”事件具体方法

//被减数-减数=差
    xxxx(val) {
      var _this = this;
      var data1 = _this.列表绑定值data[val.$index].被减数字段; 
      var data2 = _this.列表绑定值data[val.$index].减数字段;
      // 减法(去掉金额单位制逗号计算结果)
      var data3 = parseFloat(data1.split(",").join("")) - parseFloat(data2.split(",").join("")).toFixed(2); //保留两位
     //默认格式有单位制逗号隔开
      if (parseFloat(data3).toString() !== "NaN") {
        _this.列表绑定值data[val.$index].最终差值字段 = parseFloat(data3)
          .toFixed(2)
          .toString()
          .split("")
          .reverse()
          .join("")
          .replace(/(\d{3})/g, "$1,")
          .replace(/\,$/, "")
          .split("")
          .reverse()
          .join("");
      }
    },
//例如:
//模板下载-项目预计利润自动计算=合同金额-预计目标成本
    paymentChange(val) {
      var _this = this;
      var data1 = _this.pmCostDetail[val.$index].contractAmount; //合同金额
      var data2 = _this.pmCostDetail[val.$index].costAmount; //预计目标成本
      // 减法
      var data3 =
        parseFloat(data1.split(",").join("")) -
        parseFloat(data2.split(",").join("")).toFixed(2); //保留两位
      if (parseFloat(data3).toString() !== "NaN") {
        _this.pmCostDetail[val.$index].profitAmount = parseFloat(data3)
          .toFixed(2)
          .toString()
          .split("")
          .reverse()
          .join("")
          .replace(/(\d{3})/g, "$1,")
          .replace(/\,$/, "")
          .split("")
          .reverse()
          .join("");
      }
    },

10.根据上面固定列表,带出下面动态新增列表某字段值/上面固定列表修改某字段数组,下面列表随着变化

(1)根据固定列表绑定的data值 再下面列表对应的新增按钮绑定值后加xxx[数组下标].某字段

详细代码参考项目策划-成本目标及实施方案

(2)上面固定列表变动某字段数据,下面列表随着变化
再上面固定列表需要变动的字段加@change(scope.$index, scope.row)事件

<el-table-column label="备注" align="left" header-align="center">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.memo"
                :disabled="action === 'view'"
                autosize
                type="textarea"
                @change="memoChange(scope.$index, scope.row)"
              />
            </template>
          </el-table-column>

方法循环修改赋值

memoChange(index, row) {
      //措施方案-人工列表-备注
      if (index === 0) {
        for (var i = 0; i < this.form.measuresList.length; i++) {
          this.form.measuresList[i].meno = row.memo;
        }
      //措施方案-机械费列表-备注
      } else if (index === 1) {       
        for (var i = 0; i < this.form.machineryList.length; i++) {
          this.form.machineryList[i].meno = row.memo;
        }
      //措施方案-辅材费列表-备注
      } else if (index === 2) {   
        for (var i = 0; i < this.form.auxiliaryList.length; i++) {
          this.form.auxiliaryList[i].meno = row.memo;
        }
        //措施方案-主材费列表-备注
      } else if (index === 3) {
        for (var i = 0; i < this.form.mainList.length; i++) {
          this.form.mainList[i].meno = row.memo;
        }
        //措施方案-设备费列表-备注
      } else if (index === 4) {
        for (var i = 0; i < this.form.equipmentList.length; i++) {
          this.form.equipmentList[i].meno = row.memo;
        }
        //措施方案-措施费列表-备注
      } else if (index === 5) {
        for (var i = 0; i < this.form.measureList.length; i++) {
          this.form.measureList[i].meno = row.memo;
        }
        //措施方案-管理人员工资列表-备注
      } else if (index === 13) {
        for (var i = 0; i < this.form.executiveList.length; i++) {
          this.form.executiveList[i].meno = row.memo;
        }
        //措施方案-项目部管理费用列表-备注
      } else if (index === 14) {
        for (var i = 0; i < this.form.projectList.length; i++) {
          this.form.projectList[i].meno = row.memo;
        }
        //措施方案-总包配合费列表-备注
      } else if (index === 24) {
        for (var i = 0; i < this.form.coordinateList.length; i++) {
          this.form.coordinateList[i].meno = row.memo;
        }
        //措施方案-利润分成列表-备注
      } else if (index === 30) {
        for (var i = 0; i < this.form.profitList.length; i++) {
          this.form.profitList[i].meno = row.memo;
        }
      }

11.乘法计算

若v-model绑定值不是在form里面封装,而是表格scope.row

<el-table-column label="调整系数" width="80" prop="adjustCoefficient">
            <template slot-scope="scope">
                <el-input v-model="scope.row.adjustCoefficient" placeholder="请输入" :disabled="scope.row.companyName == '安装公司全年生产人数合计'? true:false " @input="paymentChanges(scope)"/>
            </template>
</el-table-column>

取做计算的对应值,应该[val.$index].计算需要值

/调整后指标=各分公司计划总人数×调整系数
    paymentChanges(val) {
        var _this = this;
        var data1 = _this.dataList[val.$index].branchHeadcount; //分公司计划总人数
        var data2 = _this.dataList[val.$index].adjustCoefficient; //调整系数
        // 乘法
       _this.dataList[val.$index].adjustTarget =  parseFloat((data1 * data2 ));   //保留两位正则表达式
  },

12.表格数据默认最后一行,禁止输入

核心代码:

:disabled="scope.row.companyName == ‘安装公司全年生产人数合计’? true:false "

<el-table-column label="调整系数" width="80" prop="adjustCoefficient">
            <template slot-scope="scope">
                <el-input v-model="scope.row.adjustCoefficient" placeholder="请输入" :disabled="scope.row.companyName == '安装公司全年生产人数合计'? true:false " @input="paymentChanges(scope)"/>
            </template>
</el-table-column>

图例:
在这里插入图片描述
在这里插入图片描述

13.列表数据默认带出来,拼接文本

<el-table-column label="需求专业" align="center" prop="demand" >
              <template slot-scope="scope">
                {{"需求人数"}}
              </template>
 </el-table-column>

图例:
在这里插入图片描述

14.复选框数据回显(存储字段:subcontractMajor)

  1. 页面
 <el-col :span="15">
          <el-form-item
            label="分包专业"
            prop="subcontractMajors"
          > 
            <el-checkbox-group v-model="form.subcontractMajors" @change="subcontractMajorChange">
              <el-checkbox label="给排水"></el-checkbox>
              <el-checkbox label="通风"></el-checkbox>
              <el-checkbox label="消防"></el-checkbox>
              <el-checkbox label="电气"></el-checkbox>
              <el-checkbox label="保温工"></el-checkbox>
              <el-checkbox label="高压电工"></el-checkbox>
              <el-checkbox label="弱电工"></el-checkbox>
            </el-checkbox-group>
          </el-form-item>
  </el-col>
  1. form里定义
form: {
    subcontractMajors:[], //专业
    subcontractMajor:"",
 }
  1. 复选框数据回显
 this.form.subcontractMajors=this.data.subcontractMajor.split(',');  //修改方法
  1. 修改保存按钮
 this.form.subcontractMajor=this.form.subcontractMajors.join(',');
  1. change方法
methods:{
//专业-复选框数据回显修改
    subcontractMajorChange(){
       this.$forceUpdate();
    },
}

15.列表数据默认带出来,拼接文本需求人数

<el-table-column label="需求专业" align="center" prop="demand" >
              <template slot-scope="scope">
                {{"需求人数"}}
              </template>
 </el-table-column>

在这里插入图片描述

16.单选框radio,选择是,弹出下面表单信息(详情参考劳务分包-分包发票录入是否已抵扣)

方法一:el-radio单选框
  1. @change事件:
<el-col :span="8">
       <el-form-item label="是否已抵扣" prop="deduction">
         <el-radio v-model="form.deduction" label="1" @change="deductionChange"></el-radio>
         <el-radio v-model="form.deduction" label="2" @change="deductionChangeFalse"></el-radio>
       </el-form-item>
 </el-col>
  1. 在需要展示或者隐藏的数据页面绑定

v-show=“form.xxx”

  1. 在form外定义xxx
 xxx: false,
  1. 触发change事件函数
deductionChange(){
      this.xxx = true;
    },
deductionChangeFalse(){
      this.xxx = false;
    },
方法一:el-radio-group组
  1. group组绑定change事件
<el-radio-group v-model="form.deduction" @change="deductionChange" >
       <el-radio :label="1"></el-radio>
        <el-radio :label="2"></el-radio>
  </el-radio-group>
  1. 在需要展示或者隐藏的数据页面绑定

v-show=“form.xxx”

  1. 在form外定义xxx
 xxx: false,
  1. 触发change事件函数
 deductionChange(){
      if(this.form.deduction != 2){
         this.isPass = true;
      } else{
         this.isPass = false;
      }
    },

17.提交按钮的几种形式

  1. 只有编辑按钮,列表数据来源于上级,编辑页有提交按钮(参考劳务分包-招标信息)
    **要求:**保存后表单状态变草稿,点提交状态变已处理
    直接提交,存当前数据,该状态为已处理
//前端处理
<el-button
              type="success"
              icon="el-icon-check"
              size="mini"
              @click="submit"
              >提交</el-button
            >
/** 提交按钮操作 */
    submit() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          this.$confirm("是否确认提交", "警告", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          }).then(() => {
            //提交时-表单状态默认为已处理1
            this.form.formStatus = "1";
            if (this.form.biddingId != null || this.form.biddingId != "") {
              updatePmBiddingInformation(this.form).then((res) => {
                if (res.code === 200) {
                  //保存项目信息
                  this.$notify({
                    title: "成功",
                    message: "提交成功",
                    type: "success",
                  });
                  this.$emit("closeView");
                }
              });
            } else {
              addPmBiddingInformation(this.form).then((res) => {
                if (res.code === 200) {
                  //保存项目信息
                  this.$notify({
                    title: "成功",
                    message: "提交成功",
                    type: "success",
                  });
                  this.$emit("closeView");
                }
              });
            }
          });
        }
//后端新增判断表单状态
if (StringUtils.isEmpty(pmBiddingInformation.getFormStatus())){
            pmBiddingInformation.setFormStatus("0");
        }
  1. 新增按钮和编辑按钮分开(参考检测分包-招标信息)
    **要求,**保存后表单状态变草稿,点提交状态变已处理
    直接一键提交,存当前数据,该状态为已处理
       //前端处理
<el-button
              type="success"
              icon="el-icon-check"
              size="mini"
              @click="submit"
              >提交</el-button
            >
/** 提交按钮操作 */
     submit() {
      this.$refs["form"].validate((valid) => {
        if (true) {
          this.$confirm("是否确认提交", "警告", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          }).then(() => {
            //提交时-表单状态默认为已处理1
            this.form.formStatus = "1";
            if (this.form.orderId == "") {
              this.form.orderId = this.form.orderId1
              addPmTestConstructOrder(this.form).then((res) => {
                if (res.code === 200) {
                  //保存项目信息
                  this.$notify({
                    title: "成功",
                    message: "提交成功",
                    type: "success",
                  });
                  this.$emit("closeView");
                }
              });
            } else {
              updatePmTestConstructOrder(this.form).then((res) => {
                if (res.code === 200) {
                  //保存项目信息
                  this.$notify({
                    title: "成功",
                    message: "提交成功",
                    type: "success",
                  });
                  this.$emit("closeView");
                }
              });
            }
          });
        }
       });
    },
//后端新增判断表单状态
if (StringUtils.isEmpty(pmBiddingInformation.getFormStatus())){
            pmBiddingInformation.setFormStatus("0");
        }
      });
    },

18.操作主-子表(Oracle)

动态新增删除

<1> 前端页面
① 列表绑定值:data="from.xxxList"        :data="form.pmDesignBiddingInfoItemList"
    动态新增按钮绑定值@click="xxx"         @click="handlePaytAdd"
    动态删除按钮绑定值@click="xxx(scope.row)"                           @click="handlePayDelete(scope.row)"
<el-card class="box-card">
        <div slot="header" class="clearfix"><span>付款节点</span></div>
          <el-row :gutter="10"  class="mb8">
            <el-col :span="1.5">
            <el-button
              type="primary"
              icon="el-icon-plus"
              size="mini"
              @click="handlePaytAdd"
              show-summary
              >新增</el-button
            >
          </el-col>
          <el-table v-loading="loading" :data="form.pmDesignBiddingInfoItemList">
             <el-table-column
              label="工作节点"
              align="center"
              prop="workNode"
            >
              <template slot-scope="scope">
                <el-input v-model="scope.row.workNode" size="mini" />
              </template>
            </el-table-column>
            <el-table-column
              label="付款条件"
              align="center"
              prop="paymentClause"
            >
              <template slot-scope="scope">
                <el-input v-model="scope.row.paymentClause" size="mini" />
              </template>
            </el-table-column>
            <el-table-column
              label="占总设计费%"
              align="center"
              prop="totalDesignFee"
            >
              <template slot-scope="scope">
                <el-input v-model="scope.row.totalDesignFee" size="mini" />
              </template>
            </el-table-column>
            <el-table-column
              label="金额"
              align="center"
              prop="money"
            >
              <template slot-scope="scope">
                <el-input v-model="scope.row.money" size="mini" @change="moneyChange(scope)"/>
              </template>
            </el-table-column>
            <el-table-column label="操作" align="center">
            <template slot-scope="scope">
              <el-button
                type="danger"
                icon="el-icon-delete"
                size="mini"
                @click="handlePayDelete(scope.row)"
              >删除</el-button>
            </template>
          </el-table-column>
          </el-table>
     </el-row>
</el-card>
②在form定义列表数据绑定值xxxList
form:{
    xxxList:[],
    //子表列表
      pmDesignBiddingInfoItemList:[],
 }created()方法,修改回显列表赋值
created(){
     this.form.xxxList = this.data.xxxList;
     this.form.pmDesignBiddingInfoItemList = this.data.pmDesignBiddingInfoItemList;
 }
④ 动态新增 ,删除方法
 //列表
    handlePaytAdd() {
      this.form.pmDesignBiddingInfoItemList.push({
          tenderId:"",
          workNode: "",  
          paymentClause: "",  
          totalDesignFee: "",
          money: "",
      });
    },
     handlePayDelete(row) {
      this.form.pmDesignBiddingInfoItemList.splice(this.form.pmDesignBiddingInfoItemList.indexOf(row), 1);
    },
<2> 后端代码
①在主表实体封装子表实体
private List<PmDesignBiddingInfoItem> pmDesignBiddingInfoItemList;
②主表impl
-- 新增
 //循环添加设计分包-招标信息子表数据
       List<PmDesignBiddingInfoItem> list = pmDesignBiddingInfo.getPmDesignBiddingInfoItemList();
           if(list != null){
               for (PmDesignBiddingInfoItem b : list) {
                   b.setBiddingInfoId(pmDesignBiddingInfo.getBiddingInfoId());
                   b.setTenderId(RandomUtil.randomStr(32));
                   pmDesignBiddingInfoItemMapper.insertPmDesignBiddingInfoItem(b);
               }
       }
-- 修改
 //修改设计分包-招标信息子表
        List<PmDesignBiddingInfoItem> list = pmDesignBiddingInfo.getPmDesignBiddingInfoItemList();
        // 先删除
        pmDesignBiddingInfoItemMapper.deletePmDesignBiddingInfoItemById(pmDesignBiddingInfo.getBiddingInfoId());
        if(list != null){
            for (PmDesignBiddingInfoItem b : list) {
                b.setBiddingInfoId(pmDesignBiddingInfo.getBiddingInfoId());
                b.setTenderId(RandomUtil.randomStr(32));
                pmDesignBiddingInfoItemMapper.insertPmDesignBiddingInfoItem(b);
              }
        }

-- 查询
 public PmDesignBiddingInfo selectPmDesignBiddingInfoById(String biddingInfoId)
    {
        PmDesignBiddingInfo pmDesignBiddingInfo = pmDesignBiddingInfoMapper.selectPmDesignBiddingInfoById(biddingInfoId);
        //招标信息子表数据,并赋值给主表对象
        PmDesignBiddingInfoItem pmDesignBiddingInfoItem = new PmDesignBiddingInfoItem();
        pmDesignBiddingInfoItem.setBiddingInfoId(biddingInfoId);
        List<PmDesignBiddingInfoItem> pmDesignBiddingInfoItemList = pmDesignBiddingInfoItemMapper.selectPmDesignBiddingInfoItemList(pmDesignBiddingInfoItem);
        pmDesignBiddingInfo.setPmDesignBiddingInfoItemList(pmDesignBiddingInfoItemList);
        return pmDesignBiddingInfo;
    }
注意:子表的查询,删除的xml,根据主表id操作

19.mysql主从表,增删改查

mybatis针对mysql自增主键怎样配置mapper
添加useGeneratedKeys=“true”,并且keyProperty=“id” 中属性为要自增的主键。

20.富文本编辑器

  1. 前端控制台下载富文本编辑器插件

    npm install vue-quill-editor
    npm install quill
    
  2. 富文本标签

 <!--  富文本标签 -->
  <quill-editor 
        v-model="form.photo" 
        ref="myQuillEditor" 
        :options="editorOption" 
        >
    </quill-editor>
	
  1. 引入富文本编辑器
import { quillEditor } from "vue-quill-editor";
import 'quill/dist/quill.core.css';
import 'quill/dist/quill.snow.css';
import 'quill/dist/quill.bubble.css';

4.引入组件

components:{
   quillEditor
 }
  1. return里配置富文本编辑器
editorOption: {
        placeholder: "请在这里输入文章内容",
        modules:{
          toolbar:[
                  ['bold', 'italic', 'underline', 'strike'],    //加粗,斜体,下划线,删除线
                  ['blockquote', 'code-block'],     //引用,代码块
                  [{ 'header': 1 }, { 'header': 2 }],        // 标题,键值对的形式;1、2表示字体大小
                  [{ 'list': 'ordered'}, { 'list': 'bullet' }],     //列表
                  [{ 'script': 'sub'}, { 'script': 'super' }],   // 上下标
                  [{ 'indent': '-1'}, { 'indent': '+1' }],     // 缩进
                  [{ 'direction': 'rtl' }],             // 文本方向
                  [{ 'size': ['small', false, 'large', 'huge'] }], // 字体大小
                  [{ 'header': [1, 2, 3, 4, 5, 6, false] }],     //几级标题
                  [{ 'color': [] }, { 'background': [] }],     // 字体颜色,字体背景颜色
                  [{ 'font': [] }],     //字体
                  [{ 'align': [] }],    //对齐方式
                  ['clean'],    //清除字体样式
                  ['image','video']    //上传图片、上传视频
                  ]
                }
          },

21.前端自动计算表格列数据

show-summary 该属性自动计算表格列数据,位置再el-table标签

22.模板下载 --------------详情参考项目管理-劳务管理-项目招工计划

下载模板如下图
在这里插入图片描述

  1. 后端:模板下载接口
    service
 /**
     * 模板下载
     */
    void templateExport(HttpServletResponse response, List<PmProjectRecruitment> RecruitmentList);

impl

/**
     * 模板下载
     * @param response
     * @param pmProjectRecruitment
     */
    @Override
    public void templateExport(HttpServletResponse response, List<PmProjectRecruitment> recruitmentList) {
       //第一步,创建一个webbook对象,对应一个excel文件
        XSSFWorkbook wb = new XSSFWorkbook();
        //第二部,再webbook中添加一个sheet,对应Excel文件中的sheet
        XSSFSheet sheet = wb.createSheet("项目招工计划");
        //第三步,再sheet中添加表头第0行,注意老版本poi对excel的行数列数有限制的short
        //第一行
        XSSFRow row1 = sheet.createRow(0);
        //第四步 创建单元格,并设置表头。设置表头居中
        XSSFCellStyle style = wb.createCellStyle();
        style.setLocked(true);
        style.setWrapText(true); //自动换行
        style.setAlignment(HorizontalAlignment.CENTER); //左右居中
        //设置行高
        row1.setHeight((short) 450);
        //设计模板
        //第一列,固定列
        XSSFCell cell0 = row1.createCell(0);
        cell0.setCellStyle(style);
        sheet.setColumnWidth(0, 20 * 256);
        //第二列  ,固定列
        cell0 = row1.createCell (1);
        cell0.setCellStyle(style);
        sheet.setColumnWidth(1, 12 * 600);
        //第三列
        cell0 = row1.createCell (2);
        cell0.setCellValue("模板字段");
        cell0.setCellStyle(style);
        sheet.setColumnWidth(2, 12 * 256);
      //将数据set到excel中(固定列自动带出)
    if(recruitmentList !=null && recruitmentList.size () > 0){
            for (int i = 0; i < recruitmentList.size (); i++) {
                // 创建第二行
                XSSFRow rowI = sheet.createRow (i + 1);
                // 设置行高
                rowI.setHeight ((short) 450);
                XSSFCell cellI = rowI.createCell (0);
                cellI.setCellValue (recruitmentList.get (i).getMonetizationOtypeName ());
                cellI.setCellStyle(style);
                style.setAlignment(HorizontalAlignment.CENTER);
                XSSFCell cells = rowI.createCell (1);
                cells.setCellValue (recruitmentList.get (i).getMonetizationTtypeName ());
                cellI.setCellStyle (style);
            }
        }
   //合并单元格(四个参数分别为:起始行,结束行,起始列,结束列)
        sheet.addMergedRegion(new CellRangeAddress(2, 5, 0, 0));	

        OutputStream output = null;
        try {
            output = response.getOutputStream ();
            response.reset ();
            response.addHeader ("Content-Disposition", "attachment;filename=项目招工计划.xlsx");
            response.setContentType ("application/x-download");
            wb.write (output);
            output.flush ();
            output.close ();
        } catch (Exception e) {
            e.printStackTrace ();
        }
 }

controller

/**
     * 模板下载
     */
    @PostMapping("/templateexport")
    public void templateexport(HttpServletResponse response, @RequestBody List<PmProjectRecruitment> RecruitmentList)
    {
        pmProjectRecruitmentService.templateExport(response,RecruitmentList);
    }
注释:@ResponseBody
作用:@ResponseBody注解用于将Controller的方法返回的对象,通过springmvc提供的HttpMessageConverter接口转换为指定格式的数据如:json,xml等,通过Response响应给客户端。

@RequestBody
作用:@RequestBody注解用于读取http请求的内容(字符串),通过springmvc提供的HttpMessageConverter接口将读到的内容(json数据)转换为java对象并绑定到Controller方法的参数上。
  1. 前端
import axios from "axios";     //引入
import { getToken } from "@/utils/auth";      //引入toke参数
templateDownload(){
     axios({
        method: "post", // 请求方式
        url: process.env.VUE_APP_BASE_API + "/recruitment/recruitment/templateexport", // 请求地址
        headers: {
          Authorization: "Bearer " + getToken(),
        },
        data: this.form.RecruitmentList,   //赋值
        responseType: "blob", // 返回数据类型
      }).then((res) => {
        let blob = new Blob([res.data]);
        var link = document.createElement("a");
        link.href = window.URL.createObjectURL(blob);
        link.download = "项目招工计划.xlsx";
        link.click();
        //释放内存
        window.URL.revokeObjectURL(link.href);
        this.loading = false;
      });
    },

23.新增时,不能重复新增数据

解决方案:
新增时查询是否有相同数据,不需要重复存储
List<PmAnnualMonetization> searchList = pmAnnualMonetizationMapper.selectPmAnnualMonetizationList(pmAnnualMonetization);
                    if (searchList != null && searchList.size()>0){
                        continue;
                    }

24.求和 --------------详情参考项目管理-劳务管理-项目招工计划

(1)分别计算出不同类型的合计

① 多条数据查询组装到一个集合中
List<PmProjectRecruitment> reslut  = new ArrayList<>();
② sql求和
<select id="selectProjectSum" resultMap="PmProjectRecruitmentResult" parameterType="java.lang.String">
        SELECT
            nvl(SUM (MWD_JANUARY),0) AS MWD_JANUARY,
            nvl(SUM (MWD_FEBRUARY),0) AS MWD_FEBRUARY,
            nvl(SUM (MWD_MARCH),0) AS MWD_MARCH,
            nvl(SUM (MWD_APRIL),0) AS MWD_APRIL,
            nvl(SUM (MWD_MAY),0) AS MWD_MAY,
            nvl(SUM (MWD_JUNE),0) AS MWD_JUNE,
            nvl(SUM (MWD_JULY),0) AS MWD_JULY,
            nvl(SUM (MWD_AUGUST),0) AS MWD_AUGUST,
            nvl(SUM (MWD_SEPTEMBER),0) AS MWD_SEPTEMBER,
            nvl(SUM (MWD_OCTOBER),0) AS MWD_OCTOBER,
            nvl(SUM (MWD_NOVEMBER),0) AS MWD_NOVEMBER,
            nvl(SUM (MWD_DECEMBER),0) AS MWD_DECEMBER
        FROM
            pm_am_breakdown
        <where>
            <if test="monetizationOtype != null  and monetizationOtype != ''">
                monetization_otype = #{monetizationOtype}
            </if>
                and monetization_otype is not null
        </where>
    </select>
③ impl
//电器合计,管道合计,通风合计,其他合计
        String[] typeList = new String []{"AT002","AT003","AT004","AT005"};
        for (int i = 0; i < typeList.length; i++) {
            String type = typeList[i];
            //项目招工计划:一级分类的明细
            List<PmProjectRecruitment> list = pmProjectRecruitmentMapper.selectPmProjectRecruitmentById(type);
            reslut.addAll(list);
            //一级分类的求和
            PmProjectRecruitment projectRecruitment = pmProjectRecruitmentMapper.selectProjectSum(type);
            projectRecruitment.setMonetizationOtype(list.get(0).getMonetizationOtype());
            projectRecruitment.setMonetizationOtypeName(list.get(0).getMonetizationOtypeName());
            projectRecruitment.setMonetizationTtypeName(list.get(0).getMonetizationOtypeName()+"合计");
            reslut.add(projectRecruitment);
        }
//全年生产人数合计=电器合计+管道合计+通风合计+其他合计
        PmProjectRecruitment projectRecruitmentSumSum = pmProjectRecruitmentMapper.selectProjectSum(null);
        projectRecruitmentSumSum.setMonetizationOtypeName("全年生产人数合计");
        reslut.add(projectRecruitmentSumSum);
        return reslut;

25.oracle查询sql关系到条件既满足A又满足B时

例如,查询出考勤工时为0和0.5的记录

select   ...
from   .....
where
 工时字段 in"0", "0.5"
select
            pac.attendance_clock_id,
            pac.project_id,
            pac.attendance_date,
            pac.emp_number,
            pac.emp_name,
            pac.id_card,
            pac.attendance_hours
        from PM_ATTENDANCE_CLOCK pac
        <where>
            pac.attendance_hours in('0','0.5')
            <if test="attendanceDate != null  and attendanceDate != ''"> and pac.attendance_date = to_date(#{attendanceDate}, 'YYYY-mm-dd') </if>
        </where>

26. 查询列表计算问题

例如:考勤异常人数-已处理人数=未处理
在这里插入图片描述

  1. 后端实体封装字段:考勤异常人数,已处理,未处理(无需再表里加字段)
  2. impl实现层业务
 for (PmWaitingStateManage wait : pmWaitingStateManages) {
            //考勤异常人数
            //注:stream流根据考勤日期进行过滤,拿到异常总人数
            long count = pmWaitingStateManages.stream().filter(wait1 -> wait1.getAttendanceDate().equals(wait.getAttendanceDate())).count();
            wait.setPeopleCount(count);
            //已处理
            //根据考勤日期查询当前已处理的个数
            long dealCount = pmWaitingStateManageItemMapper.selectCountByDate(wait.getAttendanceDate());
            wait.setDealCount(dealCount);
            //未处理
            long noDealCount = count - dealCount;
            wait.setNoDealCount(noDealCount);
        }
/**
     * 根据考勤日期查询当前日期已处理个数
     */
    int selectCountByDate(String attendanceDate);
<select id="selectCountByDate" parameterType="java.lang.String"  resultType="int">
        SELECT
            COUNT (*)
        FROM
            pm_waiting_state_manage_item pw
        LEFT JOIN PM_ATTENDANCE_CLOCK pa ON PW.attendance_clock_id = PA.attendance_clock_id
        WHERE
            PA.attendance_date = to_date(#{attendanceDate}, 'YYYY-mm-dd hh24:mi:ss')
    </select>

27. 判空,判断某状态为空不做处理

跳出for循环
//状态为空不处理
      if (StringUtils.isEmpty(pmAttendanceClock.getOndutyType())){
           continue;
       }

28. 提交之前校验是否处理完(需先保存后,在提交)

提交的impl业务层方法中写
//校验是否处理完
        //已处理
        long dealCount = pmWaitingStateManageItemMapper.selectCountByDate(pmWaitingStateManage.getAttendanceDate());
        if(dealCount<pmWaitingStateManage.getList().size()){
            long count = pmWaitingStateManage.getList().size()-dealCount;
            return new AjaxResult(500, "存在"+count+"条异常未处理");
        }

29. 多表模板下载(一个excel文件,有多个sheet)

功能实现图
在这里插入图片描述
效果图
在这里插入图片描述
后端代码

service
 /**
     * 月度计划报表-模板下载
     */
    void templateExport(HttpServletResponse response);
    
impl     模板下载方法封装
/**
     *  项目月度计划-模板下载
     * @param response
     * @param pmBusinessMonthlyplanVo
     */
    @Override
    public void templateExport(HttpServletResponse response) {
        //第一步,创建一个webbook对象,对应一个excel文件
        XSSFWorkbook wb = new XSSFWorkbook();
        //1.工程计划费用明细表
        this.setSheet1(wb);
        //2.低成本管理指标计划表
        this.setSheet2(wb);
        //3.人工费计划用工表
        this.setSheet3(wb);
        //4.材料计划限用表
        this.setSheet4(wb);
        //5.计划指标包干费用明细表
        this.setSheet5(wb);

        OutputStream output = null;
        try {
            output = response.getOutputStream ();
            response.reset ();
            response.addHeader ("Content-Disposition", "attachment;filename=项目月度计划表.xlsx");
            response.setContentType ("application/x-download");
            wb.write (output);
            output.flush ();
            output.close ();
        } catch (Exception e) {
            e.printStackTrace ();
        }
    }
impl    具体的模板分类
 /**
     * 1.工程计划费用明细表
     * @param wb
     * @return
     */
    private XSSFSheet setSheet1(XSSFWorkbook wb){
        //1.工程计划费用明细表
        XSSFSheet sheet = wb.createSheet("工程计划费用明细表");
        XSSFRow row1 = sheet.createRow(0);
        XSSFCellStyle style = wb.createCellStyle();
        style.setLocked(true);
        style.setWrapText(true); //自动换行
        style.setAlignment(HorizontalAlignment.CENTER); //左右居中
        style.setVerticalAlignment(VerticalAlignment.CENTER); //垂直居中
        row1.setHeight((short) 500);

        XSSFCell cell0 = row1.createCell(0);
        cell0 = row1.createCell (0);
        cell0.setCellValue("序号");
        cell0.setCellStyle(style);
        sheet.setColumnWidth(0, 20 * 256);

        cell0 = row1.createCell (1);
        cell0.setCellValue("费用名称");
        cell0.setCellStyle(style);
        sheet.setColumnWidth(1, 20 * 256);

        cell0 = row1.createCell (2);
        cell0.setCellValue("计算程序");
        cell0.setCellStyle(style);
        sheet.setColumnWidth(2, 20 * 256);

        cell0 = row1.createCell (3);
        cell0.setCellValue("金额(元)");
        cell0.setCellStyle(style);
        sheet.setColumnWidth(3, 20 * 256);

        cell0 = row1.createCell (4);
        cell0.setCellValue("总量占比(%)");
        cell0.setCellStyle(style);
        sheet.setColumnWidth(4, 20 * 256);

        cell0 = row1.createCell (5);
        cell0.setCellValue("经济指标(元/m2)");
        cell0.setCellStyle(style);
        sheet.setColumnWidth(5, 20 * 256);

        cell0 = row1.createCell (6);
        cell0.setCellValue("备注");
        cell0.setCellStyle(style);
        sheet.setColumnWidth(6, 20 * 256);

        return sheet;
    }

    /**
     * 2.低成本管理指标计划表
     * @param wb
     * @return
     */
    private XSSFSheet setSheet2(XSSFWorkbook wb){
        //2.低成本管理指标计划表
        XSSFSheet sheet = wb.createSheet("低成本管理指标计划表");
        XSSFRow row1 = sheet.createRow(0);
        XSSFCellStyle style = wb.createCellStyle();
        style.setLocked(true);
        style.setWrapText(true); //自动换行
        style.setAlignment(HorizontalAlignment.CENTER); //左右居中
        style.setVerticalAlignment(VerticalAlignment.CENTER); //垂直居中
        row1.setHeight((short) 450);

        XSSFCell cell2 = row1.createCell(0);
        cell2 = row1.createCell (0);
        cell2.setCellValue("分类");
        cell2.setCellStyle(style);
        sheet.setColumnWidth(0, 5000);

        cell2 = row1.createCell (1);
        cell2.setCellValue("序号");
        cell2.setCellStyle(style);
        sheet.setColumnWidth(1, 5000);

        cell2 = row1.createCell (2);
        cell2.setCellValue("费用名称");
        cell2.setCellStyle(style);
        sheet.setColumnWidth(2, 5000);

        cell2 = row1.createCell (3);
        cell2.setCellValue("预算数(元)");
        cell2.setCellStyle(style);
        sheet.setColumnWidth(3, 5000);

        cell2 = row1.createCell (4);
        cell2.setCellValue("计划制造数(元)");
        cell2.setCellStyle(style);
        sheet.setColumnWidth(4, 5000);

        cell2 = row1.createCell (5);
        cell2.setCellValue("预计实际成本(元)");
        cell2.setCellStyle(style);
        sheet.setColumnWidth(5, 5000);

        cell2 = row1.createCell (6);
        cell2.setCellValue("计划降本");
        cell2.setCellStyle(style);
        sheet.setColumnWidth(6, 5000);

        cell2 = row1.createCell (8);
        cell2.setCellValue("预计实际降本");
        cell2.setCellStyle(style);
        sheet.setColumnWidth(8, 5000);

        //第二行
        XSSFRow row = sheet.createRow(1);
        // 设置行高
        row.setHeight((short) 450);
        XSSFCell cell = row.createCell(6);
        cell.setCellValue("金额");
        cell.setCellStyle(style);
        sheet.setColumnWidth(6, 5000);

        cell = row.createCell(7);
        cell.setCellValue("降低率");
        cell.setCellStyle(style);
        sheet.setColumnWidth(7, 5000);

        cell = row.createCell(8);
        cell.setCellValue("金额");
        cell.setCellStyle(style);
        sheet.setColumnWidth(8, 5000);

        cell = row.createCell(9);
        cell.setCellValue("降低率");
        cell.setCellStyle(style);
        sheet.setColumnWidth(9, 5000);
        
        //合并单元格(四个参数分别为:起始行,结束行,起始列,结束列,默认从0开始)
        sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 0)); //合并单元格
        sheet.addMergedRegion(new CellRangeAddress(0, 1, 1, 1));
        sheet.addMergedRegion(new CellRangeAddress(0, 1, 2, 2));
        sheet.addMergedRegion(new CellRangeAddress(0, 1, 3, 3));
        sheet.addMergedRegion(new CellRangeAddress(0, 1, 4, 4));
        sheet.addMergedRegion(new CellRangeAddress(0, 1, 5, 5));
        sheet.addMergedRegion(new CellRangeAddress(0, 0, 6, 7));
        sheet.addMergedRegion(new CellRangeAddress(0, 0, 8, 9));
        return sheet;
    }
controller
/**
     * 模板下载
     */
    @PostMapping("/templateExport")
    public void templateExport(HttpServletResponse response)
    {
        pmBusinessMonthlyplanService.templateExport(response);
    }

前端代码

<el-button
                type="info"
                icon="el-icon-download"
                size="mini"
                @click="templateDownload"
                v-if="action != 'view'"
                >模板下载</el-button
              >
js
//模板下载
    templateDownload() {
      axios({
        method: "post", // 请求方式
        url:
          process.env.VUE_APP_BASE_API +
          "/BusinessMonthlyplan/PmBusinessMonthlyplan/templateExport", // 请求地址
        headers: {
          Authorization: "Bearer " + getToken(),
        },
        responseType: "blob", // 返回数据类型
      }).then((res) => {
        let blob = new Blob([res.data]);
        var link = document.createElement("a");
        link.href = window.URL.createObjectURL(blob);
        link.download = "项目月度计划表.xlsx";
        link.click();
        //释放内存
        window.URL.revokeObjectURL(link.href);
        this.loading = false;
      });
    },

30. 多表模板导入,导入的数据存到对应数据表中,前端页面回显展示

service
/**
     * 模板导入
     */
    int importProjectMonthPlan(MultipartFile file, String monthlyplanId) throws Exception;
impl 导入多表,方法封装
/**
     * 模板导入
     * @param file
     * @return
     * @throws Exception
     */
    @Override
    public int importProjectMonthPlan(MultipartFile file, String monthlyplanId) throws Exception {
        AjaxResult ajaxResult = new AjaxResult();
        try {
            //从excel中读取数据
            XSSFWorkbook xssfWorkbook = new XSSFWorkbook(file.getInputStream());
            //1.工程计划费用明细表
            this.setSheetValue1(xssfWorkbook, monthlyplanId);
            //2.低成本管理指标计划表
            this.setSheetValue2(xssfWorkbook, monthlyplanId);
            //3.人工费计划用工表
            this.setSheetValue3(xssfWorkbook, monthlyplanId);
            //4.材料计划限用表
            this.setSheetValue4(xssfWorkbook, monthlyplanId);
            //5.计划指标包干费用明细表
            this.setSheetValue5(xssfWorkbook, monthlyplanId);

        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
        return 1;
    }
impl  具体多表分类导入操作
/**
     * 1.工程计划费用明细表
     * @param xssfWorkbook
     */
    private void setSheetValue1(XSSFWorkbook xssfWorkbook, String monthlyplanId){
        XSSFSheet sheet = xssfWorkbook.getSheetAt(0);
        //判断sheet名称是否对应的名称
        if(!sheet.getSheetName().equals("工程计划费用明细表")){
            return;
        } else {
            //清除数据
            pmPorjectPlanCostDetailMapper.deleteByMonthlyplanId(monthlyplanId);
            //循环存入数据
            for(int i = 1; i<=sheet.getLastRowNum(); i++){
                XSSFRow row = sheet.getRow (i);
                //将导入的数据更新到商务管理-工程计划费用明细对象
                PmPorjectPlanCostDetail entity = new PmPorjectPlanCostDetail();
                entity.setMonthlyplanId(monthlyplanId);
                entity.setCreateTime(DateUtils.getNowDate());
                entity.setPorjectPlanCostDetailId(IdUtils.randomUUID());
                entity.setSerialNumber ((row.getCell (0).toString())); //序号
                entity.setCostName ((row.getCell (1).toString())); //费用名称
                entity.setCountProcedure ((row.getCell (2).toString())); //计算程序
                entity.setPorjectPlanMonety ((row.getCell (3).toString())); //金额(元)
                entity.setGrossProportion ((row.getCell (4).toString())); //总量占比(%)
                entity.setEconomicIndicators ((row.getCell (5).toString())); //经济指标(元/m2)
                entity.setRemark ((row.getCell (6).toString())); //备注
                pmPorjectPlanCostDetailMapper.insertPmPorjectPlanCostDetail(entity);
            }
        }
    }

    /**
     * 2.低成本管理指标计划表
     * @param xssfWorkbook
     */
    private void setSheetValue2(XSSFWorkbook xssfWorkbook, String monthlyplanId){
        XSSFSheet sheet = xssfWorkbook.getSheetAt(1);
        //判断sheet名称是否对应的名称
        if(!sheet.getSheetName().equals("低成本管理指标计划表")){
            return;
        } else {
            //清除数据
            pmSeventeenTargetProfitMapper.deleteByMonthlyplanId(monthlyplanId);
            //循环存入数据
            for(int i = 2; i<=sheet.getLastRowNum(); i++){
                XSSFRow row = sheet.getRow (i);
                //将导入的数据更新低成本管理指标计划表对象
                PmSeventeenTargetProfit entity = new PmSeventeenTargetProfit();
                entity.setMonthlyplanId(monthlyplanId);
                entity.setCreateTime(DateUtils.getNowDate());
                entity.setSeventeenTargetProfitId(IdUtils.randomUUID());
                entity.setClassify((row.getCell (0).toString())); //分类
                entity.setSerialNumber ((row.getCell (1).toString())); //序号
                entity.setCostName ((row.getCell (2).toString())); //费用名称
                entity.setBudgetLevel ((row.getCell (3).toString())); //预算数(元)
                entity.setPlanMakeNum ((row.getCell (4).toString())); //计划制造数(元)
                entity.setPredictPracticalCost ((row.getCell (5).toString())); //预计实际成本(元)
                entity.setPlanReduceCostMoney ((row.getCell (6).toString())); //计划降本-金额
                entity.setPlanReduceCostLowerrate ((row.getCell (7).toString())); //计划降本-降低率
                entity.setPracticalReduceCostMoney ((row.getCell (8).toString())); //预计实际降本-金额
                entity.setPracticalReduceCostLowerrat ((row.getCell (9).toString())); //预计实际降本-降低率
                pmSeventeenTargetProfitMapper.insertPmSeventeenTargetProfit(entity);
            }
        }
    }
controller
/**
     * 模板导入
     */
    @PostMapping("/importProjectMonthPlan")
    public AjaxResult importProjectMonthPlan(MultipartFile file , String monthlyplanId) throws Exception
    {
        return toAjax(pmBusinessMonthlyplanService.importProjectMonthPlan(file, monthlyplanId));
      }

前端代码

<el-col :span="1.5" style="margin-left: -20px">
            <el-upload
              class="upload-demo"
              v-if="!(action == 'view')"
              ref="upload"
              :action="url"
              :auto-upload="true"
              :data="form"
              :headers="myHeaders"
              :show-file-list="false"
              :on-success="importTemplate"
            >
              <el-button
                size="mini"
                type="success"
                plain
                icon="el-icon-folder-add"
                >导入</el-button
              >
            </el-upload>
          </el-col>
 
return 里写
//项目月度计划报表导入
      myHeaders: {
        Authorization: "Bearer " + getToken(),
      },
      //项目月度计划报表导入
      url:
        process.env.VUE_APP_BASE_API +
        "/BusinessMonthlyplan/PmBusinessMonthlyplan/importProjectMonthPlan", // 请求地址

form里定义需要导入的列表名称 xxxList:[], 修改时回显给相应导入列表赋值

v-loading="loading" 页面对应相关导入表格中加v-loading,  默认false
导入方法
/** 导入项目月度计划的钩子 */
    importTemplate(res, file, fileList) {
      if (res.code == 500) {
        this.$message({
          message: "有一项为空,请确保都填写完成!",
          type: "warning",
        });
      } else {
        this.$notify.success({
          title: "成功",
          message: "导入成功",
        });
      }
      this.loading = true;
      //导入成功对应列表数据查询回显
      getPmBusinessMonthlyplanList(this.form.monthlyplanId).then((res) => {
          this.form.pmPorjectPlanCostDetailList = res.pmPorjectPlanCostDetailList; //工程计划费用明细表
          this.form.pmSeventeenTargetProfitList = res.pmSeventeenTargetProfitList; //低成本管理指标计划表
          this.form.pmLaborCostPlanEmploymentList = res.pmLaborCostPlanEmploymentList; //人工费计划用工表
          this.form.pmMaterialsPlanRestrictList = res.pmMaterialsPlanRestrictList; //工程计划费用明细表
          this.form.pmIndicatorCostDetailsList = res.pmIndicatorCostDetailsList; //工程计划费用明细表
          this.loading = false;
      });
// 查询导入的数据列表
1.封装vo
 //1.工程计划费用明细对象 pm_porject_plan_cost_detail
    private List<PmPorjectPlanCostDetail> pmPorjectPlanCostDetailList;
2.service
/**
     * 查询月度计划报及其六张子表
     *
     * @param monthlyplanId 月度计划报ID
     * @return 月度计划报
     */
    public PmBusinessMonthlyplanVo selectPmBusinessMonthlyplanList(String monthlyplanId);
3.impl
/**
     * 查询月度计划报及其五张子表
     *
     * @param monthlyplanId 月度计划报ID
     * @return 月度计划报
     */
    public PmBusinessMonthlyplanVo selectPmBusinessMonthlyplanList(String monthlyplanId) {

        PmBusinessMonthlyplanVo pmBusinessMonthlyplanVo = new PmBusinessMonthlyplanVo();

        //1.查询工程计划费用明细表
        PmPorjectPlanCostDetail pmPorjectPlanCostDetail = new PmPorjectPlanCostDetail();
        pmPorjectPlanCostDetail.setMonthlyplanId(monthlyplanId);
        List<PmPorjectPlanCostDetail> pmPorjectPlanCostDetailList = pmPorjectPlanCostDetailMapper.selectPmPorjectPlanCostDetailList(pmPorjectPlanCostDetail);

		pmBusinessMonthlyplanVo.setPmPorjectPlanCostDetailList(pmPorjectPlanCostDetailList);
		return pmBusinessMonthlyplanVo;

4.controller
/**
     * 查询月度计划报及其五张子表
     *
     * @param monthlyplanId 月度计划报ID
     * @return 月度计划报
     */
    @PreAuthorize("@ss.hasPermi('BusinessMonthlyplan:PmBusinessMonthlyplan:query')")
    @GetMapping(value = "/list/{monthlyplanId}")
    public PmBusinessMonthlyplanVo selectPmBusinessMonthlyplanList(@PathVariable("monthlyplanId") String monthlyplanId) {
        PmBusinessMonthlyplanVo pmBusinessMonthlyplanVo = pmBusinessMonthlyplanService.selectPmBusinessMonthlyplanList(monthlyplanId);
        return pmBusinessMonthlyplanVo;
    }

js
// 查询月度计划报及其五张子表
export function getPmBusinessMonthlyplanList(monthlyplanId) {
  return request({
    url: '/BusinessMonthlyplan/PmBusinessMonthlyplan/list/' + monthlyplanId,
    method: 'get'
  })
}

31. 编辑页掉复杂列表查询接口,代码格式

/** 修改按钮操作 */
    handleUpdate() {
      this.time=new Date().getTime();
      const monthlyplanId = this.rowInfo.monthlyplanId ;
      getPmBusinessMonthlyplan(monthlyplanId).then(response => {
        this.Data = response.data;
      });
      //复杂查询接口,模板导入多表
      getPmBusinessMonthlyplanList(monthlyplanId).then((res) => {
          this.dataList = res;
          this.action = "update";
          this.title = "项目月度计划报表(修改)";
          this.open = true;
          this.open = true;
      });
    },

32. 选择项目带出项目信息和合同信息,其中合同信息数据有列表存在

1.合同数据和项目信息封装vo

33. 校验同项目,同月度是否唯一(保存之前校验)

在这里插入图片描述

1.mapper
 /**
     *  校验同项目,同月度是否唯一
     */
    int checkProject(@Param("projectId") String projectId,@Param("year") String year,@Param("month") String month,@Param("monthlyplanId")  String monthlyplanId);
2.xml
<select id="checkProject" parameterType="String" resultType="int">
        select count (1) from pm_business_monthlyplan where project_id = #{projectId} and year = #{year} and month = #{month}
        <if test="monthlyplanId != null">and monthlyplan_id != #{monthlyplanId}</if>
    </select>
3. servic
 /**
     *  校验同项目,同月度是否唯一
     */
    int checkProject(String projectId, String year, String month, String monthlyplanId);
4.impl
 /**
     * 校验同项目,同月度是否唯一
     * @param ProjectId
     * @param year
     * @param month
     * @param monthlyplanId
     * @return
     */
    @Override
    public int checkProject(String projectId, String year, String month, String monthlyplanId) {
        return pmBusinessMonthlyplanMapper.checkProject(projectId, year, month, monthlyplanId);
    }
5.controller

//核心代码
int count = pmBusinessMonthlyplanService.checkProject(pmBusinessMonthlyplan.getProjectId(), pmBusinessMonthlyplan.getYear(), pmBusinessMonthlyplan.getMonth(), pmBusinessMonthlyplan.getMonthlyplanId());
        if(count > 0){
            return AjaxResult.error("该月度信息已录入,请重新填写!");
        }
----------------------------------------------------------------------------------
新增
/**
     * 新增月度计划报
     */
    @PreAuthorize("@ss.hasPermi('BusinessMonthlyplan:PmBusinessMonthlyplan:add')")
    @Log(title = "月度计划报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PmBusinessMonthlyplan pmBusinessMonthlyplan)
    {
        int count = pmBusinessMonthlyplanService.checkProject(pmBusinessMonthlyplan.getProjectId(), pmBusinessMonthlyplan.getYear(), pmBusinessMonthlyplan.getMonth(), pmBusinessMonthlyplan.getMonthlyplanId());
        if(count > 0){
            return AjaxResult.error("该月度信息已录入,请重新填写!");
        }
        return toAjax(pmBusinessMonthlyplanService.insertPmBusinessMonthlyplan(pmBusinessMonthlyplan));
    }

/**
     * 修改月度计划报
     */
    @PreAuthorize("@ss.hasPermi('BusinessMonthlyplan:PmBusinessMonthlyplan:edit')")
    @Log(title = "月度计划报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PmBusinessMonthlyplan pmBusinessMonthlyplan)
    {
        int count = pmBusinessMonthlyplanService.checkProject(pmBusinessMonthlyplan.getProjectId(), pmBusinessMonthlyplan.getYear(), pmBusinessMonthlyplan.getMonth(), pmBusinessMonthlyplan.getMonthlyplanId());
        if(count > 0){
            return AjaxResult.error("该月度信息已录入,请重新填写!");
        }
        return toAjax(pmBusinessMonthlyplanService.updatePmBusinessMonthlyplan(pmBusinessMonthlyplan));
    }
前端
保存接口
else if(response.code === 500){
                this.msgError(response.msg)
              }
/** 保存按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.action == "update") {
            updatePmBusinessMonthlyplan(this.form).then((response) => {
              if (response.code === 200) {
                this.msgSuccess("修改成功");
                this.$emit("closeView");
              }
            });
          } else {
            addPmBusinessMonthlyplan(this.form).then((response) => {
              if (response.code === 200) {
                this.msgSuccess("新增成功");
                this.$emit("closeView");
              }else if(response.code === 500){
                this.msgError(response.msg)
              }
            });
          }
        }
      });
    },

34. select选择框,选择类型A隐藏对应的文本框或者列表

例如:选择付款类型-月度付款,隐藏是否到期文本框,同时选择付款类型为-年度付款,将A表数据自动带入到B表中,既A表数据覆盖B表数

1.选择付款类型-月度付款,隐藏是否到期文本框
	付款类型绑定监听change事件  @change="payTypeChange"
	需要隐藏的文本框里定义状态 v-show="this.isPass"

<el-col :span="8">
            <el-form-item label="付款类型" prop="payType">
              <el-select
                v-model="form.payType"
                placeholder="请选择付款类型"
                style="width: 100%"
                clearable
                :disabled="action === 'view'"
                @change="payTypeChange"
              >
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

<el-col :span="8" v-show="this.isPass">
            <el-form-item
              label="是否到期"
              prop="whetherDue"
              style="width: 100%"
            >
              <el-select
                v-model="form.whetherDue"
                placeholder="是否到期"
                clearable
                style="width: 100%"
                :disabled="action === 'view'"
              >
                <el-option
                  v-for="dict in whetherDueOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
       
  1. isPass:默认true isPass: true,
3.绑定监听change事件

//选择付款类型为月度付款
    payTypeChange() {
      if (this.form.payType == "1") {
        this.isPass = false;
      } else if (this.form.payType == "2") {
        this.isPass = true;
      }else if (this.form.payType == "3") {
        this.isPass = true;
        //付款类型为年度付款3 ,将A表数据自动带入到B表中,既A表数据覆盖B表数
        this.form.monthNumberList = this.form.yearCountList;
      }
    },

35. 列表,固定列内容合并

在这里插入图片描述

1.列表里绑定函数 :span-method=“arraySpanMethodSettle”

2.
 //结算数合计-付款比例合并
    arraySpanMethodSettle({ row, column, rowIndex, columnIndex }) {
      // 合并列  默认从0开始
      if (columnIndex === 3 || columnIndex === 5) {
        if (
          rowIndex === 0 ||
          row.固定列表头!= this.form.列表绑定Data数据List[rowIndex - 1].payRatio
        ) {
          let rowspan = 0;
          this.form.列表绑定Data数据List.forEach((element) => {
            if (element.固定列表头=== row.固定列表头) {
              rowspan++;
            }
          });
          return [rowspan, 1];
        } else if (
          rowIndex === 0 ||
          row.固定列表头!=
            this.form.列表绑定Data数据List[rowIndex - 1].固定列表头
        ) {
          let rowspan = 0;
          this.form.列表绑定Data数据List.forEach((element) => {
            if (element.固定列表头=== row.固定列表头) {
              rowspan++;
            }
          });
          return [rowspan, 1];
        } else {
          return [0, 0];
        }
      }
    },
eg:
//结算数合计-付款比例合并
    arraySpanMethodSettle({ row, column, rowIndex, columnIndex }) {
      // 合并列  付款比例相同数据合并
      if (columnIndex === 3 || columnIndex === 5) {
        if (
          rowIndex === 0 ||
          row.payRatio != this.form.settleNumberCountList[rowIndex - 1].payRatio
        ) {
          let rowspan = 0;
          this.form.settleNumberCountList.forEach((element) => {
            if (element.payRatio === row.payRatio) {
              rowspan++;
            }
          });
          return [rowspan, 1];
        } else if (
          rowIndex === 0 ||
          row.paymentProportion !=
            this.form.settleNumberCountList[rowIndex - 1].paymentProportion
        ) {
          let rowspan = 0;
          this.form.settleNumberCountList.forEach((element) => {
            if (element.paymentProportion === row.paymentProportion) {
              rowspan++;
            }
          });
          return [rowspan, 1];
        } else {
          return [0, 0];
        }
      }
    },

36. 列表,固定列合并,该列表数据增删改查在这里插入图片描述

1.列表内容全部融合到一张子表中
子表需要一个表格类型字段,存储不同的类型列表,以便于区分

/**
     * 表格类型
     */
    @Excel(name = "表格类型")
    private String tableType;

2.主表实体封装不同类型列表

 //本月数
    private List<PmProjectOutputDetail> monthNumberList;

    //本年度累计数
    private List<PmProjectOutputDetail> yearCountList;

    //截止开累至本月末累计数合计
    private List<PmProjectOutputDetail> endMonthCountList;

3.service

/**
     * 新增页回显
     * @return
     */
    public PmProjectOutput selectAdd(PmProjectOutput pmProjectOutput);
  1. impl
/**
     * 新增商务管理-项目产值确权
     * 
     * @param pmProjectOutput 商务管理-项目产值确权
     * @return 结果
     */
    @Override
    public int insertPmProjectOutput(PmProjectOutput pmProjectOutput)
    {
        //存储子表数据
        List<PmProjectOutputDetail> monthNumberList = pmProjectOutput.getMonthNumberList();  //本月数列表
        monthNumberList.addAll(pmProjectOutput.getYearCountList());  //本年度累计 
        monthNumberList.addAll(pmProjectOutput.getEndMonthCountList()); 
        monthNumberList.addAll(pmProjectOutput.getSettleNumberCountList());
        monthNumberList.addAll(pmProjectOutput.getPmProjectOutputDetailList());
        for (PmProjectOutputDetail detail : monthNumberList) {
            detail.setProjectOutputDetailId(randomStr(32));
            detail.setProjectOutputId(pmProjectOutput.getProjectOutputId());
            pmProjectOutputDetailMapper.insertPmProjectOutputDetail(detail);
        }
        //存储主表数据
        pmProjectOutput.setCreateTime(DateUtils.getNowDate());
        LoginUser currentUser = SecurityUtils.getLoginUser();
        pmProjectOutput.setCreateBy(currentUser.getUser().getUserId().toString());
        return pmProjectOutputMapper.insertPmProjectOutput(pmProjectOutput);
    }
/**
     * 修改商务管理-项目产值确权
     * 
     * @param pmProjectOutput 商务管理-项目产值确权
     * @return 结果
     */
    @Override
    public int updatePmProjectOutput(PmProjectOutput pmProjectOutput)
    {
        //修改子表数据
        List<PmProjectOutputDetail> monthNumberList = pmProjectOutput.getMonthNumberList();
        monthNumberList.addAll(pmProjectOutput.getYearCountList());
        monthNumberList.addAll(pmProjectOutput.getEndMonthCountList());
        monthNumberList.addAll(pmProjectOutput.getSettleNumberCountList());
        monthNumberList.addAll(pmProjectOutput.getPmProjectOutputDetailList());
        for (PmProjectOutputDetail detail : monthNumberList) {
            pmProjectOutputDetailMapper.updatePmProjectOutputDetail(detail);
        }
        pmProjectOutput.setUpdateTime(DateUtils.getNowDate());
        LoginUser currentUser = SecurityUtils.getLoginUser();
        pmProjectOutput.setUpdateBy(currentUser.getUser().getUserId().toString());
        return pmProjectOutputMapper.updatePmProjectOutput(pmProjectOutput);
    }
/**
     * 查询商务管理-新增页回显
     *  方法封装
     * @return 商务管理-项目产值确权
     */
    @Override
    public PmProjectOutput selectAdd(PmProjectOutput pmProjectOutput)
    {
        PmProjectOutput entity = new PmProjectOutput();
        //1.本月数
        List<PmProjectOutputDetail> monthNumberList = this.getMonthNumberList();
        entity.setMonthNumberList(monthNumberList);
        if(pmProjectOutput.getProjectId() != null && pmProjectOutput.getProjectOutputYear() != null){
            //2.本年度累计数
            entity.setYearCountList(this.getYearCountList(pmProjectOutput));
            //3.截止开累至本月末累计数合计
            entity.setEndMonthCountList(this.getEndMonthCountList(pmProjectOutput));
            //4.结算数合计列表
            entity.setSettleNumberCountList(this.getSettleNumberCountList(pmProjectOutput));
        }
        return entity;
    }

    /**
     * 1.本月数
     * @return
     */
    private List<PmProjectOutputDetail> getMonthNumberList(){
        List<PmProjectOutputDetail> monthNumberList = new ArrayList<>();
        //第一行
        PmProjectOutputDetail detail11 = new PmProjectOutputDetail();
        detail11.setTableType("本月数");
        detail11.setReportType("内部产值");
        detail11.setPayRatio("0");
        detail11.setAccountReceivable("0");
        //施工合同产值
        PmProMonCollectFees mon = new PmProMonCollectFees();
        mon.setCostName("施工合同产值");
        //本月数列表,内部产值-产值,甲供,自动带出,来源项目月度施工产值table1,费用名称对应的本月完成
        List<PmProMonCollectFees> list1 = pmProMonCollectFeesMapper.selectPmProMonCollectFeesList(mon);
        if (list1 != null && list1.size()>0){
            detail11.setOutputValue(list1.get(0).getMonthAccomplish());
        }
        //甲供材料
        //本月数列表,内部产值-产值,甲供,自动带出,来源项目月度施工产值table1,费用名称对应的本月完成
        mon.setCostName("甲供材料");
        List<PmProMonCollectFees> list2 = pmProMonCollectFeesMapper.selectPmProMonCollectFeesList(mon);
        if (list2 != null && list2.size()>0){
            detail11.setPartyMaterial(list2.get(0).getMonthAccomplish());
        }
        monthNumberList.add(detail11);
        //第二行
        PmProjectOutputDetail detail12 = new PmProjectOutputDetail();
        detail12.setTableType("本月数");
        detail12.setReportType("甲方确认产值");
        detail12.setPayRatio("0");
        detail12.setOutputValue("0");
        detail12.setPartyMaterial("0");
        detail12.setAccountReceivable("0");
        monthNumberList.add(detail12);
        return monthNumberList;
    }

    /**
     * 2.本年度累计数
     * @return
     */
    private List<PmProjectOutputDetail> getYearCountList(PmProjectOutput pmProjectOutput){
        List<PmProjectOutputDetail> yearCountList = new ArrayList<>();
        //第一行
        PmProjectOutputDetail detail1  = new PmProjectOutputDetail();
        detail1.setOutputValue("0");
        detail1.setPartyMaterial("0");
        PmProjectOutputDetail entity = pmProjectOutputDetailMapper.sumYear("内部产值", pmProjectOutput.getProjectId(), pmProjectOutput.getProjectOutputYear());
        if (entity != null){
            detail1 = entity;
        }
        detail1.setTableType("本年度累计数");
        detail1.setReportType("内部产值");
        yearCountList.add(detail1);

        //第二行
        PmProjectOutputDetail detail2  = new PmProjectOutputDetail();
        detail2.setOutputValue("0");
        detail2.setPartyMaterial("0");
        PmProjectOutputDetail eneity2 = pmProjectOutputDetailMapper.sumYear("甲方确认产值", pmProjectOutput.getProjectId(), pmProjectOutput.getProjectOutputYear());
        if (eneity2 != null){
            detail2 = eneity2;
        }
        detail2.setTableType("本年度累计数");
        detail2.setReportType("甲方确认产值");
        detail1.setPayRatio(detail2.getPayRatio()); //取第二行甲方确认产值数据
        yearCountList.add(detail2);
        return yearCountList;
    }

    /**
     * 3.截止开累至本月末累计数合计
     * @return
     */
    private List<PmProjectOutputDetail> getEndMonthCountList(PmProjectOutput pmProjectOutput){
        List<PmProjectOutputDetail> endMonthCountList = new ArrayList<>();
        //第一行
        PmProjectOutputDetail detail1  = new PmProjectOutputDetail();
        detail1.setOutputValue("0");
        detail1.setPartyMaterial("0");
        PmProjectOutputDetail entity = pmProjectOutputDetailMapper.sumYear("内部产值", pmProjectOutput.getProjectId(), null);
        if (entity != null){
            detail1 = entity;
        }
        detail1.setTableType("截止开累至本月末累计数合计");
        detail1.setReportType("内部产值");
        endMonthCountList.add(detail1);

        //第二行
        PmProjectOutputDetail detail2  = new PmProjectOutputDetail();
        detail2.setOutputValue("0");
        detail2.setPartyMaterial("0");
        PmProjectOutputDetail eneity2 = pmProjectOutputDetailMapper.sumYear("甲方确认产值", pmProjectOutput.getProjectId(), null);
        if (eneity2 != null){
            detail2 = eneity2;
        }
        detail2.setTableType("截止开累至本月末累计数合计");
        detail2.setReportType("甲方确认产值");
        detail1.setPayRatio(detail2.getPayRatio()); //取第二行甲方确认产值数据
        endMonthCountList.add(detail2);
        return endMonthCountList;
    }

    /**
     * 4.结算数合计列表
     * @return
     */
    private List<PmProjectOutputDetail> getSettleNumberCountList(PmProjectOutput pmProjectOutput){
        List<PmProjectOutputDetail> settleNumberCountList = new ArrayList<>();
        //第一行
        PmProjectOutputDetail detail1  = new PmProjectOutputDetail();
        detail1.setOutputValue("0");
        detail1.setPartyMaterial("0");
        PmProjectOutputDetail entity = pmProjectOutputDetailMapper.sumYear("内部产值", pmProjectOutput.getProjectId(), null);
        if (entity != null){
            detail1 = entity;
        }
        detail1.setTableType("结算数合计列表");
        detail1.setReportType("内部产值");
        detail1.setPayRatio(null);
        settleNumberCountList.add(detail1);

        //第二行
        PmProjectOutputDetail detail2  = new PmProjectOutputDetail();
        detail2.setOutputValue("0");
        detail2.setPartyMaterial("0");
        PmProjectOutputDetail eneity2 = pmProjectOutputDetailMapper.sumYear("甲方确认产值", pmProjectOutput.getProjectId(), null);
        if (eneity2 != null){
            detail2 = eneity2;
        }
        detail2.setTableType("结算数合计列表");
        detail2.setReportType("甲方结算额");
        detail2.setOutputValue("0");
        detail2.setPayRatio(null);
        detail1.setPayRatio(detail2.getPayRatio()); //取第二行甲方确认产值数据
        settleNumberCountList.add(detail2);
        return settleNumberCountList;
    }
  1. 子表mapper
 /**
     * 计算本年度累计数
     */
    PmProjectOutputDetail sumYear(@Param("reportType") String reportType,@Param("projectId") String projectId,@Param("projectOutputYear") String projectOutputYear);
 <!--  本年度累计数 -->
    <select id="sumYear" parameterType="java.lang.String" resultMap="PmProjectOutputDetailResult">
        select
            sum(ppod.OUTPUT_VALUE) as OUTPUT_VALUE,
            sum(ppod.PARTY_MATERIAL) as PARTY_MATERIAL,
            sum(ppod.ACCOUNT_RECEIVABLE) as ACCOUNT_RECEIVABLE,
            ROUND(sum(ppod.ACCOUNT_RECEIVABLE) /(sum(ppod.OUTPUT_VALUE) - sum(ppod.PARTY_MATERIAL)),2)*100 as PAY_RATIO
        from PM_PROJECT_OUTPUT_DETAIL ppod
        left join PM_PROJECT_OUTPUT ppo on ppo.PROJECT_OUTPUT_ID = ppod.PROJECT_OUTPUT_ID
        where
            ppod.REPORT_TYPE = #{reportType}
        and ppo.PROJECT_ID = #{projectId}
        <if test="projectOutputYear != null and projectOutputYear != ''"> and PPO.PROJECT_OUTPUT_YEAR = #{projectOutputYear} </if>
        and ppo.FORM_STATUS = '1'
    </select>

5.controller

/**
     * 获取商务管理-新增页回显
     */
    @PostMapping(value = "/selectAdd")
    public AjaxResult selectAdd(@RequestBody PmProjectOutput pmProjectOutput)
    {
        return AjaxResult.success(pmProjectOutputService.selectAdd(pmProjectOutput));
    }

5,前端代码

//新增查询回显
export function selectAdd(data) {
  return request({
    url: '/PmProjectOutput/PmProjectOutput/selectAdd',
    method: 'post',
    data: data
  })
}
 /** 新增按钮操作 */
    handleAdd() {
      let param = {};
      selectAdd(param).then(response => {
        this.Data = response.data;
        this.time=new Date().getTime();
        this.action = "add";
        this.title = "项目产值确权(添加)";
        this.open = true;
      });

    },

二,编辑页回显查询

service

/**
     * 查询商务管理-项目产值确权
     * 
     * @param projectOutputId 商务管理-项目产值确权ID
     * @return 商务管理-项目产值确权
     */
    public PmProjectOutput selectPmProjectOutputById(String projectOutputId);

impl
/**
     * 查询商务管理-项目产值确权
     * 
     * @param projectOutputId 商务管理-项目产值确权ID
     * @return 商务管理-项目产值确权
     */
    @Override
    public PmProjectOutput selectPmProjectOutputById(String projectOutputId)
    {
        //编辑页回显
        PmProjectOutput pmProjectOutput = pmProjectOutputMapper.selectPmProjectOutputById(projectOutputId);
        //子表数据
        PmProjectOutputDetail detail = new PmProjectOutputDetail();
        detail.setProjectOutputId(projectOutputId);
        List<PmProjectOutputDetail> list = pmProjectOutputDetailMapper.selectPmProjectOutputDetailList(detail);
        List<PmProjectOutputDetail> monthNumberList = new ArrayList<>();
        List<PmProjectOutputDetail> yearCountList = new ArrayList<>();
        List<PmProjectOutputDetail> endMonthCountList = new ArrayList<>();
        List<PmProjectOutputDetail> settleNumberCountList = new ArrayList<>();
        List<PmProjectOutputDetail> pmProjectOutputDetailList = new ArrayList<>();
        for (PmProjectOutputDetail outputDetail : list) {
            String tableType = outputDetail.getTableType();
            if (StringUtils.isEmpty(tableType)){
                continue;
            }
            switch (tableType){
                case "本月数": monthNumberList.add(outputDetail); break;
                case "本年度累计数": yearCountList.add(outputDetail); break;
                case "截止开累至本月末累计数合计": endMonthCountList.add(outputDetail); break;
                case "结算数合计列表": settleNumberCountList.add(outputDetail); break;
                case "割接金额列表": pmProjectOutputDetailList.add(outputDetail); break;
            }
        }
        pmProjectOutput.setMonthNumberList(monthNumberList);
        pmProjectOutput.setYearCountList(yearCountList);
        pmProjectOutput.setEndMonthCountList(endMonthCountList);
        pmProjectOutput.setSettleNumberCountList(settleNumberCountList);
        pmProjectOutput.setPmProjectOutputDetailList(pmProjectOutputDetailList);
        return pmProjectOutput;
    }

controller

 /**
     * 获取商务管理-项目产值确权详细信息
     */
    @PreAuthorize("@ss.hasPermi('PmProjectOutput:PmProjectOutput:query')")
    @GetMapping(value = "/{projectOutputId}")
    public AjaxResult getInfo(@PathVariable("projectOutputId") String projectOutputId)
    {
        return AjaxResult.success(pmProjectOutputService.selectPmProjectOutputById(projectOutputId));
    }

37. 列表复杂查询,内部产值应收款,甲方确认应收款,取本月数列表的应收款

在这里插入图片描述
在这里插入图片描述

1.主表实体封装
//本月数-内部产值应收款
    private String accountReceivable1;
    //本月数-甲方确认应收款
    private String accountReceivable2;
2.子表mapper
/**
     * 查询本月数中的应收款
     * @param reportType
     * @param projectOutputId
     * @return
     */
    String selectByprojectOutputId(@Param("reportType") String reportType,@Param("projectOutputId") String projectOutputId);
<!-- 查询本月数中应收款 -->
    <select id="selectByprojectOutputId" parameterType="java.lang.String" resultType="java.lang.String">
        select ACCOUNT_RECEIVABLE as  from PM_PROJECT_OUTPUT_DETAIL
        where table_type = '本月数'  and REPORT_TYPE = #{reportType} and PROJECT_OUTPUT_ID = #{projectOutputId}
    </select>
3.查询列表impl

/**
     * 查询商务管理-项目产值确权列表
     * 
     * @param pmProjectOutput 商务管理-项目产值确权
     * @return 商务管理-项目产值确权
     */
    @Override
    public List<PmProjectOutput> selectPmProjectOutputList(PmProjectOutput pmProjectOutput)
    {
        LoginUser currentUser = SecurityUtils.getLoginUser();
        pmProjectOutput.setCreateBy(currentUser.getUser().getUserId().toString());
        List<PmProjectOutput> pmProjectOutputs = pmProjectOutputMapper.selectPmProjectOutputList(pmProjectOutput);
        for (PmProjectOutput projectOutput : pmProjectOutputs) {
            projectOutput.setAccountReceivable1(pmProjectOutputDetailMapper.selectByprojectOutputId("内部产值", projectOutput.getProjectOutputId()));
            projectOutput.setAccountReceivable2(pmProjectOutputDetailMapper.selectByprojectOutputId("甲方确认产值", projectOutput.getProjectOutputId()));
        }
        return pmProjectOutputs;
    }

38.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值