完成仓库模块

This commit is contained in:
Zy
2026-04-23 17:59:36 +08:00
parent 985860c9de
commit 9d4416b238
39 changed files with 5040 additions and 80 deletions

View File

@@ -8,6 +8,7 @@
import { useSettingsStore } from '@/store/modules/settings';
import { handleThemeStyle } from '@/utils/theme';
import { useAppStore } from '@/store/modules/app';
import { useDictStore } from './store/modules/dict';
const appStore = useAppStore();
onMounted(() => {

View File

@@ -0,0 +1,63 @@
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ChargeItemVO, ChargeItemForm, ChargeItemQuery } from './type';
/**
* 查询收费项目管理列表
* @param query
* @returns {*}
*/
export const listChargeItem = (query?: ChargeItemQuery): AxiosPromise<ChargeItemVO[]> => {
return request({
url: '/chargeItem/list',
method: 'get',
params: query
});
};
/**
* 查询收费项目管理详细
* @param id
*/
export const getChargeItem = (id: string | number): AxiosPromise<ChargeItemVO> => {
return request({
url: '/chargeItem/' + id,
method: 'get'
});
};
/**
* 新增收费项目管理
* @param data
*/
export const addChargeItem = (data: ChargeItemForm) => {
return request({
url: '/chargeItem',
method: 'post',
data: data
});
};
/**
* 修改收费项目管理
* @param data
*/
export const updateChargeItem = (data: ChargeItemForm) => {
return request({
url: '/chargeItem',
method: 'put',
data: data
});
};
/**
* 删除收费项目管理
* @param id
*/
export const delChargeItem = (id: string | number | Array<string | number>) => {
return request({
url: '/chargeItem/' + id,
method: 'delete'
});
};

View File

@@ -0,0 +1,150 @@
export interface ChargeItemVO {
/**
* 收费项目管理表id
*/
id: string | number;
/**
* 项目名称
*/
name: string;
/**
* 计费方式 0单次收费 1周期收费 2仪表收费
*/
billingMethod: string;
/**
* 单价
*/
price: number;
/**
* 单位 0㎡ 1度 3m³ 4升
*/
unit: string;
/**
* 精度 0保留两位小数 1保留一位小数 2保留整数
*/
precision: string;
/**
* 进位方式 0四舍五入 1向上进位 2向下进位
*/
carryMethod: string;
/**
* 滞纳金比例 %
*/
lateFee: number;
/**
* 备注
*/
remark: string;
/**
* 小区id
*/
villageId: string | number;
}
export interface ChargeItemForm extends BaseEntity {
/**
* 收费项目管理表id
*/
id?: string | number;
/**
* 项目名称
*/
name?: string;
/**
* 计费方式 0单次收费 1周期收费 2仪表收费
*/
billingMethod?: string;
/**
* 单价
*/
price?: number;
/**
* 单位 0㎡ 1度 3m³ 4升
*/
unit?: string;
/**
* 精度 0保留两位小数 1保留一位小数 2保留整数
*/
precision?: string;
/**
* 进位方式 0四舍五入 1向上进位 2向下进位
*/
carryMethod?: string;
/**
* 滞纳金比例 %
*/
lateFee?: number;
/**
* 备注
*/
remark?: string;
/**
* 小区id
*/
villageId?: string | number;
}
export interface ChargeItemQuery extends PageQuery {
/**
* 项目名称
*/
name?: string;
/**
* 计费方式 0单次收费 1周期收费 2仪表收费
*/
billingMethod?: string;
/**
* 单价
*/
price?: number;
/**
* 单位 0㎡ 1度 3m³ 4升
*/
unit?: string;
/**
* 精度 0保留两位小数 1保留一位小数 2保留整数
*/
precision?: string;
/**
* 进位方式 0四舍五入 1向上进位 2向下进位
*/
carryMethod?: string;
/**
* 滞纳金比例 %
*/
lateFee?: number;
/**
* 小区id
*/
villageId?: string | number;
/**
* 日期范围参数
*/
params?: any;
}

View File

@@ -0,0 +1,63 @@
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { StockInVO, StockInForm, StockInQuery } from './type';
/**
* 查询入库主列表
* @param query
* @returns {*}
*/
export const listStockIn = (query?: StockInQuery): AxiosPromise<StockInVO[]> => {
return request({
url: '/stockIn/list',
method: 'get',
params: query
});
};
/**
* 查询入库主详细
* @param id
*/
export const getStockIn = (id: string | number): AxiosPromise<StockInVO> => {
return request({
url: '/stockIn/' + id,
method: 'get'
});
};
/**
* 新增入库主
* @param data
*/
export const addStockIn = (data: StockInForm) => {
return request({
url: '/stockIn',
method: 'post',
data: data
});
};
/**
* 修改入库主
* @param data
*/
export const updateStockIn = (data: StockInForm) => {
return request({
url: '/stockIn',
method: 'put',
data: data
});
};
/**
* 删除入库主
* @param id
*/
export const delStockIn = (id: string | number | Array<string | number>) => {
return request({
url: '/stockIn/' + id,
method: 'delete'
});
};

View File

@@ -0,0 +1,128 @@
import { MaterialVO } from '../Tmaterial/type';
export interface StockInVO {
/**
* 主键
*/
id: string | number;
/**
* 入库单号*
*/
inNo: string;
/**
* 入库日期*
*/
inDate: string;
totalAmount: string;
/**
* 供应商id*
*/
supplierId: string;
/**
* 入库仓库id*
*/
warehouseId: string;
/**
* 操作状态 入库/未入库
*/
operateStatus: string;
/**
* 负责人
*/
leader: string;
/**
* 备注
*/
remark: string;
items: MaterialVO[];
warehouseName: string;
supplierName: string;
createTime: string;
}
export interface StockInForm extends BaseEntity {
/**
* 主键
*/
id?: string | number;
/**
* 入库单号*
*/
inNo?: string;
/**
* 入库日期*
*/
inDate?: string;
/**
* 供应商id*
*/
supplierId?: string;
/**
* 入库仓库id*
*/
warehouseId?: string;
/**
* 操作状态 入库/未入库
*/
operateStatus?: string;
/**
* 负责人
*/
leader?: string;
/**
* 备注
*/
remark?: string;
}
export interface StockInQuery extends PageQuery {
/**
* 入库单号*
*/
inNo?: string;
/**
* 入库日期*
*/
inDate?: string;
/**
* 供应商id*
*/
supplierId?: string;
/**
* 入库仓库id*
*/
warehouseId?: string;
/**
* 操作状态 入库/未入库
*/
operateStatus?: string;
/**
* 负责人
*/
leader?: string;
/**
* 日期范围参数
*/
params?: any;
}

View File

@@ -0,0 +1,63 @@
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { StockOutVO, StockOutForm, StockOutQuery } from './type';
/**
* 查询出库主列表
* @param query
* @returns {*}
*/
export const listStockOut = (query?: StockOutQuery): AxiosPromise<StockOutVO[]> => {
return request({
url: '/stockOut/list',
method: 'get',
params: query
});
};
/**
* 查询出库主详细
* @param id
*/
export const getStockOut = (id: string | number): AxiosPromise<StockOutVO> => {
return request({
url: '/stockOut/' + id,
method: 'get'
});
};
/**
* 新增出库主
* @param data
*/
export const addStockOut = (data: StockOutForm) => {
return request({
url: '/stockOut',
method: 'post',
data: data
});
};
/**
* 修改出库主
* @param data
*/
export const updateStockOut = (data: StockOutForm) => {
return request({
url: '/stockOut',
method: 'put',
data: data
});
};
/**
* 删除出库主
* @param id
*/
export const delStockOut = (id: string | number | Array<string | number>) => {
return request({
url: '/stockOut/' + id,
method: 'delete'
});
};

View File

@@ -0,0 +1,127 @@
import { MaterialVO } from '../Tmaterial/type';
export interface StockOutVO {
/**
* 主键
*/
id: string;
/**
* 出库单号*
*/
outNo: string;
/**
* 出库日期*
*/
outDate: string;
totalAmount: string;
/**
* 领用人(供应商id)*
*/
supplierId: string;
/**
* 出库仓库id*
*/
warehouseId: string;
/**
* 操作状态 未出库/出库
*/
operateStatus: string;
/**
* 负责人
*/
leader: string;
/**
* 备注
*/
remark: string;
items: MaterialVO[];
warehouseName: string;
supplierName: string;
createTime: string;
}
export interface StockOutForm extends BaseEntity {
/**
* 主键
*/
id?: string;
/**
* 出库单号*
*/
outNo?: string;
/**
* 出库日期*
*/
outDate?: string;
/**
* 领用人(供应商id)*
*/
supplierId?: string;
/**
* 出库仓库id*
*/
warehouseId?: string;
/**
* 操作状态 未出库/出库
*/
operateStatus?: string;
/**
* 负责人
*/
leader?: string;
/**
* 备注
*/
remark?: string;
}
export interface StockOutQuery extends PageQuery {
/**
* 出库单号*
*/
outNo?: string;
/**
* 出库日期*
*/
outDate?: string;
/**
* 领用人(供应商id)*
*/
supplierId?: string;
/**
* 出库仓库id*
*/
warehouseId?: string;
/**
* 操作状态 未出库/出库
*/
operateStatus?: string;
/**
* 负责人
*/
leader?: string;
/**
* 日期范围参数
*/
params?: any;
}

View File

@@ -0,0 +1,63 @@
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MaterialVO, MaterialForm, MaterialQuery } from './type';
/**
* 查询物料列表
* @param query
* @returns {*}
*/
export const listMaterial = (query?: MaterialQuery): AxiosPromise<MaterialVO[]> => {
return request({
url: '/warehouse/material/list',
method: 'get',
params: query
});
};
/**
* 查询物料详细
* @param id
*/
export const getMaterial = (id: string | number): AxiosPromise<MaterialVO> => {
return request({
url: '/warehouse/material/' + id,
method: 'get'
});
};
/**
* 新增物料
* @param data
*/
export const addMaterial = (data: MaterialForm) => {
return request({
url: '/warehouse/material',
method: 'post',
data: data
});
};
/**
* 修改物料
* @param data
*/
export const updateMaterial = (data: MaterialForm) => {
return request({
url: '/warehouse/material',
method: 'put',
data: data
});
};
/**
* 删除物料
* @param id
*/
export const delMaterial = (id: string | number | Array<string | number>) => {
return request({
url: '/warehouse/material/' + id,
method: 'delete'
});
};

View File

@@ -0,0 +1,90 @@
export interface MaterialVO {
/**
* 物料ID
*/
id: string;
/**
* 物料名称*
*/
materialName: string;
/**
* 品牌*
*/
brand: string;
/**
* 规格型号*
*/
model: string;
/**
* 计量单位
*/
unit: string;
/**
* 备注
*/
remark: string;
}
export interface MaterialForm extends BaseEntity {
/**
* 物料ID
*/
id?: string;
/**
* 物料名称*
*/
materialName?: string;
/**
* 品牌*
*/
brand?: string;
/**
* 规格型号*
*/
model?: string;
/**
* 计量单位
*/
unit?: string;
/**
* 备注
*/
remark?: string;
}
export interface MaterialQuery extends PageQuery {
/**
* 物料名称*
*/
materialName?: string;
/**
* 品牌*
*/
brand?: string;
/**
* 规格型号*
*/
model?: string;
/**
* 计量单位
*/
unit?: string;
/**
* 日期范围参数
*/
params?: any;
}

View File

@@ -0,0 +1,16 @@
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
/**
* 查询 库存查询列表
* @param query
* @returns {*}
*/
export const listStock = (query?: any): AxiosPromise<any[]> => {
return request({
url: '/stock/list',
method: 'get',
params: query
});
};

View File

@@ -0,0 +1,63 @@
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SupplierVO, SupplierForm, SupplierQuery } from './type';
/**
* 查询供应商列表
* @param query
* @returns {*}
*/
export const listSupplier = (query?: SupplierQuery): AxiosPromise<SupplierVO[]> => {
return request({
url: '/warehouse/supplier/list',
method: 'get',
params: query
});
};
/**
* 查询供应商详细
* @param id
*/
export const getSupplier = (id: string | number): AxiosPromise<SupplierVO> => {
return request({
url: '/warehouse/supplier/' + id,
method: 'get'
});
};
/**
* 新增供应商
* @param data
*/
export const addSupplier = (data: SupplierForm) => {
return request({
url: '/warehouse/supplier',
method: 'post',
data: data
});
};
/**
* 修改供应商
* @param data
*/
export const updateSupplier = (data: SupplierForm) => {
return request({
url: '/warehouse/supplier',
method: 'put',
data: data
});
};
/**
* 删除供应商
* @param id
*/
export const delSupplier = (id: string | number | Array<string | number>) => {
return request({
url: '/warehouse/supplier/' + id,
method: 'delete'
});
};

View File

@@ -0,0 +1,105 @@
export interface SupplierVO {
/**
* 主键ID
*/
id: string | number;
/**
* 供应商名称*
*/
supplierName: string;
/**
* 联系人*
*/
contactPerson: string;
/**
* 联系电话*
*/
contactPhone: string;
/**
* 邮箱
*/
email: string;
/**
* 地址
*/
address: string;
/**
* 备注
*/
remark: string;
}
export interface SupplierForm extends BaseEntity {
/**
* 主键ID
*/
id?: string | number;
/**
* 供应商名称*
*/
supplierName?: string;
/**
* 联系人*
*/
contactPerson?: string;
/**
* 联系电话*
*/
contactPhone?: string;
/**
* 邮箱
*/
email?: string;
/**
* 地址
*/
address?: string;
/**
* 备注
*/
remark?: string;
}
export interface SupplierQuery extends PageQuery {
/**
* 供应商名称*
*/
supplierName?: string;
/**
* 联系人*
*/
contactPerson?: string;
/**
* 联系电话*
*/
contactPhone?: string;
/**
* 邮箱
*/
email?: string;
/**
* 地址
*/
address?: string;
/**
* 日期范围参数
*/
params?: any;
}

View File

@@ -0,0 +1,63 @@
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { WarehouseVO, WarehouseForm, WarehouseQuery } from './type';
/**
* 查询仓库列表
* @param query
* @returns {*}
*/
export const listWarehouse = (query?: WarehouseQuery): AxiosPromise<WarehouseVO[]> => {
return request({
url: '/warehouse/list',
method: 'get',
params: query
});
};
/**
* 查询仓库详细
* @param id
*/
export const getWarehouse = (id: string | number): AxiosPromise<WarehouseVO> => {
return request({
url: '/warehouse/' + id,
method: 'get'
});
};
/**
* 新增仓库
* @param data
*/
export const addWarehouse = (data: WarehouseForm) => {
return request({
url: '/warehouse',
method: 'post',
data: data
});
};
/**
* 修改仓库
* @param data
*/
export const updateWarehouse = (data: WarehouseForm) => {
return request({
url: '/warehouse',
method: 'put',
data: data
});
};
/**
* 删除仓库
* @param id
*/
export const delWarehouse = (id: string | number | Array<string | number>) => {
return request({
url: '/warehouse/' + id,
method: 'delete'
});
};

