Commit 4c04b444 by jml0128

fix

1 parent 3386169d
......@@ -188,3 +188,17 @@ export const date = {
return _fmt;
}
};
export const keepLastIndex = (obj, focusOffset) => {
if (window.getSelection) {
obj.focus(); //解决ff不获取焦点无法定位问题
var range = window.getSelection(); //创建range
// range.selectAllChildren(obj); //range 选择obj下所有子内容
range.collapse(obj.firstChild, focusOffset); //光标移至最后
} else if (document.selection) {
var rangeForIE = document.selection.createRange(); //创建选择对象
rangeForIE.moveToElementText(obj); //range定位到obj
rangeForIE.collapse(obj, focusOffset); //光标移至最后
rangeForIE.select();
}
};
......@@ -8,11 +8,7 @@
<div
class="bi-chart-choice-mixin-toggle-axis_sub_title"
:contenteditable="contenteditable"
@input="
event => {
$emit('change-title', event.target.innerText);
}
"
@input="input"
>
{{ customGroupTitle || dealAxis.join('与') }}
</div>
......@@ -36,6 +32,7 @@
import mixin from '../mixin/index';
import { Button } from 'element-ui';
import BiBlank from './blank.vue';
import { keepLastIndex } from '../chart-type/common';
export default {
name: 'bi-chart-choice-mixin-toggle-axis',
mixins: [mixin],
......@@ -57,6 +54,13 @@ export default {
}
},
methods: {
input(event) {
const focusOffset = window.getSelection().focusOffset;
this.$emit('change-title', event.target.innerText);
this.$nextTick(() => {
keepLastIndex(event.target, focusOffset);
});
},
toggle() {
this.$emit('toggle-axis');
}
......
......@@ -8,11 +8,7 @@
<div
class="bi-chart-title_name"
:contenteditable="contenteditable"
@input="
event => {
$emit('change-title', event.target.innerText);
}
"
@input="input"
>
<!-- {{ `${name}`.slice(0, 36) }}{{ `${name}`.length > 36 ? '...' : '' }} -->
{{ name }}
......@@ -107,6 +103,7 @@ import BiTypesChart from './types-chart.vue';
import mixin from '../mixin/index';
import types from '../chart-type/types';
import eventBus from '../eventBus';
import { keepLastIndex } from '../chart-type/common';
export default {
name: 'bi-chart-title',
mixins: [mixin],
......@@ -153,6 +150,13 @@ export default {
}
},
methods: {
input(event) {
const focusOffset = window.getSelection().focusOffset;
this.$emit('change-title', event.target.innerText);
this.$nextTick(() => {
keepLastIndex(event.target, focusOffset);
});
},
changeColors(colors) {
this.visibleColors = false;
this.$emit('change-colors', colors);
......
......@@ -3,7 +3,7 @@
* @Author: jml
* @Date: 2021-03-24 10:22:27
* @LastEditors: Please set LastEditors
* @LastEditTime: 2021-07-04 13:13:05
* @LastEditTime: 2021-07-04 17:12:14
-->
<template>
<div class="bi-table">
......@@ -21,12 +21,12 @@
<template v-for="(cItem, cIndex) in item">
<td v-if="Array.isArray(cItem)" id="lineTd" :key="cIndex">
<span
style="float:left;margin-top:20px;padding-left:5px;width:150px;"
style="float:left;margin-top:20px;padding-left:5px;width:50%;text-align: left;"
>
{{ cItem[0] }}
</span>
<span
style="float:right;margin-top:-15px;padding-right:5px;width:150px;"
style="float:right;margin-top:-15px;padding-right:5px;width:50%;text-align: right;"
>
{{ cItem[1] }}
</span>
......@@ -90,7 +90,10 @@ export default {
dealData() {
const { data, isSingle, title, axis } = this;
return [
[isSingle ? title : [axis[1].name, axis[0].name], ...axis[0].names],
[
isSingle ? title : [axis[1].factorName, axis[0].factorName],
...axis[0].names
],
...data.map((item, index) => {
return [isSingle ? '数量' : axis[1].names[index], ...item];
})
......
......@@ -94,6 +94,7 @@ import { Popover, Button } from 'element-ui';
import { Swiper, SwiperSlide } from 'vue-awesome-swiper';
import 'swiper/swiper-bundle.css';
import mixin, { printWidth } from '../mixin/index';
import { keepLastIndex } from '../chart-type/common';
export default {
name: 'bi-cover',
mixins: [mixin],
......@@ -132,8 +133,12 @@ export default {
},
computed: {
chooseBackground() {
const a = this.coverList.find(item => item.id == this.coverId) ||
this.coverList[0] || {
const a =
this.coverList.find(item => item.id == this.coverId) || this.coverUrl
? {
templatePicUrl: this.coverUrl
}
: this.coverList[0] || {
templatePicUrl: this.coverUrl
};
return a;
......@@ -203,20 +208,9 @@ export default {
off(document, 'touchmove', this._dragHandler);
});
},
keepLastIndex(obj) {
if (window.getSelection) {
obj.focus(); //解决ff不获取焦点无法定位问题
var range = window.getSelection(); //创建range
range.selectAllChildren(obj); //range 选择obj下所有子内容
range.collapseToEnd(); //光标移至最后
} else if (document.selection) {
var rangeForIE = document.selection.createRange(); //创建选择对象
rangeForIE.moveToElementText(obj); //range定位到obj
rangeForIE.collapse(false); //光标移至最后
rangeForIE.select();
}
},
input(event, index, maxLength) {
const range = window.getSelection(); //创建range
const focusOffset = range.focusOffset;
try {
const { innerText } = event.target;
if (
......@@ -224,11 +218,14 @@ export default {
this.content[index]['name'].length === maxLength
) {
event.target.innerText = this.content[index]['name'];
this.keepLastIndex(event.target);
return;
}
const text = `${innerText}`.slice(0, maxLength);
this.content[index]['name'] = text;
this.$nextTick(() => {
keepLastIndex(event.target, focusOffset);
});
} catch (error) {
console.log(error);
}
......
......@@ -128,8 +128,12 @@ export const chartConfig = () => {
colors[0],
data: data,
axis: [
{ factorName: xFactor, name: xAxisName, names: x },
{ factorName: yFactor, name: yAxisName, names: y }
{ factorName: xFactor, name: '您的医保类型( )', names: x },
{
factorName: yFactor,
name: '日常药物的选择,您更偏向( )',
names: y
}
],
width: width,
height: height,
......
......@@ -315,6 +315,7 @@ export default {
legendName: '总参与项目执行人数${num}人',
hideDesc: true,
hideDelete: true,
dontContenteditable: true,
width: 520,
height: 350,
disableTypes: [3, 4],
......@@ -328,6 +329,7 @@ export default {
legendName: '总参与项目执行人数${num}人',
hideDesc: true,
hideDelete: true,
dontContenteditable: true,
width: 520,
height: 350,
disableTypes: [3, 4]
......@@ -346,6 +348,7 @@ export default {
blockTitle: '项目参与人完成任务区间分布',
legendName: '总参与项目执行人数${num}人',
hideDelete: true,
dontContenteditable: true,
height: 400,
disableTypes: [3, 4]
})
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!