UNPKG

ming-demo3

Version:
1,307 lines (1,163 loc) 43.8 kB
"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 _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); 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 _DraggableArea = _interopRequireDefault(require("./DraggableArea")); var _baseui = require("@mdf/baseui"); var _row = _interopRequireDefault(require("../basic/row")); var _col = _interopRequireDefault(require("../basic/col")); var _input = _interopRequireDefault(require("../basic/input")); var _InputSearch = _interopRequireDefault(require("../common/InputSearch")); var _SvgIcon = _interopRequireDefault(require("@mdf/metaui-web/lib/components/common/SvgIcon")); var _util = require("@mdf/cube/lib/helpers/util"); var RadioGroup = _baseui.Radio.Group; var leftDisabledKeys = []; var DimensionSetting = function (_Component) { (0, _inherits2["default"])(DimensionSetting, _Component); function DimensionSetting(props) { var _this; (0, _classCallCheck2["default"])(this, DimensionSetting); _this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(DimensionSetting).call(this, props)); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onRightButtonClick", function () { var _this$state = _this.state, checkedItem = _this$state.checkedItem, selectedItems = _this$state.selectedItems, checkedData = _this$state.checkedData, rightIndex = _this$state.rightIndex; if (checkedItem) { selectedItems.push(checkedItem); var _checkedData = []; _checkedData.push(checkedItem); _checkedData = _checkedData.map(function (v) { v.checked = false; return v; }); checkedData[rightIndex] = checkedData[rightIndex].concat(_checkedData); } _this.setState({ selectedNum: 0, checkedItem: null, selectedItems: selectedItems, checkedData: checkedData }); _this.checkmock(checkedData); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "ShowList", function () { document.body.addEventListener('click', _this.handleBodyClick); _this.setState({ bShowList: !_this.state.bShowList }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleCancel", function (e) { leftDisabledKeys = []; var editDimension = _this.state.editDimension; editDimension.name = ""; editDimension.isDefault = false; editDimension.bEdit = false; var checkedData = [[]]; checkedData.push([]); _this.setState({ bShowCard: false, selectedNum: 0, checkedItem: null, selectedItems: [], keyWord: "", editDimension: editDimension, checkedData: checkedData, editId: '', rightIndex: 0 }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleOk", function (e) { var _this$state2 = _this.state, billnum = _this$state2.billnum, editDimension = _this$state2.editDimension, selectedItems = _this$state2.selectedItems, checkedData = _this$state2.checkedData, editId = _this$state2.editId; if (editDimension.name == "") { cb.utils.alert("名称不可为空。"); return; } var checked_Data = checkedData.filter(function (t) { return t.length; }); if (checked_Data.length == 0) { cb.utils.alert("请添加数据项到已选区域!"); return; } if (checked_Data.length > 3) { cb.utils.alert("最多只支持三级维度导航!"); return; } var selected = []; checked_Data.forEach(function (ele, index) { ele.forEach(function (ele) { selected.push({ fieldname: ele.fieldname, caption: ele.caption, groupType: 0, level: index + 1 }); }); }); var params = { billnum: billnum, name: editDimension.name, isDefault: editDimension.isDefault, selected: selected, type: 2, isPc: true, id: editId ? editId : null }; _this.onOk(params); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "editDimension_SetValue", function (fieldName, fieldValue) { var editDimension = _this.state.editDimension; editDimension[fieldName] = fieldValue; _this.setState({ editDimension: editDimension }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "selectItems", function (fieldname, bSelected) { var _this$state3 = _this.state, dimensionItems = _this$state3.dimensionItems, selectedNum = _this$state3.selectedNum, checkedItem = _this$state3.checkedItem; if (bSelected == true) { if (selectedNum == 1) { cb.utils.alert("每次只能选择一个数据项!", 'error'); return; } dimensionItems.forEach(function (ele, index) { if (ele.fieldname == fieldname) { ele.bSelected = true; checkedItem = ele; } }); _this.setState({ dimensionItems: dimensionItems, selectedNum: 1, checkedItem: checkedItem }); return; } dimensionItems.forEach(function (ele, index) { if (ele.fieldname == fieldname) { ele.bSelected = false; } }); _this.setState({ dimensionItems: dimensionItems, selectedNum: 0, checkedItem: null }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "SetKeyWord", function (fieldValue) { _this.setState({ keyWord: fieldValue }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleBodyClick", function (e) { if (e.target && cb.dom(e.target).parents('div.ant-popover').length) return; if (e.target.parentElement.className == "ant-input-group-addon") return; if (e.target.parentElement.className == "ant-popover-open") return; if (e.target.tagName == "CANVAS") return; if (e.target.parentElement.parentElement.className == "ant-popover-open") return; if (e.target.parentElement.className == "ant-input-wrapper ant-input-group") return; document.body.removeEventListener('click', _this.handleBodyClick); _this.setState({ bShowList: false }); }); var _checkedData2 = [[]]; _checkedData2.push([]); var viewModel = props.viewModel, cStyle = props.cStyle; var _viewModel$getParams = viewModel.getParams(), billNo = _viewModel$getParams.billNo; _this.initDimensionListValue(billNo); _this.state = { cStyle: cStyle && JSON.parse(cStyle), selectedNum: 0, checkedItem: null, selectedItems: [], dimensionItems: [], billnum: billNo, keyWord: "", bShowCard: false, bShowList: false, textMouseEnterId: -1, currentName: "", currentId: '', dimensionList: [], editDimension: { bEdit: false, name: "", isDefault: false }, uncheckedData: [], checkedData: _checkedData2, rightIndex: 0, isEnterInput: false, editId: '' }; _this.setModel(viewModel); return _this; } (0, _createClass2["default"])(DimensionSetting, [{ key: "setModel", value: function setModel(viewModel) { var _this2 = this; this.model = new cb.models.SimpleModel({ needClear: false }); viewModel.setCache("dimensionModel", this.model); this.model.on("changeDimension", function (obj) { return _this2.modelChange(obj); }); } }, { key: "setModelValue", value: function setModelValue(value) { this.model.setValue(value); } }, { key: "setModelCache", value: function setModelCache(dimensionList) { this.model.setCache("dimensionList", dimensionList); } }, { key: "modelChange", value: function modelChange(obj) { this.chooseDimension(obj.id, ""); } }, { key: "componentDidMount", value: function componentDidMount() {} }, { key: "changeTags", value: function changeTags(tags, index) { var checkedData = this.state.checkedData; checkedData[index] = tags; this.checkmock(checkedData); } }, { key: "uncheckedSort", value: function uncheckedSort(uncheckedData) { return uncheckedData.sort(function (a, b) { return a.id - b.id; }); } }, { key: "changeunchecked", value: function changeunchecked(tags) { tags[tags.length - 1].checked = false; this.setState({ uncheckedData: this.uncheckedSort(tags) }); } }, { key: "handleClickDelete", value: function handleClickDelete(tag, index) { leftDisabledKeys = leftDisabledKeys.filter(function (t) { return t !== tag.fieldname; }); var _this$state4 = this.state, checkedData = _this$state4.checkedData, dimensionItems = _this$state4.dimensionItems, selectedItems = _this$state4.selectedItems; selectedItems = selectedItems.filter(function (t) { return t.fieldname !== tag.fieldname; }); dimensionItems.forEach(function (ele, index) { if (ele.fieldname == tag.fieldname) { ele.bSelected = false; } }); index = this.findIndex(checkedData, index); var Tags = checkedData[index].filter(function (t) { return tag.id !== t.id; }); checkedData[index] = Tags; this.setState({ selectedItems: selectedItems, dimensionItems: dimensionItems, checkedData: checkedData }); } }, { key: "findIndex", value: function findIndex(checkedData, index) { for (var i = index; i < checkedData.length; i++) { if (!checkedData[i].length) { index++; } else { break; } } return index; } }, { key: "handelClick", value: function handelClick(rightIndex) { this.setState({ rightIndex: rightIndex }); } }, { key: "handleTagTriggerClick", value: function handleTagTriggerClick(_index, index, e) { var checkedData = this.state.checkedData; checkedData = checkedData.map(function (value, _I) { return value.map(function (val, _i) { if (_I !== _index || _i !== index) { val.checked = false; } else { val.checked = true; } return val; }); }); this.setState({ checkedData: checkedData }); } }, { key: "checkmock", value: function checkmock(checkedData) { checkedData = checkedData.filter(function (t) { return t.length; }); checkedData.push([]); this.setState({ checkedData: checkedData }); } }, { key: "checkedUncheckedData", value: function checkedUncheckedData(tag, index, e) { var uncheckedData = this.state.uncheckedData; uncheckedData[index].checked = e.target.checked; this.setState({ uncheckedData: uncheckedData }); } }, { key: "initDimensionListValue", value: function () { var _initDimensionListValue = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(billNo) { var _this3 = this; var config, json, defaultItem, currentId, currentName; return _regenerator["default"].wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: config = { url: 'report/getDimensions', method: 'GET', params: { billnum: billNo } }; _context.next = 3; return (0, _util.proxy)(config); case 3: json = _context.sent; if (!(json.code !== 200)) { _context.next = 7; break; } cb.utils.alert('获取维度列表失败!' + json.message, 'error'); return _context.abrupt("return"); case 7: defaultItem = json.data.filter(function (ele) { return ele.isDefault == true; }); currentId = defaultItem.length !== 0 ? defaultItem[0].id : ''; currentName = defaultItem.length !== 0 ? defaultItem[0].name : ''; this.setState({ dimensionList: json.data, currentId: currentId, currentName: currentName }); this.setModelValue(currentId); this.setModelCache(json.data); this.props.viewModel.execute('dimensionChanged', { dimensionId: currentId }); this.props.viewModel.on('refreshEChartConfig', function (params) { var tmpId = -1; var tmpName = ""; var dimensionList = _this3.state.dimensionList; var presetItem = params.dimensionId && dimensionList.filter(function (ele) { return ele.id == params.dimensionId; }); if (presetItem && presetItem.length > 0) { tmpId = params.dimensionId; tmpName = presetItem[0].name; } else { dimensionList && dimensionList.forEach(function (ele, index) { if (ele.isDefault == true || index == 0) { tmpId = ele.id; tmpName = ele.name; } }); } if (tmpId > 0) { _this3.setModelValue(tmpId); if (_this3.state.currentId != tmpId) { _this3.setState({ currentId: tmpId, currentName: tmpName }); } _this3.props.viewModel.execute('dimensionChanged', { dimensionId: tmpId }); } }); case 15: case "end": return _context.stop(); } } }, _callee, this); })); function initDimensionListValue(_x) { return _initDimensionListValue.apply(this, arguments); } return initDimensionListValue; }() }, { key: "refreshDimensionListValue", value: function () { var _refreshDimensionListValue = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(billNo) { var config, json; return _regenerator["default"].wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: config = { url: 'report/getDimensions', method: 'GET', params: { billnum: billNo } }; _context2.next = 3; return (0, _util.proxy)(config); case 3: json = _context2.sent; if (!(json.code !== 200)) { _context2.next = 7; break; } cb.utils.alert('获取维度列表失败!' + json.message, 'error'); return _context2.abrupt("return"); case 7: this.setState({ dimensionList: json.data }); this.setModelCache(json.data); case 9: case "end": return _context2.stop(); } } }, _callee2, this); })); function refreshDimensionListValue(_x2) { return _refreshDimensionListValue.apply(this, arguments); } return refreshDimensionListValue; }() }, { key: "getDimensionItems", value: function () { var _getDimensionItems = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3(billNo) { var config, json; return _regenerator["default"].wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: config = { url: 'report/getGroupItems', method: 'GET', params: { billnum: billNo } }; _context3.next = 3; return (0, _util.proxy)(config); case 3: json = _context3.sent; if (!(json.code !== 200)) { _context3.next = 7; break; } cb.utils.alert('获取数据失败!' + json.message, 'error'); return _context3.abrupt("return"); case 7: json.data.unselected.forEach(function (ele, index) { ele.id = ele.fieldname; }); this.setState({ dimensionItems: json.data.unselected }); case 9: case "end": return _context3.stop(); } } }, _callee3, this); })); function getDimensionItems(_x3) { return _getDimensionItems.apply(this, arguments); } return getDimensionItems; }() }, { key: "onOk", value: function () { var _onOk = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4(params) { var config, json, _this$state5, editDimension, editId, currentId; return _regenerator["default"].wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: config = { url: 'report/saveDimensionSchema', method: 'POST', params: params }; _context4.next = 3; return (0, _util.proxy)(config); case 3: json = _context4.sent; if (!(json.code !== 200)) { _context4.next = 7; break; } cb.utils.alert('保存失败!' + json.message, 'error'); return _context4.abrupt("return"); case 7: cb.utils.alert("保存成功!", 'success'); leftDisabledKeys = []; this.refreshDimensionListValue(this.state.billnum); _this$state5 = this.state, editDimension = _this$state5.editDimension, editId = _this$state5.editId, currentId = _this$state5.currentId; if (editId == currentId) { this.props.viewModel.execute('dimensionChanged', { dimensionId: editId }); } editDimension.name = ""; editDimension.isDefault = false; editDimension.bEdit = false; this.setState({ rightIndex: 0, bShowCard: false, selectedNum: 0, checkedItem: null, selectedItems: [], keyWord: "", editDimension: editDimension, checkedData: [[], []], editId: '' }); case 16: case "end": return _context4.stop(); } } }, _callee4, this); })); function onOk(_x4) { return _onOk.apply(this, arguments); } return onOk; }() }, { key: "getDimensionCardRender", value: function getDimensionCardRender() { var _this4 = this; var editDimension = this.state.editDimension; var bEdit = editDimension.bEdit; var content; if (this.state.bShowCard == true) { var card; card = this.getInnerRender(); content = _react["default"].createElement(_baseui.Modal, { className: "crossGroupingModal addDimension", title: bEdit ? "编辑" : "新增维度导航方案", onOk: function onOk(e) { return _this4.handleOk(e); }, onCancel: function onCancel(e) { return _this4.handleCancel(e); }, visible: true }, card); } return content; } }, { key: "onTextMouseEnter", value: function onTextMouseEnter(bEnter) { this.setState({ isEnterInput: bEnter }); } }, { key: "onMouseEnter", value: function onMouseEnter(bEnter, e, id) { var dimensionList = this.state.dimensionList; if (dimensionList && dimensionList.length > 0) { dimensionList.forEach(function (ele, index) { if (ele.id == id) ele.isMouseEnter = bEnter; }); } this.setState({ dimensionList: dimensionList }); } }, { key: "handelClick", value: function handelClick(rightIndex) { this.setState({ rightIndex: rightIndex }); } }, { key: "getInnerRender", value: function getInnerRender() { var _this5 = this; var self = this; var _this$state6 = this.state, editDimension = _this$state6.editDimension, dimensionItems = _this$state6.dimensionItems, selectedItems = _this$state6.selectedItems, checkedData = _this$state6.checkedData, rightIndex = _this$state6.rightIndex; checkedData = checkedData.filter(function (v) { return v.length; }); checkedData.push([]); var leftContentRender = [], rightContentRender = []; selectedItems.forEach(function (ele, index) { leftDisabledKeys.push(ele.fieldname); rightContentRender.push(_react["default"].createElement(_baseui.Tag, null, ele.caption)); }); dimensionItems.forEach(function (ele, index) { if (ele.caption.indexOf(self.state.keyWord) > -1) { var bChecked = ele.bSelected ? true : false; var bDisabled = leftDisabledKeys.indexOf(ele.fieldname) > -1 ? true : false; leftContentRender.push(_react["default"].createElement(_row["default"], null, _react["default"].createElement(_baseui.Checkbox, { checked: bChecked, disabled: bDisabled, onChange: function onChange(e) { return self.selectItems(ele.fieldname, e.target.checked); } }, ele.caption))); } }); return _react["default"].createElement("div", null, _react["default"].createElement("br", null), _react["default"].createElement(_row["default"], { colCount: 12, className: "crosstype" }, _react["default"].createElement(_col["default"], { span: 1, className: "crosstypeName crosstypeline" }, _react["default"].createElement("i", { className: "anticon anticon-star nametitlemarginstar" }), "\u540D\u79F0"), _react["default"].createElement(_col["default"], { span: 1 }), _react["default"].createElement(_col["default"], { span: 4, className: "crosstypeNameList crossinput" }, _react["default"].createElement(_baseui.Input, { defaultValue: editDimension.name, onChange: function onChange(e) { return _this5.editDimension_SetValue("name", e.target.value); } }), " "), _react["default"].createElement(_col["default"], { span: 1 }), _react["default"].createElement(_col["default"], { span: 5, className: "crosscheckbox" }, _react["default"].createElement(_baseui.Checkbox, { checked: editDimension.isDefault, onChange: function onChange(e) { return _this5.editDimension_SetValue("isDefault", e.target.checked); } }, "\u8BBE\u4E3A\u9ED8\u8BA4"))), _react["default"].createElement("br", null), _react["default"].createElement(_row["default"], { colCount: 12 }, _react["default"].createElement(_col["default"], { span: 5, className: "crossadddata" }, _react["default"].createElement("div", null, _react["default"].createElement(_row["default"], { className: "crossaddnamemargin" }, "\u6DFB\u52A0\u6570\u636E\u9879"), _react["default"].createElement("div", { className: "crossselectborder" }, _react["default"].createElement(_InputSearch["default"], { placeholder: "\u8BF7\u8F93\u5165\u5173\u952E\u5B57", value: this.state.keyWord, onChange: function onChange(value) { return _this5.SetKeyWord(value.currentTarget.value); }, onDelete: function onDelete() { return _this5.SetKeyWord(""); } }), _react["default"].createElement(_row["default"], { className: "crossadddatalist" }, leftContentRender)))), _react["default"].createElement(_col["default"], { span: 2, className: "crossbtncount dimension" }, _react["default"].createElement(_baseui.Button, { className: "icon-right-enabled", onClick: this.onRightButtonClick })), _react["default"].createElement(_col["default"], { span: 5, className: "selecteddata" }, _react["default"].createElement("div", null, _react["default"].createElement(_row["default"], { className: "crossaddnamemargin" }, "\u5DF2\u9009\u6570\u636E\u9879", _react["default"].createElement("span", { style: { color: 'red' } }, "\uFF08\u6700\u591A\u652F\u6301\u4E09\u7EA7\u5BFC\u822A\uFF09")), _react["default"].createElement("div", { className: "groupCondition-SelectedItem" }, _react["default"].createElement("div", { className: "crossArea" }, _react["default"].createElement("div", { className: "fr crossArea-list" }, checkedData.map(function (value, index) { return _react["default"].createElement("div", { key: 'crossArea-list' + index, onClick: function onClick() { return _this5.handelClick(index); }, className: "crossArea-list-content", style: { left: 63 + index * 27 + 'px', top: index * 46 + 'px' } }, checkedData.length - 1 !== index ? index == 0 ? _react["default"].createElement(_baseui.Button, { size: 'small' }, _react["default"].createElement(_baseui.Icon, { type: "tianjiashuliang" })) : _react["default"].createElement(_baseui.Button, { size: 'small' }, _react["default"].createElement(_baseui.Icon, { type: "jianshaoshuliang" })) : null, _react["default"].createElement(_DraggableArea["default"], { dragChecked: rightIndex === index, handleTagTriggerClick: function handleTagTriggerClick(_index, index, e) { _this5.handleTagTriggerClick(_index, index, e); }, clickDelete: function clickDelete(tag, index) { _this5.handleClickDelete(tag, index); }, Tags: value, index: index, changeTags: function changeTags(tag, index) { return _this5.changeTags(tag, index); }, selectedItems: selectedItems })); })))))))); } }, { key: "setDefaultItem", value: function () { var _setDefaultItem = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee5(id, name) { var billnum, config, json; return _regenerator["default"].wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: billnum = this.state.billnum; config = { url: 'report/saveDimensionSchema', method: 'POST', params: { billnum: billnum, id: id, isDefault: true, name: name } }; _context5.next = 4; return (0, _util.proxy)(config); case 4: json = _context5.sent; if (!(json.code !== 200)) { _context5.next = 8; break; } cb.utils.alert('操作失败!' + json.message, 'error'); return _context5.abrupt("return"); case 8: this.refreshDimensionListValue(this.state.billnum); case 9: case "end": return _context5.stop(); } } }, _callee5, this); })); function setDefaultItem(_x5, _x6) { return _setDefaultItem.apply(this, arguments); } return setDefaultItem; }() }, { key: "editDimensionInfo", value: function () { var _editDimensionInfo = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee6(id) { var config, json, _this$state7, editDimension, dimensionItems, selectedItems, selectedData, level_1, level_2, level_3; return _regenerator["default"].wrap(function _callee6$(_context6) { while (1) { switch (_context6.prev = _context6.next) { case 0: this.setState({ editId: id, rightIndex: 0 }); this.getDimensionItems(this.state.billnum); config = { url: '/report/getDimensionSetting', method: 'GET', params: { billnum: this.state.billnum, dimensionId: id } }; _context6.next = 5; return (0, _util.proxy)(config); case 5: json = _context6.sent; if (!(json.code !== 200)) { _context6.next = 9; break; } cb.utils.alert('获取数据失败!' + json.message, 'error'); return _context6.abrupt("return"); case 9: _this$state7 = this.state, editDimension = _this$state7.editDimension, dimensionItems = _this$state7.dimensionItems, selectedItems = _this$state7.selectedItems; editDimension.bEdit = true; editDimension.name = json.data.name; editDimension.isDefault = json.data.isDefault; json.data.selected.forEach(function (ele, index) { leftDisabledKeys.push(ele.fieldname); }); if (dimensionItems) { dimensionItems.forEach(function (ele, index) { if (leftDisabledKeys.indexOf(ele.fieldname) > -1) { ele.bSelected = true; selectedItems.push(ele); } }); } selectedData = []; if (json.data.selected) { level_1 = json.data.selected.filter(function (t) { return t.level == 1; }); level_2 = json.data.selected.filter(function (t) { return t.level == 2; }); level_3 = json.data.selected.filter(function (t) { return t.level == 3; }); if (level_1.length !== 0) { level_1.forEach(function (ele) { ele.id = ele.fieldname; }); selectedData.push(level_1); } if (level_2.length !== 0) { level_2.forEach(function (ele) { ele.id = ele.fieldname; }); selectedData.push(level_2); } if (level_3.length !== 0) { level_3.forEach(function (ele) { ele.id = ele.fieldname; }); selectedData.push(level_3); } } selectedData = selectedData.filter(function (t) { return t.length !== 0; }); selectedData.push([]); this.setState({ bShowCard: true, bShowList: false, editDimension: editDimension, checkedData: selectedData, dimensionItems: dimensionItems, selectedItems: selectedItems }); case 20: case "end": return _context6.stop(); } } }, _callee6, this); })); function editDimensionInfo(_x7) { return _editDimensionInfo.apply(this, arguments); } return editDimensionInfo; }() }, { key: "deleteDimension", value: function () { var _deleteDimension = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee7(id, name) { var config, json; return _regenerator["default"].wrap(function _callee7$(_context7) { while (1) { switch (_context7.prev = _context7.next) { case 0: config = { url: '/report/deleteGroupSchema', method: 'GET', params: { groupSchemaId: id } }; _context7.next = 3; return (0, _util.proxy)(config); case 3: json = _context7.sent; if (!(json.code !== 200)) { _context7.next = 7; break; } cb.utils.alert('操作失败!' + json.message, 'error'); return _context7.abrupt("return"); case 7: if (name == this.state.currentName) { this.setState({ currentName: "", currentId: '' }); } this.refreshDimensionListValue(this.state.billnum); case 9: case "end": return _context7.stop(); } } }, _callee7, this); })); function deleteDimension(_x8, _x9) { return _deleteDimension.apply(this, arguments); } return deleteDimension; }() }, { key: "getDimensionListRender", value: function getDimensionListRender() { var _this7 = this; var canEdit = true; if (this.state.cStyle && this.state.cStyle.disableUserSetting == true) { canEdit = false; } var dimensionList = this.state.dimensionList; var currentId = this.state.currentId; var renderList = []; var bAuthAdd = this.state.bAuthAdd; var bAuthEdit = this.state.bAuthEdit; var bAuthDel = this.state.bAuthDel; if (this.state.bIgnoreAuth === true) { bAuthAdd = true; bAuthEdit = true; bAuthDel = true; } if (dimensionList && dimensionList.length > 0) { dimensionList.forEach(function (element, index) { var _this6 = this; var item; var isChecked = element.id == currentId ? true : false; var itemChecked = isChecked ? _react["default"].createElement("span", { className: "groupCondition-Checked" }, _react["default"].createElement("i", { className: "anticon icon-xuanzhong1", checked: isChecked }), " ") : _react["default"].createElement("span", { className: "groupCondition-Checked" }, " "); var isDefault = element.isDefault ? element.isDefault : false; var itemDefault = isDefault ? _react["default"].createElement("span", { className: "groupCondition-Default" }, " ", _react["default"].createElement("span", { className: "crossdefault-btn" }, "\u9ED8\u8BA4"), " ") : _react["default"].createElement("span", { className: "groupCondition-Default" }, " "); var isMouseEnter = element.isMouseEnter ? element.isMouseEnter : false; var itemEnter = isMouseEnter ? canEdit ? _react["default"].createElement("span", { className: "groupCondition-MouseEnter" }, isDefault ? null : _react["default"].createElement("span", { onClick: function onClick() { return _this6.setDefaultItem(element.id, element.name); } }, "\u8BBE\u4E3A\u9ED8\u8BA4"), _react["default"].createElement("span", { onClick: function onClick() { return _this6.editDimensionInfo(element.id); } }, "\u8BBE\u7F6E"), _react["default"].createElement("span", { onClick: function onClick() { return _this6.deleteDimension(element.id, element.name); } }, "\u5220\u9664")) : _react["default"].createElement("span", { className: "groupCondition-MouseEnter" }, " ") : _react["default"].createElement("span", { className: "groupCondition-MouseEnter" }, " "); item = _react["default"].createElement(_row["default"], { style: { minHeight: "25px" }, onMouseEnter: function onMouseEnter(e) { return _this6.onMouseEnter(true, e, element.id); }, onMouseLeave: function onMouseLeave(e) { return _this6.onMouseEnter(false, e, element.id); } }, itemChecked, _react["default"].createElement("span", { style: { cursor: "pointer" }, onClick: function onClick() { return _this6.chooseDimension(element.id, element.name); } }, " ", element.name), itemDefault, itemEnter); renderList.push(item); }, this); } var addItem = canEdit ? _react["default"].createElement("div", { className: "group-add-grouping" }, _react["default"].createElement("div", { onClick: function onClick() { return _this7.addDimensionInfo(); } }, _react["default"].createElement(_SvgIcon["default"], { type: "plus" }), "\u65B0\u589E\u7EF4\u5EA6\u5BFC\u822A\u65B9\u6848")) : null; return _react["default"].createElement("div", { className: "group-add-grouping-count " + (canEdit == false ? "group-add-grouping-count-noauth" : "") }, _react["default"].createElement("div", { style: { overflow: "auto", maxHeight: "258px", paddingBottom: "2px" } }, renderList), addItem); } }, { key: "addDimensionInfo", value: function addDimensionInfo() { this.getDimensionItems(this.state.billnum); this.setState({ bShowCard: true, bShowList: false }); } }, { key: "chooseDimension", value: function chooseDimension(id, name) { if (id && name == "") { var tmp = _.find(this.state.dimensionList, function (o) { return o.id == id; }); name = tmp ? tmp.name : name; } this.setModelValue(id); this.props.viewModel.execute('dimensionChanged', { dimensionId: id }); this.setState({ currentName: name, currentId: id, bShowList: false }); } }, { key: "render", value: function render() { var _this8 = this; var bNeedClose = this.state.currentName && this.state.isEnterInput ? true : false; var type = this.state.bShowList ? "up" : "down"; var button = _react["default"].createElement("div", null, bNeedClose ? _react["default"].createElement(_baseui.Icon, { onClick: function onClick() { return _this8.chooseDimension(); }, type: "close-circle" }) : null, _react["default"].createElement(_baseui.Icon, { onClick: function onClick() { return _this8.ShowList(); }, type: type })); var dimensionList = null; dimensionList = this.getDimensionListRender(); var dimensionPop = _react["default"].createElement("div", null, _react["default"].createElement("div", { className: "Grouping-condition-left" }, "\u7EF4\u5EA6\u5BFC\u822A\u65B9\u6848"), _react["default"].createElement(_baseui.Popover, { overlayStyle: { width: "236px" }, content: dimensionList, trigger: "click", visible: this.state.bShowList }, _react["default"].createElement("div", { className: "Grouping-condition" }, _react["default"].createElement("div", { className: "Grouping-condition-input", onMouseEnter: function onMouseEnter() { return _this8.onTextMouseEnter(true); }, onMouseLeave: function onMouseLeave() { return _this8.onTextMouseEnter(false); } }, _react["default"].createElement("span", { className: "Grouping-condition-span", style: { cursor: "pointer" }, onClick: function onClick() { return _this8.ShowList(); }, overlayStyle: { width: "100px" } }, this.state.currentName), button)))); var dimensionCard = this.getDimensionCardRender(); return _react["default"].createElement("div", { className: "groupCondition" }, dimensionPop, dimensionCard); } }]); return DimensionSetting; }(_react.Component); var _default = DimensionSetting; exports["default"] = _default; //# sourceMappingURL=DimensionSetting.js.map