ng-widget

npm install ng-widget

Usage no npm install needed!

<script type="module">
  import ngWidget from 'https://cdn.skypack.dev/ng-widget';
</script>

README

ng-widget

安装(依赖zorro, delon)

npm install ng-widget 

juhe-widget-search 搜索模块

ts

  searchOption = [
    {
      key: 'movieCode',
      name: '影片名称',
      type: 'movie',
    },
    {
      key: 'frameType',
      name: '图像制式',
      type: 'select-multiple',
      options: options.frame_type
    },
    {
      key: 'imageType',
      name: '画面类型',
      type: 'select-multiple',
      options: options.image_type
    },
    {
      key: 'ticketTime',
      name: '票房日期范围',
      type: 'date-range',
      default: [
        new Date(new Date().setDate(1)),
        new Date()
      ],
    },
    {
      key: 'zone',
      name: '院线所属分区',
      type: 'select',
      options: [
        {
          label: '全国', value: 0,
        },
        {
          label: '甲区', value: 1,
        },
        {
          label: '乙区', value: 2,
        }
      ]
    },
    {
      key: 'chainId',
      name: '院线',
      type: 'select',
      options: options.chains,
    },
  ];
  searchData: any = {};

  search(data?): void {
    this.searchData = data || this.searchData;
    if (this.searchData.ticketTime || this.searchData.pid) {
      const formatData = {
        pclass: this.searchData.pclass,
        pid: this.searchData.pid,
        ticketStartTime: undefined,
        ticketEndTime: undefined,
        movieCode: this.searchData.movieCode,
      };
      if (this.searchData.ticketTime) {
        formatData.ticketStartTime = this.searchData.ticketTime[0] && this.datePipe.transform(this.searchData.ticketTime[0], 'yyyy-MM-dd');
        formatData.ticketEndTime = this.searchData.ticketTime[1] && this.datePipe.transform(this.searchData.ticketTime[1], 'yyyy-MM-dd');
      }
      this.loading = true;
      // 模拟数据
      this.http.post('**', { ...formatData, page: this.pageIndex, pagesize: this.pageSize }).subscribe((res: any) => {
        this.loading = false;
        this.listOfData = res.result.list;
        this.listOfData.forEach((item, index) => {
          item.index = (this.pageIndex - 1) * this.pageSize + index + 1;
        });

        this.pageIndex = res.result.pageNum;
        // this.pageSize = res.result.pageSize;
      });
    }
  }

html

<juhe-widget-search [option]="searchOption" (search)="search($event)"></juhe-widget-search>

juhe-widget-div-time 选择时间组件

<juhe-widget-div-time [(ngModel)]="endTime"></juhe-widget-div-time>

juhe-widget-data-table 数据表格

<juhe-widget-data-table [(loading)]="dataLoading" [options]="dataOption" (headerChange)="onHeaderChange($event)" [docExplain]="docExplain"> </juhe-widget-data-table>

引入NgWidgetService, 添加girdOptions

widgetService.addOptions(GirdItem[])

dataOption = {
 nodes: {
  value: 'new_movie_data',
  label: '基础信息',
  children: [
     {
       value: 'title',
       checked: true,
     }
   ]
 },
 data: [], // 具体的数据 [{title: '',...}]
};
docExplain: string; // 文档说明, 一般是搜索条件组的

juhe-widget-input-list input列表

<juhe-widget-input-list formControlName="used_names"></juhe-widget-input-list>

juhe-widget-upload-single 单文件自定义上传

<juhe-widget-upload-single formControlName="oa_reply" catalog="uptest" url="/ucs/upload"></juhe-widget-upload-single>

juhe-widget-fayered-form 层级选择器

<juhe-widget-fayered-form [form]="form" [formStyle]="formStyle" [formData]="formData" [headerinfo]="headerinfo"
    (search)="search($event)"></juhe-widget-fayered-form>
  /**
   * 表单
   */
  @Input() form: FormItem[] = [];
  @Input() formStyle: 'radio_button_q' | 'radio_button' | 'radio_q' | 'radio' | 'select_q' | 'select' | '' = '';
  @Input() showTitle = true;
  @Input() headerinfo: any = {};
  /**
   * 可以传如默认值
   */
  @Input() formData = {};
  /**
   * 搜索回调
   */
  @Output() search: EventEmitter<object> = new EventEmitter<object>();
  /**
   * 标题样式
   */
  @Input() titleStyle = {
    0: {
      fontWeight: 500,
      fontSize: '14px'
    },
    1: {
      fontWeight: 500,
      fontSize: '14px'
    },
    2: {
      fontWeight: 500,
      fontSize: '14px'
    }
  }
  /**
   * 子标签样式
   */
  @Input() itemStyle = {
    0: {},
    1: {},
    2: {}
  }

  /**
   * 标签‘全部’的样式
   */
  @Input() itemQStyle = {
    0: {
      width: '100px'
    },
    1: {
      width: '100px'
    },
    2: {
      width: '100px'
    }
  }

  /**
   * 是否可以搜索
   */
  @Input() formSearch = {
    0: false,
    1: false,
  }

NgWidget

This library was generated with Angular CLI version 10.2.0.

Code scaffolding

Run ng generate component component-name --project ng-widget to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module --project ng-widget.

Note: Don't forget to add --project ng-widget or else it will be added to the default project in your angular.json file.

Build

Run ng build ng-widget to build the project. The build artifacts will be stored in the dist/ directory.

Publishing

After building your library with ng build ng-widget, go to the dist folder cd dist/ng-widget and run npm publish.

Running unit tests

Run ng test ng-widget to execute the unit tests via Karma.

Further help

To get more help on the Angular CLI use ng help or go check out the Angular CLI Overview and Command Reference page.