| | |
| | | import { defineComponent } from 'vue' |
| | | 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 { 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 |
| | |
| | | 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 表格 |
| | | */ |
| | |
| | | return ( |
| | | <div |
| | | class={{ |
| | | [styles.wmsmaterialList]: true, |
| | | [styles.wmsMaterialList]: true, |
| | | }} |
| | | > |
| | | <BaseTable |
| | | ref={tableRef} |
| | | url={url} |
| | | sortUrlTpl="/api/v1/hiawms/wmsmaterial/{id}/adjustsort/{sort}" |
| | | sortUrlTpl="/api/v1/hIAWms/wmsMaterial/{id}/adjustsort/{sort}" |
| | | v-model:dataSource={dataSource.value} |
| | | columns={columns} |
| | | contextMenu={contextMenu} |
| | |
| | | onCheck={onCheck} |
| | | onRowClick={onRowClick} |
| | | isHidePagination={isHidePagination} |
| | | pageSize={50} |
| | | pageSize={20} |
| | | v-slots={{ |
| | | name: ({ row }: any) => { |
| | | return row?.name ? ( |
| | |
| | | </div> |
| | | ) |
| | | } |
| | | |
| | | return () => { |
| | | return ( |
| | | <div class={styles.wmsmaterialContent}> |
| | | <div class={styles.wmsMaterialContent}> |
| | | {/* 添加/编辑 */} |
| | | <WmsMaterialDrawer |
| | | v-model={dialogConfig.visible} |
| | |
| | | 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" |
| | | v-permission="wmsMaterial-add" |
| | | icon="add-p" |
| | | onClick={onAddWmsMaterial} |
| | | type="primary" |
| | |
| | | </IconButton> |
| | | <el-divider direction="vertical" /> |
| | | <el-upload |
| | | v-permission="wmsmaterial-import" |
| | | v-permission="wmsMaterial-import" |
| | | name="file" |
| | | accept=".xlsx,.xls,.csv" |
| | | show-file-list={false} |
| | |
| | | onSuccess={onSuccess} |
| | | before-upload={onBeforeUpload} |
| | | headers={headers.value} |
| | | action="/api/v1/hiawms/wmsmaterial/import" |
| | | action="/api/v1/hIAWms/wmsMaterial/import" |
| | | > |
| | | <IconButton icon="in">导入</IconButton> |
| | | </el-upload> |
| | | |
| | | <IconButton |
| | | v-permission="wmsmaterial-output" |
| | | v-permission="wmsMaterial-output" |
| | | icon="out" |
| | | onClick={onExport} |
| | | > |
| | | 导出 |
| | | </IconButton> |
| | | </div> |
| | | <Search |
| | | {/* <Search |
| | | placeholder="请输入关键字" |
| | | v-model={search.value} |
| | | onConfirm={onSearch} |
| | | style={{ marginTop: '-1px' }} |
| | | /> |
| | | /> */} |
| | | </div> |
| | | |
| | | <RenderBaseTable |
| | | url="/api/v1/hiawms/wmsmaterial" |
| | | url="/api/v1/hIAWms/wmsMaterial/page" |
| | | dataSource={dataSource} |
| | | isChecked={true} |
| | | isDrag={true} |