index.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <script setup lang="ts">
  2. import { usePageSearch, type PageHooks, type PageEvents } from "/@/hooks/page";
  3. import contentConfig from "./config/content.config";
  4. import { ElDialog, ElMessage } from "element-plus";
  5. import searchConfig from "./config/search.config";
  6. import { useVModel } from "@vueuse/core";
  7. import { useRouter } from "vue-router";
  8. import { ref } from "vue";
  9. const props = defineProps<{ visible: boolean; otherSearchParameter: any }>()
  10. const emit = defineEmits(['submit'])
  11. const visible = useVModel(props, 'visible')
  12. const router = useRouter();
  13. const hooks: PageHooks = {
  14. pageSearchHook: () => usePageSearch(undefined, undefined, searchConfig)
  15. };
  16. const selection= ref([])
  17. const events: PageEvents = {
  18. content: {
  19. preview: ({ id }) => router.push("/invoiceInOut/productManagerDetail?id=" + id),
  20. create: () => router.push('/invoiceInOut/productManagerDetail')
  21. }
  22. };
  23. function handleSubmit(){
  24. if(selection.value.length === 0){
  25. ElMessage.warning('请选择至少一个商品')
  26. return
  27. }
  28. const result = []
  29. selection.value.forEach(single => {
  30. if (single.ProductsCombind.length === 0) {
  31. result.push({ ...single, goodNum: 1 })
  32. } else {
  33. single.ProductsCombind.forEach(child => {
  34. result.push({ ...single, goodNum: 1 ,childCode: child.products.skuCode, childNum: single.child_num, childActionNum: single.child_num })
  35. })
  36. }
  37. })
  38. visible.value = false
  39. emit('submit', result)
  40. }
  41. </script>
  42. <template>
  43. <ElDialog class="relative" v-model="visible" title="选择商品" center top="10px">
  44. <PageContainer :only-self="true" v-if="visible" :hooks="hooks" :events="events" :searchConfig="searchConfig"
  45. :contentConfig="contentConfig" :isPageStart="true" :other-search-parameter="otherSearchParameter"
  46. @content-select-change="values => selection = values.map(item => ({ ...item, child_num: '1', child_id: item.id }))" />
  47. <ElButton class="absolute bottom-[30px] right-[20px]" type="primary" @click="handleSubmit">保存 </ElButton>
  48. </ElDialog>
  49. </template>