1.0.3 add计量单位、物料、关联销售物料

dev
yinq 3 months ago
parent 81ad403f29
commit f8636f8152

@ -0,0 +1,76 @@
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MaterielInfoVO, MaterielInfoForm, MaterielInfoQuery } from '@/api/oa/base/materielInfo/types';
/**
* SAP
* @param query
* @returns {*}
*/
export const listMaterielInfo = (query?: MaterielInfoQuery): AxiosPromise<MaterielInfoVO[]> => {
return request({
url: '/oa/base/materielInfo/list',
method: 'get',
params: query
});
};
/**
* SAP
* @param materielId
*/
export const getMaterielInfo = (materielId: string | number): AxiosPromise<MaterielInfoVO> => {
return request({
url: '/oa/base/materielInfo/' + materielId,
method: 'get'
});
};
/**
* SAP
* @param data
*/
export const addMaterielInfo = (data: MaterielInfoForm) => {
return request({
url: '/oa/base/materielInfo',
method: 'post',
data: data
});
};
/**
* SAP
* @param data
*/
export const updateMaterielInfo = (data: MaterielInfoForm) => {
return request({
url: '/oa/base/materielInfo',
method: 'put',
data: data
});
};
/**
* SAP
* @param materielId
*/
export const delMaterielInfo = (materielId: string | number | Array<string | number>) => {
return request({
url: '/oa/base/materielInfo/' + materielId,
method: 'delete'
});
};
/**
* SAP
* @param query
* @returns {*}
*/
export function getBaseMaterielInfoList(query) {
return request({
url: '/oa/base/materielInfo/getBaseMaterielInfoList',
method: 'get',
params: query
});
}

@ -0,0 +1,186 @@
export interface MaterielInfoVO {
/**
* ID
*/
materielId: string | number;
/**
* SAP
*/
materielCode: string;
/**
* SAP
*/
materielName: string;
/**
*
*/
materielBrand: string;
/**
*
*/
materielModel: string;
/**
* ID
*/
unitId: string | number;
/**
*
*/
materialParameter: string;
/**
* ()
*/
purchasePrice: number;
/**
* ()
*/
foreignPrice: number;
/**
*
*/
stockingPeriod: number;
/**
*
*/
remark: string;
/**
* 1 0
*/
activeFlag: string;
}
export interface MaterielInfoForm extends BaseEntity {
/**
* ID
*/
materielId?: string | number;
/**
* SAP
*/
materielCode?: string;
/**
* SAP
*/
materielName?: string;
/**
*
*/
materielBrand?: string;
/**
*
*/
materielModel?: string;
/**
* ID
*/
unitId?: string | number;
/**
*
*/
materialParameter?: string;
/**
* ()
*/
purchasePrice?: number;
/**
* ()
*/
foreignPrice?: number;
/**
*
*/
stockingPeriod?: number;
/**
*
*/
remark?: string;
/**
* 1 0
*/
activeFlag?: string;
}
export interface MaterielInfoQuery extends PageQuery {
/**
* SAP
*/
materielCode?: string;
/**
* SAP
*/
materielName?: string;
/**
*
*/
materielBrand?: string;
/**
*
*/
materielModel?: string;
/**
* ID
*/
unitId?: string | number;
/**
*
*/
materialParameter?: string;
/**
* ()
*/
purchasePrice?: number;
/**
* ()
*/
foreignPrice?: number;
/**
*
*/
stockingPeriod?: number;
/**
* 1 0
*/
activeFlag?: string;
/**
*
*/
params?: any;
}

@ -0,0 +1,76 @@
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RelationMaterielVO, RelationMaterielForm, RelationMaterielQuery } from '@/api/oa/base/relationMateriel/types';
/**
*
* @param query
* @returns {*}
*/
export const listRelationMateriel = (query?: RelationMaterielQuery): AxiosPromise<RelationMaterielVO[]> => {
return request({
url: '/oa/base/relationMateriel/list',
method: 'get',
params: query
});
};
/**
*
* @param relationMaterielId
*/
export const getRelationMateriel = (relationMaterielId: string | number): AxiosPromise<RelationMaterielVO> => {
return request({
url: '/oa/base/relationMateriel/' + relationMaterielId,
method: 'get'
});
};
/**
*
* @param data
*/
export const addRelationMateriel = (data: RelationMaterielForm) => {
return request({
url: '/oa/base/relationMateriel',
method: 'post',
data: data
});
};
/**
*
* @param data
*/
export const updateRelationMateriel = (data: RelationMaterielForm) => {
return request({
url: '/oa/base/relationMateriel',
method: 'put',
data: data
});
};
/**
*
* @param relationMaterielId
*/
export const delRelationMateriel = (relationMaterielId: string | number | Array<string | number>) => {
return request({
url: '/oa/base/relationMateriel/' + relationMaterielId,
method: 'delete'
});
};
/**
*
* @param query
* @returns {*}
*/
export function getBaseRelationMaterielList(query) {
return request({
url: '/oa/base/relationMateriel/getBaseRelationMaterielList',
method: 'get',
params: query
});
}

