From a2cb4ebc089b890318f335fadcd8b48aa3ef60cd Mon Sep 17 00:00:00 2001
From: schangxiang@126.com <schangxiang@126.com>
Date: 周二, 20 5月 2025 16:58:21 +0800
Subject: [PATCH] 222
---
HIAWms/hiawms_web/src/widgets/WmsInOutStockRecord/Controllers/WmsInOutStockRecord.ts | 557 ++++++++++++++++++++++++++++---------------------------
1 files changed, 282 insertions(+), 275 deletions(-)
diff --git a/HIAWms/hiawms_web/src/widgets/WmsInOutStockRecord/Controllers/WmsInOutStockRecord.ts b/HIAWms/hiawms_web/src/widgets/WmsInOutStockRecord/Controllers/WmsInOutStockRecord.ts
index 039bb46..9c4a213 100644
--- a/HIAWms/hiawms_web/src/widgets/WmsInOutStockRecord/Controllers/WmsInOutStockRecord.ts
+++ b/HIAWms/hiawms_web/src/widgets/WmsInOutStockRecord/Controllers/WmsInOutStockRecord.ts
@@ -1,275 +1,282 @@
-import { ref, onMounted, reactive, Ref, nextTick, computed } from 'vue'
-import { injectModel } from '@/libs/Provider/Provider'
-import { WmsInOutStockRecord } from '../Models/WmsInOutStockRecord'
-import { ElMessage } from 'element-plus'
-import { ConfirmBox } from '@/components/ConfirmBox/ConfirmBox'
-import { useFile } from './File'
-
-interface CurrentType {
- row: any
- index: number
-}
-export const useWmsInOutStockRecord = (props: any, ctx?: any) => {
- const wmsInOutStockRecord = injectModel<WmsInOutStockRecord>('wmsInOutStockRecord')
- const { exportFile } = useFile()
- /**
- * 澶撮儴閰嶇疆
- */
- const headers = ref({})
- /**
- * 鍔ㄦ�佸垪閰嶇疆
- */
- const wmsInOutStockRecordColumns = ref<Record<string, any>>([])
- /**
- * 鎼滅储鍊�
- */
- const search = ref('')
-
- /**
- * 鎺掑簭
- */
- const sort = ref(0)
- /**
- * 閫夋嫨椤�
- */
- const selection = ref([])
- /**
- * 褰撳墠閫変腑鐨勮
- */
- const current = ref<any>(null)
- /**
- * 鏁版嵁婧�
- */
- const dataSource: Ref<any[]> = ref([])
-
- /**
- * 琛ㄦ牸
- */
- const tableRef = ref()
- const dialogConfig = reactive({
- visible: false,
- title: '',
- isAdd: false,
- })
- const dialogConfigForQuery = reactive({
- visible: false,
- title: '',
- isAdd: false,
- })
-
-
- const dialogSettingConfig = reactive({
- visible: false,
- title: '',
- })
-
- /**
- * 鍒嗛〉鏁版嵁
- */
- const paginationParams = ref({})
-
- /**
- * 鎵撳紑璇︽儏
- * @param row
- */
- const openDetail = (row: any) => {
- current.value = row
- dialogConfig.visible = true
- dialogConfig.title = row.name
- dialogConfig.isAdd = false
- sort.value = row.sort
- }
-
- const contextMenu = [
- {
- label: '灞曞紑璇︽儏',
- fn: (c: CurrentType) => {
- current.value = null
- sort.value = c.row.sort
- nextTick(() => openDetail(c.row))
- },
- divided: true,
- icon: 'o',
- },
- // {
- // label: '鍚戜笂娣诲姞',
- // fn: (c: CurrentType, pageNum: number) => {
- // current.value = null
- // sort.value = c.index + 1 + (pageNum - 1) * 50
- // dialogConfig.visible = true
- // dialogConfig.title = '娣诲姞'
- // dialogConfig.isAdd = false
- // },
- // divided: true,
- // icon: 'up',
- // },
- // {
- // label: '鍚戜笅娣诲姞',
- // fn: (c: CurrentType, pageNum: number) => {
- // current.value = null
- // sort.value = c.index + 2 + (pageNum - 1) * 50
- // dialogConfig.visible = true
- // dialogConfig.title = '娣诲姞'
- // dialogConfig.isAdd = false
- // },
- // divided: true,
- // icon: 'down',
- // },
- // {
- // label: '鍒涘缓鍓湰',
- // fn: async ({ row }: CurrentType) => {
- // await wmsInOutStockRecord.cloneData([row.id])
- // ElMessage.success('鍒涘缓鍓湰鎴愬姛')
- // tableRef.value?.getList()
- // },
- // divided: true,
- // icon: 'copy',
- // },
- {
- label: '鍒犻櫎',
- fn: async (c: CurrentType) => {
- const names = selection.value.map((item: { id: string }) => item.id)
- ConfirmBox(
- `鏄惁鍒犻櫎${names.length ? names.join(',') : c.row.id}`
- ).then(async () => {
- const ids = selection.value.map((item: { id: string }) => item.id)
- await wmsInOutStockRecord.deleteWmsInOutStockRecords(ids.length ? ids : [c.row.id])
- ElMessage.success('鍒犻櫎鎴愬姛')
- tableRef.value.getList()
- })
- },
- icon: 'close',
- },
- ]
-
- const onCheck = (records: any) => {
- selection.value = records
- }
-
- const onAddWmsInOutStockRecord = () => {
- const params = tableRef.value?.getPaginationParams()
- current.value = null
- dialogConfig.visible = true
- dialogConfig.isAdd = true
- dialogConfig.title = '娣诲姞'
- sort.value = params.totalCount + 1
- }
-
- //鐐瑰嚮鎸夐挳銆愰珮绾ф煡璇€��
- const onAdvancedQuery = () => {
- const params = tableRef.value?.getPaginationParams()
- current.value = null
- dialogConfigForQuery.visible = true
- dialogConfigForQuery.isAdd = true
- dialogConfigForQuery.title = '楂樼骇鏌ヨ'
- }
-
- const onConfirmWmsInOutStockRecord = async () => {
- dialogConfig.visible = false
- if (dialogConfig.isAdd) {
- tableRef.value?.scrollToRow({
- skip: true,
- })
- } else {
- await tableRef.value?.getList()
- }
- }
- /**
- * 琛岀偣鍑绘椂鏇存柊current
- */
- const onRowClick = ({ row }: any) => {
- if (dialogConfig.visible && current.value) {
- current.value = row
- }
- }
- /**
- * 瀵煎嚭
- */
- const onExport = (data={}) => {
- //const params = tableRef.value?.getParams()
- exportFile('/api/v1/HIAWms/wmsInOutStockRecord/export', data, 'wmsInOutStockRecord')
- }
-
- /**
- * 鍏抽敭瀛楁悳绱�
- */
- const onSearch = () => {
- tableRef.value?.getList({
- Filter: search.value,
- })
- }
-
- /**
- * 閲嶇疆琛ㄦ牸鏁版嵁
- */
- const reloadList = () => {
- tableRef.value?.getList()
- }
- /**
- * 涓婁紶鎴愬姛
- */
- const onSuccess = () => {
- tableRef.value?.getList()
- ElMessage.success('瀵煎叆鎴愬姛')
- }
- /**
- * 澶辫触
- * @param err
- */
- const onError = (err: any) => {
- try {
- const message = JSON.parse(err.message)
- ElMessage.error(message.msg)
- } catch (error) {
- ElMessage.error('瀵煎叆澶辫触')
- }
- }
- /**
- * 涓婁紶閽╁瓙
- */
- const onBeforeUpload = (file: File) => {
- const format = ['xlsx', 'xls', 'csv']
- if (!format.includes(file.name.split('.')[1])) {
- ElMessage.error('瀵煎叆鏂囦欢鏍煎紡涓嶆纭紝璇峰鍏�.xlsx/.xls涓�.csv鏍煎紡鐨勬枃浠�')
- return false
- }
- return true
- }
-
- onMounted(() => {
- headers.value = {
- Authorization: `Bearer ${sessionStorage.getItem('Token')}`,
- 'X-Project': sessionStorage.getItem('X-Project'),
- }
- })
-
- ctx.expose({
- reloadList,
- })
-
- return {
- dataSource,
- contextMenu,
- dialogConfig,
- dialogConfigForQuery,
- dialogSettingConfig,
- tableRef,
- current,
- search,
- sort,
- wmsInOutStockRecordColumns,
- paginationParams,
- headers,
- onBeforeUpload,
- onError,
- onSuccess,
- openDetail,
- onSearch,
- onExport,
- onRowClick,
- onConfirmWmsInOutStockRecord,
- onCheck,
- onAddWmsInOutStockRecord,
- onAdvancedQuery
- }
-}
+import { ref, onMounted, reactive, Ref, nextTick, computed } from 'vue'
+import { injectModel } from '@/libs/Provider/Provider'
+import { WmsInOutStockRecord } from '../Models/WmsInOutStockRecord'
+import { ElMessage } from 'element-plus'
+import { ConfirmBox } from '@/components/ConfirmBox/ConfirmBox'
+import { useFile } from './File'
+
+interface CurrentType {
+ row: any
+ index: number
+}
+export const useWmsInOutStockRecord = (props: any, ctx?: any) => {
+ const wmsInOutStockRecord = injectModel<WmsInOutStockRecord>(
+ 'wmsInOutStockRecord'
+ )
+ const { exportFile } = useFile()
+ /**
+ * 澶撮儴閰嶇疆
+ */
+ const headers = ref({})
+ /**
+ * 鍔ㄦ�佸垪閰嶇疆
+ */
+ const wmsInOutStockRecordColumns = ref<Record<string, any>>([])
+ /**
+ * 鎼滅储鍊�
+ */
+ const search = ref('')
+
+ /**
+ * 鎺掑簭
+ */
+ const sort = ref(0)
+ /**
+ * 閫夋嫨椤�
+ */
+ const selection = ref([])
+ /**
+ * 褰撳墠閫変腑鐨勮
+ */
+ const current = ref<any>(null)
+ /**
+ * 鏁版嵁婧�
+ */
+ const dataSource: Ref<any[]> = ref([])
+
+ /**
+ * 琛ㄦ牸
+ */
+ const tableRef = ref()
+ const dialogConfig = reactive({
+ visible: false,
+ title: '',
+ isAdd: false,
+ })
+ const dialogConfigForQuery = reactive({
+ visible: false,
+ title: '',
+ isAdd: false,
+ })
+
+ const dialogSettingConfig = reactive({
+ visible: false,
+ title: '',
+ })
+
+ /**
+ * 鍒嗛〉鏁版嵁
+ */
+ const paginationParams = ref({})
+
+ /**
+ * 鎵撳紑璇︽儏
+ * @param row
+ */
+ const openDetail = (row: any) => {
+ current.value = row
+ dialogConfig.visible = true
+ dialogConfig.title = row.name
+ dialogConfig.isAdd = false
+ sort.value = row.sort
+ }
+
+ const contextMenu = [
+ // {
+ // label: '灞曞紑璇︽儏',
+ // fn: (c: CurrentType) => {
+ // current.value = null
+ // sort.value = c.row.sort
+ // nextTick(() => openDetail(c.row))
+ // },
+ // divided: true,
+ // icon: 'o',
+ // },
+ // {
+ // label: '鍚戜笂娣诲姞',
+ // fn: (c: CurrentType, pageNum: number) => {
+ // current.value = null
+ // sort.value = c.index + 1 + (pageNum - 1) * 50
+ // dialogConfig.visible = true
+ // dialogConfig.title = '娣诲姞'
+ // dialogConfig.isAdd = false
+ // },
+ // divided: true,
+ // icon: 'up',
+ // },
+ // {
+ // label: '鍚戜笅娣诲姞',
+ // fn: (c: CurrentType, pageNum: number) => {
+ // current.value = null
+ // sort.value = c.index + 2 + (pageNum - 1) * 50
+ // dialogConfig.visible = true
+ // dialogConfig.title = '娣诲姞'
+ // dialogConfig.isAdd = false
+ // },
+ // divided: true,
+ // icon: 'down',
+ // },
+ // {
+ // label: '鍒涘缓鍓湰',
+ // fn: async ({ row }: CurrentType) => {
+ // await wmsInOutStockRecord.cloneData([row.id])
+ // ElMessage.success('鍒涘缓鍓湰鎴愬姛')
+ // tableRef.value?.getList()
+ // },
+ // divided: true,
+ // icon: 'copy',
+ // },
+ {
+ label: '鍒犻櫎',
+ fn: async (c: CurrentType) => {
+ const names = selection.value.map((item: { id: string }) => item.id)
+ ConfirmBox(`鏄惁鍒犻櫎${names.length ? names.join(',') : c.row.id}`).then(
+ async () => {
+ const ids = selection.value.map((item: { id: string }) => item.id)
+ await wmsInOutStockRecord.deleteWmsInOutStockRecords(
+ ids.length ? ids : [c.row.id]
+ )
+ ElMessage.success('鍒犻櫎鎴愬姛')
+ tableRef.value.getList()
+ }
+ )
+ },
+ icon: 'close',
+ },
+ ]
+
+ const onCheck = (records: any) => {
+ selection.value = records
+ }
+
+ const onAddWmsInOutStockRecord = () => {
+ const params = tableRef.value?.getPaginationParams()
+ current.value = null
+ dialogConfig.visible = true
+ dialogConfig.isAdd = true
+ dialogConfig.title = '娣诲姞'
+ sort.value = params.totalCount + 1
+ }
+
+ //鐐瑰嚮鎸夐挳銆愰珮绾ф煡璇€��
+ const onAdvancedQuery = () => {
+ const params = tableRef.value?.getPaginationParams()
+ current.value = null
+ dialogConfigForQuery.visible = true
+ dialogConfigForQuery.isAdd = true
+ dialogConfigForQuery.title = '楂樼骇鏌ヨ'
+ }
+
+ const onConfirmWmsInOutStockRecord = async () => {
+ dialogConfig.visible = false
+ if (dialogConfig.isAdd) {
+ tableRef.value?.scrollToRow({
+ skip: true,
+ })
+ } else {
+ await tableRef.value?.getList()
+ }
+ }
+ /**
+ * 琛岀偣鍑绘椂鏇存柊current
+ */
+ const onRowClick = ({ row }: any) => {
+ if (dialogConfig.visible && current.value) {
+ current.value = row
+ }
+ }
+ /**
+ * 瀵煎嚭
+ */
+ const onExport = (data = {}) => {
+ //const params = tableRef.value?.getParams()
+ exportFile(
+ '/api/v1/HIAWms/wmsInOutStockRecord/export',
+ data,
+ 'wmsInOutStockRecord'
+ )
+ }
+
+ /**
+ * 鍏抽敭瀛楁悳绱�
+ */
+ const onSearch = () => {
+ tableRef.value?.getList({
+ Filter: search.value,
+ })
+ }
+
+ /**
+ * 閲嶇疆琛ㄦ牸鏁版嵁
+ */
+ const reloadList = () => {
+ tableRef.value?.getList()
+ }
+ /**
+ * 涓婁紶鎴愬姛
+ */
+ const onSuccess = () => {
+ tableRef.value?.getList()
+ ElMessage.success('瀵煎叆鎴愬姛')
+ }
+ /**
+ * 澶辫触
+ * @param err
+ */
+ const onError = (err: any) => {
+ try {
+ const message = JSON.parse(err.message)
+ ElMessage.error(message.msg)
+ } catch (error) {
+ ElMessage.error('瀵煎叆澶辫触')
+ }
+ }
+ /**
+ * 涓婁紶閽╁瓙
+ */
+ const onBeforeUpload = (file: File) => {
+ const format = ['xlsx', 'xls', 'csv']
+ if (!format.includes(file.name.split('.')[1])) {
+ ElMessage.error('瀵煎叆鏂囦欢鏍煎紡涓嶆纭紝璇峰鍏�.xlsx/.xls涓�.csv鏍煎紡鐨勬枃浠�')
+ return false
+ }
+ return true
+ }
+
+ onMounted(() => {
+ headers.value = {
+ Authorization: `Bearer ${sessionStorage.getItem('Token')}`,
+ 'X-Project': sessionStorage.getItem('X-Project'),
+ }
+ })
+
+ ctx.expose({
+ reloadList,
+ })
+
+ return {
+ dataSource,
+ contextMenu,
+ dialogConfig,
+ dialogConfigForQuery,
+ dialogSettingConfig,
+ tableRef,
+ current,
+ search,
+ sort,
+ wmsInOutStockRecordColumns,
+ paginationParams,
+ headers,
+ onBeforeUpload,
+ onError,
+ onSuccess,
+ openDetail,
+ onSearch,
+ onExport,
+ onRowClick,
+ onConfirmWmsInOutStockRecord,
+ onCheck,
+ onAddWmsInOutStockRecord,
+ onAdvancedQuery,
+ }
+}
--
Gitblit v1.9.3