瀏覽代碼

fix: 🐛 修复完问题,提取了公共代码

@sun-chaoqun 1 年之前
父節點
當前提交
ec38e2f793

+ 94 - 0
src/hooks/useDepot.ts

@@ -0,0 +1,94 @@
+import { computed } from 'vue'
+import { GlobalStore } from '@/stores/index'
+
+const globalStore = GlobalStore()
+interface ItemType {
+  T_name: string
+  Id: number
+}
+
+export interface SaleFormType {
+  T_type: number
+  T_uuid: string
+  T_receive: string
+  T_number: string
+  T_depot_id: any
+  T_product: any
+  T_date: string
+  T_remark: string
+  T_contract_number: string
+  T_delivery_type: string
+  T_signer_unit: string
+  T_signer: string
+  T_signer_phone: string
+  T_signer_date: string
+  T_courier_number: string
+}
+
+export interface ReceiveFormType {
+  T_type: number
+  T_uuid: string
+  T_receive: string
+  T_number: string
+  T_depot_id: any
+  T_product: any
+  T_date: string
+  T_remark: string
+  T_contract_number: string
+}
+
+export interface InfoType {
+  Id: number
+  T_type: number
+  T_depot_name: string
+  T_date: string
+  T_number: string
+  T_remark: string
+  T_submit: string
+  T_signer?: string
+  T_signer_phone?: string
+  T_signer_date?: string
+  T_signer_unit?: string
+  T_submit_name: string
+  T_receive_name: string
+  T_delivery_type: string
+  T_courier_number?: number
+}
+
+export interface InStorageInfoType {
+  Id: number
+  T_depot_name: string
+  T_date: string
+  T_number: string
+  T_remark: string
+  T_submit: string
+  T_submit_name: string
+}
+
+export interface InStoreageFormType {
+  T_number: string
+  T_depot_id: any
+  T_product: any
+  T_date: string
+  T_remark: string
+}
+
+export const delivery_type = [
+  { name: '自送', id: 1 },
+  { name: '自提', id: 2 },
+  { name: '快递', id: 3 }
+]
+
+export const depotHooks = () => {
+  const options = computed<ItemType[]>(() => {
+    return globalStore.GET_depotList
+  })
+  const getDepotList = async () => {
+    if (globalStore.GET_depotList.length) return
+    globalStore.SET_Storehouse_Depot_List()
+  }
+  getDepotList()
+  return {
+    options
+  }
+}

+ 9 - 0
src/stores/index.ts

@@ -6,6 +6,7 @@ import { isEmptyObject } from '@/utils/common'
 import { User_Dept_List } from '@/api/user/index'
 import { User_News_List } from '@/api/user/index'
 import { flatMenuListGet, AddRouterMeta, getAllBreadcrumbList } from '@/utils/common'
+import { Storehouse_Depot_List } from '@/api/storehouse/index'
 
 export const GlobalStore = defineStore({
   id: 'GlobalState',
@@ -134,6 +135,14 @@ export const GlobalStore = defineStore({
         this.SET_NoticeList(res.Data.Data)
       }, 100)
       this.SET_NoticeTotal(res.Data.Num)
+    },
+    /**
+     * 获取仓库列表
+     */
+    async SET_Storehouse_Depot_List() {
+      if (this.depotList.length) return
+      const res: any = await Storehouse_Depot_List({ User_tokey: this.GET_User_tokey, page: 1, page_z: 999 })
+      this.SET_depotList(res.Data.Data)
     }
   }
 })

+ 4 - 8
src/views/Index.vue

@@ -1,22 +1,20 @@
 <script setup lang="ts">
+import { useRoute } from 'vue-router'
 import { onMounted, computed } from 'vue'
-import SubMenu from '@/layouts/Menu/SubMenu.vue'
 import Main from '@/layouts/Main/index.vue'
 import Header from '@/layouts/Header/index.vue'
 import { GlobalStore } from '@/stores/index'
-import { useRoute } from 'vue-router'
 import Logo from '@/layouts/Menu/Logo.vue'
+import SubMenu from '@/layouts/Menu/SubMenu.vue'
 
+const route = useRoute()
 const globalStore = GlobalStore()
-
+const defaultActive = computed(() => route.path)
 const routerList = computed(() => globalStore.expandMenuList)
 
 onMounted(() => {
   globalStore.SET_User_Dept_List()
 })
-
-const route = useRoute()
-const defaultActive = computed(() => route.path)
 </script>
 
 <template>
