Commit 4c04b444 by jml0128

fix

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