前后端修改
This commit is contained in:
@@ -114,9 +114,9 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="扫码时间" align="center" prop="scanTime" width="155" :show-overflow-tooltip="true">
|
||||
<el-table-column label="新增时间" align="center" prop="createTime" width="155" :show-overflow-tooltip="true">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.scanTime, '{y}-{m}-{d} {h}:{i}') }}</span>
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
|
||||
@@ -11,7 +11,11 @@
|
||||
|
||||
<!-- 真实库区 -->
|
||||
<el-form-item label="真实库区">
|
||||
<ActualWarehouseSelect v-model="queryParams.actualWarehouseId" @change="handleActualWarehouseChange" />
|
||||
<ActualWarehouseSelect
|
||||
v-model="queryParams.actualWarehouseId"
|
||||
@change="handleActualWarehouseChange"
|
||||
:width="220"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
|
||||
@@ -1,25 +1,212 @@
|
||||
<template>
|
||||
<BasePage :qrcode="qrcode" :querys="querys" :labelType="labelType" :hideType="hideType" />
|
||||
<div
|
||||
:class="['actual-warehouse-select', { 'is-block': block }]"
|
||||
:style="wrapperStyle"
|
||||
>
|
||||
<el-cascader
|
||||
ref="cascader"
|
||||
v-model="innerPath"
|
||||
:props="cascaderProps"
|
||||
:placeholder="placeholder"
|
||||
:clearable="clearable"
|
||||
:show-all-levels="true"
|
||||
:emit-path="true"
|
||||
style="width: 100%;"
|
||||
@change="handleChange"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import BasePage from './panels/base.vue';
|
||||
import { listActualWarehouse } from '@/api/wms/actualWarehouse';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
BasePage
|
||||
name: 'ActualWarehouseSelect',
|
||||
props: {
|
||||
// 对外仍然是「单个 ID」,即第三级 actualWarehouseId
|
||||
value: {
|
||||
type: [Number, String, null],
|
||||
default: null
|
||||
},
|
||||
placeholder: {
|
||||
type: String,
|
||||
default: '请选择实际库位'
|
||||
},
|
||||
clearable: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
// 已经不再显示“最高级”
|
||||
showTop: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
block: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
width: {
|
||||
type: [String, Number],
|
||||
default: 240
|
||||
},
|
||||
size: {
|
||||
type: String,
|
||||
default: 'small'
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
qrcode: true,
|
||||
querys: {
|
||||
dataType: 1,
|
||||
// itemType: 'raw_material'
|
||||
materialType: '原料'
|
||||
},
|
||||
labelType: '2',
|
||||
hideType: true
|
||||
// 级联组件内部使用的「路径值」,例如 [一级ID, 二级ID, 三级ID]
|
||||
innerPath: [],
|
||||
// 记录所有已加载节点(如果后面要根据 ID 反查路径,可复用)
|
||||
allLoadedNodes: []
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
wrapperStyle() {
|
||||
const widthValue = this.block
|
||||
? '100%'
|
||||
: (typeof this.width === 'number' ? `${this.width}px` : this.width);
|
||||
return { width: widthValue };
|
||||
},
|
||||
// el-cascader 的 props 配置
|
||||
cascaderProps() {
|
||||
return {
|
||||
lazy: true,
|
||||
lazyLoad: this.loadNode, // 懒加载方法
|
||||
checkStrictly: false, // 只允许选叶子节点
|
||||
value: 'value',
|
||||
label: 'label',
|
||||
children: 'children'
|
||||
};
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
// 外部把 value 置空时,同步清空面板
|
||||
value(val) {
|
||||
if (val == null || val === '') {
|
||||
this.innerPath = [];
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 级联懒加载
|
||||
* node.level:
|
||||
* 0:根(还没选任何东西,parentId = 0 -> 加载一级)
|
||||
* 1:一级节点,加载二级
|
||||
* 2:二级节点,加载三级(三级设为叶子,不再展开)
|
||||
*/
|
||||
loadNode(node, resolve) {
|
||||
const { level, value } = node;
|
||||
|
||||
// 超过第三级就不再加载
|
||||
if (level >= 3) {
|
||||
resolve([]);
|
||||
return;
|
||||
}
|
||||
|
||||
const parentId = level === 0 ? 0 : value;
|
||||
|
||||
listActualWarehouse({ parentId }).then(res => {
|
||||
const list = (res.data || []).map(item => {
|
||||
const nextLevel = level + 1;
|
||||
const isLeafLevel = nextLevel >= 3; // 第三级为叶子,不能再展开
|
||||
|
||||
const nodeData = {
|
||||
value: item.actualWarehouseId,
|
||||
label: item.actualWarehouseName,
|
||||
leaf: isLeafLevel,
|
||||
// 只有第三级可选;一、二级全部 disabled
|
||||
disabled: nextLevel < 3 || item.isEnabled === false,
|
||||
// 保留原始数据和层级
|
||||
raw: item,
|
||||
level: nextLevel
|
||||
};
|
||||
|
||||
this.registerNode(nodeData);
|
||||
return nodeData;
|
||||
});
|
||||
|
||||
resolve(list);
|
||||
}).catch(err => {
|
||||
console.error('加载仓库树失败:', err);
|
||||
resolve([]);
|
||||
});
|
||||
},
|
||||
|
||||
/** 把节点放进缓存数组里,后面如需扩展可用 */
|
||||
registerNode(node) {
|
||||
const id = node.value;
|
||||
const idx = this.allLoadedNodes.findIndex(
|
||||
n => String(n.value) === String(id)
|
||||
);
|
||||
if (idx === -1) {
|
||||
this.allLoadedNodes.push(node);
|
||||
} else {
|
||||
this.$set(this.allLoadedNodes, idx, {
|
||||
...this.allLoadedNodes[idx],
|
||||
...node
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 选中变化:
|
||||
* value 是路径数组,如 [一级ID, 二级ID, 三级ID]
|
||||
* 我们对外只抛最后一个(第三级)ID
|
||||
*/
|
||||
handleChange(value) {
|
||||
if (!Array.isArray(value) || value.length === 0) {
|
||||
this.$emit('input', null);
|
||||
this.$emit('select', null);
|
||||
return;
|
||||
}
|
||||
|
||||
const leafId = value[value.length - 1];
|
||||
|
||||
// 拿到当前选中节点,获取完整路径信息
|
||||
const nodes = this.$refs.cascader.getCheckedNodes();
|
||||
let payload = null;
|
||||
if (nodes && nodes.length > 0) {
|
||||
const node = nodes[0];
|
||||
const pathNodes = node.path || [];
|
||||
|
||||
payload = {
|
||||
id: leafId,
|
||||
pathIds: pathNodes.map(n => n.value),
|
||||
pathLabels: pathNodes.map(n => n.label),
|
||||
// 原始 data(如果需要后台做别的处理可以用)
|
||||
rawPath: pathNodes.map(n => n.data || n.raw || {})
|
||||
};
|
||||
}
|
||||
|
||||
this.$emit('input', leafId);
|
||||
this.$emit('select', payload);
|
||||
},
|
||||
|
||||
/** 外部刷新:如果以后需要强制重载,可以扩展这里(目前不需要缓存) */
|
||||
refresh() {
|
||||
this.innerPath = [];
|
||||
this.allLoadedNodes = [];
|
||||
// el-cascader 的懒加载不需要预载,这里清空即可
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.actual-warehouse-select {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
}
|
||||
</script>
|
||||
|
||||
.actual-warehouse-select.is-block {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* 让级联宽度占满容器,其他高度、边框等跟 el-select 共用全局 .el-input__inner 样式 */
|
||||
.actual-warehouse-select .el-cascader {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -15,13 +15,13 @@
|
||||
<el-option :value="1" label="当前数据">当前数据</el-option>
|
||||
</el-select>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="所在库位" prop="warehouseId" v-if="!hideWarehouseQuery">
|
||||
<el-form-item label="逻辑库位" prop="warehouseId" v-if="!hideWarehouseQuery">
|
||||
<warehouse-select v-model="queryParams.warehouseId" placeholder="请选择仓库/库区/库位"
|
||||
style="width: 100%; display: inline-block;" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="实际库区" prop="actualWarehouseId" v-if="!hideWarehouseQuery">
|
||||
<actual-warehouse-select v-model="queryParams.actualWarehouseId" placeholder="请选择实际库位"
|
||||
style="width: 100%; display: inline-block;" clearable />
|
||||
style="display: inline-block;" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="厂家卷号" prop="supplierCoilNo">
|
||||
<el-input v-model="queryParams.supplierCoilNo" placeholder="请输入厂家原料卷号" clearable
|
||||
@@ -69,7 +69,7 @@
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="materialCoilList" @selection-change="handleSelectionChange" height="450px">
|
||||
<el-table v-loading="loading" :data="materialCoilList" @selection-change="handleSelectionChange" >
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo" />
|
||||
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo" />
|
||||
|
||||
@@ -19,7 +19,7 @@ export default {
|
||||
},
|
||||
labelType: '3',
|
||||
showStatus: true,
|
||||
hideType: true,
|
||||
hideType: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,8 +171,12 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="真实库区" required>
|
||||
<ActualWarehouseSelect v-model="item.actualWarehouseId" placeholder="请选择真实库区" style="width: 100%"
|
||||
filterable :disabled="readonly" />
|
||||
<ActualWarehouseSelect
|
||||
v-model="item.actualWarehouseId"
|
||||
placeholder="请选择真实库区"
|
||||
block
|
||||
:disabled="readonly"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
@@ -167,8 +167,12 @@
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="真实库区" prop="warehouseId">
|
||||
<ActualWarehouseSelect v-model="updateForm.actualWarehouseId" placeholder="请选择真实库区" style="width: 100%"
|
||||
filterable :disabled="readonly" />
|
||||
<ActualWarehouseSelect
|
||||
v-model="updateForm.actualWarehouseId"
|
||||
placeholder="请选择真实库区"
|
||||
block
|
||||
:disabled="readonly"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="备注" prop="remark">
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user