新增:配件管理模块
This commit is contained in:
102
src/api/tower/part/goods/index.ts
Normal file
102
src/api/tower/part/goods/index.ts
Normal file
@@ -0,0 +1,102 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { Goods, GoodsParam } from '@/api/tower/part/goods/model';
|
||||
/**
|
||||
* 分页查询仓库
|
||||
*/
|
||||
export async function pageGoods(params: GoodsParam) {
|
||||
const res = await request.get<ApiResult<PageResult<Goods>>>(
|
||||
'/tower/tower-part-goods/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询仓库列表
|
||||
*/
|
||||
export async function listGoods(params?: GoodsParam) {
|
||||
const res = await request.get<ApiResult<Goods[]>>('/tower/tower-part-goods', {
|
||||
params
|
||||
});
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加仓库
|
||||
*/
|
||||
export async function addGoods(data: Goods) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
'/tower/tower-part-goods',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改仓库
|
||||
*/
|
||||
export async function updateGoods(data: Goods) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
'/tower/tower-part-goods',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定仓库
|
||||
*/
|
||||
export async function bindGoods(data: Goods) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
'/tower/tower-part-goods/bind',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除仓库
|
||||
*/
|
||||
export async function removeGoods(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
'/tower/tower-part-goods/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除仓库
|
||||
*/
|
||||
export async function removeBatchGoods(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
'/tower/tower-part-goods/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
30
src/api/tower/part/goods/model/index.ts
Normal file
30
src/api/tower/part/goods/model/index.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
export interface Goods {
|
||||
goodsId?: number;
|
||||
goodsName?: string;
|
||||
goodsCode?: string;
|
||||
category?: string;
|
||||
specs?: string;
|
||||
position?: string;
|
||||
stock?: number;
|
||||
stockMoney?: number;
|
||||
price?: number;
|
||||
salePrice?: number;
|
||||
stockMin?: number;
|
||||
stockLower?: boolean;
|
||||
status?: number;
|
||||
userId?: number;
|
||||
comments?: string;
|
||||
sortNumber?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索条件
|
||||
*/
|
||||
export interface GoodsParam extends PageParam {
|
||||
goodsId?: number;
|
||||
goodsCode?: string;
|
||||
status?: number;
|
||||
keywords?: string;
|
||||
}
|
||||
@@ -23,6 +23,32 @@ export interface SecurityRecord {
|
||||
accessoryNo?: string;
|
||||
accessorySpecs?: string;
|
||||
accessoryModel?: string;
|
||||
before1?: string;
|
||||
before2?: string;
|
||||
before3?: string;
|
||||
before4?: string;
|
||||
before5?: string;
|
||||
before6?: string;
|
||||
before7?: string;
|
||||
before8?: string;
|
||||
before9?: string;
|
||||
before10?: string;
|
||||
before11?: string;
|
||||
before12?: string;
|
||||
before13?: string;
|
||||
after1?: string;
|
||||
after2?: string;
|
||||
after3?: string;
|
||||
after4?: string;
|
||||
after5?: string;
|
||||
after6?: string;
|
||||
after7?: string;
|
||||
after8?: string;
|
||||
after9?: string;
|
||||
after10?: string;
|
||||
after11?: string;
|
||||
after12?: string;
|
||||
after13?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -190,10 +190,10 @@
|
||||
hideInSetting: true,
|
||||
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
},
|
||||
{
|
||||
title: '配件编号',
|
||||
dataIndex: 'accessoryNo'
|
||||
},
|
||||
// {
|
||||
// title: '配件编号',
|
||||
// dataIndex: 'accessoryNo'
|
||||
// },
|
||||
{
|
||||
title: '生产厂家',
|
||||
dataIndex: 'accessoryName'
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,17 +20,11 @@
|
||||
</template>
|
||||
<span>新建</span>
|
||||
</a-button>
|
||||
<ProjectSelectModel
|
||||
:placeholder="`请选择项目`"
|
||||
v-model:value="projectName"
|
||||
@done="chooseProject"
|
||||
/>
|
||||
<!-- <a-radio-group v-model:value="searchStatus" @change="onStatus">-->
|
||||
<!-- <a-radio-button value="0">正常</a-radio-button>-->
|
||||
<!-- <a-radio-button value="1">待修</a-radio-button>-->
|
||||
<!-- <a-radio-button value="2">异常已修</a-radio-button>-->
|
||||
<!-- <a-radio-button value="3">异常未修</a-radio-button>-->
|
||||
<!-- </a-radio-group>-->
|
||||
<!-- <ProjectSelectModel-->
|
||||
<!-- :placeholder="`请选择项目`"-->
|
||||
<!-- v-model:value="projectName"-->
|
||||
<!-- @done="chooseProject"-->
|
||||
<!-- />-->
|
||||
<a-range-picker
|
||||
v-model:value="dateRange"
|
||||
@change="onRange"
|
||||
@@ -107,32 +101,13 @@
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
title: '配件编号',
|
||||
dataIndex: 'accessoryNo',
|
||||
key: 'accessoryNo'
|
||||
title: '保养编号',
|
||||
dataIndex: 'securityCode',
|
||||
key: 'securityCode',
|
||||
width: 200
|
||||
},
|
||||
{
|
||||
title: '生产厂家',
|
||||
dataIndex: 'accessoryName',
|
||||
key: 'accessoryName'
|
||||
},
|
||||
{
|
||||
title: '配件分类',
|
||||
dataIndex: 'accessoryCategory',
|
||||
key: 'accessoryCategory'
|
||||
},
|
||||
{
|
||||
title: '适用设备型号',
|
||||
dataIndex: 'accessoryModel',
|
||||
key: 'accessoryModel'
|
||||
},
|
||||
{
|
||||
title: '配件规格',
|
||||
dataIndex: 'accessorySpecs',
|
||||
key: 'accessorySpecs'
|
||||
},
|
||||
{
|
||||
title: '保养内容',
|
||||
title: '备注信息',
|
||||
dataIndex: 'comments',
|
||||
key: 'comments'
|
||||
},
|
||||
@@ -143,7 +118,7 @@
|
||||
width: 180
|
||||
},
|
||||
{
|
||||
title: '保养人',
|
||||
title: '操作人',
|
||||
dataIndex: 'userId',
|
||||
key: 'userId',
|
||||
width: 180
|
||||
@@ -160,10 +135,8 @@
|
||||
// 当前编辑数据
|
||||
const current = ref<SecurityRecord | null>(null);
|
||||
const searchText = ref('');
|
||||
const searchStatus = ref('');
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
const projectName = ref('');
|
||||
|
||||
// 日期范围选择
|
||||
const dateRange = ref<[string, string]>(['', '']);
|
||||
|
||||
@@ -29,12 +29,11 @@
|
||||
@done="chooseProject"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="所在地" name="address">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入项目地址"
|
||||
v-model:value="form.address"
|
||||
/>
|
||||
<a-form-item label="设备类型" name="type">
|
||||
<a-radio-group v-model:value="form.type">
|
||||
<a-radio :value="0">塔式起重机</a-radio>
|
||||
<a-radio :value="1">施工电梯</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item label="现场图片" name="files">
|
||||
<ele-image-upload
|
||||
|
||||
@@ -1,249 +0,0 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="740"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:title="isUpdate ? '修改分类' : '新建分类'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="styleResponsive ? { md: 6, sm: 4, xs: 24 } : { flex: '90px' }"
|
||||
:wrapper-col="
|
||||
styleResponsive ? { md: 18, sm: 20, xs: 24 } : { flex: '1' }
|
||||
"
|
||||
>
|
||||
<a-row :gutter="16">
|
||||
<a-col
|
||||
v-bind="styleResponsive ? { md: 12, sm: 24, xs: 24 } : { span: 12 }"
|
||||
>
|
||||
<a-form-item label="上级分类" name="parentId">
|
||||
<a-tree-select
|
||||
allow-clear
|
||||
:tree-data="categoryList"
|
||||
tree-default-expand-all
|
||||
placeholder="请选择上级分类"
|
||||
:value="form.parentId || undefined"
|
||||
:dropdown-style="{ maxHeight: '360px', overflow: 'auto' }"
|
||||
@update:value="(value?: number) => (form.parentId = value)"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="设备型号" name="title">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入分类名称"
|
||||
v-model:value="form.title"
|
||||
@pressEnter="save"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="使用年限" name="yearLife">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入分类名称"
|
||||
v-model:value="form.yearLife"
|
||||
@pressEnter="save"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import type { FormInstance, Rule } from 'ant-design-vue/es/form';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import type { Security } from '@/api/tower/security/model';
|
||||
import { addSecurity, updateSecurity } from '@/api/tower/security';
|
||||
import { FILE_SERVER } from "@/config/setting";
|
||||
import { ItemType } from "ele-admin-pro/es/ele-image-upload/types";
|
||||
import { uploadFile } from "@/api/system/file";
|
||||
import { LoginRecordParam } from "@/api/system/login-record/model";
|
||||
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: Security | null;
|
||||
// 上级分类id
|
||||
parentId?: number;
|
||||
// 全部分类数据
|
||||
categoryList: Security[];
|
||||
}>();
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<Security>({
|
||||
securityId: undefined,
|
||||
projectName: undefined,
|
||||
securityCode: undefined,
|
||||
regionName: '',
|
||||
status: 0,
|
||||
address: undefined,
|
||||
sortNumber: 100
|
||||
});
|
||||
|
||||
//
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 已上传数据, 可赋初始值用于回显
|
||||
const images = ref([]);
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<Record<string, Rule[]>>({
|
||||
title: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入分类名称',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
sortNumber: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入排序号',
|
||||
type: 'number',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
meta: [
|
||||
{
|
||||
type: 'string',
|
||||
validator: async (_rule: Rule, value: string) => {
|
||||
if (value) {
|
||||
const msg = '请输入正确的JSON格式';
|
||||
try {
|
||||
const obj = JSON.parse(value);
|
||||
if (typeof obj !== 'object' || obj === null) {
|
||||
return Promise.reject(msg);
|
||||
}
|
||||
} catch (_e) {
|
||||
return Promise.reject(msg);
|
||||
}
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
// 上传文件
|
||||
const onUpload = (d: ItemType) => {
|
||||
uploadFile(<File>d.file)
|
||||
.then((result) => {
|
||||
form.image = result.path;
|
||||
message.success('上传成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
const onClose = () => {
|
||||
form.image = ''
|
||||
}
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const categoryForm = {
|
||||
...form,
|
||||
parentId: form.parentId || 0
|
||||
};
|
||||
const saveOrUpdate = isUpdate.value ? updateSecurity : addSecurity;
|
||||
saveOrUpdate(categoryForm)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
const updateHideValue = (value: boolean) => {
|
||||
form.status = value ? 0 : 1;
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
// 头像赋值
|
||||
images.value = [];
|
||||
if(props.data.image){
|
||||
images.value.push({ uid:1, url: props.data.image, status: '' });
|
||||
}
|
||||
assignFields({
|
||||
...props.data,
|
||||
parentId:
|
||||
props.data.parentId === 0 ? undefined : props.data.parentId
|
||||
});
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
form.parentId = props.parentId;
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import * as icons from '@/layout/menu-icons';
|
||||
|
||||
export default {
|
||||
components: icons,
|
||||
data() {
|
||||
return {
|
||||
iconData: [
|
||||
{
|
||||
title: '已引入的图标',
|
||||
icons: Object.keys(icons)
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -29,7 +29,7 @@
|
||||
@done="chooseProject"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="问题描述">
|
||||
<a-form-item label="问题描述" name="problem">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
@@ -37,11 +37,11 @@
|
||||
v-model:value="form.problem"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="处理方法">
|
||||
<a-form-item label="处理方法" name="processingMethod">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
placeholder="请输入问题描述"
|
||||
placeholder="请输入处理方法"
|
||||
v-model:value="form.processingMethod"
|
||||
/>
|
||||
</a-form-item>
|
||||
@@ -63,13 +63,6 @@
|
||||
<a-radio :value="0">否</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item label="所在地" name="address">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入项目地址"
|
||||
v-model:value="form.address"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
@@ -140,35 +133,41 @@
|
||||
type: 'string',
|
||||
trigger: 'blur',
|
||||
validator: async (_rule: RuleObject, value: string) => {
|
||||
if (value == "") {
|
||||
if (!value) {
|
||||
return Promise.reject("请输入项目名称");
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
],
|
||||
model: [
|
||||
problem: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入设备型号',
|
||||
message: '请输入问题描述',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
yearLife: [
|
||||
processingMethod: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入设备使用年限',
|
||||
type: 'number',
|
||||
message: '请输入处理方法',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
sortNumber: [
|
||||
files: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入排序号',
|
||||
type: 'number',
|
||||
trigger: 'blur'
|
||||
message: '请上传图片',
|
||||
type: 'string',
|
||||
trigger: 'blur',
|
||||
validator: async (_rule: RuleObject, value: string) => {
|
||||
if (files.value.length == 0) {
|
||||
return Promise.reject("请上传图片");
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
<span>新建</span>
|
||||
</a-button>
|
||||
<a-radio-group v-model:value="searchStatus" @change="onStatus">
|
||||
<a-radio-button value="0">正常</a-radio-button>
|
||||
<a-radio-button value="1">待修</a-radio-button>
|
||||
<a-radio-button value="2">异常已修</a-radio-button>
|
||||
<a-radio-button value="3">异常未修</a-radio-button>
|
||||
@@ -58,7 +57,6 @@
|
||||
<a-tag v-else>否</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'status'">
|
||||
<a-tag v-if="record.status == 0">正常</a-tag>
|
||||
<a-tag v-if="record.status == 1" color="red">待修</a-tag>
|
||||
<a-tag v-if="record.status == 2" color="green">异常已修</a-tag>
|
||||
<a-tag v-if="record.status == 3" color="orange">异常未修</a-tag>
|
||||
|
||||
324
src/views/tower/part/goods/components/goods-edit.vue
Normal file
324
src/views/tower/part/goods/components/goods-edit.vue
Normal file
@@ -0,0 +1,324 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<template xmlns="">
|
||||
<ele-modal
|
||||
:width="700"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:title="isUpdate ? '修改配件' : '新建配件'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="styleResponsive ? { md: 6, sm: 6, xs: 24 } : { flex: '90px' }"
|
||||
:wrapper-col="
|
||||
styleResponsive ? { md: 18, sm: 20, xs: 24 } : { flex: '1' }
|
||||
"
|
||||
>
|
||||
<a-row :gutter="16">
|
||||
<a-col
|
||||
v-bind="styleResponsive ? { md: 22, sm: 24, xs: 24 } : { span: 12 }"
|
||||
>
|
||||
<a-form-item label="产品编码" name="goodsCode">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入产品编码"
|
||||
v-model:value="form.goodsCode"
|
||||
@pressEnter="save"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="类别" name="category">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请选择类别"
|
||||
v-model:value="form.category"
|
||||
@pressEnter="save"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="产品名称" name="goodsName">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入产品名称"
|
||||
v-model:value="form.goodsName"
|
||||
@pressEnter="save"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="产品规格" name="specs">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入产品规格"
|
||||
v-model:value="form.specs"
|
||||
@pressEnter="save"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="货架" name="position">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入货架"
|
||||
v-model:value="form.position"
|
||||
@pressEnter="save"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="进货价格" name="price">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 200px"
|
||||
placeholder="请输入进货价格"
|
||||
v-model:value="form.price"
|
||||
@pressEnter="save"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="销售价格" name="salePrice">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 200px"
|
||||
placeholder="请输入销售价格"
|
||||
v-model:value="form.salePrice"
|
||||
@pressEnter="save"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="备注说明" name="comments">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
placeholder="请输入备注说明"
|
||||
v-model:value="form.comments"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import type { FormInstance, Rule } from 'ant-design-vue/es/form';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import type { Goods } from '@/api/tower/part/goods/model';
|
||||
import { addGoods, updateGoods } from '@/api/tower/part/goods';
|
||||
import { Project } from '@/api/tower/project/model';
|
||||
import type { ItemType } from "ele-admin-pro/es/ele-image-upload/types";
|
||||
import { uploadFile } from "@/api/system/file";
|
||||
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: Goods | null;
|
||||
}>();
|
||||
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 已上传数据, 可赋初始值用于回显
|
||||
const files = ref<ItemType[]>([]);
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<Goods>({
|
||||
goodsId: undefined,
|
||||
goodsName: '',
|
||||
goodsCode: '',
|
||||
category: '',
|
||||
specs: '',
|
||||
position: '',
|
||||
stock: undefined,
|
||||
stockMoney: undefined,
|
||||
price: undefined,
|
||||
salePrice: undefined,
|
||||
stockMin: undefined,
|
||||
stockLower: undefined,
|
||||
status: undefined,
|
||||
userId: undefined,
|
||||
comments: '',
|
||||
sortNumber: undefined,
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<Record<string, Rule[]>>({
|
||||
goodsCode: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入产品编码',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
category: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择类别',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
goodsName: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入产品名称',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
price: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入进货价格',
|
||||
type: 'number',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
salePrice: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入销售价格',
|
||||
type: 'number',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
|
||||
sortNumber: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入排序号',
|
||||
type: 'number',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
/* 上传事件 */
|
||||
const uploadHandler = (file: File) => {
|
||||
const item: ItemType = {
|
||||
file,
|
||||
uid: (file as any).uid,
|
||||
name: file.name
|
||||
};
|
||||
if (!file.type.startsWith('image')) {
|
||||
message.error('只能选择图片');
|
||||
return;
|
||||
}
|
||||
if (file.size / 1024 / 1024 > 2) {
|
||||
message.error('大小不能超过 2MB');
|
||||
return;
|
||||
}
|
||||
onUpload(item);
|
||||
};
|
||||
|
||||
// 上传文件
|
||||
const onUpload = (d: ItemType) => {
|
||||
uploadFile(<File>d.file)
|
||||
.then((result) => {
|
||||
files.value.push({
|
||||
uid: result.id,
|
||||
url: result.url,
|
||||
status: "done"
|
||||
})
|
||||
message.success('上传成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const categoryForm = {
|
||||
...form,
|
||||
files: JSON.stringify(files.value)
|
||||
};
|
||||
const saveOrUpdate = isUpdate.value ? updateGoods : addGoods;
|
||||
saveOrUpdate(categoryForm)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
const chooseProject = (row: Project) => {
|
||||
console.log(row);
|
||||
form.projectId = row.projectId;
|
||||
form.projectName = row.projectName;
|
||||
form.address = row.projectAddress;
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
assignFields({
|
||||
...props.data
|
||||
});
|
||||
|
||||
files.value = [];
|
||||
if (props.data.files) {
|
||||
const arr = JSON.parse(props.data.files);
|
||||
arr.map((d, i) => {
|
||||
files.value.push({
|
||||
uid: d.uid,
|
||||
url: d.url,
|
||||
status: 'done'
|
||||
});
|
||||
});
|
||||
}
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
.ml-10 {
|
||||
margin-left: 5px;
|
||||
}
|
||||
</style>
|
||||
263
src/views/tower/part/goods/index.vue
Normal file
263
src/views/tower/part/goods/index.vue
Normal file
@@ -0,0 +1,263 @@
|
||||
<template>
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false" style="margin-top: 10px">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="goodsId"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
:customRow="customRow"
|
||||
:expand-icon-column-index="1"
|
||||
:scroll="{ x: 1200 }"
|
||||
cache-key="towerModel"
|
||||
>
|
||||
<template #toolbar>
|
||||
<a-space>
|
||||
<a-button type="primary" class="ele-btn-icon" @click="openEdit()">
|
||||
<template #icon>
|
||||
<plus-outlined />
|
||||
</template>
|
||||
<span>新建</span>
|
||||
</a-button>
|
||||
<!-- 搜索表单 -->
|
||||
<a-input-search
|
||||
allow-clear
|
||||
v-model:value="searchText"
|
||||
placeholder="请输入搜索关键词"
|
||||
@search="search"
|
||||
@pressEnter="search"
|
||||
/>
|
||||
</a-space>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'userId'">
|
||||
{{ `${record.nickname ? record.nickname : ''}` }}
|
||||
</template>
|
||||
<template v-if="column.key === 'files'">
|
||||
<a-image-preview-group v-if="record.files">
|
||||
<a-image
|
||||
:width="70"
|
||||
v-for="(item, index) in JSON.parse(record.files)"
|
||||
:key="index"
|
||||
:src="item.url"
|
||||
/>
|
||||
</a-image-preview-group>
|
||||
</template>
|
||||
<template v-if="column.key === 'stockLower'">
|
||||
<a-tag v-if="record.stock < record.stockMin" color="red">是</a-tag>
|
||||
<a-tag v-else>否</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'salePrice'">
|
||||
<span class="ele-text-danger">¥{{ record.salePrice }}</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'status'">
|
||||
<a-tag v-if="record.status == 0">正常</a-tag>
|
||||
<a-tag v-if="record.status == 1" color="red">待修</a-tag>
|
||||
<a-tag v-if="record.status == 2" color="green">异常已修</a-tag>
|
||||
<a-tag v-if="record.status == 3" color="orange">异常未修</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<!-- <a @click="openRecord(record)">保养记录</a>-->
|
||||
<!-- <a-divider type="vertical" />-->
|
||||
<a @click="openEdit(record)">修改</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm
|
||||
placement="topRight"
|
||||
title="确定要删除此记录吗?"
|
||||
@confirm="remove(record)"
|
||||
>
|
||||
<a class="ele-text-danger">删除</a>
|
||||
</a-popconfirm>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
<!-- 编辑弹窗 -->
|
||||
<GoodsEdit v-model:visible="showEdit" :data="current" @done="reload" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import { PlusOutlined } from '@ant-design/icons-vue';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { messageLoading, toDateString } from 'ele-admin-pro/es';
|
||||
import type { EleProTable } from 'ele-admin-pro/es';
|
||||
import type { Goods, GoodsParam } from '@/api/tower/part/goods/model';
|
||||
import { pageGoods, removeGoods } from '@/api/tower/part/goods';
|
||||
import GoodsEdit from './components/goods-edit.vue';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
// {
|
||||
// key: 'index',
|
||||
// width: 48,
|
||||
// align: 'center',
|
||||
// fixed: 'left',
|
||||
// hideInSetting: true,
|
||||
// customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
// },
|
||||
{
|
||||
title: '产品编码',
|
||||
dataIndex: 'goodsCode',
|
||||
key: 'goodsCode'
|
||||
},
|
||||
{
|
||||
title: '类别',
|
||||
dataIndex: 'category',
|
||||
key: 'category'
|
||||
},
|
||||
{
|
||||
title: '产品名称',
|
||||
dataIndex: 'goodsName',
|
||||
key: 'goodsName'
|
||||
},
|
||||
{
|
||||
title: '产品规格',
|
||||
dataIndex: 'specs',
|
||||
key: 'specs'
|
||||
},
|
||||
{
|
||||
title: '货架',
|
||||
dataIndex: 'position',
|
||||
key: 'position'
|
||||
},
|
||||
{
|
||||
title: '进货价格',
|
||||
dataIndex: 'price',
|
||||
key: 'price'
|
||||
},
|
||||
{
|
||||
title: '销售价格',
|
||||
dataIndex: 'salePrice',
|
||||
key: 'salePrice'
|
||||
},
|
||||
{
|
||||
title: '录入时间',
|
||||
dataIndex: 'createTime',
|
||||
width: 180,
|
||||
customRender: ({ text }) => toDateString(text)
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 200,
|
||||
align: 'center'
|
||||
}
|
||||
]);
|
||||
|
||||
// 当前编辑数据
|
||||
const current = ref<Goods | null>(null);
|
||||
const searchText = ref('');
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
const showRecord = ref(false);
|
||||
|
||||
// 日期范围选择
|
||||
const dateRange = ref<[string, string]>(['', '']);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({ where }) => {
|
||||
if (searchText.value && searchText.value != '') {
|
||||
where.keywords = searchText.value;
|
||||
}
|
||||
where.type = 1;
|
||||
return pageGoods({ ...where });
|
||||
};
|
||||
|
||||
/* 刷新表格 */
|
||||
const reload = (where?: GoodsParam) => {
|
||||
tableRef?.value?.reload({ where });
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: Goods | null, id?: number) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
const openRecord = (row?: Goods, id?: number) => {
|
||||
current.value = row ?? null;
|
||||
showRecord.value = true;
|
||||
};
|
||||
|
||||
const search = (searchText) => {
|
||||
reload({ keywords: searchText });
|
||||
};
|
||||
|
||||
const onStatus = (e: any) => {
|
||||
console.log(e.target.value);
|
||||
const status = e.target.value;
|
||||
reload({ status });
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: Goods) => {
|
||||
const hide = messageLoading('请求中..', 0);
|
||||
removeGoods(row.goodsId)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: Goods) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'TowerGoods'
|
||||
};
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.count {
|
||||
display: flex;
|
||||
.btn {
|
||||
margin: 0 12px;
|
||||
padding: 6px 18px;
|
||||
background-color: #f3f3f3;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 16px;
|
||||
.divider {
|
||||
width: 4px;
|
||||
height: 15px;
|
||||
border-radius: 8px;
|
||||
margin-right: 8px;
|
||||
background-color: #16a90b;
|
||||
}
|
||||
.active {
|
||||
color: #16a90b;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
324
src/views/tower/part/stock/components/goods-edit.vue
Normal file
324
src/views/tower/part/stock/components/goods-edit.vue
Normal file
@@ -0,0 +1,324 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<template xmlns="">
|
||||
<ele-modal
|
||||
:width="700"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:title="isUpdate ? '修改配件' : '新建配件'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="styleResponsive ? { md: 6, sm: 6, xs: 24 } : { flex: '90px' }"
|
||||
:wrapper-col="
|
||||
styleResponsive ? { md: 18, sm: 20, xs: 24 } : { flex: '1' }
|
||||
"
|
||||
>
|
||||
<a-row :gutter="16">
|
||||
<a-col
|
||||
v-bind="styleResponsive ? { md: 22, sm: 24, xs: 24 } : { span: 12 }"
|
||||
>
|
||||
<a-form-item label="产品编码" name="goodsCode">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入产品编码"
|
||||
v-model:value="form.goodsCode"
|
||||
@pressEnter="save"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="类别" name="category">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请选择类别"
|
||||
v-model:value="form.category"
|
||||
@pressEnter="save"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="产品名称" name="goodsName">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入产品名称"
|
||||
v-model:value="form.goodsName"
|
||||
@pressEnter="save"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="产品规格" name="specs">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入产品规格"
|
||||
v-model:value="form.specs"
|
||||
@pressEnter="save"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="货架" name="position">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入货架"
|
||||
v-model:value="form.position"
|
||||
@pressEnter="save"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="进货价格" name="price">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 200px"
|
||||
placeholder="请输入进货价格"
|
||||
v-model:value="form.price"
|
||||
@pressEnter="save"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="销售价格" name="salePrice">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 200px"
|
||||
placeholder="请输入销售价格"
|
||||
v-model:value="form.salePrice"
|
||||
@pressEnter="save"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="备注说明" name="comments">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
placeholder="请输入备注说明"
|
||||
v-model:value="form.comments"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import type { FormInstance, Rule } from 'ant-design-vue/es/form';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import type { Goods } from '@/api/tower/part/goods/model';
|
||||
import { addGoods, updateGoods } from '@/api/tower/part/goods';
|
||||
import { Project } from '@/api/tower/project/model';
|
||||
import type { ItemType } from "ele-admin-pro/es/ele-image-upload/types";
|
||||
import { uploadFile } from "@/api/system/file";
|
||||
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: Goods | null;
|
||||
}>();
|
||||
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 已上传数据, 可赋初始值用于回显
|
||||
const files = ref<ItemType[]>([]);
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<Goods>({
|
||||
goodsId: undefined,
|
||||
goodsName: '',
|
||||
goodsCode: '',
|
||||
category: '',
|
||||
specs: '',
|
||||
position: '',
|
||||
stock: undefined,
|
||||
stockMoney: undefined,
|
||||
price: undefined,
|
||||
salePrice: undefined,
|
||||
stockMin: undefined,
|
||||
stockLower: undefined,
|
||||
status: undefined,
|
||||
userId: undefined,
|
||||
comments: '',
|
||||
sortNumber: undefined,
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<Record<string, Rule[]>>({
|
||||
goodsCode: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入产品编码',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
category: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择类别',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
goodsName: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入产品名称',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
price: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入进货价格',
|
||||
type: 'number',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
salePrice: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入销售价格',
|
||||
type: 'number',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
|
||||
sortNumber: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入排序号',
|
||||
type: 'number',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
/* 上传事件 */
|
||||
const uploadHandler = (file: File) => {
|
||||
const item: ItemType = {
|
||||
file,
|
||||
uid: (file as any).uid,
|
||||
name: file.name
|
||||
};
|
||||
if (!file.type.startsWith('image')) {
|
||||
message.error('只能选择图片');
|
||||
return;
|
||||
}
|
||||
if (file.size / 1024 / 1024 > 2) {
|
||||
message.error('大小不能超过 2MB');
|
||||
return;
|
||||
}
|
||||
onUpload(item);
|
||||
};
|
||||
|
||||
// 上传文件
|
||||
const onUpload = (d: ItemType) => {
|
||||
uploadFile(<File>d.file)
|
||||
.then((result) => {
|
||||
files.value.push({
|
||||
uid: result.id,
|
||||
url: result.url,
|
||||
status: "done"
|
||||
})
|
||||
message.success('上传成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const categoryForm = {
|
||||
...form,
|
||||
files: JSON.stringify(files.value)
|
||||
};
|
||||
const saveOrUpdate = isUpdate.value ? updateGoods : addGoods;
|
||||
saveOrUpdate(categoryForm)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
const chooseProject = (row: Project) => {
|
||||
console.log(row);
|
||||
form.projectId = row.projectId;
|
||||
form.projectName = row.projectName;
|
||||
form.address = row.projectAddress;
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
assignFields({
|
||||
...props.data
|
||||
});
|
||||
|
||||
files.value = [];
|
||||
if (props.data.files) {
|
||||
const arr = JSON.parse(props.data.files);
|
||||
arr.map((d, i) => {
|
||||
files.value.push({
|
||||
uid: d.uid,
|
||||
url: d.url,
|
||||
status: 'done'
|
||||
});
|
||||
});
|
||||
}
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
.ml-10 {
|
||||
margin-left: 5px;
|
||||
}
|
||||
</style>
|
||||
301
src/views/tower/part/stock/components/part-edit.vue
Normal file
301
src/views/tower/part/stock/components/part-edit.vue
Normal file
@@ -0,0 +1,301 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<template xmlns="">
|
||||
<ele-modal
|
||||
:width="700"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:title="isUpdate ? '修改配件' : '新建配件'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="styleResponsive ? { md: 6, sm: 6, xs: 24 } : { flex: '90px' }"
|
||||
:wrapper-col="
|
||||
styleResponsive ? { md: 18, sm: 20, xs: 24 } : { flex: '1' }
|
||||
"
|
||||
>
|
||||
<a-row :gutter="16">
|
||||
<a-col
|
||||
v-bind="styleResponsive ? { md: 22, sm: 24, xs: 24 } : { span: 12 }"
|
||||
>
|
||||
<a-form-item label="配件编码" name="partCode">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入配件编码"
|
||||
v-model:value="form.partCode"
|
||||
@pressEnter="save"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="类别" name="category">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请选择类别"
|
||||
v-model:value="form.category"
|
||||
@pressEnter="save"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="规格" name="specs">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入配件规格"
|
||||
v-model:value="form.specs"
|
||||
@pressEnter="save"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="位置" name="position">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入位置"
|
||||
v-model:value="form.position"
|
||||
@pressEnter="save"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="库存数量" name="stock">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入库存数量"
|
||||
v-model:value="form.stock"
|
||||
@pressEnter="save"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="最低库存" name="stockMin">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入最低库存"
|
||||
v-model:value="form.stockMin"
|
||||
@pressEnter="save"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="进货价格" name="price">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入库存数量"
|
||||
v-model:value="form.price"
|
||||
@pressEnter="save"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="备注说明" name="comments">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
placeholder="请输入备注说明"
|
||||
v-model:value="form.comments"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import type { FormInstance, Rule } from 'ant-design-vue/es/form';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import type { Part } from '@/api/tower/part/model';
|
||||
import { addPart, updatePart } from '@/api/tower/part';
|
||||
import { Project } from '@/api/tower/project/model';
|
||||
import type { ItemType } from "ele-admin-pro/es/ele-image-upload/types";
|
||||
import { uploadFile } from "@/api/system/file";
|
||||
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: Part | null;
|
||||
}>();
|
||||
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 已上传数据, 可赋初始值用于回显
|
||||
const files = ref<ItemType[]>([]);
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<Part>({
|
||||
partId: undefined,
|
||||
partCode: '',
|
||||
category: '',
|
||||
specs: '',
|
||||
position: '',
|
||||
stock: undefined,
|
||||
stockMoney: undefined,
|
||||
price: undefined,
|
||||
stockMin: undefined,
|
||||
stockLower: undefined,
|
||||
status: undefined,
|
||||
userId: undefined,
|
||||
comments: '',
|
||||
sortNumber: undefined,
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<Record<string, Rule[]>>({
|
||||
projectName: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入设备名称',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
model: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入设备型号',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
yearLife: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入设备使用年限',
|
||||
type: 'number',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
sortNumber: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入排序号',
|
||||
type: 'number',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
/* 上传事件 */
|
||||
const uploadHandler = (file: File) => {
|
||||
const item: ItemType = {
|
||||
file,
|
||||
uid: (file as any).uid,
|
||||
name: file.name
|
||||
};
|
||||
if (!file.type.startsWith('image')) {
|
||||
message.error('只能选择图片');
|
||||
return;
|
||||
}
|
||||
if (file.size / 1024 / 1024 > 2) {
|
||||
message.error('大小不能超过 2MB');
|
||||
return;
|
||||
}
|
||||
onUpload(item);
|
||||
};
|
||||
|
||||
// 上传文件
|
||||
const onUpload = (d: ItemType) => {
|
||||
uploadFile(<File>d.file)
|
||||
.then((result) => {
|
||||
files.value.push({
|
||||
uid: result.id,
|
||||
url: result.url,
|
||||
status: "done"
|
||||
})
|
||||
message.success('上传成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const categoryForm = {
|
||||
...form,
|
||||
files: JSON.stringify(files.value)
|
||||
};
|
||||
const saveOrUpdate = isUpdate.value ? updatePart : addPart;
|
||||
saveOrUpdate(categoryForm)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
const chooseProject = (row: Project) => {
|
||||
console.log(row);
|
||||
form.projectId = row.projectId;
|
||||
form.projectName = row.projectName;
|
||||
form.address = row.projectAddress;
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
assignFields({
|
||||
...props.data
|
||||
});
|
||||
|
||||
files.value = [];
|
||||
if (props.data.files) {
|
||||
const arr = JSON.parse(props.data.files);
|
||||
arr.map((d, i) => {
|
||||
files.value.push({
|
||||
uid: d.uid,
|
||||
url: d.url,
|
||||
status: 'done'
|
||||
});
|
||||
});
|
||||
}
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
.ml-10 {
|
||||
margin-left: 5px;
|
||||
}
|
||||
</style>
|
||||
272
src/views/tower/part/stock/index.vue
Normal file
272
src/views/tower/part/stock/index.vue
Normal file
@@ -0,0 +1,272 @@
|
||||
<template>
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false" style="margin-top: 10px">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="goodsId"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
:customRow="customRow"
|
||||
:expand-icon-column-index="1"
|
||||
:scroll="{ x: 1200 }"
|
||||
cache-key="towerModel"
|
||||
>
|
||||
<template #toolbar>
|
||||
<a-space>
|
||||
<!-- 搜索表单 -->
|
||||
<a-input-search
|
||||
allow-clear
|
||||
v-model:value="searchText"
|
||||
placeholder="请输入搜索关键词"
|
||||
@search="search"
|
||||
@pressEnter="search"
|
||||
/>
|
||||
</a-space>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'userId'">
|
||||
{{ `${record.nickname ? record.nickname : ''}` }}
|
||||
</template>
|
||||
<template v-if="column.key === 'files'">
|
||||
<a-image-preview-group v-if="record.files">
|
||||
<a-image
|
||||
:width="70"
|
||||
v-for="(item, index) in JSON.parse(record.files)"
|
||||
:key="index"
|
||||
:src="item.url"
|
||||
/>
|
||||
</a-image-preview-group>
|
||||
</template>
|
||||
<template v-if="column.key === 'stockLower'">
|
||||
<a-tag v-if="record.stock < record.stockMin" color="red">是</a-tag>
|
||||
<a-tag v-else>否</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'salePrice'">
|
||||
<span class="ele-text-danger">¥{{ record.salePrice }}</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'stockMoney'">
|
||||
<span class="ele-text-warning">¥{{ record.stock * record.price }}</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'status'">
|
||||
<a-tag v-if="record.status == 0">正常</a-tag>
|
||||
<a-tag v-if="record.status == 1" color="red">待修</a-tag>
|
||||
<a-tag v-if="record.status == 2" color="green">异常已修</a-tag>
|
||||
<a-tag v-if="record.status == 3" color="orange">异常未修</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<!-- <a @click="openRecord(record)">保养记录</a>-->
|
||||
<!-- <a-divider type="vertical" />-->
|
||||
<a @click="openEdit(record)">修改</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm
|
||||
placement="topRight"
|
||||
title="确定要删除此记录吗?"
|
||||
@confirm="remove(record)"
|
||||
>
|
||||
<a class="ele-text-danger">删除</a>
|
||||
</a-popconfirm>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
<!-- 编辑弹窗 -->
|
||||
<GoodsEdit v-model:visible="showEdit" :data="current" @done="reload" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import { PlusOutlined } from '@ant-design/icons-vue';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { messageLoading } from 'ele-admin-pro/es';
|
||||
import type { EleProTable } from 'ele-admin-pro/es';
|
||||
import type { Goods, GoodsParam } from '@/api/tower/part/goods/model';
|
||||
import { pageGoods, removeGoods } from '@/api/tower/part/goods';
|
||||
import GoodsEdit from './components/goods-edit.vue';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
// {
|
||||
// key: 'index',
|
||||
// width: 48,
|
||||
// align: 'center',
|
||||
// fixed: 'left',
|
||||
// hideInSetting: true,
|
||||
// customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
// },
|
||||
{
|
||||
title: '产品编码',
|
||||
dataIndex: 'goodsCode',
|
||||
key: 'goodsCode'
|
||||
},
|
||||
{
|
||||
title: '类别',
|
||||
dataIndex: 'category',
|
||||
key: 'category'
|
||||
},
|
||||
{
|
||||
title: '产品名称',
|
||||
dataIndex: 'goodsName',
|
||||
key: 'goodsName'
|
||||
},
|
||||
{
|
||||
title: '产品规格',
|
||||
dataIndex: 'specs',
|
||||
key: 'specs'
|
||||
},
|
||||
{
|
||||
title: '货架',
|
||||
dataIndex: 'position',
|
||||
key: 'position'
|
||||
},
|
||||
{
|
||||
title: '期初库存'
|
||||
},
|
||||
{
|
||||
title: '入库数量'
|
||||
},
|
||||
{
|
||||
title: '出库数量'
|
||||
},
|
||||
{
|
||||
title: '进货价格',
|
||||
dataIndex: 'price',
|
||||
key: 'price'
|
||||
},
|
||||
{
|
||||
title: '库存数量',
|
||||
dataIndex: 'stock',
|
||||
key: 'stock'
|
||||
},
|
||||
{
|
||||
title: '库存金额',
|
||||
dataIndex: 'stockMoney',
|
||||
key: 'stockMoney'
|
||||
},
|
||||
{
|
||||
title: '最低库存',
|
||||
dataIndex: 'stockMin',
|
||||
key: 'stockMin'
|
||||
},
|
||||
{
|
||||
title: '是否低于最低库存',
|
||||
dataIndex: 'stockLower',
|
||||
key: 'stockLower'
|
||||
}
|
||||
]);
|
||||
|
||||
// 当前编辑数据
|
||||
const current = ref<Goods | null>(null);
|
||||
const searchText = ref('');
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
const showRecord = ref(false);
|
||||
|
||||
// 日期范围选择
|
||||
const dateRange = ref<[string, string]>(['', '']);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({ where }) => {
|
||||
if (searchText.value && searchText.value != '') {
|
||||
where.keywords = searchText.value;
|
||||
}
|
||||
where.type = 1;
|
||||
return pageGoods({ ...where });
|
||||
};
|
||||
|
||||
/* 刷新表格 */
|
||||
const reload = (where?: GoodsParam) => {
|
||||
tableRef?.value?.reload({ where });
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: Goods | null, id?: number) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
const openRecord = (row?: Goods, id?: number) => {
|
||||
current.value = row ?? null;
|
||||
showRecord.value = true;
|
||||
};
|
||||
|
||||
const search = (searchText) => {
|
||||
reload({ keywords: searchText });
|
||||
};
|
||||
|
||||
const onStatus = (e: any) => {
|
||||
console.log(e.target.value);
|
||||
const status = e.target.value;
|
||||
reload({ status });
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: Goods) => {
|
||||
const hide = messageLoading('请求中..', 0);
|
||||
removeGoods(row.goodsId)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: Goods) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'TowerGoods'
|
||||
};
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.count {
|
||||
display: flex;
|
||||
.btn {
|
||||
margin: 0 12px;
|
||||
padding: 6px 18px;
|
||||
background-color: #f3f3f3;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 16px;
|
||||
.divider {
|
||||
width: 4px;
|
||||
height: 15px;
|
||||
border-radius: 8px;
|
||||
margin-right: 8px;
|
||||
background-color: #16a90b;
|
||||
}
|
||||
.active {
|
||||
color: #16a90b;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user