View File

@@ -0,0 +1,120 @@
export interface WarehouseVO {
/**
* 仓库ID
*/
id: string | number;
/**
* 仓库名称*
*/
warehouseName: string;
/**
* 仓库归属id*关联com_village
*/
villageId: number;
/**
* 联系人*
*/
contactPerson: string;
/**
* 联系电话*
*/
contactPhone: string;
/**
* 地址
*/
address: string;
/**
* 状态 0-启用 1-禁用
*/
status: string;
/**
* 备注
*/
remark: string;
}
export interface WarehouseForm extends BaseEntity {
/**
* 仓库ID
*/
id?: string | number;
/**
* 仓库名称*
*/
warehouseName?: string;
/**
* 仓库归属id*关联com_village
*/
villageId?: number;
/**
* 联系人*
*/
contactPerson?: string;
/**
* 联系电话*
*/
contactPhone?: string;
/**
* 地址
*/
address?: string;
/**
* 状态 0-启用 1-禁用
*/
status?: string;
/**
* 备注
*/
remark?: string;
}
export interface WarehouseQuery extends PageQuery {
/**
* 仓库名称*
*/
warehouseName?: string;
/**
* 仓库归属id*关联com_village
*/
villageId?: number;
/**
* 联系人*
*/
contactPerson?: string;
/**
* 联系电话*
*/
contactPhone?: string;
/**
* 地址
*/
address?: string;
/**
* 状态 0-启用 1-禁用
*/
status?: string;
/**
* 日期范围参数
*/
params?: any;
}

View File

@@ -0,0 +1,272 @@
<template>
<slot name="default" />
<el-dialog append-to-body v-model="dialog.dialogVisible" :title="dialog.dialogTitle" width="1050">
<nav class="flex flex-items-center mb-8">
<div class="flex flex-items-center">
<div style="width: 70px; text-align: right; padding-right: 10px">物料名称</div>
<div class="mr-5 flex-1">
<el-input style="width: 170px" clearable v-model="queryParams.materialName" placeholder="请输入物料名称" />
</div>
</div>
<div class="flex flex-items-center">
<div style="width: 70px; text-align: right; padding-right: 10px">品牌</div>
<div class="mr-5 flex-1">
<el-input style="width: 170px" clearable v-model="queryParams.brand" placeholder="请输入品牌" />
</div>
</div>
<div>
<el-button type="primary" @click="getlist">查询</el-button>
<el-button @click="resetQuery">重置</el-button>
</div>
</nav>
<el-table
@select-all="handleSelectionChange"
@row-click="handleRowClick"
ref="multipleTableRef"
:data="tableData"
border
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="物料名称" align="center" prop="materialName" />
<el-table-column label="品牌" align="center" prop="brand" />
<el-table-column label="规格型号" align="center" prop="model" />
<el-table-column label="单位" align="center" prop="unit" />
<el-table-column label="备注" align="center" prop="remark" />
</el-table>
<template #footer>
<div class="dialog-footer flex flex-items-center flex-justify-between">
<pagination
style="margin-top: 0"
layout="total, prev, pager, next, jumper"
v-show="total > 0"
:total="total"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
@pagination="getlist"
/>
<div>
<el-button @click="conback">退出</el-button>
<el-button type="primary" @click="confirm"> 确定 </el-button>
</div>
</div>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { listMaterial } from '@/api/system/Tmaterial';
import { MaterialVO } from '@/api/system/Tmaterial/type';
import { ref, watch, nextTick, getCurrentInstance, ComponentInternalInstance, toRefs } from 'vue';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const props = defineProps({
userid: {
type: String,
default: ''
},
returnvalue: {
type: String,
default: 'id'
},
titleName: {
type: String,
default: '选择物料'
},
isMultiple: {
type: Boolean,
default: false
}
});
const { userid, titleName, returnvalue } = toRefs(props);
// ✅ 手动设置默认值(替代 withDefaults
const emit = defineEmits<{
change: [value: string | number | (string | number)[] | MaterialVO | MaterialVO[]]; // 支持返回数组
}>();
const dialog = ref({
dialogVisible: false,
dialogTitle: titleName.value
});
const queryParams = ref({
pageNum: 1,
pageSize: 10,
brand: '',
materialName: ''
});
const multipleTableRef = ref();
const tableData = ref<MaterialVO[]>([]);
const total = ref(0);
const loading = ref(false);
// 存储选中项
const multipleSelection = ref<MaterialVO[]>([]);
// 多选
const isMultiple = computed(() => props.isMultiple ?? false);
// 优化 handleUserSelection避免重复查找
const handleUserSelection = () => {
if (!userid.value || !tableData.value.length) return;
multipleSelection.value = [];
if (userid.value.trim() !== '') {
const arr = userid.value.split(',');
arr.forEach((item) => {
const target = tableData.value.find((row) => row.id == item);
target && multipleSelection.value.push(target);
});
nextTick(() => {
if (multipleTableRef.value) {
multipleTableRef.value.clearSelection();
multipleSelection.value.forEach((item) => {
multipleTableRef.value.toggleRowSelection(item, true);
});
}
});
}
};
// 监听
// 监听优化:只在 userid 变化时触发
// watch(userid, handleUserSelection, { immediate: true });
// watch(tableData, () => {
// if (userid.value) handleUserSelection(); // 仅在有 userid 时重新处理
// });
// ====================== 方法 ======================
// 获取列表
function getlist() {
loading.value = true;
listMaterial(queryParams.value)
.then((res) => {
tableData.value = res.rows;
total.value = res.total;
})
.catch((error) => {
console.error('获取用户列表失败:', error);
})
.finally(() => {
loading.value = false;
});
}
// ==============================================
// ✅ 新增:处理 selection-change多选专用
// ==============================================
function handleSelectionChange(selection: MaterialVO[]) {
console.log(selection);
if (isMultiple.value) {
multipleSelection.value = selection;
}
}
// ==============================================
// 最佳单选方案:点击行选中,无报错、无循环、最稳定
// ==============================================
// 优化 handleRowClick避免重复
function handleRowClick(row: MaterialVO) {
if (!multipleTableRef.value) return;
if (isMultiple.value) {
const index = multipleSelection.value.findIndex((item) => item.id === row.id);
if (index > -1) {
// 取消选中
multipleSelection.value.splice(index, 1);
multipleTableRef.value?.toggleRowSelection(row, false);
} else {
// 选中
multipleSelection.value.push(row);
multipleTableRef.value?.toggleRowSelection(row, true);
}
} else {
// 【单选模式】先清空,再选中当前行
multipleSelection.value = [];
multipleTableRef.value.clearSelection();
multipleSelection.value = [row];
multipleTableRef.value.toggleRowSelection(row, true);
}
}
// 重置查询
function resetQuery() {
queryParams.value = {
pageNum: 1,
pageSize: 10,
brand: '',
materialName: ''
};
getlist();
}
// 退出
function conback() {
dialog.value.dialogVisible = false;
resetQuery();
}
// ==============================================
// ✅ 核心修改:根据 returnvalue 返回对应的值
// ==============================================
function confirm() {
dialog.value.dialogVisible = false;
if (isMultiple.value) {
// 多选
if (returnvalue.value === '*') {
// ✅ 返回整个对象数组
emit('change', multipleSelection.value);
} else {
// 返回指定字段数组
emit(
'change',
multipleSelection.value.map((item) => item[returnvalue.value as keyof MaterialVO])
);
}
} else {
// 单选
if (returnvalue.value === '*') {
// ✅ 返回整个对象
emit('change', multipleSelection.value[0]);
} else {
console.log(multipleSelection.value[0], returnvalue.value);
// 返回指定字段
emit('change', multipleSelection.value[0][returnvalue.value as keyof MaterialVO]);
}
}
multipleSelection.value = [];
multipleTableRef.value.clearSelection();
}
// 初始化
getlist();
defineExpose({
open: () => {
dialog.value.dialogVisible = true;
handleUserSelection();
}
});
</script>
<style scoped lang="scss">
.residentBox {
width: 385px;
height: 35px;
line-height: 35px;
border: 1px solid #ccc;
border-radius: 5px;
padding: 0 10px;
.defaultbox {
display: flex;
align-items: center;
justify-content: space-between;
}
cursor: pointer;
&:hover {
background-color: #f4f8ff;
}
}
</style>

View File

