国家医疗器械不良事件监测信息系统用户操作手册_v20181220.docx

    1. <div class="outer">
    2. <div class="table-header">
    3. <div class="select1">
    4. 线别:
    5. <nz-select
    6. nzShowSearch
    7. nzAllowClear
    8. nzPlaceHolder="搜索线别"
    9. [(ngModel)]="selectedLine"
    10. style="width: 100%;"
    11. >
    12. <nz-option *ngFor="let option of lines" [nzLabel]="option" [nzValue]="option" ></nz-option>
    13. </nz-select>
    14. </div>
    15. <div class="select2">
    16. 机种:
    17. <nz-select nzShowSearch nzAllowClear nzPlaceHolder="搜索机种" [(ngModel)]="selectedModel" style="width: 100%;">
    18. <nz-option *ngFor="let option of models" [nzLabel]="option" [nzValue]="option"></nz-option>
    19. </nz-select>
    20. </div>
    21. <div class="headerButton">
    22. <button nz-button nzType="primary" (click)="searchLineAndModel()" style="margin-left: 5%;">
    23. <i nz-icon nzType="search"></i>
    24. 搜 索
    25. </button>
    26. <button nz-button nzType="primary" (click)="addData()" style="margin-left: 5%;">
    27. <i nz-icon nzType="plus-square" nzTheme="outline"></i>
    28. 添 加
    29. </button>
    30. <button nz-button nzType="primary" (click)="deleteSelect()" style="margin-left: 5%;">
    31. <i nz-icon nzType="delete" nzTheme="outline"></i>
    32. 删除所选数据
    33. </button>
    34. <button nz-button nzType="primary" (click)="showModal()" style="margin-left: 5%;">
    35. <i nz-icon nzType="upload" nzTheme="outline"></i>
    36. 上 传
    37. </button>
    38. </div>
    39. </div>
    40. <div class="tebal-content">
    41. <nz-table
    42. #rowSelectionTable
    43. [nzData]="listOfData"
    44. [nzScroll]="{ y: '480px' }"
    45. (nzCurrentPageDataChange)="onCurrentPageDataChange($event)"
    46. nzShowSizeChanger
    47. >
    48. <thead>
    49. <tr>
    50. <!-- <th
    51. [nzSelections]="listOfSelection"
    52. [(nzChecked)]="checked"
    53. [nzIndeterminate]="indeterminate"
    54. (nzCheckedChange)="onAllChecked($event)"
    55. ></th> -->
    56. <th
    57. [(nzChecked)]="checked"
    58. [nzIndeterminate]="indeterminate"
    59. (nzCheckedChange)="onAllChecked($event)"
    60. ></th>
    61. <th>厂区</th>
    62. <th>厂别</th>
    63. <th>线种</th>
    64. <th>机种</th>
    65. <th>站别</th>
    66. <th>操作</th>
    67. </tr>
    68. </thead>
    69. <tbody>
    70. <tr *ngFor="let data of rowSelectionTable.data">
    71. <!-- <td [nzChecked]="setOfCheckedId.has(data.id)" (nzCheckedChange)="onItemChecked(data.id, $event)"></td> -->
    72. <td
    73. [nzChecked]="setOfCheckedId.has(data.station_id)"
    74. [nzIndeterminate]="indeterminate"
    75. (nzCheckedChange)="onItemChecked(data.station_id, $event)"
    76. ></td>
    77. <td>{{ data.site }}</td>
    78. <td>{{ data.plant }}</td>
    79. <td>{{ data.line }}</td>
    80. <td>{{ data.model }}</td>
    81. <td>{{ data.station }}</td>
    82. <td class="cell">
    83. <em
    84. nz-icon
    85. nzType="more"
    86. nzTheme="outline"
    87. nz-popover
    88. nzPopoverTrigger="hover"
    89. (nzPopoverVisibleChange)="change($event)"
    90. [nzPopoverContent]="contentTemplate"
    91. nzPopoverPlacement="left"
    92. ></em>
    93. <!-- 操作 -->
    94. <ng-template #contentTemplate>
    95. <a class="selectsadd" (click)="deleteModal(data.station_id)">删除</a><br>
    96. <a class="selectsadd" (click)="update(data.station_id)">更新</a><br>
    97. <a class="selectsadd" (click)="downLoad(data)">下載</a>
    98. </ng-template>
    99. </td>
    100. </tr>
    101. </tbody>
    102. </nz-table>
    103. <!-- <span>共{{ listOfData.length }}笔资料</span> -->
    104. </div>
    105. </div>
    106. <!-- 上传弹出框 -->
    107. <div>
    108. <nz-modal
    109. nzTitle="上传"
    110. [(nzVisible)]="uploadVisible"
    111. (nzOnCancel)="handleCancel()"
    112. (nzOnOk)="handleOk()"
    113. [nzStyle]="{ width: '30%', top: '100px' }"
    114. [nzMaskStyle]="{ 'background-color': '#666' }"
    115. [nzFooter]="nzModalFooter"
    116. >
    117. <ng-container *nzModalContent>
    118. <nz-upload
    119. nzType="drag"
    120. [nzShowUploadList]="showUploadProgress"
    121. [(nzFileList)]="fileList"
    122. [nzLimit]="0"
    123. [nzBeforeUpload]="beforeUpload"
    124. [nzMultiple]="true"
    125. [nzRemove]="delFileFromList"
    126. >
    127. <div class="upload-text">
    128. <em nz-icon nzType="paper-clip" nzTheme="outline"></em>
    129. <span>选择或拖拽上传</span>
    130. </div>
    131. </nz-upload>
    132. </ng-container>
    133. <ng-template #nzModalFooter>
    134. <button
    135. class="cancel"
    136. nz-button
    137. nzType="primary"
    138. (click)="handleCancel()"
    139. >
    140. 取消
    141. </button>
    142. <button [disabled]="flag" nz-button nzType="primary" (click)="handleOk()">
    143. 確定
    144. </button>
    145. </ng-template>
    146. </nz-modal>
    147. </div>
    1. import { Component, OnInit } from '@angular/core';
    2. import { HttpserviceService } from 'src/app/services/httpservice.service';
    3. import { NzMessageService } from 'ng-zorro-antd/message'; //信息提示
    4. import { NzModalService } from 'ng-zorro-antd/modal';
    5. import { NzUploadFile } from 'ng-zorro-antd/upload';//上传
    6. interface ItemData {
    7. station_id: number;
    8. site: string;
    9. plant: number;
    10. line: string;
    11. model: string;
    12. station: string;
    13. }
    14. @Component({
    15. selector: 'app-mytemplate',
    16. templateUrl: './mytemplate.component.html',
    17. styleUrls: ['./mytemplate.component.css']
    18. })
    19. export class MytemplateComponent implements OnInit {
    20. selectedLine = null;//搜索线别
    21. selectedModel = null;//搜索机种
    22. lines = new Set<number>(); //线别数组
    23. models = new Set<number>(); //机种数组
    24. deleteVisible = false;//删除提示框
    25. checked = false;//控制单选
    26. indeterminate = false;//
    27. public listOfData:any[] = [];//所有数据
    28. listOfCurrentPageData: readonly ItemData[] = [];//指定类型数组
    29. checkedAll = false; //控制全选
    30. setOfCheckedId = new Set<number>();//已选的数据
    31. //上传数据
    32. uploadVisible = false;//上传弹出框
    33. flag = true;
    34. fileList: NzUploadFile[] = [];
    35. data: any = {
    36. fileList: [],
    37. isUploadXML: false// 是否上传了XML檔
    38. };
    39. showUploadProgress = true; //是否展示uploadList
    40. //item的删除
    41. delete(id: number, event: any){
    42. console.log("删除");
    43. this.listOfData = this.listOfData.filter((item) => item.station_id !== id);
    44. }
    45. //item的更新
    46. update(id: any) {
    47. console.log("更新");
    48. this.listOfData.forEach((ele) => {
    49. if (ele.station_id == id) {
    50. ele.site = 'WCQ';
    51. ele.plant = 'F715';
    52. ele.line = "line";
    53. ele.model = "model";
    54. ele.station = 'station';
    55. }
    56. });
    57. }
    58. //item的下载
    59. downLoad(data: any) {
    60. console.log("下载");
    61. let downLoadData = [];
    62. downLoadData.push(data);
    63. // this.downloadService.exportAsExcelFile(downLoadData, '表格数据');
    64. }
    65. //操作
    66. change(event: any) {
    67. console.log(event);
    68. }
    69. //全选
    70. onAllChecked(isCheckAll: boolean): void {
    71. this.listOfData.forEach(element => {
    72. this.updateCheckedSet(element.station_id, isCheckAll);
    73. });
    74. this.refreshCheckedStatus();
    75. this.checkedAll = isCheckAll;
    76. }
    77. //单选
    78. onItemChecked(id: number, checked: boolean): void {
    79. this.updateCheckedSet(id, checked);
    80. this.refreshCheckedStatus();
    81. if (checked) {
    82. this.setOfCheckedId.add(id);
    83. } else {
    84. this.setOfCheckedId.delete(id);
    85. }
    86. console.log("setOfCheckedId:",this.setOfCheckedId);
    87. console.log("id:",id);
    88. }
    89. //更新已选行的id列表
    90. updateCheckedSet(id: number, checked: boolean): void {
    91. if (checked) {
    92. this.setOfCheckedId.add(id);
    93. } else {
    94. this.setOfCheckedId.delete(id);
    95. }
    96. }
    97. //每页显示多少数据
    98. onCurrentPageDataChange($event: readonly ItemData[]): void {
    99. this.listOfCurrentPageData = $event;
    100. this.refreshCheckedStatus();
    101. }
    102. //刷新table表
    103. refreshCheckedStatus(): void {
    104. this.checked = this.listOfCurrentPageData.every(item => this.setOfCheckedId.has(item.station_id));
    105. this.indeterminate = this.listOfCurrentPageData.some(item => this.setOfCheckedId.has(item.station_id)) && !this.checked;
    106. }
    107. //删除本条数据
    108. deleteModal(id: number): void {
    109. this.modal.confirm({
    110. nzTitle: '<i>警告</i>',
    111. nzContent: '<b>是否确认删除本条数据?</b>',
    112. nzOnOk: () => {
    113. this.delete(id,true)
    114. this.nzMessageService.success('删除成功!');
    115. // console.log("this.listOfData:",this.listOfData);
    116. }
    117. });
    118. }
    119. //搜索线种和机种
    120. searchLineAndModel(){
    121. if(this.selectedLine!=null || this.selectedModel!=null){
    122. let tempTable:any[]=[]
    123. this.listOfData.forEach(element => {
    124. if(this.selectedLine==element.line && this.selectedModel==element.model){
    125. tempTable.push(element)
    126. }
    127. else if(this.selectedLine==null){
    128. if(this.selectedModel==element.model){
    129. tempTable.push(element)
    130. }
    131. }
    132. else if(this.selectedModel==null){
    133. if(this.selectedLine==element.line){
    134. tempTable.push(element)
    135. }
    136. }
    137. })
    138. this.listOfData = tempTable
    139. }else{
    140. this.getTable();
    141. }
    142. //搜索完清空
    143. this.selectedLine = null;
    144. this.selectedModel = null;
    145. this.refreshCheckedStatus()
    146. }
    147. //增加数据
    148. addData() {
    149. this.listOfData.push({
    150. station_id: Math.floor(Math.random() * 100),
    151. site: 'WCD',
    152. plant: 'F721',
    153. line: 'E1A',
    154. model: 'SP15',
    155. });
    156. console.log(this.listOfData);
    157. // this.refreshCheckedStatus()
    158. }
    159. //删除当前所选数据
    160. deleteSelect() {
    161. [...this.setOfCheckedId].forEach((id) => {
    162. this.listOfData = this.listOfData.filter((item) => item['station_id'] !== id);
    163. });
    164. if (this.checkedAll) {
    165. this.listOfData = [];
    166. }
    167. }
    168. /**
    169. * 上传弹出框
    170. */
    171. showModal(): void {
    172. this.uploadVisible = true;
    173. console.log("this.listOfData:",this.listOfData);
    174. }
    175. handleOk(): void {
    176. this.uploadVisible = false;
    177. }
    178. handleCancel(): void {
    179. this.uploadVisible = false;
    180. }
    181. //上传
    182. beforeUpload = (file: NzUploadFile): boolean => {
    183. this.fileList = this.fileList.concat(file);
    184. console.log('档案', file);
    185. console.log(this.fileList);
    186. if (file['type'] === 'text/xml') {
    187. this.flag = false;
    188. //callAPI
    189. } else {
    190. this.nzMessageService.create('error', '该档案不是xml类型');
    191. }
    192. return false;
    193. };
    194. //移出
    195. delFileFromList = (file: NzUploadFile): boolean => {
    196. console.log(file)
    197. this.fileList.forEach((element, index) => {
    198. if (element.uid == file.uid) {
    199. this.fileList.splice(index, 1);
    200. }
    201. });
    202. return true;
    203. }
    204. constructor(
    205. private HttpService:HttpserviceService,
    206. private nzMessageService: NzMessageService,
    207. private modal: NzModalService
    208. ) {}
    209. ngOnInit(){
    210. this.getTable();
    211. }
    212. //调用Linlin的table的api
    213. getTable(){
    214. // await this.HttpService.getTableData().subscribe(
    215. // res=>{
    216. // console.log('res:',res.data);
    217. // this.listOfData = res.data;
    218. // }
    219. // )
    220. this.listOfData=[
    221. {
    222. station_id:1,
    223. site:"WCD",
    224. plant:1,
    225. line:"A1",
    226. model:"B1",
    227. station:"C1",
    228. },{
    229. station_id:2,
    230. site:"WCD",
    231. plant:2,
    232. line:"A1",
    233. model:"B2",
    234. station:"C2",
    235. },{
    236. station_id:3,
    237. site:"WCD",
    238. plant:3,
    239. line:"A3",
    240. model:"B3",
    241. station:"C3",
    242. },{
    243. station_id:4,
    244. site:"WCD",
    245. plant:4,
    246. line:"A4",
    247. model:"B3",
    248. station:"C4",
    249. },{
    250. station_id:5,
    251. site:"WCD",
    252. plant:5,
    253. line:"A5",
    254. model:"B5",
    255. station:"C5",
    256. },{
    257. station_id:6,
    258. site:"WCD",
    259. plant:6,
    260. line:"A6",
    261. model:"B6",
    262. station:"C6",
    263. },{
    264. station_id:7,
    265. site:"WCD",
    266. plant:7,
    267. line:"A7",
    268. model:"B7",
    269. station:"C7",
    270. },{
    271. station_id:8,
    272. site:"WCD",
    273. plant:8,
    274. line:"A8",
    275. model:"B8",
    276. station:"C8",
    277. },{
    278. station_id:9,
    279. site:"WCD",
    280. plant:9,
    281. line:"A9",
    282. model:"B9",
    283. station:"C9",
    284. },{
    285. station_id:10,
    286. site:"WCD",
    287. plant:10,
    288. line:"A10",
    289. model:"B10",
    290. station:"C10",
    291. },{
    292. station_id:11,
    293. site:"WCD",
    294. plant:11,
    295. line:"A11",
    296. model:"B11",
    297. station:"C11",
    298. }
    299. ]
    300. //存储线种,机种
    301. this.listOfData.forEach(element => {
    302. this.lines.add(element.line);
    303. this.models.add(element.model)
    304. });
    305. }
    306. xxx(){
    307. console.log('selectedLine:',this.selectedLine);
    308. }
    309. }
    1. @import "~ng-zorro-antd/style/index.min.css"; /* 引入基本样式 */
    2. @import "~ng-zorro-antd/button/style/index.min.css"; /* 引入组件样式 */
    3. .outer{
    4. height: 100%;
    5. position: relative;
    6. }
    7. .table-header{
    8. /* border: 1px solid rebeccapurple; */
    9. width: 100%;
    10. height: 10%;
    11. position: relative;
    12. }
    13. .select1{
    14. /* border: 1px solid red; */
    15. width: 15%;
    16. position: absolute;
    17. margin: auto;
    18. left: 5%;
    19. top: 8%;
    20. }
    21. .select2{
    22. /* border: 1px solid red; */
    23. width: 15%;
    24. position: absolute;
    25. margin: auto;
    26. left: 25%;
    27. top: 8%;
    28. }
    29. .headerButton{
    30. /* border: 1px solid rebeccapurple; */
    31. /* width: 80%; */
    32. height: 100%;
    33. position: absolute;
    34. margin: auto;
    35. left: 40%;
    36. right: 1px;
    37. padding-top: 26px;
    38. /* position: relative; */
    39. }
    40. .tebal-content{
    41. /* border: 1px solid skyblue; */
    42. width: 100%;
    43. height: 90%;
    44. position: absolute;
    45. margin: auto;
    46. top: 10%;
    47. }
    48. .selectsadd {
    49. color: #40a9ff !important;
    50. }
    51. .selectsadd:hover {
    52. color: white !important;
    53. background: #40a9ff;
    54. }

    新建项目:ng new 项目名称
    建立component、directive等schemastic:ng g schemastic名 名称
    启动服务:ng serve 默认4200端口 +—port 指定端口/+—open直接打开
    打包:ng build

    插值语法:{{xxx}},直接读到component.ts里面的值
    指令语法:

    1. ngif,else:就是if:条件为布尔值,false时不加载:ngif=”xxx”;else=”yyy”
    2. ngfor:就是循环:ngfor=”let item of list;let i = index”

    数据绑定:

    1. 单向绑定:
      1. 基本的单项绑定:[]:[src]=”url”
      2. 类绑定:动态选择样式:[ngClass]={“class1=true,class2=false”}
      3. 样式绑定:控制大小等样式:[ngStyle]=”{color=xxx}”
    2. 双向绑定:输入框等信息:[(ngmodel)]=”xxx”

    表单:

    1. 响应式表单
    2. 模板驱动表单

    事件处理:

    1. 鼠标事件:
      1. 单击触发:(click)=”xxx()”
      2. 双击触发:(dblclick)=”xxx()”
      3. 失去焦点:(blur)=”xxx()”
      4. 鼠标进入:(mouseenter)=”xxx()”
      5. 鼠标离开:(mouseleave)=”xxx()”
      6. 鼠标滚动:(wheel)=”xxx()”
      7. 滑动条滚动:(scroll)=”xxx()”
      8. … …
    2. 键盘事件:
      1. 抬起触发:(keyup)=”xxx()”
      2. 按下触发:(keydown)=”xxx()”,(keypress)=”xxx()”
      3. enter抬起监听:(keyup.enter)=”xxx()”
      4. esc抬起触发:(keyup.esc)=”xxx()”

    … …

    1. tab需配合keydown使用,无法配合keyup。

    组件通信

    1. 父传子:父组件在子组件标签内传值,子组件中引入Input,用@Input接收值
    2. 子传父:子组件引入Output和EventEmitter,并实例化EventEmitter,通过this.new EventEmitter().emit(“xxx”)发送数据,
    3. 父调子:父组件在子组件标签内定义一个名如:#son,父组件引入viewChild,
    4. 任意组件传值:

    路由:单页面应用实现跳转

    1. 创建路由:ng new 项目名 —routing

    服务:

    1. 创建服务:ng g s 服务名
    2. 组件引入服务并注册
    3. 组件使用:result = this.服务.get/post(“url”,{参数})

    image.png
    image.png