UNPKG

yylib-quick-mobile

Version:

yylib-quick-mobile

716 lines (625 loc) 31.7 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _textareaItem = require('antd-mobile/lib/textarea-item'); var _textareaItem2 = _interopRequireDefault(_textareaItem); var _picker = require('antd-mobile/lib/picker'); var _picker2 = _interopRequireDefault(_picker); var _modal = require('antd-mobile/lib/modal'); var _modal2 = _interopRequireDefault(_modal); var _list = require('antd-mobile/lib/list'); var _list2 = _interopRequireDefault(_list); var _radio = require('antd-mobile/lib/radio'); var _radio2 = _interopRequireDefault(_radio); var _checkbox = require('antd-mobile/lib/checkbox'); var _checkbox2 = _interopRequireDefault(_checkbox); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; 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/textarea-item/style/css'); require('antd-mobile/lib/picker/style/css'); require('antd-mobile/lib/modal/style/css'); require('antd-mobile/lib/list/style/css'); require('antd-mobile/lib/radio/style/css'); require('antd-mobile/lib/checkbox/style/css'); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _rcForm = require('rc-form'); var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); var _YYIcon = require('./../icon/YYIcon'); var _YYIcon2 = _interopRequireDefault(_YYIcon); var _YYToast = require('./../toast/YYToast'); var _YYToast2 = _interopRequireDefault(_YYToast); var _YYRefer = require('./../refer/YYRefer'); var _YYRefer2 = _interopRequireDefault(_YYRefer); var _YYApproveHistory = require('./../bpm/YYApproveHistory'); var _YYApproveHistory2 = _interopRequireDefault(_YYApproveHistory); var _YYAssignRef = require('./../bpm/YYAssignRef'); var _YYAssignRef2 = _interopRequireDefault(_YYAssignRef); var _YYAddSignModal = require('./../bpm/YYAddSignModal'); var _YYAddSignModal2 = _interopRequireDefault(_YYAddSignModal); var _YYForm = require('./../form/YYForm'); var _YYForm2 = _interopRequireDefault(_YYForm); var _RestUrl = require('../../common/RestUrl'); require('./YYApprove.less'); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } 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 RadioItem = _radio2.default.RadioItem; var Item = _list2.default.Item; var prompt = _modal2.default.prompt; var alert = _modal2.default.alert; var YYApproveAction = function (_React$Component) { _inherits(YYApproveAction, _React$Component); function YYApproveAction() { var _ref; var _temp, _this, _ret; _classCallCheck(this, YYApproveAction); for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = YYApproveAction.__proto__ || Object.getPrototypeOf(YYApproveAction)).call.apply(_ref, [this].concat(args))), _this), _this.state = { comment: '同意!', bohuiValueRadio: ['提交人'], bohuiDate: [], showAssignRef: false, actionType: 'tongyi', counterSignAble: false, showAddsignRef: false, jiaqianModal: false, taskId: "", countersign: "", rejectVisible: false }, _this.getInfo = function () { var ajax = window.YYUtils.Ajax; var _this$props = _this.props, billTypeId = _this$props.billTypeId, userId = _this$props.userId, billId = _this$props.billId, approveType = _this$props.approveType; if (approveType !== '审批') return false; ajax.getText(_RestUrl.MODULE_URL.getBpmId, { 'billId': billId }, function (getBpmIdTextData) { var getBpmIdData = JSON.parse(getBpmIdTextData); if (getBpmIdData.success && getBpmIdData.success == true) { if (getBpmIdData.bpmId) { ajax.postText(_RestUrl.MODULE_URL.beforeReject, { 'bpmId': getBpmIdData.bpmId, 'userId': userId }, function (beforeRejectTextData) { var beforeRejectData = JSON.parse(beforeRejectTextData); _this.setState({ bpmId: getBpmIdData.bpmId, inPower: beforeRejectData.inPower, rejectAble: beforeRejectData.rejectAble, addsignAble: beforeRejectData.addsignAble, assignAble: beforeRejectData.assignAble, countersign: beforeRejectData["parenttaskid"] ? beforeRejectData["parenttaskid"] : "", counterSignAble: beforeRejectData.addsigninPower && beforeRejectData["addAisnInfo"]["addlotAble"] ? true : false, taskId: beforeRejectData.addsigninPower ? beforeRejectData["addAisnInfo"]["taskId"] : "", bohuiDate: beforeRejectData.data.array ? beforeRejectData.data.array : null }); }); } else { _YYToast2.default.info('没有审批历史', 2); } } else { _YYToast2.default.info('查看审批记录失败,请检查参数', 2); } }); }, _this.otherHandleClick = function (type) { var ajax = window.YYUtils.Ajax; var _this$props2 = _this.props, billTypeId = _this$props2.billTypeId, userId = _this$props2.userId, billId = _this$props2.billId, approveType = _this$props2.approveType, onOk = _this$props2.onOk; var url = null; if (type === '弃审') { url = _RestUrl.MODULE_URL.unapprove; } else if (type === '收回') { url = _RestUrl.MODULE_URL.doCallBack; } else { _YYToast2.default.info("approveType错误!", 2); return false; } if (!billId) { _YYToast2.default.info("找不到对应的表单!", 2); } else if (!billTypeId) { _YYToast2.default.info("找不到对应的单据类型!", 2); } else { _YYToast2.default.loading('Loading...', 0, null, false); ajax.postJSON(url, { userId: userId, billId: billId, billTypeId: billTypeId }, null, function (error) {}, function (data) { if (data != null && data.status == 200) { var param = eval("(" + data.text + ")"); if (param != null) { if (param.success == true && param.msg) { _YYToast2.default.success(param.msg, 2); } else { _YYToast2.default.info(param.msg, 2); } } } if (onOk && typeof onOk == "function") { onOk(JSON.parse(data.text)); } }); } }, _this.shouhuiClick = function () {}, _this.actionBtnClick = function (type) { var _this$state = _this.state, bohuiValueRadio = _this$state.bohuiValueRadio, bohuiDate = _this$state.bohuiDate, showAddsignRef = _this$state.showAddsignRef, addsingUser = _this$state.addsingUser; if (type === 'tongyi') { _this.setState({ actionType: type, comment: '同意!' }, function () { alert('同意', _react2.default.createElement(ActionModal, { actionType: _this.state.actionType, comment: _this.state.comment, onChangeComment: function onChangeComment(v) { return _this.setState({ comment: v }); } }), [{ text: '取消', onPress: function onPress() { return console.log('取消'); } }, { text: '确定', onPress: function onPress() { _this.beforeApprove(); } }]); }); } else if (type === 'bohui') { _this.setState({ actionType: type, comment: '驳回!', rejectVisible: true }); } else if (type === 'shenhe') { _this.setState({ actionType: type, comment: '已审核!' }, function () { alert('审核', _react2.default.createElement(ActionModal, { actionType: _this.state.actionType, comment: _this.state.comment, onChangeComment: function onChangeComment(v) { return _this.setState({ comment: v }); } }), [{ text: '取消', onPress: function onPress() { return console.log('取消'); } }, { text: '确定', onPress: function onPress() { _this.beforeApprove(); } }]); }); } else if (type === 'gaipai') { _this.setState({ actionType: type, comment: '改派!' }, function () { alert('改派', _react2.default.createElement(GaipAction, _extends({}, _this.props, { comment: _this.state.comment, onChangeComment: function onChangeComment(v) { return _this.setState({ comment: v }); }, showAddsignRef: showAddsignRef, addsingUser: addsingUser, onClose: function onClose() {}, onOk: function onOk(user) { return _this.setState({ addsingUser: user }); } })), [{ text: '取消', onPress: function onPress() { return console.log('取消'); } }, { text: '确定', onPress: function onPress() { _this.beforeApprove(); } }]); }); } else if (type === 'jiaqian') { _this.setState({ jiaqianModal: true }); } else { console.log('审批动作代码错误!'); } }, _this.beforeApprove = function () { var ajax = window.YYUtils.Ajax; var _this$state2 = _this.state, actionType = _this$state2.actionType, comment = _this$state2.comment, assignAble = _this$state2.assignAble, countersign = _this$state2.countersign; var opttype = 1; if (actionType === 'tongyi') opttype = 1;else if (actionType === 'bohui') opttype = 0; var param = { opttype: opttype, taskid: _this.state.countersign, comment: comment, assignee: _this.props.userId }; _this.setState({ comment: comment }, function () { if (assignAble !== null && assignAble === true && (actionType === 'tongyi' || actionType === 'shenhe')) { _this.showAssign(); } else if (countersign !== "") { ajax.postJSON(_RestUrl.MODULE_URL.completeSignTask, param, function (msg) { _this.setState({ rejectVisible: false }); if (msg.success && msg.success === true) { _YYToast2.default.success(msg.msg, 2); _this.getInfo(); } else { _YYToast2.default.fail(msg.msg, 2); } if (_this.props.onOk && typeof _this.props.onOk == "function") { _this.props.onOk(msg); } }); } else { _this.doApprove([]); } }); }, _this.doApprove = function (assign) { var _this$props3 = _this.props, userId = _this$props3.userId, billId = _this$props3.billId, billTypeId = _this$props3.billTypeId; var _this$state3 = _this.state, bpmId = _this$state3.bpmId, actionType = _this$state3.actionType, bohuiValueRadio = _this$state3.bohuiValueRadio, addsingUser = _this$state3.addsingUser, comment = _this$state3.comment, addsignAble = _this$state3.addsignAble; var opinionContent = null; if (actionType === 'tongyi') opinionContent = "同意";else if (actionType === 'bohui') opinionContent = "不同意且退回";else if (actionType === 'shenhe') opinionContent = "审核";else if (actionType === 'gaipai') { opinionContent = "改派"; if (!addsingUser) { _YYToast2.default.info("请选择需要改派处!", 2); return; } } var approveObject = {}; approveObject = { userId: userId, bill: { billTypeId: billTypeId, billId: billId, bpmId: bpmId }, bpmId: bpmId, approveType: opinionContent, comment: comment, delegateUser: actionType === 'gaipai' && addsingUser ? addsingUser.userId : null, activityId: bohuiValueRadio[0], assignAble: assign != null && assign.length > 0 ? true : false, assign: assign }; _this.onBpmApprove(approveObject); }, _this.onBpmApprove = function (data) { var ajax = window.YYUtils.Ajax; var url = ''; if (data.approveType == "同意" || data.approveType == "审核") { url = _RestUrl.MODULE_URL.doApprove; } else if (data.approveType == "改派") { url = _RestUrl.MODULE_URL.delegateTaskCompletely; } else if (data.approveType == "不同意且退回") { url = _RestUrl.MODULE_URL.disApprove; } _YYToast2.default.loading('Loading...', 0, null, false); ajax.postText(url, data, function (text) { var data = JSON.parse(text); if (data.success && data.success === true) { _YYToast2.default.success(data.msg, 2); _this.getInfo(); } else { _YYToast2.default.fail(data.msg, 2); } if (_this.props.onOk && typeof _this.props.onOk == "function") { _this.props.onOk(data); } }); }, _this.showAssign = function () { _this.setState({ showAssignRef: true }); }, _this.closeAssign = function () { _this.state.showAssignRef = false; }, _this.comfirmAssign = function (val) { _this.setState({ showAssignRef: false }); _this.doApprove([val]); }, _temp), _possibleConstructorReturn(_this, _ret); } _createClass(YYApproveAction, [{ key: 'componentDidMount', value: function componentDidMount() { this.getInfo(); } }, { key: 'render', value: function render() { var _this2 = this; var _props = this.props, billTypeId = _props.billTypeId, userId = _props.userId, approveType = _props.approveType, billId = _props.billId, onOk = _props.onOk, className = _props.className, restProps = _objectWithoutProperties(_props, ['billTypeId', 'userId', 'approveType', 'billId', 'onOk', 'className']); var _state = this.state, inPower = _state.inPower, rejectAble = _state.rejectAble, addsignAble = _state.addsignAble, counterSignAble = _state.counterSignAble, showAssignRef = _state.showAssignRef, jiaqianModal = _state.jiaqianModal, taskId = _state.taskId, countersign = _state.countersign, bohuiValueRadio = _state.bohuiValueRadio, bohuiDate = _state.bohuiDate, rejectVisible = _state.rejectVisible; var yyApproveActionCls = (0, _classnames2.default)('yy-approve-action', className); var bohuiCls = (0, _classnames2.default)('action-btn bohui', rejectAble || countersign !== "" ? '' : 'disabled'); var gaipaiCls = (0, _classnames2.default)('action-btn gaipai', addsignAble ? '' : 'disabled'); var shenheCls = (0, _classnames2.default)('action-btn shenhe', inPower && !rejectAble ? '' : 'disabled'); var jiaqianCls = (0, _classnames2.default)('action-btn shenhe', counterSignAble ? '' : 'disabled'); var tongyiCls = (0, _classnames2.default)('action-btn tongyi', rejectAble || countersign !== "" ? '' : 'disabled'); var AssignRef = showAssignRef ? _react2.default.createElement(_YYAssignRef2.default, { visible: showAssignRef, type: "approve", billTypeId: billTypeId, bpmId: this.state.bpmId, userId: userId, onClose: this.closeAssign, comfirm: this.comfirmAssign }) : null; var counterSignRef = jiaqianModal ? _react2.default.createElement(_YYAddSignModal2.default, { visible: jiaqianModal, type: "approve", billTypeId: billTypeId, bpmId: this.state.bpmId, taskId: taskId, userId: userId, onClose: function onClose() { _this2.setState({ jiaqianModal: false }); } }) : null; return _react2.default.createElement( 'div', _extends({ className: yyApproveActionCls }, restProps), approveType === '审批' ? _react2.default.createElement( 'div', null, AssignRef, counterSignRef, _react2.default.createElement( 'span', { className: bohuiCls, onClick: rejectAble || countersign !== "" ? this.actionBtnClick.bind(this, 'bohui') : null }, _react2.default.createElement(_YYIcon2.default, { className: 'action-icon', type: 'delete', size: 'xxs' }), '\u9A73\u56DE' ), _react2.default.createElement( 'span', { className: gaipaiCls, onClick: addsignAble ? this.actionBtnClick.bind(this, 'gaipai') : null }, _react2.default.createElement(_YYIcon2.default, { className: 'action-icon', type: 'edit', size: 'xxs' }), '\u6539\u6D3E' ), _react2.default.createElement( 'span', { className: shenheCls, onClick: inPower && !rejectAble ? this.actionBtnClick.bind(this, 'shenhe') : null }, _react2.default.createElement(_YYIcon2.default, { className: 'action-icon', type: 'screen', size: 'xxs' }), '\u5BA1\u6838' ), _react2.default.createElement( 'span', { className: jiaqianCls, onClick: counterSignAble ? this.actionBtnClick.bind(this, 'jiaqian') : null }, _react2.default.createElement(_YYIcon2.default, { className: 'action-icon', type: 'jiaqian', size: 'xxs' }), '\u52A0\u7B7E' ), _react2.default.createElement( 'span', { className: tongyiCls, onClick: rejectAble || countersign !== "" ? this.actionBtnClick.bind(this, 'tongyi') : null }, _react2.default.createElement(_YYIcon2.default, { className: 'action-icon', type: 'upload', size: 'xxs' }), '\u540C\u610F' ) ) : _react2.default.createElement( 'span', { className: 'block', onClick: this.otherHandleClick.bind(this, approveType) }, approveType ), _react2.default.createElement( _modal2.default, { visible: rejectVisible, transparent: true, maskClosable: false, title: '\u9A73\u56DE', footer: [{ text: '取消', onPress: function onPress() { _this2.setState({ rejectVisible: false, bohuiValueRadio: [] }); } }, { text: '确定', onPress: function onPress() { if (_this2.state.bohuiValueRadio.length === 0 && countersign === "") { _YYToast2.default.fail("请选择需要退回的节点", 1.5); } else { _this2.beforeApprove(); } } }] }, _react2.default.createElement(ActionModal, { actionType: 'bohui', comment: this.state.comment, onChangeComment: function onChangeComment(v) { return _this2.setState({ comment: v }); }, bohuiDate: bohuiDate, countersign: countersign, bohuiValueRadio: bohuiValueRadio, onChange: function onChange(v) { return _this2.setState({ bohuiValueRadio: v }); }, onOk: function onOk(v) { return _this2.setState({ bohuiValueRadio: v }); } }) ) ); } }]); return YYApproveAction; }(_react2.default.Component); YYApproveAction.propTypes = { billTypeId: _propTypes2.default.string, userId: _propTypes2.default.string, billId: _propTypes2.default.string, approveType: _propTypes2.default.string }; YYApproveAction.defaultProps = { billTypeId: '', userId: '', billId: '', approveType: '审批' }; exports.default = YYApproveAction; var ActionModal = function (_React$Component2) { _inherits(ActionModal, _React$Component2); function ActionModal(props) { _classCallCheck(this, ActionModal); var _this3 = _possibleConstructorReturn(this, (ActionModal.__proto__ || Object.getPrototypeOf(ActionModal)).call(this, props)); _this3.onChangeComment = function (v) { _this3.setState({ comment: v }, function () { _this3.props.onChangeComment(v); }); }; _this3.onChange = function (v) { _this3.setState({ bohuiValueRadio: v }, function () { _this3.props.onChange(v); }); }; _this3.onOk = function (v) { _this3.setState({ bohuiValueRadio: v }, function () { _this3.props.onOk(v); }); }; _this3.state = { actionType: _this3.props.actionType, comment: _this3.props.comment, bohuiValueRadio: _this3.props.bohuiValueRadio }; return _this3; } _createClass(ActionModal, [{ key: 'render', value: function render() { var bohuiDate = this.props.bohuiDate; var pickerDate = [{ label: '提交人', value: '提交人' }]; if (bohuiDate && bohuiDate.length > 0) { for (var i = 0; i < bohuiDate.length; i++) { pickerDate.push({ label: bohuiDate[i].activityName, value: bohuiDate[i].activityId }); } } var _state2 = this.state, actionType = _state2.actionType, comment = _state2.comment, bohuiValueRadio = _state2.bohuiValueRadio; return _react2.default.createElement( 'div', null, actionType === 'bohui' && this.props.countersign === "" ? _react2.default.createElement( _picker2.default, { data: pickerDate, title: '\u9009\u62E9\u9A73\u56DE\u5904', cols: 1, value: bohuiValueRadio, onChange: this.onChange, onOk: this.onOk }, _react2.default.createElement( Item, { arrow: 'horizontal' }, '\u6D41\u7A0B\u9000\u56DE\u81F3' ) ) : null, _react2.default.createElement(_textareaItem2.default, { style: { border: '1px solid #f4f4f4', borderRadius: '2px', marginLeft: '-4px', padding: '1px' }, placeholder: '\u8BF7\u8F93\u5165\u5BA1\u6279\u8BED...', value: comment, onChange: this.onChangeComment, rows: 2 }) ); } }]); return ActionModal; }(_react2.default.Component); var GaipActionForm = function (_React$Component3) { _inherits(GaipActionForm, _React$Component3); function GaipActionForm(props) { _classCallCheck(this, GaipActionForm); var _this4 = _possibleConstructorReturn(this, (GaipActionForm.__proto__ || Object.getPrototypeOf(GaipActionForm)).call(this, props)); _this4.onChangeComment = function (v) { _this4.setState({ comment: v }, function () { _this4.props.onChangeComment(v); }); }; _this4.showAddsign = function () { _this4.setState({ showAddsignRef: true }); }; _this4.onClose = function () { _this4.setState({ showAddsignRef: false }, function () { _this4.props.onClose(); }); }; _this4.onOk = function (user) { _this4.setState({ showAddsignRef: false, addsingUser: user }, function () { _this4.props.onOk(user); }); }; _this4.state = { comment: _this4.props.comment, showAddsignRef: _this4.props.showAddsignRef, addsingUser: _this4.props.addsingUser }; return _this4; } _createClass(GaipActionForm, [{ key: 'render', value: function render() { var form = this.props.form; var _state3 = this.state, comment = _state3.comment, showAddsignRef = _state3.showAddsignRef, addsingUser = _state3.addsingUser; return _react2.default.createElement( 'div', null, _react2.default.createElement( Item, { arrow: 'horizontal', onClick: this.showAddsign, extra: addsingUser ? addsingUser.name : '请选择' }, '\u6D41\u7A0B\u6539\u6D3E\u81F3' ), _react2.default.createElement(_YYRefer2.default, { referlabel: '\u6D41\u7A0B\u6539\u6D3E\u81F3', form: form, referName: 'Addsign', onOk: this.onOk, onClose: this.onClose, multiMode: false, open: showAddsignRef, referCode: '00081', referStyle: 'list' }), _react2.default.createElement(_textareaItem2.default, { style: { border: '1px solid #f4f4f4', borderRadius: '2px', marginLeft: '-4px', padding: '1px' }, placeholder: '\u8BF7\u8F93\u5165\u5BA1\u6279\u8BED...', value: comment, onChange: this.onChangeComment, rows: 2 }) ); } }]); return GaipActionForm; }(_react2.default.Component); var GaipAction = _YYForm2.default.create()(GaipActionForm);