|
@@ -1,6 +1,6 @@
|
|
|
import request from '@/helpers/request'
|
|
|
import { useAsyncState } from '@vueuse/core'
|
|
|
-import { defineComponent, reactive, ref, watch } from 'vue'
|
|
|
+import { defineComponent, reactive, Ref, ref, watch } from 'vue'
|
|
|
import { state as appState } from '@/state'
|
|
|
import { Button } from 'vant'
|
|
|
import SelectTagsChild from './select-tags-child'
|
|
@@ -31,16 +31,17 @@ export default defineComponent({
|
|
|
null
|
|
|
)
|
|
|
const resetTags = () => {
|
|
|
- for (const key in tags) {
|
|
|
- if (Object.prototype.hasOwnProperty.call(tags, key)) {
|
|
|
- delete tags[key]
|
|
|
- }
|
|
|
- }
|
|
|
+ tags.value = {}
|
|
|
+ // for (const key in tags) {
|
|
|
+ // if (Object.prototype.hasOwnProperty.call(tags, key)) {
|
|
|
+ // // delete tags[key]
|
|
|
+ // }
|
|
|
+ // }
|
|
|
emit('cancel')
|
|
|
}
|
|
|
|
|
|
const defaultTags = (defaultValue || '').split(',').map(id => Number(id))
|
|
|
- const tags: { [key in string]: number[] } = reactive({})
|
|
|
+ const tags: Ref<{ [key in string]: number[] }> = ref({})
|
|
|
const names = {}
|
|
|
watch(state, () => {
|
|
|
if (state.value) {
|
|
@@ -50,7 +51,7 @@ export default defineComponent({
|
|
|
names[c.id] = c.name
|
|
|
return c.id
|
|
|
})
|
|
|
- tags[item.id] = defaultTags.filter(id => {
|
|
|
+ tags.value[item.id] = defaultTags.filter(id => {
|
|
|
return allids.includes(Number(id))
|
|
|
})
|
|
|
}
|
|
@@ -77,10 +78,10 @@ export default defineComponent({
|
|
|
<SelectTagsChild
|
|
|
key={item.id}
|
|
|
// @ts-ignore
|
|
|
- selected={tags[item.id] || []}
|
|
|
+ selected={tags.value[item.id] || []}
|
|
|
child={item.children || []}
|
|
|
onSelect={val => {
|
|
|
- tags[item.id] = val
|
|
|
+ tags.value[item.id] = val
|
|
|
}}
|
|
|
{...restProps}
|
|
|
/>
|
|
@@ -96,7 +97,7 @@ export default defineComponent({
|
|
|
class={styles.btn}
|
|
|
type="primary"
|
|
|
round
|
|
|
- onClick={() => emit('confirm', tags, names)}
|
|
|
+ onClick={() => emit('confirm', tags.value, names)}
|
|
|
>
|
|
|
确认
|
|
|
</Button>
|