@ -0,0 +1,141 @@
export interface RelationMaterielVO {
/**
* ID
*/
relationMaterielId: string | number;
/**
* ID
*/
materielId: string | number;
/**
* ID
*/
customerId: string | number;
/**
* SAP
*/
materielCode: string;
/**
* SAP
*/
materielName: string;
/**
*
*/
customerName: string;
/**
*
*/
saleMaterielName: string;
/**
*
*/
remark: string;
/**
* 1 0
*/
activeFlag: string;
}
export interface RelationMaterielForm extends BaseEntity {
/**
* ID
*/
relationMaterielId?: string | number;
/**
* ID
*/
materielId?: string | number;
/**
* ID
*/
customerId?: string | number;
/**
* SAP
*/
materielCode: string;
/**
* SAP
*/
materielName: string;
/**
*
*/
customerName: string;
/**
*
*/
saleMaterielName?: string;
/**
*
*/
remark?: string;
/**
* 1 0
*/
activeFlag?: string;
}
export interface RelationMaterielQuery extends PageQuery {
/**
* ID
*/
materielId?: string | number;
/**
* ID
*/
customerId?: string | number;
/**
*
*/
saleMaterielName?: string;
/**
* SAP
*/
materielCode: string;
/**
* SAP
*/
materielName: string;
/**
*
*/
customerName: string;
/**
* 1 0
*/
activeFlag?: string;
/**
*
*/
params?: any;
}

@ -0,0 +1,76 @@
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { UnitInfoVO, UnitInfoForm, UnitInfoQuery } from '@/api/oa/base/unitInfo/types';
/**
*
* @param query
* @returns {*}
*/
export const listUnitInfo = (query?: UnitInfoQuery): AxiosPromise<UnitInfoVO[]> => {
return request({
url: '/oa/base/unitInfo/list',
method: 'get',
params: query
});
};
/**
*
* @param unitId
*/
export const getUnitInfo = (unitId: string | number): AxiosPromise<UnitInfoVO> => {
return request({
url: '/oa/base/unitInfo/' + unitId,
method: 'get'
});
};
/**
*
* @param data
*/
export const addUnitInfo = (data: UnitInfoForm) => {
return request({
url: '/oa/base/unitInfo',
method: 'post',
data: data
});
};
/**
*
* @param data
*/
export const updateUnitInfo = (data: UnitInfoForm) => {
return request({
url: '/oa/base/unitInfo',
method: 'put',
data: data
});
};
/**
*
* @param unitId
*/
export const delUnitInfo = (unitId: string | number | Array<string | number>) => {
return request({
url: '/oa/base/unitInfo/' + unitId,
method: 'delete'
});
};
/**
*
* @param query
* @returns {*}
*/
export function getBaseUnitInfoList(query) {
return request({
url: '/oa/base/unitInfo/getBaseUnitInfoList',
method: 'get',
params: query
});
}

@ -0,0 +1,96 @@
export interface UnitInfoVO {
/**
* ID
*/
unitId: string | number;
/**
*
*/
unitCode: string;
/**
*
*/
unitName: string;
/**
* 1 2 3 4 5
*/
unitType: string;
/**
*
*/
remark: string;
/**
* 1 0
*/
activeFlag: string;
}
export interface UnitInfoForm extends BaseEntity {
/**
* ID
*/
unitId?: string | number;
/**
*
*/
unitCode?: string;
/**
*
*/
unitName?: string;
/**
* 1 2 3 4 5
*/
unitType?: string;
/**
*
*/
remark?: string;
/**
* 1 0
*/
activeFlag?: string;
}
export interface UnitInfoQuery extends PageQuery {
/**
*
*/
unitCode?: string;
/**
*
*/
unitName?: string;
/**
* 1 2 3 4 5
*/
unitType?: string;
/**
* 1 0
*/
activeFlag?: string;
/**
*
*/
params?: any;
}

