Elements-SY

modify

......@@ -183,18 +183,16 @@ export default {
methods: {
getTrCurrentHeight: debounce(function () {
this.$nextTick(() => {
// const trEl =
// this.$refs.tableRef.$refs.bodyWrapper.children[0].children[1]
// .children[0];
// console.log(trEl)
// if (trEl) {
// this.trHeight = trEl.clientHeight;
// }
// const trEl =
// this.$refs.tableRef.$refs.bodyWrapper.children[0].children[1]
// .children[0];
// console.log(trEl)
// if (trEl) {
// this.trHeight = trEl.clientHeight;
// }
});
}, 800),
// 给表头列添加className
headerCellClassName({ row, column, rowIndex, columnIndex }) {
if (columnIndex !== 0) {
......@@ -255,6 +253,10 @@ export default {
sort: this.attrs.isDragSort,
animation: 100,
delay: 0,
onStart(evt) {
// console.log("onStart:", evt);
evt.oldIndex;
},
onEnd({ newIndex, oldIndex }) {
// console.log("onEnd:", newIndex, oldIndex);
const currRow = _this.tableData.splice(oldIndex, 1)[0];
......
This diff is collapsed. Click to expand it.
......@@ -11,10 +11,10 @@
formWidth="auto"
@blur="blurEvent"
>
<yl-draggable
<route-draggable
:routeList="routeList"
:dragOptions="dragOptions"
></yl-draggable>
></route-draggable>
</yl-form>
</el-col>
</el-row>
......@@ -49,8 +49,8 @@
</template>
<script>
import YlForm from "@/components/YlForm";
import RouteInfo from "../components/routeInfo";
import YlDraggable from "@/components/YlDraggable";
import RouteInfo from "../components/RouteInfo";
import RouteDraggable from "../components/RouteDraggable";
import { formConfig, routeRuleForm, validateForm } from "./formConfig";
import {
updateOrAddFlight, // 新增/修改航线规则设置
......@@ -64,7 +64,7 @@ export default {
components: {
YlForm,
RouteInfo,
YlDraggable,
RouteDraggable,
},
mixins: [indexMixins],
data() {
......@@ -105,7 +105,7 @@ export default {
dataStatus: this.$route.query.dataStatus || "", // add 、edit、view
flightKindName: this.$route.query.flightKindName || "", // 航班种类White Tail 、Purple Tail
pageName: this.$route.query.pageName || "", //
id: this.$route.query.id,
id: this.$route.query.id || "",
};
// 指定隐藏或显示From表单域
this.hiddenFormItem(parmas);
......
......@@ -405,8 +405,8 @@ export default {
if (this.$route.query.flightKindName == "Purple Tail") {
this.showFlightKind(dateDataLists);
}
}
if (dateConfigFlag == false) {
} else {
// 当前航线有缺省的航线配置
// 航班航线有规则配置的
const dateListHas = mergeDateRouteInfo.filter(
(item) => item.config == true
......
import YlElInputNumber from "./src/input-number";
/* istanbul ignore next */
YlElInputNumber.install = function (Vue) {
Vue.component(YlElInputNumber.name, YlElInputNumber);
};
export default YlElInputNumber;
<template>
<div
@dragstart.prevent
:class="[
'el-input-number',
inputNumberSize ? 'el-input-number--' + inputNumberSize : '',
{ 'is-disabled': inputNumberDisabled },
{ 'is-without-controls': !controls },
{ 'is-controls-right': controlsAtRight }
]">
<span
class="el-input-number__decrease"
role="button"
v-if="controls"
@click="decrease"
:class="{'is-disabled': minDisabled}"
@keydown.enter="decrease">
<i :class="`el-icon-${controlsAtRight ? 'arrow-down' : 'minus'}`"></i>
</span>
<span
class="el-input-number__increase"
role="button"
v-if="controls"
@click="increase"
:class="{'is-disabled': maxDisabled}"
@keydown.enter="increase">
<i :class="`el-icon-${controlsAtRight ? 'arrow-up' : 'plus'}`"></i>
</span>
<el-input
ref="input"
:value="displayValue"
:placeholder="placeholder"
:disabled="inputNumberDisabled"
:size="inputNumberSize"
:max="max"
:min="min"
:name="name"
:label="label"
@keydown.up.native.prevent="increase"
@keydown.down.native.prevent="decrease"
@blur="handleBlur"
@focus="handleFocus"
@input="handleInput"
@change="handleInputChange">
</el-input>
</div>
</template>
<script>
import ElInput from 'element-ui/packages/input';
import Focus from 'element-ui/src/mixins/focus';
import RepeatClick from 'element-ui/src/directives/repeat-click';
export default {
name: 'YlElInputNumber',
mixins: [Focus('input')],
inject: {
elForm: {
default: ''
},
elFormItem: {
default: ''
}
},
directives: {
repeatClick: RepeatClick
},
components: {
ElInput
},
props: {
step: {
type: Number,
default: 1
},
stepStrictly: {
type: Boolean,
default: false
},
max: {
type: Number,
default: Infinity
},
min: {
type: Number,
default: -Infinity
},
value: {},
disabled: Boolean,
size: String,
controls: {
type: Boolean,
default: true
},
controlsPosition: {
type: String,
default: ''
},
name: String,
label: String,
placeholder: String,
precision: {
type: Number,
validator(val) {
return val >= 0 && val === parseInt(val, 10);
}
}
},
data() {
return {
currentValue: 0,
userInput: null
};
},
watch: {
value: {
immediate: true,
handler(value) {
let newVal = value === undefined ? value : Number(value);
if (newVal !== undefined) {
if (isNaN(newVal)) {
return;
}
if (this.stepStrictly) {
const stepPrecision = this.getPrecision(this.step);
const precisionFactor = Math.pow(10, stepPrecision);
newVal = Math.round(newVal / this.step) * precisionFactor * this.step / precisionFactor;
}
if (this.precision !== undefined) {
newVal = this.toPrecision(newVal, this.precision);
}
}
if (newVal >= this.max) newVal = this.max;
if (newVal <= this.min) newVal = this.min;
this.currentValue = newVal;
this.userInput = null;
this.$emit('input', newVal);
}
}
},
computed: {
minDisabled() {
return this._decrease(this.value, this.step) < this.min;
},
maxDisabled() {
return this._increase(this.value, this.step) > this.max;
},
numPrecision() {
const { value, step, getPrecision, precision } = this;
const stepPrecision = getPrecision(step);
if (precision !== undefined) {
if (stepPrecision > precision) {
console.warn('[Element Warn][InputNumber]precision should not be less than the decimal places of step');
}
return precision;
} else {
return Math.max(getPrecision(value), stepPrecision);
}
},
controlsAtRight() {
return this.controls && this.controlsPosition === 'right';
},
_elFormItemSize() {
return (this.elFormItem || {}).elFormItemSize;
},
inputNumberSize() {
return this.size || this._elFormItemSize || (this.$ELEMENT || {}).size;
},
inputNumberDisabled() {
return this.disabled || !!(this.elForm || {}).disabled;
},
displayValue() {
if (this.userInput !== null) {
return this.userInput;
}
let currentValue = this.currentValue;
if (typeof currentValue === 'number') {
if (this.stepStrictly) {
const stepPrecision = this.getPrecision(this.step);
const precisionFactor = Math.pow(10, stepPrecision);
currentValue = Math.round(currentValue / this.step) * precisionFactor * this.step / precisionFactor;
}
if (this.precision !== undefined) {
currentValue = currentValue.toFixed(this.precision);
}
}
return currentValue;
}
},
methods: {
toPrecision(num, precision) {
if (precision === undefined) precision = this.numPrecision;
return parseFloat(Math.round(num * Math.pow(10, precision)) / Math.pow(10, precision));
},
getPrecision(value) {
if (value === undefined) return 0;
const valueString = value.toString();
const dotPosition = valueString.indexOf('.');
let precision = 0;
if (dotPosition !== -1) {
precision = valueString.length - dotPosition - 1;
}
return precision;
},
_increase(val, step) {
if (typeof val !== 'number' && val !== undefined) return this.currentValue;
const precisionFactor = Math.pow(10, this.numPrecision);
// Solve the accuracy problem of JS decimal calculation by converting the value to integer.
return this.toPrecision((precisionFactor * val + precisionFactor * step) / precisionFactor);
},
_decrease(val, step) {
if (typeof val !== 'number' && val !== undefined) return this.currentValue;
const precisionFactor = Math.pow(10, this.numPrecision);
return this.toPrecision((precisionFactor * val - precisionFactor * step) / precisionFactor);
},
increase() {
if (this.inputNumberDisabled || this.maxDisabled) return;
const value = this.value || 0;
const newVal = this._increase(value, this.step);
this.setCurrentValue(newVal);
},
decrease() {
if (this.inputNumberDisabled || this.minDisabled) return;
const value = this.value || 0;
const newVal = this._decrease(value, this.step);
this.setCurrentValue(newVal);
},
handleBlur(event) {
this.$emit('blur', event);
},
handleFocus(event) {
this.$emit('focus', event);
},
setCurrentValue(newVal) {
const oldVal = this.currentValue;
if (typeof newVal === 'number' && this.precision !== undefined) {
newVal = this.toPrecision(newVal, this.precision);
}
if (newVal >= this.max) newVal = this.max;
if (newVal <= this.min) newVal = this.min;
if (oldVal === newVal) return;
this.userInput = null;
this.$emit('input', newVal);
this.$emit('change', newVal, oldVal);
this.currentValue = newVal;
},
handleInput(value) {
this.userInput = value;
},
handleInputChange(value) {
const newVal = value === '' ? undefined : Number(value);
if (!isNaN(newVal) || value === '') {
this.setCurrentValue(newVal);
}
this.userInput = null;
},
select() {
this.$refs.input.select();
}
},
mounted() {
let innerInput = this.$refs.input.$refs.input;
innerInput.setAttribute('role', 'spinbutton');
innerInput.setAttribute('aria-valuemax', this.max);
innerInput.setAttribute('aria-valuemin', this.min);
innerInput.setAttribute('aria-valuenow', this.currentValue);
innerInput.setAttribute('aria-disabled', this.inputNumberDisabled);
},
updated() {
if (!this.$refs || !this.$refs.input) return;
const innerInput = this.$refs.input.$refs.input;
innerInput.setAttribute('aria-valuenow', this.currentValue);
}
};
</script>
......@@ -23,6 +23,7 @@
</el-col>
</el-row>
<yl-table
ref="ylTable"
emptyText="请添加配舱航班"
:attrs="tableAttr"
:loadingTable="tableAttr.loadingTable"
......@@ -63,27 +64,17 @@
align="center"
>
<template slot-scope="scope">
<el-input-number
<yl-el-input-number
v-model="scope.row.calculateDay"
:disabled="scope.row.edit"
:precision="0"
:controls="true"
v-input-filter
clearable
placeholder=""
size="small"
style="width: 100%"
/>
<!-- <el-input
type="text"
v-model="scope.row.calculateDay"
:disabled="scope.row.edit"
min="-7"
max="7"
v-input-filter
clearable
placeholder=""
size="small"
/> -->
</template>
</el-table-column>
<el-table-column
......@@ -431,6 +422,7 @@
<script>
import YlForm from "@/components/YlForm";
import YlTable from "@/components/YlTable";
import YlElInputNumber from "../components/input-number"
import { inputBlurValidate } from "@/utils/mixins";
import { tableAttr } from "./tableConfig";
import {
......@@ -448,6 +440,7 @@ export default {
components: {
YlForm,
YlTable,
YlElInputNumber
},
mixins: [indexMixins, inputBlurValidate],
data() {
......@@ -752,7 +745,7 @@ export default {
// 表单提交
submitForm(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
if (valid && this.validateForm) {
this.tableData.map((item, i) => {
item.priority = ++i;
});
......@@ -793,6 +786,7 @@ export default {
flightRankDtoList: tableData, // ET86配舱航班顺位
fltRuleDto: this.queryForm,
};
let queryParmas = JSON.parse(JSON.stringify(parmas));
// 筛选重复的航班
let repeat = tableData.filter(
(item) =>
......@@ -808,17 +802,17 @@ export default {
this.msgError("ET86配舱航班顺位中存在重复设置");
return;
}
parmas.fltRuleDto.multiHs = this.queryForm.multiHs ? "N" : "Y"; // N为单品名,Y为多品名
queryParmas.fltRuleDto.multiHs = this.queryForm.multiHs ? "N" : "Y"; // N为单品名,Y为多品名
if (this.validateForm && this.$route.query.name == "add") {
this.postAdd(parmas); // 新增
this.postAdd(queryParmas); // 新增
} else {
if (this.validateForm) {
parmas.flightRankDtoList.map((item) => {
queryParmas.flightRankDtoList.map((item) => {
if (item.hasOwnProperty("routeList")) {
delete item.routeList;
}
});
this.postUpdate(parmas); // 修改
this.postUpdate(queryParmas); // 修改
}
}
} else {
......
......@@ -129,20 +129,20 @@ export default {
};
// ursa包含
if (ursaMark && ursaInfo.repeat) {
this.ursaError = "填写的Ursa已重复";
this.ursaError = "填写的URSA已重复";
}
if (ursaMark && !ursaInfo.inUrsa) {
this.ursaError = "Ursa包含之间用分号分隔,例:P2_;P3_;P_";
this.ursaError = "URSA包含之间用分号分隔,例:P2_;P3_;P_";
}
if (ursaMark && !ursaInfo.repeat && ursaInfo.inUrsa) {
this.ursaError = "";
}
// ursa不包含;
if (!ursaMark && ursaInfo.repeat) {
this.notUrsaError = "填写的Ursa已重复";
this.notUrsaError = "填写的URSA已重复";
}
if (!ursaMark && !ursaInfo.inUrsa) {
this.notUrsaError = "Ursa不包含之间用分号分隔,例:P2;P3;P";
this.notUrsaError = "URSA不包含之间用分号分隔,例:P2;P3;P";
}
if (!ursaMark && !ursaInfo.repeat && ursaInfo.inUrsa) {
this.notUrsaError = "";
......