Merge branch 'feature-530' of https://e.coding.yili.com/yldc/ylst/ylst-survey-web into feature-530
This commit is contained in:
@@ -237,26 +237,41 @@ export default defineComponent({
|
||||
if (question.config.select_random) {
|
||||
// 行随机
|
||||
if (question.config.row_random) {
|
||||
question.config.row_option_groups.option_group =
|
||||
question.config.row_option_groups.option_group.sort(() => Math.random() - 0.5);
|
||||
question.config.row_option_groups.option_group.forEach((optionGroup) => {
|
||||
optionGroup.groups = optionGroup.groups.sort(() => Math.random() - 0.5);
|
||||
});
|
||||
// 组外随机
|
||||
if (question.config.option_group_random_outside) {
|
||||
question.config.row_option_groups.option_group =
|
||||
question.config.row_option_groups.option_group.sort(() => Math.random() - 0.5);
|
||||
}
|
||||
// 组内随机
|
||||
if (question.config.option_group_random_inside) {
|
||||
question.config.row_option_groups.option_group.forEach((optionGroup) => {
|
||||
optionGroup.groups = optionGroup.groups.sort(() => Math.random() - 0.5);
|
||||
});
|
||||
}
|
||||
}
|
||||
// 列随机
|
||||
if (question.config.cell_random) {
|
||||
question.config.cell_option_groups.option_group =
|
||||
question.config.cell_option_groups.option_group.sort(() => Math.random() - 0.5);
|
||||
question.config.cell_option_groups.option_group.forEach((optionGroup) => {
|
||||
optionGroup.groups = optionGroup.groups.sort(() => Math.random() - 0.5);
|
||||
});
|
||||
// 组外随机
|
||||
if (question.config.option_group_random_outside) {
|
||||
question.config.cell_option_groups.option_group =
|
||||
question.config.cell_option_groups.option_group.sort(() => Math.random() - 0.5);
|
||||
}
|
||||
// 组内随机
|
||||
if (question.config.option_group_random_inside) {
|
||||
question.config.cell_option_groups.option_group.forEach((optionGroup) => {
|
||||
optionGroup.groups = optionGroup.groups.sort(() => Math.random() - 0.5);
|
||||
});
|
||||
}
|
||||
}
|
||||
// 选项随机
|
||||
question.list.forEach((list) => {
|
||||
if (
|
||||
(list.type === 1 && question.config.row_random) ||
|
||||
(list.type === 2 && question.config.cell_random) ||
|
||||
(!question.config.row_random && !question.config.cell_random)
|
||||
(list.type === 1 &&
|
||||
question.config.row_random &&
|
||||
question.config.option_group_random_inside) ||
|
||||
(list.type === 2 &&
|
||||
question.config.cell_random &&
|
||||
question.config.option_group_random_inside)
|
||||
) {
|
||||
list.options = list.options.sort(() => Math.random() - 0.5);
|
||||
}
|
||||
|
||||
@@ -119,26 +119,41 @@ export default defineComponent({
|
||||
if (question.config.select_random) {
|
||||
// 行随机
|
||||
if (question.config.row_random) {
|
||||
question.config.row_option_groups.option_group =
|
||||
question.config.row_option_groups.option_group.sort(() => Math.random() - 0.5);
|
||||
question.config.row_option_groups.option_group.forEach((optionGroup) => {
|
||||
optionGroup.groups = optionGroup.groups.sort(() => Math.random() - 0.5);
|
||||
});
|
||||
// 组外随机
|
||||
if (question.config.option_group_random_outside) {
|
||||
question.config.row_option_groups.option_group =
|
||||
question.config.row_option_groups.option_group.sort(() => Math.random() - 0.5);
|
||||
}
|
||||
// 组内随机
|
||||
if (question.config.option_group_random_inside) {
|
||||
question.config.row_option_groups.option_group.forEach((optionGroup) => {
|
||||
optionGroup.groups = optionGroup.groups.sort(() => Math.random() - 0.5);
|
||||
});
|
||||
}
|
||||
}
|
||||
// 列随机
|
||||
if (question.config.cell_random) {
|
||||
question.config.cell_option_groups.option_group =
|
||||
question.config.cell_option_groups.option_group.sort(() => Math.random() - 0.5);
|
||||
question.config.cell_option_groups.option_group.forEach((optionGroup) => {
|
||||
optionGroup.groups = optionGroup.groups.sort(() => Math.random() - 0.5);
|
||||
});
|
||||
// 组外随机
|
||||
if (question.config.option_group_random_outside) {
|
||||
question.config.cell_option_groups.option_group =
|
||||
question.config.cell_option_groups.option_group.sort(() => Math.random() - 0.5);
|
||||
}
|
||||
// 组内随机
|
||||
if (question.config.option_group_random_inside) {
|
||||
question.config.cell_option_groups.option_group.forEach((optionGroup) => {
|
||||
optionGroup.groups = optionGroup.groups.sort(() => Math.random() - 0.5);
|
||||
});
|
||||
}
|
||||
}
|
||||
// 选项随机
|
||||
question.list.forEach((list) => {
|
||||
if (
|
||||
(list.type === 1 && question.config.row_random) ||
|
||||
(list.type === 2 && question.config.cell_random) ||
|
||||
(!question.config.row_random && !question.config.cell_random)
|
||||
(list.type === 1 &&
|
||||
question.config.row_random &&
|
||||
question.config.option_group_random_inside) ||
|
||||
(list.type === 2 &&
|
||||
question.config.cell_random &&
|
||||
question.config.option_group_random_inside)
|
||||
) {
|
||||
list.options = list.options.sort(() => Math.random() - 0.5);
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
:options="item.answer"
|
||||
class="lineSelect"
|
||||
placeholder="请选择"
|
||||
change-on-select
|
||||
/>
|
||||
<!-- 单选多选题select多选 radio单选 -->
|
||||
<a-select
|
||||
|
||||
@@ -199,6 +199,21 @@
|
||||
</a-select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="filterBox">
|
||||
<div class="filterBoxL">样本编码</div>
|
||||
<div class="filterBoxR flexBox">
|
||||
<a-textarea ref="textareaRef" @change="onChangeTextarea" @pressEnter="onPressEnter" @blur="onTextBlur" v-model:value="textareaValue" class="lineSelect maxSelect custom-input" :placeholder="placeholder" :rows="4" v-if="isFocus" />
|
||||
<div class="codeInput" @click="isFocus=true" v-else>
|
||||
<div class="codeContent">
|
||||
<span v-if="inputValue.length==0">{{ placeholder }}</span>
|
||||
<div v-else v-for="(item,index) in inputValue" :key="index" style="display: inline-block;">
|
||||
<span class="codeSpan">{{ item }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <a-input v-model:value="inputValue" @focus="isFocus=true" placeholder="请输入样本编码,多个请换行" class="lineSelect maxSelect custom-input" v-else /> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="isAllOpen">
|
||||
<div class="isAllOpenBtn" @click="isAllOpenClick" :class="{ act: isAllOpen }">{{ !isAllOpen ? '更多筛选类型' : '收起' }}<CaretDownFilled class="isAllOpenIcon" /></div>
|
||||
@@ -314,7 +329,7 @@ const logics = computed(() => {
|
||||
})
|
||||
const mark = [
|
||||
{label:'已标记',value:'1'},
|
||||
{label:'未标记',value:'2'}
|
||||
{label:'未标记',value:'0'}
|
||||
]
|
||||
const emit = defineEmits(['onSearch'])
|
||||
const route = useRoute()
|
||||
@@ -513,7 +528,7 @@ const showData = {
|
||||
// 配额逻辑
|
||||
logics: [],
|
||||
// 标记状态
|
||||
isMark: ['1','2']
|
||||
isMark: ['1','0']
|
||||
}
|
||||
const filterPlan = ref({
|
||||
// 方案
|
||||
@@ -530,6 +545,13 @@ const defaultData = ref(showData)
|
||||
// 题目答案列表
|
||||
const answerList = ref([{}])
|
||||
const answerGroupList = ref([])
|
||||
// 样本编码
|
||||
// 获取焦点
|
||||
const isFocus = ref(false)
|
||||
const textareaRef = ref()
|
||||
const textareaValue = ref('')
|
||||
const inputValue = ref([])
|
||||
const placeholder = ref('请输入样本编码,多个请换行')
|
||||
const getFilterData = () => {
|
||||
let fData = {
|
||||
// 筛选条件
|
||||
@@ -557,7 +579,9 @@ const getFilterData = () => {
|
||||
// 标记状态
|
||||
isMark: [],
|
||||
// 题目答案
|
||||
answer: []
|
||||
answer: [],
|
||||
// 样本编码
|
||||
sample_encoding:'',
|
||||
}
|
||||
if (filterData.value?.answer) {
|
||||
let nAnswer = filterData.value?.answer
|
||||
@@ -627,7 +651,7 @@ const getFilterData = () => {
|
||||
}
|
||||
// 标记状态
|
||||
if (filterData.value?.is_mark) {
|
||||
fData.isMark = filterData.value?.is_mark + ''
|
||||
fData.isMark = filterData.value?.is_mark?.split(',')
|
||||
}
|
||||
// 配额
|
||||
if (!filterData.value?.id) {
|
||||
@@ -683,6 +707,15 @@ const getFilterData = () => {
|
||||
fData.answerStatus = filterData.value?.answer_status.split(',')
|
||||
}
|
||||
}
|
||||
// 样本编码
|
||||
if (filterData.value?.sample_encoding) {
|
||||
fData.sample_encoding = filterData.value?.sample_encoding + ''
|
||||
inputValue.value = fData.sample_encoding.split(',') || []
|
||||
textareaValue.value = inputValue.value.join('\n') || ''
|
||||
}else{
|
||||
inputValue.value = []
|
||||
textareaValue.value = ''
|
||||
}
|
||||
let retData = { ...showData }
|
||||
if (isModal.value || isArt.value) {
|
||||
retData = { ...showData, ...fData }
|
||||
@@ -967,6 +1000,9 @@ const filterFormater = () => {
|
||||
// 标记状态
|
||||
if (searchObj.isMark.length > 0) subData.is_mark = searchObj.isMark.join()
|
||||
else subData.is_mark = ''
|
||||
// 样本编码
|
||||
if (inputValue.value.length > 0) subData.sample_encoding = inputValue.value.join()
|
||||
else subData.sample_encoding = ''
|
||||
console.log('subData', subData)
|
||||
// 记录条件
|
||||
store.dispatch('dataFilter/dataFilterInfo', subData)
|
||||
@@ -1033,6 +1069,10 @@ const clearInfo = (type) => {
|
||||
searchData.value.answerStatus = ['1']
|
||||
// 标记状态
|
||||
searchData.value.isMark = ['1','2']
|
||||
// 样本编码
|
||||
searchData.value.sample_encoding = ''
|
||||
inputValue.value = []
|
||||
textareaValue.value = ''
|
||||
// showData.answerStatusList.map((el) => {
|
||||
// searchData.value.answerStatus.push(el.value)
|
||||
// })
|
||||
@@ -1067,6 +1107,92 @@ const options2 = ref([
|
||||
label: 'Lucy'
|
||||
}
|
||||
])
|
||||
// 样本编码
|
||||
// 重复
|
||||
let repeat = ref(0)
|
||||
// 不符合
|
||||
let inconformity = ref(0)
|
||||
// 改变输入框
|
||||
const onChangeTextarea = (e)=> {
|
||||
let value = e.target.value.split('\n')
|
||||
let newValue = value.map((item)=>{
|
||||
item = item.replace(/[^\d]/g,'');
|
||||
return item
|
||||
})
|
||||
inputValue.value = newValue.filter((item) => {
|
||||
return item && item.trim();
|
||||
});
|
||||
textareaValue.value = newValue.join('\n')
|
||||
}
|
||||
// 回车
|
||||
const onPressEnter = (e)=> {
|
||||
let value = e.target.value.split('\n')
|
||||
let newValue = value.filter((item,index)=>
|
||||
{
|
||||
return value.indexOf(item) === index;
|
||||
});
|
||||
newValue = newValue.map((item,index)=>{
|
||||
item = item.replace(/[^\d]/g,'');
|
||||
return item.trim()
|
||||
})
|
||||
inputValue.value = newValue.filter((item) => {
|
||||
return item && item.trim();
|
||||
});
|
||||
e.target.value = newValue.join('\n')
|
||||
}
|
||||
|
||||
// 失焦
|
||||
const onTextBlur = ()=> {
|
||||
isFocus.value = false
|
||||
let arr = textareaValue.value.split('\n')
|
||||
let arr2 = noRepeat(arr)
|
||||
if(textareaValue.value && textareaValue.value!=0) {
|
||||
inputValue.value = arr2.filter((item) => {
|
||||
return item && item.trim();
|
||||
});
|
||||
}
|
||||
textareaValue.value = inputValue.value.join('\n')
|
||||
}
|
||||
// 去重,去不符合
|
||||
function noRepeat(arr){
|
||||
repeat.value = 0
|
||||
inconformity.value = 0
|
||||
let indexArr = []
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
for (var j = 0; j < arr.length; j++) {
|
||||
if (arr[i] == arr[j] && i != j) { //将后面重复的数删掉
|
||||
repeat.value++
|
||||
arr.splice(j, 1);
|
||||
}
|
||||
}
|
||||
if (/[^\d]/.test(arr[i])) {
|
||||
inconformity.value++
|
||||
indexArr.push(i)
|
||||
}
|
||||
}
|
||||
if(repeat.value > 0 && inconformity.value > 0){
|
||||
message.warning(`已过滤非样本编码${inconformity.value}个,重复样本编码${repeat.value}个!`)
|
||||
}else{
|
||||
if(repeat.value > 0) message.warning(`已过滤重复样本编码${repeat.value}个!`)
|
||||
if(inconformity.value > 0) message.warning(`已过滤非样本编码${inconformity.value}个!`)
|
||||
}
|
||||
if(indexArr.length > 0) {
|
||||
indexArr.map((item,index)=>{
|
||||
arr.splice(item-index, 1);
|
||||
})
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
watch (
|
||||
() => isFocus.value,
|
||||
(nval) => {
|
||||
if(nval) {
|
||||
nextTick(()=>{
|
||||
textareaRef.value.focus()
|
||||
})
|
||||
}
|
||||
}
|
||||
)
|
||||
// 默认全选
|
||||
watch(
|
||||
() => versions.value,
|
||||
@@ -1371,6 +1497,43 @@ defineExpose({
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.codeInput {
|
||||
width: 240px;
|
||||
min-height: 32px;
|
||||
max-height: 200px;
|
||||
overflow: auto;
|
||||
height: 100%;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #d9d9d9;
|
||||
background-color: #FFF;
|
||||
cursor: text;
|
||||
&:hover {
|
||||
transition: all 0.3s ease-in-out;
|
||||
border: 1px solid #70b936;
|
||||
}
|
||||
.codeContent {
|
||||
padding: 4px 12px;
|
||||
color: #bfbfbf;
|
||||
.codeSpan {
|
||||
display: inline-block;
|
||||
margin-right: 3px;
|
||||
color: #262626;
|
||||
background: #f5f5f5;
|
||||
border: 1px solid #F5F5F5;
|
||||
border-radius: 4px;
|
||||
max-width: 214px;
|
||||
height: 24px;
|
||||
margin-top: 2px;
|
||||
margin-bottom: 2px;
|
||||
padding: 0 8px;
|
||||
line-height: 22px;
|
||||
overflow: hidden;
|
||||
white-space: pre;
|
||||
-o-text-overflow: ellipsis;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
}
|
||||
.filterDelIcon {
|
||||
cursor: pointer;
|
||||
color: #dadada;
|
||||
|
||||
Reference in New Issue
Block a user