@ -0,0 +1,340 @@
<template>
<div class="p-2">
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="100px">
<el-form-item label="SAP物料编码" prop="materielCode">
<el-input v-model="queryParams.materielCode" placeholder="请输入SAP物料编码" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="SAP物料名称" prop="materielName">
<el-input v-model="queryParams.materielName" placeholder="请输入SAP物料名称" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="物料品牌" prop="materielBrand">
<el-input v-model="queryParams.materielBrand" placeholder="请输入物料品牌" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="物料型号" prop="materielModel">
<el-input v-model="queryParams.materielModel" placeholder="请输入物料型号" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="物料参数" prop="materialParameter">
<el-input v-model="queryParams.materialParameter" placeholder="请输入物料参数" clearable @keyup.enter="handleQuery" />
</el-form-item>
<!-- <el-form-item label="激活标识" prop="activeFlag">-->
<!-- <el-select v-model="queryParams.activeFlag" placeholder="请选择激活标识" clearable>-->
<!-- <el-option v-for="dict in active_flag" :key="dict.value" :label="dict.label" :value="dict.value" />-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery"></el-button>
<el-button icon="Refresh" @click="resetQuery"></el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</transition>
<el-card shadow="never">
<template #header>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['oa/base:materielInfo:add']"> </el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['oa/base:materielInfo:edit']"
>修改
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['oa/base:materielInfo:remove']"
>删除
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['oa/base:materielInfo:export']"> </el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" :columns="columns" :search="true" @queryTable="getList"></right-toolbar>
</el-row>
</template>
<el-table v-loading="loading" border :data="materielInfoList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="物料ID" align="center" prop="materielId" v-if="columns[0].visible" />
<el-table-column label="SAP物料编码" align="center" prop="materielCode" width="120" v-if="columns[2].visible" />
<el-table-column label="SAP物料名称" align="center" prop="materielName" width="120" v-if="columns[3].visible" />
<el-table-column label="物料品牌" align="center" prop="materielBrand" width="120" v-if="columns[4].visible" />
<el-table-column label="物料型号" align="center" prop="materielModel" width="120" v-if="columns[5].visible" />
<el-table-column label="物料单位" align="center" prop="unitName" v-if="columns[6].visible" />
<el-table-column label="物料参数" align="center" prop="materialParameter" v-if="columns[7].visible" />
<el-table-column label="采购单价(元)" align="center" prop="purchasePrice" width="120" v-if="columns[8].visible" />
<el-table-column label="售前对外单价(元)" align="center" prop="foreignPrice" width="140" v-if="columns[9].visible" />
<el-table-column label="备货期" align="center" prop="stockingPeriod" v-if="columns[10].visible" />
<el-table-column label="备注" align="center" prop="remark" v-if="columns[11].visible" />
<el-table-column label="激活标识" align="center" prop="activeFlag" v-if="columns[12].visible">
<template #default="scope">
<dict-tag :options="active_flag" :value="scope.row.activeFlag" />
</template>
</el-table-column>
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
<template #default="scope">
<el-tooltip content="修改" placement="top">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['oa/base:materielInfo:edit']"></el-button>
</el-tooltip>
<el-tooltip content="删除" placement="top">
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['oa/base:materielInfo:remove']"></el-button>
</el-tooltip>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
</el-card>
<!-- 添加或修改SAP物料信息对话框 -->
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
<el-form ref="materielInfoFormRef" :model="form" :rules="rules" label-width="120px">
<el-form-item label="SAP物料编码" prop="materielCode">
<el-input v-model="form.materielCode" placeholder="请输入SAP物料编码" />
</el-form-item>
<el-form-item label="SAP物料名称" prop="materielName">
<el-input v-model="form.materielName" placeholder="请输入SAP物料名称" />
</el-form-item>
<el-form-item label="物料品牌" prop="materielBrand">
<el-input v-model="form.materielBrand" placeholder="请输入物料品牌" />
</el-form-item>
<el-form-item label="物料型号" prop="materielModel">
<el-input v-model="form.materielModel" placeholder="请输入物料型号" />
</el-form-item>
<el-form-item label="物料单位" prop="unitId">
<el-select v-model="form.unitId" placeholder="请选择物料单位">
<el-option
v-for="item in unitInfoList"
:key="item.unitId"
:label="item.unitName"
:value="item.unitId"
/>
</el-select>
</el-form-item>
<el-form-item label="物料参数" prop="materialParameter">
<el-input v-model="form.materialParameter" placeholder="请输入物料参数" />
</el-form-item>
<el-form-item label="采购单价(元)" prop="purchasePrice">
<el-input-number v-model="form.purchasePrice" placeholder="请输入采购单价(元)" style="width: 240px" />
</el-form-item>
<el-form-item label="售前对外单价(元)" prop="foreignPrice">
<el-input-number v-model="form.foreignPrice" placeholder="请输入售前对外单价(元)" style="width: 240px" />
</el-form-item>
<el-form-item label="备货期" prop="stockingPeriod">
<el-input-number v-model="form.stockingPeriod" placeholder="请输入备货期" style="width: 240px" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
<!-- <el-form-item label="激活标识" prop="activeFlag">-->
<!-- <el-radio-group v-model="form.activeFlag">-->
<!-- <el-radio v-for="dict in active_flag" :key="dict.value" :value="dict.value">{{ dict.label }} </el-radio>-->
<!-- </el-radio-group>-->
<!-- </el-form-item>-->
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup name="MaterielInfo" lang="ts">
import { listMaterielInfo, getMaterielInfo, delMaterielInfo, addMaterielInfo, updateMaterielInfo } from '@/api/oa/base/materielInfo';
import { MaterielInfoVO, MaterielInfoQuery, MaterielInfoForm } from '@/api/oa/base/materielInfo/types';
import { getBaseUnitInfoList } from '@/api/oa/base/unitInfo';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { active_flag } = toRefs<any>(proxy?.useDict('active_flag'));
const materielInfoList = ref<MaterielInfoVO[]>([]);
const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref<Array<string | number>>([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const queryFormRef = ref<ElFormInstance>();
const materielInfoFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({
visible: false,
title: ''
});
/** 查询单位信息下拉框结构 */
const unitInfoList = ref([]);
const getUnitInfoListSelect = async () => {
let res = await getBaseUnitInfoList(null);
unitInfoList.value = res.data;
};
//
const columns = ref<FieldOption[]>([
{ key: 0, label: `物料ID`, visible: false },
{ key: 1, label: `租户编号`, visible: true },
{ key: 2, label: `SAP物料编码`, visible: true },
{ key: 3, label: `SAP物料名称`, visible: true },
{ key: 4, label: `物料品牌`, visible: true },
{ key: 5, label: `物料型号`, visible: true },
{ key: 6, label: `物料单位`, visible: true },
{ key: 7, label: `物料参数`, visible: true },
{ key: 8, label: `采购单价(元)`, visible: true },
{ key: 9, label: `售前对外单价(元)`, visible: true },
{ key: 10, label: `备货期`, visible: true },
{ key: 11, label: `备注`, visible: false },
{ key: 12, label: `激活标识`, visible: false },
{ key: 13, label: `删除标志`, visible: false },
{ key: 14, label: `创建部门`, visible: false },
{ key: 15, label: `创建人`, visible: false },
{ key: 16, label: `创建时间`, visible: false },
{ key: 17, label: `更新人`, visible: false },
{ key: 18, label: `更新时间`, visible: false }
]);
const initFormData: MaterielInfoForm = {
materielId: undefined,
materielCode: undefined,
materielName: undefined,
materielBrand: undefined,
materielModel: undefined,
unitId: undefined,
materialParameter: undefined,
purchasePrice: undefined,
foreignPrice: undefined,
stockingPeriod: undefined,
remark: undefined,
activeFlag: undefined
};
const data = reactive<PageData<MaterielInfoForm, MaterielInfoQuery>>({
form: { ...initFormData },
queryParams: {
pageNum: 1,
pageSize: 10,
materielCode: undefined,
materielName: undefined,
materielBrand: undefined,
materielModel: undefined,
unitId: undefined,
materialParameter: undefined,
purchasePrice: undefined,
foreignPrice: undefined,
stockingPeriod: undefined,
activeFlag: undefined,
params: {}
},
rules: {
materielCode: [{ required: true, message: 'SAP物料编码不能为空', trigger: 'blur' }],
materielName: [{ required: true, message: 'SAP物料名称不能为空', trigger: 'blur' }],
unitId: [{ required: true, message: '物料单位不能为空', trigger: 'blur' }]
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询SAP物料信息列表 */
const getList = async () => {
loading.value = true;
const res = await listMaterielInfo(queryParams.value);
materielInfoList.value = res.rows;
total.value = res.total;
loading.value = false;
};
/** 取消按钮 */
const cancel = () => {
reset();
dialog.visible = false;
};
/** 表单重置 */
const reset = () => {
form.value = { ...initFormData };
materielInfoFormRef.value?.resetFields();
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
};
/** 多选框选中数据 */
const handleSelectionChange = (selection: MaterielInfoVO[]) => {
ids.value = selection.map((item) => item.materielId);
single.value = selection.length != 1;
multiple.value = !selection.length;
};
/** 新增按钮操作 */
const handleAdd = () => {
reset();
dialog.visible = true;
dialog.title = '添加SAP物料信息';
};
/** 修改按钮操作 */
const handleUpdate = async (row?: MaterielInfoVO) => {
reset();
const _materielId = row?.materielId || ids.value[0];
const res = await getMaterielInfo(_materielId);
Object.assign(form.value, res.data);
dialog.visible = true;
dialog.title = '修改SAP物料信息';
};
/** 提交按钮 */
const submitForm = () => {
materielInfoFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
if (form.value.materielId) {
await updateMaterielInfo(form.value).finally(() => (buttonLoading.value = false));
} else {
await addMaterielInfo(form.value).finally(() => (buttonLoading.value = false));
}
proxy?.$modal.msgSuccess('操作成功');
dialog.visible = false;
await getList();
}
});
};
/** 删除按钮操作 */
const handleDelete = async (row?: MaterielInfoVO) => {
const _materielIds = row?.materielId || ids.value;
await proxy?.$modal.confirm('是否确认删除SAP物料信息编号为"' + _materielIds + '"的数据项?').finally(() => (loading.value = false));
await delMaterielInfo(_materielIds);
proxy?.$modal.msgSuccess('删除成功');
await getList();
};
/** 导出按钮操作 */
const handleExport = () => {
proxy?.download(
'oa/base/materielInfo/export',
{
...queryParams.value
},
`materielInfo_${new Date().getTime()}.xlsx`
);
};
onMounted(() => {
getUnitInfoListSelect();
getList();
});
</script>

@ -0,0 +1,306 @@
<template>
<div class="p-2">
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="100px">
<el-form-item label="SAP物料编码" prop="materielCode">
<el-input v-model="queryParams.materielCode" placeholder="请输入SAP物料编码" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="SAP物料名称" prop="materielName">
<el-input v-model="queryParams.materielName" placeholder="请输入SAP物料名称" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="客户名称" prop="customerId">
<el-select v-model="queryParams.customerId" placeholder="请选择客户名称" filterable clearable @keyup.enter="handleQuery">
<el-option v-for="item in customerInfoList" :key="item.customerId" :label="item.customerName" :value="item.customerId" />
</el-select>
</el-form-item>
<el-form-item label="销售物料名称" prop="saleMaterielName">
<el-input v-model="queryParams.saleMaterielName" placeholder="请输入销售物料名称" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="激活标识" prop="activeFlag">
<el-select v-model="queryParams.activeFlag" placeholder="请选择激活标识" clearable>
<el-option v-for="dict in active_flag" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery"></el-button>
<el-button icon="Refresh" @click="resetQuery"></el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</transition>
<el-card shadow="never">
<template #header>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['oa/base:relationMateriel:add']"> </el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['oa/base:relationMateriel:edit']"
>修改
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['oa/base:relationMateriel:remove']"
>删除
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['oa/base:relationMateriel:export']"> </el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" :columns="columns" :search="true" @queryTable="getList"></right-toolbar>
</el-row>
</template>
<el-table v-loading="loading" border :data="relationMaterielList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="关联物料ID" align="center" prop="relationMaterielId" v-if="columns[0].visible" />
<el-table-column label="物料ID" align="center" prop="materielId" v-if="columns[2].visible" />
<el-table-column label="客户名称" align="center" prop="customerId" v-if="columns[3].visible" />
<el-table-column label="销售物料名称" align="center" prop="saleMaterielName" v-if="columns[4].visible" />
<el-table-column label="备注" align="center" prop="remark" v-if="columns[5].visible" />
<el-table-column label="激活标识" align="center" prop="activeFlag" v-if="columns[6].visible">
<template #default="scope">
<dict-tag :options="active_flag" :value="scope.row.activeFlag" />
</template>
</el-table-column>
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
<template #default="scope">
<el-tooltip content="修改" placement="top">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['oa/base:relationMateriel:edit']"></el-button>
</el-tooltip>
<el-tooltip content="删除" placement="top">
<el-button
link
type="primary"
icon="Delete"
@click="handleDelete(scope.row)"
v-hasPermi="['oa/base:relationMateriel:remove']"
></el-button>
</el-tooltip>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
</el-card>
<!-- 添加或修改关联销售物料信息对话框 -->
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
<el-form ref="relationMaterielFormRef" :model="form" :rules="rules" label-width="120px">
<el-form-item label="物料ID" prop="materielId">
<el-input v-model="form.materielId" placeholder="请输入物料ID" />
</el-form-item>
<el-form-item label="客户名称" prop="customerId">
<el-input v-model="form.customerId" placeholder="请输入客户名称" />
</el-form-item>
<el-form-item label="销售物料名称" prop="saleMaterielName">
<el-input v-model="form.saleMaterielName" placeholder="请输入销售物料名称" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
<el-form-item label="激活标识" prop="activeFlag">
<el-radio-group v-model="form.activeFlag">
<el-radio v-for="dict in active_flag" :key="dict.value" :value="dict.value">{{ dict.label }}</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup name="RelationMateriel" lang="ts">
import {
listRelationMateriel,
getRelationMateriel,
delRelationMateriel,
addRelationMateriel,
updateRelationMateriel
} from '@/api/oa/base/relationMateriel';
import { RelationMaterielVO, RelationMaterielQuery, RelationMaterielForm } from '@/api/oa/base/relationMateriel/types';
import { getCrmCustomerInfoList } from '@/api/oa/crm/customerInfo';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { active_flag } = toRefs<any>(proxy?.useDict('active_flag'));
const relationMaterielList = ref<RelationMaterielVO[]>([]);
const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref<Array<string | number>>([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const queryFormRef = ref<ElFormInstance>();
const relationMaterielFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({
visible: false,
title: ''
});
/** 查询客户信息下拉框结构 */
const customerInfoList = ref([]);
const getCustomerInfoListSelect = async () => {
let res = await getCrmCustomerInfoList(null);
customerInfoList.value = res.data;
};
//
const columns = ref<FieldOption[]>([
{ key: 0, label: `关联物料ID`, visible: true },
{ key: 1, label: `租户编号`, visible: true },
{ key: 2, label: `物料ID`, visible: true },
{ key: 3, label: `客户名称`, visible: true },
{ key: 4, label: `销售物料名称`, visible: true },
{ key: 5, label: `备注`, visible: true },
{ key: 6, label: `激活标识`, visible: true },
{ key: 7, label: `删除标志`, visible: true },
{ key: 8, label: `创建部门`, visible: true },
{ key: 9, label: `创建人`, visible: true },
{ key: 10, label: `创建时间`, visible: true },
{ key: 11, label: `更新人`, visible: true },
{ key: 12, label: `更新时间`, visible: true }
]);
const initFormData: RelationMaterielForm = {
relationMaterielId: undefined,
materielId: undefined,
materielCode: undefined,
materielName: undefined,
customerId: undefined,
customerName: undefined,
saleMaterielName: undefined,
remark: undefined,
activeFlag: undefined
};
const data = reactive<PageData<RelationMaterielForm, RelationMaterielQuery>>({
form: { ...initFormData },
queryParams: {
pageNum: 1,
pageSize: 10,
materielId: undefined,
materielCode: undefined,
materielName: undefined,
customerId: undefined,
customerName: undefined,
saleMaterielName: undefined,
activeFlag: undefined,
params: {}
},
rules: {
relationMaterielId: [{ required: true, message: '关联物料ID不能为空', trigger: 'blur' }]
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询关联销售物料信息列表 */
const getList = async () => {
loading.value = true;
const res = await listRelationMateriel(queryParams.value);
relationMaterielList.value = res.rows;
total.value = res.total;
loading.value = false;
};
/** 取消按钮 */
const cancel = () => {
reset();
dialog.visible = false;
};
/** 表单重置 */
const reset = () => {
form.value = { ...initFormData };
relationMaterielFormRef.value?.resetFields();
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
};
/** 多选框选中数据 */
const handleSelectionChange = (selection: RelationMaterielVO[]) => {
ids.value = selection.map((item) => item.relationMaterielId);
single.value = selection.length != 1;
multiple.value = !selection.length;
};
/** 新增按钮操作 */
const handleAdd = () => {
reset();
dialog.visible = true;
dialog.title = '添加关联销售物料信息';
};
/** 修改按钮操作 */
const handleUpdate = async (row?: RelationMaterielVO) => {
reset();
const _relationMaterielId = row?.relationMaterielId || ids.value[0];
const res = await getRelationMateriel(_relationMaterielId);
Object.assign(form.value, res.data);
dialog.visible = true;
dialog.title = '修改关联销售物料信息';
};
/** 提交按钮 */
const submitForm = () => {
relationMaterielFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
if (form.value.relationMaterielId) {
await updateRelationMateriel(form.value).finally(() => (buttonLoading.value = false));
} else {
await addRelationMateriel(form.value).finally(() => (buttonLoading.value = false));
}
proxy?.$modal.msgSuccess('操作成功');
dialog.visible = false;
await getList();
}
});
};
/** 删除按钮操作 */
const handleDelete = async (row?: RelationMaterielVO) => {
const _relationMaterielIds = row?.relationMaterielId || ids.value;
await proxy?.$modal.confirm('是否确认删除关联销售物料信息编号为"' + _relationMaterielIds + '"的数据项?').finally(() => (loading.value = false));
await delRelationMateriel(_relationMaterielIds);
proxy?.$modal.msgSuccess('删除成功');
await getList();
};
/** 导出按钮操作 */
const handleExport = () => {
proxy?.download(
'oa/base/relationMateriel/export',
{
...queryParams.value
},
`relationMateriel_${new Date().getTime()}.xlsx`
);
};
onMounted(() => {
getCustomerInfoListSelect();
getList();
});
</script>

@ -0,0 +1,268 @@
<template>
<div class="p-2">
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width='100px'>
<el-form-item label="计量单位名称" prop="unitName">
<el-input v-model="queryParams.unitName" placeholder="请输入计量单位名称" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="单位类型" prop="unitType">
<el-select v-model="queryParams.unitType" placeholder="请选择单位类型" clearable>
<el-option v-for="dict in unit_type" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery"></el-button>
<el-button icon="Refresh" @click="resetQuery"></el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</transition>
<el-card shadow="never">
<template #header>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['oa/base:unitInfo:add']"> </el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['oa/base:unitInfo:edit']"
>修改
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['oa/base:unitInfo:remove']"
>删除
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['oa/base:unitInfo:export']"> </el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" :columns="columns" :search="true" @queryTable="getList"></right-toolbar>
</el-row>
</template>
<el-table v-loading="loading" border :data="unitInfoList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="单位ID" align="center" prop="unitId" v-if="columns[0].visible" />
<el-table-column label="计量单位编号" align="center" prop="unitCode" v-if="columns[2].visible" />
<el-table-column label="计量单位名称" align="center" prop="unitName" v-if="columns[3].visible" />
<el-table-column label="单位类型" align="center" prop="unitType" v-if="columns[4].visible">
<template #default="scope">
<dict-tag :options="unit_type" :value="scope.row.unitType" />
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" v-if="columns[5].visible" />
<el-table-column label="激活标识" align="center" prop="activeFlag" v-if="columns[6].visible">
<template #default="scope">
<dict-tag :options="active_flag" :value="scope.row.activeFlag" />
</template>
</el-table-column>
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
<template #default="scope">
<el-tooltip content="修改" placement="top">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['oa/base:unitInfo:edit']"></el-button>
</el-tooltip>
<el-tooltip content="删除" placement="top">
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['oa/base:unitInfo:remove']"></el-button>
</el-tooltip>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
</el-card>
<!-- 添加或修改计量单位信息对话框 -->
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
<el-form ref="unitInfoFormRef" :model="form" :rules="rules" label-width="120px">
<el-form-item label="计量单位编号" prop="unitCode">
<el-input v-model="form.unitCode" placeholder="请输入计量单位编号" />
</el-form-item>
<el-form-item label="计量单位名称" prop="unitName">
<el-input v-model="form.unitName" placeholder="请输入计量单位名称" />
</el-form-item>
<el-form-item label="单位类型" prop="unitType">
<el-select v-model="form.unitType" placeholder="请选择单位类型">
<el-option v-for="dict in unit_type" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
</el-select>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
<el-form-item label="激活标识" prop="activeFlag">
<el-radio-group v-model="form.activeFlag">
<el-radio v-for="dict in active_flag" :key="dict.value" :value="dict.value">{{ dict.label }} </el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup name="UnitInfo" lang="ts">
import { listUnitInfo, getUnitInfo, delUnitInfo, addUnitInfo, updateUnitInfo } from '@/api/oa/base/unitInfo';
import { UnitInfoVO, UnitInfoQuery, UnitInfoForm } from '@/api/oa/base/unitInfo/types';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { active_flag, unit_type } = toRefs<any>(proxy?.useDict('active_flag', 'unit_type'));
const unitInfoList = ref<UnitInfoVO[]>([]);
const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref<Array<string | number>>([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const queryFormRef = ref<ElFormInstance>();
const unitInfoFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({
visible: false,
title: ''
});
//
const columns = ref<FieldOption[]>([
{ key: 0, label: `单位ID`, visible: true },
{ key: 1, label: `租户编号`, visible: false },
{ key: 2, label: `计量单位编号`, visible: true },
{ key: 3, label: `计量单位名称`, visible: true },
{ key: 4, label: `单位类型`, visible: true },
{ key: 5, label: `备注`, visible: true },
{ key: 6, label: `激活标识`, visible: true },
]);
const initFormData: UnitInfoForm = {
unitId: undefined,
unitCode: undefined,
unitName: undefined,
unitType: undefined,
remark: undefined,
activeFlag: undefined
};
const data = reactive<PageData<UnitInfoForm, UnitInfoQuery>>({
form: { ...initFormData },
queryParams: {
pageNum: 1,
pageSize: 10,
unitCode: undefined,
unitName: undefined,
unitType: undefined,
activeFlag: undefined,
params: {}
},
rules: {
unitId: [{ required: true, message: '单位ID不能为空', trigger: 'blur' }]
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询计量单位信息列表 */
const getList = async () => {
loading.value = true;
const res = await listUnitInfo(queryParams.value);
unitInfoList.value = res.rows;
total.value = res.total;
loading.value = false;
};
/** 取消按钮 */
const cancel = () => {
reset();
dialog.visible = false;
};
/** 表单重置 */
const reset = () => {
form.value = { ...initFormData };
unitInfoFormRef.value?.resetFields();
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
};
/** 多选框选中数据 */
const handleSelectionChange = (selection: UnitInfoVO[]) => {
ids.value = selection.map((item) => item.unitId);
single.value = selection.length != 1;
multiple.value = !selection.length;
};
/** 新增按钮操作 */
const handleAdd = () => {
reset();
dialog.visible = true;
dialog.title = '添加计量单位信息';
};
/** 修改按钮操作 */
const handleUpdate = async (row?: UnitInfoVO) => {
reset();
const _unitId = row?.unitId || ids.value[0];
const res = await getUnitInfo(_unitId);
Object.assign(form.value, res.data);
dialog.visible = true;
dialog.title = '修改计量单位信息';
};
/** 提交按钮 */
const submitForm = () => {
unitInfoFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
if (form.value.unitId) {
await updateUnitInfo(form.value).finally(() => (buttonLoading.value = false));
} else {
await addUnitInfo(form.value).finally(() => (buttonLoading.value = false));
}
proxy?.$modal.msgSuccess('操作成功');
dialog.visible = false;
await getList();
}
});
};
/** 删除按钮操作 */
const handleDelete = async (row?: UnitInfoVO) => {
const _unitIds = row?.unitId || ids.value;
await proxy?.$modal.confirm('是否确认删除计量单位信息编号为"' + _unitIds + '"的数据项?').finally(() => (loading.value = false));
await delUnitInfo(_unitIds);
proxy?.$modal.msgSuccess('删除成功');
await getList();
};
/** 导出按钮操作 */
const handleExport = () => {
proxy?.download(
'oa/base/unitInfo/export',
{
...queryParams.value
},
`unitInfo_${new Date().getTime()}.xlsx`
);
};
onMounted(() => {
getList();
});
</script>
Loading…
Cancel
Save