import { computed, defineComponent, onMounted, reactive, ref } from 'vue'
|
import type { Ref } from 'vue'
|
import BaseTable from '@/components/Table/Table'
|
import styles from './CallMaterialOrder.module.scss'
|
import { useCallMaterialOrder } from '../../../Controllers/CallMaterialOrder'
|
import IconButton from '@/components/IconButton/IconButton'
|
import CallMaterialOrderDrawer from '../Dialog/CallMaterialOrderDrawer/CallMaterialOrderDrawer'
|
import CallMaterialOrderQueryDrawer from '../Dialog/CallMaterialOrderQueryDrawer/CallMaterialOrderQueryDrawer'
|
import Search from '@/components/Search/Search'
|
import { columns } from './Config'
|
import TdButton from '@/components/TdButton/TdButton'
|
import { vPermission } from '@/libs/Permission/Permission'
|
import dayjs from 'dayjs'
|
import {
|
getWmsEnumData
|
} from '@/widgets/CallMaterialOrder/Models/Service/CallMaterialOrderDrawer'
|
// 引入公共选项配置
|
import {
|
FILTER_MODE_OPTIONS_STRING
|
} from '@/components/DyFormForHighQuery/DyFormForHighQueryOptions';
|
// 引入公共高级查询工具文件
|
import { commonSaveCurHighQueryData,setValueForCurHighQueryData,commonGetHighQueryForm,initQueryForm,GetFilteredData } from '@/utils/myHighQueryUtils';
|
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: 'CallMaterialOrder',
|
directives: {
|
permission: vPermission,
|
},
|
setup(props, ctx) {
|
const {
|
dataSource,
|
contextMenu,
|
dialogConfig,
|
dialogConfigForQuery,
|
tableRef,
|
current,
|
search,
|
sort,
|
headers,
|
onError,
|
onSearch,
|
onRowClick,
|
onConfirmCallMaterialOrder,
|
onCheck,
|
onAddCallMaterialOrder,
|
onCallMaterialToWms,
|
onAdvancedQuery,
|
onExport,
|
openDetail,
|
onSuccess,
|
onBeforeUpload,
|
} = useCallMaterialOrder(props, ctx)
|
|
//定义高级查询引用
|
const callMaterialOrderQueryDrawerRef=ref(null);
|
|
//定义整体模糊查询的列数组(注意:必须大小写跟后端的实体类属性名一致,否则会导致匹配不对的问题)
|
const _searchFormInputAttrs = ref([
|
'DataIdentifier','MaterialMode','WmsRetResult','WmsTaskNo','CreatorName','LastModifierName','Remark'
|
]);
|
const searchFormInputAttrs_Placeholder = ref('请输入原料标识/原料型号/WMS返回结果/WMS任务号/创建人/修改人/备注');
|
|
|
// 动态枚举选项
|
const enumOptions = reactive({
|
callMaterialStatus: [] as Array<{label: string; value: any }>,
|
})
|
|
// 获取枚举数据
|
const fetchEnumData = async () => {
|
try {
|
const callMaterialStatusEnumData = await getWmsEnumData({
|
EnumName: 'CallMaterialStatusEnum',
|
})
|
enumOptions.callMaterialStatus = callMaterialStatusEnumData.map((item) => ({
|
label: item.description,
|
value: item.value,
|
}))
|
|
} catch (error) {
|
console.error('获取枚举数据失败:', error)
|
}
|
}
|
// 组件挂载时获取枚举数据
|
onMounted(() => {
|
fetchEnumData()
|
resetQuery();
|
})
|
/*******************************************************[高级查询]开始********************************************************************************* */
|
// 新增的查询条件
|
const queryForm = ref({ searchVal: '',str_searchFormInputAttrs:[],searchVal_FilterMode:'' });
|
// 定义响应式查询数据
|
const _curHighQueryData = ref({ searchVal: '',str_searchFormInputAttrs:[],searchVal_FilterMode:'' });
|
// 新版的查询方法(主页面中的按钮【查询】)
|
const handleQueryForMain = async () => {
|
setValueForCurHighQueryData(_curHighQueryData,queryForm,_searchFormInputAttrs);
|
tableRef.value.getList(_curHighQueryData.value)
|
}
|
// 新版的查询方法(高级查询中的按钮【查询】)
|
const handleQuery = async (extraParams = {}) => {
|
let filteredData = GetFilteredData(extraParams,queryForm,_searchFormInputAttrs,_curHighQueryData);
|
tableRef.value.getList(filteredData)
|
}
|
// 新版的查询重置
|
const resetQuery = () => {
|
initQueryForm(queryForm,_searchFormInputAttrs,FILTER_MODE_OPTIONS_STRING);
|
setValueForCurHighQueryData(_curHighQueryData,queryForm,_searchFormInputAttrs);
|
}
|
//新版的导出方法
|
const handleExport=()=>{
|
onExport(_curHighQueryData.value);
|
}
|
// 新版的查询弹出框关闭方法
|
const closeQuery = (extraParams={}) => {
|
GetFilteredData(extraParams,queryForm,_searchFormInputAttrs,_curHighQueryData);
|
}
|
/*******************************************************[高级查询]结束********************************************************************************* */
|
|
|
/**
|
* @returns 表格
|
*/
|
const RenderBaseTable = (props: RenderTableType) => {
|
const {
|
url,
|
dataSource,
|
isDrag,
|
isChecked,
|
isHidePagination,
|
params,
|
autoHeight,
|
} = props
|
|
return (
|
<div
|
class={{
|
[styles.callMaterialOrderList]: true,
|
}}
|
>
|
<BaseTable
|
ref={tableRef}
|
url={url}
|
sortUrlTpl="/api/v1/PipeLineLems/callMaterialOrder/{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={20}
|
v-slots={{
|
creationTime: ({ row }: any) => {
|
return (
|
<div>
|
{row.creationTime != null
|
? dayjs(row.creationTime).format('YYYY-MM-DD HH:mm:ss')
|
: '-'}
|
</div>
|
)
|
},
|
lastModificationTime: ({ row }: any) => {
|
return (
|
<div>
|
{row.lastModificationTime != null
|
? dayjs(row.lastModificationTime).format('YYYY-MM-DD HH:mm:ss')
|
: '-'}
|
</div>
|
)
|
},
|
isDeleted: ({ row }: any) => {
|
return (
|
<div>
|
{row.isDeleted != null ? (row.isDeleted ? '是' : '否') : '-'}
|
</div>
|
)
|
},
|
deletionTime: ({ row }: any) => {
|
return (
|
<div>
|
{row.deletionTime != null
|
? dayjs(row.deletionTime).format('YYYY-MM-DD HH:mm:ss')
|
: '-'}
|
</div>
|
)
|
},
|
isDisabled: ({ row }: any) => {
|
return (
|
<div>
|
{row.isDisabled != null ? (row.isDisabled ? '是' : '否') : '-'}
|
</div>
|
)
|
},
|
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.callMaterialOrderContent}>
|
{/* 添加/编辑 */}
|
<CallMaterialOrderDrawer
|
v-model={dialogConfig.visible}
|
title={dialogConfig.title}
|
row={current.value}
|
sort={sort.value}
|
onConfirm={onConfirmCallMaterialOrder}
|
/>
|
{/* 高级查询 */}
|
<CallMaterialOrderQueryDrawer
|
ref="callMaterialOrderQueryDrawerRef"
|
v-model={dialogConfigForQuery.visible}
|
title={dialogConfigForQuery.title}
|
row={current.value}
|
sort={sort.value}
|
onConfirmQuery={handleQuery}
|
onRestQuery={resetQuery}
|
onClose={closeQuery}
|
/>
|
|
<div class={styles.headerContent}>
|
<div class={styles.header}>
|
{/* <IconButton
|
v-permission="callMaterialOrder-add"
|
icon="add-p"
|
onClick={onAddCallMaterialOrder}
|
type="primary"
|
>
|
添加
|
</IconButton>
|
<el-divider direction="vertical" /> */}
|
<IconButton
|
v-permission="callMaterialOrder-add"
|
icon="add-p"
|
onClick={onCallMaterialToWms}
|
type="primary"
|
>
|
叫料
|
</IconButton>
|
<el-divider direction="vertical" />
|
{/* <el-upload
|
v-permission="callMaterialOrder-import"
|
name="file"
|
accept=".xlsx,.xls,.csv"
|
show-file-list={false}
|
onError={onError}
|
onSuccess={onSuccess}
|
before-upload={onBeforeUpload}
|
headers={headers.value}
|
action="/api/v1/PipeLineLems/callMaterialOrder/import"
|
>
|
<IconButton icon="in">导入</IconButton>
|
</el-upload> */}
|
|
<IconButton
|
v-permission="callMaterialOrder-output"
|
icon="out"
|
onClick={handleExport}
|
>
|
导出
|
</IconButton>
|
</div>
|
<ElFormItem style={{ marginTop: '15px' }}>
|
<ElFormItem label="关键字">
|
<el-tooltip
|
class="box-item"
|
effect="dark"
|
content={searchFormInputAttrs_Placeholder.value}
|
placement="top-start"
|
>
|
<ElInput
|
v-model={queryForm.value.searchVal}
|
placeholder={searchFormInputAttrs_Placeholder.value}
|
clearable
|
class={styles.formItem}
|
/>
|
</el-tooltip>
|
</ElFormItem>
|
<ElFormItem label="" style="width:100px;">
|
<ElSelect
|
v-model={queryForm.value.searchVal_FilterMode}
|
placeholder="请选择"
|
class={styles.formItem}
|
>
|
{FILTER_MODE_OPTIONS_STRING.map((option) => (
|
<ElOption
|
key={option.value}
|
label={option.label}
|
value={option.value}
|
/>
|
))}
|
</ElSelect>
|
</ElFormItem>
|
<IconButton type="primary" icon="search" onClick={handleQueryForMain}>
|
查询
|
</IconButton>
|
{/* <IconButton style="" icon="refresh" onClick={resetQuery}>
|
重置
|
</IconButton> */}
|
<IconButton
|
v-permission="callMaterialOrder-add"
|
icon="search"
|
onClick={onAdvancedQuery}
|
type="primary"
|
>
|
高级查询
|
</IconButton>
|
</ElFormItem>
|
</div>
|
|
<RenderBaseTable
|
url="/api/v1/PipeLineLems/callMaterialOrder/page"
|
dataSource={dataSource}
|
isChecked={true}
|
isDrag={true}
|
/>
|
</div>
|
)
|
}
|
},
|
})
|