ming-demo1
Version:
mdf metaui web
485 lines (406 loc) • 16 kB
JavaScript
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _react = _interopRequireWildcard(require("react"));
var _redux = require("redux");
var _reactRedux = require("react-redux");
var _baseui = require("@mdf/baseui");
var _col = _interopRequireDefault(require("../basic/col"));
var _row = _interopRequireDefault(require("../basic/row"));
var _SvgIcon = _interopRequireDefault(require("@mdf/metaui-web/lib/components/common/SvgIcon"));
var _AddMessage = _interopRequireDefault(require("./AddMessage"));
var addActions = _interopRequireWildcard(require("../../redux/addMessage"));
var TabPane = _baseui.Tabs.TabPane;
var Table = null;
if (process.env.__CLIENT__ === true) {
require("./billdesign.css");
}
var SubscribeSetting = function (_Component) {
(0, _inherits2["default"])(SubscribeSetting, _Component);
function SubscribeSetting(props) {
var _this;
(0, _classCallCheck2["default"])(this, SubscribeSetting);
_this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(SubscribeSetting).call(this, props));
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onClick", function (e, type, data) {
var readOnly, modalVisible;
if (type == 'see') {
readOnly = true;
} else {
readOnly = false;
}
_this.title = data.cName;
_this.actions.modifyModalVisible(true, _this.props.type);
_this.actions.setReadOnly(readOnly, _this.props.type);
_this.gridModel.setReadOnly(readOnly);
_this.actions.getBillByBillNo(data.cBillNo, _this.gridModel, readOnly, _this.props.type);
_this.params = {
cBillNo: data.cBillNo,
readOnly: readOnly
};
_this.billNo = data.cBillNo;
});
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleModify", function () {
_this.isAdd = false;
var checkRows = _this.gridModel.getSelectedRows();
var checkRow = [];
if (!checkRows || checkRows.length < 1) {
cb.utils.alert('未选中任何行!', 'error');
return;
} else {
checkRow = checkRows[0];
if (checkRow.iSystem == 1) {
cb.utils.alert('系统项,不允许设计!', 'error');
return;
}
}
var iBillEntityId = _this.getBillEntityId();
_this.props.initData(_this.billNo, {
caption: checkRow.cShowCaption,
expressionCode: checkRow.cFieldName,
expression: checkRow.cDefineName
}, iBillEntityId);
});
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getBillEntityId", function () {
var activeKey,
groups,
iBillEntityId = "";
var data = cb.utils.extend(true, [], groups);
data.map(function (item, groupIndex) {
if (item.groupId == activeKey) {
iBillEntityId = item.iBillEntityId;
}
});
return iBillEntityId;
});
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleOk", function (args) {
var groups = [],
activeKey;
var data = cb.utils.extend(true, [], groups);
var controls = [],
gIndex;
data.map(function (item, groupIndex) {
if (item.groupId == activeKey) {
controls = item.controls;
gIndex = groupIndex;
}
});
if (_this.isAdd) {
var selectRowIndex = _this.gridModel.getSelectedRowIndexes()[0];
var rows = _this.gridModel.getData();
var selectRow = rows[selectRowIndex];
var row = {
cCaption: args.caption,
cShowCaption: args.caption,
cFieldName: args.expressionCode,
cDefineName: args.expression,
iBillTplGroupId: selectRow.iBillTplGroupId,
iBillId: selectRow.iBillId,
iBillEntityId: selectRow.iBillEntityId,
iTplId: selectRow.iTplId,
cSubId: selectRow.cSubId,
iOrder: selectRow.iOrder + 1,
cDataSourceName: selectRow.cDataSourceName
};
row._status = 'Insert';
data[gIndex].controls = [row];
for (var i = selectRowIndex + 1; i < rows.length; i++) {
data[gIndex].controls.push(rows[i]);
}
_this.actions.updateBillTemplate(data, "insert", {
cBillNo: _this.params.cBillNo,
gridModel: _this.gridModel,
readOnly: _this.params.readOnly,
type: _this.props.type
});
} else {
var seletIndexs = _this.gridModel.getSelectedRowIndexes();
var checkIndex = seletIndexs[0];
_this.gridModel.setCellValue(checkIndex, 'cCaption', args.caption);
_this.gridModel.setCellValue(checkIndex, 'cShowCaption', args.caption);
_this.gridModel.setCellValue(checkIndex, 'cFieldName', args.expressionCode);
_this.gridModel.setCellValue(checkIndex, 'cDefineName', args.expression);
controls[checkIndex].cCaption = args.caption;
controls[checkIndex].cShowCaption = args.caption;
controls[checkIndex].cFieldName = args.expressionCode;
controls[checkIndex].cDefineName = args.expression;
controls[checkIndex]._status = 'Update';
_this.actions.setGroups(controls, _this.props.type);
}
});
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onOk", function (e) {
var groups = [];
_this.actions.updateBillTemplate(groups, null, {
cBillNo: _this.params.cBillNo,
gridModel: _this.gridModel,
readOnly: _this.params.readOnly,
type: _this.props.type
});
_this.actions.modifyModalVisible(false, _this.props.type);
});
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onCancel", function (e) {
_this.props.close();
});
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onButtonClick", function (type) {
_this.actions.setReadOnly(false, _this.props.type);
_this.gridModel.setReadOnly(false);
});
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onActionClick", function (index, action) {
var subscribeId = _this.props.addMessage.subscribeId;
var id = subscribeId[index];
var cItemName = action.cItemName;
if (cItemName == 'btnDeleteRow') {
cb.utils.confirm("确定删除此栏目么?", function () {
_this.actions.deleteRow(id, _this.gridModel);
});
} else {
var model = _this.props.model;
var _model$getParams = model.getParams(),
billNo = _model$getParams.billNo,
menuId = _model$getParams.menuId,
filterId = _model$getParams.filterId,
code = _model$getParams.code,
name = _model$getParams.name,
viewType = _model$getParams.viewType,
metaType = _model$getParams.metaType,
metaKey = _model$getParams.metaKey;
var command = JSON.stringify({
code: code,
name: name,
viewType: viewType,
metaType: metaType,
metaKey: metaKey
});
_this.actions.initData(billNo, command, filterId, model.getCache('lastSearchCondition'), model.getCache('groupSchemaId'));
_this.actions.getSolutionEdit(filterId);
_this.actions.editRow(index);
}
});
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "bHasDataSource", function () {
var activeKey,
groups,
hasDataSource = false;
var data = cb.utils.extend(true, [], groups);
data.map(function (item, groupIndex) {
if (item.groupId == activeKey) {
if (item.cDataSourceName) hasDataSource = true;
}
});
return hasDataSource;
});
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "showAddModal", function () {
var model = _this.props.model;
var _model$getParams2 = model.getParams(),
billNo = _model$getParams2.billNo,
menuId = _model$getParams2.menuId,
filterId = _model$getParams2.filterId,
code = _model$getParams2.code,
name = _model$getParams2.name,
viewType = _model$getParams2.viewType,
metaType = _model$getParams2.metaType,
metaKey = _model$getParams2.metaKey;
var command = JSON.stringify({
code: code,
name: name,
viewType: viewType,
metaType: metaType,
metaKey: metaKey
});
_this.actions.initData(billNo, command, filterId, model.getCache('lastSearchCondition'), model.getCache('groupSchemaId'));
_this.actions.getReceivers();
_this.actions.getSolutionList(filterId);
});
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getModalControl", function () {
var action = {
"cControlType": "Toolbar",
"cStyle": "{\"fixedwidth\":150}",
"controls": [{
"cItemName": "btnEditRow",
"cCaption": "编辑",
"iOrder": 34,
"cShowCaption": "编辑",
"iStyle": 0,
"cControlType": "button",
"icon": "shanchu1",
"childrenField": "purInRecords",
"key": "3876626"
}, {
"cItemName": "btnDeleteRow",
"cCaption": "删除",
"iOrder": 34,
"cShowCaption": "删除",
"iStyle": 0,
"cControlType": "button",
"icon": "shanchu1",
"childrenField": "purInRecords",
"key": "3876626"
}]
};
return _react["default"].createElement("div", null, _react["default"].createElement("div", {
className: "bill-design-tabs clearfix"
}, _react["default"].createElement("div", {
className: "tabs-button noTabs"
}, _react["default"].createElement(_baseui.Button, {
type: "primary",
onClick: _this.showAddModal
}, _react["default"].createElement(_SvgIcon["default"], {
className: "icon-plus-copy",
type: "plus-copy"
}), "\u65B0\u589E"))), _react["default"].createElement(Table, {
action: action,
noViewModel: true,
onActionClick: _this.onActionClick,
width: 800,
height: 441,
model: _this.gridModel
}));
});
Table = require('../basic/table')["default"];
_this.actions = props.addActions;
_this.title = '订阅设置';
return _this;
}
(0, _createClass2["default"])(SubscribeSetting, [{
key: "componentDidMount",
value: function componentDidMount() {
var _this2 = this;
var columns = {
cCaption: {
cItemName: 'name',
cShowCaption: '订阅名称',
iColWidth: 150,
bHidden: false,
bShowIt: true,
bCanModify: false,
cControlType: 'Input',
bMustSelect: true
},
cCycle: {
cItemName: 'cycle',
cShowCaption: '订阅周期',
iColWidth: 200,
bHidden: false,
bShowIt: true,
bCanModify: false,
cControlType: 'Input',
bMustSelect: true
},
cStart: {
cItemName: 'isStart',
cShowCaption: '是否启用',
iColWidth: 150,
bHidden: false,
bShowIt: true,
bCanModify: true,
cControlType: 'CheckRadio',
bMustSelect: true
}
};
this.gridModel = new cb.models.GridModel({
columns: columns,
independent: true,
readOnly: false,
showRowNo: true,
showCheckBox: false,
showAggregates: false,
pagination: false,
isDirty: true,
showColumnSetting: false
});
this.actions.getListData(this.gridModel);
this.gridModel.on('beforeCellValueChange', function (val) {
var data = _this2.gridModel.getRowsByIndexes([val.rowIndex]);
if (data[0].isStart) {
cb.utils.confirm("确定停用此条订阅吗?", function () {
_this2.actions.modifyCellValue(data[0].isStart, val.rowIndex);
});
return false;
}
cb.utils.confirm("确定启用此条订阅吗?", function () {
_this2.actions.modifyCellValue(data[0].isStart, val.rowIndex);
});
return false;
});
this.gridModel.on('afterCellValueChange', function (val) {
var index = val.rowIndex;
var data = _this2.gridModel.getAllData();
data[index]._status = 'Update';
_this2.actions.setGroups(data, _this2.props.type, data[index]);
});
this.gridModel.on('afterUpdateRow', function (val) {
var index = val.index;
var data = _this2.gridModel.getAllData();
data[index]._status = 'Update';
_this2.actions.setGroups(data, _this2.props.type, data[index]);
});
this.gridModel.on('afterInsertRow', function (val) {
var index = val.index;
var data = _this2.gridModel.getAllData();
_this2.actions.setGroups(data, _this2.props.type);
});
this.gridModel.on('afterSetDataSource', function (data) {
if (cb.utils.isArray(data)) {
var states = [];
data.map(function (row, index) {
if (row.iSystem != 1) {
states.push({
"rowIndex": index,
"cellName": "bIsNull",
"propertyName": "disabled",
"value": true
});
}
});
if (states.length > 0) _this2.gridModel.setCellStates(states);
}
});
}
}, {
key: "render",
value: function render() {
var showModal,
modalData,
readOnly,
className = "bill-design-modal report-design-modal";
var modalControl = this.getModalControl();
var iBillEntityId = this.getBillEntityId();
return _react["default"].createElement("div", {
className: "uretail-billdesign-body"
}, _react["default"].createElement(_baseui.Modal, {
title: "\u8BA2\u9605\u8BBE\u7F6E",
width: 800,
visible: true,
className: className,
onOk: this.onCancel,
onCancel: this.onCancel,
okText: "\u786E\u5B9A",
cancelText: "\u53D6\u6D88",
maskClosable: false
}, _react["default"].createElement("div", null, modalControl)), _react["default"].createElement(_AddMessage["default"], null));
}
}]);
return SubscribeSetting;
}(_react.Component);
function mapStateToProps(state) {
return {
addMessage: state.addMessage.toJS()
};
}
function mapDispatchToProps(dispatch) {
return {
addActions: (0, _redux.bindActionCreators)(addActions, dispatch)
};
}
var _default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(SubscribeSetting);
exports["default"] = _default;
//# sourceMappingURL=SubscribeSetting.js.map