|
@@ -56,10 +56,15 @@ export default defineComponent({
|
|
drag: false,
|
|
drag: false,
|
|
sortable: null as any,
|
|
sortable: null as any,
|
|
list: [] as any,
|
|
list: [] as any,
|
|
- options: [] as any
|
|
|
|
|
|
+ options: [] as any,
|
|
|
|
+ alst: [] as any
|
|
})
|
|
})
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
|
+ initSortable()
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ const initSortable = () => {
|
|
nextTick(() => {
|
|
nextTick(() => {
|
|
const el = document.getElementById(state.domId)
|
|
const el = document.getElementById(state.domId)
|
|
state.sortable = Sortable.create(el, {
|
|
state.sortable = Sortable.create(el, {
|
|
@@ -80,17 +85,14 @@ export default defineComponent({
|
|
}
|
|
}
|
|
})
|
|
})
|
|
})
|
|
})
|
|
- })
|
|
|
|
|
|
+ }
|
|
|
|
|
|
// 返回选中的结果
|
|
// 返回选中的结果
|
|
const onSelect = () => {
|
|
const onSelect = () => {
|
|
- // const options = state.options || []
|
|
|
|
const list = state.list || []
|
|
const list = state.list || []
|
|
const result: any = []
|
|
const result: any = []
|
|
|
|
|
|
- console.log(list, '1212')
|
|
|
|
list.forEach((item: any, index: number) => {
|
|
list.forEach((item: any, index: number) => {
|
|
- console.log(index, '测试返回')
|
|
|
|
result.push({
|
|
result.push({
|
|
answerId: item.index,
|
|
answerId: item.index,
|
|
answer: item.leftValue,
|
|
answer: item.leftValue,
|
|
@@ -160,8 +162,9 @@ export default defineComponent({
|
|
}
|
|
}
|
|
state.options.push(tmp)
|
|
state.options.push(tmp)
|
|
})
|
|
})
|
|
|
|
+ state.list = state.options
|
|
}
|
|
}
|
|
- // else {
|
|
|
|
|
|
+ // else {
|
|
// const resultValue: any = []
|
|
// const resultValue: any = []
|
|
// answers.forEach((answer: any) => {
|
|
// answers.forEach((answer: any) => {
|
|
// const tmp = {
|
|
// const tmp = {
|
|
@@ -235,17 +238,11 @@ export default defineComponent({
|
|
answers.forEach((item: any) => {
|
|
answers.forEach((item: any) => {
|
|
ids.push(item.itemIndex)
|
|
ids.push(item.itemIndex)
|
|
})
|
|
})
|
|
- console.log(ids)
|
|
|
|
state.sortable.sort(
|
|
state.sortable.sort(
|
|
ids.sort((a: any, b: any) => a - b),
|
|
ids.sort((a: any, b: any) => a - b),
|
|
true
|
|
true
|
|
)
|
|
)
|
|
|
|
|
|
- // state.options.forEach((item: any) => {
|
|
|
|
- // item.checked = false
|
|
|
|
- // })
|
|
|
|
- // state.list = []
|
|
|
|
-
|
|
|
|
onSelect()
|
|
onSelect()
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
@@ -263,7 +260,7 @@ export default defineComponent({
|
|
{item.leftType === AnswerType.IMAGE && (
|
|
{item.leftType === AnswerType.IMAGE && (
|
|
<Image
|
|
<Image
|
|
src={item.leftValue}
|
|
src={item.leftValue}
|
|
- data-id={item.index}
|
|
|
|
|
|
+ data-id={item.itemIndex}
|
|
class={[styles.imgs, 'van-hairline--surround']}
|
|
class={[styles.imgs, 'van-hairline--surround']}
|
|
fit="cover"
|
|
fit="cover"
|
|
/>
|
|
/>
|