vue导出名单

前端代码

    <div style="text-align: right; margin-top: -37px">
          <el-button
            type="primary"
            style="
              background-color: rgb(229, 241, 255);
              color: rgb(34, 118, 218);
            "
            @click="exportShry()"
            >导出名单
          </el-button>
        </div>
exportShry() {
      var KHMC = "电子准驾证审核人员名单";
      let finparams = {
        title: KHMC,
        name: KHMC,
        params: this.listQuery,
        column: [
          [
            {
              field: "PXH",
              title: "序号",
              width: 50,
              halign: "center",
              align: "center",
            },
            {
              field: "CYRXM",
              title: "姓名",
              width: 100,
              halign: "center",
              align: "center",
            },
            {
              field: "XB",
              title: "性别",
              width: 200,
              halign: "center",
              align: "center",
            },
            {
              field: "CSRQ",
              title: "出生年月",
              width: 300,
              halign: "center",
              align: "center",
            },
            {
              field: "GWLX",
              title: "岗位类别",
              width: 300,
              halign: "center",
              align: "center",
            },
            {
              field: "ZJCX",
              title: "准驾车型",
              width: 300,
              halign: "center",
              align: "center",
            },
            {
              field: "SQLX",
              title: "类型",
              width: 200,
              halign: "center",
              align: "center",
            },
            {
              field: "ZMCL",
              title: "证明材料",
              width: 200,
              halign: "center",
              align: "center",
            },
          ],
        ],
      };
      axios({
        method: "post",
        url: "/fxgk/dzzjz/exportShry",
        data: finparams,
        responseType: "blob", //服务器返回的数据为二进制流
      })
        .then((resp) => {
          const { headers } = resp;
          const blob = new Blob([resp.data], {
            type: headers["Content-Type"],
          });
          var url = window.URL.createObjectURL(blob);
          var aLink = document.createElement("a");
          aLink.style.display = "none";
          aLink.href = url;
          aLink.setAttribute("download", finparams.title + ".xls");
          document.body.appendChild(aLink);
          aLink.click();
          document.body.removeChild(aLink); //下载完成移除元素
          window.URL.revokeObjectURL(url); //释放掉blob对象 */
        })
        .catch((error) => {
          this.$notify({
            title: "警告",
            message: "下载出错" + error,
            type: "warning",
            duration: 2000,
            offset: 80,
          });
        });
    },

后端

@PostMapping("/exportShry")
    @ApiOperation(value = "exportShry", notes = "导出审核人员名单")
    public void dzzjzService(@RequestBody Map params, HttpServletRequest request, HttpServletResponse response) {
        dzzjzService.dzzjzService(params, request, response);
    }
public void dzzjzService(Map params, HttpServletRequest request, HttpServletResponse response) {
        JSONArray column = JSONArray.fromObject(params.get("column"));  //获得列名
        Map data = (Map) params.get("params");  //获得查询条件
        List<Object> list = mybatisRepository.selectByParams(this.namespace + "selectDzzjzEx", data);
        for (int i = 0; i < list.size(); i++) {
            Map map = (Map) list.get(i);
            if ("1".equals(map.get("SQLX"))) {
                map.put("SQLX", "新申请");
            } else if ("2".equals(map.get("SQLX"))) {
                map.put("SQLX", "复审");
            }
            if ("0".equals(map.get("XB"))) {
                map.put("XB", "男");
            } else if ("1".equals(map.get("XB"))) {
                map.put("XB", "女");
            }

            map.put("GWLX", map.get("GWLXMC"));

            String zjcxmc = this.getZjcxMc((String) map.get("ZJCX"));
            map.put("ZJCX", zjcxmc);

            map.put("PXH", (i + 1));
        }
        String name = params.get("title") + "";  //文件名

        String title = name; //文件标题

        ExportExcel.Export(name, title, column, list, request, response);
    }
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package cn.com.victorysoft.vseaf.core.repository;

import cn.com.victorysoft.vseaf.core.mybatis.SqlSessionDao;
import cn.com.victorysoft.vseaf.core.mybatis.paging.bean.DataPaging;
import cn.com.victorysoft.vseaf.core.mybatis.paging.bean.Pageable;
import java.util.List;
import javax.annotation.Resource;
import javax.sql.DataSource;
import org.apache.ibatis.session.SqlSession;

public class MybatisRepository {
    private SqlSession sqlSession;
    @Resource
    private SqlSessionDao sqlSessionDao;

    public MybatisRepository() {
    }

    @Resource
    public void setSqlSessionTemplate(SqlSession sqlSessionTemplate) {
        this.sqlSession = sqlSessionTemplate;
    }

    public SqlSession getSqlSession() {
        return this.sqlSession;
    }

    public DataSource getDataSource() {
        return this.sqlSession.getConfiguration().getEnvironment().getDataSource();
    }

    public <T> T selectById(String statement, String id) {
        return this.sqlSessionDao.selectById(statement, id);
    }

    public <T> T selectOne(String statement, Object key) {
        return this.sqlSessionDao.selectOne(statement, key);
    }

    public <E> List<E> selectByParams(String statement, Object parameter) {
        return this.sqlSessionDao.selectList(statement, parameter);
    }

    public <E> DataPaging<E> selectPaging(String statement, Pageable pageable) {
        return this.sqlSessionDao.selectList(statement, pageable.getParameters(), pageable.getOffset(), pageable.getLimit());
    }

    public void insert(String statement, Object params) {
        this.sqlSessionDao.insert(statement, params);
    }

    public void update(String statement, Object params) {
        this.sqlSessionDao.update(statement, params);
    }

    public void delete(String statement, Object params) {
        this.sqlSessionDao.delete(statement, params);
    }
}

SQL

    <select id="selectDzzjzEx" parameterType="java.lang.String" resultType="java.util.Map">
        select <include refid="Base_Column_List"/>,
        n.SHJG,GWBM.MC as gwlxmc
        from FXGK_DZZJZ_SQJL m
        left join FXGK_DZZJZ_SHJL n on  m.SQID= n.SQID
        left join (select B.BM, B.MC from ZXPX_DMB B where B.LBBM = 'DZZJZ_ZJLB') GWBM
        on m.GWLX = GWBM.BM
        where 1=1
        <if test="cyrxm != '' and cyrxm != null">
            and m.cyrxm like '%' || #{cyrxm} || '%'
        </if>
        <if test="zt != '' and zt != null">
            and m.zt = #{zt,jdbcType=VARCHAR}
        </if>
        <if test="zjcx != '' and zjcx != null">
            and m.zjcx = #{zjcx,jdbcType=VARCHAR}
        </if>
        <if test="sqdwid != '' and sqdwid != null">
            and m.sqdwid = #{sqdwid,jdbcType=VARCHAR}
        </if>
        order by m.SQSJ desc
    </select>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值