1.0.201901260943 • Published 5 years ago

@feidao-works/webtest-web v1.0.201901260943

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

开发步骤

准备

环境

Node.js安装

项目

下载依赖包

yarn

页面开发

运行命令

npm t

服务依赖

如xxx是生成验证码原子操作依赖的,需要添加到项目中,方法为:

  1. 安装依赖

    cnpm i xxx -D
  2. 项目依赖package-service.json添加

"dependencies": {
	"xxx": "*"
}

项目发布

一键发布

./publish.sh

第三方依赖

导出pdf

  • 参数
    • orientation pdf版式('landscape': 横版,'portrait': 竖版;默认是竖版)
    • attachment pdf文件名称(完整文件名称,例如:ceshi.pdf)
import render from '@feidao-factory/atom/nodejs/render/render';
// 在页面上显示pdf文件内容,则不能传入参数attachment

// 要展示的pdf为横版
const url = 'http://192.168.40.196/flippedclass/print.pdf?orientation=landscape';

// 竖版
const url = 'http://192.168.40.196/flippedclass/print.pdf?orientation=portrait';
const url = 'http://192.168.40.196/flippedclass/print.pdf';

// 直接对pdf文件进行下载,需传入参数attachment
const url = 'http://192.168.40.196/flippedclass/print.pdf?attachment=ceshi.pdf';

// 渲染
render(fd.data.node, url, '<a href={{=it}}>docx</a>', 'p01');
  • 名称

    • jsreport-phantom-pdf
    • jsreport-core
    • inline-source
  • 安装

yarn add jsreport-phantom-pdf inline-source jsreport-core

导出xlsx

  • 参数
    • attachment excel文件名称(完整文件名称,例如:ceshi.xlsx)
import render from '@feidao-factory/atom/nodejs/render/render';
// 指定下载文件名称
const url = 'http://192.168.40.196/flippedclass/print.xlsx?attachment=ceshi.xlsx';

// 文件名称无需制定,下载为本页面的名陈'print.xlsx'
const url = 'http://192.168.40.196/flippedclass/print.xlsx';

// 渲染
render(fd.data.node, url, '<a href={{=it}}>docx</a>', 'p01');
  • 名称

    • jsreport-html-to-xlsx
    • jsreport-xlsx
    • inline-source
    • jsreport-core
  • 安装

yarn add jsreport-html-to-xlsx jsreport-xlsx inline-source jsreport-core

导出docx

  • 参数
    • attachment docx文件名称(完整文件名称,例如:ceshi.docx)
import render from '@feidao-factory/atom/nodejs/render/render';
// 指定下载文件名称
const url = 'http://192.168.40.196/flippedclass/print.docx?attachment=ceshi.docx';

// 文件名称无需制定,下载为本页面的名陈'print.docx'
const url = 'http://192.168.40.196/flippedclass/print.docx';

// 渲染
render(fd.data.node, url, '<a href={{=it}}>docx</a>', 'p01');
  • 名称

    • inline-source
    • jsreport-core
    • jsreport-html-embedded-in-docx
  • 安装

yarn add jsreport-html-embedded-in-docx inline-source jsreport-core

服务导出excel

  • 暂时使用的第三方库为exceljs

  • 服务完成后本地测试需配置

    • 配置的文件为:feidao-server.json
{
	"URL": "@访问地址@",
	"METHOD": "get",
	"SERVICE": "dataservice.nodejs",
	"DATA": {
		"modelid": "custom::js_@文件路径+文件名@"
	}
}
  • 注意,配置访问地址不能和文件feidao-server.json中已有的地址重复
  • 配置之后,重新启动服务,本地测试路径为:http://127.0.0.1:8889/@访问地址@
  • 打包之后请求的地址为:'./@访问地址@'
yarn add exceljs

服务导出doc

  • 暂时使用的第三方库为docx

  • 服务完成后本地测试需配置

    • 配置的文件为:feidao-server.json
{
	"URL": "@访问地址@",
	"METHOD": "get",
	"SERVICE": "dataservice.nodejs",
	"DATA": {
		"modelid": "custom::js_@文件路径+文件名@"
	}
}
  • 注意,配置访问地址不能和文件feidao-server.json中已有的地址重复
  • 配置之后,重新启动服务,本地测试路径为:http://127.0.0.1:8889/@访问地址@
  • 打包之后请求的地址为:'./@访问地址@'
yarn add docx