新增采购入库功能
This commit is contained in:
@@ -12,8 +12,9 @@ export interface DictData {
|
|||||||
dictDataCode?: string;
|
dictDataCode?: string;
|
||||||
// 字典数据名称
|
// 字典数据名称
|
||||||
dictDataName?: string;
|
dictDataName?: string;
|
||||||
|
dictCode?: string;
|
||||||
// 排序号
|
// 排序号
|
||||||
sortNumber?: string;
|
sortNumber?: any;
|
||||||
// 备注
|
// 备注
|
||||||
comments?: string;
|
comments?: string;
|
||||||
// 创建时间
|
// 创建时间
|
||||||
|
|||||||
@@ -1,61 +1,62 @@
|
|||||||
import type { PageParam } from "@/api";
|
import type { PageParam } from '@/api';
|
||||||
import { Project } from "@/api/tower/project/model";
|
import { Project } from '@/api/tower/project/model';
|
||||||
|
|
||||||
export interface TowerEquipment {
|
export interface TowerEquipment {
|
||||||
equipmentId?: number;
|
equipmentId?: number;
|
||||||
name?: string;
|
name?: string;
|
||||||
model?: string;
|
model?: string;
|
||||||
equipmentNo?: string;
|
equipmentNo?: string;
|
||||||
factoryNo?: string;
|
factoryNo?: string;
|
||||||
factoryDate?: string;
|
factoryDate?: string;
|
||||||
manufactor?: string;
|
manufactor?: string;
|
||||||
lifeYear?: any;
|
lifeYear?: any;
|
||||||
surplusYear?: number;
|
surplusYear?: number;
|
||||||
scrapDate?: string;
|
scrapDate?: string;
|
||||||
beianNo?: string;
|
beianNo?: string;
|
||||||
licenceNo?: string;
|
licenceNo?: string;
|
||||||
company?: string;
|
company?: string;
|
||||||
organization?: string;
|
organization?: string;
|
||||||
warehouse?: string;
|
warehouse?: string;
|
||||||
source?: string;
|
source?: string;
|
||||||
filingNo?: string;
|
filingNo?: string;
|
||||||
machineNo?: string;
|
machineNo?: string;
|
||||||
maxLiftingHeight?: string;
|
maxLiftingHeight?: string;
|
||||||
armLength?: string;
|
armLength?: string;
|
||||||
isOutOrg?: boolean;
|
isOutOrg?: boolean;
|
||||||
buyDate?: string;
|
buyDate?: string;
|
||||||
currentLocation?: string;
|
currentLocation?: string;
|
||||||
designHeight?: number;
|
designHeight?: number;
|
||||||
height?: number;
|
height?: number;
|
||||||
ratedLoad?: string;
|
ratedLoad?: string;
|
||||||
files?: string;
|
files?: string;
|
||||||
file1?: string;
|
file1?: string;
|
||||||
file2?: string;
|
file2?: string;
|
||||||
file3?: string;
|
file3?: string;
|
||||||
file4?: string;
|
file4?: string;
|
||||||
file5?: string;
|
file5?: string;
|
||||||
file6?: string;
|
file6?: string;
|
||||||
file7?: string;
|
file7?: string;
|
||||||
users?: string;
|
users?: string;
|
||||||
status?: number;
|
status?: number;
|
||||||
comments?: string;
|
comments?: string;
|
||||||
userId?: number;
|
userId?: number;
|
||||||
deleted?: number;
|
deleted?: number;
|
||||||
tenantId?: number;
|
tenantId?: number;
|
||||||
createTime?: number;
|
createTime?: number;
|
||||||
maxRatedLoad?: string;
|
maxRatedLoad?: string;
|
||||||
securityStatus?: string;
|
securityStatus?: string;
|
||||||
projectName?: string;
|
projectName?: string;
|
||||||
competentDepartment?: string;
|
competentDepartment?: string;
|
||||||
projectList?: Project[];
|
projectList?: Project[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 搜索条件
|
* 搜索条件
|
||||||
*/
|
*/
|
||||||
export interface TowerEquipmentParam extends PageParam {
|
export interface TowerEquipmentParam extends PageParam {
|
||||||
equipmentId?: number;
|
equipmentId?: number;
|
||||||
name?: string;
|
name?: string;
|
||||||
status?: number;
|
status?: number;
|
||||||
yearFilter?: number;
|
scrapDate?: string;
|
||||||
|
yearFilter?: number;
|
||||||
}
|
}
|
||||||
|
|||||||
113
src/api/tower/purchase/index.ts
Normal file
113
src/api/tower/purchase/index.ts
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
import request from '@/utils/request';
|
||||||
|
import type { ApiResult, PageResult } from '@/api';
|
||||||
|
import type { TowerPurchase, TowerPurchaseParam } from './model';
|
||||||
|
// const merchantCode = String(localStorage.getItem('merchantCode'));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询采购入库
|
||||||
|
*/
|
||||||
|
export async function pageTowerPurchase(params: TowerPurchaseParam) {
|
||||||
|
const res = await request.get<ApiResult<PageResult<TowerPurchase>>>(
|
||||||
|
'/tower/tower-purchase/page',
|
||||||
|
{
|
||||||
|
params
|
||||||
|
}
|
||||||
|
);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.data;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询采购入库列表
|
||||||
|
*/
|
||||||
|
export async function listTowerPurchase(params?: TowerPurchaseParam) {
|
||||||
|
const res = await request.get<ApiResult<TowerPurchase[]>>(
|
||||||
|
'/tower/tower-purchase',
|
||||||
|
{
|
||||||
|
params
|
||||||
|
}
|
||||||
|
);
|
||||||
|
if (res.data.code === 0 && res.data.data) {
|
||||||
|
return res.data.data;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加采购入库
|
||||||
|
*/
|
||||||
|
export async function addTowerPurchase(data: TowerPurchase) {
|
||||||
|
const res = await request.post<ApiResult<unknown>>(
|
||||||
|
'/tower/tower-purchase',
|
||||||
|
data
|
||||||
|
);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改采购入库
|
||||||
|
*/
|
||||||
|
export async function updateTowerPurchase(data: TowerPurchase) {
|
||||||
|
const res = await request.put<ApiResult<unknown>>(
|
||||||
|
'/tower/tower-purchase',
|
||||||
|
data
|
||||||
|
);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除采购入库
|
||||||
|
*/
|
||||||
|
export async function removeTowerPurchase(id?: number) {
|
||||||
|
const res = await request.delete<ApiResult<unknown>>(
|
||||||
|
'/tower/tower-purchase/' + id
|
||||||
|
);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除采购入库
|
||||||
|
*/
|
||||||
|
export async function removeBatchTowerPurchase(data: (number | undefined)[]) {
|
||||||
|
const res = await request.delete<ApiResult<unknown>>(
|
||||||
|
'/tower/tower-purchase/batch',
|
||||||
|
{
|
||||||
|
data
|
||||||
|
}
|
||||||
|
);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查IP是否存在
|
||||||
|
*/
|
||||||
|
export async function checkExistence(
|
||||||
|
field: string,
|
||||||
|
value: string,
|
||||||
|
id?: number
|
||||||
|
) {
|
||||||
|
const res = await request.get<ApiResult<unknown>>(
|
||||||
|
'/tower/tower-purchase/existence',
|
||||||
|
{
|
||||||
|
params: { field, value, id }
|
||||||
|
}
|
||||||
|
);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
37
src/api/tower/purchase/model/index.ts
Normal file
37
src/api/tower/purchase/model/index.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import type { PageParam } from '@/api';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购入库
|
||||||
|
*/
|
||||||
|
export interface TowerPurchase {
|
||||||
|
purchaseId?: number;
|
||||||
|
name?: string;
|
||||||
|
purchaseCode?: string;
|
||||||
|
purchaseType?: string;
|
||||||
|
price?: number;
|
||||||
|
companyName?: string;
|
||||||
|
userId?: number;
|
||||||
|
sortNumber?: number;
|
||||||
|
comments?: string;
|
||||||
|
status?: number;
|
||||||
|
createTime?: string;
|
||||||
|
updateTime?: string;
|
||||||
|
key?: number;
|
||||||
|
merchantCode?: string;
|
||||||
|
value?: number;
|
||||||
|
index?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索条件
|
||||||
|
*/
|
||||||
|
export interface TowerPurchaseParam extends PageParam {
|
||||||
|
rentId?: number;
|
||||||
|
title?: string;
|
||||||
|
categoryId?: string;
|
||||||
|
yearLife?: number;
|
||||||
|
name?: string;
|
||||||
|
companyName: string;
|
||||||
|
// 商户编号
|
||||||
|
merchantCode?: string;
|
||||||
|
}
|
||||||
@@ -151,7 +151,7 @@
|
|||||||
title: '客户名称',
|
title: '客户名称',
|
||||||
dataIndex: 'name',
|
dataIndex: 'name',
|
||||||
key: 'name',
|
key: 'name',
|
||||||
width: 280,
|
width: 380,
|
||||||
ellipsis: true
|
ellipsis: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
249
src/views/tower/purchase/components/category-edit.vue
Normal file
249
src/views/tower/purchase/components/category-edit.vue
Normal file
@@ -0,0 +1,249 @@
|
|||||||
|
<!-- 编辑弹窗 -->
|
||||||
|
<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 { TowerModel } from '@/api/tower/model/model';
|
||||||
|
import { addTowerModel, updateTowerModel } from '@/api/tower/model';
|
||||||
|
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?: TowerModel | null;
|
||||||
|
// 上级分类id
|
||||||
|
parentId?: number;
|
||||||
|
// 全部分类数据
|
||||||
|
categoryList: TowerModel[];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
// 表单数据
|
||||||
|
const { form, resetFields, assignFields } = useFormData<TowerModel>({
|
||||||
|
title: '',
|
||||||
|
categoryId: undefined,
|
||||||
|
parentId: undefined,
|
||||||
|
image: '',
|
||||||
|
status: 0,
|
||||||
|
yearLife: 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 ? updateTowerModel : addTowerModel;
|
||||||
|
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>
|
||||||
233
src/views/tower/purchase/components/purchase-edit.vue
Normal file
233
src/views/tower/purchase/components/purchase-edit.vue
Normal file
@@ -0,0 +1,233 @@
|
|||||||
|
<!-- 编辑弹窗 -->
|
||||||
|
<template>
|
||||||
|
<ele-modal
|
||||||
|
:width="500"
|
||||||
|
: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="company">
|
||||||
|
<SelectCompany
|
||||||
|
:placeholder="`请选择供应商`"
|
||||||
|
v-model:value="form.companyName"
|
||||||
|
@done="chooseCompany"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="部件分类" name="purchaseType">
|
||||||
|
<DictSelect
|
||||||
|
dict-code="purchaseType"
|
||||||
|
placeholder="请选择部件分类"
|
||||||
|
style="width: 200px"
|
||||||
|
v-model:value="form.purchaseType"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="部件名称" name="name">
|
||||||
|
<a-input
|
||||||
|
allow-clear
|
||||||
|
placeholder="请输入部件名称"
|
||||||
|
v-model:value="form.name"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="价格" name="price">
|
||||||
|
<a-input
|
||||||
|
allow-clear
|
||||||
|
placeholder="请输入部件价格"
|
||||||
|
v-model:value="form.price"
|
||||||
|
/>
|
||||||
|
</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 { TowerPurchase } from '@/api/tower/purchase/model';
|
||||||
|
import { addTowerPurchase, updateTowerPurchase } from '@/api/tower/purchase';
|
||||||
|
import { RuleObject } from 'ant-design-vue/es/form';
|
||||||
|
|
||||||
|
// 是否开启响应式布局
|
||||||
|
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?: TowerPurchase | null;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const formRef = ref<FormInstance | null>(null);
|
||||||
|
// 是否是修改
|
||||||
|
const isUpdate = ref(false);
|
||||||
|
// 提交状态
|
||||||
|
const loading = ref(false);
|
||||||
|
|
||||||
|
// 表单数据
|
||||||
|
const { form, resetFields, assignFields } = useFormData<TowerPurchase>({
|
||||||
|
purchaseId: undefined,
|
||||||
|
name: '',
|
||||||
|
purchaseCode: '',
|
||||||
|
purchaseType: undefined,
|
||||||
|
price: undefined,
|
||||||
|
companyName: '',
|
||||||
|
comments: '',
|
||||||
|
status: 0,
|
||||||
|
sortNumber: 100
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表单验证规则
|
||||||
|
const rules = reactive<Record<string, Rule[]>>({
|
||||||
|
company: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择租赁单位',
|
||||||
|
type: 'string',
|
||||||
|
trigger: 'blur',
|
||||||
|
validator: async (_rule: RuleObject, value: string) => {
|
||||||
|
console.log(value);
|
||||||
|
if (form.companyName == '') {
|
||||||
|
return Promise.reject('请选择租赁单位');
|
||||||
|
}
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
purchaseType: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择部件分类',
|
||||||
|
type: 'string',
|
||||||
|
trigger: 'blur'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
name: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入部件名称',
|
||||||
|
type: 'string',
|
||||||
|
trigger: 'blur'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
month: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入租金',
|
||||||
|
type: 'string',
|
||||||
|
trigger: 'blur'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
num: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入月数',
|
||||||
|
type: 'string',
|
||||||
|
trigger: 'blur'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
sortNumber: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入排序号',
|
||||||
|
type: 'number',
|
||||||
|
trigger: 'blur'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
/* 保存编辑 */
|
||||||
|
const save = () => {
|
||||||
|
if (!formRef.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
formRef.value
|
||||||
|
.validate()
|
||||||
|
.then(() => {
|
||||||
|
loading.value = true;
|
||||||
|
const categoryForm = {
|
||||||
|
...form
|
||||||
|
};
|
||||||
|
const saveOrUpdate = isUpdate.value
|
||||||
|
? updateTowerPurchase
|
||||||
|
: addTowerPurchase;
|
||||||
|
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 chooseCompany = (row) => {
|
||||||
|
console.log(row);
|
||||||
|
form.companyName = row.companyName;
|
||||||
|
form.companyId = row.companyId;
|
||||||
|
};
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.visible,
|
||||||
|
(visible) => {
|
||||||
|
if (visible) {
|
||||||
|
if (props.data) {
|
||||||
|
assignFields({
|
||||||
|
...props.data
|
||||||
|
});
|
||||||
|
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>
|
||||||
175
src/views/tower/purchase/dict/components/dict-edit.vue
Normal file
175
src/views/tower/purchase/dict/components/dict-edit.vue
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
<!-- 分类编辑弹窗 -->
|
||||||
|
<template>
|
||||||
|
<ele-modal
|
||||||
|
:width="460"
|
||||||
|
: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: 5, sm: 5, xs: 24 } : { flex: '90px' }"
|
||||||
|
:wrapper-col="
|
||||||
|
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<a-form-item label="分类标识" name="dictCode">
|
||||||
|
<a-input
|
||||||
|
allow-clear
|
||||||
|
:maxlength="20"
|
||||||
|
disabled
|
||||||
|
placeholder="请输入分类标识"
|
||||||
|
v-model:value="form.dictCode"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="分类名称" name="dictDataName">
|
||||||
|
<a-input
|
||||||
|
allow-clear
|
||||||
|
:maxlength="20"
|
||||||
|
placeholder="请输入分类名称"
|
||||||
|
v-model:value="form.dictDataName"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="排序" name="sortNumber">
|
||||||
|
<a-input-number
|
||||||
|
:min="0"
|
||||||
|
:max="99999"
|
||||||
|
class="ele-fluid"
|
||||||
|
placeholder="请输入排序号"
|
||||||
|
v-model:value="form.sortNumber"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="备注">
|
||||||
|
<a-textarea
|
||||||
|
:rows="4"
|
||||||
|
:maxlength="200"
|
||||||
|
placeholder="请输入备注"
|
||||||
|
v-model:value="form.comments"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
</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 { addDictData, updateDictData } from '@/api/system/dict-data';
|
||||||
|
import { DictData } from '@/api/system/dict-data/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?: DictData | null;
|
||||||
|
// 字典ID
|
||||||
|
dictId?: number | 0;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
//
|
||||||
|
const formRef = ref<FormInstance | null>(null);
|
||||||
|
|
||||||
|
// 是否是修改
|
||||||
|
const isUpdate = ref(false);
|
||||||
|
|
||||||
|
// 提交状态
|
||||||
|
const loading = ref(false);
|
||||||
|
|
||||||
|
// 表单数据
|
||||||
|
const { form, resetFields, assignFields } = useFormData<DictData>({
|
||||||
|
dictId: undefined,
|
||||||
|
dictDataId: undefined,
|
||||||
|
dictDataName: '',
|
||||||
|
dictCode: 'purchaseType',
|
||||||
|
dictDataCode: '',
|
||||||
|
sortNumber: 100,
|
||||||
|
comments: ''
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表单验证规则
|
||||||
|
const rules = reactive<Record<string, Rule[]>>({
|
||||||
|
dictDataCode: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入分类名称',
|
||||||
|
type: 'string',
|
||||||
|
trigger: 'blur'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
dictCode: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入分类标识',
|
||||||
|
type: 'string',
|
||||||
|
trigger: 'blur'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
/* 保存编辑 */
|
||||||
|
const save = () => {
|
||||||
|
if (!formRef.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
formRef.value
|
||||||
|
.validate()
|
||||||
|
.then(() => {
|
||||||
|
loading.value = true;
|
||||||
|
const saveOrUpdate = isUpdate.value ? updateDictData : addDictData;
|
||||||
|
form.dictDataCode = form.dictDataName;
|
||||||
|
form.dictId = props.dictId;
|
||||||
|
saveOrUpdate(form)
|
||||||
|
.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);
|
||||||
|
};
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.visible,
|
||||||
|
(visible) => {
|
||||||
|
if (visible) {
|
||||||
|
if (props.data) {
|
||||||
|
assignFields(props.data);
|
||||||
|
isUpdate.value = true;
|
||||||
|
} else {
|
||||||
|
isUpdate.value = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resetFields();
|
||||||
|
formRef.value?.clearValidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
</script>
|
||||||
225
src/views/tower/purchase/dict/index.vue
Normal file
225
src/views/tower/purchase/dict/index.vue
Normal file
@@ -0,0 +1,225 @@
|
|||||||
|
<template>
|
||||||
|
<div class="ele-body">
|
||||||
|
<a-card :bordered="false">
|
||||||
|
<!-- 表格 -->
|
||||||
|
<ele-pro-table
|
||||||
|
ref="tableRef"
|
||||||
|
row-key="dictDataId"
|
||||||
|
:columns="columns"
|
||||||
|
:datasource="datasource"
|
||||||
|
:customRow="customRow"
|
||||||
|
:scroll="{ x: 800 }"
|
||||||
|
cache-key="purchaseDictTable"
|
||||||
|
>
|
||||||
|
<template #toolbar>
|
||||||
|
<a-space>
|
||||||
|
<a-button type="primary" class="ele-btn-icon" @click="openEdit()">
|
||||||
|
<template #icon>
|
||||||
|
<plus-outlined />
|
||||||
|
</template>
|
||||||
|
<span>新建</span>
|
||||||
|
</a-button>
|
||||||
|
<a-button
|
||||||
|
danger
|
||||||
|
type="primary"
|
||||||
|
class="ele-btn-icon"
|
||||||
|
@click="removeBatch"
|
||||||
|
>
|
||||||
|
<template #icon>
|
||||||
|
<delete-outlined />
|
||||||
|
</template>
|
||||||
|
<span>删除</span>
|
||||||
|
</a-button>
|
||||||
|
</a-space>
|
||||||
|
</template>
|
||||||
|
<template #bodyCell="{ column, record }">
|
||||||
|
<template v-if="column.key === 'action'">
|
||||||
|
<a-space>
|
||||||
|
<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>
|
||||||
|
<!-- 编辑弹窗 -->
|
||||||
|
<dict-edit
|
||||||
|
v-model:visible="showEdit"
|
||||||
|
:dictId="dictId"
|
||||||
|
:data="current"
|
||||||
|
@done="reload"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { createVNode, ref } from 'vue';
|
||||||
|
import { message, Modal } from 'ant-design-vue/es';
|
||||||
|
import {
|
||||||
|
PlusOutlined,
|
||||||
|
DeleteOutlined,
|
||||||
|
ExclamationCircleOutlined
|
||||||
|
} from '@ant-design/icons-vue';
|
||||||
|
import type { EleProTable } from 'ele-admin-pro/es';
|
||||||
|
import type {
|
||||||
|
DatasourceFunction,
|
||||||
|
ColumnItem
|
||||||
|
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||||
|
import { messageLoading } from 'ele-admin-pro/es';
|
||||||
|
import DictEdit from './components/dict-edit.vue';
|
||||||
|
import {
|
||||||
|
pageDictData,
|
||||||
|
removeDictData,
|
||||||
|
removeDictDataBatch
|
||||||
|
} from '@/api/system/dict-data';
|
||||||
|
import { DictParam } from '@/api/system/dict/model';
|
||||||
|
import { DictData } from '@/api/system/dict-data/model';
|
||||||
|
import { addDict, listDictionaries } from '@/api/system/dict';
|
||||||
|
import { Dictionary } from '@/api/system/dictionary/model';
|
||||||
|
|
||||||
|
// 表格实例
|
||||||
|
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||||
|
const dictId = ref(0);
|
||||||
|
|
||||||
|
// 表格列配置
|
||||||
|
const columns = ref<ColumnItem[]>([
|
||||||
|
{
|
||||||
|
key: 'index',
|
||||||
|
width: 48,
|
||||||
|
align: 'center',
|
||||||
|
fixed: 'left',
|
||||||
|
hideInSetting: true,
|
||||||
|
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '分类名称',
|
||||||
|
dataIndex: 'dictDataName',
|
||||||
|
showSorterTooltip: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '备注',
|
||||||
|
dataIndex: 'comments',
|
||||||
|
sorter: true,
|
||||||
|
showSorterTooltip: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '排序号',
|
||||||
|
width: 180,
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'sortNumber'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
key: 'action',
|
||||||
|
width: 180,
|
||||||
|
align: 'center'
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 表格选中数据
|
||||||
|
const selection = ref<DictData[]>([]);
|
||||||
|
|
||||||
|
// 当前编辑数据
|
||||||
|
const current = ref<Dictionary | null>(null);
|
||||||
|
|
||||||
|
// 是否显示编辑弹窗
|
||||||
|
const showEdit = ref(false);
|
||||||
|
|
||||||
|
// 表格数据源
|
||||||
|
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
|
||||||
|
where.dictCode = 'purchaseType';
|
||||||
|
return pageDictData({ ...where, ...orders, page, limit });
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 搜索 */
|
||||||
|
const reload = (where?: DictParam) => {
|
||||||
|
selection.value = [];
|
||||||
|
tableRef?.value?.reload({ page: 1, where });
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 打开编辑弹窗 */
|
||||||
|
const openEdit = (row?: DictData) => {
|
||||||
|
current.value = row ?? null;
|
||||||
|
showEdit.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 删除单个 */
|
||||||
|
const remove = (row: DictData) => {
|
||||||
|
const hide = messageLoading('请求中..', 0);
|
||||||
|
removeDictData(row.dictDataId)
|
||||||
|
.then((msg) => {
|
||||||
|
hide();
|
||||||
|
message.success(msg);
|
||||||
|
reload();
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
hide();
|
||||||
|
message.error(e.message);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 批量删除 */
|
||||||
|
const removeBatch = () => {
|
||||||
|
if (!selection.value.length) {
|
||||||
|
message.error('请至少选择一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Modal.confirm({
|
||||||
|
title: '提示',
|
||||||
|
content: '确定要删除选中的分类吗?',
|
||||||
|
icon: createVNode(ExclamationCircleOutlined),
|
||||||
|
maskClosable: true,
|
||||||
|
onOk: () => {
|
||||||
|
const hide = messageLoading('请求中..', 0);
|
||||||
|
removeDictDataBatch(selection.value.map((d) => d.dictDataId))
|
||||||
|
.then((msg) => {
|
||||||
|
hide();
|
||||||
|
message.success(msg);
|
||||||
|
reload();
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
hide();
|
||||||
|
message.error(e.message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 初始化字典
|
||||||
|
const loadDict = () => {
|
||||||
|
listDictionaries({ dictCode: 'purchaseType' }).then(async (data) => {
|
||||||
|
if (data?.length == 0) {
|
||||||
|
await addDict({ dictCode: 'purchaseType', dictName: '链接分类' });
|
||||||
|
}
|
||||||
|
await listDictionaries({ dictCode: 'purchaseType' }).then((list) => {
|
||||||
|
list?.map((d) => {
|
||||||
|
dictId.value = Number(d.dictId);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
loadDict();
|
||||||
|
|
||||||
|
/* 自定义行属性 */
|
||||||
|
const customRow = (record: DictData) => {
|
||||||
|
return {
|
||||||
|
onDblclick: () => {
|
||||||
|
openEdit(record);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
export default {
|
||||||
|
name: 'PurchaseDictData'
|
||||||
|
};
|
||||||
|
</script>
|
||||||
200
src/views/tower/purchase/index.vue
Normal file
200
src/views/tower/purchase/index.vue
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
<template>
|
||||||
|
<div class="ele-body">
|
||||||
|
<a-card :bordered="false">
|
||||||
|
<!-- 表格 -->
|
||||||
|
<ele-pro-table
|
||||||
|
ref="tableRef"
|
||||||
|
row-key="purchaseId"
|
||||||
|
:columns="columns"
|
||||||
|
:datasource="datasource"
|
||||||
|
:customRow="customRow"
|
||||||
|
:need-page="false"
|
||||||
|
:expand-icon-column-index="1"
|
||||||
|
:scroll="{ x: 1200 }"
|
||||||
|
cache-key="towerPurchase"
|
||||||
|
>
|
||||||
|
<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 === 'price'">
|
||||||
|
¥{{ record.price }}
|
||||||
|
</template>
|
||||||
|
<template v-if="column.key == 'totalPurchase'">
|
||||||
|
{{ record.month * record.num }}
|
||||||
|
</template>
|
||||||
|
<template v-if="column.key === 'action'">
|
||||||
|
<a-space>
|
||||||
|
<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>
|
||||||
|
<!-- 编辑弹窗 -->
|
||||||
|
<PurchaseEdit 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 {
|
||||||
|
TowerPurchase,
|
||||||
|
TowerPurchaseParam
|
||||||
|
} from '@/api/tower/purchase/model';
|
||||||
|
import { listTowerPurchase, removeTowerPurchase } from '@/api/tower/purchase';
|
||||||
|
import PurchaseEdit from '@/views/tower/purchase/components/purchase-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: 'companyName',
|
||||||
|
key: 'companyName',
|
||||||
|
showSorterTooltip: false,
|
||||||
|
ellipsis: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '部件名称',
|
||||||
|
dataIndex: 'name',
|
||||||
|
key: 'name',
|
||||||
|
showSorterTooltip: false,
|
||||||
|
ellipsis: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '部件分类',
|
||||||
|
dataIndex: 'purchaseType',
|
||||||
|
key: 'purchaseType',
|
||||||
|
showSorterTooltip: false,
|
||||||
|
ellipsis: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '价格',
|
||||||
|
dataIndex: 'price',
|
||||||
|
key: 'price',
|
||||||
|
showSorterTooltip: false,
|
||||||
|
ellipsis: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '创建时间',
|
||||||
|
dataIndex: 'createTime',
|
||||||
|
sorter: true,
|
||||||
|
showSorterTooltip: false,
|
||||||
|
ellipsis: true,
|
||||||
|
width: 180,
|
||||||
|
customRender: ({ text }) => toDateString(text)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
key: 'action',
|
||||||
|
width: 200,
|
||||||
|
align: 'center'
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 当前编辑数据
|
||||||
|
const current = ref<TowerPurchase | null>(null);
|
||||||
|
const searchText = ref('');
|
||||||
|
// 是否显示编辑弹窗
|
||||||
|
const showEdit = ref(false);
|
||||||
|
|
||||||
|
// 表格数据源
|
||||||
|
const datasource: DatasourceFunction = ({ where }) => {
|
||||||
|
if (searchText.value) {
|
||||||
|
where.name = searchText.value;
|
||||||
|
}
|
||||||
|
return listTowerPurchase({ ...where });
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 刷新表格 */
|
||||||
|
const reload = (where?: TowerPurchaseParam) => {
|
||||||
|
tableRef?.value?.reload({ where });
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 打开编辑弹窗 */
|
||||||
|
const openEdit = (row?: TowerPurchase | null, id?: number) => {
|
||||||
|
current.value = row ?? null;
|
||||||
|
showEdit.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const search = (searchText) => {
|
||||||
|
reload({ name: searchText });
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 删除单个 */
|
||||||
|
const remove = (row: TowerPurchase) => {
|
||||||
|
const hide = messageLoading('请求中..', 0);
|
||||||
|
removeTowerPurchase(row.purchaseId)
|
||||||
|
.then((msg) => {
|
||||||
|
hide();
|
||||||
|
message.success(msg);
|
||||||
|
reload();
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
hide();
|
||||||
|
message.error(e.message);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 自定义行属性 */
|
||||||
|
const customRow = (record: TowerPurchase) => {
|
||||||
|
return {
|
||||||
|
// 行点击事件
|
||||||
|
onClick: () => {
|
||||||
|
// console.log(record);
|
||||||
|
},
|
||||||
|
// 行双击事件
|
||||||
|
onDblclick: () => {
|
||||||
|
openEdit(record);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
export default {
|
||||||
|
name: 'TowerPurchase'
|
||||||
|
};
|
||||||
|
</script>
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
<a-col
|
<a-col
|
||||||
v-bind="styleResponsive ? { md: 22, sm: 24, xs: 24 } : { span: 12 }"
|
v-bind="styleResponsive ? { md: 22, sm: 24, xs: 24 } : { span: 12 }"
|
||||||
>
|
>
|
||||||
<a-form-item label="租赁名称" name="company">
|
<a-form-item label="租赁单位" name="company">
|
||||||
<SelectCompany
|
<SelectCompany
|
||||||
:placeholder="`请选择租赁单位`"
|
:placeholder="`请选择租赁单位`"
|
||||||
v-model:value="form.companyName"
|
v-model:value="form.companyName"
|
||||||
|
|||||||
Reference in New Issue
Block a user