<template>
|
<div class="wmsConfigKbcard-container">
|
<el-dialog v-model="isShowDialog" :width="800" draggable="" :close-on-click-modal="false">
|
<template #header>
|
<div style="color: #fff">
|
<!--<el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Edit /> </el-icon>-->
|
<span>{{ props.title }}</span>
|
</div>
|
</template>
|
<el-form :model="ruleForm" ref="ruleFormRef" label-width="auto" :rules="rules" v-loading="loading">
|
<el-row :gutter="35">
|
<el-form-item v-show="false">
|
<el-input v-model="ruleForm.id" />
|
</el-form-item>
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="看板卡号" prop="kanBanCardNo">
|
<el-input v-model="ruleForm.kanBanCardNo" placeholder="请输入看板卡号" maxlength="50" show-word-limit clearable />
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="物料编号" prop="materialCode">
|
<el-input v-model="ruleForm.materialCode" placeholder="请输入物料编号" maxlength="50" show-word-limit clearable />
|
</el-form-item>
|
</el-col>
|
<!-- <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="物料名称" prop="materialName">
|
<el-input v-model="ruleForm.materialName" placeholder="请输入物料名称" maxlength="50" show-word-limit clearable />
|
</el-form-item>
|
</el-col> -->
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="数量" prop="quantity">
|
<el-input v-model="ruleForm.quantity" placeholder="请输入数量" maxlength="10" show-word-limit clearable />
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="客户名称" prop="SupplierCode">
|
<el-select clearable="" v-model="ruleForm.supplierCode" placeholder="请选择客户名称" @change="supplierNameChange">
|
<el-option v-for="(item, index) in arrSupper" :key="index" :value="item.custCode" :label="`${item.value}`"></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="源库区" prop="sourceAreaCode">
|
<el-select clearable="" v-model="ruleForm.sourceAreaCode" placeholder="请选择源库区" @change="sourceAreaChange">
|
<el-option v-for="(item, index) in arrW" :key="index" :value="item.areaCode" :label="`[${item.areaCode}]${item.areaName}`"></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="目标库区" prop="toAreaCode">
|
<el-select clearable="" v-model="ruleForm.toAreaCode" placeholder="请选择目标库区" @change="handleSelectChange">
|
<el-option v-for="(item, index) in arrW" :key="index" :value="item.areaCode" :label="`[${item.areaCode}]${item.areaName}`"></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="目标库位" prop="toPlaceCode">
|
<el-select clearable="" v-model="ruleForm.toPlaceCode" placeholder="请选择目标库位" @change="toPlaceChange">
|
<el-option v-for="(item, index) in arrPlace" :key="index" :value="item.placeCode" :label="`[${item.placeCode}]${item.placeName}`"></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
<template #footer>
|
<span class="dialog-footer">
|
<el-button @click="cancel">取 消</el-button>
|
<el-button type="primary" @click="submit" :disabled="disabled_btn">确 定</el-button>
|
</span>
|
</template>
|
</el-dialog>
|
</div>
|
</template>
|
<style scoped>
|
:deep(.el-select),
|
:deep(.el-input-number) {
|
width: 100%;
|
}
|
</style>
|
<script lang="ts" setup>
|
import { ref, onMounted, nextTick } from 'vue';
|
import { getDictDataItem as di, getDictDataList as dl } from '/@/utils/dict-utils';
|
import { ElMessage } from 'element-plus';
|
import type { FormRules } from 'element-plus';
|
import { addWmsConfigKbcard, updateWmsConfigKbcard, detailWmsConfigKbcard, getPlaceByAreaCode } from '/@/api/main/WmsSystemConfig/wmsConfigKbcard';
|
import { handleSlectDataSupplier, handleSlectDataWmsArea } from '/@/utils/selectData';
|
|
//父级传递来的参数
|
var props = defineProps({
|
title: {
|
type: String,
|
default: '',
|
},
|
});
|
//父级传递来的函数,用于回调
|
const emit = defineEmits(['reloadTable']);
|
const ruleFormRef = ref();
|
const isShowDialog = ref(false);
|
const loading = ref(false);
|
const disabled_btn = ref(false);
|
const ruleForm = ref<any>({});
|
//自行添加其他规则
|
const rules = ref<FormRules>({
|
toAreaCode: [{ required: true, message: '请选择目标库区!', trigger: 'blur' }],
|
toPlaceCode: [{ required: true, message: '请选择目标库位!', trigger: 'blur' }],
|
kanBanCardNo: [{ required: true, message: '请输入看板卡号!', trigger: 'blur' }],
|
materialCode: [{ required: true, message: '请输入物料编号!', trigger: 'blur' }],
|
quantity: [{ required: true, message: '请输入数量!', trigger: 'blur' }],
|
materialName: [{ required: true, message: '请输入物料名称!', trigger: 'blur' }],
|
});
|
|
|
const arrW: any = ref([]); //库区下拉读取接口
|
const arrSupper: any = ref([]); //客户下拉读取接口
|
/*
|
* 打开弹窗
|
* @param flag 标记(1新增 2编辑 3查看)
|
* @param row 行数据
|
*/
|
const openDialog = async (flag: number, row: any) => {
|
|
arrW.value = await handleSlectDataWmsArea(); //下拉读取接口
|
arrSupper.value = await handleSlectDataSupplier(
|
{
|
custType:"货主"
|
}
|
); //下拉读取接口
|
|
// ruleForm.value = JSON.parse(JSON.stringify(row));
|
// 改用detail获取最新数据来编辑
|
let rowData = JSON.parse(JSON.stringify(row));
|
if (rowData.id) ruleForm.value = (await detailWmsConfigKbcard(rowData.id)).data.result;
|
else {
|
ruleForm.value = rowData;
|
}
|
isShowDialog.value = true;
|
};
|
|
// 关闭弹窗
|
const closeDialog = () => {
|
emit('reloadTable');
|
isShowDialog.value = false;
|
};
|
|
// 取消
|
const cancel = () => {
|
isShowDialog.value = false;
|
};
|
//源库区选择
|
const sourceAreaChange = async (value: any) => {
|
ruleForm.value.sourceAreaName = '';
|
ruleForm.value.sourceAreaName = arrW.value.find((item: { value: any }) => item.areaCode == value).areaName;
|
};
|
//客户选择
|
const supplierNameChange = async (value: any) => {
|
ruleForm.value.supplierName = '';
|
ruleForm.value.supplierName = arrSupper.value.find((item: { value: any }) => item.custCode == value).custChinaName;
|
};
|
let arr: any = ref([]);
|
//库位查询,目标库区选择
|
const arrPlace: any = ref([]); //下拉读取接口
|
const handleSelectChange = async (value: any) => {
|
ruleForm.value.toAreaName = '';
|
ruleForm.value.toPlaceName = '';
|
ruleForm.value.toPlaceCode = '';
|
ruleForm.value.toAreaName = arrW.value.find((item: { value: any }) => item.areaCode == value).areaName;
|
arr = await getPlaceByAreaCode(value);
|
arrPlace.value = arr.data.result;
|
};
|
//库位选择
|
const toPlaceChange = async (value: any) => {
|
ruleForm.value.toPlaceName = arrPlace.value.find((item: { value: any }) => item.placeCode == value).placeName;
|
};
|
|
// 提交
|
const submit = async () => {
|
disabled_btn.value = true;
|
ruleFormRef.value.validate(async (isValid: boolean, fields?: any) => {
|
if (isValid) {
|
loading.value = true;
|
let values = ruleForm.value;
|
let ret = {};
|
let title = '新增';
|
// console.log('values',values)
|
if (ruleForm.value.id == undefined || ruleForm.value.id == null || ruleForm.value.id == '' || ruleForm.value.id == 0) {
|
ret = await addWmsConfigKbcard(values);
|
} else {
|
title = '编辑';
|
ret = await updateWmsConfigKbcard(values);
|
}
|
loading.value = false;
|
disabled_btn.value = false;
|
if (ret.data.type == 'success') {
|
ElMessage.success(title + '成功');
|
closeDialog();
|
}
|
} else {
|
disabled_btn.value = false;
|
ElMessage({
|
message: `表单有${Object.keys(fields).length}处验证失败,请修改后再提交`,
|
type: 'error',
|
});
|
}
|
});
|
};
|
|
// 页面加载时
|
|
onMounted(() => {
|
|
});
|
|
//将属性或者函数暴露给父组件
|
defineExpose({ openDialog });
|
</script>
|