|
|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <AidopDemoShell :title="pageTitle" subtitle="S0 / 仓储建模 / 货架列表">
|
|
|
+ <AidopDemoShell :title="pageTitle" subtitle="S0 / 仓储建模 / 货架列表(只读)">
|
|
|
<el-form :inline="true" :model="query" class="mb12" @submit.prevent>
|
|
|
<el-form-item label="关键字">
|
|
|
<el-input v-model="query.keyword" placeholder="货架编码/库位编码" clearable style="width: 200px" />
|
|
|
@@ -10,23 +10,19 @@
|
|
|
<el-form-item>
|
|
|
<el-button type="primary" @click="loadList">查询</el-button>
|
|
|
<el-button @click="resetQuery">重置</el-button>
|
|
|
- <el-button type="success" @click="openCreate">新增货架</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
|
|
|
- <el-table :data="rows" v-loading="loading" border stripe style="width: 100%" max-height="calc(100vh - 260px)">
|
|
|
+ <el-alert type="info" :closable="false" show-icon class="mb12"
|
|
|
+ title="货架为只读展示。新增/修改/删除货架请在「库位维护」的货架明细中完成。" />
|
|
|
+
|
|
|
+ <el-table :data="rows" v-loading="loading" border stripe style="width: 100%" max-height="calc(100vh - 300px)">
|
|
|
<el-table-column prop="kwhjName" label="库位:货架" width="160" show-overflow-tooltip />
|
|
|
<el-table-column prop="location" label="所属库位" width="130" show-overflow-tooltip />
|
|
|
<el-table-column prop="locationDescr" label="库位说明" min-width="150" show-overflow-tooltip />
|
|
|
<el-table-column prop="invShelf" label="货架编码" width="130" show-overflow-tooltip />
|
|
|
<el-table-column prop="descr" label="货架说明" min-width="150" show-overflow-tooltip />
|
|
|
<el-table-column prop="area" label="区域" width="100" show-overflow-tooltip />
|
|
|
- <el-table-column label="操作" width="160" fixed="right" align="center">
|
|
|
- <template #default="{ row }">
|
|
|
- <el-button link type="primary" @click="openEdit(row)">编辑</el-button>
|
|
|
- <el-button link type="danger" @click="onDelete(row)">删除</el-button>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
</el-table>
|
|
|
|
|
|
<div class="pager">
|
|
|
@@ -34,40 +30,14 @@
|
|
|
:page-sizes="[20, 50, 100]" layout="total, sizes, prev, pager, next"
|
|
|
@current-change="loadList" @size-change="loadList" />
|
|
|
</div>
|
|
|
-
|
|
|
- <el-dialog v-model="dialogVisible" :title="dialogTitle" width="600px" destroy-on-close @closed="resetForm">
|
|
|
- <el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
|
|
|
- <el-form-item v-if="false" label="公司" prop="companyRefId">
|
|
|
- <el-select v-model="form.companyRefId" clearable filterable placeholder="请选择公司" style="width: 100%">
|
|
|
- <el-option v-for="item in companyOptions" :key="item.id" :label="item.name || item.code || `${item.id}`" :value="item.id" />
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item v-if="false" label="工厂" prop="factoryRefId">
|
|
|
- <el-select v-model="form.factoryRefId" clearable filterable placeholder="请选择工厂" style="width: 100%" :disabled="!form.companyRefId">
|
|
|
- <el-option v-for="item in formFactoryOptions" :key="item.id" :label="item.name || item.code || `${item.id}`" :value="item.id" />
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="所属库位" prop="location"><el-input v-model="form.location" /></el-form-item>
|
|
|
- <el-form-item label="货架编码" prop="invShelf"><el-input v-model="form.invShelf" :disabled="!!editingId" /></el-form-item>
|
|
|
- <el-form-item label="货架说明"><el-input v-model="form.descr" /></el-form-item>
|
|
|
- <el-form-item label="区域"><el-input v-model="form.area" /></el-form-item>
|
|
|
- <el-form-item label="域编码"><el-input v-model="form.domainCode" /></el-form-item>
|
|
|
- </el-form>
|
|
|
- <template #footer>
|
|
|
- <el-button @click="dialogVisible = false">取消</el-button>
|
|
|
- <el-button type="primary" :loading="saving" @click="submitForm">保存</el-button>
|
|
|
- </template>
|
|
|
- </el-dialog>
|
|
|
</AidopDemoShell>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts" name="aidopS0WhLocationShelf">
|
|
|
-import { computed, onMounted, reactive, ref, watch } from 'vue';
|
|
|
+import { computed, onMounted, reactive, ref } from 'vue';
|
|
|
import { useRoute } from 'vue-router';
|
|
|
-import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus';
|
|
|
import AidopDemoShell from '../../components/AidopDemoShell.vue';
|
|
|
-import { s0LocationShelvesApi, type S0LocationShelfRow, type S0LocationShelfUpsert } from '../api/s0WarehouseApi';
|
|
|
-import { loadOrgList, type OrgOption } from '../api/s0SalesApi';
|
|
|
+import { s0LocationShelvesApi, type S0LocationShelfRow } from '../api/s0WarehouseApi';
|
|
|
|
|
|
const route = useRoute();
|
|
|
const pageTitle = computed(() => (route.meta?.title as string) || '货架列表');
|
|
|
@@ -75,43 +45,7 @@ const query = reactive({ keyword: '', domainCode: '', location: '', page: 1, pag
|
|
|
const loading = ref(false);
|
|
|
const rows = ref<S0LocationShelfRow[]>([]);
|
|
|
const total = ref(0);
|
|
|
-const dialogVisible = ref(false);
|
|
|
-const dialogTitle = ref('');
|
|
|
-const editingId = ref<number | null>(null);
|
|
|
-const saving = ref(false);
|
|
|
-const formRef = ref<FormInstance>();
|
|
|
-const form = reactive<S0LocationShelfUpsert>({ companyRefId: undefined, factoryRefId: undefined, domainCode: '', location: '', invShelf: '', descr: '', area: '' });
|
|
|
-
|
|
|
-// 单甲方私有云口径:公司/工厂不在前端启用,统一注入全局默认组织(不依赖登录账号 tenant_id)
|
|
|
-const DEFAULT_COMPANY_REF_ID = '1329900200001';
|
|
|
-const DEFAULT_FACTORY_REF_ID = '1329900200002';
|
|
|
-function isMissingOrLegacyOrgRef(v: unknown): boolean {
|
|
|
- return v == null || v === '' || v === 0 || v === '0' || v === 1 || v === '1';
|
|
|
-}
|
|
|
-function applyDefaultOrg() {
|
|
|
- if (isMissingOrLegacyOrgRef(form.companyRefId)) form.companyRefId = DEFAULT_COMPANY_REF_ID;
|
|
|
- if (isMissingOrLegacyOrgRef(form.factoryRefId)) form.factoryRefId = DEFAULT_FACTORY_REF_ID;
|
|
|
-}
|
|
|
-const companyOptions = ref<OrgOption[]>([]);
|
|
|
-const factoryOptions = ref<OrgOption[]>([]);
|
|
|
-const formFactoryOptions = computed(() => {
|
|
|
- if (!form.companyRefId) return factoryOptions.value;
|
|
|
- return factoryOptions.value.filter((item) => item.pid === form.companyRefId);
|
|
|
-});
|
|
|
-
|
|
|
-const rules: FormRules = {
|
|
|
- location: [{ required: true, message: '请填写所属库位', trigger: 'blur' }],
|
|
|
- invShelf: [{ required: true, message: '请填写货架编码', trigger: 'blur' }],
|
|
|
-};
|
|
|
|
|
|
-watch(
|
|
|
- () => form.companyRefId,
|
|
|
- () => {
|
|
|
- if (!formFactoryOptions.value.some((item) => item.id === form.factoryRefId)) {
|
|
|
- form.factoryRefId = undefined;
|
|
|
- }
|
|
|
- },
|
|
|
-);
|
|
|
async function loadList() {
|
|
|
loading.value = true;
|
|
|
try {
|
|
|
@@ -120,34 +54,8 @@ async function loadList() {
|
|
|
} catch { rows.value = []; total.value = 0; } finally { loading.value = false; }
|
|
|
}
|
|
|
function resetQuery() { Object.assign(query, { keyword: '', domainCode: '', location: '', page: 1 }); void loadList(); }
|
|
|
-function resetForm() { editingId.value = null; Object.assign(form, { companyRefId: undefined, factoryRefId: undefined, domainCode: '', location: '', invShelf: '', descr: '', area: '' }); formRef.value?.clearValidate(); }
|
|
|
-function openCreate() { resetForm(); dialogTitle.value = '新增货架'; dialogVisible.value = true; }
|
|
|
-function openEdit(row: S0LocationShelfRow) {
|
|
|
- resetForm(); editingId.value = row.id; dialogTitle.value = `编辑货架 ${row.kwhjName || row.invShelf}`;
|
|
|
- Object.assign(form, { companyRefId: row.companyRefId, factoryRefId: row.factoryRefId, domainCode: row.domainCode ?? '', location: row.location, invShelf: row.invShelf, descr: row.descr ?? '', area: row.area ?? '' });
|
|
|
- dialogVisible.value = true;
|
|
|
-}
|
|
|
-async function submitForm() {
|
|
|
- await formRef.value?.validate();
|
|
|
- applyDefaultOrg();
|
|
|
- saving.value = true;
|
|
|
- try {
|
|
|
- if (editingId.value) { await s0LocationShelvesApi.update(editingId.value, { ...form }); ElMessage.success('已保存'); }
|
|
|
- else { await s0LocationShelvesApi.create({ ...form }); ElMessage.success('已创建'); }
|
|
|
- dialogVisible.value = false; await loadList();
|
|
|
- } finally { saving.value = false; }
|
|
|
-}
|
|
|
-function onDelete(row: S0LocationShelfRow) {
|
|
|
- ElMessageBox.confirm(`确定删除货架「${row.kwhjName || row.invShelf}」?`, '确认', { type: 'warning' })
|
|
|
- .then(async () => { await s0LocationShelvesApi.delete(row.id); ElMessage.success('已删除'); await loadList(); }).catch(() => {});
|
|
|
-}
|
|
|
-async function loadOrgOptions() {
|
|
|
- const [companies, factories] = await Promise.all([loadOrgList('201'), loadOrgList('501')]);
|
|
|
- companyOptions.value = companies.filter((item) => item.id && item.id !== '0');
|
|
|
- factoryOptions.value = factories.filter((item) => item.id && item.id !== '0');
|
|
|
-}
|
|
|
|
|
|
-onMounted(() => { void loadList(); void loadOrgOptions(); });
|
|
|
+onMounted(() => { void loadList(); });
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|