Skip to content

The open source simple and complete warehouse management system is derived from our many years of experience in implementing erp projects. We stripped the original commercial system wms function and opened it up for free, hoping to help the majority of small and medium-sized enterprises. At present, the system supports cross-platform。

Merge branch 'release'

liufu764297fc3348
diff --cc frontend/src/view/warehouseWorking/warehouseMove/add-or-update-move.vue
index e861716,afa0b92..b26d90c
--- a/frontend/src/view/warehouseWorking/warehouseMove/add-or-update-move.vue
+++ b/frontend/src/view/warehouseWorking/warehouseMove/add-or-update-move.vue
@@@ -1,311 -1,315 +1,315 @@@
-<!-- Warehouse Move Operate Dialog -->
-<template>
- <v-dialog v-model="isShow" :width="'30%'" transition="dialog-top-transition" :persistent="true">
- <template #default>
- <v-card>
- <v-toolbar class="" color="white" :title="`${$t('router.sideBar.warehouseMove')}`">
- <custom-qrcode :value="qrCodeValue" />
- </v-toolbar>
- <v-card-text>
- <v-form ref="formRef">
- <v-text-field
- v-model="data.form.spu_code"
- :label="$t('base.commodityManagement.spu_code')"
- :rules="data.rules.spu_code"
- variant="outlined"
- readonly
- clearable
- @click="method.openCommoditySelect"
- @click:clear="method.clearCommodity"
- ></v-text-field>
- <v-text-field
- v-model="data.form.spu_name"
- :label="$t('base.commodityManagement.spu_name')"
- :rules="data.rules.spu_name"
- variant="outlined"
- disabled
- ></v-text-field>
- <v-text-field
- v-model="data.form.sku_code"
- :label="$t('base.commodityManagement.sku_code')"
- :rules="data.rules.sku_code"
- variant="outlined"
- disabled
- ></v-text-field>
- <!-- <v-text-field
- v-model="data.form.sku_name"
- :label="$t('base.commodityManagement.sku_name')"
- :rules="data.rules.sku_name"
- variant="outlined"
- disabled
- ></v-text-field> -->
- <v-text-field
- v-model="data.form.orig_goods_warehouse"
- :label="$t('wms.warehouseWorking.warehouseMove.orig_goods_warehouse')"
- :rules="data.rules.orig_goods_warehouse"
- variant="outlined"
- disabled
- ></v-text-field>
- <v-text-field
- v-model="data.form.orig_goods_location_name"
- :label="$t('wms.warehouseWorking.warehouseMove.orig_goods_location_name')"
- :rules="data.rules.orig_goods_location_name"
- variant="outlined"
- disabled
- ></v-text-field>
- <v-text-field
- v-model="data.form.dest_googs_warehouse"
- :label="$t('wms.warehouseWorking.warehouseMove.dest_googs_warehouse')"
- :rules="data.rules.dest_googs_warehouse"
- variant="outlined"
- disabled
- ></v-text-field>
- <v-text-field
- v-model="data.form.dest_googs_location_name"
- :label="$t('wms.warehouseWorking.warehouseMove.dest_googs_location_name')"
- :rules="data.rules.dest_googs_location_name"
- variant="outlined"
- readonly
- clearable
- @click="method.openLocationSelect"
- @click:clear="method.clearLocation"
- ></v-text-field>
- <v-text-field
- v-model="data.form.qty"
- :label="$t('wms.warehouseWorking.warehouseMove.qty')"
- :rules="data.rules.qty"
- variant="outlined"
- ></v-text-field>
- </v-form>
- </v-card-text>
- <v-card-actions class="justify-end">
- <v-btn variant="text" @click="method.closeDialog">{{ $t('system.page.close') }}</v-btn>
- <v-btn color="primary" variant="text" :disabled="operateDisabled" @click="method.submit">{{ $t('system.page.submit') }}</v-btn>
- </v-card-actions>
- </v-card>
- </template>
- </v-dialog>
-
- <commodity-select
- :show-dialog="data.showCommodityDialogSelect"
- @close="method.closeCommodityDialogSelect"
- @sureSelect="method.sureSelectCommodity"
- />
- <location-select :show-dialog="data.showLocationDialogSelect" @close="method.closeLocationDialogSelect" @sureSelect="method.sureSelectLocation" />
-</template>
-
-<script lang="ts" setup>
-import { reactive, computed, ref, watch } from 'vue'
-import i18n from '@/languages/i18n'
-import { hookComponent } from '@/components/system/index'
-import { addStockMove } from '@/api/wms/warehouseMove'
-import { WarehouseMoveVO, MoveStatus } from '@/types/WarehouseWorking/WarehouseMove'
-import { removeObjectNull } from '@/utils/common'
-import commoditySelect from '@/components/select/commodity-select.vue'
-import locationSelect from '@/components/select/location-select.vue'
-import customQrcode from '@/components/custom-qrcode.vue'
-import { IsInteger } from '@/utils/dataVerification/formRule'
-
-const formRef = ref()
-const emit = defineEmits(['close', 'saveSuccess'])
-const isUpdate = computed(() => props.form.id && props.form.id > 0)
-const operateDisabled = computed(() => !!isUpdate.value)
-const qrCodeValue = computed(() => data.form.id.toString())
-
-const props = defineProps<{
- showDialog: boolean
- form: WarehouseMoveVO
-}>()
-
-const isShow = computed(() => props.showDialog)
-
-const data = reactive({
- showCommodityDialogSelect: false,
- showLocationDialogSelect: false,
-
- // Available Qty
- curAvailableQty: 0,
-
- form: ref<WarehouseMoveVO>({
- id: 0,
- job_code: '',
- move_status: MoveStatus.UNADJUST,
- sku_id: 0,
- orig_goods_location_id: 0,
- dest_googs_location_id: 0,
- qty: 0,
- goods_owner_id: 0,
- handler: '',
- handle_time: '',
- orig_goods_warehouse: '',
- orig_goods_location_name: '',
- dest_googs_warehouse: '',
- dest_googs_location_name: '',
- spu_code: '',
- spu_name: '',
- sku_code: '',
- sku_name: '',
- creator: '',
- create_time: ''
- }),
- rules: {
- qty: [
- (val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('wms.warehouseWorking.warehouseMove.qty') }!`,
- (val: number) => IsInteger(val, 'greaterThanZero') === '' || IsInteger(val, 'greaterThanZero'),
- (val: string) => method.validQty(val)
- ],
- orig_goods_warehouse: [
- (val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('wms.warehouseWorking.warehouseMove.orig_goods_warehouse') }!`
- ],
- orig_goods_location_name: [
- (val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('wms.warehouseWorking.warehouseMove.orig_goods_location_name') }!`
- ],
- dest_googs_warehouse: [
- (val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('wms.warehouseWorking.warehouseMove.dest_googs_warehouse') }!`
- ],
- dest_googs_location_name: [
- (val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('wms.warehouseWorking.warehouseMove.dest_googs_location_name') }!`
- ],
- spu_code: [(val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('base.commodityManagement.spu_code') }!`],
- spu_name: [(val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('base.commodityManagement.spu_name') }!`],
- sku_code: [(val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('base.commodityManagement.sku_code') }!`],
- sku_name: [(val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('base.commodityManagement.sku_name') }!`]
- }
-})
-
-const method = reactive({
- // The 'qty' can't more than 'qty_available'
- validQty: (value: string): boolean | string => {
- let inputQty = Number(value)
- if (Number.isNaN(inputQty)) {
- inputQty = 0
- }
-
- if (inputQty > data.curAvailableQty) {
- return `${ i18n.global.t('wms.warehouseWorking.warehouseProcessing.qtyMoreThanAvailable') }${ data.curAvailableQty }`
- }
- return true
- },
- closeDialog: () => {
- emit('close')
- },
- initForm: () => {
- data.form = props.form
- },
-
- openCommoditySelect: () => {
- // Open select modal after UI rendered.
- setTimeout(() => {
- data.showCommodityDialogSelect = true
- }, 100)
- },
-
- closeCommodityDialogSelect: () => {
- data.showCommodityDialogSelect = false
- },
-
- openLocationSelect: () => {
- setTimeout(() => {
- data.showLocationDialogSelect = true
- }, 100)
- },
-
- closeLocationDialogSelect: () => {
- data.showLocationDialogSelect = false
- },
-
- sureSelectCommodity: (selectRecords: any) => {
- try {
- data.form.sku_id = selectRecords[0].sku_id
- data.form.orig_goods_location_id = selectRecords[0].goods_location_id
- data.form.orig_goods_warehouse = selectRecords[0].warehouse_name
- data.form.orig_goods_location_name = selectRecords[0].location_name
- data.form.goods_owner_id = selectRecords[0].goods_owner_id
- data.form.spu_code = selectRecords[0].spu_code
- data.form.spu_name = selectRecords[0].spu_name
- data.form.sku_code = selectRecords[0].sku_code
- data.form.sku_name = selectRecords[0].sku_name
-
- data.curAvailableQty = selectRecords[0].qty_available
- } catch (error) {
- console.error(error)
- }
- },
-
- sureSelectLocation: (selectRecords: any) => {
- try {
- data.form.dest_googs_location_id = selectRecords[0].id
- data.form.dest_googs_warehouse = selectRecords[0].warehouse_name
- data.form.dest_googs_location_name = selectRecords[0].location_name
- } catch (error) {
- console.error(error)
- }
- },
-
- clearCommodity: () => {
- data.form.sku_id = 0
- data.form.orig_goods_location_id = 0
- data.form.orig_goods_warehouse = ''
- data.form.orig_goods_location_name = ''
- data.form.spu_code = ''
- data.form.spu_name = ''
- data.form.sku_code = ''
- data.form.sku_name = ''
-
- data.curAvailableQty = 0
- },
-
- clearLocation: () => {
- data.form.dest_googs_location_id = 0
- data.form.dest_googs_warehouse = ''
- data.form.dest_googs_location_name = ''
- },
-
- submit: async () => {
- const { valid } = await formRef.value.validate()
-
- const form = method.constructFormBody()
-
- if (valid) {
- const { data: res } = await addStockMove(form)
- if (!res.isSuccess) {
- hookComponent.$message({
- type: 'error',
- content: res.errorMessage
- })
- return
- }
- hookComponent.$message({
- type: 'success',
- content: `${ i18n.global.t('system.page.submit') }${ i18n.global.t('system.tips.success') }`
- })
- emit('saveSuccess')
- } else {
- hookComponent.$message({
- type: 'error',
- content: i18n.global.t('system.checkText.checkFormFail')
- })
- }
- },
-
- constructFormBody: () => {
- let form = { ...data.form }
- form = removeObjectNull(form)
-
- return form
- }
-})
-
-watch(
- () => isShow.value,
- (val) => {
- if (val) {
- method.initForm()
- }
- }
-)
-</script>
-
-<style scoped lang="less">
-.v-form {
- div {
- margin-bottom: 7px;
- }
-}
-</style>
+<!-- Warehouse Move Operate Dialog -->
+<template>
+ <v-dialog v-model="isShow" :width="'30%'" transition="dialog-top-transition" :persistent="true">
+ <template #default>
+ <v-card>
- <v-toolbar class="" color="white" :title="`${$t('router.sideBar.warehouseMove')}`"></v-toolbar>
++ <v-toolbar class="" color="white" :title="`${$t('router.sideBar.warehouseMove')}`">
++ <custom-qrcode :value="qrCodeValue" />
++ </v-toolbar>
+ <v-card-text>
+ <v-form ref="formRef">
+ <v-text-field
+ v-model="data.form.spu_code"
+ :label="$t('base.commodityManagement.spu_code')"
+ :rules="data.rules.spu_code"
+ variant="outlined"
+ readonly
+ clearable
+ @click="method.openCommoditySelect"
+ @click:clear="method.clearCommodity"
+ ></v-text-field>
+ <v-text-field
+ v-model="data.form.spu_name"
+ :label="$t('base.commodityManagement.spu_name')"
+ :rules="data.rules.spu_name"
+ variant="outlined"
+ disabled
+ ></v-text-field>
+ <v-text-field
+ v-model="data.form.sku_code"
+ :label="$t('base.commodityManagement.sku_code')"
+ :rules="data.rules.sku_code"
+ variant="outlined"
+ disabled
+ ></v-text-field>
+ <!-- <v-text-field
+ v-model="data.form.sku_name"
+ :label="$t('base.commodityManagement.sku_name')"
+ :rules="data.rules.sku_name"
+ variant="outlined"
+ disabled
+ ></v-text-field> -->
+ <v-text-field
+ v-model="data.form.orig_goods_warehouse"
+ :label="$t('wms.warehouseWorking.warehouseMove.orig_goods_warehouse')"
+ :rules="data.rules.orig_goods_warehouse"
+ variant="outlined"
+ disabled
+ ></v-text-field>
+ <v-text-field
+ v-model="data.form.orig_goods_location_name"
+ :label="$t('wms.warehouseWorking.warehouseMove.orig_goods_location_name')"
+ :rules="data.rules.orig_goods_location_name"
+ variant="outlined"
+ disabled
+ ></v-text-field>
+ <v-text-field
+ v-model="data.form.dest_googs_warehouse"
+ :label="$t('wms.warehouseWorking.warehouseMove.dest_googs_warehouse')"
+ :rules="data.rules.dest_googs_warehouse"
+ variant="outlined"
+ disabled
+ ></v-text-field>
+ <v-text-field
+ v-model="data.form.dest_googs_location_name"
+ :label="$t('wms.warehouseWorking.warehouseMove.dest_googs_location_name')"
+ :rules="data.rules.dest_googs_location_name"
+ variant="outlined"
+ readonly
+ clearable
+ @click="method.openLocationSelect"
+ @click:clear="method.clearLocation"
+ ></v-text-field>
+ <v-text-field
+ v-model="data.form.qty"
+ :label="$t('wms.warehouseWorking.warehouseMove.qty')"
+ :rules="data.rules.qty"
+ variant="outlined"
+ ></v-text-field>
+ </v-form>
+ </v-card-text>
+ <v-card-actions class="justify-end">
+ <v-btn variant="text" @click="method.closeDialog">{{ $t('system.page.close') }}</v-btn>
+ <v-btn color="primary" variant="text" :disabled="operateDisabled" @click="method.submit">{{ $t('system.page.submit') }}</v-btn>
+ </v-card-actions>
+ </v-card>
+ </template>
+ </v-dialog>
+
+ <commodity-select
+ :show-dialog="data.showCommodityDialogSelect"
+ @close="method.closeCommodityDialogSelect"
+ @sureSelect="method.sureSelectCommodity"
+ />
+ <location-select :show-dialog="data.showLocationDialogSelect" @close="method.closeLocationDialogSelect" @sureSelect="method.sureSelectLocation" />
+</template>
+
+<script lang="ts" setup>
+import { reactive, computed, ref, watch } from 'vue'
+import i18n from '@/languages/i18n'
+import { hookComponent } from '@/components/system/index'
+import { addStockMove } from '@/api/wms/warehouseMove'
+import { WarehouseMoveVO, MoveStatus } from '@/types/WarehouseWorking/WarehouseMove'
+import { removeObjectNull } from '@/utils/common'
+import commoditySelect from '@/components/select/commodity-select.vue'
+import locationSelect from '@/components/select/location-select.vue'
++import customQrcode from '@/components/custom-qrcode.vue'
+import { IsInteger } from '@/utils/dataVerification/formRule'
+
+const formRef = ref()
+const emit = defineEmits(['close', 'saveSuccess'])
+const isUpdate = computed(() => props.form.id && props.form.id > 0)
+const operateDisabled = computed(() => !!isUpdate.value)
++const qrCodeValue = computed(() => data.form.id.toString())
+
+const props = defineProps<{
+ showDialog: boolean
+ form: WarehouseMoveVO
+}>()
+
+const isShow = computed(() => props.showDialog)
+
+const data = reactive({
+ showCommodityDialogSelect: false,
+ showLocationDialogSelect: false,
+
+ // Available Qty
+ curAvailableQty: 0,
+
+ form: ref<WarehouseMoveVO>({
+ id: 0,
+ job_code: '',
+ move_status: MoveStatus.UNADJUST,
+ sku_id: 0,
+ orig_goods_location_id: 0,
+ dest_googs_location_id: 0,
+ qty: 0,
+ goods_owner_id: 0,
+ handler: '',
+ handle_time: '',
+ orig_goods_warehouse: '',
+ orig_goods_location_name: '',
+ dest_googs_warehouse: '',
+ dest_googs_location_name: '',
+ spu_code: '',
+ spu_name: '',
+ sku_code: '',
+ sku_name: '',
+ creator: '',
+ create_time: ''
+ }),
+ rules: {
+ qty: [
+ (val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('wms.warehouseWorking.warehouseMove.qty') }!`,
+ (val: number) => IsInteger(val, 'greaterThanZero') === '' || IsInteger(val, 'greaterThanZero'),
+ (val: string) => method.validQty(val)
+ ],
+ orig_goods_warehouse: [
+ (val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('wms.warehouseWorking.warehouseMove.orig_goods_warehouse') }!`
+ ],
+ orig_goods_location_name: [
+ (val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('wms.warehouseWorking.warehouseMove.orig_goods_location_name') }!`
+ ],
+ dest_googs_warehouse: [
+ (val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('wms.warehouseWorking.warehouseMove.dest_googs_warehouse') }!`
+ ],
+ dest_googs_location_name: [
+ (val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('wms.warehouseWorking.warehouseMove.dest_googs_location_name') }!`
+ ],
+ spu_code: [(val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('base.commodityManagement.spu_code') }!`],
+ spu_name: [(val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('base.commodityManagement.spu_name') }!`],
+ sku_code: [(val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('base.commodityManagement.sku_code') }!`],
+ sku_name: [(val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('base.commodityManagement.sku_name') }!`]
+ }
+})
+
+const method = reactive({
+ // The 'qty' can't more than 'qty_available'
+ validQty: (value: string): boolean | string => {
+ let inputQty = Number(value)
+ if (Number.isNaN(inputQty)) {
+ inputQty = 0
+ }
+
+ if (inputQty > data.curAvailableQty) {
+ return `${ i18n.global.t('wms.warehouseWorking.warehouseProcessing.qtyMoreThanAvailable') }${ data.curAvailableQty }`
+ }
+ return true
+ },
+ closeDialog: () => {
+ emit('close')
+ },
+ initForm: () => {
+ data.form = props.form
+ },
+
+ openCommoditySelect: () => {
+ // Open select modal after UI rendered.
+ setTimeout(() => {
+ data.showCommodityDialogSelect = true
+ }, 100)
+ },
+
+ closeCommodityDialogSelect: () => {
+ data.showCommodityDialogSelect = false
+ },
+
+ openLocationSelect: () => {
+ setTimeout(() => {
+ data.showLocationDialogSelect = true
+ }, 100)
+ },
+
+ closeLocationDialogSelect: () => {
+ data.showLocationDialogSelect = false
+ },
+
+ sureSelectCommodity: (selectRecords: any) => {
+ try {
+ data.form.sku_id = selectRecords[0].sku_id
+ data.form.orig_goods_location_id = selectRecords[0].goods_location_id
+ data.form.orig_goods_warehouse = selectRecords[0].warehouse_name
+ data.form.orig_goods_location_name = selectRecords[0].location_name
+ data.form.goods_owner_id = selectRecords[0].goods_owner_id
+ data.form.spu_code = selectRecords[0].spu_code
+ data.form.spu_name = selectRecords[0].spu_name
+ data.form.sku_code = selectRecords[0].sku_code
+ data.form.sku_name = selectRecords[0].sku_name
+
+ data.curAvailableQty = selectRecords[0].qty_available
+ } catch (error) {
+ console.error(error)
+ }
+ },
+
+ sureSelectLocation: (selectRecords: any) => {
+ try {
+ data.form.dest_googs_location_id = selectRecords[0].id
+ data.form.dest_googs_warehouse = selectRecords[0].warehouse_name
+ data.form.dest_googs_location_name = selectRecords[0].location_name
+ } catch (error) {
+ console.error(error)
+ }
+ },
+
+ clearCommodity: () => {
+ data.form.sku_id = 0
+ data.form.orig_goods_location_id = 0
+ data.form.orig_goods_warehouse = ''
+ data.form.orig_goods_location_name = ''
+ data.form.spu_code = ''
+ data.form.spu_name = ''
+ data.form.sku_code = ''
+ data.form.sku_name = ''
+
+ data.curAvailableQty = 0
+ },
+
+ clearLocation: () => {
+ data.form.dest_googs_location_id = 0
+ data.form.dest_googs_warehouse = ''
+ data.form.dest_googs_location_name = ''
+ },
+
+ submit: async () => {
+ const { valid } = await formRef.value.validate()
+
+ const form = method.constructFormBody()
+
+ if (valid) {
+ const { data: res } = await addStockMove(form)
+ if (!res.isSuccess) {
+ hookComponent.$message({
+ type: 'error',
+ content: res.errorMessage
+ })
+ return
+ }
+ hookComponent.$message({
+ type: 'success',
+ content: `${ i18n.global.t('system.page.submit') }${ i18n.global.t('system.tips.success') }`
+ })
+ emit('saveSuccess')
+ } else {
+ hookComponent.$message({
+ type: 'error',
+ content: i18n.global.t('system.checkText.checkFormFail')
+ })
+ }
+ },
+
+ constructFormBody: () => {
+ let form = { ...data.form }
+ form = removeObjectNull(form)
+
+ return form
+ }
+})
+
+watch(
+ () => isShow.value,
+ (val) => {
+ if (val) {
+ method.initForm()
+ }
+ }
+)
+</script>
+
+<style scoped lang="less">
+.v-form {
+ div {
+ margin-bottom: 7px;
+ }
+}
+</style>
diff --cc frontend/src/view/warehouseWorking/warehouseProcessing/add-or-update-process.vue
index 734e47f,5690637..ff380d1
--- a/frontend/src/view/warehouseWorking/warehouseProcessing/add-or-update-process.vue
+++ b/frontend/src/view/warehouseWorking/warehouseProcessing/add-or-update-process.vue
@@@ -1,584 -1,588 +1,588 @@@
-<template>
- <v-dialog v-model="isShow" width="80%" transition="dialog-top-transition" :persistent="true">
- <template #default>
- <v-card>
- <v-toolbar color="white" :title="jobTypeComp">
- <custom-qrcode :value="qrCodeValue" />
- </v-toolbar>
- <v-card-text>
- <v-row>
- <!-- Source Table -->
- <v-col cols="6">
- <div class="dataTable">
- <div class="toolbar">
- <div class="toolbarTitle">
- <p style="color: #999">{{ $t('wms.warehouseWorking.warehouseProcessing.source') }}</p>
- </div>
- <tooltip-btn
- icon="mdi-plus"
- :tooltip-text="$t('system.page.add')"
- size="x-small"
- :disabled="operateDisabled"
- @click="method.openSelect('source')"
- ></tooltip-btn>
- </div>
- <vxe-table
- ref="xTableSource"
- :column-config="{ minWidth: '100px' }"
- :data="data.form.source_detail_list"
- :height="SYSTEM_HEIGHT.SELECT_TABLE"
- :edit-config="{ trigger: 'click', mode: 'cell' }"
- :edit-rules="data.validRulesSource"
- align="center"
- >
- <template #empty>
- {{ i18n.global.t('system.page.noData') }}
- </template>
- <vxe-column type="seq" width="60"></vxe-column>
- <vxe-column field="operate" width="50" :title="$t('system.page.operate')" :resizable="false">
- <template #default="{ row }">
- <tooltip-btn
- :flat="true"
- icon="mdi-delete-outline"
- :tooltip-text="$t('system.page.delete')"
- :icon-color="errorColor"
- @click="method.deleteRowSource(row)"
- ></tooltip-btn>
- </template>
- </vxe-column>
- <vxe-column field="spu_code" :title="$t('wms.warehouseWorking.warehouseProcessing.spu_code')"></vxe-column>
- <vxe-column field="spu_name" :title="$t('wms.warehouseWorking.warehouseProcessing.spu_name')"></vxe-column>
- <vxe-column field="sku_code" :title="$t('wms.warehouseWorking.warehouseProcessing.sku_code')"></vxe-column>
- <vxe-column
- field="qty"
- :title="$t('wms.warehouseWorking.warehouseProcessing.qty')"
- :edit-render="{ autofocus: '.vxe-input--inner' }"
- >
- <template #edit="{ row }">
- <vxe-input v-model="row.qty" type="text"></vxe-input>
- </template>
- </vxe-column>
- <vxe-column field="unit" :title="$t('wms.warehouseWorking.warehouseProcessing.unit')"></vxe-column>
- </vxe-table>
- </div>
- </v-col>
-
- <!-- Target Table -->
- <v-col cols="6">
- <div class="dataTable">
- <div class="toolbar">
- <div class="toolbarTitle">
- <p style="color: #999">{{ $t('wms.warehouseWorking.warehouseProcessing.target') }}</p>
- </div>
- <tooltip-btn
- icon="mdi-plus"
- :tooltip-text="$t('system.page.add')"
- size="x-small"
- :disabled="operateDisabled"
- @click="method.openSelect('target')"
- ></tooltip-btn>
- </div>
- <vxe-table
- ref="xTableTarget"
- :column-config="{ minWidth: '100px' }"
- :data="data.form.target_detail_list"
- :height="SYSTEM_HEIGHT.SELECT_TABLE"
- :edit-config="{ trigger: 'click', mode: 'cell' }"
- :edit-rules="data.validRulesTarget"
- align="center"
- >
- <template #empty>
- {{ i18n.global.t('system.page.noData') }}
- </template>
- <vxe-column type="seq" width="60"></vxe-column>
- <vxe-column field="operate" width="50" :title="$t('system.page.operate')" :resizable="false">
- <template #default="{ row }">
- <tooltip-btn
- :flat="true"
- icon="mdi-delete-outline"
- :tooltip-text="$t('system.page.delete')"
- :icon-color="errorColor"
- @click="method.deleteRowTarget(row)"
- ></tooltip-btn>
- </template>
- </vxe-column>
- <vxe-column field="spu_code" :title="$t('wms.warehouseWorking.warehouseProcessing.spu_code')"></vxe-column>
- <vxe-column field="spu_name" :title="$t('wms.warehouseWorking.warehouseProcessing.spu_name')"></vxe-column>
- <vxe-column field="sku_code" :title="$t('wms.warehouseWorking.warehouseProcessing.sku_code')"></vxe-column>
- <vxe-column
- field="qty"
- :title="$t('wms.warehouseWorking.warehouseProcessing.qty')"
- :edit-render="{ autofocus: '.vxe-input--inner' }"
- >
- <template #edit="{ row }">
- <vxe-input v-model="row.qty" type="text"></vxe-input>
- </template>
- </vxe-column>
- <vxe-column field="unit" width="60" :title="$t('wms.warehouseWorking.warehouseProcessing.unit')"></vxe-column>
- <vxe-column field="location_name" :title="$t('wms.warehouseWorking.warehouseProcessing.target_location')" :edit-render="{}">
- <template #edit="{ row }">
- <vxe-input v-model="row.location_name" readonly type="search" @search-click="method.openLocationSelect(row)"></vxe-input>
- </template>
- </vxe-column>
- </vxe-table>
- </div>
- </v-col>
- </v-row>
- </v-card-text>
- <v-card-actions class="justify-end">
- <v-btn variant="text" @click="method.closeDialog">{{ $t('system.page.close') }}</v-btn>
- <v-btn color="primary" variant="text" :disabled="operateDisabled" @click="method.submit">{{ $t('system.page.submit') }}</v-btn>
- </v-card-actions>
- </v-card>
- </template>
- </v-dialog>
-
- <commodity-select :show-dialog="data.showCommodityDialogSelect" @close="method.closeDialogSelect('source')" @sureSelect="method.sureSelect" />
- <sku-select :show-dialog="data.showSkuDialogSelect" @close="method.closeDialogSelect('target')" @sureSelect="method.sureSelect" />
- <location-select :show-dialog="data.showLocationDialogSelect" @close="method.closeLocationDialogSelect" @sureSelect="method.sureSelectLocation" />
-</template>
-
-<script lang="ts" setup>
-import { reactive, computed, ref, watch } from 'vue'
-import { VxeTablePropTypes } from 'vxe-table'
-import { WarehouseProcessingVO, WarehouseProcessingDetailVO } from '@/types/WarehouseWorking/WarehouseProcessing'
-import i18n from '@/languages/i18n'
-import { hookComponent } from '@/components/system/index'
-import { addStockProcess } from '@/api/wms/warehouseProcessing'
-import { SYSTEM_HEIGHT, errorColor } from '@/constant/style'
-import { removeObjectNull } from '@/utils/common'
-import { PROCESS_JOB_COMBINE, PROCESS_JOB_SPLIT } from '@/constant/warehouseWorking'
-import commoditySelect from '@/components/select/commodity-select.vue'
-import locationSelect from '@/components/select/location-select.vue'
-import skuSelect from '@/components/select/sku-select.vue'
-import tooltipBtn from '@/components/tooltip-btn.vue'
-import customQrcode from '@/components/custom-qrcode.vue'
-import { exportData } from '@/utils/exportTable'
-import { isInteger } from '@/utils/dataVerification/tableRule'
-
-const emit = defineEmits(['close', 'saveSuccess'])
-const xTableSource = ref()
-const xTableTarget = ref()
-
-const props = defineProps<{
- showDialog: boolean
- form: WarehouseProcessingVO
- processType: boolean
-}>()
-
-const isShow = computed(() => props.showDialog)
-const isUpdate = computed(() => props.form.id && props.form.id > 0)
-const jobTypeComp = computed(() => (data.form.job_type === PROCESS_JOB_COMBINE
- ? i18n.global.t('wms.warehouseWorking.warehouseProcessing.process_combine')
- : i18n.global.t('wms.warehouseWorking.warehouseProcessing.process_split')))
-const operateDisabled = computed(() => !!isUpdate.value)
-const qrCodeValue = computed(() => data.form.id.toString())
-
-const method = reactive({
- initForm: () => {
- data.form = props.form
- data.form.job_type = props.processType
- },
-
- closeDialog: () => {
- emit('close')
- },
-
- openSelect: (type: string) => {
- data.curSelectType = type
-
- if (type === 'source') {
- data.showCommodityDialogSelect = true
- } else if (type === 'target') {
- // Target should select the data with 'sku-select-modal'
- data.showSkuDialogSelect = true
- }
- },
-
- closeDialogSelect: (type: string) => {
- if (type === 'source') {
- data.showCommodityDialogSelect = false
- } else if (type === 'target') {
- // Target should select the data with 'sku-select-modal'
- data.showSkuDialogSelect = false
- }
- },
-
- sureSelect: (selectRecords: any) => {
- if (data.curSelectType === 'source') {
- method.insertSourceData(selectRecords)
- } else if (data.curSelectType === 'target') {
- method.insertTargetData(selectRecords)
- }
- },
-
- openLocationSelect: (row: WarehouseProcessingDetailVO) => {
- data.curSelectRow = row
- data.showLocationDialogSelect = true
- },
-
- closeLocationDialogSelect: () => {
- data.showLocationDialogSelect = false
- },
-
- sureSelectLocation: (selectRecords: any) => {
- if (selectRecords.length > 0) {
- const $table = xTableTarget.value
- const tableData = $table.getTableData().fullData
- tableData.forEach((row: WarehouseProcessingDetailVO) => {
- if (data.curSelectRow.sku_id === row.sku_id) {
- row.goods_location_id = selectRecords[0].id
- row.location_name = selectRecords[0].location_name
- }
- })
- // Tips: Must to reload!
- $table.reloadData(tableData)
- }
- },
-
- insertSourceData: (selectRecords: any) => {
- const $table = xTableSource.value
- const tableData = $table.getTableData().fullData
-
- // Combine: That can select more source commodity
- if (data.form.job_type === PROCESS_JOB_COMBINE) {
- for (const record of selectRecords) {
- const isRepeat = tableData.some((data: WarehouseProcessingDetailVO) => data.sku_id === record.sku_id)
- if (isRepeat) {
- continue
- }
-
- $table.insertAt(
- {
- id: 0,
- stock_process_id: 0,
- sku_id: record.sku_id,
- goods_owner_id: record.goods_owner_id,
- goods_location_id: record.goods_location_id,
- qty: record.qty_available || 0,
- tenant_id: 0,
- is_source: true,
- spu_code: record.spu_code,
- spu_name: record.spu_name,
- sku_code: record.sku_code,
- unit: record.unit,
- is_update_stock: false,
- qty_available: record.qty_available
- },
- -1
- )
- // })
- }
- } else if (data.form.job_type === PROCESS_JOB_SPLIT) {
- // Split: That just can select one source commodity.
- // It should remove all data before insert.
- $table.remove()
- $table.insertAt(
- {
- id: 0,
- stock_process_id: 0,
- sku_id: selectRecords[0].sku_id,
- goods_owner_id: selectRecords[0].goods_owner_id,
- goods_location_id: selectRecords[0].goods_location_id,
- qty: selectRecords[0].qty_available || 0,
- tenant_id: 0,
- is_source: true,
- spu_code: selectRecords[0].spu_code,
- spu_name: selectRecords[0].spu_name,
- sku_code: selectRecords[0].sku_code,
- unit: selectRecords[0].unit,
- is_update_stock: false,
- qty_available: selectRecords[0].qty_available
- },
- -1
- )
- }
- },
-
- insertTargetData: (selectRecords: any) => {
- const $table = xTableTarget.value
- const tableData = $table.getTableData().fullData
-
- // Combine: That just can select one target commodity
- if (data.form.job_type === PROCESS_JOB_COMBINE) {
- // It should remove all data before insert.
- $table.remove()
- $table.insertAt(
- {
- id: 0,
- stock_process_id: 0,
- sku_id: selectRecords[0].sku_id,
- goods_owner_id: 0,
- goods_location_id: 0,
- qty: 0,
- tenant_id: 0,
- is_source: false,
- spu_code: selectRecords[0].spu_code,
- spu_name: selectRecords[0].spu_name,
- sku_code: selectRecords[0].sku_code,
- unit: selectRecords[0].unit,
- is_update_stock: false
- },
- -1
- )
- } else if (data.form.job_type === PROCESS_JOB_SPLIT) {
- // Split: That can select more target commodity
- for (const record of selectRecords) {
- const isRepeat = tableData.some((data: WarehouseProcessingDetailVO) => data.sku_id === record.sku_id)
- if (isRepeat) {
- continue
- }
- $table.insertAt(
- {
- id: 0,
- stock_process_id: 0,
- sku_id: record.sku_id,
- goods_owner_id: 0,
- goods_location_id: 0,
- qty: 0,
- tenant_id: 0,
- is_source: false,
- spu_code: record.spu_code,
- spu_name: record.spu_name,
- sku_code: record.sku_code,
- unit: record.unit,
- is_update_stock: false
- },
- -1
- )
- }
- }
- },
-
- // Export table
- exportTable: (type: string) => {
- const $table = type === 'source' ? xTableSource.value : xTableTarget.value
- exportData({
- table: $table,
- filename: i18n.global.t('router.sideBar.commodityManagement'),
- columnFilterMethod({ column }: any) {
- return !['checkbox'].includes(column?.type) && !['operate'].includes(column?.field)
- }
- })
- },
-
- submit: async () => {
- const validSource = await method.validSourceTable()
- const validTarget = await method.validTargetTable()
- if (!validSource || !validTarget) {
- return
- }
-
- const form = method.constructFormBody()
-
- const { data: res } = await addStockProcess(form)
- if (!res.isSuccess) {
- hookComponent.$message({
- type: 'error',
- content: res.errorMessage
- })
- return
- }
- hookComponent.$message({
- type: 'success',
- content: `${ i18n.global.t('system.page.submit') }${ i18n.global.t('system.tips.success') }`
- })
- emit('saveSuccess')
- },
-
- constructFormBody: () => {
- const $tableSource = xTableSource.value
- const $tableTarget = xTableTarget.value
-
- const tableSourceRecords = $tableSource.getTableData().fullData
- const tableTargetRecords = $tableTarget.getTableData().fullData
-
- // Need combine source and target to server.
- let form = { ...data.form }
- form.detailList = [...tableSourceRecords, ...tableTargetRecords]
- form = removeObjectNull(form)
-
- delete form.source_detail_list
- delete form.target_detail_list
-
- return form
- },
-
- validSourceTable: async () => {
- const $table = xTableSource.value
- const tableData = $table.getTableData().fullData
-
- // 1.The table must have data.
- if (!tableData.length) {
- hookComponent.$message({
- type: 'error',
- content: i18n.global.t('system.tips.detailLengthIsZero')
- })
- return false
- }
-
- // 2.The properties valid.
- const errMap = await $table.validate()
- if (errMap) {
- hookComponent.$message({
- type: 'error',
- content: i18n.global.t('system.checkText.checkFormFail')
- })
- return false
- }
-
- return true
- },
-
- validTargetTable: async () => {
- const $table = xTableTarget.value
- const tableData = $table.getTableData().fullData
-
- // 1.The table must have data.
- if (!tableData.length) {
- hookComponent.$message({
- type: 'error',
- content: i18n.global.t('system.tips.detailLengthIsZero')
- })
- return false
- }
-
- // 2.The properties valid.
- const errMap = await $table.validate()
- if (errMap) {
- hookComponent.$message({
- type: 'error',
- content: i18n.global.t('system.checkText.checkFormFail')
- })
- return false
- }
-
- return true
- },
-
- // The 'qty' can't more than 'qty_available'
- validQty: ({ cellValue, row }: any) => {
- const qty = cellValue || 0
- const qtyAvailable = row.qty_available || 0
-
- if (qty > qtyAvailable) {
- return new Error(`${ i18n.global.t('wms.warehouseWorking.warehouseProcessing.qtyMoreThanAvailable') } ${ qtyAvailable }`)
- }
- },
-
- deleteRowSource: (row: WarehouseProcessingDetailVO) => {
- hookComponent.$dialog({
- content: i18n.global.t('system.tips.beforeDeleteDetailMessage'),
- handleConfirm: async () => {
- if (row) {
- const $table = xTableSource.value
- $table.remove(row)
- }
- }
- })
- },
-
- deleteRowTarget: (row: WarehouseProcessingDetailVO) => {
- hookComponent.$dialog({
- content: i18n.global.t('system.tips.beforeDeleteDetailMessage'),
- handleConfirm: async () => {
- if (row) {
- const $table = xTableTarget.value
- $table.remove(row)
- }
- }
- })
- }
-})
-
-const data = reactive({
- tableData: [],
- // 'source' | 'target'
- curSelectType: '',
-
- showCommodityDialogSelect: false,
- showSkuDialogSelect: false,
- showLocationDialogSelect: false,
-
- form: ref<WarehouseProcessingVO>({
- id: 0,
- job_code: '',
- job_type: PROCESS_JOB_COMBINE,
- process_status: false,
- processor: '',
- process_time: '',
- source_detail_list: [],
- target_detail_list: []
- }),
- curSelectRow: ref<WarehouseProcessingDetailVO>({
- id: 0,
- stock_process_id: 0,
- sku_id: 0,
- goods_owner_id: 0,
- goods_location_id: 0,
- qty: 0,
- is_source: true,
- spu_code: '',
- spu_name: '',
- sku_code: '',
- unit: '',
- is_update_stock: false
- }),
- validRulesSource: ref<any>({
- qty: [
- { required: true, message: `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('wms.warehouseWorking.warehouseProcessing.qty') }` },
- {
- validator: method.validQty
- },
- {
- validator: isInteger,
- validNumerical: 'greaterThanZero',
- trigger: 'change'
- }
- ]
- }),
- validRulesTarget: ref<any>({
- qty: [
- { required: true, message: `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('wms.warehouseWorking.warehouseProcessing.qty') }` },
- {
- validator: isInteger,
- validNumerical: 'greaterThanZero',
- trigger: 'change'
- }
- ],
- location_name: [
- {
- required: true,
- message: `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('wms.warehouseWorking.warehouseProcessing.target_location') }`
- }
- ]
- })
-})
-
-watch(
- () => isShow.value,
- (val) => {
- if (val) {
- method.initForm()
- }
- }
-)
-</script>
-
-<style scoped lang="less">
-.mainForm {
- background-color: #f9f9f9;
- border-radius: 5px;
- padding: 20px;
- box-sizing: border-box;
- overflow: auto;
-}
-
-.toolbar {
- height: 40px;
- display: flex;
- justify-content: space-between;
-}
-
-.toolbarTitle {
- display: flex;
- // justify-content: center;
- // align-items: center;
-}
-</style>
+<template>
+ <v-dialog v-model="isShow" width="80%" transition="dialog-top-transition" :persistent="true">
+ <template #default>
+ <v-card>
- <v-toolbar color="white" :title="jobTypeComp"></v-toolbar>
++ <v-toolbar color="white" :title="jobTypeComp">
++ <custom-qrcode :value="qrCodeValue" />
++ </v-toolbar>
+ <v-card-text>
+ <v-row>
+ <!-- Source Table -->
+ <v-col cols="6">
+ <div class="dataTable">
+ <div class="toolbar">
+ <div class="toolbarTitle">
+ <p style="color: #999">{{ $t('wms.warehouseWorking.warehouseProcessing.source') }}</p>
+ </div>
+ <tooltip-btn
+ icon="mdi-plus"
+ :tooltip-text="$t('system.page.add')"
+ size="x-small"
+ :disabled="operateDisabled"
+ @click="method.openSelect('source')"
+ ></tooltip-btn>
+ </div>
+ <vxe-table
+ ref="xTableSource"
+ :column-config="{ minWidth: '100px' }"
+ :data="data.form.source_detail_list"
+ :height="SYSTEM_HEIGHT.SELECT_TABLE"
+ :edit-config="{ trigger: 'click', mode: 'cell' }"
+ :edit-rules="data.validRulesSource"
+ align="center"
+ >
+ <template #empty>
+ {{ i18n.global.t('system.page.noData') }}
+ </template>
+ <vxe-column type="seq" width="60"></vxe-column>
+ <vxe-column field="operate" width="50" :title="$t('system.page.operate')" :resizable="false">
+ <template #default="{ row }">
+ <tooltip-btn
+ :flat="true"
+ icon="mdi-delete-outline"
+ :tooltip-text="$t('system.page.delete')"
+ :icon-color="errorColor"
+ @click="method.deleteRowSource(row)"
+ ></tooltip-btn>
+ </template>
+ </vxe-column>
+ <vxe-column field="spu_code" :title="$t('wms.warehouseWorking.warehouseProcessing.spu_code')"></vxe-column>
+ <vxe-column field="spu_name" :title="$t('wms.warehouseWorking.warehouseProcessing.spu_name')"></vxe-column>
+ <vxe-column field="sku_code" :title="$t('wms.warehouseWorking.warehouseProcessing.sku_code')"></vxe-column>
+ <vxe-column
+ field="qty"
+ :title="$t('wms.warehouseWorking.warehouseProcessing.qty')"
+ :edit-render="{ autofocus: '.vxe-input--inner' }"
+ >
+ <template #edit="{ row }">
+ <vxe-input v-model="row.qty" type="text"></vxe-input>
+ </template>
+ </vxe-column>
+ <vxe-column field="unit" :title="$t('wms.warehouseWorking.warehouseProcessing.unit')"></vxe-column>
+ </vxe-table>
+ </div>
+ </v-col>
+
+ <!-- Target Table -->
+ <v-col cols="6">
+ <div class="dataTable">
+ <div class="toolbar">
+ <div class="toolbarTitle">
+ <p style="color: #999">{{ $t('wms.warehouseWorking.warehouseProcessing.target') }}</p>
+ </div>
+ <tooltip-btn
+ icon="mdi-plus"
+ :tooltip-text="$t('system.page.add')"
+ size="x-small"
+ :disabled="operateDisabled"
+ @click="method.openSelect('target')"
+ ></tooltip-btn>
+ </div>
+ <vxe-table
+ ref="xTableTarget"
+ :column-config="{ minWidth: '100px' }"
+ :data="data.form.target_detail_list"
+ :height="SYSTEM_HEIGHT.SELECT_TABLE"
+ :edit-config="{ trigger: 'click', mode: 'cell' }"
+ :edit-rules="data.validRulesTarget"
+ align="center"
+ >
+ <template #empty>
+ {{ i18n.global.t('system.page.noData') }}
+ </template>
+ <vxe-column type="seq" width="60"></vxe-column>
+ <vxe-column field="operate" width="50" :title="$t('system.page.operate')" :resizable="false">
+ <template #default="{ row }">
+ <tooltip-btn
+ :flat="true"
+ icon="mdi-delete-outline"
+ :tooltip-text="$t('system.page.delete')"
+ :icon-color="errorColor"
+ @click="method.deleteRowTarget(row)"
+ ></tooltip-btn>
+ </template>
+ </vxe-column>
+ <vxe-column field="spu_code" :title="$t('wms.warehouseWorking.warehouseProcessing.spu_code')"></vxe-column>
+ <vxe-column field="spu_name" :title="$t('wms.warehouseWorking.warehouseProcessing.spu_name')"></vxe-column>
+ <vxe-column field="sku_code" :title="$t('wms.warehouseWorking.warehouseProcessing.sku_code')"></vxe-column>
+ <vxe-column
+ field="qty"
+ :title="$t('wms.warehouseWorking.warehouseProcessing.qty')"
+ :edit-render="{ autofocus: '.vxe-input--inner' }"
+ >
+ <template #edit="{ row }">
+ <vxe-input v-model="row.qty" type="text"></vxe-input>
+ </template>
+ </vxe-column>
+ <vxe-column field="unit" width="60" :title="$t('wms.warehouseWorking.warehouseProcessing.unit')"></vxe-column>
+ <vxe-column field="location_name" :title="$t('wms.warehouseWorking.warehouseProcessing.target_location')" :edit-render="{}">
+ <template #edit="{ row }">
+ <vxe-input v-model="row.location_name" readonly type="search" @search-click="method.openLocationSelect(row)"></vxe-input>
+ </template>
+ </vxe-column>
+ </vxe-table>
+ </div>
+ </v-col>
+ </v-row>
+ </v-card-text>
+ <v-card-actions class="justify-end">
+ <v-btn variant="text" @click="method.closeDialog">{{ $t('system.page.close') }}</v-btn>
+ <v-btn color="primary" variant="text" :disabled="operateDisabled" @click="method.submit">{{ $t('system.page.submit') }}</v-btn>
+ </v-card-actions>
+ </v-card>
+ </template>
+ </v-dialog>
+
+ <commodity-select :show-dialog="data.showCommodityDialogSelect" @close="method.closeDialogSelect('source')" @sureSelect="method.sureSelect" />
+ <sku-select :show-dialog="data.showSkuDialogSelect" @close="method.closeDialogSelect('target')" @sureSelect="method.sureSelect" />
+ <location-select :show-dialog="data.showLocationDialogSelect" @close="method.closeLocationDialogSelect" @sureSelect="method.sureSelectLocation" />
+</template>
+
+<script lang="ts" setup>
+import { reactive, computed, ref, watch } from 'vue'
+import { VxeTablePropTypes } from 'vxe-table'
+import { WarehouseProcessingVO, WarehouseProcessingDetailVO } from '@/types/WarehouseWorking/WarehouseProcessing'
+import i18n from '@/languages/i18n'
+import { hookComponent } from '@/components/system/index'
+import { addStockProcess } from '@/api/wms/warehouseProcessing'
+import { SYSTEM_HEIGHT, errorColor } from '@/constant/style'
+import { removeObjectNull } from '@/utils/common'
+import { PROCESS_JOB_COMBINE, PROCESS_JOB_SPLIT } from '@/constant/warehouseWorking'
+import commoditySelect from '@/components/select/commodity-select.vue'
+import locationSelect from '@/components/select/location-select.vue'
+import skuSelect from '@/components/select/sku-select.vue'
+import tooltipBtn from '@/components/tooltip-btn.vue'
++import customQrcode from '@/components/custom-qrcode.vue'
+import { exportData } from '@/utils/exportTable'
+import { isInteger } from '@/utils/dataVerification/tableRule'
+
+const emit = defineEmits(['close', 'saveSuccess'])
+const xTableSource = ref()
+const xTableTarget = ref()
+
+const props = defineProps<{
+ showDialog: boolean
+ form: WarehouseProcessingVO
+ processType: boolean
+}>()
+
+const isShow = computed(() => props.showDialog)
+const isUpdate = computed(() => props.form.id && props.form.id > 0)
+const jobTypeComp = computed(() => (data.form.job_type === PROCESS_JOB_COMBINE
+ ? i18n.global.t('wms.warehouseWorking.warehouseProcessing.process_combine')
+ : i18n.global.t('wms.warehouseWorking.warehouseProcessing.process_split')))
+const operateDisabled = computed(() => !!isUpdate.value)
++const qrCodeValue = computed(() => data.form.id.toString())
+
+const method = reactive({
+ initForm: () => {
+ data.form = props.form
+ data.form.job_type = props.processType
+ },
+
+ closeDialog: () => {
+ emit('close')
+ },
+
+ openSelect: (type: string) => {
+ data.curSelectType = type
+
+ if (type === 'source') {
+ data.showCommodityDialogSelect = true
+ } else if (type === 'target') {
+ // Target should select the data with 'sku-select-modal'
+ data.showSkuDialogSelect = true
+ }
+ },
+
+ closeDialogSelect: (type: string) => {
+ if (type === 'source') {
+ data.showCommodityDialogSelect = false
+ } else if (type === 'target') {
+ // Target should select the data with 'sku-select-modal'
+ data.showSkuDialogSelect = false
+ }
+ },
+
+ sureSelect: (selectRecords: any) => {
+ if (data.curSelectType === 'source') {
+ method.insertSourceData(selectRecords)
+ } else if (data.curSelectType === 'target') {
+ method.insertTargetData(selectRecords)
+ }
+ },
+
+ openLocationSelect: (row: WarehouseProcessingDetailVO) => {
+ data.curSelectRow = row
+ data.showLocationDialogSelect = true
+ },
+
+ closeLocationDialogSelect: () => {
+ data.showLocationDialogSelect = false
+ },
+
+ sureSelectLocation: (selectRecords: any) => {
+ if (selectRecords.length > 0) {
+ const $table = xTableTarget.value
+ const tableData = $table.getTableData().fullData
+ tableData.forEach((row: WarehouseProcessingDetailVO) => {
+ if (data.curSelectRow.sku_id === row.sku_id) {
+ row.goods_location_id = selectRecords[0].id
+ row.location_name = selectRecords[0].location_name
+ }
+ })
+ // Tips: Must to reload!
+ $table.reloadData(tableData)
+ }
+ },
+
+ insertSourceData: (selectRecords: any) => {
+ const $table = xTableSource.value
+ const tableData = $table.getTableData().fullData
+
+ // Combine: That can select more source commodity
+ if (data.form.job_type === PROCESS_JOB_COMBINE) {
+ for (const record of selectRecords) {
+ const isRepeat = tableData.some((data: WarehouseProcessingDetailVO) => data.sku_id === record.sku_id)
+ if (isRepeat) {
+ continue
+ }
+
+ $table.insertAt(
+ {
+ id: 0,
+ stock_process_id: 0,
+ sku_id: record.sku_id,
+ goods_owner_id: record.goods_owner_id,
+ goods_location_id: record.goods_location_id,
+ qty: record.qty_available || 0,
+ tenant_id: 0,
+ is_source: true,
+ spu_code: record.spu_code,
+ spu_name: record.spu_name,
+ sku_code: record.sku_code,
+ unit: record.unit,
+ is_update_stock: false,
+ qty_available: record.qty_available
+ },
+ -1
+ )
+ // })
+ }
+ } else if (data.form.job_type === PROCESS_JOB_SPLIT) {
+ // Split: That just can select one source commodity.
+ // It should remove all data before insert.
+ $table.remove()
+ $table.insertAt(
+ {
+ id: 0,
+ stock_process_id: 0,
+ sku_id: selectRecords[0].sku_id,
+ goods_owner_id: selectRecords[0].goods_owner_id,
+ goods_location_id: selectRecords[0].goods_location_id,
+ qty: selectRecords[0].qty_available || 0,
+ tenant_id: 0,
+ is_source: true,
+ spu_code: selectRecords[0].spu_code,
+ spu_name: selectRecords[0].spu_name,
+ sku_code: selectRecords[0].sku_code,
+ unit: selectRecords[0].unit,
+ is_update_stock: false,
+ qty_available: selectRecords[0].qty_available
+ },
+ -1
+ )
+ }
+ },
+
+ insertTargetData: (selectRecords: any) => {
+ const $table = xTableTarget.value
+ const tableData = $table.getTableData().fullData
+
+ // Combine: That just can select one target commodity
+ if (data.form.job_type === PROCESS_JOB_COMBINE) {
+ // It should remove all data before insert.
+ $table.remove()
+ $table.insertAt(
+ {
+ id: 0,
+ stock_process_id: 0,
+ sku_id: selectRecords[0].sku_id,
+ goods_owner_id: 0,
+ goods_location_id: 0,
+ qty: 0,
+ tenant_id: 0,
+ is_source: false,
+ spu_code: selectRecords[0].spu_code,
+ spu_name: selectRecords[0].spu_name,
+ sku_code: selectRecords[0].sku_code,
+ unit: selectRecords[0].unit,
+ is_update_stock: false
+ },
+ -1
+ )
+ } else if (data.form.job_type === PROCESS_JOB_SPLIT) {
+ // Split: That can select more target commodity
+ for (const record of selectRecords) {
+ const isRepeat = tableData.some((data: WarehouseProcessingDetailVO) => data.sku_id === record.sku_id)
+ if (isRepeat) {
+ continue
+ }
+ $table.insertAt(
+ {
+ id: 0,
+ stock_process_id: 0,
+ sku_id: record.sku_id,
+ goods_owner_id: 0,
+ goods_location_id: 0,
+ qty: 0,
+ tenant_id: 0,
+ is_source: false,
+ spu_code: record.spu_code,
+ spu_name: record.spu_name,
+ sku_code: record.sku_code,
+ unit: record.unit,
+ is_update_stock: false
+ },
+ -1
+ )
+ }
+ }
+ },
+
+ // Export table
+ exportTable: (type: string) => {
+ const $table = type === 'source' ? xTableSource.value : xTableTarget.value
+ exportData({
+ table: $table,
+ filename: i18n.global.t('router.sideBar.commodityManagement'),
+ columnFilterMethod({ column }: any) {
+ return !['checkbox'].includes(column?.type) && !['operate'].includes(column?.field)
+ }
+ })
+ },
+
+ submit: async () => {
+ const validSource = await method.validSourceTable()
+ const validTarget = await method.validTargetTable()
+ if (!validSource || !validTarget) {
+ return
+ }
+
+ const form = method.constructFormBody()
+
+ const { data: res } = await addStockProcess(form)
+ if (!res.isSuccess) {
+ hookComponent.$message({
+ type: 'error',
+ content: res.errorMessage
+ })
+ return
+ }
+ hookComponent.$message({
+ type: 'success',
+ content: `${ i18n.global.t('system.page.submit') }${ i18n.global.t('system.tips.success') }`
+ })
+ emit('saveSuccess')
+ },
+
+ constructFormBody: () => {
+ const $tableSource = xTableSource.value
+ const $tableTarget = xTableTarget.value
+
+ const tableSourceRecords = $tableSource.getTableData().fullData
+ const tableTargetRecords = $tableTarget.getTableData().fullData
+
+ // Need combine source and target to server.
+ let form = { ...data.form }
+ form.detailList = [...tableSourceRecords, ...tableTargetRecords]
+ form = removeObjectNull(form)
+
+ delete form.source_detail_list
+ delete form.target_detail_list
+
+ return form
+ },
+
+ validSourceTable: async () => {
+ const $table = xTableSource.value
+ const tableData = $table.getTableData().fullData
+
+ // 1.The table must have data.
+ if (!tableData.length) {
+ hookComponent.$message({
+ type: 'error',
+ content: i18n.global.t('system.tips.detailLengthIsZero')
+ })
+ return false
+ }
+
+ // 2.The properties valid.
+ const errMap = await $table.validate()
+ if (errMap) {
+ hookComponent.$message({
+ type: 'error',
+ content: i18n.global.t('system.checkText.checkFormFail')
+ })
+ return false
+ }
+
+ return true
+ },
+
+ validTargetTable: async () => {
+ const $table = xTableTarget.value
+ const tableData = $table.getTableData().fullData
+
+ // 1.The table must have data.
+ if (!tableData.length) {
+ hookComponent.$message({
+ type: 'error',
+ content: i18n.global.t('system.tips.detailLengthIsZero')
+ })
+ return false
+ }
+
+ // 2.The properties valid.
+ const errMap = await $table.validate()
+ if (errMap) {
+ hookComponent.$message({
+ type: 'error',
+ content: i18n.global.t('system.checkText.checkFormFail')
+ })
+ return false
+ }
+
+ return true
+ },
+
+ // The 'qty' can't more than 'qty_available'
+ validQty: ({ cellValue, row }: any) => {
+ const qty = cellValue || 0
+ const qtyAvailable = row.qty_available || 0
+
+ if (qty > qtyAvailable) {
+ return new Error(`${ i18n.global.t('wms.warehouseWorking.warehouseProcessing.qtyMoreThanAvailable') } ${ qtyAvailable }`)
+ }
+ },
+
+ deleteRowSource: (row: WarehouseProcessingDetailVO) => {
+ hookComponent.$dialog({
+ content: i18n.global.t('system.tips.beforeDeleteDetailMessage'),
+ handleConfirm: async () => {
+ if (row) {
+ const $table = xTableSource.value
+ $table.remove(row)
+ }
+ }
+ })
+ },
+
+ deleteRowTarget: (row: WarehouseProcessingDetailVO) => {
+ hookComponent.$dialog({
+ content: i18n.global.t('system.tips.beforeDeleteDetailMessage'),
+ handleConfirm: async () => {
+ if (row) {
+ const $table = xTableTarget.value
+ $table.remove(row)
+ }
+ }
+ })
+ }
+})
+
+const data = reactive({
+ tableData: [],
+ // 'source' | 'target'
+ curSelectType: '',
+
+ showCommodityDialogSelect: false,
+ showSkuDialogSelect: false,
+ showLocationDialogSelect: false,
+
+ form: ref<WarehouseProcessingVO>({
+ id: 0,
+ job_code: '',
+ job_type: PROCESS_JOB_COMBINE,
+ process_status: false,
+ processor: '',
+ process_time: '',
+ source_detail_list: [],
+ target_detail_list: []
+ }),
+ curSelectRow: ref<WarehouseProcessingDetailVO>({
+ id: 0,
+ stock_process_id: 0,
+ sku_id: 0,
+ goods_owner_id: 0,
+ goods_location_id: 0,
+ qty: 0,
+ is_source: true,
+ spu_code: '',
+ spu_name: '',
+ sku_code: '',
+ unit: '',
+ is_update_stock: false
+ }),
+ validRulesSource: ref<any>({
+ qty: [
+ { required: true, message: `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('wms.warehouseWorking.warehouseProcessing.qty') }` },
+ {
+ validator: method.validQty
+ },
+ {
+ validator: isInteger,
+ validNumerical: 'greaterThanZero',
+ trigger: 'change'
+ }
+ ]
+ }),
+ validRulesTarget: ref<any>({
+ qty: [
+ { required: true, message: `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('wms.warehouseWorking.warehouseProcessing.qty') }` },
+ {
+ validator: isInteger,
+ validNumerical: 'greaterThanZero',
+ trigger: 'change'
+ }
+ ],
+ location_name: [
+ {
+ required: true,
+ message: `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('wms.warehouseWorking.warehouseProcessing.target_location') }`
+ }
+ ]
+ })
+})
+
+watch(
+ () => isShow.value,
+ (val) => {
+ if (val) {
+ method.initForm()
+ }
+ }
+)
+</script>
+
+<style scoped lang="less">
+.mainForm {
+ background-color: #f9f9f9;
+ border-radius: 5px;
+ padding: 20px;
+ box-sizing: border-box;
+ overflow: auto;
+}
+
+.toolbar {
+ height: 40px;
+ display: flex;
+ justify-content: space-between;
+}
+
+.toolbarTitle {
+ display: flex;
+ // justify-content: center;
+ // align-items: center;
+}
+</style>
diff --cc frontend/src/view/warehouseWorking/warehouseTaking/add-or-update-taking.vue
index 47c073c,6a93977..d6071a1
--- a/frontend/src/view/warehouseWorking/warehouseTaking/add-or-update-taking.vue
+++ b/frontend/src/view/warehouseWorking/warehouseTaking/add-or-update-taking.vue
@@@ -1,322 -1,326 +1,326 @@@
-<!-- Warehouse Taking Operate Dialog -->
-<template>
- <v-dialog v-model="isShow" :width="'30%'" transition="dialog-top-transition" :persistent="true">
- <template #default>
- <v-card>
- <v-toolbar color="white" :title="`${$t('router.sideBar.warehouseTaking')}`">
- <custom-qrcode :value="qrCodeValue" />
- </v-toolbar>
- <v-card-text>
- <div class="header">
- <div class="headerBtn">
- <tooltip-btn
- size="x-small"
- icon="mdi-home-plus-outline"
- :tooltip-text="$t('wms.warehouseWorking.warehouseTaking.addFromStock')"
- @click="method.openCommoditySelect()"
- ></tooltip-btn>
- <tooltip-btn
- size="x-small"
- icon="mdi-store-plus-outline"
- :tooltip-text="$t('wms.warehouseWorking.warehouseTaking.addFromCommodity')"
- :disabled="isFromStock"
- @click="method.openSkuSelect()"
- ></tooltip-btn>
- </div>
- <div class="headerTips">
- <v-tooltip :text="$t('wms.warehouseWorking.warehouseTaking.addTips')">
- <template #activator="{ props }">
- <v-btn v-bind="props" size="x-small" variant="text" icon="mdi-help-circle" color="blue-lighten-2"></v-btn>
- </template>
- </v-tooltip>
- </div>
- </div>
- <v-form ref="formRef">
- <v-text-field
- v-model="data.form.spu_code"
- :label="$t('base.commodityManagement.spu_code')"
- :rules="data.rules.spu_code"
- variant="outlined"
- readonly
- clearable
- @click:clear="method.clearCommodity"
- ></v-text-field>
- <v-text-field
- v-model="data.form.spu_name"
- :label="$t('base.commodityManagement.spu_name')"
- :rules="data.rules.spu_name"
- variant="outlined"
- disabled
- ></v-text-field>
- <v-text-field
- v-model="data.form.sku_code"
- :label="$t('base.commodityManagement.sku_code')"
- :rules="data.rules.sku_code"
- variant="outlined"
- disabled
- ></v-text-field>
- <v-text-field
- v-model="data.form.warehouse_name"
- :label="$t('wms.warehouseWorking.warehouseTaking.warehouse')"
- :rules="data.rules.warehouse_name"
- variant="outlined"
- disabled
- ></v-text-field>
- <v-text-field
- v-model="data.form.location_name"
- :label="$t('wms.warehouseWorking.warehouseTaking.location_name')"
- :rules="data.rules.location_name"
- variant="outlined"
- :disabled="isFromStock"
- @click="method.openLocationSelect"
- @click:clear="method.clearLocation"
- ></v-text-field>
- <v-text-field
- v-model="data.form.book_qty"
- :label="$t('wms.warehouseWorking.warehouseTaking.book_qty')"
- :rules="data.rules.book_qty"
- variant="outlined"
- disabled
- ></v-text-field>
- </v-form>
- </v-card-text>
- <v-card-actions class="justify-end">
- <v-btn variant="text" @click="method.closeDialog">{{ $t('system.page.close') }}</v-btn>
- <v-btn color="primary" variant="text" :disabled="operateDisabled" @click="method.submit">{{ $t('system.page.submit') }}</v-btn>
- </v-card-actions>
- </v-card>
- </template>
- </v-dialog>
-
- <commodity-select
- :show-dialog="data.showCommodityDialogSelect"
- @close="method.closeCommodityDialogSelect"
- @sureSelect="method.sureSelectCommodity"
- />
- <sku-select :show-dialog="data.showSkuDialogSelect" @close="method.closeDialogSelectSku" @sureSelect="method.sureSelectSku" />
- <location-select :show-dialog="data.showLocationDialogSelect" @close="method.closeDialogSelectLocation" @sureSelect="method.sureSelectLocation" />
-</template>
-
-<script lang="ts" setup>
-import { reactive, computed, ref, watch } from 'vue'
-import { hookComponent } from '@/components/system/index'
-import { addStockTaking } from '@/api/wms/warehouseTaking'
-import { WarehouseTakingVO } from '@/types/WarehouseWorking/WarehouseTaking'
-import { removeObjectNull } from '@/utils/common'
-import { TAKING_JOB_FINISH } from '@/constant/warehouseWorking'
-import i18n from '@/languages/i18n'
-import commoditySelect from '@/components/select/commodity-select.vue'
-import tooltipBtn from '@/components/tooltip-btn.vue'
-import locationSelect from '@/components/select/location-select.vue'
-import skuSelect from '@/components/select/sku-select.vue'
-import customQrcode from '@/components/custom-qrcode.vue'
-
-const formRef = ref()
-const emit = defineEmits(['close', 'saveSuccess'])
-const isUpdate = computed(() => props.form.id && props.form.id > 0)
-const operateDisabled = computed(() => !!isUpdate.value)
-const isFromStock = computed(() => data.curStockID > 0)
-const qrCodeValue = computed(() => data.form.id.toString())
-
-const props = defineProps<{
- showDialog: boolean
- form: WarehouseTakingVO
-}>()
-
-const isShow = computed(() => props.showDialog)
-
-const data = reactive({
- showCommodityDialogSelect: false,
- showLocationDialogSelect: false,
- showSkuDialogSelect: false,
-
- // There has value when choose from stock.
- curStockID: 0,
-
- form: ref<WarehouseTakingVO>({
- id: 0,
- job_code: '',
- job_status: TAKING_JOB_FINISH,
- sku_id: 0,
- goods_owner_id: 0,
- goods_location_id: 0,
- book_qty: 0,
- counted_qty: 0,
- difference_qty: 0,
- spu_code: '',
- spu_name: '',
- sku_code: '',
- warehouse_name: '',
- location_name: '',
- handler: '',
- handle_time: '',
- adjust_status: false,
- creator: '',
- create_time: ''
- }),
- rules: {
- job_type: [],
- book_qty: [],
- warehouse_name: [
- (val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('wms.warehouseWorking.warehouseTaking.warehouse') }!`
- ],
- location_name: [
- (val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('wms.warehouseWorking.warehouseTaking.location_name') }!`
- ],
- spu_code: [(val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('base.commodityManagement.spu_code') }!`],
- spu_name: [(val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('base.commodityManagement.spu_name') }!`],
- sku_code: [(val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('base.commodityManagement.sku_code') }!`],
- sku_name: [(val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('base.commodityManagement.sku_name') }!`]
- }
-})
-
-const method = reactive({
- closeDialog: () => {
- emit('close')
- },
-
- initForm: () => {
- data.form = props.form
- },
-
- openCommoditySelect: () => {
- data.showCommodityDialogSelect = true
- },
-
- closeCommodityDialogSelect: () => {
- data.showCommodityDialogSelect = false
- },
-
- sureSelectCommodity: (selectRecords: any) => {
- try {
- data.curStockID = selectRecords[0].id
- data.form.sku_id = selectRecords[0].sku_id
- data.form.goods_owner_id = selectRecords[0].goods_owner_id
- data.form.goods_location_id = selectRecords[0].goods_location_id
- data.form.warehouse_name = selectRecords[0].warehouse_name
- data.form.location_name = selectRecords[0].location_name
- data.form.spu_code = selectRecords[0].spu_code
- data.form.spu_name = selectRecords[0].spu_name
- data.form.sku_code = selectRecords[0].sku_code
- data.form.book_qty = selectRecords[0].qty_available
- } catch (error) {
- // console.error(error)
- }
- },
-
- clearCommodity: () => {
- data.curStockID = 0
- data.form.sku_id = 0
- data.form.goods_location_id = 0
- data.form.warehouse_name = ''
- data.form.location_name = ''
- data.form.spu_code = ''
- data.form.spu_name = ''
- data.form.sku_code = ''
- data.form.book_qty = 0
- },
-
- openSkuSelect: () => {
- data.showSkuDialogSelect = true
- },
-
- closeDialogSelectSku: () => {
- data.showSkuDialogSelect = false
- },
-
- sureSelectSku: (selectRecords: any) => {
- if (selectRecords.length > 0) {
- data.form.sku_id = selectRecords[0].sku_id
- data.form.goods_owner_id = selectRecords[0].goods_owner_id
- data.form.goods_location_id = selectRecords[0].goods_location_id
- // The book qty should zero when the data from commodity.
- data.form.book_qty = 0
- data.form.spu_code = selectRecords[0].spu_code
- data.form.spu_name = selectRecords[0].spu_name
- data.form.sku_code = selectRecords[0].sku_code
- }
- },
-
- openLocationSelect: () => {
- data.showLocationDialogSelect = true
- },
-
- closeDialogSelectLocation: () => {
- data.showLocationDialogSelect = false
- },
-
- sureSelectLocation: (selectRecords: any) => {
- if (selectRecords.length > 0) {
- data.form.goods_location_id = selectRecords[0].id
- data.form.warehouse_name = selectRecords[0].warehouse_name
- data.form.location_name = selectRecords[0].location_name
- }
- },
-
- clearLocation: () => {
- data.form.goods_location_id = 0
- data.form.warehouse_name = ''
- data.form.location_name = ''
- },
-
- submit: async () => {
- const { valid } = await formRef.value.validate()
-
- const form = method.constructFormBody()
-
- if (valid) {
- const { data: res } = await addStockTaking(form)
- if (!res.isSuccess) {
- hookComponent.$message({
- type: 'error',
- content: res.errorMessage
- })
- return
- }
- hookComponent.$message({
- type: 'success',
- content: `${ i18n.global.t('system.page.submit') }${ i18n.global.t('system.tips.success') }`
- })
- emit('saveSuccess')
- } else {
- hookComponent.$message({
- type: 'error',
- content: i18n.global.t('system.checkText.checkFormFail')
- })
- }
- },
-
- constructFormBody: () => {
- let form = { ...data.form }
- form = removeObjectNull(form)
-
- return form
- }
-})
-
-watch(
- () => isShow.value,
- (val) => {
- if (val) {
- method.initForm()
- }
- }
-)
-</script>
-
-<style scoped lang="less">
-.v-form {
- div {
- margin-bottom: 7px;
- }
-}
-
-.header {
- display: flex;
- margin-bottom: 15px;
- justify-content: space-between;
-}
-
-.headerBtn {
-}
-.headerTips {
- display: flex;
- align-items: center;
-}
-</style>
+<!-- Warehouse Taking Operate Dialog -->
+<template>
+ <v-dialog v-model="isShow" :width="'30%'" transition="dialog-top-transition" :persistent="true">
+ <template #default>
+ <v-card>
- <v-toolbar color="white" :title="`${$t('router.sideBar.warehouseTaking')}`"></v-toolbar>
++ <v-toolbar color="white" :title="`${$t('router.sideBar.warehouseTaking')}`">
++ <custom-qrcode :value="qrCodeValue" />
++ </v-toolbar>
+ <v-card-text>
+ <div class="header">
+ <div class="headerBtn">
+ <tooltip-btn
+ size="x-small"
+ icon="mdi-home-plus-outline"
+ :tooltip-text="$t('wms.warehouseWorking.warehouseTaking.addFromStock')"
+ @click="method.openCommoditySelect()"
+ ></tooltip-btn>
+ <tooltip-btn
+ size="x-small"
+ icon="mdi-store-plus-outline"
+ :tooltip-text="$t('wms.warehouseWorking.warehouseTaking.addFromCommodity')"
+ :disabled="isFromStock"
+ @click="method.openSkuSelect()"
+ ></tooltip-btn>
+ </div>
+ <div class="headerTips">
+ <v-tooltip :text="$t('wms.warehouseWorking.warehouseTaking.addTips')">
+ <template #activator="{ props }">
+ <v-btn v-bind="props" size="x-small" variant="text" icon="mdi-help-circle" color="blue-lighten-2"></v-btn>
+ </template>
+ </v-tooltip>
+ </div>
+ </div>
+ <v-form ref="formRef">
+ <v-text-field
+ v-model="data.form.spu_code"
+ :label="$t('base.commodityManagement.spu_code')"
+ :rules="data.rules.spu_code"
+ variant="outlined"
+ readonly
+ clearable
+ @click:clear="method.clearCommodity"
+ ></v-text-field>
+ <v-text-field
+ v-model="data.form.spu_name"
+ :label="$t('base.commodityManagement.spu_name')"
+ :rules="data.rules.spu_name"
+ variant="outlined"
+ disabled
+ ></v-text-field>
+ <v-text-field
+ v-model="data.form.sku_code"
+ :label="$t('base.commodityManagement.sku_code')"
+ :rules="data.rules.sku_code"
+ variant="outlined"
+ disabled
+ ></v-text-field>
+ <v-text-field
+ v-model="data.form.warehouse_name"
+ :label="$t('wms.warehouseWorking.warehouseTaking.warehouse')"
+ :rules="data.rules.warehouse_name"
+ variant="outlined"
+ disabled
+ ></v-text-field>
+ <v-text-field
+ v-model="data.form.location_name"
+ :label="$t('wms.warehouseWorking.warehouseTaking.location_name')"
+ :rules="data.rules.location_name"
+ variant="outlined"
+ :disabled="isFromStock"
+ @click="method.openLocationSelect"
+ @click:clear="method.clearLocation"
+ ></v-text-field>
+ <v-text-field
+ v-model="data.form.book_qty"
+ :label="$t('wms.warehouseWorking.warehouseTaking.book_qty')"
+ :rules="data.rules.book_qty"
+ variant="outlined"
+ disabled
+ ></v-text-field>
+ </v-form>
+ </v-card-text>
+ <v-card-actions class="justify-end">
+ <v-btn variant="text" @click="method.closeDialog">{{ $t('system.page.close') }}</v-btn>
+ <v-btn color="primary" variant="text" :disabled="operateDisabled" @click="method.submit">{{ $t('system.page.submit') }}</v-btn>
+ </v-card-actions>
+ </v-card>
+ </template>
+ </v-dialog>
+
+ <commodity-select
+ :show-dialog="data.showCommodityDialogSelect"
+ @close="method.closeCommodityDialogSelect"
+ @sureSelect="method.sureSelectCommodity"
+ />
+ <sku-select :show-dialog="data.showSkuDialogSelect" @close="method.closeDialogSelectSku" @sureSelect="method.sureSelectSku" />
+ <location-select :show-dialog="data.showLocationDialogSelect" @close="method.closeDialogSelectLocation" @sureSelect="method.sureSelectLocation" />
+</template>
+
+<script lang="ts" setup>
+import { reactive, computed, ref, watch } from 'vue'
+import { hookComponent } from '@/components/system/index'
+import { addStockTaking } from '@/api/wms/warehouseTaking'
+import { WarehouseTakingVO } from '@/types/WarehouseWorking/WarehouseTaking'
+import { removeObjectNull } from '@/utils/common'
+import { TAKING_JOB_FINISH } from '@/constant/warehouseWorking'
+import i18n from '@/languages/i18n'
+import commoditySelect from '@/components/select/commodity-select.vue'
+import tooltipBtn from '@/components/tooltip-btn.vue'
+import locationSelect from '@/components/select/location-select.vue'
+import skuSelect from '@/components/select/sku-select.vue'
++import customQrcode from '@/components/custom-qrcode.vue'
+
+const formRef = ref()
+const emit = defineEmits(['close', 'saveSuccess'])
+const isUpdate = computed(() => props.form.id && props.form.id > 0)
+const operateDisabled = computed(() => !!isUpdate.value)
+const isFromStock = computed(() => data.curStockID > 0)
++const qrCodeValue = computed(() => data.form.id.toString())
+
+const props = defineProps<{
+ showDialog: boolean
+ form: WarehouseTakingVO
+}>()
+
+const isShow = computed(() => props.showDialog)
+
+const data = reactive({
+ showCommodityDialogSelect: false,
+ showLocationDialogSelect: false,
+ showSkuDialogSelect: false,
+
+ // There has value when choose from stock.
+ curStockID: 0,
+
+ form: ref<WarehouseTakingVO>({
+ id: 0,
+ job_code: '',
+ job_status: TAKING_JOB_FINISH,
+ sku_id: 0,
+ goods_owner_id: 0,
+ goods_location_id: 0,
+ book_qty: 0,
+ counted_qty: 0,
+ difference_qty: 0,
+ spu_code: '',
+ spu_name: '',
+ sku_code: '',
+ warehouse_name: '',
+ location_name: '',
+ handler: '',
+ handle_time: '',
+ adjust_status: false,
+ creator: '',
+ create_time: ''
+ }),
+ rules: {
+ job_type: [],
+ book_qty: [],
+ warehouse_name: [
+ (val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('wms.warehouseWorking.warehouseTaking.warehouse') }!`
+ ],
+ location_name: [
+ (val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('wms.warehouseWorking.warehouseTaking.location_name') }!`
+ ],
+ spu_code: [(val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('base.commodityManagement.spu_code') }!`],
+ spu_name: [(val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('base.commodityManagement.spu_name') }!`],
+ sku_code: [(val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('base.commodityManagement.sku_code') }!`],
+ sku_name: [(val: string) => !!val || `${ i18n.global.t('system.checkText.mustInput') }${ i18n.global.t('base.commodityManagement.sku_name') }!`]
+ }
+})
+
+const method = reactive({
+ closeDialog: () => {
+ emit('close')
+ },
+
+ initForm: () => {
+ data.form = props.form
+ },
+
+ openCommoditySelect: () => {
+ data.showCommodityDialogSelect = true
+ },
+
+ closeCommodityDialogSelect: () => {
+ data.showCommodityDialogSelect = false
+ },
+
+ sureSelectCommodity: (selectRecords: any) => {
+ try {
+ data.curStockID = selectRecords[0].id
+ data.form.sku_id = selectRecords[0].sku_id
+ data.form.goods_owner_id = selectRecords[0].goods_owner_id
+ data.form.goods_location_id = selectRecords[0].goods_location_id
+ data.form.warehouse_name = selectRecords[0].warehouse_name
+ data.form.location_name = selectRecords[0].location_name
+ data.form.spu_code = selectRecords[0].spu_code
+ data.form.spu_name = selectRecords[0].spu_name
+ data.form.sku_code = selectRecords[0].sku_code
+ data.form.book_qty = selectRecords[0].qty_available
+ } catch (error) {
+ // console.error(error)
+ }
+ },
+
+ clearCommodity: () => {
+ data.curStockID = 0
+ data.form.sku_id = 0
+ data.form.goods_location_id = 0
+ data.form.warehouse_name = ''
+ data.form.location_name = ''
+ data.form.spu_code = ''
+ data.form.spu_name = ''
+ data.form.sku_code = ''
+ data.form.book_qty = 0
+ },
+
+ openSkuSelect: () => {
+ data.showSkuDialogSelect = true
+ },
+
+ closeDialogSelectSku: () => {
+ data.showSkuDialogSelect = false
+ },
+
+ sureSelectSku: (selectRecords: any) => {
+ if (selectRecords.length > 0) {
+ data.form.sku_id = selectRecords[0].sku_id
+ data.form.goods_owner_id = selectRecords[0].goods_owner_id
+ data.form.goods_location_id = selectRecords[0].goods_location_id
+ // The book qty should zero when the data from commodity.
+ data.form.book_qty = 0
+ data.form.spu_code = selectRecords[0].spu_code
+ data.form.spu_name = selectRecords[0].spu_name
+ data.form.sku_code = selectRecords[0].sku_code
+ }
+ },
+
+ openLocationSelect: () => {
+ data.showLocationDialogSelect = true
+ },
+
+ closeDialogSelectLocation: () => {
+ data.showLocationDialogSelect = false
+ },
+
+ sureSelectLocation: (selectRecords: any) => {
+ if (selectRecords.length > 0) {
+ data.form.goods_location_id = selectRecords[0].id
+ data.form.warehouse_name = selectRecords[0].warehouse_name
+ data.form.location_name = selectRecords[0].location_name
+ }
+ },
+
+ clearLocation: () => {
+ data.form.goods_location_id = 0
+ data.form.warehouse_name = ''
+ data.form.location_name = ''
+ },
+
+ submit: async () => {
+ const { valid } = await formRef.value.validate()
+
+ const form = method.constructFormBody()
+
+ if (valid) {
+ const { data: res } = await addStockTaking(form)
+ if (!res.isSuccess) {
+ hookComponent.$message({
+ type: 'error',
+ content: res.errorMessage
+ })
+ return
+ }
+ hookComponent.$message({
+ type: 'success',
+ content: `${ i18n.global.t('system.page.submit') }${ i18n.global.t('system.tips.success') }`
+ })
+ emit('saveSuccess')
+ } else {
+ hookComponent.$message({
+ type: 'error',
+ content: i18n.global.t('system.checkText.checkFormFail')
+ })
+ }
+ },
+
+ constructFormBody: () => {
+ let form = { ...data.form }
+ form = removeObjectNull(form)
+
+ return form
+ }
+})
+
+watch(
+ () => isShow.value,
+ (val) => {
+ if (val) {
+ method.initForm()
+ }
+ }
+)
+</script>
+
+<style scoped lang="less">
+.v-form {
+ div {
+ margin-bottom: 7px;
+ }
+}
+
+.header {
+ display: flex;
+ margin-bottom: 15px;
+ justify-content: space-between;
+}
+
+.headerBtn {
+}
+.headerTips {
+ display: flex;
+ align-items: center;
+}
+</style>