yylib-quick-mobile
Version:
yylib-quick-mobile
436 lines (375 loc) • 17.8 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
var _modal = require('antd-mobile/lib/modal');
var _modal2 = _interopRequireDefault(_modal);
var _button = require('antd-mobile/lib/button');
var _button2 = _interopRequireDefault(_button);
var _icon = require('antd-mobile/lib/icon');
var _icon2 = _interopRequireDefault(_icon);
var _list = require('antd-mobile/lib/list');
var _list2 = _interopRequireDefault(_list);
var _checkbox = require('antd-mobile/lib/checkbox');
var _checkbox2 = _interopRequireDefault(_checkbox);
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
require('antd-mobile/lib/modal/style/css');
require('antd-mobile/lib/button/style/css');
require('antd-mobile/lib/icon/style/css');
require('antd-mobile/lib/list/style/css');
require('antd-mobile/lib/checkbox/style/css');
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _rcForm = require('rc-form');
var _classnames = require('classnames');
var _classnames2 = _interopRequireDefault(_classnames);
var _YYToast = require('../toast/YYToast');
var _YYToast2 = _interopRequireDefault(_YYToast);
var _YYNavBar = require('../navBar/YYNavBar');
var _YYNavBar2 = _interopRequireDefault(_YYNavBar);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _FunctionUtil = require('../../utils/FunctionUtil');
var _RestUrl = require('../../common/RestUrl');
require('./YYApprove.less');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var CheckboxItem = _checkbox2.default.CheckboxItem;
var YYAssignRef = function (_React$Component) {
_inherits(YYAssignRef, _React$Component);
function YYAssignRef(props) {
_classCallCheck(this, YYAssignRef);
var _this = _possibleConstructorReturn(this, (YYAssignRef.__proto__ || Object.getPrototypeOf(YYAssignRef)).call(this, props));
_this.closeAssign = function () {
_this.setState({
AssignUser: _this.state.allUsers,
visible: false
});
if ((0, _FunctionUtil.isFunction)(_this.props.onClose)) {
_this.props.onClose();
}
};
_this.onAssignChange = function (selectedNode, i, activeKey) {
var selectedNodes = [],
selectConFirmParams = {},
paramIndex = 0,
newConfirmParams = JSON.parse(JSON.stringify(_this.conFirmParams));
newConfirmParams.map(function (item, index) {
if (item["activeKey"] === activeKey) {
selectConFirmParams = item;
selectedNodes = item["targetKeys"];
paramIndex = index;
return false;
}
});
if (!selectedNodes.some(function (item) {
return item === selectedNode;
})) {
selectedNodes.push(selectedNode);
_.set(selectConFirmParams, "targetKeys", selectedNodes);
} else {
var newNodes = [];
selectedNodes.forEach(function (item) {
if (item !== selectedNode) newNodes.push(item);
});
_.set(selectConFirmParams, "targetKeys", newNodes);
}
_this.conFirmParams[paramIndex] = selectConFirmParams;
_this.initDefaultChecked();
};
_this.initDefaultChecked = function () {
var _this$state = _this.state,
allUsers = _this$state.allUsers,
AssignUser = _this$state.AssignUser;
var searchUsers = [];
var AsearchUsers = [];
allUsers.forEach(function (item) {
var newParticipants = [];
item["participants"].forEach(function (value) {
var newChecked = false;
_this.conFirmParams.forEach(function (c) {
if (item["activityId"] === c["activeKey"]) {
c["targetKeys"].forEach(function (i) {
if (value["id"] === i) {
newChecked = true;
}
});
}
});
newParticipants.push({
"code": value["code"],
"id": value["id"],
"name": value["name"],
"org": value["org"],
"priority": value["priority"],
"type": value["type"],
"checked": newChecked
});
});
searchUsers.push({
"activityId": item["activityId"],
"activityName": item["activityName"],
"gatewayRule": item["gatewayRule"],
"participants": newParticipants
});
});
AssignUser.forEach(function (item, index) {
var newParticipants = [];
item["participants"].forEach(function (value, indexI) {
var newChecked = false;
_this.conFirmParams.forEach(function (c) {
if (item["activityId"] === c["activeKey"]) {
c["targetKeys"].forEach(function (i) {
if (value["id"] === i) {
newChecked = true;
}
});
}
});
newParticipants.push({
"code": value["code"],
"id": value["id"],
"name": value["name"],
"org": value["org"],
"priority": value["priority"],
"type": value["type"],
"checked": newChecked
});
});
AsearchUsers.push({
"activityId": item["activityId"],
"activityName": item["activityName"],
"gatewayRule": item["gatewayRule"],
"participants": newParticipants
});
});
_this.setState({
allUsers: searchUsers,
AssignUser: AsearchUsers
});
};
_this.comfirm = function () {
var onOff = true;
_this.conFirmParams.forEach(function (item) {
if (item["targetKeys"].length === 0) {
onOff = false;
}
});
if (onOff) {
_this.props.comfirm(_this.conFirmParams);
} else _YYToast2.default.fail('每个节点都必须选择参与者!', 2);
};
_this.onSearchSubmit = function (val) {
_this.activeOnOff = false;
if (val === '') {
_this.setState({
AssignUser: []
});
} else {
var allUsers = _this.state.allUsers;
var searchUsers = [];
allUsers.forEach(function (item, index) {
var newParticipants = [];
item["participants"].forEach(function (value) {
if (value.name.indexOf(val) !== -1) {
var newChecked = false;
_this.conFirmParams.forEach(function (c) {
if (item["activityId"] === c["activeKey"]) {
c["targetKeys"].forEach(function (i) {
if (value["id"] === i) {
newChecked = true;
}
});
}
});
newParticipants.push({
"code": value["code"],
"id": value["id"],
"name": value["name"],
"org": value["org"],
"priority": value["priority"],
"type": value["type"],
"checked": newChecked
});
}
});
searchUsers.push({
"activityId": item["activityId"],
"activityName": item["activityName"],
"gatewayRule": item["gatewayRule"],
"participants": newParticipants
});
});
_this.setState({
AssignUser: searchUsers
});
}
};
_this.renderAssignList = function (allUsers, num) {
var accordionDom = [];
var onOff = [];
allUsers.forEach(function (value) {
var AssignUser = value["participants"];
onOff.push(value["activityId"]);
accordionDom.push(_react2.default.createElement(
Accordion.Panel,
{ key: value["activityId"], header: value["activityName"],
className: 'yy-bpm-assignRef-modal-body-list' },
_react2.default.createElement(
_list2.default,
{ className: 'my-list' },
AssignUser && AssignUser.length > 0 ? AssignUser.map(function (i) {
return _react2.default.createElement(
CheckboxItem,
{ key: value["activityId"] + i.id, checked: i.checked,
onChange: function onChange() {
return _this.onAssignChange(i.id, i, value["activityId"]);
} },
i.name
);
}) : null
)
));
});
if (num === 2 && !_this.activeOnOff) _this.state.activeKey = onOff;
var renderDom = _react2.default.createElement(
Accordion,
{
activeKey: _this.state.activeKey,
onChange: function onChange(activeKey) {
_this.activeOnOff = true;
_this.setState({ activeKey: activeKey });
},
className: 'yy-bpm-assignRef-modal-body-list' },
accordionDom
);
return renderDom;
};
_this.state = {
visible: _this.props.visible,
activeKey: [],
AssignUser: [],
selectedNodes: [],
allUsers: [],
searchValue: ""
};
return _this;
}
_createClass(YYAssignRef, [{
key: 'componentDidMount',
value: function componentDidMount() {
var _this2 = this;
var ajax = window.YYUtils.Ajax;
console.log(1);
var _props = this.props,
visible = _props.visible,
type = _props.type,
bpmId = _props.bpmId,
userId = _props.userId;
var params = {
userId: userId,
cbiztypeId: "",
bpmId: bpmId,
approveType: "同意"
};
var url = '';
if (type != null && type == 'approve') {
url = _RestUrl.MODULE_URL.queryAssignUser;
} else if (type != null && type == 'submit') {
url = _RestUrl.MODULE_URL.queryStartAssignUser;
}
ajax.postText(url, params, function (AssignUserTextData) {
var AssignUserData = JSON.parse(AssignUserTextData);
if (AssignUserData.success && AssignUserData.success === true && AssignUserData.assignAble === true) {
var assignUserList = AssignUserData.data;
assignUserList.forEach(function (value, index) {
_this2.conFirmParams.push({ activeKey: value["activityId"], targetKeys: [] });
value["participants"].forEach(function (i) {
_.set(i, "activityId", value["activityId"]);
_.set(i, "checked", false);
});
});
_this2.setState({
allUsers: AssignUserData.data
});
} else {
_YYToast2.default.fail('没有审批权限!!', 2);
}
});
}
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextprops) {
if (nextprops.visible !== this.state.visible) {
this.setState({
visible: nextprops.visible
});
}
}
}, {
key: 'render',
value: function render() {
var _this3 = this;
var visible = this.state.visible;
return _react2.default.createElement(
'div',
{ className: 'yy-assign-ref' },
_react2.default.createElement(
_modal2.default,
{ popup: true,
visible: visible,
maskClosable: false,
animationType: 'slide-up'
},
_react2.default.createElement(
'div',
{ className: 'yy-bpm-assignRef-modal-body' },
_react2.default.createElement(
'div',
{ className: 'yy-bpm-assignRef-modal-body-nav' },
_react2.default.createElement(
_YYNavBar2.default,
{
mode: 'light',
leftContent: _react2.default.createElement(_icon2.default, { type: 'left' }),
onLeftClick: this.closeAssign },
'\u6307\u6D3E\u4E0B\u4E00\u73AF\u8282\u53C2\u4E0E\u4EBA'
),
_react2.default.createElement(SearchBar, {
placeholder: '\u641C\u7D22',
onSubmit: this.onSearchSubmit,
value: this.state.searchValue,
onChange: function onChange(searchValue) {
_this3.setState({ searchValue: searchValue });
},
onClear: function onClear() {
_this3.setState({ searchValue: "" });
},
onCancel: function onCancel() {
_this3.setState({ AssignUser: [], searchValue: "" });
} })
),
this.state.AssignUser["length"] === 0 ? this.renderAssignList(this.state.allUsers, 1) : this.renderAssignList(this.state.AssignUser, 2),
_react2.default.createElement(
'div',
null,
_react2.default.createElement(
_button2.default,
{ type: 'primary',
onClick: this.comfirm },
'\u786E\u5B9A'
)
)
)
)
);
}
}]);
return YYAssignRef;
}(_react2.default.Component);
YYAssignRef.defaultProps = {
userId: '',
billId: '' };
exports.default = YYAssignRef;
;