mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-11-07 17:38:55 +08:00
- buyer(95) / seller(169) / im(53) / manager(280) 共 597 个组件全部从 Options API 转换为 <script setup> - 四端 vuex 全部移除,状态管理统一迁移至 pinia 4(stores/ 目录) - util.js 等基础设施去除 vm 首参依赖;全局属性($Message/$filters 等)在 script 内改为具名导入 - 被外部 ref 访问的公共组件均已补齐 defineExpose(清单见各端 MIGRATION-VUE3.md) - 各端 eslint 启用 vue/component-api-style 防止新代码回退 Options API - 四端 yarn build 全部通过;迁移约定与注意事项已更新至各端 MIGRATION-VUE3.md
173 lines
5.3 KiB
Vue
173 lines
5.3 KiB
Vue
<template>
|
|
<div class="search">
|
|
<el-card>
|
|
<el-form :model="searchForm" inline label-width="80px">
|
|
<el-form-item label="原因">
|
|
<el-input v-model="searchForm.reason" clearable style="width: 200px" />
|
|
</el-form-item>
|
|
<el-form-item label="类别">
|
|
<el-select v-model="searchForm.category" clearable style="width: 160px">
|
|
<el-option label="入库" value="INBOUND" />
|
|
<el-option label="出库" value="OUTBOUND" />
|
|
<el-option label="报损" value="DAMAGE" />
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item>
|
|
<el-button type="primary" @click="handleSearch">搜索</el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
<div class="operation padding-row">
|
|
<el-button type="primary" @click="openAdd">添加</el-button>
|
|
</div>
|
|
<el-table v-loading="loading" :data="data" border class="mt_10" style="width: 100%">
|
|
<el-table-column prop="reason" label="原因" width="240" show-overflow-tooltip />
|
|
<el-table-column label="类别" width="120" align="center">
|
|
<template #default="{ row }">{{ stockReasonCategoryText(row.category) }}</template>
|
|
</el-table-column>
|
|
<el-table-column prop="createTime" label="创建时间" width="170" />
|
|
<el-table-column label="操作" width="150" align="center" fixed="right">
|
|
<template #default="{ row }">
|
|
<a class="link-text" @click="openEdit(row)">编辑</a>
|
|
<span class="op-split">|</span>
|
|
<a class="link-text" @click="handleDelete(row)">删除</a>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
<div class="mt_10" style="display: flex; justify-content: flex-end">
|
|
<el-pagination
|
|
v-model:current-page="searchForm.pageNumber"
|
|
v-model:page-size="searchForm.pageSize"
|
|
:total="total"
|
|
layout="total, prev, pager, next"
|
|
size="small"
|
|
@current-change="getDataList"
|
|
@size-change="getDataList"
|
|
/>
|
|
</div>
|
|
</el-card>
|
|
|
|
<el-dialog v-model="modalVisible" :title="modalTitle" width="480px" append-to-body>
|
|
<el-form ref="formRef" :model="form" label-width="80px">
|
|
<el-form-item label="原因" required>
|
|
<el-input v-model="form.reason" placeholder="出入库原因" />
|
|
</el-form-item>
|
|
<el-form-item label="类别" required>
|
|
<el-select v-model="form.category" style="width: 100%">
|
|
<el-option label="入库" value="INBOUND" />
|
|
<el-option label="出库" value="OUTBOUND" />
|
|
<el-option label="报损" value="DAMAGE" />
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-form>
|
|
<template #footer>
|
|
<el-button @click="modalVisible = false">取消</el-button>
|
|
<el-button type="primary" :loading="submitLoading" @click="handleSubmit">确定</el-button>
|
|
</template>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref, reactive, onMounted } from "vue";
|
|
import {
|
|
getStockReasonPage,
|
|
addStockReason,
|
|
updateStockReason,
|
|
deleteStockReason,
|
|
} from "@/api/procurement";
|
|
import { stockReasonCategoryText } from "../constants";
|
|
import { Message, Modal } from "@/utils/message";
|
|
|
|
defineOptions({ name: "manager-stock-reason-manage" });
|
|
|
|
const loading = ref(false);
|
|
const submitLoading = ref(false);
|
|
const modalVisible = ref(false);
|
|
const modalTitle = ref("添加原因");
|
|
const data = ref([]);
|
|
const total = ref(0);
|
|
const searchForm = reactive({ pageNumber: 1, pageSize: 10, reason: "", category: "" });
|
|
const form = ref({ id: "", reason: "", category: "INBOUND" });
|
|
|
|
const formRef = ref(null);
|
|
|
|
function handleSearch() {
|
|
searchForm.pageNumber = 1;
|
|
getDataList();
|
|
}
|
|
|
|
function getDataList() {
|
|
loading.value = true;
|
|
getStockReasonPage(searchForm)
|
|
.then((res) => {
|
|
if (res.success) {
|
|
data.value = res.result.records || [];
|
|
total.value = res.result.total || 0;
|
|
}
|
|
})
|
|
.finally(() => {
|
|
loading.value = false;
|
|
});
|
|
}
|
|
|
|
function openAdd() {
|
|
modalTitle.value = "添加原因";
|
|
form.value = { id: "", reason: "", category: "INBOUND" };
|
|
modalVisible.value = true;
|
|
}
|
|
|
|
function openEdit(row) {
|
|
modalTitle.value = "编辑原因";
|
|
form.value = { id: row.id, reason: row.reason, category: row.category };
|
|
modalVisible.value = true;
|
|
}
|
|
|
|
function handleSubmit() {
|
|
if (!form.value.reason || !form.value.category) {
|
|
Message.warning("请填写完整信息");
|
|
return;
|
|
}
|
|
submitLoading.value = true;
|
|
const req = form.value.id
|
|
? updateStockReason(form.value)
|
|
: addStockReason({ reason: form.value.reason, category: form.value.category });
|
|
req
|
|
.then((res) => {
|
|
if (res.success) {
|
|
Message.success("保存成功");
|
|
modalVisible.value = false;
|
|
getDataList();
|
|
}
|
|
})
|
|
.finally(() => {
|
|
submitLoading.value = false;
|
|
});
|
|
}
|
|
|
|
function handleDelete(row) {
|
|
Modal.confirm({
|
|
title: "删除确认",
|
|
content: `确认删除原因「${row.reason}」?`,
|
|
onOk: () => {
|
|
deleteStockReason(row.id).then((res) => {
|
|
if (res.success) {
|
|
Message.success("删除成功");
|
|
getDataList();
|
|
}
|
|
});
|
|
},
|
|
});
|
|
}
|
|
|
|
onMounted(() => {
|
|
getDataList();
|
|
});
|
|
</script>
|
|
|
|
<style scoped>
|
|
.op-split {
|
|
margin: 0 6px;
|
|
color: #dcdfe6;
|
|
}
|
|
</style>
|