@@ -7,6 +7,7 @@ import { defineStore } from 'pinia';
import { ref } from 'vue';
import { useHouseStore } from './house';
import { UserInfo } from '@/api/system/user/types';
import { useDictStore } from './dict';
export const useUserStore = defineStore('user', () => {
const token = ref(getToken());
@@ -63,6 +64,7 @@ export const useUserStore = defineStore('user', () => {
// 注销
const logout = async (): Promise<void> => {
useDictStore().cleanDict();
await logoutApi();
token.value = '';
roles.value = [];

10
src/utils/map.ts Normal file
View File

@@ -0,0 +1,10 @@
/**
* 合并两个对象数组并去重(基于 id后面的覆盖前面的
*/
export function mergeObjectsAndDedupe<T extends { id?: string }>(arr1: T[], arr2: T[]): T[] {
const map = new Map(arr1.map((item) => [item.id, item]));
arr2.forEach((item) => {
if (item.id) map.set(item.id, item);
});
return [...map.values()];
}

82
src/utils/money.ts Normal file
View File

@@ -0,0 +1,82 @@
/**
* 数字金额转中文大写(支持整数、小数)
* @param num - 待转换的金额(支持数字或字符串格式)
* @returns 中文大写金额字符串
*/
export function convertToChineseCapital(num: number | string): string {
// 中文数字映射
const digits: readonly string[] = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
// 基本单位(个、拾、佰、仟)
const units: readonly string[] = ['', '拾', '佰', '仟'];
// 大单位(万、亿、万亿)
const bigUnits: readonly string[] = ['', '万', '亿', '万亿'];
// 1. 标准化输入保留4位小数分割整数与小数部分
const [intPartRaw, decPartRaw] = Number(num).toFixed(4).split('.');
// 去除整数前导零,若全零则保留一个 '0'
const intPart: string = intPartRaw.replace(/^0+/, '') || '0';
let result: string = '';
// 2. 处理整数部分
if (intPart === '0') {
result = '零元';
} else {
// 从右向左每4位分为一组处理万、亿等大单位
const groups: string[] = [];
let tempInt: string = intPart;
while (tempInt.length > 0) {
groups.unshift(tempInt.slice(-4));
tempInt = tempInt.slice(0, -4);
}
// 遍历每一组进行转换
groups.forEach((group: string, gIndex: number) => {
let groupStr: string = '';
let needZero: boolean = false; // 标记是否需要补零
for (let i = 0; i < group.length; i++) {
const digit: number = parseInt(group[i], 10);
const unitPos: number = group.length - 1 - i; // 当前数字对应的单位位置
if (digit === 0) {
needZero = true;
} else {
// 补零如果前面有0
if (needZero) {
groupStr += '零';
needZero = false;
}
groupStr += digits[digit] + units[unitPos];
}
}
// 拼接大单位(万、亿)
if (groupStr) {
result += groupStr + bigUnits[groups.length - 1 - gIndex];
}
});
result += '元';
}
// 3. 处理小数部分(仅保留角、分,忽略毫、厘)
const jiao: number = parseInt(decPartRaw[0], 10); // 角第1位小数
const fen: number = parseInt(decPartRaw[1], 10); // 分第2位小数
if (jiao === 0 && fen === 0) {
result += '整';
} else {
// 处理“角”
if (jiao > 0) {
result += digits[jiao] + '角';
} else if (jiao === 0 && fen > 0) {
result += '零';
}
// 处理“分”
if (fen > 0) {
result += digits[fen] + '分';
}
}
return result;
}

264
src/utils/print.ts Normal file
View File

@@ -0,0 +1,264 @@
/**
* 🔥 Vue后台专用 - 打印指定DIV样式完全还原 + 无侧边栏/导航)
* 适配 Element Plus / scoped样式 / 后台管理系统
*/
export function printVueDiv(elementId: string, title: string = '打印') {
const el = document.getElementById(elementId);
if (!el) {
console.error('未找到打印元素');
return;
}
const win = window.open('', '_blank', 'width=1000,height=800');
if (!win) return;
// ==============================================
// 【核心1】复制 全局样式 + Element Plus 样式
// ==============================================
const styles = Array.from(document.querySelectorAll('link[rel="stylesheet"], style:not([scoped])'))
.map((item) => item.outerHTML)
.join('');
// ==============================================
// 【核心2】手动注入打印区域的 scoped 样式(关键!)
// ==============================================
const printScopeStyle = `
<style>
* {
box-sizing: border-box;
margin:0;
padding:0;
}
body {
margin: 10px;
padding: 0;
background: #fff;
font-size: 12px; /* 全局缩小字体(核心) */
font-family: "Microsoft YaHei", sans-serif;
}
/* 强制不显示后台侧边栏/导航 */
.el-container, .el-aside, .el-header, .el-footer {
display: none !important;
}
/* 打印区域基础样式 */
#print-content {
width: 100% !important;
}
/* 标题样式(缩小) */
#print-content h3 {
font-size: 16px;
text-align: center;
margin: 10px 0;
font-weight: bold;
}
#print-content p {
font-size: 12px;
margin: 5px 0;
}
/* ====================== 表格核心优化 ====================== */
table {
border-collapse: collapse;
width: 100% !important;
table-layout: fixed; /* 固定表格布局,防止列变形 */
}
table td, table th {
border: 1px solid #333;
font-size: 9px; /* 表格字体最小化 */
text-align: center;
white-space: nowrap; /* ✅ 禁止文字自动换行(核心) */
overflow: hidden;
}
/* 适配合并列 */
td[colspan], th[colspan] {
white-space: normal !important;
}
/* 打印纸张设置 */
@page {
size: A4;
margin: 8mm; /* 缩小页边距 */
}
.navtitle {
text-align: center;
height: 41px;
line-height: 14px;
color: rgba(48, 49, 51, 1);
font-size: 20px;
margin-bottom: 50px;
}
p {
line-height: 14px;
color: rgba(48, 49, 51, 1);
font-size: 9px;
margin-bottom: 10px;
}
table {
margin-top: 15px;
width: 100%;
border-collapse: collapse;
color: rgba(48, 49, 51, 1);
}
tr {
border: 1px solid #dddddd;
}
td {
border: 1px solid #dddddd;
height: 50px;
line-height: 45px;
background-color: rgba(255, 255, 255, 1);
text-align: center;
font-weight: 450;
}
.footertr td {
height: 90px;
}
.foorter {
display: grid;
grid-template-columns: repeat(3, 1fr);
width: 85%;
margin: 0 auto;
gap: 30px;
margin-top: 30px;
}
</style>
`;
// ==============================================
// 【核心3】写入新窗口
// ==============================================
win.document.write(`
<!DOCTYPE html>
<html>
<head>
<title>${title}</title>
<meta charset="UTF-8">
${styles}
${printScopeStyle}
</head>
<body>
${el.outerHTML} <!-- 直接用innerHTML复制完整结构 -->
</body>
</html>
`);
win.document.close();
win.onload = () => {
setTimeout(() => {
win.print();
win.close();
}, 300);
};
}
/**
* 打印指定 DOM 元素(绝对不会打印其他内容)
* @param elementId 目标 div 的 id
* @param title 打印标题(可选)
*/
export function printDivPure(elementId: string, title: string = '打印') {
// 1. 获取目标元素
const targetElement = document.getElementById(elementId);
if (!targetElement) {
console.error(`未找到 id 为 "${elementId}" 的元素`);
return;
}
// 2. 保存原页面的所有内容
const originalBodyContent = document.body.innerHTML;
// 3. 克隆目标元素
const cloneElement = targetElement.cloneNode(true) as HTMLElement;
// 4. 【核心】把 body 替换成只有目标元素的内容
document.body.innerHTML = '';
// 添加打印专用样式
const printStyle = document.createElement('style');
printStyle.innerHTML = `
@page {
size: A4;
margin: 10mm;
}
body {
margin: 0;
padding: 20px;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
`;
document.head.appendChild(printStyle);
// 插入目标元素
document.body.appendChild(cloneElement);
// 5. 打印
window.print();
// 6. 【核心】打印完恢复原页面内容
setTimeout(() => {
document.body.innerHTML = originalBodyContent;
document.head.removeChild(printStyle);
// 强制刷新一下 Vue 组件(避免恢复后事件丢失)
window.location.reload();
}, 100);
}
/**
* 打印指定 DOM 元素(新窗口法加强版,不刷新页面)
* @param elementId 目标 div 的 id
* @param title 打印标题(可选)
*/
export function printDivNewWindow(elementId: string, title: string = '打印') {
const targetElement = document.getElementById(elementId);
if (!targetElement) {
console.error(`未找到 id 为 "${elementId}" 的元素`);
return;
}
const printWindow = window.open('', '_blank', 'width=800,height=1000');
if (!printWindow) {
console.error('无法打开新窗口,请检查浏览器弹窗拦截设置');
return;
}
// 【关键】深度克隆目标元素,包括所有子节点
const clone = targetElement.cloneNode(true) as HTMLElement;
printWindow.document.write(`
<!DOCTYPE html>
<html>
<head>
<title>${title}</title>
<meta charset="UTF-8">
<!-- 复制所有外部 CSS -->
${Array.from(document.querySelectorAll('link[rel="stylesheet"]'))
.map((l) => l.outerHTML)
.join('')}
<!-- 复制所有 style 标签 -->
${Array.from(document.querySelectorAll('style'))
.map((s) => s.outerHTML)
.join('')}
<style>
body { margin: 20px; padding: 0; }
@page { size: A4; margin: 10mm; }
</style>
</head>
<body></body>
</html>
`);
// 把克隆的元素插入到新窗口
printWindow.document.body.appendChild(clone);
printWindow.document.close();
// 等待加载完成后打印
printWindow.onload = () => {
printWindow.focus();
setTimeout(() => {
printWindow.print();
printWindow.close();
}, 300);
};
}

View File

@@ -51,13 +51,20 @@ export function needVillageId(url: string): boolean {
// 去掉 ? 后面的参数
const path = url.split('?')[0];
// 遍历白名单,正则匹配
return !whiteVillageId.some((pattern) => {
// 把 * 转成正则的 .* 通配
const regPattern = pattern.replace(/\*/g, '[^\\/]*');
const regex = new RegExp(`^${regPattern}$`);
return regex.test(path);
// 遍历白名单匹配
const isWhite = whiteVillageId.some((pattern) => {
// 处理 /* 结尾的通配(匹配该路径及其所有子路径)
if (pattern.endsWith('/*')) {
const basePath = pattern.slice(0, -2); // 比如 /warehouse/* → /warehouse
// 只要 path 是 /warehouse 或 /warehouse/ 或 /warehouse/xxx 就匹配
return path === basePath || path.startsWith(basePath + '/');
} else {
// 精确匹配
return path === pattern;
}
});
return !isWhite;
}
// 请求拦截器
service.interceptors.request.use(
@@ -105,6 +112,7 @@ service.interceptors.request.use(
} else {
obj = config.data;
}
if (!config.data) config.data = {};
Object.assign(config.data, obj);

View File

@@ -0,0 +1,147 @@
<template>
<div class="AddBuildingBox">
<PageHeader></PageHeader>
<div class="AddBuildingBody">
<div class="title">基本信息</div>
<div class="addBuildingFormBody">
<el-form class="formBody" label-position="right" ref="formRef" :model="form" :rules="rules" label-width="130px">
<el-form-item label="项目名称" prop="materialName">
<span>{{ form.materialName }}</span>
</el-form-item>
<el-form-item label="品牌" prop="brand">
<span>{{ form.brand }}</span>
</el-form-item>
<el-form-item label="规格型号" prop="model">
<span>{{ form.model }}</span>
</el-form-item>
<el-form-item label="计量单位" prop="unit">
<span>{{ form.unit }}</span>
</el-form-item>
<el-form-item label="成本" prop="unit">
<span>{{ form.unit }}</span>
<el-input v-model.trim="form.remark" placeholder="请输入成本" />
</el-form-item>
<el-form-item label="当前库存" prop="unit">
<span>{{ form.unit }}</span>
<el-input v-model.trim="form.remark" placeholder="请输入当前库存" />
</el-form-item>
<el-form-item style="margin-top: 30px">
<el-button type="primary" @click="submitForm">提交</el-button>
<el-button @click="cancelForm">返回</el-button>
</el-form-item>
</el-form>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import PageHeader from '@/components/Pageheader/index.vue';
import { getMaterial, updateMaterial, addMaterial } from '@/api/system/Tmaterial';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const router = useRouter();
const route = useRoute();
const formRef = ref();
const form = ref({
id: null,
materialName: '', // 物料名称
brand: '', // 联系电话
model: '', // 邮箱
unit: '', // 地址
remark: '' // 备注
});
const rules = ref({
materialName: [{ required: true, message: '请输入 物料名称', trigger: 'blur' }],
brand: [{ required: true, message: '请输入 品牌', trigger: 'blur' }],
model: [{ required: true, message: '请输入 规格型号', trigger: 'blur' }],
unit: [{ required: true, message: '请输入 计量单位', trigger: 'blur' }]
});
const userid = ref(null);
if (route.query.id) {
userid.value = route.query.id;
getMaterial(userid.value).then((res) => {
form.value = {
id: res.data.id,
materialName: res.data.materialName,
brand: res.data.brand,
model: res.data.model,
unit: res.data.unit,
remark: res.data.remark
};
});
}
// !== 提交 =============================================================================
// 提交
const submitForm = () => {
formRef.value?.validate(async (valid: boolean) => {
if (valid) {
if (userid.value) {
updateMaterial(form.value).then((res) => {
ElMessage.success('编辑成功');
cancelForm();
});
} else {
addMaterial(form.value).then((res) => {
ElMessage.success('添加成功');
cancelForm();
});
}
}
});
};
// 推出
const cancelForm = () => {
router.back();
};
</script>
<style scoped lang="scss">
.AddBuildingBox {
padding: 15px;
height: 100%;
width: 100%;
}
.AddBuildingBody {
margin-top: 20px;
display: flex;
flex-direction: column;
justify-content: center;
background-color: white;
padding: 15px;
.title {
height: 40px;
line-height: 40px;
padding-left: 20px;
background-color: rgba(255, 255, 255, 1);
color: rgba(16, 16, 16, 1);
border-bottom: 1px solid #bbbbbb;
margin-bottom: 60px;
}
.formBody {
width: 650px;
margin: 0 auto;
&:deep(.el-form-item__content, .el-select, .el-input) {
width: 350px !important;
margin-right: 10px;
.el-cascader {
width: 100%;
}
}
.el-form-item {
margin-bottom: 20px;
align-items: center;
}
.el-button {
width: 80px;
height: 35px;
margin-right: 20px;
}
}
}
</style>

View File

@@ -0,0 +1,249 @@
<template>
<div class="flex flex-col h-full p-2">
<pageheader></pageheader>
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
<el-form-item label="项目名称" prop="name">
<el-input v-model="queryParams.name" placeholder="请输入项目名称" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</transition>
<el-card class="flex-1" shadow="never">
<template #header>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['chargeItem:chargeItem:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['chargeItem:chargeItem:edit']"
>修改</el-button
>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['chargeItem:chargeItem:remove']"
>删除</el-button
>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
</template>
<el-table v-loading="loading" border :data="chargeItemList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="项目名称" align="center" prop="name" />
<el-table-column label="计费方式" align="center" prop="billingMethod">
<template #default="scope">
<dict-tag :options="com_charge_item_method" :value="scope.row.billingMethod"></dict-tag>
</template>
</el-table-column>
<el-table-column label="单价" align="center" prop="price" />
<el-table-column label="单位" align="center" prop="unit">
<template #default="scope">
<dict-tag :options="com_charge_item_unit" :value="scope.row.unit"></dict-tag>
</template>
</el-table-column>
<el-table-column label="精度" align="center" prop="precision">
<template #default="scope">
<dict-tag :options="com_charge_item_precision" :value="scope.row.precision"></dict-tag>
</template>
</el-table-column>
<el-table-column label="进位方式" align="center" prop="carryMethod">
<template #default="scope">
<dict-tag :options="com_charge_item_carry_method" :value="scope.row.carryMethod"></dict-tag>
</template>
</el-table-column>
<el-table-column label="滞纳金比例" align="center" prop="lateFee" />
<el-table-column label="小区" align="center" prop="villageId" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
<template #default="scope">
<el-tooltip content="修改" placement="top">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['chargeItem:chargeItem:edit']"></el-button>
</el-tooltip>
<el-tooltip content="删除" placement="top">
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['chargeItem:chargeItem:remove']"></el-button>
</el-tooltip>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
</el-card>
</div>
</template>
<script setup name="ChargeItem" lang="ts">
import { listChargeItem, getChargeItem, delChargeItem, addChargeItem, updateChargeItem } from '@/api/system/SdbChargeItem';
import { ChargeItemVO, ChargeItemQuery, ChargeItemForm } from '@/api/system/SdbChargeItem/type';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { com_charge_item_method } = toRefs<any>(proxy?.useDict('com_charge_item_method'));
const { com_charge_item_unit } = toRefs<any>(proxy?.useDict('com_charge_item_unit'));
const { com_charge_item_precision } = toRefs<any>(proxy?.useDict('com_charge_item_precision'));
const { com_charge_item_carry_method } = toRefs<any>(proxy?.useDict('com_charge_item_carry_method'));
const chargeItemList = ref<ChargeItemVO[]>([]);
const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref<Array<string | number>>([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const queryFormRef = ref<ElFormInstance>();
const chargeItemFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({
visible: false,
title: ''
});
const initFormData: ChargeItemForm = {
id: undefined,
name: undefined,
billingMethod: undefined,
price: undefined,
unit: undefined,
precision: undefined,
carryMethod: undefined,
lateFee: undefined,
remark: undefined,
villageId: undefined
};
const data = reactive<PageData<ChargeItemForm, ChargeItemQuery>>({
form: { ...initFormData },
queryParams: {
pageNum: 1,
pageSize: 10,
name: undefined,
billingMethod: undefined,
price: undefined,
unit: undefined,
precision: undefined,
carryMethod: undefined,
lateFee: undefined,
villageId: undefined,
params: {}
},
rules: {
id: [{ required: true, message: '收费项目管理表id不能为空', trigger: 'blur' }]
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询收费项目管理列表 */
const getList = async () => {
loading.value = true;
const res = await listChargeItem(queryParams.value);
chargeItemList.value = res.rows;
total.value = res.total;
loading.value = false;
};
/** 取消按钮 */
const cancel = () => {
reset();
dialog.visible = false;
};
/** 表单重置 */
const reset = () => {
form.value = { ...initFormData };
chargeItemFormRef.value?.resetFields();
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
};
/** 多选框选中数据 */
const handleSelectionChange = (selection: ChargeItemVO[]) => {
ids.value = selection.map((item) => item.id);
single.value = selection.length != 1;
multiple.value = !selection.length;
};
const router = useRouter();
/** 新增按钮操作 */
const handleAdd = () => {
router.push({
path: '/sdb/addchargeItem'
});
};
/** 修改按钮操作 */
const handleUpdate = async (row?: ChargeItemVO) => {
router.push({
path: '/sdb/addchargeItem',
query: {
id: row.id
}
});
};
/** 提交按钮 */
const submitForm = () => {
chargeItemFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
if (form.value.id) {
await updateChargeItem(form.value).finally(() => (buttonLoading.value = false));
} else {
await addChargeItem(form.value).finally(() => (buttonLoading.value = false));
}
proxy?.$modal.msgSuccess('操作成功');
dialog.visible = false;
await getList();
}
});
};
/** 删除按钮操作 */
const handleDelete = async (row?: ChargeItemVO) => {
const _ids = row?.id || ids.value;
await proxy?.$modal.confirm('是否确认删除收费项目管理编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
await delChargeItem(_ids);
proxy?.$modal.msgSuccess('删除成功');
await getList();
};
/** 导出按钮操作 */
const handleExport = () => {
proxy?.download(
'chargeItem/chargeItem/export',
{
...queryParams.value
},
`chargeItem_${new Date().getTime()}.xlsx`
);
};
onMounted(() => {
getList();
});
</script>
<style lang="scss" scoped>
.el-table {
height: calc(100% - 80px);
}
</style>

View File

@@ -6,7 +6,7 @@
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
<el-form-item label="执行状态" prop="status">
<el-select>
<el-select v-model="queryParams.status">
<el-option v-for="item in com_inspection_task_status" :key="item.value" :value="item.value" :label="item.label"></el-option>
</el-select>
</el-form-item>
@@ -74,6 +74,7 @@
<script setup name="Record" lang="ts">
import { listRecord, getRecord, delRecord, addRecord, updateRecord } from '@/api/system/InspectionRecord/index';
import { RecordVO, RecordQuery, RecordForm } from '@/api/system/InspectionRecord/type';
import { getUserByRoleKey } from '@/api/system/user';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { com_inspection_task_status } = toRefs<any>(proxy?.useDict('com_inspection_task_status'));
@@ -123,6 +124,7 @@ const { queryParams, form } = toRefs(data);
/** 查询巡检记录主列表 */
const getList = async () => {
loading.value = true;
const res = await listRecord(queryParams.value);
recordList.value = res.rows;
total.value = res.total;

View File

@@ -107,7 +107,6 @@ function checkoutItem(id: string) {
checkoutPointlist.value.push(id);
const find = pointslist.value.find((item) => item.id === id);
if (find && find.location) {
console.log(find.location, find.pointName);
if (find && find.location) {
addPointMarker(id, find.location, find.pointName);
}
@@ -172,7 +171,6 @@ function init() {
pathPoints: res.data.pathPoints, // 巡检路线经纬度
totalPoints: res.data.totalPoints // 巡检点
};
console.log('巡检路线详情:', form.value);
nextTick(() => {
if (routeid.value) {
checkoutPointlist.value = res.data.totalPoints ? res.data.totalPoints.split(',') : [];
@@ -187,7 +185,6 @@ function init() {
}
// 回显路线
if (res.data.pathPoints) {
console.log('回显巡检点:', res.data.pathPoints);
renderSavedPath(res.data.pathPoints);
}
}
@@ -242,7 +239,6 @@ onMounted(async () => {
if (drawnPolylines.value.length > 0) {
map.value.remove(drawnPolylines.value[0]);
}
drawnPolylines.value = [e.obj];
// 画完继续允许画下一条(但永远只保留一条)
initDrawTool();
@@ -315,16 +311,38 @@ function clearAll() {
// !!! 核心:获取绘制的路线经纬度数组
function getPolylinePath() {
if (drawnPolylines.value.length === 0) return [];
const lastLine = drawnPolylines.value.at(-1);
console.log('最后一条线的路径:', lastLine.getPath());
const lastLine = drawnPolylines.value.pop();
const path = lastLine.getPath().map((p) => [p.lng, p.lat]);
return path;
}
/**
* 修复高德地图 Polyline 闭合路线最后一段不显示
* 解决:最后两点坐标相同 → 长度0 → 不渲染
*/
function fixClosePath(path: number[][]): number[][] {
if (!path || path.length < 2) return path;
const newPath = [...path];
// 如果是闭合路线(最后一点 ≈ 第一点)
const first = newPath[0];
const last = newPath[newPath.length - 1];
// 判断是否几乎重合
const isSame = Math.abs(last[0] - first[0]) < 1e-8 && Math.abs(last[1] - first[1]) < 1e-8;
if (isSame) {
// 【关键】最后一点极微小偏移,强制生成线段
newPath[newPath.length - 1] = [last[0] + 0.0000001, last[1] + 0.0000001];
}
return newPath;
}
// !== 提交 =============================================================================
const submitForm = () => {
formRef.value?.validate(async (valid: boolean) => {
if (valid) {
// if (valid) {
// 获取路线经纬度
const path = getPolylinePath() as [number, number][];
if (path.length === 0) {
@@ -332,8 +350,8 @@ const submitForm = () => {
return;
}
// 转成字符串传给后端
const [start_lng, start_lat] = path.shift() as [number, number];
const [end_lng, end_lat] = path.pop() as [number, number];
const [start_lng, start_lat] = path.at(0) as [number, number];
const [end_lng, end_lat] = path.at(-1) as [number, number];
form.value.startLng = `${start_lng}`;
form.value.startLat = `${start_lat}`;
@@ -342,8 +360,6 @@ const submitForm = () => {
form.value.pathPoints = JSON.stringify(path);
form.value.totalPoints = checkoutPointlist.value.join(',');
console.log('提交数据:', form.value);
if (routeid.value) {
updateRoute(form.value).then(() => {
ElMessage.success('编辑成功');
@@ -355,7 +371,7 @@ const submitForm = () => {
cancelForm();
});
}
}
// }
});
};
// 返回

View File

@@ -55,6 +55,7 @@
<script setup name="Route" lang="ts">
import { list_statapi } from '@/api/system/Inspection';
import { getUserByRoleKey } from '@/api/system/user';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@@ -74,12 +75,15 @@ const data = reactive({
});
const checkdata = ref([]);
// TODO 巡检人员名称
const { queryParams } = toRefs(data);
const inspectionUserlist = ref([]);
/** 查询巡检路线列表 */
const getList = async () => {
loading.value = true;
// const inspectionUseres = await getUserByRoleKey('inspection');
// inspectionUserlist.value = inspectionUseres.data;
const res = await list_statapi(queryParams.value);
routeList.value = res.rows;
total.value = res.total;

View File

@@ -0,0 +1,147 @@
<template>
<div class="AddBuildingBox">
<PageHeader></PageHeader>
<div class="AddBuildingBody">
<div class="title">基本信息</div>
<div class="addBuildingFormBody">
<el-form class="formBody" label-position="right" ref="formRef" :model="form" :rules="rules" label-width="130px">
<el-form-item label="物料名称" prop="materialName">
<span>{{ form.materialName }}</span>
</el-form-item>
<el-form-item label="品牌" prop="brand">
<span>{{ form.brand }}</span>
</el-form-item>
<el-form-item label="规格型号" prop="model">
<span>{{ form.model }}</span>
</el-form-item>
<el-form-item label="计量单位" prop="unit">
<span>{{ form.unit }}</span>
</el-form-item>
<el-form-item label="成本" prop="unit">
<span>{{ form.unit }}</span>
<el-input v-model.trim="form.remark" placeholder="请输入成本" />
</el-form-item>
<el-form-item label="当前库存" prop="unit">
<span>{{ form.unit }}</span>
<el-input v-model.trim="form.remark" placeholder="请输入当前库存" />
</el-form-item>
<el-form-item style="margin-top: 30px">
<el-button type="primary" @click="submitForm">提交</el-button>
<el-button @click="cancelForm">返回</el-button>
</el-form-item>
</el-form>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import PageHeader from '@/components/Pageheader/index.vue';
import { getMaterial, updateMaterial, addMaterial } from '@/api/system/Tmaterial';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const router = useRouter();
const route = useRoute();
const formRef = ref();
const form = ref({
id: null,
materialName: '', // 物料名称
brand: '', // 联系电话
model: '', // 邮箱
unit: '', // 地址
remark: '' // 备注
});
const rules = ref({
materialName: [{ required: true, message: '请输入 物料名称', trigger: 'blur' }],
brand: [{ required: true, message: '请输入 品牌', trigger: 'blur' }],
model: [{ required: true, message: '请输入 规格型号', trigger: 'blur' }],
unit: [{ required: true, message: '请输入 计量单位', trigger: 'blur' }]
});
const userid = ref(null);
if (route.query.id) {
userid.value = route.query.id;
getMaterial(userid.value).then((res) => {
form.value = {
id: res.data.id,
materialName: res.data.materialName,
brand: res.data.brand,
model: res.data.model,
unit: res.data.unit,
remark: res.data.remark
};
});
}
// !== 提交 =============================================================================
// 提交
const submitForm = () => {
formRef.value?.validate(async (valid: boolean) => {
if (valid) {
if (userid.value) {
updateMaterial(form.value).then((res) => {
ElMessage.success('编辑成功');
cancelForm();
});
} else {
addMaterial(form.value).then((res) => {
ElMessage.success('添加成功');
cancelForm();
});
}
}
});
};
// 推出
const cancelForm = () => {
router.back();
};
</script>
<style scoped lang="scss">
.AddBuildingBox {
padding: 15px;
height: 100%;
width: 100%;
}
.AddBuildingBody {
margin-top: 20px;
display: flex;
flex-direction: column;
justify-content: center;
background-color: white;
padding: 15px;
.title {
height: 40px;
line-height: 40px;
padding-left: 20px;
background-color: rgba(255, 255, 255, 1);
color: rgba(16, 16, 16, 1);
border-bottom: 1px solid #bbbbbb;
margin-bottom: 60px;
}
.formBody {
width: 650px;
margin: 0 auto;
&:deep(.el-form-item__content, .el-select, .el-input) {
width: 350px !important;
margin-right: 10px;
.el-cascader {
width: 100%;
}
}
.el-form-item {
margin-bottom: 20px;
align-items: center;
}
.el-button {
width: 80px;
height: 35px;
margin-right: 20px;
}
}
}
</style>

View File

@@ -1,12 +1,154 @@
<template>
<div class="p-2 h-full flex flex-col">
<Pageheader></Pageheader>
<div class="flex-1 color-gray flex h-full font-size-6 flex-center">系统还在维护中敬请期待...</div>
<div class="flex flex-col h-full p-2">
<pageheader></pageheader>
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
<el-form-item label="选择品牌" prop="brand">
<el-input v-model="queryParams.brand" placeholder="请输入物料名称" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="选择型号" prop="model">
<el-input v-model="queryParams.model" placeholder="请输入物料名称" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="物料名称" prop="materialName">
<el-input v-model="queryParams.materialName" placeholder="请输入物料名称" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</transition>
<el-card class="flex-1" shadow="never">
<template #header>
<el-row :gutter="10" class="mb8">
<el-button type="primary" icon="Plus" @click="handleAdd">添加</el-button>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
</template>
<el-table v-loading="loading" border :data="materialList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="物料名称" align="center" prop="materialName" />
<el-table-column label="品牌" align="center" prop="brand" />
<el-table-column label="规格型号" align="center" prop="model" />
<el-table-column label="单位" width="60" align="center" prop="unit" />
<el-table-column label="成本" width="60" align="center" prop="avgCostPrice" />
<el-table-column label="当前库存" width="80" align="center" prop="totalStockNum" />
<el-table-column label="备注" show-overflow-tooltip align="center" prop="remark" />
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:material:edit']">修改</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:material:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
</el-card>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
<script setup name="Material" lang="ts">
import { listMaterial, getMaterial, delMaterial, addMaterial, updateMaterial } from '@/api/system/Tmaterial';
import { MaterialVO, MaterialQuery, MaterialForm } from '@/api/system/Tmaterial/type';
import { listStock } from '@/api/system/Tstock/index';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const router = useRouter();
const materialList = ref<MaterialVO[]>([]);
const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref<Array<string | number>>([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const queryFormRef = ref<ElFormInstance>();
const initFormData: MaterialForm = {
id: undefined,
materialName: undefined,
brand: undefined,
model: undefined
};
const data = reactive<PageData<MaterialForm, MaterialQuery>>({
form: { ...initFormData },
queryParams: {
pageNum: 1,
pageSize: 10,
materialName: undefined,
brand: undefined,
model: undefined
}
});
const { queryParams } = toRefs(data);
/** 查询物料列表 */
const getList = async () => {
loading.value = true;
const res = await listStock(queryParams.value);
materialList.value = res.data;
total.value = res.total ?? 0;
loading.value = false;
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
};
/** 多选框选中数据 */
const handleSelectionChange = (selection: MaterialVO[]) => {
ids.value = selection.map((item) => item.id);
single.value = selection.length != 1;
multiple.value = !selection.length;
};
const handleAdd = () => {
router.push({
path: '/warehouse/purchaseIn'
});
};
/** 修改按钮操作 */
const handleUpdate = async (row?: MaterialVO) => {
router.push({
path: '/warehouse/editInventory',
query: {
id: row.id
}
});
};
/** 删除按钮操作 */
const handleDelete = async (row?: MaterialVO) => {
const _ids = row?.id || ids.value;
await proxy?.$modal.confirm('是否确认删除该物料?').finally(() => (loading.value = false));
await delMaterial(_ids);
proxy?.$modal.msgSuccess('删除成功');
await getList();
};
onMounted(() => {
getList();
});
</script>
<style scoped lang="scss"></style>
<style lang="scss" scoped>
.el-table {
height: calc(100% - 80px);
}
</style>

View File

@@ -0,0 +1,171 @@
<template>
<div class="h-full flex flex-col p-2">
<Pageheader></Pageheader>
<div class="mainbody">
<div class="actionsbox">
<el-button @click="handlePrint" icon="Printer" type="primary">打印</el-button>
<el-button @click="cancelForm">返回</el-button>
</div>
<div class="formBody" id="print-area">
<div class="navtitle">出库单</div>
<p>单号{{ form.outNo }}</p>
<p>制单日期{{ form.outDate }}</p>
<table border>
<tbody>
<tr>
<td style="width: 60px">序号</td>
<td>物资名称</td>
<td>品牌</td>
<td>规格型号</td>
<td style="width: 40px">单位</td>
<td>供应商</td>
<td style="width: 40px">数量</td>
<td style="width: 80px">单价</td>
<td>合计</td>
<td>备注</td>
</tr>
<tr v-for="(item, index) in form.items" :key="index">
<td>{{ index + 1 }}</td>
<td>{{ item.materialName }}</td>
<td>{{ item.brand }}</td>
<td>{{ item.model }}</td>
<td>{{ item.unit }}</td>
<td>{{ form.supplierName }}</td>
<td>{{ item.outNum }}</td>
<td>{{ item.outPrice }}</td>
<td>{{ item.totalPrice }}</td>
<td>{{ item.remark }}</td>
</tr>
<tr class="footertr">
<td>金额大写</td>
<td colspan="4">{{ convertToChineseCapital(form.totalAmount) }}</td>
<td>总价合计</td>
<td colspan="4">{{ form.totalAmount }}</td>
</tr>
</tbody>
</table>
<div class="foorter">
<div>制单人{{ form.leader }}</div>
<div>仓库{{ form.warehouseName }}</div>
<div>日期 {{ form.createTime }}</div>
<div>备注 {{ form.remark }}</div>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { printVueDiv } from '@/utils/print';
import { convertToChineseCapital } from '@/utils/money';
import { getStockOut } from '@/api/system/TissueOut';
const router = useRouter();
const route = useRoute();
const form = ref({
id: null,
outNo: null, //
outDate: '', // 出库日期
operateStatus: '0', //
remark: '', // 备注
supplierName: '', // 供应商
warehouseName: '', // 仓库
leader: '', // 出库人
totalAmount: '', // 总出库金额
createTime: '', // 创建时间
items: [] // 联系人
});
const userid = ref(null);
function init() {
if (route.query.id) {
userid.value = route.query.id;
getStockOut(userid.value).then((res) => {
form.value = {
id: res.data.id,
leader: res.data.leader,
totalAmount: res.data.totalAmount ?? '0.00',
operateStatus: res.data.operateStatus,
outNo: res.data.outNo,
outDate: res.data.outDate,
remark: res.data.remark,
warehouseName: res.data.warehouseName,
supplierName: res.data.supplierName,
createTime: res.data.createTime,
items: res.data.items
};
});
}
}
init();
const handlePrint = () => {
console.log('print');
// window.print();
printVueDiv('print-area', '仓库出库单');
};
// 推出
const cancelForm = () => {
router.back();
};
</script>
<style scoped lang="scss">
.mainbody {
padding: 30px;
background-color: #fff;
margin-top: 20px;
border-radius: 5px;
.actionsbox {
text-align: right;
margin-bottom: 10px;
}
.formBody {
.navtitle {
text-align: center;
height: 41px;
line-height: 14px;
color: rgba(48, 49, 51, 1);
font-size: 30px;
margin-bottom: 50px;
}
p {
line-height: 14px;
color: rgba(48, 49, 51, 1);
font-size: 16px;
margin-bottom: 10px;
}
table {
margin-top: 15px;
width: 100%;
border-collapse: collapse; /* 核心:合并边框 */
color: rgba(48, 49, 51, 1);
tr {
border: 1px solid #dddddd; /* 现代浅灰色边框 */
td {
border: 1px solid #dddddd; /* 现代浅灰色边框 */
height: 50px;
line-height: 45px;
background-color: rgba(255, 255, 255, 1);
font-size: 1rem;
text-align: center;
font-weight: 450;
}
&.footertr td {
height: 90px;
}
}
}
.foorter {
display: grid;
grid-template-columns: repeat(3, 1fr);
width: 85%;
margin: 0 auto;
gap: 30px;
margin-top: 30px;
}
}
}
</style>

View File

@@ -0,0 +1,267 @@
<template>
<div class="AddBuildingBox">
<PageHeader></PageHeader>
<el-form class="formBody" label-position="right" ref="formRef" :model="form" :rules="rules" label-width="130px">
<div class="AddBuildingBody formbox">
<div class="title">
<span>基本信息</span>
<div>
<el-button type="primary" @click="submitForm">提交</el-button>
<el-button @click="cancelForm">返回</el-button>
</div>
</div>
<div class="addBuildingFormBody">
<el-form-item label="出库日期" prop="outDate">
<el-date-picker
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
style="width: 100%"
v-model="form.outDate"
type="date"
placeholder="请选择出库日期"
/>
</el-form-item>
<el-form-item label="供应商" prop="supplierId">
<el-select v-model="form.supplierId" placeholder="请选择供应商">
<el-option v-for="(item, index) in supplierlist" :key="index" :label="item.supplierName" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="出库仓库" prop="warehouseId">
<el-select v-model="form.warehouseId" placeholder="请选择出库仓库">
<el-option v-for="(item, index) in warehouselist" :key="index" :label="item.warehouseName" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="出库状态" prop="operateStatus">
<el-radio-group v-model="form.operateStatus">
<el-radio v-for="(item, index) in com_stock_out_status" :key="index" :value="item.value">{{ item.label }}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="领用人" prop="leader">
<el-input v-model.trim="form.leader" placeholder="请输入领用人" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input type="textarea" :rows="5" v-model.trim="form.remark" placeholder="请输入备注" />
</el-form-item>
</div>
</div>
<div class="AddBuildingBody">
<div style="margin-bottom: 20px">
<span>详细出库列表</span>
<material :userid="itemsid" returnvalue="*" @change="handleChangeitem" :is-multiple="true" ref="materialRef">
<template #default>
<el-button @click="() => materialRef.open()" style="margin-left: 20px" icon="Plus" type="primary">添加</el-button>
</template>
</material>
</div>
<div class="addBuildingFormBody">
<el-table :data="form.items">
<el-table-column label="物料名称" align="center" prop="materialName" />
<el-table-column label="品牌" align="center" prop="brand" />
<el-table-column label="规格型号" align="center" prop="model" />
<el-table-column label="单位" align="center" prop="unit" />
<el-table-column label="出库价" align="center" prop="inNo">
<template #default="scope">
<el-input v-model.trim.number="scope.row.outPrice" placeholder="请输入"></el-input>
</template>
</el-table-column>
<el-table-column label="数量" align="center" prop="inNo">
<template #default="scope">
<el-input v-model.trim.number="scope.row.outNum" placeholder="请输入"></el-input>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark">
<template #default="scope">
{{ scope.row.remark ? scope.row.remark : '-------' }}
</template>
</el-table-column>
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button type="primary" link @click="handleDeleteRow(scope.row.id)">删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
</div>
</el-form>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import material from '@/components/Holder/material.vue';
import PageHeader from '@/components/Pageheader/index.vue';
import { listSupplier } from '@/api/system/Tsupplier';
import { listWarehouse } from '@/api/system/Twarehouse';
import { MaterialVO } from '@/api/system/Tmaterial/type';
import { addStockOut, getStockOut, updateStockOut } from '@/api/system/TissueOut';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { com_stock_out_status } = toRefs<any>(proxy?.useDict('com_stock_out_status'));
interface tabletype extends MaterialVO {
costPrice?: number; // 成本价
inNum?: number; // 成本价
}
const router = useRouter();
const route = useRoute();
const materialRef = ref();
const formRef = ref();
const form = ref({
id: null,
outNo: null, //
operateStatus: '0', //
outDate: '', // 出库日期
supplierId: '', // 供应商
warehouseId: '', // 出库仓库
leader: '', // 备注
remark: '', // 备注
items: [] as tabletype[] // 联系人
});
const itemsid = computed(() => {
return form.value.items.map((item) => item.id).join(',');
});
const rules = ref({
outDate: [{ required: true, message: '请选择 出库日期', trigger: 'blur' }],
supplierId: [{ required: true, message: '请选择 供应商', trigger: 'blur' }],
leader: [{ required: true, message: '请输入制单人', trigger: 'blur' }],
warehouseId: [{ required: true, message: '请选择 出库仓库', trigger: 'blur' }]
});
const userid = ref(null);
const warehouselist = ref([]);
const supplierlist = ref([]);
function init() {
listWarehouse().then((res) => {
warehouselist.value = res.rows;
});
listSupplier().then((res) => {
supplierlist.value = res.rows;
});
if (route.query.id) {
userid.value = route.query.id;
getStockOut(userid.value).then((res) => {
form.value = {
id: res.data.id,
leader: res.data.leader,
operateStatus: res.data.operateStatus,
outNo: res.data.outNo,
outDate: res.data.outDate,
supplierId: res.data.supplierId,
warehouseId: res.data.warehouseId,
remark: res.data.remark,
items: res.data.items
};
});
}
}
init();
function handleChangeitem(row: MaterialVO[]) {
const arr = row
.map((item) => {
if (!item.id) return null;
const find = form.value.items.find((i) => i.id === item.id);
if (find || form.value.items.length <= 0) {
return {
...item,
materialId: item.id,
...find
};
} else {
return {
...item,
materialId: item.id
};
}
})
.filter((item) => item !== null);
form.value.items = arr;
}
function handleDeleteRow(id: string) {
const findindex = form.value.items.findIndex((item) => item.id === id);
if (findindex !== -1) {
form.value.items.splice(findindex, 1);
}
}
// !== 提交 =============================================================================
// 提交
const submitForm = () => {
formRef.value?.validate(async (valid: boolean) => {
if (valid) {
if (userid.value) {
updateStockOut(form.value).then(() => {
ElMessage.success('编辑成功');
cancelForm();
});
} else {
addStockOut(form.value).then(() => {
ElMessage.success('添加成功');
cancelForm();
});
}
}
});
};
// 推出
const cancelForm = () => {
router.back();
};
</script>
<style scoped lang="scss">
.AddBuildingBox {
padding: 15px;
height: 100%;
width: 100%;
}
.AddBuildingBody {
margin-top: 20px;
display: flex;
flex-direction: column;
justify-content: center;
background-color: white;
padding: 15px;
.title {
height: 40px;
line-height: 40px;
padding-left: 20px;
background-color: rgba(255, 255, 255, 1);
color: rgba(16, 16, 16, 1);
margin-bottom: 60px;
display: flex;
justify-content: space-between;
align-items: center;
}
&.formbox .addBuildingFormBody {
width: 550px;
margin: 0 auto;
}
.addBuildingFormBody {
width: 100%;
}
.formBody {
width: 650px;
margin: 0 auto;
&:deep(.el-form-item__content, .el-date-picker, .el-select, .el-input) {
width: 550px !important;
margin-right: 10px;
}
.el-form-item {
margin-bottom: 20px;
align-items: center;
}
.el-button {
width: 80px;
height: 35px;
margin-right: 20px;
}
}
}
</style>

View File

@@ -1,12 +1,237 @@
<template>
<div class="p-2 h-full flex flex-col">
<Pageheader title="出库管理"></Pageheader>
<div class="flex-1 color-gray flex h-full font-size-6 flex-center">系统还在维护中敬请期待...</div>
<pageheader></pageheader>
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
<el-form-item label="出库单号" prop="outNo">
<el-input v-model="queryParams.outNo" placeholder="请输入出库单号" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</transition>
<el-card class="flex-1" shadow="never">
<template #header>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:stockOut:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['system:stockOut:edit']"
>修改</el-button
>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['system:stockOut:remove']"
>删除</el-button
>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
</template>
<el-table v-loading="loading" border :data="stockOutList" @selection-change="handleSelectionChange">
<el-table-column type="selection" flexd width="55" align="center" />
<el-table-column label="出库单号" flexd align="center" prop="outNo" />
<el-table-column label="出库日期" width="100" align="center" prop="outDate" />
<el-table-column label="领用人" align="center" prop="supplierName" />
<el-table-column label="出库仓库" align="center" prop="warehouseName" />
<el-table-column label="操作状态" width="80" align="center" prop="operateStatus">
<template #default="scope">
<dict-tag :options="com_stock_out_status" :value="scope.row.operateStatus"></dict-tag>
</template>
</el-table-column>
<el-table-column label="负责人" show-overflow-tooltip align="center" prop="leader" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" width="180" align="center" fixed="right" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="primary" @click="handleMain(scope.row)" v-hasPermi="['system:stockOut:edit']">查看清单</el-button>
<el-button link type="primary" @click="handleUpdate(scope.row)" v-hasPermi="['system:stockOut:edit']">修改</el-button>
<el-button link type="primary" @click="handleDelete(scope.row)" v-hasPermi="['system:stockOut:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
</el-card>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
<script setup name="StockOut" lang="ts">
import { listStockOut, getStockOut, delStockOut, addStockOut, updateStockOut } from '@/api/system/TissueOut/index';
import { StockOutVO, StockOutQuery, StockOutForm } from '@/api/system/TissueOut/type';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { com_stock_out_status } = toRefs<any>(proxy?.useDict('com_stock_out_status'));
const stockOutList = ref<StockOutVO[]>([]);
const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref<Array<string | number>>([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const queryFormRef = ref<ElFormInstance>();
const stockOutFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({
visible: false,
title: ''
});
const initFormData: StockOutForm = {
id: undefined,
outNo: undefined,
outDate: undefined,
supplierId: undefined,
warehouseId: undefined,
operateStatus: undefined,
leader: undefined,
remark: undefined
};
const data = reactive<PageData<StockOutForm, StockOutQuery>>({
form: { ...initFormData },
queryParams: {
pageNum: 1,
pageSize: 10,
outNo: undefined,
outDate: undefined,
supplierId: undefined,
warehouseId: undefined,
operateStatus: undefined,
leader: undefined,
params: {}
},
rules: {
id: [{ required: true, message: '主键不能为空', trigger: 'blur' }],
outNo: [{ required: true, message: '出库单号不能为空', trigger: 'blur' }],
outDate: [{ required: true, message: '出库日期不能为空', trigger: 'blur' }],
supplierId: [{ required: true, message: '领用人(供应商id)不能为空', trigger: 'blur' }],
warehouseId: [{ required: true, message: '出库仓库id不能为空', trigger: 'blur' }]
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询出库主列表 */
const getList = async () => {
loading.value = true;
const res = await listStockOut(queryParams.value);
stockOutList.value = res.rows;
total.value = res.total;
loading.value = false;
};
/** 取消按钮 */
const cancel = () => {
reset();
dialog.visible = false;
};
/** 表单重置 */
const reset = () => {
form.value = { ...initFormData };
stockOutFormRef.value?.resetFields();
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
};
/** 多选框选中数据 */
const handleSelectionChange = (selection: StockOutVO[]) => {
ids.value = selection.map((item) => item.id);
single.value = selection.length != 1;
multiple.value = !selection.length;
};
const router = useRouter();
/** 新增按钮操作 */
const handleAdd = () => {
router.push({
path: '/warehouse/addissueOut'
});
};
/** 修改按钮操作 */
const handleUpdate = async (row?: StockOutVO) => {
router.push({
path: '/warehouse/stockoutMain',
query: {
id: row.id
}
});
};
/** 修改按钮操作 */
const handleMain = async (row?: StockOutVO) => {
router.push({
path: '/warehouse/stockoutMain',
query: {
id: row.id
}
});
};
/** 提交按钮 */
const submitForm = () => {
stockOutFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
if (form.value.id) {
await updateStockOut(form.value).finally(() => (buttonLoading.value = false));
} else {
await addStockOut(form.value).finally(() => (buttonLoading.value = false));
}
proxy?.$modal.msgSuccess('操作成功');
dialog.visible = false;
await getList();
}
});
};
/** 删除按钮操作 */
const handleDelete = async (row?: StockOutVO) => {
const _ids = row?.id || ids.value;
await proxy?.$modal.confirm('是否确认删除出库主编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
await delStockOut(_ids);
proxy?.$modal.msgSuccess('删除成功');
await getList();
};
/** 导出按钮操作 */
const handleExport = () => {
proxy?.download(
'system/stockOut/export',
{
...queryParams.value
},
`stockOut_${new Date().getTime()}.xlsx`
);
};
onMounted(() => {
getList();
});
</script>
<style scoped lang="scss"></style>
<style lang="scss" scoped>
.el-table {
height: calc(100% - 80px);
}
</style>

View File

@@ -0,0 +1,142 @@
<template>
<div class="AddBuildingBox">
<PageHeader></PageHeader>
<div class="AddBuildingBody">
<div class="title">基本信息</div>
<div class="addBuildingFormBody">
<el-form class="formBody" label-position="right" ref="formRef" :model="form" :rules="rules" label-width="130px">
<el-form-item label="物料名称" prop="materialName">
<el-input v-model.trim="form.materialName" placeholder="请输入物料名称" />
</el-form-item>
<el-form-item label="品牌" prop="brand">
<el-input v-model.trim="form.brand" placeholder="请输入品牌" />
</el-form-item>
<el-form-item label="规格型号" prop="model">
<el-input v-model.trim="form.model" placeholder="请输入规格型号" />
</el-form-item>
<el-form-item label="计量单位" prop="unit">
<el-input v-model.trim="form.unit" placeholder="请输入计量单位" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input type="textarea" :rows="5" v-model.trim="form.remark" placeholder="请输入备注" />
</el-form-item>
<el-form-item style="margin-top: 30px">
<el-button type="primary" @click="submitForm">提交</el-button>
<el-button @click="cancelForm">返回</el-button>
</el-form-item>
</el-form>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import PageHeader from '@/components/Pageheader/index.vue';
import { validator } from '@/utils/Reg';
import { getMaterial, updateMaterial, addMaterial } from '@/api/system/Tmaterial';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const router = useRouter();
const route = useRoute();
const formRef = ref();
const form = ref({
id: null,
materialName: '', // 物料名称
brand: '', // 联系电话
model: '', // 邮箱
unit: '', // 地址
remark: '' // 备注
});
const rules = ref({
materialName: [{ required: true, message: '请输入 物料名称', trigger: 'blur' }],
brand: [{ required: true, message: '请输入 品牌', trigger: 'blur' }],
model: [{ required: true, message: '请输入 规格型号', trigger: 'blur' }],
unit: [{ required: true, message: '请输入 计量单位', trigger: 'blur' }]
});
const userid = ref(null);
if (route.query.id) {
userid.value = route.query.id;
getMaterial(userid.value).then((res) => {
form.value = {
id: res.data.id,
materialName: res.data.materialName,
brand: res.data.brand,
model: res.data.model,
unit: res.data.unit,
remark: res.data.remark
};
});
}
// !== 提交 =============================================================================
// 提交
const submitForm = () => {
formRef.value?.validate(async (valid: boolean) => {
if (valid) {
if (userid.value) {
updateMaterial(form.value).then((res) => {
ElMessage.success('编辑成功');
cancelForm();
});
} else {
addMaterial(form.value).then((res) => {
ElMessage.success('添加成功');
cancelForm();
});
}
}
});
};
// 推出
const cancelForm = () => {
router.back();
};
</script>
<style scoped lang="scss">
.AddBuildingBox {
padding: 15px;
height: 100%;
width: 100%;
}
.AddBuildingBody {
margin-top: 20px;
display: flex;
flex-direction: column;
justify-content: center;
background-color: white;
padding: 15px;
.title {
height: 40px;
line-height: 40px;
padding-left: 20px;
background-color: rgba(255, 255, 255, 1);
color: rgba(16, 16, 16, 1);
border-bottom: 1px solid #bbbbbb;
margin-bottom: 60px;
}
.formBody {
width: 650px;
margin: 0 auto;
&:deep(.el-form-item__content, .el-select, .el-input) {
width: 350px !important;
margin-right: 10px;
.el-cascader {
width: 100%;
}
}
.el-form-item {
margin-bottom: 20px;
align-items: center;
}
.el-button {
width: 80px;
height: 35px;
margin-right: 20px;
}
}
}
</style>

View File

@@ -1,12 +1,239 @@
<template>
<div class="p-2 h-full flex flex-col">
<Pageheader title="物料管理"></Pageheader>
<div class="flex-1 color-gray flex h-full font-size-6 flex-center">系统还在维护中敬请期待...</div>
<div class="flex flex-col h-full p-2">
<pageheader></pageheader>
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
<el-form-item label="物料名称" prop="materialName">
<el-input v-model="queryParams.materialName" placeholder="请输入物料名称" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</transition>
<el-card class="flex-1" shadow="never">
<template #header>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:material:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['system:material:remove']"
>删除</el-button
>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
</template>
<el-table v-loading="loading" border :data="materialList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="物料名称" align="center" prop="materialName" />
<el-table-column label="品牌" align="center" prop="brand" />
<el-table-column label="规格型号" align="center" prop="model" />
<el-table-column label="计量单位" align="center" prop="unit" />
<el-table-column label="备注" show-overflow-tooltip align="center" prop="remark" />
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
<template #default="scope">
<el-tooltip content="修改" placement="top">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:material:edit']"></el-button>
</el-tooltip>
<el-tooltip content="删除" placement="top">
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:material:remove']"></el-button>
</el-tooltip>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
</el-card>
<!-- 添加或修改物料对话框 -->
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
<el-form ref="materialFormRef" :model="form" :rules="rules" label-width="80px">
<el-form-item label="物料名称*" prop="materialName">
<el-input v-model="form.materialName" placeholder="请输入物料名称*" />
</el-form-item>
<el-form-item label="品牌*" prop="brand">
<el-input v-model="form.brand" placeholder="请输入品牌*" />
</el-form-item>
<el-form-item label="规格型号*" prop="model">
<el-input v-model="form.model" placeholder="请输入规格型号*" />
</el-form-item>
<el-form-item label="计量单位" prop="unit">
<el-input v-model="form.unit" placeholder="请输入计量单位" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
<script setup name="Material" lang="ts">
import { listMaterial, getMaterial, delMaterial, addMaterial, updateMaterial } from '@/api/system/Tmaterial';
import { MaterialVO, MaterialQuery, MaterialForm } from '@/api/system/Tmaterial/type';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const router = useRouter();
const materialList = ref<MaterialVO[]>([]);
const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref<Array<string | number>>([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const queryFormRef = ref<ElFormInstance>();
const materialFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({
visible: false,
title: ''
});
const initFormData: MaterialForm = {
id: undefined,
materialName: undefined,
brand: undefined,
model: undefined,
unit: undefined,
remark: undefined
};
const data = reactive<PageData<MaterialForm, MaterialQuery>>({
form: { ...initFormData },
queryParams: {
pageNum: 1,
pageSize: 10,
materialName: undefined,
brand: undefined,
model: undefined,
unit: undefined
},
rules: {
id: [{ required: true, message: '物料ID不能为空', trigger: 'blur' }],
materialName: [{ required: true, message: '物料名称*不能为空', trigger: 'blur' }],
brand: [{ required: true, message: '品牌*不能为空', trigger: 'blur' }],
model: [{ required: true, message: '规格型号*不能为空', trigger: 'blur' }]
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询物料列表 */
const getList = async () => {
loading.value = true;
const res = await listMaterial(queryParams.value);
materialList.value = res.rows;
total.value = res.total;
loading.value = false;
};
/** 取消按钮 */
const cancel = () => {
reset();
dialog.visible = false;
};
/** 表单重置 */
const reset = () => {
form.value = { ...initFormData };
materialFormRef.value?.resetFields();
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
};
/** 多选框选中数据 */
const handleSelectionChange = (selection: MaterialVO[]) => {
ids.value = selection.map((item) => item.id);
single.value = selection.length != 1;
multiple.value = !selection.length;
};
/** 新增按钮操作 */
const handleAdd = () => {
router.push({
path: '/warehouse/addMaterial'
});
};
/** 修改按钮操作 */
const handleUpdate = async (row?: MaterialVO) => {
router.push({
path: '/warehouse/addMaterial',
query: {
id: row.id
}
});
};
/** 提交按钮 */
const submitForm = () => {
materialFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
if (form.value.id) {
await updateMaterial(form.value).finally(() => (buttonLoading.value = false));
} else {
await addMaterial(form.value).finally(() => (buttonLoading.value = false));
}
proxy?.$modal.msgSuccess('操作成功');
dialog.visible = false;
await getList();
}
});
};
/** 删除按钮操作 */
const handleDelete = async (row?: MaterialVO) => {
const _ids = row?.id || ids.value;
await proxy?.$modal.confirm('是否确认删除该物料?').finally(() => (loading.value = false));
await delMaterial(_ids);
proxy?.$modal.msgSuccess('删除成功');
await getList();
};
/** 导出按钮操作 */
const handleExport = () => {
proxy?.download(
'system/material/export',
{
...queryParams.value
},
`material_${new Date().getTime()}.xlsx`
);
};
onMounted(() => {
getList();
});
</script>
<style scoped lang="scss"></style>
<style lang="scss" scoped>
.el-table {
height: calc(100% - 80px);
}
</style>

View File

@@ -0,0 +1,171 @@
<template>
<div class="h-full flex flex-col p-2">
<Pageheader></Pageheader>
<div class="mainbody">
<div class="actionsbox">
<el-button @click="handlePrint" icon="Printer" type="primary">打印</el-button>
<el-button @click="cancelForm">返回</el-button>
</div>
<div class="formBody" id="print-area">
<div class="navtitle">入库单</div>
<p>单号{{ form.inNo }}</p>
<p>制单日期{{ form.inDate }}</p>
<table border>
<tbody>
<tr>
<td style="width: 60px">序号</td>
<td>物资名称</td>
<td>品牌</td>
<td>规格型号</td>
<td style="width: 40px">单位</td>
<td>供应商</td>
<td style="width: 40px">数量</td>
<td style="width: 80px">单价</td>
<td>合计</td>
<td>备注</td>
</tr>
<tr v-for="(item, index) in form.items" :key="index">
<td>{{ index + 1 }}</td>
<td>{{ item.materialName }}</td>
<td>{{ item.brand }}</td>
<td>{{ item.model }}</td>
<td>{{ item.unit }}</td>
<td>{{ form.supplierName }}</td>
<td>{{ item.stockNum }}</td>
<td>{{ item.costPrice }}</td>
<td>{{ item.totalPrice }}</td>
<td>{{ item.remark }}</td>
</tr>
<tr class="footertr">
<td>金额大写</td>
<td colspan="4">{{ convertToChineseCapital(form.totalAmount) }}</td>
<td>总价合计</td>
<td colspan="4">{{ form.totalAmount }}</td>
</tr>
</tbody>
</table>
<div class="foorter">
<div>制单人{{ form.leader }}</div>
<div>仓库{{ form.warehouseName }}</div>
<div>日期 {{ form.createTime }}</div>
<div>备注 {{ form.remark }}</div>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { getStockIn } from '@/api/system/TPurchaseIn';
import { ref } from 'vue';
import { printVueDiv } from '@/utils/print';
import { convertToChineseCapital } from '@/utils/money';
const router = useRouter();
const route = useRoute();
const form = ref({
id: null,
inNo: null, //
operateStatus: '0', //
inDate: '', // 入库日期
remark: '', // 备注
supplierName: '', // 供应商
warehouseName: '', // 仓库
leader: '', // 入库人
totalAmount: '', // 入库人
createTime: '', // 创建时间
items: [] // 联系人
});
const userid = ref(null);
function init() {
if (route.query.id) {
userid.value = route.query.id;
getStockIn(userid.value).then((res) => {
form.value = {
id: res.data.id,
leader: res.data.leader,
totalAmount: res.data.totalAmount,
operateStatus: res.data.operateStatus,
inNo: res.data.inNo,
inDate: res.data.inDate,
remark: res.data.remark,
warehouseName: res.data.warehouseName,
supplierName: res.data.supplierName,
createTime: res.data.createTime,
items: res.data.items
};
});
}
}
init();
const handlePrint = () => {
console.log('print');
// window.print();
printVueDiv('print-area', '仓库入库单');
};
// 推出
const cancelForm = () => {
router.back();
};
</script>
<style scoped lang="scss">
.mainbody {
padding: 30px;
background-color: #fff;
margin-top: 20px;
border-radius: 5px;
.actionsbox {
text-align: right;
margin-bottom: 10px;
}
.formBody {
.navtitle {
text-align: center;
height: 41px;
line-height: 14px;
color: rgba(48, 49, 51, 1);
font-size: 30px;
margin-bottom: 50px;
}
p {
line-height: 14px;
color: rgba(48, 49, 51, 1);
font-size: 16px;
margin-bottom: 10px;
}
table {
margin-top: 15px;
width: 100%;
border-collapse: collapse; /* 核心:合并边框 */
color: rgba(48, 49, 51, 1);
tr {
border: 1px solid #dddddd; /* 现代浅灰色边框 */
td {
border: 1px solid #dddddd; /* 现代浅灰色边框 */
height: 50px;
line-height: 45px;
background-color: rgba(255, 255, 255, 1);
font-size: 1rem;
text-align: center;
font-weight: 450;
}
&.footertr td {
height: 90px;
}
}
}
.foorter {
display: grid;
grid-template-columns: repeat(3, 1fr);
width: 85%;
margin: 0 auto;
gap: 30px;
margin-top: 30px;
}
}
}
</style>

View File

@@ -0,0 +1,275 @@
<template>
<div class="AddBuildingBox">
<PageHeader></PageHeader>
<el-form class="formBody" label-position="right" ref="formRef" :model="form" :rules="rules" label-width="130px">
<div class="AddBuildingBody formbox">
<div class="title">
<span>基本信息</span>
<div>
<el-button type="primary" @click="submitForm">提交</el-button>
<el-button @click="cancelForm">返回</el-button>
</div>
</div>
<div class="addBuildingFormBody">
<el-form-item label="入库日期" prop="inDate">
<el-date-picker
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
style="width: 100%"
v-model="form.inDate"
type="date"
placeholder="请选择入库日期"
/>
</el-form-item>
<el-form-item label="供应商" prop="supplierId">
<el-select v-model="form.supplierId" placeholder="请选择供应商">
<el-option v-for="(item, index) in supplierlist" :key="index" :label="item.supplierName" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="入库仓库" prop="warehouseId">
<el-select v-model="form.warehouseId" placeholder="请选择入库仓库">
<el-option v-for="(item, index) in warehouselist" :key="index" :label="item.warehouseName" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="入库状态" prop="operateStatus">
<el-radio-group v-model="form.operateStatus">
<el-radio v-for="(item, index) in com_stock_in_status" :key="index" :value="item.value">{{ item.label }}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="制单人" prop="leader">
<el-input v-model.trim="form.leader" placeholder="请输入制单人" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input type="textarea" :rows="5" v-model.trim="form.remark" placeholder="请输入备注" />
</el-form-item>
</div>
</div>
<div class="AddBuildingBody">
<div style="margin-bottom: 20px">
<span>详细入库列表</span>
<material :userid="itemsid" returnvalue="*" @change="handleChangeitem" :is-multiple="true" ref="materialRef">
<template #default>
<el-button @click="() => materialRef.open()" style="margin-left: 20px" icon="Plus" type="primary">添加</el-button>
</template>
</material>
</div>
<div class="addBuildingFormBody">
<el-table :data="form.items">
<el-table-column label="物料名称" align="center" prop="materialName" />
<el-table-column label="品牌" align="center" prop="brand" />
<el-table-column label="规格型号" align="center" prop="model" />
<el-table-column label="单位" align="center" prop="unit" />
<el-table-column label="成本价" align="center" prop="inNo">
<template #default="scope">
<el-input v-model.trim.number="scope.row.costPrice" placeholder="请输入"></el-input>
</template>
</el-table-column>
<el-table-column label="数量" align="center" prop="inNo">
<template #default="scope">
<el-input v-model.trim.number="scope.row.inNum" placeholder="请输入"></el-input>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark">
<template #default="scope">
{{ scope.row.remark ? scope.row.remark : '-------' }}
</template>
</el-table-column>
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button type="primary" link @click="handleDeleteRow(scope.row.id)">删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
</div>
</el-form>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import material from '@/components/Holder/material.vue';
import PageHeader from '@/components/Pageheader/index.vue';
import { listSupplier } from '@/api/system/Tsupplier';
import { listWarehouse } from '@/api/system/Twarehouse';
import { addStockIn, getStockIn, updateStockIn } from '@/api/system/TPurchaseIn';
import { MaterialVO } from '@/api/system/Tmaterial/type';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { com_stock_in_status } = toRefs<any>(proxy?.useDict('com_stock_in_status'));
interface tabletype extends MaterialVO {
costPrice?: number; // 成本价
inNum?: number; // 成本价
}
const router = useRouter();
const route = useRoute();
const materialRef = ref();
const formRef = ref();
const form = ref({
id: null,
inNo: null, //
operateStatus: '0', //
inDate: '', // 入库日期
supplierId: '', // 供应商
warehouseId: '', // 入库仓库
leader: '', // 备注
remark: '', // 备注
items: [] as tabletype[] // 联系人
});
const itemsid = computed(() => {
return form.value.items.map((item) => item.id).join(',');
});
const rules = ref({
inDate: [{ required: true, message: '请选择 入库日期', trigger: 'blur' }],
supplierId: [{ required: true, message: '请选择 供应商', trigger: 'blur' }],
leader: [{ required: true, message: '请输入制单人', trigger: 'blur' }],
warehouseId: [{ required: true, message: '请选择 入库仓库', trigger: 'blur' }]
});
const userid = ref(null);
const warehouselist = ref([]);
const supplierlist = ref([]);
function init() {
listWarehouse().then((res) => {
warehouselist.value = res.rows;
});
listSupplier().then((res) => {
supplierlist.value = res.rows;
});
if (route.query.id) {
userid.value = route.query.id;
getStockIn(userid.value).then((res) => {
form.value = {
id: res.data.id,
leader: res.data.leader,
operateStatus: res.data.operateStatus,
inNo: res.data.inNo,
inDate: res.data.inDate,
supplierId: res.data.supplierId,
warehouseId: res.data.warehouseId,
remark: res.data.remark,
items: res.data.items
};
});
}
}
init();
function handleChangeitem(row: MaterialVO[]) {
const arr = row
.map((item) => {
if (!item.id) return null;
const find = form.value.items.find((i) => i.id === item.id);
if (find || form.value.items.length <= 0) {
return {
...item,
materialId: item.id,
...find
};
} else {
return {
...item,
materialId: item.id
};
}
})
.filter((item) => item !== null);
form.value.items = arr;
}
function handleDeleteRow(id: string) {
const findindex = form.value.items.findIndex((item) => item.id === id);
if (findindex !== -1) {
form.value.items.splice(findindex, 1);
}
}
// !== 提交 =============================================================================
// 提交
const submitForm = () => {
formRef.value?.validate(async (valid: boolean) => {
if (valid) {
// form.value.items = form.value.items.map((itme) => {
// return {
// 'materialId': itme.id,
// 'costPrice': itme.costPrice,
// 'inNum': itme.inNum
// };
// });
if (userid.value) {
updateStockIn(form.value).then(() => {
ElMessage.success('编辑成功');
cancelForm();
});
} else {
addStockIn(form.value).then(() => {
ElMessage.success('添加成功');
cancelForm();
});
}
}
});
};
// 推出
const cancelForm = () => {
router.back();
};
</script>
<style scoped lang="scss">
.AddBuildingBox {
padding: 15px;
height: 100%;
width: 100%;
}
.AddBuildingBody {
margin-top: 20px;
display: flex;
flex-direction: column;
justify-content: center;
background-color: white;
padding: 15px;
.title {
height: 40px;
line-height: 40px;
padding-left: 20px;
background-color: rgba(255, 255, 255, 1);
color: rgba(16, 16, 16, 1);
margin-bottom: 60px;
display: flex;
justify-content: space-between;
align-items: center;
}
&.formbox .addBuildingFormBody {
width: 550px;
margin: 0 auto;
}
.addBuildingFormBody {
width: 100%;
}
.formBody {
width: 650px;
margin: 0 auto;
&:deep(.el-form-item__content, .el-date-picker, .el-select, .el-input) {
width: 550px !important;
margin-right: 10px;
}
.el-form-item {
margin-bottom: 20px;
align-items: center;
}
.el-button {
width: 80px;
height: 35px;
margin-right: 20px;
}
}
}
</style>

View File

@@ -1,12 +1,228 @@
<template>
<div class="p-2 h-full flex flex-col">
<Pageheader title="采购入库管理"></Pageheader>
<div class="flex-1 color-gray flex h-full font-size-6 flex-center">系统还在维护中敬请期待...</div>
<div class="h-full flex flex-col p-2">
<pageheader></pageheader>
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
<el-form-item label="入库单号" prop="inNo">
<el-input v-model="queryParams.inNo" placeholder="请输入入库单号" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</transition>
<el-card class="flex-1" shadow="never">
<template #header>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:stockIn:add']">新增</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
</template>
<el-table v-loading="loading" border :data="stockInList" @selection-change="handleSelectionChange">
<el-table-column type="selection" flexd width="55" align="center" />
<el-table-column label="入库单号" flexd align="center" prop="inNo" />
<el-table-column label="入库日期" width="100" align="center" prop="inDate" />
<el-table-column label="供应商" align="center" prop="supplierName" />
<el-table-column label="入库仓库" align="center" prop="warehouseName" />
<el-table-column label="操作状态" width="80" align="center" prop="operateStatus">
<template #default="scope">
<dict-tag :options="com_stock_in_status" :value="scope.row.operateStatus"></dict-tag>
</template>
</el-table-column>
<el-table-column label="制单人" align="center" prop="leader" />
<el-table-column label="备注" show-overflow-tooltip align="center" prop="remark" />
<el-table-column label="操作" width="200" align="center" fixed="right" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="primary" @click="handleMain(scope.row)" v-hasPermi="['system:stockIn:edit']">查看清单</el-button>
<el-button link type="primary" @click="handleUpdate(scope.row)" v-hasPermi="['system:stockIn:edit']">修改</el-button>
<el-button link type="primary" @click="handleDelete(scope.row)" v-hasPermi="['system:stockIn:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
</el-card>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
<script setup name="StockIn" lang="ts">
import { listStockIn, getStockIn, delStockIn, addStockIn, updateStockIn } from '@/api/system/TPurchaseIn';
import { StockInVO, StockInQuery, StockInForm } from '@/api/system/TPurchaseIn/type';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { com_stock_in_status } = toRefs<any>(proxy?.useDict('com_stock_in_status'));
const stockInList = ref<StockInVO[]>([]);
const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref<Array<string | number>>([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const queryFormRef = ref<ElFormInstance>();
const stockInFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({
visible: false,
title: ''
});
const initFormData: StockInForm = {
id: undefined,
inNo: undefined,
inDate: undefined,
supplierId: undefined,
warehouseId: undefined,
operateStatus: undefined,
leader: undefined,
remark: undefined
};
const data = reactive<PageData<StockInForm, StockInQuery>>({
form: { ...initFormData },
queryParams: {
pageNum: 1,
pageSize: 10,
inNo: undefined,
inDate: undefined,
supplierId: undefined,
warehouseId: undefined,
operateStatus: undefined,
leader: undefined,
params: {}
},
rules: {
id: [{ required: true, message: '主键不能为空', trigger: 'blur' }],
inNo: [{ required: true, message: '入库单号*不能为空', trigger: 'blur' }],
inDate: [{ required: true, message: '入库日期*不能为空', trigger: 'blur' }],
supplierId: [{ required: true, message: '供应商id*不能为空', trigger: 'blur' }],
warehouseId: [{ required: true, message: '入库仓库id*不能为空', trigger: 'blur' }]
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询入库主列表 */
const getList = async () => {
loading.value = true;
const res = await listStockIn(queryParams.value);
stockInList.value = res.rows;
total.value = res.total;
loading.value = false;
};
/** 取消按钮 */
const cancel = () => {
reset();
dialog.visible = false;
};
/** 表单重置 */
const reset = () => {
form.value = { ...initFormData };
stockInFormRef.value?.resetFields();
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
};
/** 多选框选中数据 */
const handleSelectionChange = (selection: StockInVO[]) => {
ids.value = selection.map((item) => item.id);
single.value = selection.length != 1;
multiple.value = !selection.length;
};
const router = useRouter();
/** 新增按钮操作 */
const handleAdd = () => {
router.push({
path: '/warehouse/addPurchaseIn'
});
};
/** 修改按钮操作 */
const handleUpdate = async (row?: StockInVO) => {
router.push({
path: '/warehouse/addPurchaseIn',
query: {
id: row.id
}
});
};
/** 修改按钮操作 */
const handleMain = async (row?: StockInVO) => {
router.push({
path: '/warehouse/purchaseInMain',
query: {
id: row.id
}
});
};
/** 提交按钮 */
const submitForm = () => {
stockInFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
if (form.value.id) {
await updateStockIn(form.value).finally(() => (buttonLoading.value = false));
} else {
await addStockIn(form.value).finally(() => (buttonLoading.value = false));
}
proxy?.$modal.msgSuccess('操作成功');
dialog.visible = false;
await getList();
}
});
};
/** 删除按钮操作 */
const handleDelete = async (row?: StockInVO) => {
const _ids = row?.id || ids.value;
await proxy?.$modal.confirm('是否确认删除?').finally(() => (loading.value = false));
await delStockIn(_ids);
proxy?.$modal.msgSuccess('删除成功');
await getList();
};
/** 导出按钮操作 */
const handleExport = () => {
proxy?.download(
'system/stockIn/export',
{
...queryParams.value
},
`stockIn_${new Date().getTime()}.xlsx`
);
};
onMounted(() => {
getList();
});
</script>
<style scoped lang="scss"></style>
<style lang="scss" scoped>
.el-table {
height: calc(100% - 80px);
}
</style>

View File

@@ -0,0 +1,155 @@
<template>
<div class="AddBuildingBox">
<PageHeader></PageHeader>
<div class="AddBuildingBody">
<div class="title">基本信息</div>
<div class="addBuildingFormBody">
<el-form class="formBody" label-position="right" ref="formRef" :model="form" :rules="rules" label-width="130px">
<el-form-item label="供应商名称" prop="supplierName">
<el-input v-model.trim="form.supplierName" placeholder="请输入供应商名称" />
</el-form-item>
<el-form-item label="联系人" prop="contactPerson">
<el-input v-model.trim="form.contactPerson" placeholder="请输入联系人" />
</el-form-item>
<el-form-item label="联系电话" prop="contactPhone">
<el-input v-model.trim="form.contactPhone" placeholder="请输入联系电话" />
</el-form-item>
<el-form-item label="邮箱" prop="email">
<el-input v-model.trim="form.email" placeholder="请输入邮箱" />
</el-form-item>
<el-form-item label="地址" prop="address">
<el-input v-model.trim="form.address" placeholder="请输入地址" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input type="textarea" :rows="5" v-model.trim="form.remark" placeholder="请输入备注" />
</el-form-item>
<el-form-item style="margin-top: 30px">
<el-button type="primary" @click="submitForm">提交</el-button>
<el-button @click="cancelForm">返回</el-button>
</el-form-item>
</el-form>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import PageHeader from '@/components/Pageheader/index.vue';
import { getSupplier, updateSupplier, addSupplier } from '@/api/system/Tsupplier';
import { validator } from '@/utils/Reg';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const router = useRouter();
const route = useRoute();
const formRef = ref();
const form = ref({
id: null,
supplierName: '', // 供应商名称
contactPhone: '', // 联系电话
email: '', // 邮箱
address: '', // 地址
remark: '', // 备注
contactPerson: '' // 联系人
});
const rules = ref({
supplierName: [{ required: true, message: '请输入供应商名称', trigger: 'blur' }],
contactPhone: [{ required: true, message: '请输入 联系电话', trigger: 'blur' }],
contactPerson: [{ required: true, message: '请输入 联系人', trigger: 'blur' }],
email: [
{ required: true, message: '请输入 邮箱', trigger: 'blur' },
{
validator: (_, value) => validator(value, 'email'),
required: false,
message: '请输入正确的邮箱格式',
trigger: 'blur'
}
]
});
const userid = ref(null);
if (route.query.id) {
userid.value = route.query.id;
getSupplier(userid.value).then((res) => {
form.value = {
id: res.data.id,
supplierName: res.data.supplierName,
contactPhone: res.data.contactPhone,
email: res.data.email,
address: res.data.address,
remark: res.data.remark,
contactPerson: res.data.contactPerson
};
});
}
// !== 提交 =============================================================================
// 提交
const submitForm = () => {
formRef.value?.validate(async (valid: boolean) => {
if (valid) {
if (userid.value) {
updateSupplier(form.value).then((res) => {
ElMessage.success('编辑成功');
cancelForm();
});
} else {
addSupplier(form.value).then((res) => {
ElMessage.success('添加成功');
cancelForm();
});
}
}
});
};
// 推出
const cancelForm = () => {
router.back();
};
</script>
<style scoped lang="scss">
.AddBuildingBox {
padding: 15px;
height: 100%;
width: 100%;
}
.AddBuildingBody {
margin-top: 20px;
display: flex;
flex-direction: column;
justify-content: center;
background-color: white;
padding: 15px;
.title {
height: 40px;
line-height: 40px;
padding-left: 20px;
background-color: rgba(255, 255, 255, 1);
color: rgba(16, 16, 16, 1);
border-bottom: 1px solid #bbbbbb;
margin-bottom: 60px;
}
.formBody {
width: 650px;
margin: 0 auto;
&:deep(.el-form-item__content, .el-select, .el-input) {
width: 350px !important;
margin-right: 10px;
.el-cascader {
width: 100%;
}
}
.el-form-item {
margin-bottom: 20px;
align-items: center;
}
.el-button {
width: 80px;
height: 35px;
margin-right: 20px;
}
}
}
</style>

View File

@@ -1,12 +1,247 @@
<template>
<div class="p-2 h-full flex flex-col">
<Pageheader title="供应商管理"></Pageheader>
<div class="flex-1 color-gray flex h-full font-size-6 flex-center">系统还在维护中敬请期待...</div>
<div class="flex flex-col h-full p-2">
<pageheader></pageheader>
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" label-width="100px" :model="queryParams" :inline="true">
<el-form-item label="供应商名称" prop="supplierName">
<el-input v-model="queryParams.supplierName" placeholder="请输入供应商名称" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</transition>
<el-card class="flex-1" shadow="never">
<template #header>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:supplier:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['system:supplier:remove']"
>删除</el-button
>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
</template>
<el-table v-loading="loading" border :data="supplierList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="供应商名称" align="center" prop="supplierName" />
<el-table-column label="联系人" align="center" prop="contactPerson" />
<el-table-column label="联系电话" align="center" prop="contactPhone" />
<el-table-column label="邮箱" align="center" prop="email" />
<el-table-column label="地址" align="center" prop="address" />
<el-table-column label="备注" show-overflow-tooltip align="center" prop="remark" />
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
<template #default="scope">
<el-tooltip content="修改" placement="top">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:supplier:edit']"></el-button>
</el-tooltip>
<el-tooltip content="删除" placement="top">
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:supplier:remove']"></el-button>
</el-tooltip>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
</el-card>
<!-- 添加或修改供应商对话框 -->
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
<el-form ref="supplierFormRef" :model="form" :rules="rules" label-width="80px">
<el-form-item label="供应商名称*" prop="supplierName">
<el-input v-model="form.supplierName" placeholder="请输入供应商名称*" />
</el-form-item>
<el-form-item label="联系人*" prop="contactPerson">
<el-input v-model="form.contactPerson" placeholder="请输入联系人*" />
</el-form-item>
<el-form-item label="联系电话*" prop="contactPhone">
<el-input v-model="form.contactPhone" placeholder="请输入联系电话*" />
</el-form-item>
<el-form-item label="邮箱" prop="email">
<el-input v-model="form.email" placeholder="请输入邮箱" />
</el-form-item>
<el-form-item label="地址" prop="address">
<el-input v-model="form.address" placeholder="请输入地址" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
<script setup name="Supplier" lang="ts">
import { listSupplier, getSupplier, delSupplier, addSupplier, updateSupplier } from '@/api/system/Tsupplier/index';
import { SupplierVO, SupplierQuery, SupplierForm } from '@/api/system/Tsupplier/type';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const supplierList = ref<SupplierVO[]>([]);
const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref<Array<string | number>>([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const queryFormRef = ref<ElFormInstance>();
const supplierFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({
visible: false,
title: ''
});
const initFormData: SupplierForm = {
id: undefined,
supplierName: undefined,
contactPerson: undefined,
contactPhone: undefined,
email: undefined,
address: undefined,
remark: undefined
};
const data = reactive<PageData<SupplierForm, SupplierQuery>>({
form: { ...initFormData },
queryParams: {
pageNum: 1,
pageSize: 10,
supplierName: undefined,
contactPerson: undefined,
contactPhone: undefined,
email: undefined,
address: undefined,
params: {}
},
rules: {
id: [{ required: true, message: '主键ID不能为空', trigger: 'blur' }],
supplierName: [{ required: true, message: '供应商名称*不能为空', trigger: 'blur' }],
contactPerson: [{ required: true, message: '联系人*不能为空', trigger: 'blur' }],
contactPhone: [{ required: true, message: '联系电话*不能为空', trigger: 'blur' }]
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询供应商列表 */
const getList = async () => {
loading.value = true;
const res = await listSupplier(queryParams.value);
supplierList.value = res.rows;
total.value = res.total;
loading.value = false;
};
/** 取消按钮 */
const cancel = () => {
reset();
dialog.visible = false;
};
/** 表单重置 */
const reset = () => {
form.value = { ...initFormData };
supplierFormRef.value?.resetFields();
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
};
/** 多选框选中数据 */
const handleSelectionChange = (selection: SupplierVO[]) => {
ids.value = selection.map((item) => item.id);
single.value = selection.length != 1;
multiple.value = !selection.length;
};
const router = useRouter();
/** 新增按钮操作 */
const handleAdd = () => {
router.push({
path: '/warehouse/addSupplier'
});
};
/** 修改按钮操作 */
const handleUpdate = async (row?: SupplierVO) => {
router.push({
path: '/warehouse/addSupplier',
query: {
id: row.id
}
});
};
/** 提交按钮 */
const submitForm = () => {
supplierFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
if (form.value.id) {
await updateSupplier(form.value).finally(() => (buttonLoading.value = false));
} else {
await addSupplier(form.value).finally(() => (buttonLoading.value = false));
}
proxy?.$modal.msgSuccess('操作成功');
dialog.visible = false;
await getList();
}
});
};
/** 删除按钮操作 */
const handleDelete = async (row?: SupplierVO) => {
const _ids = row?.id || ids.value;
await proxy?.$modal.confirm('是否确认删除供应商编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
await delSupplier(_ids);
proxy?.$modal.msgSuccess('删除成功');
await getList();
};
/** 导出按钮操作 */
const handleExport = () => {
proxy?.download(
'system/supplier/export',
{
...queryParams.value
},
`supplier_${new Date().getTime()}.xlsx`
);
};
onMounted(() => {
getList();
});
</script>
<style scoped lang="scss"></style>
<style lang="scss" scoped>
.el-table {
height: calc(100% - 80px);
}
</style>

View File

@@ -0,0 +1,166 @@
<template>
<div class="AddBuildingBox">
<PageHeader></PageHeader>
<div class="AddBuildingBody">
<div class="title">基本信息</div>
<div class="addBuildingFormBody">
<el-form class="formBody" label-position="right" ref="formRef" :model="form" :rules="rules" label-width="130px">
<el-form-item label="仓库名称" prop="warehouseName">
<el-input v-model.trim="form.warehouseName" placeholder="请输入仓库名称" />
</el-form-item>
<el-form-item label="联系人" prop="contactPerson">
<el-input v-model.trim="form.contactPerson" placeholder="请输入联系人" />
</el-form-item>
<el-form-item label="联系电话" prop="contactPhone">
<el-input v-model.trim="form.contactPhone" placeholder="请输入联系电话" />
</el-form-item>
<el-form-item label="地址" prop="address">
<el-input v-model.trim="form.address" placeholder="请输入地址" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input type="textarea" :rows="5" v-model.trim="form.remark" placeholder="请输入备注" />
</el-form-item>
<el-form-item style="margin-top: 30px">
<el-button type="primary" @click="submitForm">提交</el-button>
<el-button @click="cancelForm">返回</el-button>
</el-form-item>
</el-form>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import PageHeader from '@/components/Pageheader/index.vue';
import { getCommunitylistAPI } from '@/api/system/community';
import { addWarehouse, getWarehouse, updateWarehouse } from '@/api/system/Twarehouse';
import { validator } from '@/utils/Reg';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const router = useRouter();
const route = useRoute();
const formRef = ref();
const form = ref({
id: null,
warehouseName: '', // 供应商名称
villageId: Number(localStorage.getItem('villageid')), // 邮箱
contactPhone: '', // 联系电话
address: '', // 地址
remark: '', // 备注
contactPerson: '' // 联系人
});
const rules = ref({
warehouseName: [{ required: true, message: '请输入 仓库名称', trigger: 'blur' }],
contactPhone: [
{ required: true, message: '请输入 联系电话', trigger: 'blur' },
{
validator: (_, value) => validator(value, 'phone'),
message: '请输入正确的电话号码',
trigger: 'blur'
}
],
contactPerson: [{ required: true, message: '请输入 联系人姓名', trigger: 'blur' }],
villageId: [{ required: true, message: '请选择 仓库归属', trigger: 'blur' }]
});
const userid = ref(null);
// 小区列表
const cummunitylist = ref([]);
function init() {
getCommunitylistAPI().then((res) => {
cummunitylist.value = res.rows;
});
if (route.query.id) {
userid.value = route.query.id;
getWarehouse(userid.value).then((res) => {
form.value = {
id: res.data.id,
warehouseName: res.data.warehouseName,
villageId: res.data.villageId,
contactPhone: res.data.contactPhone,
address: res.data.address,
remark: res.data.remark,
contactPerson: res.data.contactPerson
};
});
}
}
init();
// !== 提交 =============================================================================
// 提交
const submitForm = () => {
formRef.value?.validate(async (valid: boolean) => {
if (valid) {
if (userid.value) {
updateWarehouse(form.value).then((res) => {
ElMessage.success('编辑成功');
cancelForm();
});
} else {
addWarehouse(form.value).then((res) => {
ElMessage.success('添加成功');
cancelForm();
});
}
}
});
};
// 推出
const cancelForm = () => {
router.push({
path: '/warehouse/warehouse'
});
};
</script>
<style scoped lang="scss">
.AddBuildingBox {
padding: 15px;
height: 100%;
width: 100%;
}
.AddBuildingBody {
margin-top: 20px;
display: flex;
flex-direction: column;
justify-content: center;
background-color: white;
padding: 15px;
.title {
height: 40px;
line-height: 40px;
padding-left: 20px;
background-color: rgba(255, 255, 255, 1);
color: rgba(16, 16, 16, 1);
border-bottom: 1px solid #bbbbbb;
margin-bottom: 60px;
}
.formBody {
width: 500px;
margin: 0 auto;
&:deep(.el-form-item__content, .el-select, .el-input) {
width: 350px !important;
margin-right: 10px;
.el-cascader {
width: 100%;
}
}
.el-form-item {
margin-bottom: 20px;
align-items: center;
}
.el-button {
width: 80px;
height: 35px;
margin-right: 20px;
}
}
}
</style>

View File

@@ -1,12 +1,262 @@
<template>
<div class="p-2 h-full flex flex-col">
<Pageheader title="账单管理"></Pageheader>
<div class="flex-1 color-gray flex h-full font-size-6 flex-center">系统还在维护中敬请期待...</div>
<div class="h-full flex flex-col p-2">
<pageheader></pageheader>
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" label-width="100px" :model="queryParams" :inline="true">
<el-form-item label="仓库名称" prop="warehouseName">
<el-input v-model="queryParams.warehouseName" placeholder="请输入仓库名称" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</transition>
<el-card class="flex-1" shadow="never">
<template #header>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:warehouse:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['system:warehouse:remove']"
>删除</el-button
>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
</template>
<el-table v-loading="loading" border :data="warehouseList" @selection-change="handleSelectionChange">
<el-table-column type="selection" align="center" />
<el-table-column label="仓库名称" align="center" prop="warehouseName" />
<el-table-column label="联系人" width="100" align="center" prop="contactPerson" />
<el-table-column label="联系电话" width="120" align="center" prop="contactPhone" />
<el-table-column label="地址" align="center" prop="address" />
<el-table-column label="状态" width="150" align="center" prop="status">
<template #default="scope">
<el-switch
@change="(val: string) => handleChangeSwitch(val, scope.row)"
v-model="scope.row.status"
active-value="0"
active-text="启用"
inactive-value="1"
inactive-text="禁用"
></el-switch>
</template>
</el-table-column>
<el-table-column label="备注" width="80" align="center" prop="remark" show-overflow-tooltip />
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:warehouse:edit']">修改</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:warehouse:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
</el-card>
<!-- 添加或修改仓库对话框 -->
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
<el-form ref="warehouseFormRef" :model="form" :rules="rules" label-width="80px">
<el-form-item label="仓库名称*" prop="warehouseName">
<el-input v-model="form.warehouseName" placeholder="请输入仓库名称*" />
</el-form-item>
<el-form-item label="仓库归属id*" prop="villageId">
<el-input v-model="form.villageId" placeholder="请输入仓库归属id*" />
</el-form-item>
<el-form-item label="联系人*" prop="contactPerson">
<el-input v-model="form.contactPerson" placeholder="请输入联系人*" />
</el-form-item>
<el-form-item label="联系电话*" prop="contactPhone">
<el-input v-model="form.contactPhone" placeholder="请输入联系电话*" />
</el-form-item>
<el-form-item label="地址" prop="address">
<el-input v-model="form.address" placeholder="请输入地址" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
<script setup name="Warehouse" lang="ts">
import { listWarehouse, getWarehouse, delWarehouse, addWarehouse, updateWarehouse } from '@/api/system/Twarehouse/index';
import { WarehouseVO, WarehouseQuery, WarehouseForm } from '@/api/system/Twarehouse/type';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const warehouseList = ref<WarehouseVO[]>([]);
const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref<Array<string | number>>([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const queryFormRef = ref<ElFormInstance>();
const warehouseFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({
visible: false,
title: ''
});
const initFormData: WarehouseForm = {
id: undefined,
warehouseName: undefined,
villageId: undefined,
contactPerson: undefined,
contactPhone: undefined,
address: undefined,
status: undefined,
remark: undefined
};
const data = reactive<PageData<WarehouseForm, WarehouseQuery>>({
form: { ...initFormData },
queryParams: {
pageNum: 1,
pageSize: 10,
warehouseName: undefined,
villageId: undefined,
contactPerson: undefined,
contactPhone: undefined,
address: undefined,
status: undefined,
params: {}
},
rules: {
id: [{ required: true, message: '仓库ID不能为空', trigger: 'blur' }],
warehouseName: [{ required: true, message: '仓库名称*不能为空', trigger: 'blur' }],
villageId: [{ required: true, message: '仓库归属id*不能为空', trigger: 'blur' }],
contactPerson: [{ required: true, message: '联系人*不能为空', trigger: 'blur' }],
contactPhone: [{ required: true, message: '联系电话*不能为空', trigger: 'blur' }],
status: [{ required: true, message: '状态 0-启用 1-禁用不能为空', trigger: 'change' }]
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询仓库列表 */
const getList = async () => {
loading.value = true;
const res = await listWarehouse(queryParams.value);
warehouseList.value = res.rows;
total.value = res.total;
loading.value = false;
};
/** 取消按钮 */
const cancel = () => {
reset();
dialog.visible = false;
};
/** 表单重置 */
const reset = () => {
form.value = { ...initFormData };
warehouseFormRef.value?.resetFields();
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
};
/** 多选框选中数据 */
const handleSelectionChange = (selection: WarehouseVO[]) => {
ids.value = selection.map((item) => item.id);
single.value = selection.length != 1;
multiple.value = !selection.length;
};
const router = useRouter();
/** 新增按钮操作 */
const handleAdd = () => {
router.push({
path: '/warehouse/addWarehouse'
});
};
/** 修改按钮操作 */
const handleUpdate = async (row?: WarehouseVO) => {
router.push({
path: '/warehouse/addWarehouse',
query: {
id: row.id
}
});
};
/** 提交按钮 */
const submitForm = () => {
warehouseFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
if (form.value.id) {
await updateWarehouse(form.value).finally(() => (buttonLoading.value = false));
} else {
await addWarehouse(form.value).finally(() => (buttonLoading.value = false));
}
proxy?.$modal.msgSuccess('操作成功');
dialog.visible = false;
await getList();
}
});
};
/** 删除按钮操作 */
const handleDelete = async (row?: WarehouseVO) => {
const _ids = row?.id || ids.value;
await proxy?.$modal.confirm('是否确认删除该仓库?').finally(() => (loading.value = false));
await delWarehouse(_ids);
proxy?.$modal.msgSuccess('删除成功');
await getList();
};
// 切换状态
const handleChangeSwitch = (val: string, row) => {
updateWarehouse(row)
.then(() => {
ElMessage.success('修改状态成功');
})
.catch(() => {
const index = warehouseList.value.findIndex((item) => item.id === row.id);
if (index !== -1) {
warehouseList.value[index].status = val === '0' ? '1' : '0';
}
ElMessage.error('修改状态失败,请稍后再试');
});
};
onMounted(() => {
getList();
});
</script>
<style scoped lang="scss"></style>
<style lang="scss" scoped>
.el-table {
height: calc(100% - 80px);
}
</style>