1.0.45 • Published 5 years ago

wms-common v1.0.45

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

WMS公共组件工程

使用方法

npm i wms-common@latest --save

组件清单

Component
组件名组件标识职责完成情况
表单组件wms-form待开发
表格组件wms-grid已完成
按钮组件wms-button统一处理样式,防抖动待开发
树形组件wms-tree待开发
Service
服务名服务类名职责完成情况
上下文服务ContextService待开发
Http服务HttpService统一处理url、参数、错误处理等已完成
日期服务DateService提供处理日期的工具类方法开发中
缓存服务StorageService处理本地缓存已完成
URL服务UrlService用于正确识别开发环境服务器地址已完成

通用业务解决方案

表单类业务
constructor(
    private $ctx: ContextService
) {}

/**
 * 打开表单
 */
createFormArea() {
    this.$ctx.openDrawer('新增xxx', DemoCreateBusinessComponent).then(() => {
        this.$ctx.feedback('新增xxx', '操作成功', 'success');
    }, () => {});
}
// 表单类
export class DemoCreateBusinessComponent {
  	// 必须有提交和取消的输入属性
    @Input() onSubmit: () => void = () => {};
    @Input() onClose: () => void = () => {};
    
    /**
     * 提交按钮事件
     */
    handleSubmit() {
        // 提交表单后,调用 onSubmit 事件
        this.$service.addXxx().subscribe(result => {
            this.onSubmit();
        });
    }
}
非表格区域需要处理接口异常/等待/成功
orchid-async-container
<wms-async-container [observer]="observer">
    <!-- wmsAsyncSuccessTemplate指令标识接口成功会显示的内容,let-dataItem 为接口返回数据,即result.data -->
    <ng-template wmsAsyncSuccessTemplate recordsKey="list" let-data>
        <!-- 由调用方控制此处显示内容 -->
        <div class="warehouse-card-item" *ngFor="let item of data.list">
            <wms-warehouse-card [dataSource]="item"></wms-warehouse-card>
        </div>
    </ng-template>
</wms-async-container>
// 将可观察对象传入 wms-async-container 组件
this.observer = this.$service.queryWarehouseList(params);
处理成功/警告/错误等反馈信息
constructor(
    private $ctx: ContextService
) {}

handleOk() {
    // 在提交表单成功后等业务场景,
    this.$ctx.feedback('message-title', 'message-desc', 'success');
}
开发环境请求跨域问题

方案a,通过environment配置 httpUrl。然后通过chrome浏览器设置。

export const environment = {
  	production: false,
    httpUrl: 'http://localhost:8099'
};
// 谷歌解决跨域配置
右键谷歌浏览器 在目标中追加 --disable-web-security --user-data-dir=d:/myChromeDevUserData

方案b,通过angular代理。在根目录下创建proxy.conf.json。在package.json的script中新增命令

// proxy.conf.json
{
    "/api": {
        "target":"http://localhost:8099", // 指向nginx代理地址
        "secure":false,
        "changeOrigin":true,
        "pathRewrite":{
            "^/api":""
        }
    }
}
// package.json
{
	"scripts": {
		"start": "ng serve --port 4100",
		"start:proxy": "ng serve --port 4100 --proxy-config proxy.conf.json"
	}
}
1.0.45

5 years ago

1.0.44

5 years ago

1.0.43

5 years ago

1.0.42

5 years ago

1.0.41

5 years ago

1.0.40

5 years ago

1.0.38

5 years ago

1.0.37

5 years ago

1.0.36

5 years ago

1.0.35

5 years ago

1.0.34

5 years ago

1.0.33

5 years ago

1.0.32

5 years ago

1.0.31

5 years ago

1.0.30

5 years ago

1.0.29

5 years ago

1.0.28

5 years ago

1.0.27

5 years ago

1.0.26

5 years ago

1.0.25

5 years ago

1.0.24

5 years ago

1.0.23

5 years ago

1.0.22

5 years ago

1.0.21

5 years ago

1.0.20

5 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago