|
@@ -1,5 +1,5 @@
|
|
|
import { Tag, Image, Button } from 'vant'
|
|
|
-import { computed, defineComponent, nextTick, onMounted, PropType, reactive } from 'vue'
|
|
|
+import { computed, defineComponent, nextTick, onMounted, PropType, reactive, watch } from 'vue'
|
|
|
import { AnswerType, labelOptions, QuestionType } from '../../unit'
|
|
|
import Draggable from 'vuedraggable'
|
|
|
import styles from './index.module.less'
|
|
@@ -61,7 +61,7 @@ export default defineComponent({
|
|
|
})
|
|
|
|
|
|
onMounted(() => {
|
|
|
- initSortable()
|
|
|
+ // initSortable()
|
|
|
})
|
|
|
|
|
|
const initSortable = () => {
|
|
@@ -72,9 +72,6 @@ export default defineComponent({
|
|
|
animation: 150,
|
|
|
sort: true,
|
|
|
fallbackTolerance: 3,
|
|
|
- onAdd(ele: any, e: any) {
|
|
|
- console.log(ele, e, 'add information')
|
|
|
- },
|
|
|
onUpdate: (evt: any) => {
|
|
|
const updatePosition = (list: any) =>
|
|
|
list.splice(evt.newIndex, 0, list.splice(evt.oldIndex, 1)[0])
|
|
@@ -90,7 +87,7 @@ export default defineComponent({
|
|
|
}
|
|
|
})
|
|
|
|
|
|
- console.log(state.sortable)
|
|
|
+ // console.log(state.sortable)
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -100,7 +97,7 @@ export default defineComponent({
|
|
|
const result: any = []
|
|
|
|
|
|
list.forEach((item: any, index: number) => {
|
|
|
- console.log(item, 'item')
|
|
|
+ // console.log(item, 'item')
|
|
|
result.push({
|
|
|
answerId: item.answerId,
|
|
|
answer: item.answer,
|
|
@@ -108,7 +105,7 @@ export default defineComponent({
|
|
|
})
|
|
|
})
|
|
|
|
|
|
- console.log('🚀 ~ onSelect ~ result', result)
|
|
|
+ // console.log('🚀 ~ onSelect ~ result', result)
|
|
|
emit('update:value', result)
|
|
|
}
|
|
|
|
|
@@ -117,7 +114,7 @@ export default defineComponent({
|
|
|
// 判断是否已经选中了
|
|
|
if (item.checked || props.readOnly) return
|
|
|
const result: any = []
|
|
|
- console.log(state.options, 'state.options')
|
|
|
+ // console.log(state.options, 'state.options')
|
|
|
state.options.forEach((option: any, index: any) => {
|
|
|
// console.log(option, '------')
|
|
|
result.push({
|
|
@@ -139,7 +136,7 @@ export default defineComponent({
|
|
|
answerExtra: state.list.length + 1
|
|
|
})
|
|
|
|
|
|
- console.log(state.list, '------', result, 'result lis4t')
|
|
|
+ // console.log(state.list, '------', result, 'result lis4t')
|
|
|
emit('update:value', result)
|
|
|
|
|
|
nextTick(() => {
|
|
@@ -150,7 +147,7 @@ export default defineComponent({
|
|
|
const answers = computed(() => {
|
|
|
const list: any = props.data.answers || []
|
|
|
const value: any = props.value || []
|
|
|
- console.log(value, 'answer')
|
|
|
+ // console.log(value, 'answer')
|
|
|
list.forEach((item: any) => {
|
|
|
const tempIndex = value.findIndex(
|
|
|
(c: any) => c.answerId === item.examinationQuestionAnswerId
|
|
@@ -189,40 +186,26 @@ export default defineComponent({
|
|
|
tempList.push(tmp)
|
|
|
})
|
|
|
state.options = tempList
|
|
|
- console.log(state.options, 'after options')
|
|
|
-
|
|
|
- // console.log(state.sortable.toArray())
|
|
|
- // answers.forEach((item: any) => {
|
|
|
- // ids.push(item.itemIndex)
|
|
|
- // })
|
|
|
- // state.sortable.sort(
|
|
|
- // ids.sort((a: any, b: any) => a - b),
|
|
|
- // true
|
|
|
- // )
|
|
|
- // state.list = state.options
|
|
|
}
|
|
|
})
|
|
|
- // else {
|
|
|
- // const resultValue: any = []
|
|
|
- // answers.forEach((answer: any) => {
|
|
|
- // const tmp = {
|
|
|
- // index: answer.examinationQuestionAnswerId, // 左边的值
|
|
|
- // leftValue: answer.questionAnswer, // 左边的值
|
|
|
- // rightValue: answer.questionExtra, // 右边的值
|
|
|
- // leftType: answer.questionAnswerTypeCode || 'TXT', // 左边类型
|
|
|
- // rightType: answer.questionExtraTypeCode || 'TXT' // 右边类型
|
|
|
- // }
|
|
|
- // resultValue.push({
|
|
|
- // answerId: answer.examinationQuestionAnswerId,
|
|
|
- // answer: answer.questionAnswer,
|
|
|
- // answerExtra: answer.questionExtra
|
|
|
- // })
|
|
|
- // state.options.push(tmp)
|
|
|
- // })
|
|
|
- // // 进页面就默认初始化答案
|
|
|
- // }
|
|
|
}
|
|
|
|
|
|
+ watch(
|
|
|
+ () => state.options,
|
|
|
+ () => {
|
|
|
+ const list = state.options || []
|
|
|
+ const result: any = []
|
|
|
+ list.forEach((item: any, index: number) => {
|
|
|
+ result.push({
|
|
|
+ answerId: item.index,
|
|
|
+ answer: item.leftValue,
|
|
|
+ answerExtra: index + 1
|
|
|
+ })
|
|
|
+ })
|
|
|
+ emit('update:value', result)
|
|
|
+ }
|
|
|
+ )
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
initOptions()
|
|
|
})
|
|
@@ -273,12 +256,13 @@ export default defineComponent({
|
|
|
state.options = []
|
|
|
state.list = []
|
|
|
onSelect()
|
|
|
+ initOptions()
|
|
|
}}
|
|
|
>
|
|
|
重置
|
|
|
</Button>
|
|
|
</div>
|
|
|
- <div id={state.domId}>
|
|
|
+ {/* <div id={state.domId}>
|
|
|
{state.options.length > 0 &&
|
|
|
state.options.map((item: any) => (
|
|
|
<>
|
|
@@ -297,15 +281,24 @@ export default defineComponent({
|
|
|
)}
|
|
|
</>
|
|
|
))}
|
|
|
- </div>
|
|
|
+ </div> */}
|
|
|
|
|
|
- {/* <Draggable v-model:modelValue={state.options} itemKey="itemIndex" componentData={}>
|
|
|
+ <Draggable
|
|
|
+ v-model:modelValue={state.options}
|
|
|
+ itemKey="itemIndex"
|
|
|
+ // componentData={{
|
|
|
+ // on: {
|
|
|
+ // change: () => {
|
|
|
+ // console.log('input')
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }}
|
|
|
+ >
|
|
|
{{
|
|
|
item: (element: any) => {
|
|
|
- console.log(element)
|
|
|
const item = element.element
|
|
|
return (
|
|
|
- <>
|
|
|
+ <div class={styles.itemsContainer}>
|
|
|
{item.leftType === AnswerType.TXT && (
|
|
|
<Tag class={[styles.items]} data-id={item.itemIndex}>
|
|
|
{item.leftValue}
|
|
@@ -319,11 +312,11 @@ export default defineComponent({
|
|
|
fit="cover"
|
|
|
/>
|
|
|
)}
|
|
|
- </>
|
|
|
+ </div>
|
|
|
)
|
|
|
}
|
|
|
}}
|
|
|
- </Draggable> */}
|
|
|
+ </Draggable>
|
|
|
</div>
|
|
|
</div>
|
|
|
{props.showAnalysis && (
|