¶Ô±ÈÐÂÎļþ |
| | |
| | | import { computed, defineComponent, onMounted, reactive, ref } from 'vue' |
| | | import type { Ref } from 'vue' |
| | | import BaseTable from '@/components/Table/Table' |
| | | import styles from './WmsMaterial.module.scss' |
| | | import { useWmsMaterial } from '../../../Controllers/WmsMaterial' |
| | | import IconButton from '@/components/IconButton/IconButton' |
| | | import WmsMaterialDrawer from '../Dialog/WmsMaterialDrawer/WmsMaterialDrawer' |
| | | import Search from '@/components/Search/Search' |
| | | import { columns } from './Config' |
| | | import TdButton from '@/components/TdButton/TdButton' |
| | | import { vPermission } from '@/libs/Permission/Permission' |
| | | import { |
| | | getWmsEnumData, |
| | | getWmsDataList, |
| | | } from '@/widgets/HIAWms/Models/Service/WmsMaterialDrawer' |
| | | import { |
| | | ElInput, |
| | | ElSelect, |
| | | ElOption, |
| | | ElDatePicker, |
| | | ElForm, |
| | | ElFormItem, |
| | | } from 'element-plus' |
| | | import { injectModel } from '@/libs/Provider/Provider' |
| | | |
| | | interface RenderTableType { |
| | | url?: string |
| | | dataSource: Ref<any[]> |
| | | isDrag?: boolean |
| | | isChecked?: boolean |
| | | isHidePagination?: boolean |
| | | params?: Record<string, any> |
| | | autoHeight?: boolean |
| | | } |
| | | |
| | | export default defineComponent({ |
| | | name: 'WmsMaterial', |
| | | directives: { |
| | | permission: vPermission, |
| | | }, |
| | | setup(props, ctx) { |
| | | const { |
| | | dataSource, |
| | | contextMenu, |
| | | dialogConfig, |
| | | tableRef, |
| | | current, |
| | | search, |
| | | sort, |
| | | headers, |
| | | onError, |
| | | onSearch, |
| | | onRowClick, |
| | | onConfirmWmsMaterial, |
| | | onCheck, |
| | | onAddWmsMaterial, |
| | | onExport, |
| | | openDetail, |
| | | onSuccess, |
| | | onBeforeUpload, |
| | | } = useWmsMaterial(props, ctx) |
| | | |
| | | // æ°å¢çæ¥è¯¢æ¡ä»¶ |
| | | const queryForm = ref({ |
| | | materialCode: '', |
| | | materialName: '', |
| | | materialType: '', |
| | | purchaseType: '', |
| | | filter: '', |
| | | }) |
| | | |
| | | const queryParams = computed(() => ({ |
| | | ...queryForm.value, |
| | | materialType: queryForm.value.materialType || '', // å¤ç䏿 |
| | | purchaseType: queryForm.value.purchaseType || '', |
| | | })) |
| | | |
| | | // 卿æä¸¾é项 |
| | | const enumOptions = reactive({ |
| | | materialType: [] as Array<{ label: string; value: any }>, |
| | | purchaseType: [] as Array<{ label: string; value: any }>, |
| | | isMainBranch: [] as Array<{ label: string; value: any }>, |
| | | }) |
| | | |
| | | // è·åæä¸¾æ°æ® |
| | | const fetchEnumData = async () => { |
| | | try { |
| | | // è·åç©æç±»åæä¸¾ |
| | | const materialTypeData = await getWmsEnumData({ |
| | | EnumName: 'MaterialTypeEnum', |
| | | }) |
| | | enumOptions.materialType = materialTypeData.map((item) => ({ |
| | | label: item.description, |
| | | value: item.value, |
| | | })) |
| | | |
| | | // è·åéè´ç±»åæä¸¾ |
| | | const purchaseTypeData = await getWmsEnumData({ |
| | | EnumName: 'PurchaseTypeEnum', |
| | | }) |
| | | enumOptions.purchaseType = purchaseTypeData.map((item) => ({ |
| | | label: item.description, |
| | | value: item.value, |
| | | })) |
| | | } catch (error) { |
| | | console.error('è·åæä¸¾æ°æ®å¤±è´¥:', error) |
| | | } |
| | | } |
| | | |
| | | // ç»ä»¶æè½½æ¶è·åæä¸¾æ°æ® |
| | | onMounted(() => { |
| | | fetchEnumData() |
| | | }) |
| | | |
| | | // æ°å¢çæ¥è¯¢æ¹æ³ |
| | | const handleQuery = async () => { |
| | | console.log('æ¥è¯¢æ¡ä»¶:', queryParams.value) |
| | | tableRef.value.getTableList() |
| | | // tableRef.value.getList(queryParams.value) |
| | | } |
| | | |
| | | // éç½®æ¥è¯¢æ¡ä»¶ |
| | | const resetQuery = () => { |
| | | queryForm.value = { |
| | | materialCode: '', |
| | | materialName: '', |
| | | materialType: '', |
| | | purchaseType: '', |
| | | filter: '', |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @returns è¡¨æ ¼ |
| | | */ |
| | | const RenderBaseTable = (props: RenderTableType) => { |
| | | const { |
| | | url, |
| | | dataSource, |
| | | isDrag, |
| | | isChecked, |
| | | isHidePagination, |
| | | params, |
| | | autoHeight, |
| | | } = props |
| | | |
| | | return ( |
| | | <div |
| | | class={{ |
| | | [styles.wmsMaterialList]: true, |
| | | }} |
| | | > |
| | | <BaseTable |
| | | ref={tableRef} |
| | | url={url} |
| | | sortUrlTpl="/api/v1/hIAWms/wmsMaterial/{id}/adjustsort/{sort}" |
| | | v-model:dataSource={dataSource.value} |
| | | columns={columns} |
| | | contextMenu={contextMenu} |
| | | params={params} |
| | | isDrag={isDrag} |
| | | isChecked={isChecked} |
| | | autoHeight={autoHeight} |
| | | onCheck={onCheck} |
| | | onRowClick={onRowClick} |
| | | isHidePagination={isHidePagination} |
| | | pageSize={10} |
| | | v-slots={{ |
| | | name: ({ row }: any) => { |
| | | return row?.name ? ( |
| | | <TdButton |
| | | onClick={() => openDetail(row)} |
| | | text={<span style="color:#5a84ff">详æ
</span>} |
| | | icon="scale" |
| | | tip={row?.name} |
| | | hover |
| | | > |
| | | {row?.name} |
| | | </TdButton> |
| | | ) : ( |
| | | '-' |
| | | ) |
| | | }, |
| | | }} |
| | | ></BaseTable> |
| | | </div> |
| | | ) |
| | | } |
| | | |
| | | return () => { |
| | | return ( |
| | | <div class={styles.wmsMaterialContent}> |
| | | {/* æ·»å /ç¼è¾ */} |
| | | <WmsMaterialDrawer |
| | | v-model={dialogConfig.visible} |
| | | title={dialogConfig.title} |
| | | row={current.value} |
| | | sort={sort.value} |
| | | onConfirm={onConfirmWmsMaterial} |
| | | /> |
| | | |
| | | {/* æ°å¢çæ¥è¯¢è¡¨å */} |
| | | <ElForm |
| | | inline |
| | | model={queryForm.value} |
| | | class={styles.queryForm} |
| | | label-width="80px" |
| | | > |
| | | <ElFormItem label="å
³é®å"> |
| | | <ElInput |
| | | v-model={queryForm.value.filter} |
| | | placeholder="请è¾å
¥å
³é®åæç´¢" |
| | | clearable |
| | | class={styles.formItem} |
| | | /> |
| | | </ElFormItem> |
| | | <ElFormItem label="ç©æç¼ç "> |
| | | <ElInput |
| | | v-model={queryForm.value.materialCode} |
| | | placeholder="请è¾å
¥ç©æç¼ç " |
| | | clearable |
| | | class={styles.formItem} |
| | | /> |
| | | </ElFormItem> |
| | | <ElFormItem label="ç©æåç§°"> |
| | | <ElInput |
| | | v-model={queryForm.value.materialName} |
| | | placeholder="请è¾å
¥ç©æåç§°" |
| | | clearable |
| | | class={styles.formItem} |
| | | /> |
| | | </ElFormItem> |
| | | <ElFormItem label="ç©æç±»å"> |
| | | <ElSelect |
| | | v-model={queryForm.value.materialType} |
| | | placeholder="è¯·éæ©ç©æç±»å" |
| | | clearable |
| | | loading={enumOptions.materialType.length === 0} |
| | | class={styles.formItem} |
| | | > |
| | | {enumOptions.materialType.map((option) => ( |
| | | <ElOption |
| | | key={option.value} |
| | | label={option.label} |
| | | value={option.value} |
| | | /> |
| | | ))} |
| | | </ElSelect> |
| | | </ElFormItem> |
| | | <ElFormItem label="éè´ç±»å"> |
| | | <ElSelect |
| | | v-model={queryForm.value.purchaseType} |
| | | placeholder="è¯·éæ©éè´ç±»å" |
| | | clearable |
| | | loading={enumOptions.purchaseType.length === 0} |
| | | class={styles.formItem} |
| | | > |
| | | {enumOptions.purchaseType.map((option) => ( |
| | | <ElOption |
| | | key={option.value} |
| | | label={option.label} |
| | | value={option.value} |
| | | /> |
| | | ))} |
| | | </ElSelect> |
| | | </ElFormItem> |
| | | {/* <ElFormItem label="æ¥æèå´"> |
| | | <ElDatePicker |
| | | v-model={queryForm.value.dateRange} |
| | | type="daterange" |
| | | range-separator="è³" |
| | | start-placeholder="å¼å§æ¥æ" |
| | | end-placeholder="ç»ææ¥æ" |
| | | value-format="YYYY-MM-DD" |
| | | /> |
| | | </ElFormItem> */} |
| | | <ElFormItem> |
| | | <IconButton type="primary" icon="search" onClick={handleQuery}> |
| | | æ¥è¯¢ |
| | | </IconButton> |
| | | <IconButton |
| | | style="margin-left: 10px;" |
| | | icon="refresh" |
| | | onClick={resetQuery} |
| | | > |
| | | éç½® |
| | | </IconButton> |
| | | </ElFormItem> |
| | | </ElForm> |
| | | |
| | | <div class={styles.headerContent}> |
| | | <div class={styles.header}> |
| | | <IconButton |
| | | v-permission="wmsMaterial-add" |
| | | icon="add-p" |
| | | onClick={onAddWmsMaterial} |
| | | type="primary" |
| | | > |
| | | æ·»å |
| | | </IconButton> |
| | | <el-divider direction="vertical" /> |
| | | <el-upload |
| | | v-permission="wmsMaterial-import" |
| | | name="file" |
| | | accept=".xlsx,.xls,.csv" |
| | | show-file-list={false} |
| | | onError={onError} |
| | | onSuccess={onSuccess} |
| | | before-upload={onBeforeUpload} |
| | | headers={headers.value} |
| | | action="/api/v1/hIAWms/wmsMaterial/import" |
| | | > |
| | | <IconButton icon="in">导å
¥</IconButton> |
| | | </el-upload> |
| | | |
| | | <IconButton |
| | | v-permission="wmsMaterial-output" |
| | | icon="out" |
| | | onClick={onExport} |
| | | > |
| | | å¯¼åº |
| | | </IconButton> |
| | | </div> |
| | | {/* <Search |
| | | placeholder="请è¾å
¥å
³é®å" |
| | | v-model={search.value} |
| | | onConfirm={onSearch} |
| | | style={{ marginTop: '-1px' }} |
| | | /> */} |
| | | </div> |
| | | |
| | | <RenderBaseTable |
| | | url="/api/v1/hIAWms/wmsMaterial/page" |
| | | dataSource={dataSource} |
| | | isChecked={true} |
| | | isDrag={true} |
| | | /> |
| | | </div> |
| | | ) |
| | | } |
| | | }, |
| | | }) |