@@ -68,11 +66,9 @@ const defaultActive = computed(() => route.path)
       flex-direction: column;
       height: 100%;
       transition: all 0.3s ease;
-      // background-color: rgba(18, 21, 39, 0.86);
       .el-menu {
         overflow-x: hidden;
         border-right: none;
-        // background-color: rgba(18, 21, 39, 0.86);
       }
     }
   }

+ 71 - 54
src/views/account/roles/Roles.vue

@@ -242,68 +242,85 @@ const append = async (data: any) => {
     T_code: code,
     T_menu
   }
-  // const res = await User_Power_Edit_Menu(params)
-  // if (res.Code === 200) {
-  //   ElMessage.success('修改成功!')
-  //   // dialog.value?.DialogClose()
-  // }
-}
-let fatherData: any = {}
-const checkChange = (data: any, check: boolean) => {
-  let fatherData = menuMap.get(data.T_permission)
-  if (['/base'].includes(data.T_permission)) {
-    fatherData = menuMap.get('/stock')
+  const res = await User_Power_Edit_Menu(params)
+  if (res.Code === 200) {
+    ElMessage.success('修改成功!')
+    // dialog.value?.DialogClose()
   }
-
-  if (check) {
-    console.log(data, fatherData)
-  }
-
-  // console.log(data, check)
-  // if (father) {
-  //   fatherData = data
-  //   fatherCheckHandle(data.Children, father, check)
-  //   // console.log(father)
-  //   return
-  // }
-  // const prevFather = menuMap.get(fatherData.T_permission)
-  // console.log(fatherData, prevFather)
-
-  // const children = prevFather?.children
-  // // console.log(children)
-  // if (check) {
-  //   console.log(children)
-  //   prevFather.children.push(data)
-  // }
-  // if (!father && !check) {
-  //   const index = children.findIndex((item: any) => item.T_permission === data.T_permission)
-  //   if (index !== -1) {
-  //     console.log('-1')
-  //     children.splice(index, 1)
-  //   }
-  // }
 }
+let fatherDataCopy: any = {}
+const getMenuChildren = (menuchildren: any, T_permission: string) => {
+  let fatherData = getFatherData(T_permission)
+  const { children } = fatherData
+  console.log(menuchildren, fatherData)
 
-/**
- * 处理点击父级 tree 时的处理
- */
-const fatherCheckHandle = (children: any[], father: any, check: boolean) => {
-  if (check) {
-    children.forEach((item: any) => {
+  if (!menuchildren?.length) {
+    const index = children.findIndex((child: any) => child.T_permission === menuchildren.T_permission)
+    if (index === -1) children.push({ ...menuchildren })
+  } else {
+    menuchildren.forEach((item: any) => {
       if (item.Children) {
-        if (father.children.findIndex((child: any) => item.T_permission === child.T_permission) === -1) {
-          father.children.push(item)
-          fatherCheckHandle(item.Children, father, check)
-        }
+        getMenuChildren(item, T_permission)
       } else {
-        if (father.children.findIndex((child: any) => item.T_permission === child.T_permission) === -1) {
-          console.log('push3')
-          father.children.push(item)
-        }
+        const index = children.findIndex((child: any) => item.T_permission === child.T_permission)
+        if (index === -1) children.push({ ...item })
       }
     })
   }
 }
+const getFatherData = (T_permission: string) => {
+  let fatherData = menuMap.get(T_permission)
+  if (['/base', '/property', '/inventory', '/salesManage'].includes(T_permission)) {
+    fatherData = menuMap.get('/stock')
+  }
+  return fatherData
+}
+const checkChange = (data: any, check: boolean) => {
+  let fatherData = getFatherData(data.T_permission)
+  if (fatherData) {
+    fatherDataCopy = fatherData
+  }
+  if (check && fatherDataCopy) {
+    const { children } = fatherDataCopy
+    if (!data.Children) {
+      console.log('1', data)
+      const index = children.findIndex((child: any) => data.T_permission === child.T_permission)
+      if (index === -1) children.push({ ...data })
+    } else {
+      getMenuChildren(data.Children, data.T_permission)
+    }
+  }
+
+  if (!check && fatherDataCopy) {
+    let { children } = fatherDataCopy
+    if (['/base', '/property', '/inventory', '/salesManage'].includes(data.T_permission)) {
+      fatherData = menuMap.get('/stock')
+      if (data.T_permission === '/base') {
+        children = children.filter((item: any) => {
+          return !['/list', '/classify', '/productionList', '/base'].includes(item.T_permission)
+        })
+      } else if (data.T_permission === '/property') {
+        children = children.filter((item: any) => {
+          return !['/ioTNetworkCard', '/property'].includes(item.T_permission)
+        })
+      } else if (data.T_permission === '/inventory') {
+        children = children.filter((item: any) => {
+          return !['/device', '/inStorage', '/outStock', '/inventoryStatistics', '/inventory'].includes(
+            item.T_permission
+          )
+        })
+      } else {
+        children = children.filter((item: any) => {
+          return !['/contract', '/contractSale', '/salesManage'].includes(item.T_permission)
+        })
+      }
+      fatherData.children = children
+      return
+    }
+    const index = children.findIndex((child: any) => data.T_permission === child.T_permission)
+    if (index === -1) children.splice(index, 1)
+  }
+}
 /**
  * dialog 关闭回调
  */
@@ -311,7 +328,7 @@ const dialogCloseCallback = () => {
   nextTick(() => {
     menuMap.clear()
     permissionArr.value = []
-    fatherData = {}
+    fatherDataCopy = {}
   })
 }
 </script>

+ 3 - 4
src/views/home/Home.vue

@@ -68,9 +68,9 @@ onMounted(() => {
 
   tabs__content?.addEventListener('scroll', ScrollHandle)
 
-  if (globalStore.noticeList.length <= 0) {
-    globalStore.SET_User_News_List()
-  }
+  // if (globalStore.noticeList.length <= 0) {
+  //   globalStore.SET_User_News_List()
+  // }
 })
 onUnmounted(() => {
   tabs__content.removeEventListener('scroll', ScrollHandle)
@@ -84,7 +84,6 @@ onUnmounted(() => {
       <el-tabs v-model="activeName" @tab-click="handleClick" id="home">
         <transition-group
           appear
-          mode="out-in"
           leave-active-class="animate__animated animate__fadeOutLeft"
           enter-active-class="animate__animated animate__fadeInLeft"
         >

+ 1 - 1
src/views/storehouse/inventory/Device.vue

@@ -3,8 +3,8 @@ import { ref, reactive } from 'vue'
 import { GlobalStore } from '@/stores/index'
 import Dialog from '@/components/dialog/Dialog.vue'
 import TableBase from '@/components/TableBase/index.vue'
-import type { ColumnProps } from '@/components/TableBase/interface/index'
 import { Storehouse_Device_List } from '@/api/storehouse/index'
+import type { ColumnProps } from '@/components/TableBase/interface/index'
 
 const globalStore = GlobalStore()
 const TableRef = ref<InstanceType<typeof TableBase> | null>(null)

+ 4 - 19
src/views/storehouse/inventory/InStorage.vue

@@ -3,10 +3,11 @@ import { useRouter } from 'vue-router'
 import { GlobalStore } from '@/stores/index'
 import { View } from '@element-plus/icons-vue'
 import InStorageForm from './InStorageForm.vue'
-import { ref, reactive, onMounted } from 'vue'
+import { ref, reactive } from 'vue'
 import TableBase from '@/components/TableBase/index.vue'
 import type { ColumnProps } from '@/components/TableBase/interface/index'
-import { Storehouse_StockIn_List, Storehouse_Depot_List } from '@/api/storehouse/index'
+import { Storehouse_StockIn_List } from '@/api/storehouse/index'
+import { depotHooks } from '@/hooks/useDepot'
 
 const router = useRouter()
 const globalStore = GlobalStore()
@@ -50,23 +51,7 @@ const searchHandle = () => {
 const openInStorageFormDrawer = () => InStorageFormRef.value?.openDrawer()
 
 // 拿到仓库列表
-interface ItemType {
-  T_name: string
-  Id: number
-}
-const options = ref<ItemType[]>([])
-const getDepotList = async () => {
-  if (globalStore.GET_depotList.length) {
-    options.value = globalStore.GET_depotList
-    return
-  }
-  const res: any = await Storehouse_Depot_List({ User_tokey: globalStore.GET_User_tokey, page: 1, page_z: 999 })
-  options.value = res.Data.Data
-  globalStore.SET_depotList(options.value)
-}
-onMounted(() => {
-  getDepotList()
-})
+const { options } = depotHooks()
 </script>
 
 <template>

+ 3 - 12
src/views/storehouse/inventory/InStorageDetail.vue

@@ -2,23 +2,14 @@
 import { ref, onMounted } from 'vue'
 import { GlobalStore } from '@/stores/index'
 import { useRoute, useRouter } from 'vue-router'
-import { Storehouse_StockIn_Get } from '@/api/storehouse/index'
 import Drawer from '@/components/Drawer/index.vue'
-
-interface InfoType {
-  Id: number
-  T_depot_name: string
-  T_date: string
-  T_number: string
-  T_remark: string
-  T_submit: string
-  T_submit_name: string
-}
+import { InStorageInfoType } from '@/hooks/useDepot'
+import { Storehouse_StockIn_Get } from '@/api/storehouse/index'
 
 const tableData = ref<any[]>([])
 const tableSnData = ref<any[]>([])
 const globalStore = GlobalStore()
-const info = ref<InfoType | undefined>()
+const info = ref<InStorageInfoType | undefined>()
 const drawerSnRef = ref<InstanceType<typeof Drawer> | null>(null)
 const route = useRoute()
 const router = useRouter()

+ 13 - 13
src/views/storehouse/inventory/InStorageForm.vue

@@ -4,19 +4,13 @@ import InStorageSn from './InStorageSn.vue'
 import { ref, reactive, nextTick } from 'vue'
 import { GlobalStore } from '@/stores/index'
 import Drawer from '@/components/Drawer/index.vue'
+import { InStoreageFormType } from '@/hooks/useDepot'
 import InStorageProduct from './InStorageProduct.vue'
 import type { FormInstance, FormRules } from 'element-plus'
 import { Delete, CirclePlus } from '@element-plus/icons-vue'
 import { Storehouse_StockIn_Add, Storehouse_ProductClass_List } from '@/api/storehouse/index'
 
 type Fn = () => void
-interface FormType {
-  T_number: string
-  T_depot_id: any
-  T_product: any
-  T_date: string
-  T_remark: string
-}
 
 const tableData = ref<any[]>([])
 const globalStore = GlobalStore()
@@ -27,7 +21,7 @@ const drawerSnRef = ref<InstanceType<typeof InStorageSn> | null>(null)
 const drawerProductRef = ref<InstanceType<typeof InStorageProduct> | null>(null)
 const classOptions = ref<any[]>([])
 
-const form = reactive<FormType>({
+const form = reactive<InStoreageFormType>({
   T_number: '',
   T_depot_id: '',
   T_product: '',
@@ -139,8 +133,6 @@ const deleteProduct = (row: any) => {
 
 const callbackDrawer = (done: Fn) => {
   resetForm(ruleFormRef.value)
-  drawerProductRef.value?.clearSelection()
-  drawerSnRef.value?.clearDeviceSn()
   done()
 }
 /**
@@ -148,6 +140,8 @@ const callbackDrawer = (done: Fn) => {
  */
 const resetForm = (formEl: FormInstance | undefined) => {
   if (!formEl) return
+  drawerProductRef.value?.clearSelection()
+  drawerSnRef.value?.clearDeviceSn()
   tableData.value = []
   formEl.resetFields()
 }
@@ -189,7 +183,7 @@ const ProductSelectionAllChange = (selection: any[]) => {
  * 添加sn 号
  */
 const addDeviceSn = (id: number) => {
-  drawerSnRef.value?.addDeviceSn(id)
+  drawerSnRef.value?.addDeviceSn(id, 2)
 }
 /**
  * 自动计算 count
@@ -201,7 +195,13 @@ const autoGetCount = (length: number, id: number) => {
     }
   })
 }
-
+/**
+ * 关闭 取消
+ */
+const closeInStorage = () => {
+  resetForm(ruleFormRef.value)
+  drawerRef.value?.closeDrawer()
+}
 // 注册事件
 const emit = defineEmits<{ (event: 'onUpdateList'): void }>()
 
@@ -323,7 +323,7 @@ defineExpose({
         </el-form-item>
         <div class="btn">
           <el-divider>
-            <el-button>取消</el-button>
+            <el-button @click="closeInStorage">取消</el-button>
             <el-button color="#626aef" @click="AddInStorage(ruleFormRef)">提交</el-button>
           </el-divider>
         </div>

+ 7 - 4
src/views/storehouse/inventory/InStorageSn.vue

@@ -1,14 +1,15 @@
 <script setup lang="ts">
 import { ref, reactive, nextTick } from 'vue'
+import { Delete } from '@element-plus/icons-vue'
 import Drawer from '@/components/Drawer/index.vue'
 import type { FormInstance, FormRules } from 'element-plus'
-import { Delete } from '@element-plus/icons-vue'
 import { Storehouse_Device_Check } from '@/api/storehouse/index'
 
 type Fn = () => void
 interface FormSnType {
   Id?: number
   sn: string
+  type?: number
 }
 
 const snTable = ref()
@@ -24,7 +25,8 @@ const snColumns = [
 ]
 const formSn = reactive<FormSnType>({
   Id: undefined,
-  sn: ''
+  sn: '',
+  type: undefined
 })
 const rulesSn = reactive<FormRules>({
   sn: [{ required: true, message: '请输入SN号', trigger: 'blur' }]
@@ -34,7 +36,7 @@ const addSn = (formEl: FormInstance | undefined) => {
   if (!formEl) return
   formEl.validate(async valid => {
     if (valid) {
-      const res: any = await Storehouse_Device_Check({ T_sn: formSn.sn })
+      const res: any = await Storehouse_Device_Check({ T_sn: formSn.sn, T_type: formSn.type })
       if (res.Code === 200) {
         tableSnData.value.push({ sn: formSn.sn })
         nextTick(() => {
@@ -66,8 +68,9 @@ const resetSnForm = (formEl: FormInstance | undefined) => {
   formEl.resetFields()
 }
 
-const addDeviceSn = (id: number) => {
+const addDeviceSn = (id: number, type: number) => {
   formSn.Id = id
+  formSn.type = type
   if (SNDataMap.has(id)) {
     tableSnData.value = SNDataMap.get(id) as FormSnType[]
   } else {

+ 0 - 1
src/views/storehouse/outStock/ContractNumber.vue

@@ -1,7 +1,6 @@
 <script setup lang="ts">
 import { ref } from 'vue'
 import { Storehouse_Contract_Out_List } from '@/api/storehouse/index'
-// import Dialog from '@/components/dialog/Dialog.vue'
 import Drawer from '@/components/Drawer/index.vue'
 import { GlobalStore } from '@/stores/index'
 import TableBase from '@/components/TableBase/index.vue'

+ 4 - 21
src/views/storehouse/outStock/OutStock.vue

@@ -6,10 +6,11 @@ import { View, Van } from '@element-plus/icons-vue'
 import Drawer from '@/components/Drawer/index.vue'
 import type { FormInstance, FormRules } from 'element-plus'
 import { validate_T_phone } from '@/views/account/users/components/relus'
-import { ref, reactive, onMounted, nextTick } from 'vue'
+import { ref, reactive, nextTick } from 'vue'
 import TableBase from '@/components/TableBase/index.vue'
 import type { ColumnProps } from '@/components/TableBase/interface/index'
-import { Storehouse_StockOut_List, Storehouse_Depot_List, Storehouse_StockOut_Edit } from '@/api/storehouse/index'
+import { Storehouse_StockOut_List, Storehouse_StockOut_Edit } from '@/api/storehouse/index'
+import { depotHooks, delivery_type } from '@/hooks/useDepot'
 
 type Fn = () => void
 
@@ -20,11 +21,6 @@ const ruleFormRef = ref<FormInstance>()
 const TableRef = ref<InstanceType<typeof TableBase> | null>(null)
 const DrawerRef = ref<InstanceType<typeof Drawer> | null>(null)
 
-const delivery_type = [
-  { name: '自送', id: 1 },
-  { name: '自提', id: 2 },
-  { name: '快递', id: 3 }
-]
 const columns: ColumnProps[] = [
   { type: 'index', label: '序号', width: 80 },
   { prop: 'T_number', label: '出库单号' },
@@ -109,20 +105,7 @@ const resetForm = (formEl: FormInstance | undefined) => {
   formEl.resetFields()
 }
 // 拿到仓库列表
-interface ItemType {
-  T_name: string
-  Id: number
-}
-const options = ref<ItemType[]>([])
-const getDepotList = async () => {
-  if (globalStore.GET_depotList.length) return
-  const res: any = await Storehouse_Depot_List({ User_tokey: globalStore.GET_User_tokey, page: 1, page_z: 999 })
-  options.value = res.Data.Data
-  globalStore.SET_depotList(options.value)
-}
-onMounted(() => {
-  getDepotList()
-})
+const { options } = depotHooks()
 </script>
 
 <template>

+ 1 - 18
src/views/storehouse/outStock/OutStockDetail.vue

@@ -4,24 +4,7 @@ import { GlobalStore } from '@/stores/index'
 import { useRoute, useRouter } from 'vue-router'
 import Drawer from '@/components/Drawer/index.vue'
 import { Storehouse_StockOut_Get } from '@/api/storehouse/index'
-
-interface InfoType {
-  Id: number
-  T_type: number
-  T_depot_name: string
-  T_date: string
-  T_number: string
-  T_remark: string
-  T_submit: string
-  T_signer?: string
-  T_signer_phone?: string
-  T_signer_date?: string
-  T_signer_unit?: string
-  T_submit_name: string
-  T_receive_name: string
-  T_delivery_type: string
-  T_courier_number?: number
-}
+import { InfoType } from '@/hooks/useDepot'
 
 const tableSnData = ref<any[]>([])
 const info = ref<InfoType | undefined>()

+ 20 - 7
src/views/storehouse/outStock/OutStockProduct.vue

@@ -8,7 +8,7 @@ import {
 import { ElMessage } from 'element-plus'
 import { GlobalStore } from '@/stores/index'
 import Drawer from '@/components/Drawer/index.vue'
-import { ref, reactive, onMounted, nextTick } from 'vue'
+import { ref, reactive, onMounted, nextTick, watch } from 'vue'
 import { default as vElTableInfiniteScroll } from 'el-table-infinite-scroll'
 
 type Fn = () => void
@@ -64,7 +64,7 @@ const searchModelHandle = () => {
   total = 0
   initParam.page = 1
   tableProductData.value = []
-  getProductList()
+  getProductList(props.depotId)
 }
 
 // 保存选中的数据id,row-key就是要指定一个key标识这一行的数据
@@ -79,7 +79,7 @@ const load = () => {
     return
   }
   initParam.page++
-  getProductList()
+  getProductList(props.depotId)
 }
 // 勾选产品
 const ProductselectionChange = (selection: any[], row: any) => emit('ontableData', row)
@@ -96,9 +96,12 @@ const getNameAsync = async (str: string): Promise<any> => {
   })
 }
 
-const getProductList = async () => {
-  const res: any = await Storehouse_Stock_List({ ...initParam, T_name: autoSelect.value })
-  tableProductData.value.push(...res.Data.Data)
+/**
+ * 获取产品列表
+ */
+const getProductList = async (depotId: number) => {
+  const res: any = await Storehouse_Stock_List({ ...initParam, T_name: autoSelect.value, T_depot_id: depotId })
+  res.Data.Data ? tableProductData.value.push(...res.Data.Data) : (tableProductData.value = [])
   total = res.Data.Num
 }
 
@@ -107,9 +110,19 @@ const getProductClassList = async () => {
   const res: any = await Storehouse_ProductClass_List({ page: 1, page_z: 999 })
   classOptions.value = res.Data.Data
 }
+const props = withDefaults(defineProps<{ depotId: number }>(), {
+  depotId: 0
+})
+
+watch(
+  () => props.depotId,
+  cur => {
+    getProductList(cur)
+  }
+)
 
 onMounted(() => {
-  getProductList()
+  // getProductList()
   !classOptions.value.length && getProductClassList()
 })
 

+ 9 - 28
src/views/storehouse/outStock/ReceiveOutStock.vue

@@ -9,18 +9,7 @@ import { Storehouse_StockOut_Add } from '@/api/storehouse/index'
 import ReceiveUser from './receiveUser.vue'
 import InStorageSn from '../inventory/InStorageSn.vue'
 import OutStockProduct from './OutStockProduct.vue'
-
-interface FormType {
-  T_type: number
-  T_uuid: string
-  T_receive: string
-  T_number: string
-  T_depot_id: any
-  T_product: any
-  T_date: string
-  T_remark: string
-  T_contract_number: string
-}
+import { depotHooks, ReceiveFormType } from '@/hooks/useDepot'
 
 const router = useRouter()
 const tableData = ref<any[]>([])
@@ -31,12 +20,12 @@ const receiveUserdialog = ref<InstanceType<typeof ReceiveUser> | null>(null)
 const drawerSnRef = ref<InstanceType<typeof InStorageSn> | null>(null)
 const drawerProductRef = ref<InstanceType<typeof OutStockProduct> | null>(null)
 
-const form = reactive<FormType>({
+const form = reactive<ReceiveFormType>({
   T_type: 1,
   T_uuid: '',
   T_receive: '',
   T_number: '',
-  T_depot_id: '',
+  T_depot_id: undefined,
   T_product: '',
   T_date: '',
   T_remark: '',
@@ -192,7 +181,7 @@ const ProductSelectionAllChange = (selection: any[]) => {
  * 添加sn 号
  */
 const addDeviceSn = (id: number) => {
-  drawerSnRef.value?.addDeviceSn(id)
+  drawerSnRef.value?.addDeviceSn(id, 1)
 }
 /**
  * 自动计算 count
@@ -214,11 +203,8 @@ const getReceiveInfo = ({ T_uuid, T_name }: { T_uuid: string; T_name: string })
   form.T_uuid = T_uuid
 }
 
-// 注册事件
-// const emit = defineEmits<{ (event: 'onUpdateList'): void }>()
-
-// 接受props
-const options = globalStore.GET_depotList
+// 拿到仓库列表
+const { options } = depotHooks()
 </script>
 
 <template>
@@ -232,7 +218,7 @@ const options = globalStore.GET_depotList
         <el-input v-model="form.T_number" disabled type="text" placeholder="系统自动生成" class="w-50" />
       </el-form-item>
       <el-form-item label="出库仓库:" :label-width="formLabelWidth" prop="T_depot_id">
-        <el-select v-model="form.T_depot_id" class="w-50" clearable placeholder="请选择库仓库~">
+        <el-select v-model="form.T_depot_id" class="w-50" clearable placeholder="请选择库仓库~">
           <el-option v-for="item in options" :key="item.Id" :label="item.T_name" :value="item.Id" />
         </el-select>
       </el-form-item>
@@ -248,13 +234,7 @@ const options = globalStore.GET_depotList
         />
       </el-form-item>
       <el-form-item label="经办人:" :label-width="formLabelWidth" prop="T_receive">
-        <el-input
-          v-model="form.T_receive"
-          type="text"
-          placeholder="请选择经办人"
-          class="w-50"
-          @click="selectApprover"
-        />
+        <el-input v-model="form.T_receive" placeholder="请选择经办人" class="w-50" @focus="selectApprover" />
       </el-form-item>
       <el-form-item label="出库明细:" :label-width="formLabelWidth" prop="T_product">
         <el-table
@@ -351,6 +331,7 @@ const options = globalStore.GET_depotList
     <ReceiveUser ref="receiveUserdialog" @onUserInfo="getReceiveInfo" />
     <OutStockProduct
       ref="drawerProductRef"
+      :depotId="form.T_depot_id"
       @ontableData="ProductselectionChange"
       @ontableDataAll="ProductSelectionAllChange"
     />

+ 7 - 35
src/views/storehouse/outStock/SaleOutStock.vue

@@ -8,26 +8,9 @@ import { Delete, CirclePlus } from '@element-plus/icons-vue'
 import ReceiveUser from './receiveUser.vue'
 import InStorageSn from '../inventory/InStorageSn.vue'
 import ContractNumber from './ContractNumber.vue'
+import { depotHooks, SaleFormType, delivery_type } from '@/hooks/useDepot'
 import { Storehouse_StockOut_Add, Storehouse_Contract_Product_List } from '@/api/storehouse/index'
 
-interface FormType {
-  T_type: number
-  T_uuid: string
-  T_receive: string
-  T_number: string
-  T_depot_id: any
-  T_product: any
-  T_date: string
-  T_remark: string
-  T_contract_number: string
-  T_delivery_type: string
-  T_signer_unit: string
-  T_signer: string
-  T_signer_phone: string
-  T_signer_date: string
-  T_courier_number: string
-}
-
 const router = useRouter()
 const tableData = ref<any[]>([])
 const globalStore = GlobalStore()
@@ -36,7 +19,7 @@ const ruleFormRef = ref<FormInstance>()
 const drawerSnRef = ref<InstanceType<typeof InStorageSn> | null>(null)
 const receiveUserdialog = ref<InstanceType<typeof ReceiveUser> | null>(null)
 const contractNumberRef = ref<InstanceType<typeof ContractNumber> | null>(null)
-const form = ref<FormType>({
+const form = ref<SaleFormType>({
   T_type: 2,
   T_uuid: '',
   T_receive: '',
@@ -54,12 +37,6 @@ const form = ref<FormType>({
   T_contract_number: ''
 })
 
-const delivery_type = [
-  { name: '自送', id: 1 },
-  { name: '自提', id: 2 },
-  { name: '快递', id: 3 }
-]
-
 const columns = [
   { type: 'index', label: '序号', width: 80, align: 'center ' },
   { label: '产品图片', prop: 'T_product_img', align: 'center ', name: 'T_product_img', width: 100 },
@@ -139,7 +116,7 @@ const determineSNorCount = (DeviceSnData: any) => {
  * 添加sn 号
  */
 const addDeviceSn = (id: number) => {
-  drawerSnRef.value?.addDeviceSn(id)
+  drawerSnRef.value?.addDeviceSn(id, 1)
 }
 /**
  * 自动计算 count
@@ -165,9 +142,7 @@ const getReceiveInfo = ({ T_uuid, T_name }: { T_uuid: string; T_name: string })
 const selectDepot = (val: any) => {
   form.value.T_depot_id = val
 
-  if (form.value.T_depot_id && form.value.T_contract_number) {
-    getProductList()
-  }
+  if (form.value.T_depot_id && form.value.T_contract_number) getProductList()
 }
 /**
  * 选择合同
@@ -176,10 +151,7 @@ const selectContract = () => contractNumberRef.value?.openDrawer()
 const getContactInfo = ({ T_number }: { T_number: string }) => {
   if (form.value.T_contract_number === T_number) return
   form.value.T_contract_number = T_number
-  if (form.value.T_depot_id && form.value.T_contract_number) {
-    getProductList()
-    // inputContractRef.value.focus()
-  }
+  if (form.value.T_depot_id && form.value.T_contract_number) getProductList()
 }
 /**
  * 通过合同获取产品
@@ -245,7 +217,7 @@ const AddSaleOutStock = (formEl: FormInstance | undefined) => {
   })
 }
 
-const options = globalStore.GET_depotList
+const { options } = depotHooks()
 </script>
 <template>
   <div class="receive-outStock">
@@ -261,7 +233,7 @@ const options = globalStore.GET_depotList
         <el-input v-model="form.T_contract_number" placeholder="请选择合同编号" class="w-50" @focus="selectContract" />
       </el-form-item>
       <el-form-item label="出库仓库:" :label-width="formLabelWidth" prop="T_depot_id">
-        <el-select v-model="form.T_depot_id" class="w-50" clearable placeholder="请选择库仓库~" @change="selectDepot">
+        <el-select v-model="form.T_depot_id" class="w-50" clearable placeholder="请选择库仓库~" @change="selectDepot">
           <el-option v-for="item in options" :key="item.Id" :label="item.T_name" :value="item.Id" />
         </el-select>
       </el-form-item>

+ 0 - 1
src/views/storehouse/outStock/receiveUser.vue

@@ -1,7 +1,6 @@
 <script setup lang="ts">
 import { ref } from 'vue'
 import { User_List } from '@/api/user/index'
-// import Dialog from '@/components/dialog/Dialog.vue'
 import Drawer from '@/components/Drawer/index.vue'
 import { GlobalStore } from '@/stores/index'
 import TableBase from '@/components/TableBase/index.vue'

+ 1 - 1
src/views/storehouse/sales/Contract.vue

@@ -107,7 +107,7 @@ const searchHandle = () => {
       </template>
       <template #T_out="{ row }">
         <el-tag v-if="row.T_out === 2 || row.T_out === 3" type="success" effect="dark">
-          {{ row.T_out === 2 ? '已出库' : '已全部出库' }}
+          {{ row.T_out === 2 ? '部分出库' : '已出库' }}
         </el-tag>
         <el-tag v-else-if="row.T_out === 1" type="warning" effect="dark"> 未出库 </el-tag>
         <el-tag v-else type="danger" effect="dark"> --- </el-tag>

+ 2 - 9
src/views/storehouse/sales/ContractForm.vue

@@ -28,6 +28,7 @@ const selectTable = ref()
 const drawerProductRef = ref<InstanceType<typeof Drawer> | null>(null)
 
 const validate_T_product = (rule: any, value: any, callback: any) => {
+  console.log(value)
   if (form.T_type === 1 && value === '') {
     callback(new Error('请选择产品明细'))
   } else if (value.includes(undefined)) {
@@ -122,6 +123,7 @@ const editDataEcho = async (row: any) => {
         return item
       }))
     selectProductData = tableData.value
+    blurHandle()
   }
 }
 
@@ -452,15 +454,6 @@ defineExpose({
                   </el-col>
                   <el-col :xl="7" :lg="8" :md="10" class="d-flex">
                     <span class="inline-flex items-center">产品名称:</span>
-                    <!-- <el-autocomplete
-                      v-model="autoSelect"
-                      clearable
-                      :fetch-suggestions="querySearchAsync"
-                      placeholder="按产品名称搜索"
-                      :debounce="2000"
-                      :trigger-on-focus="false"
-                      @select="handleSelect"
-                    /> -->
                     <el-select
                       v-model="autoSelect"
                       filterable