UNPKG

vue-ant-patterns

Version:

vue-ant-patterns

160 lines (149 loc) 4.36 kB
import _defineProperty from 'babel-runtime/helpers/defineProperty'; import PropTypes from 'ant-design-vue/es/_util/vue-types'; import cx from 'classnames'; import middleMixins from './middleMixins'; import middleData from './middleData.js'; var BQueryCondition = { name: 'BQueryCondition', mixins: [middleMixins], props: { prefixCls: PropTypes.string.def('depot-dqcondition'), dataType: PropTypes.oneOf(['String', // 字符串类型 'Short', // 短整型 'Integer', // 整型 'Long', // 长整型 'BigDecimal', // 'Float', // 浮点型 'Double', // 双精度浮点型 'Date', // 日期类型 'DateTo', // 日期范围类型 'Code', // 代码类型 'Enum', // 枚举类型 'SetId', // 表集合 'ComboBox', 'SearchHelper'] // 搜索助手类型(实际数据类型为String) ), // 数据类型 type code: PropTypes.string.def(''), // key code name: PropTypes.string.def('标题'), // 标题 name typeCode: PropTypes.string.def(''), // 常数代码code comboOptions: PropTypes.array.def([]), // comboOptions defaultValue: PropTypes.any }, data: function data() { var dataType = this.dataType, code = this.code, name = this.name; var fdata = middleData.find(function (_mitem) { return _mitem.dataType === dataType; }); var defaultValue = fdata.options[0].code; return { isInitialize: true, conditionData: { type: dataType, code: code, name: name, value: null, operator: defaultValue }, ovalue: this.defaultValue, operator: defaultValue, middleOptions: fdata.options }; }, watch: { defaultValue: function defaultValue(v) { this.ovalue = v; this.formatResValue(); } }, mounted: function mounted() { this.formatResValue(); }, methods: { // 条件标题 renderLabel: function renderLabel() { var h = this.$createElement; return h('span', [this.name]); }, // 构建中间条件 renderMiddel: function renderMiddel() { var h = this.$createElement; // defaultValue="Zhejiang" return h( 'a-select', { style: 'width:100%', attrs: { value: this.operator }, on: { 'change': this.changeMiddleValue } }, [this.middleOptions.map(function (_oitem) { return h( 'a-select-option', { attrs: { value: _oitem.code } }, [_oitem.title] ); })] ); }, // 构建输入框组件 renderControl: function renderControl() { var dataType = this.dataType; return this['render_Col_' + dataType](); }, // 构建返回值 formatResValue: function formatResValue() { var dataType = this.dataType, code = this.code, name = this.name, ovalue = this.ovalue, operator = this.operator; this.conditionData = { type: dataType, code: code, name: name, value: ovalue, operator: operator }; }, changeView: function changeView(obj) { // code: "c3" // dataType: "DateTo" // name: "日期" // operator: "" // value: null this.ovalue = obj.value; this.operator = obj.operator; this.formatResValue(); }, resetItem: function resetItem() { this.isInitialize = true; this.ovalue = this.defaultValue; this.operator = this.middleOptions[0].code; this.formatResValue(); } }, render: function render() { var h = arguments[0]; var prefixCls = this.prefixCls; var conditionItemProps = { 'class': cx(_defineProperty({}, '' + prefixCls, true)) }; var conlabelProps = { 'class': cx(_defineProperty({}, prefixCls + '-label', true)) }; var conminProps = { 'class': cx(_defineProperty({}, prefixCls + '-middle', true)) }; var concolProps = { 'class': cx(_defineProperty({}, prefixCls + '-control', true)) }; return h( 'd-container-h', conditionItemProps, [h( 'div', conlabelProps, [this.renderLabel()] ), h( 'div', conminProps, [this.renderMiddel()] ), h( 'div', concolProps, [this.renderControl()] )] ); } }; export default BQueryCondition;