UNPKG

@kre-form/ant

Version:

1,340 lines 185 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ import { Component, Input, Output, EventEmitter, ChangeDetectorRef, } from "@angular/core"; import { FormGroup } from "@angular/forms"; import { clone, KreFormCommonService, KreFormBuilder, } from "@kre-form/core"; import { NzModalService } from "ng-zorro-antd/modal"; import { NzMessageService } from "ng-zorro-antd/message"; import * as _ from "lodash"; import { KreFormAntService } from "../../tools/service"; import { KreDialogService } from "../../service/dialog.service"; import { DataService } from "../../service/data.service"; import { KreAntCommonService } from "../../tools/commonService"; import { KreTransferService } from "../../tools/transferService"; import { KreDesginToFormService } from "../../tools/tableFieldService"; import { KreFormDSField } from "../field/index.component"; import { KreFormDSFieldLabel } from "../field-label/index.component"; import { KreFormDesignTable } from "../table/table.component"; import { KreFormDesignTables } from "../tables/table.component"; /** * @record */ export function IFormJSON() { } if (false) { /** @type {?} */ IFormJSON.prototype.code; /** @type {?} */ IFormJSON.prototype.name; /** @type {?} */ IFormJSON.prototype.type; /** @type {?} */ IFormJSON.prototype.column; /** @type {?} */ IFormJSON.prototype.row; /** @type {?} */ IFormJSON.prototype.fields; } var KreFormDesignDetailX = /** @class */ (function () { function KreFormDesignDetailX(cd, message, modalService, kreFormAntService, kreDialogService, dataService, kreAntCommonService, kreTransferService, kreDesginToFormService, kreFormCommonService, formBuilder) { this.cd = cd; this.message = message; this.modalService = modalService; this.kreFormAntService = kreFormAntService; this.kreDialogService = kreDialogService; this.dataService = dataService; this.kreAntCommonService = kreAntCommonService; this.kreTransferService = kreTransferService; this.kreDesginToFormService = kreDesginToFormService; this.kreFormCommonService = kreFormCommonService; this.formBuilder = formBuilder; this.showForm = true; this.formCode = ""; this.layout = true; this.api = { tables: { url: "assets/mockData/business.json" }, form: { url: "assets/mockData/formInfo.json" }, }; this.showAnchorList = true; /* 表字段集合 */ this._business_tables = { primary: {}, child: { single: [], multiple: [] }, }; this._langConfig = []; // _lang: string = "zh-cn"; // @Input() // set lang(value: any) { // this._lang = value; // } // get lang() { // return this._lang; // } this._triggerJson = {}; this._calculateRuleJson = {}; this._options = []; /* 表设置 */ this._business_form = { code: "", name: "", type: "", column: "", row: "", fields: [], }; this.isSaveButton = false; this.saveEvent = new EventEmitter(); this.cancelEvent = new EventEmitter(); this.previewEvent = new EventEmitter(); this.actionEvent = new EventEmitter(); this.pageStatus = 1; this.form_model = {}; this.form_group = new FormGroup({}); this.form_fields = []; this.kreFormInfo = {}; this.layout_column = "layout-column-3"; this.layout_row = "layout-row-1"; this.table_Data = []; this.anchorList = []; this.anchorDevList = {}; this.key = ""; this.AddReferProcessDisabled = false; } Object.defineProperty(KreFormDesignDetailX.prototype, "business_tables", { get: /** * @return {?} */ function () { return this._business_tables; }, set: /** * @param {?} value * @return {?} */ function (value) { this._business_tables = value; }, enumerable: true, configurable: true }); Object.defineProperty(KreFormDesignDetailX.prototype, "langConfig", { get: /** * @return {?} */ function () { return this._langConfig; }, set: /** * @param {?} value * @return {?} */ function (value) { this._langConfig = value; }, enumerable: true, configurable: true }); Object.defineProperty(KreFormDesignDetailX.prototype, "triggerJson", { get: /** * @return {?} */ function () { return this._triggerJson; }, set: /** * @param {?} value * @return {?} */ function (value) { this._triggerJson = value; }, enumerable: true, configurable: true }); Object.defineProperty(KreFormDesignDetailX.prototype, "calculateRuleJson", { get: /** * @return {?} */ function () { return this._calculateRuleJson; }, set: /** * @param {?} value * @return {?} */ function (value) { this._calculateRuleJson = value; }, enumerable: true, configurable: true }); Object.defineProperty(KreFormDesignDetailX.prototype, "options", { get: /** * @return {?} */ function () { return this._options; }, set: /** * @param {?} value * @return {?} */ function (value) { this._options = value; }, enumerable: true, configurable: true }); Object.defineProperty(KreFormDesignDetailX.prototype, "business_form", { get: /** * @return {?} */ function () { return this._business_form; }, set: /** * @param {?} value * @return {?} */ function (value) { if (value != undefined && value != null) { this._business_form = value; this.initFormInfo(this._business_form); this.cd.detectChanges(); } }, enumerable: true, configurable: true }); /** * @return {?} */ KreFormDesignDetailX.prototype.ngOnInit = /** * @return {?} */ function () { var _this = this; this.kreFormAntService.btnEvent.subscribe((/** * @param {?} res * @return {?} */ function (res) { if (res["type"] == "delete" || res["type"] == "up" || res["type"] == "down") { /** @type {?} */ var cloneField = _.cloneDeep(res["field"]); /** @type {?} */ var checkedList = _this.kreTransferService.getGroupCheckFields(cloneField); if (checkedList == null || checkedList.length == 0) { _this.message.warning("您当前没有选中任何项!"); return; } } switch (res["type"]) { case "delete": _this.modalService.confirm({ nzTitle: "提示", nzContent: "\u60A8\u786E\u5B9A\u8981\u5220\u9664\u9009\u4E2D\u9879\uFF1F<br/><span class=\"delete_tips\" >\u63D0\u793A\uFF1A\u5982\u679C\u8BE5\u5B57\u6BB5\u662F\u5185\u7F6E\u5B57\u6BB5\uFF0C\u5219\u5220\u9664\u65E0\u6548\u3002</br>&emsp;&emsp;&emsp;\u5982\u679C\u8BE5\u5B57\u6BB5\u5173\u8054\u4E86\u89E6\u53D1\u4E8B\u4EF6\uFF0C\u5219\u5220\u9664\u65E0\u6548\u3002</span>", nzOnOk: (/** * @return {?} */ function () { _this.groupBtnDeleteFields(res["field"]); }), }); break; case "up": case "down": _this.groupBtnMoveUpOrDown(res["field"], res["type"]); break; case "item": _this.groupBtnTableFields(res["field"]); break; case "remark": case "line": _this.groupBtnAddLineRemark(res["field"], res["type"]); break; case "edit": _this.editFormFieldConfig(res["field"]); break; default: break; } })); this.kreFormAntService.fieldEvent.subscribe((/** * @param {?} res * @return {?} */ function (res) { /** @type {?} */ var sign = res["sign"]; if (sign == "edit") { _this.editFormFieldConfig(res["field"]); } else if (sign == "delete") { _this.modalService.confirm({ nzTitle: "提示", nzContent: "\u60A8\u786E\u5B9A\u8981\u5220\u9664\u8BE5\u9879\uFF1F<br/><span class=\"delete_tips\" >\u63D0\u793A\uFF1A\u5982\u679C\u8BE5\u5B57\u6BB5\u662F\u5185\u7F6E\u5B57\u6BB5\uFF0C\u5219\u5220\u9664\u65E0\u6548\u3002</br>&emsp;&emsp;&emsp;\u5982\u679C\u8BE5\u5B57\u6BB5\u5173\u8054\u4E86\u89E6\u53D1\u4E8B\u4EF6\uFF0C\u5219\u5220\u9664\u65E0\u6548\u3002</span>", nzOnOk: (/** * @return {?} */ function () { _this.deleteFormFieldConfig(res["field"]); }), }); } })); this.initAnchorList(); this.AddReferProcessDisabled = this.business_form.fields.some((/** * @param {?} el * @return {?} */ function (el) { return el.key === "comprehensive$df_comprehensiveapply$associationprocess"; })); }; /** * @param {?} changes * @return {?} */ KreFormDesignDetailX.prototype.ngOnChanges = /** * @param {?} changes * @return {?} */ function (changes) { if (changes.business_tables) { this.initTableFieldStatus(); } }; /** * @return {?} */ KreFormDesignDetailX.prototype.ngOnDestroy = /** * @return {?} */ function () { }; /*按钮区域---begin*/ /*按钮区域---begin*/ /** * @return {?} */ KreFormDesignDetailX.prototype.btnSave = /*按钮区域---begin*/ /** * @return {?} */ function () { }; /** * @return {?} */ KreFormDesignDetailX.prototype.btnCancel = /** * @return {?} */ function () { }; /** * @return {?} */ KreFormDesignDetailX.prototype.btnPreview = /** * @return {?} */ function () { }; /** * @return {?} */ KreFormDesignDetailX.prototype.btnDelete = /** * @return {?} */ function () { var _this = this; /** @type {?} */ var checkedList = this.getCheckFields(); if (checkedList == null || checkedList.length == 0) { this.message.warning("您当前没有选中任何项!"); return; } /** @type {?} */ var isRelativeEvent = false; if (!!this.triggerJson && !_.isEmpty(this.triggerJson)) { Object.keys(this.triggerJson).forEach((/** * @param {?} key * @return {?} */ function (key) { if ((/** @type {?} */ (((/** @type {?} */ (checkedList))))).some((/** * @param {?} el * @return {?} */ function (el) { return el.field.key === key; }))) { isRelativeEvent = true; } })); Object.keys(this.triggerJson).forEach((/** * @param {?} key * @return {?} */ function (key) { (/** @type {?} */ (((/** @type {?} */ (_this.triggerJson[key]))))).forEach((/** * @param {?} ele * @return {?} */ function (ele) { if ((/** @type {?} */ (((/** @type {?} */ (checkedList))))).some((/** * @param {?} el * @return {?} */ function (el) { return el.field.key === ele.fieldKey; }))) { isRelativeEvent = true; } })); })); } if (!!this.calculateRuleJson && !_.isEmpty(this.calculateRuleJson)) { // isRelativeEvent = (Object.keys(this.calculateRuleJson) as any).includes( // field.key // ); Object.keys(this.calculateRuleJson).forEach((/** * @param {?} key * @return {?} */ function (key) { if ((/** @type {?} */ (((/** @type {?} */ (checkedList))))).some((/** * @param {?} el * @return {?} */ function (el) { return el.field.key === key; }))) { isRelativeEvent = true; } })); Object.keys(this.calculateRuleJson).forEach((/** * @param {?} key * @return {?} */ function (key) { if (!!_this.calculateRuleJson[key] && !!_this.calculateRuleJson[key]["calculateValue"]) { if ((/** @type {?} */ (((/** @type {?} */ (checkedList))))).some((/** * @param {?} el * @return {?} */ function (el) { return ((/** @type {?} */ (_this.calculateRuleJson[key]["calculateValue"]))).includes(el.field.key); }))) { isRelativeEvent = true; } } })); } if (isRelativeEvent) { this.message.warning("当前字段关联了触发事件,不允许删除!"); return; } this.modalService.confirm({ nzTitle: "提示", nzContent: "\u60A8\u786E\u5B9A\u8981\u5220\u9664\u9009\u4E2D\u9879\uFF1F<br/><span class=\"delete_tips\" >\u63D0\u793A\uFF1A\u5982\u679C\u8BE5\u5B57\u6BB5\u662F\u5185\u7F6E\u5B57\u6BB5\uFF0C\u5219\u5220\u9664\u65E0\u6548\u3002</br>&emsp;&emsp;&emsp;\u5982\u679C\u8BE5\u5B57\u6BB5\u5173\u8054\u4E86\u89E6\u53D1\u4E8B\u4EF6\uFF0C\u5219\u5220\u9664\u65E0\u6548\u3002</span>", nzOnOk: (/** * @return {?} */ function () { checkedList.forEach((/** * @param {?} item * @return {?} */ function (item) { _this.business_form.fields.forEach((/** * @param {?} field * @param {?} index * @param {?} object * @return {?} */ function (field, index, object) { if (field.key === item.field.key && _.get(field, "templateOptions.isButintin") != true) { object.splice(index, 1); } })); })); _this.initTableFieldStatus(); _this.initFormFieldPropertyAction(); _this.AddReferProcessDisabled = _this.business_form.fields.some((/** * @param {?} el * @return {?} */ function (el) { return el.key === "comprehensive$df_comprehensiveapply$associationprocess"; })); }), }); }; /** * @return {?} */ KreFormDesignDetailX.prototype.btnMoveUp = /** * @return {?} */ function () { var _this = this; /** @type {?} */ var checkedList = this.getCheckFields(); console.log(checkedList); if (checkedList == null || checkedList.length == 0) { this.message.warning("您当前没有选中任何项!"); return; } // if ( // !_.isEmpty(checkedList) && // checkedList.some( // (el: any) => // !!el.field.editProperty && // el.field.editProperty.canMove !== undefined && // el.field.editProperty.canMove === false // ) // ) { // this.message.warning("您当前选中项包含不能移动项!"); // return; // } checkedList.forEach((/** * @param {?} item * @return {?} */ function (item) { if (item.index > 0) { // this.business_form.fields.splice(item.index, 1); // this.business_form.fields.splice(item.index - 1, 0, item.field); /** @type {?} */ var i = 1; for (var index = item.index - 1; index > 0; index--) { /** @type {?} */ var field = _this.business_form.fields[index - 1]; if (!!field.editProperty && field.editProperty.canMove !== undefined && field.editProperty.canMove === false) { i++; } else { break; } } _this.move(_this.business_form.fields, item.index, item.index - i); } })); this.initFormFieldPropertyAction(); }; /** * @param {?} arr * @param {?} index * @param {?} tindex * @return {?} */ KreFormDesignDetailX.prototype.move = /** * @param {?} arr * @param {?} index * @param {?} tindex * @return {?} */ function (arr, index, tindex) { //如果当前元素在拖动目标位置的下方,先将当前元素从数组拿出,数组长度-1,我们直接给数组拖动目标位置的地方新增一个和当前元素值一样的元素, //我们再把数组之前的那个拖动的元素删除掉,所以要len+1 if (index > tindex) { arr.splice(tindex, 0, arr[index]); arr.splice(index + 1, 1); } else { //如果当前元素在拖动目标位置的上方,先将当前元素从数组拿出,数组长度-1,我们直接给数组拖动目标位置+1的地方新增一个和当前元素值一样的元素, //这时,数组len不变,我们再把数组之前的那个拖动的元素删除掉,下标还是index arr.splice(tindex + 1, 0, arr[index]); arr.splice(index, 1); } }; /** * @return {?} */ KreFormDesignDetailX.prototype.btnMoveDown = /** * @return {?} */ function () { var _this = this; /** @type {?} */ var checkedList = this.getCheckFields(); console.log(checkedList); if (checkedList == null || checkedList.length == 0) { this.message.warning("您当前没有选中任何项!"); return; } // if ( // !_.isEmpty(checkedList) && // checkedList.some( // (el: any) => // !!el.field.editProperty && // el.field.editProperty.canMove !== undefined && // el.field.editProperty.canMove === false // ) // ) { // this.message.warning("您当前选中项包含不能移动项!"); // return; // } checkedList.reverse().forEach((/** * @param {?} item * @return {?} */ function (item) { if (item.index < _this.business_form.fields.length - 1) { /** @type {?} */ var i = 1; for (var index = item.index; index < _this.business_form.fields.length - 1; index++) { /** @type {?} */ var field = _this.business_form.fields[index + 1]; if (!!field.editProperty && field.editProperty.canMove !== undefined && field.editProperty.canMove === false) { i++; } else { break; } } if (i > 1) { i--; } // this.business_form.fields.splice(item.index, 1); // this.business_form.fields.splice(item.index + 1, 0, item.field); _this.move(_this.business_form.fields, item.index, item.index + i); } })); this.initFormFieldPropertyAction(); }; /** * @return {?} */ KreFormDesignDetailX.prototype.btnAddFields = /** * @return {?} */ function () { this.selectTableFields(); }; /** * @return {?} */ KreFormDesignDetailX.prototype.btnAddRemark = /** * @return {?} */ function () { this.kreTransferService.transferLabelToForm(this.business_form.fields, this.getCheckFields()); this.resetFormBuild(); this.initFormFieldPropertyAction(); this.initAnchorList(); }; /** * @return {?} */ KreFormDesignDetailX.prototype.btnAddLine = /** * @return {?} */ function () { this.kreTransferService.transferLineToForm(this.business_form.fields, this.getCheckFields()); this.resetFormBuild(); this.initFormFieldPropertyAction(); }; /** * @return {?} */ KreFormDesignDetailX.prototype.btnAddAnchor = /** * @return {?} */ function () { this.kreTransferService.transferAnchorToForm(this.business_form.fields, this.getCheckFields()); this.resetFormBuild(); this.initFormFieldPropertyAction(); }; /** * @return {?} */ KreFormDesignDetailX.prototype.btnAddReferProcess = /** * @return {?} */ function () { if ( // this.business_form.fields.some( // (el) => // el.key === "comprehensive$df_comprehensiveapply$associationprocess" // ) this.AddReferProcessDisabled) { // this.message.warning("一个流程最多只能有一个关联流程组件!"); return; } // console.log(1); this.kreTransferService.transferReferProcessToForm(this.business_form.fields, this.getCheckFields()); this.resetFormBuild(); this.initFormFieldPropertyAction(); this.AddReferProcessDisabled = true; }; /** * @return {?} */ KreFormDesignDetailX.prototype.btnAddGroup = /** * @return {?} */ function () { var _this = this; /** @type {?} */ var tablecode = this.getTableMultipleCode(); if (tablecode == null || tablecode == "") { this.message.warning("暂无可用的多记录区域可以添加"); return; } if (this.business_tables && this.business_tables.child && this.business_tables.child.multiple && this.business_tables.child.multiple.length > 0) { if (this.business_tables.child.multiple.some((/** * @param {?} item * @return {?} */ function (item) { return item.tableQuote !== true; }))) { this.kreDialogService.CreateModelDialog({ nzTitle: "选择列表", size: "large", nzContent: KreFormDesignTables, }, { businessTable: this.business_tables, tableType: "single" }, (/** * @param {?} instance * @param {?} modal * @return {?} */ function (instance, modal) { modal.destroy(); if (instance.radioValue && instance.radioValue !== null && instance.radioValue !== "") { _this.kreTransferService.transferGroupToForm(_this.business_form.fields, _this.getCheckFields(), instance.radioValue, _this.business_tables); } _this.initTableFieldStatus(); _this.initFormFieldPropertyAction(); })); } } }; /** * @param {?} type * @return {?} */ KreFormDesignDetailX.prototype.btnColumn = /** * @param {?} type * @return {?} */ function (type) { this.kreFormInfo.column = "layout-column-" + type; this.layout_column = this.kreFormInfo.column; this.business_form.column = this.kreFormInfo.column; this.initFormFieldPropertyAction(); }; /** * @param {?} type * @return {?} */ KreFormDesignDetailX.prototype.btnRow = /** * @param {?} type * @return {?} */ function (type) { this.kreFormInfo.row = "layout-row-" + type; this.layout_row = this.kreFormInfo.row; this.business_form.row = this.kreFormInfo.row; this.initFormFieldPropertyAction(); }; /** * @return {?} */ KreFormDesignDetailX.prototype.getCheckFields = /** * @return {?} */ function () { /** @type {?} */ var checkedField = []; this.business_form.fields.forEach((/** * @param {?} item * @param {?} index * @return {?} */ function (item, index) { if (item.checked) { checkedField.push({ index: index, field: item }); } })); return checkedField; }; /*按钮区域---end*/ /*按钮区域---end*/ /** * @param {?} groupField * @param {?} type * @return {?} */ KreFormDesignDetailX.prototype.groupBtnMoveUpOrDown = /*按钮区域---end*/ /** * @param {?} groupField * @param {?} type * @return {?} */ function (groupField, type) { if (!_.get(groupField, "fieldArray.fieldGroup") || _.get(groupField, "fieldArray.fieldGroup").length < 1) { groupField.fieldArray = { fieldGroup: [], }; } /** @type {?} */ var res = this.kreTransferService.groupFieldMoveUpOrDown(this.business_form.fields, groupField, type); if (res != null) { this.business_form.fields = res; if (groupField.key !== null && groupField.key !== undefined) { this.form_model[groupField.key] = [{}]; } this.initFormFieldPropertyAction(); } }; /** * @param {?} groupField * @param {?} type * @return {?} */ KreFormDesignDetailX.prototype.groupBtnAddLineRemark = /** * @param {?} groupField * @param {?} type * @return {?} */ function (groupField, type) { if (!_.get(groupField, "fieldArray.fieldGroup") || _.get(groupField, "fieldArray.fieldGroup").length < 1) { groupField.fieldArray = { fieldGroup: [], }; } /** @type {?} */ var res = null; if (type === "line") { res = this.kreTransferService.groupTransferLineToForm(this.business_form.fields, groupField); } else if (type === "remark") { res = this.kreTransferService.groupTransferRemarkToForm(this.business_form.fields, groupField); } if (res != null) { this.business_form.fields = res; if (groupField.key !== null && groupField.key !== undefined) { this.form_model[groupField.key] = [{}]; } this.initFormFieldPropertyAction(); } }; /** * @param {?} groupField * @return {?} */ KreFormDesignDetailX.prototype.groupBtnTableFields = /** * @param {?} groupField * @return {?} */ function (groupField) { var _this = this; console.log(groupField); this.kreDialogService.CreateModelDialog({ nzTitle: "选择列表", size: "large", nzContent: KreFormDesignTable, }, { businessTable: this.business_tables, tableType: "multiple", fieldConfig: groupField, }, (/** * @param {?} instance * @param {?} modal * @return {?} */ function (instance, modal) { modal.destroy(); /** @type {?} */ var res = _this.kreTransferService.groupTransferSelectFieldToForm(_this.business_form.fields, groupField, _.cloneDeep(_this.kreTransferService.getGroupCheckFields(groupField)), _this.business_tables, instance.mapOfCheckedId); if (res != null) { _this.business_form.fields = res; if (groupField.key !== null && groupField.key !== undefined) { _this.form_model[groupField.key] = [{}]; } } _this.formBuilder.buildForm(_this.form_group, _this.business_form.fields, _this.form_model, {}); _this.initTableFieldStatus(); _this.initFormFieldPropertyAction(); })); }; /** * @param {?} groupField * @return {?} */ KreFormDesignDetailX.prototype.groupBtnDeleteFields = /** * @param {?} groupField * @return {?} */ function (groupField) { if (!_.get(groupField, "fieldArray.fieldGroup") || _.get(groupField, "fieldArray.fieldGroup").length < 1) { return; } /** @type {?} */ var res = this.kreTransferService.groupTransferDeleteForm(this.business_form.fields, groupField); if (res != null) { this.business_form.fields = res; if (groupField.key !== null && groupField.key !== undefined) { this.form_model[groupField.key] = [{}]; } } this.initTableFieldStatus(); this.initFormFieldPropertyAction(); this.initAnchorList(); }; /** * @return {?} */ KreFormDesignDetailX.prototype.initTablesInfo = /** * @return {?} */ function () { var _this = this; this.business_tables; this.dataService .getBusinessTables(this.api.tables.url, { formcode: this.formCode }) .subscribe((/** * @param {?} res * @return {?} */ function (res) { if (res != null) { _this.business_tables = res; } })); }; /** * @param {?} res * @return {?} */ KreFormDesignDetailX.prototype.initFormInfo = /** * @param {?} res * @return {?} */ function (res) { if (res == undefined || res == null) { return; } this.kreFormInfo = { code: res.code, name: res.name, type: res.type, fields: res.fields, }; if (this.kreFormInfo.fields !== null && this.kreFormInfo.fields !== undefined) { this.kreFormCommonService.initFormFieldModel(this.kreFormInfo.fields, this.form_model); // this.business_form.fields = this.kreFormInfo.fields; } if (res.column != undefined && res.column != null && res.column != "") { this.kreFormInfo.column = res.column; } else { this.kreFormInfo.column = "layout-column-3"; } if (res.row != undefined && res.row != null && res.row != "") { this.kreFormInfo.row = res.row; } else { this.kreFormInfo.row = "layout-row-1"; } if (this.kreFormInfo.column != undefined && this.kreFormInfo.column != null && this.kreFormInfo.row != undefined && this.kreFormInfo.row != null) { this.layout_column = this.kreFormInfo.column; this.layout_row = this.kreFormInfo.row; this.kreDesginToFormService.initFormFieldByTables(this.business_tables, this.business_form.fields); this.initTableFieldStatus(); } }; /** * @return {?} */ KreFormDesignDetailX.prototype.initTableFieldStatus = /** * @return {?} */ function () { this.kreDesginToFormService.initTableStatus(this.business_tables, this.business_form.fields); this.initTablesData(); }; /** * @return {?} */ KreFormDesignDetailX.prototype.initTablesData = /** * @return {?} */ function () { this.table_Data = []; /** @type {?} */ var business = clone(this.business_tables); /** @type {?} */ var tables = []; if (!business) return; if (business.primary && business.primary != null) { tables = [ { tableType: "primary", tableLabel: "主表", tableCode: business.primary["tableCode"], tableName: business.primary["tableName"], tableFields: business.primary["tableFields"], }, ]; } if (business.child && business.child != null && business.child.single && business.child.single != null && business.child.single.length > 0) { if (Array.isArray(business.child.single)) { business.child.single.forEach((/** * @param {?} item * @return {?} */ function (item) { tables.push({ tableType: "single", tableLabel: "单记录子表", tableCode: item["tableCode"], tableName: item["tableName"], tableFields: item["tableFields"], }); })); } } if (business.child && business.child != null && business.child.multiple && business.child.multiple != null && business.child.multiple.length > 0) { if (Array.isArray(business.child.multiple)) { business.child.multiple.forEach((/** * @param {?} item * @return {?} */ function (item) { tables.push({ tableType: "multiple", tableLabel: "多记录子表", tableCode: item["tableCode"], tableName: item["tableName"], tableFields: item["tableFields"], }); })); } } this.table_Data = tables; }; //表单选择 //表单选择 /** * @return {?} */ KreFormDesignDetailX.prototype.selectTableFields = //表单选择 /** * @return {?} */ function () { var _this = this; this.kreDialogService.CreateModelDialog({ nzTitle: "选择列表", size: "large", nzContent: KreFormDesignTable, }, { businessTable: this.business_tables, tableType: "single" }, (/** * @param {?} instance * @param {?} modal * @return {?} */ function (instance, modal) { modal.destroy(); _this.kreTransferService.transferSelectFieldToForm(_this.business_form.fields, _this.getCheckFields(), _this.business_tables, instance.mapOfCheckedId); _this.initTableFieldStatus(); _this.formBuilder.buildForm(_this.form_group, _this.business_form.fields, _this.form_model, {}); _this.initFormFieldPropertyAction(); })); }; /** * @return {?} */ KreFormDesignDetailX.prototype.getTableMultipleCode = /** * @return {?} */ function () { /** @type {?} */ var resTableCode = ""; if (this.business_tables && this.business_tables.child && this.business_tables.child.multiple && this.business_tables.child.multiple.length > 0) { this.business_tables.child.multiple.forEach((/** * @param {?} item * @return {?} */ function (item) { if (item.tableQuote !== true && resTableCode == "") { resTableCode = item.tableCode; } })); } return resTableCode; }; //修改Field //修改Field /** * @param {?} field * @return {?} */ KreFormDesignDetailX.prototype.editFormFieldConfig = //修改Field /** * @param {?} field * @return {?} */ function (field) { var _this = this; /** @type {?} */ var content; /** @type {?} */ var title = ""; if (field.type === "html") { title = "编辑片段文本描述"; content = KreFormDSFieldLabel; } else if (field.type === "repeat") { title = "编辑多记录区"; content = KreFormDSField; } else if (field.type === "tabular") { title = "编辑加班区域"; content = KreFormDSField; } else if (field.type === "htmlcontent") { title = "编辑文本"; content = KreFormDSField; } else { title = "编辑字段 - " + _.get(field, "templateOptions.label"); content = KreFormDSField; } this.kreDialogService.CreateModelDialogField({ nzTitle: title, size: "large", nzContent: content, }, { langConfig: this.langConfig, field: clone(field), modalType: "default", options: this.options, }, (/** * @param {?} type * @param {?} instance * @param {?} modal * @return {?} */ function (type, instance, modal) { if (instance.checkSave()) { /** @type {?} */ var result = _this.kreTransferService.editFormFieldInfo(_this.business_form.fields, instance.formField); if (result != null) { _this.business_form.fields = result.formFileds; if (result.groupKey != null && result.groupKey != "") { _this.form_model[result.groupKey] = [{}]; } } _this.initFormFieldPropertyAction(); if (field.type === "htmlcontent") { _this.initAnchorList(); } modal.destroy(); } })); }; //删除Field //删除Field /** * @param {?} field * @return {?} */ KreFormDesignDetailX.prototype.deleteFormFieldConfig = //删除Field /** * @param {?} field * @return {?} */ function (field) { var _this = this; /** @type {?} */ var isRelativeEvent = false; if (!!this.triggerJson && !_.isEmpty(this.triggerJson)) { // isRelativeEvent = (Object.keys(this.triggerJson) as any).includes( // field.key // ); Object.keys(this.triggerJson).forEach((/** * @param {?} key * @return {?} */ function (key) { if (key === field.key && _this.triggerJson[key].length > 0) { isRelativeEvent = true; } (/** @type {?} */ (((/** @type {?} */ (_this.triggerJson[key]))))).forEach((/** * @param {?} el * @return {?} */ function (el) { if (el.fieldKey === field.key) { isRelativeEvent = true; } })); })); } if (!!this.calculateRuleJson && !_.isEmpty(this.calculateRuleJson)) { isRelativeEvent = ((/** @type {?} */ (Object.keys(this.calculateRuleJson)))).includes(field.key); Object.keys(this.calculateRuleJson).forEach((/** * @param {?} key * @return {?} */ function (key) { if (!!_this.calculateRuleJson[key] && !!_this.calculateRuleJson[key]["calculateValue"] && ((/** @type {?} */ (_this.calculateRuleJson[key]["calculateValue"]))).includes(field.key)) { isRelativeEvent = true; } })); } if (isRelativeEvent) { this.message.warning("当前字段关联了触发事件,不允许删除!"); return; } /** @type {?} */ var result = this.kreTransferService.deleteFormFieldInfo(this.business_form.fields, field); if (result != null) { this.business_form.fields = result.formFileds; if (result.groupKey != null && result.groupKey != "") { this.form_model[result.groupKey] = [{}]; } this.initTableFieldStatus(); this.initFormFieldPropertyAction(); } this.initAnchorList(); }; /** * @return {?} */ KreFormDesignDetailX.prototype.resetFormBuild = /** * @return {?} */ function () { this.formBuilder.buildForm(this.form_group, this.business_form.fields, this.form_model, {}); }; /** * @return {?} */ KreFormDesignDetailX.prototype.initFormFieldPropertyAction = /** * @return {?} */ function () { /** @type {?} */ var newFormInfo = _.cloneDeep(this.business_form); this.kreFormCommonService.initFormFieldProperty(newFormInfo.fields); this.actionEvent.emit({ newFormInfo: newFormInfo, triggerJson: this.triggerJson, calculateRuleJson: this.calculateRuleJson, }); }; /** * @param {?} e * @return {?} */ KreFormDesignDetailX.prototype.modelChange = /** * @param {?} e * @return {?} */ function (e) { }; /** * @return {?} */ KreFormDesignDetailX.prototype.initAnchorList = /** * @return {?} */ function () { var _this = this; this.anchorList = []; this.key = ""; this.business_form.fields.forEach((/** * @param {?} el * @return {?} */ function (el) { if (el.type === "htmlcontent" && (/** @type {?} */ ((/** @type {?} */ (el)).templateOptions)).isNav) { _this.anchorList.push(el); } })); this.anchorDevList = {}; setTimeout((/** * @return {?} */ function () { if (_this.anchorList.length > 0) { _this.anchorList.forEach((/** * @param {?} el * @param {?} index * @return {?} */ function (el, index) { if (!(/** @type {?} */ ((/** @type {?} */ (el)).templateOptions)).description) { (/** @type {?} */ ((/** @type {?} */ (el)).templateOptions)).description = "\u9ED8\u8BA4\u5BFC\u822A" + (index + 1); } (/** @type {?} */ ((/** @type {?} */ (document)).getElementById("conter"))).scrollTop = 0; _this.anchorDevList[el.key] = ((/** @type {?} */ ((/** @type {?} */ ((/** @type {?} */ (document)).getElementById(el.key))).getBoundingClientRect())))["y"]; })); } }), 100); }; /** * @param {?} str * @return {?} */ KreFormDesignDetailX.prototype.at = /** * @param {?} str * @return {?} */ function (str) { if (!!this.key && str === this.key) { return; } this.key = str; /** @type {?} */ var anchorDevList = _.cloneDeep(this.anchorDevList); (/** @type {?} */ ((/** @type {?} */ (document)).getElementById("conter"))).scrollTop = anchorDevList[this.key] - 197; }; KreFormDesignDetailX.decorators = [ { type: Component, args: [{ selector: "kreform-designx", template: "<div class=\"design\">\n <div class=\"layout\">\n <ng-container *ngIf=\"layout == true\">\n <div class=\"layout-column\">\n <div class=\"title\">\u9009\u62E9\u5E03\u5C40\u6837\u5F0F</div>\n <ul>\n <li (click)=\"btnColumn(3)\">\n <div [class]=\"layout_column === 'layout-column-3' ? 'select' : ''\">\n <i class=\"icon-threeL\"> </i>\n </div>\n <span>\u4E09\u5217</span>\n </li>\n <li (click)=\"btnColumn(2)\">\n <div [class]=\"layout_column === 'layout-column-2' ? 'select' : ''\">\n <i class=\"icon-towL\"></i>\n </div>\n <span>\u4E24\u5217</span>\n </li>\n <li (click)=\"btnColumn(1)\">\n <div [class]=\"layout_column === 'layout-column-1' ? 'select' : ''\">\n <i class=\"icon-oneL\"></i>\n </div>\n <span>\u4E00\u5217</span>\n </li>\n </ul>\n </div>\n\n <div class=\"layout-row\">\n <div class=\"title\">\u9009\u62E9\u8868\u5355\u6837\u5F0F</div>\n <ul>\n <li (click)=\"btnRow(1)\">\n <div [class]=\"layout_row === 'layout-row-1' ? 'select' : ''\"></div>\n <span>\u6C34\u5E73</span>\n </li>\n <li (click)=\"btnRow(2)\">\n <div [class]=\"layout_row === 'layout-row-2' ? 'select' : ''\"></div>\n <span>\u5782\u76F4</span>\n </li>\n </ul>\n </div>\n\n <div class=\"layout-el\">\n <div class=\"title\">\u8868\u5355\u7F16\u8F91</div>\n <ul>\n <li (click)=\"btnAddFields()\">\n <i class=\"icon-TianJiaZiDuan\"></i>\u6DFB\u52A0\u5B57\u6BB5\n </li>\n <li (click)=\"btnAddRemark()\">\n <i class=\"icon-other-WenBen\"></i>\u6DFB\u52A0\u6587\u672C\n </li>\n <li (click)=\"btnAddLine()\">\n <i class=\"icon-FenGeXian\"></i>\u6DFB\u52A0\u5206\u5272\u7EBF\n </li>\n <!-- <li (click)=\"btnAddAnchor()\">\n <i class=\"icon-DuoJiLuQu\"></i>\u6DFB\u52A0\u5BFC\u822A\n </li> -->\n <li (click)=\"btnAddGroup()\">\n <i class=\"icon-DuoJiLuQu\"></i>\u6DFB\u52A0\u591A\u8BB0\u5F55\u533A\n </li>\n <li\n (click)=\"btnAddReferProcess()\"\n [class.AddReferProcessDisabled]=\"AddReferProcessDisabled\"\n >\n <i class=\"icon-DuoJiLuQu\"></i>\u6DFB\u52A0\u5173\u8054\u6D41\u7A0B\n </li>\n </ul>\n </div>\n </ng-container>\n <ng-content select=\"[name=design-layout]\"></ng-content>\n </div>\n\n <div class=\"layout anchor\" *ngIf=\"showAnchorList && anchorList.length > 0\">\n <div class=\"anchorList-box\">\n <li\n class=\"anchorList\"\n *ngFor=\"let item of anchorList\"\n [class.anchorList-active]=\"key === item.key\"\n (click)=\"at(item.key)\"\n >\n {{ item?.templateOptions?.description }}\n </li>\n </div>\n </div>\n\n <div class=\"panel\" *ngIf=\"showForm == true; else emptyContent\">\n <div class=\"krebutton\">\n <ng-content select=\"[name=other-button]\"></ng-content>\n <div>\n <button\n nz-button\n nzType=\"primary\"\n nzSize=\"small\"\n nzGhost\n (click)=\"btnDelete()\"\n >\n <i class=\"icon-N_delete2\"></i>\u5220\u9664\n </button>\n <button\n nz-button\n nzType=\"primary\"\n nzSize=\"small\"\n nzGhost\n (click)=\"btnMoveUp()\"\n >\n <i class=\"icon-ShangYi\"></i>\u4E0A\u79FB\n </button>\n <button\n nz-button\n nzType=\"primary\"\n nzSize=\"small\"\n nzGhost\n (click)=\"btnMoveDown()\"\n >\n <i class=\"icon-XiaYi\"></i>\u4E0B\u79FB\n </button>\n </div>\n </div>\n <div\n class=\"kreform-box scrollbar\"\n id=\"conter\"\n [class.has-anchorList]=\"anchorList.length > 0\"\n >\n <div class=\"kreform scrollbar\">\n <form\n [formGroup]=\"form_group\"\n [class]=\"kreFormInfo?.column + ' ' + kreFormInfo?.row\"\n nz-form\n >\n <kreform\n id=\"kreformkreform\"\n [fields]=\"business_form.fields\"\n [status]=\"1\"\n [form]=\"form_group\"\n [model]=\"form_model\"\n (modelChange)=\"modelChange($event)\"\n >\n </kreform>\n </form>\n </div>\n </div>\n </div>\n <ng-template #emptyContent>\n <div class=\"panel\">\n <ng-content select=\"[name=other-button]\"></ng-content>\n <ng-content select=\"[name=empty]\"></ng-content>\n </div>\n </ng-template>\n</div>\n", providers: [ DataService, KreAntCommonService, KreTransferService, KreDialogService, KreFormAntService, ], styles: [":host ::ng-deep{width:100%;display:flex;height:100%;background-color:#f3f3f3}:host ::ng-deep .ant-input[disabled]{color:rgba(0,0,0,.25);background-color:#f3f3f3;cursor:not-allowed;opacity:1;border:0}:host ::ng-deep .design{display:flex;flex:1}:host ::ng-deep .design .layout{float:left;width:240px;background-color:#fff;padding:15px 0 0 20px;margin-right:20px}:host ::ng-deep .design .layout .title{font-size:14px;co