projects/mes-test #133

Merged
gtz217 merged 281 commits from projects/mes-test into projects/mes 2023-11-30 09:11:34 +08:00
16 changed files with 2650 additions and 2 deletions
Showing only changes of commit e961bf6cfa - Show all commits

View File

@ -1,7 +1,7 @@
###
# @Author: Do not edit
# @Date: 2023-08-29 09:40:39
# @LastEditTime: 2023-10-16 09:22:52
# @LastEditTime: 2023-10-23 10:50:02
# @LastEditors: DY
# @Description:
###
@ -14,7 +14,8 @@ VUE_APP_TITLE = 产线监控系统
# 芋道管理系统/开发环境
# VUE_APP_BASE_API = 'http://192.168.1.49:48080'
# VUE_APP_BASE_API = 'http://192.168.1.8:48080'
VUE_APP_BASE_API = 'http://192.168.0.33:48080'
# VUE_APP_BASE_API = 'http://192.168.0.33:48082'
VUE_APP_BASE_API = 'http://192.168.1.56:48080'
# VUE_APP_BASE_API = 'http://192.168.1.188:48080'
# 路由懒加载

121
src/api/base/material.js Normal file
View File

@ -0,0 +1,121 @@
/*
* @Author: Do not edit
* @Date: 2023-10-21 11:50:46
* @LastEditTime: 2023-10-24 11:22:28
* @LastEditors: DY
* @Description:
*/
import request from '@/utils/request'
// 创建物料
export function createMaterial(data) {
return request({
url: '/base/material/create',
method: 'post',
data: data
})
}
// 更新物料
export function updateMaterial(data) {
return request({
url: '/base/material/update',
method: 'put',
data: data
})
}
// 删除物料
export function deleteMaterial(id) {
return request({
url: '/base/material/delete?id=' + id,
method: 'delete'
})
}
// 获得物料
export function getMaterial(id) {
return request({
url: '/base/material/get?id=' + id,
method: 'get'
})
}
// 获得物料code
export function getCode() {
return request({
url: '/base/material/getMaterialCode',
method: 'get'
})
}
// 获得物料分页
export function getMaterialPage(query) {
return request({
url: '/base/material/page',
method: 'get',
params: query
})
}
// 获得物料列表
export function getMaterialList(query) {
return request({
url: '/base/material/listbyfilter',
method: 'get',
params: query
})
}
// 获得供应商所有列表
export function getSupplierList(query) {
return request({
url: '/base/core-supplier/listAll',
method: 'get',
params: query
})
}
// 获得物料属性列表
export function getMaterialAttrList(query) {
return request({
url: '/base/material-attr/page',
method: 'get',
params: query
})
}
// 创建物料属性
export function createMaterialAttr(data) {
return request({
url: '/base/material-attr/create',
method: 'post',
data: data
})
}
// 更新物料属性
export function updateMaterialAttr(data) {
return request({
url: '/base/material-attr/update',
method: 'put',
data: data
})
}
// 删除物料属性
export function deleteMaterialAttr(id) {
return request({
url: '/base/material-attr/delete?id=' + id,
method: 'delete'
})
}
// 获得物料属性
export function getMaterialAttr(query) {
return request({
url: '/base/material-attr/get',
method: 'get',
params: query
})
}

View File

@ -0,0 +1,68 @@
/*
* @Author: Do not edit
* @Date: 2023-10-21 11:50:46
* @LastEditTime: 2023-10-24 17:09:59
* @LastEditors: DY
* @Description:
*/
import request from '@/utils/request'
// 创建物料批次
export function createMaterialDate(data) {
return request({
url: '/base/material-date/create',
method: 'post',
data: data
})
}
// 更新物料批次
export function updateMaterialDate(data) {
return request({
url: '/base/material-date/update',
method: 'put',
data: data
})
}
// 删除物料批次
export function deleteMaterialDate(id) {
return request({
url: '/base/material-date/delete?id=' + id,
method: 'delete'
})
}
// 获得物料批次
export function getMaterialDate(id) {
return request({
url: '/base/material-date/getDetail?id=' + id,
method: 'get'
})
}
// 获得物料批次code
export function getCode() {
return request({
url: '/base/material-date/getMaterialDateCode',
method: 'get'
})
}
// 获得物料批次分页
export function getMaterDatePage(query) {
return request({
url: '/base/material-date/page',
method: 'get',
params: query
})
}
// 获得物料批次列表
export function getMaterDateList(query) {
return request({
url: '/base/material-date/listbyfilter',
method: 'get',
params: query
})
}

View File

@ -0,0 +1,112 @@
/*
* @Author: Do not edit
* @Date: 2023-10-21 11:50:46
* @LastEditTime: 2023-10-26 20:06:29
* @LastEditors: DY
* @Description:
*/
import request from '@/utils/request'
// 创建产品Bom
export function createMaterialPB(data) {
return request({
url: '/base/material-product-bom/create',
method: 'post',
data: data
})
}
// 更新产品Bom
export function updateMaterialPB(data) {
return request({
url: '/base/material-product-bom/update',
method: 'put',
data: data
})
}
// 删除产品Bom
export function deleteMaterialPB(id) {
return request({
url: '/base/material-product-bom/delete?id=' + id,
method: 'delete'
})
}
// 获得产品Bom
export function getMaterialPB(id) {
return request({
url: '/base/material-product-bom/get?id=' + id,
method: 'get'
})
}
// 获得产品Bomcode
export function getCode() {
return request({
url: '/base/material-product-bom/getMaterialProductBomCode',
method: 'get'
})
}
// 获得产品Bom分页
export function getMaterialPBPage(query) {
return request({
url: '/base/material-product-bom/page',
method: 'get',
params: query
})
}
// 获得产品Bom列表
export function getMaterialPBList(query) {
return request({
url: '/base/material-product-bom/listbyfilter',
method: 'get',
params: query
})
}
// 获得产品列表
export function getProList(query) {
return request({
url: '/base/core-product/listAll',
method: 'get',
params: query
})
}
// 获得产品Bom详细分页
export function getProBomList(query) {
return request({
url: '/base/material-product-bom-det/page',
method: 'get',
params: query
})
}
// 创建产品Bom详细
export function createMaterialPBDet(data) {
return request({
url: '/base/material-product-bom-det/create',
method: 'post',
data: data
})
}
// 更新产品Bom详细
export function updateMaterialPBDet(data) {
return request({
url: '/base/material-product-bom-det/update',
method: 'put',
data: data
})
}
// 删除产品Bom详细
export function deleteMaterialPBDet(id) {
return request({
url: '/base/material-product-bom-det/delete?id=' + id,
method: 'delete'
})
}

View File

@ -0,0 +1,69 @@
/*
* @Author: Do not edit
* @Date: 2023-10-21 11:50:46
* @LastEditTime: 2023-10-26 09:32:21
* @LastEditors: DY
* @Description:
*/
import request from '@/utils/request'
// 创建物料使用记录
export function createMaterialLog(data) {
return request({
url: '/base/material-use-log/create',
method: 'post',
data: data
})
}
// 更新物料使用记录
export function updateMaterialLog(data) {
return request({
url: '/base/material-use-log/update',
method: 'put',
data: data
})
}
// 获得物料使用记录
export function getMaterialLog(id) {
return request({
url: '/base/material-use-log/getDetail?id=' + id,
method: 'get'
})
}
// 获得物料使用记录分页
export function getMaterialLogPage(query) {
return request({
url: '/base/material-use-log/page',
method: 'get',
params: query
})
}
// 获得所有设备列表
export function getEqListAll(query) {
return request({
url: '/base/core-equipment/listAll',
method: 'get',
params: query
})
}
// 获得所有员工列表
export function getworkerAll(query) {
return request({
url: '/base/core-worker/listAll',
method: 'get',
params: query
})
}
// 删除物料使用记录
export function deleteMaterialLog(id) {
return request({
url: '/base/material-use-log/delete?id=' + id,
method: 'delete'
})
}

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="14px" height="14px" viewBox="0 0 14 14" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 60 (88103) - https://sketch.com -->
<desc>Created with Sketch.</desc>
<g id="11_系统管理" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="11-1用户管理" transform="translate(-1822.000000, -159.000000)" fill="#FF5454" fill-rule="nonzero">
<g id="编组-10" transform="translate(1821.000000, 158.000000)">
<g id="删除">
<rect id="矩形" opacity="0" x="0" y="0" width="16" height="16"></rect>
<path d="M9.39137788,11.7149165 C9.13431614,11.7149165 8.92716929,11.5077697 8.92716929,11.2507079 L8.92716929,6.14191781 C8.92716929,5.88485607 9.13431613,5.67770922 9.39137788,5.67770922 C9.64843963,5.67770922 9.85558647,5.88485606 9.85558647,6.14191781 L9.85558647,11.2482122 C9.85558647,11.5052739 9.64843961,11.7149165 9.39137788,11.7149165 Z M6.60612639,11.7149165 C6.34906466,11.7149165 6.1419178,11.5077697 6.1419178,11.2507079 L6.1419178,6.14191781 C6.1419178,5.88485607 6.34906466,5.67770922 6.60612641,5.67770922 C6.86318814,5.67770922 7.07033499,5.88485606 7.07033499,6.14191781 L7.07033499,11.2482122 C7.07033499,11.5052739 6.86318814,11.7149165 6.60612639,11.7149165 Z M14.0359594,3.82087491 L11.7149165,3.82087491 L11.7149165,2.89245775 C11.7149165,2.12376827 11.0959718,1.499832 10.3322738,1.499832 L5.67770923,1.499832 C4.90901976,1.499832 4.28508349,2.12376827 4.28508349,2.89245775 L4.28508349,3.82087491 L1.96404059,3.82087491 C1.70697885,3.82087491 1.499832,4.02802174 1.499832,4.28508349 C1.499832,4.54214524 1.70697884,4.74929208 1.96404059,4.74929208 L14.0359594,4.74929208 C14.2930211,4.74929208 14.500168,4.54214524 14.500168,4.28508349 C14.500168,4.02802174 14.2930212,3.82087491 14.0359594,3.82087491 Z M5.21350066,2.89245775 C5.21350066,2.63789175 5.42314324,2.42824916 5.67770925,2.42824916 L10.3322738,2.42824916 C10.5868398,2.42824916 10.7864994,2.63290025 10.7864994,2.89245775 L10.7864994,3.82087491 L5.21350066,3.82087491 L5.21350066,2.89245775 L5.21350066,2.89245775 Z M11.2507079,14.500168 L4.75178782,14.500168 C3.98309834,14.500168 3.35916207,13.8762317 3.35916207,13.1075423 L3.35916207,6.13692631 C3.35916207,5.87986457 3.56630891,5.67271772 3.82337066,5.67271772 C4.08043241,5.67271772 4.28757925,5.87986456 4.28757925,6.13692631 L4.28757925,13.1075423 C4.28757925,13.364604 4.49722183,13.5717508 4.75178783,13.5717508 L11.2532037,13.5717508 C11.5102654,13.5717508 11.7174123,13.364604 11.7174123,13.1075423 L11.7174123,6.15439653 C11.7174123,5.89733479 11.9245591,5.69018794 12.1816209,5.69018794 C12.4386826,5.69018794 12.6458294,5.89733478 12.6458294,6.15439653 L12.6458294,13.1075423 C12.6433337,13.873736 12.0193974,14.500168 11.2507079,14.500168 Z" id="形状"></path>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -0,0 +1,65 @@
<!--
* @Author: zwq
* @Date: 2023-08-01 15:27:31
* @LastEditors: zwq
* @LastEditTime: 2023-08-01 16:25:54
* @Description:
-->
<template>
<div :class="[className, { 'p-0': noPadding }]">
<slot />
</div>
</template>
<script>
export default {
props: {
size: {
// : xl lg md sm
type: String,
default: 'de',
validator: function (val) {
return ['xl', 'lg', 'de', 'md', 'sm'].indexOf(val) !== -1;
},
},
noPadding: {
type: Boolean,
default: false,
},
},
computed: {
className: function () {
return `${this.size}-title`;
},
},
};
</script>
<style lang="scss" scoped>
$pxls: (xl, 28px) (lg, 24px) (de, 20px) (md, 18px) (sm, 16px);
$mgr: 8px;
@each $size, $height in $pxls {
.#{$size}-title {
font-size: 18px;
line-height: $height;
color: #000;
font-weight: 500;
font-family: '微软雅黑', 'Microsoft YaHei', Arial, Helvetica, sans-serif;
&::before {
content: '';
display: inline-block;
vertical-align: top;
width: 4px;
height: $height + 2px;
border-radius: 1px;
margin-right: $mgr;
background-color: #0b58ff;
}
}
}
.p-0 {
padding: 0;
}
</style>

View File

@ -0,0 +1,421 @@
<!--
* @Author: zwq
* @Date: 2021-11-18 14:16:25
* @LastEditors: DY
* @LastEditTime: 2023-10-27 15:11:02
* @Description:
-->
<template>
<el-drawer
:visible.sync="visible"
:show-close="false"
:wrapper-closable="false"
class="drawer"
size="60%">
<small-title slot="title" :no-padding="true">
{{ isdetail ? '详情' : !dataForm.id ? '新增' : '编辑' }}
</small-title>
<div class="content">
<div class="visual-part">
<el-form
:model="dataForm"
:rules="dataRule"
ref="dataForm"
@keyup.enter.native="dataFormSubmit()"
label-width="100px"
label-position="top">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="物料编码" prop="code">
<el-input
v-model="dataForm.code"
clearable
:disabled="isdetail"
placeholder="请输入物料编码" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="物料名称" prop="name">
<el-input v-model="dataForm.name" :disabled="isdetail" clearable placeholder="请输入物料名称" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="英文名称" prop="engName">
<el-input
v-model="dataForm.engName"
clearable
:disabled="isdetail"
placeholder="请输入英文名称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="物料类型" prop="type">
<el-select
v-model="dataForm.type"
filterable
:disabled="isdetail"
placeholder="请选择物料类型">
<el-option
v-for="dict in materialList"
:key="dict.value"
:label="dict.label"
:value="dict.value" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="规格" prop="spec">
<el-input
v-model="dataForm.spec"
clearable
:disabled="isdetail"
placeholder="请输入规格" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="供应商" prop="supplierId">
<el-select
v-model="dataForm.supplierId"
filterable
clearable
:disabled="isdetail"
placeholder="请选择供应商">
<el-option
v-for="dict in supplierList"
:key="dict.id"
:label="dict.name"
:value="dict.id" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="单位" prop="unit">
<el-select
v-model="dataForm.unit"
filterable
:disabled="isdetail"
placeholder="请选择物料单位">
<el-option
v-for="dict in unitList"
:key="dict.value"
:label="dict.label"
:value="dict.value" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="备注" prop="remark">
<el-input v-model="dataForm.remark" :disabled="isdetail" clearable placeholder="请输入备注" />
</el-form-item>
</el-col>
</el-row>
</el-form>
</div>
<div class="attr-list" v-if="idAttrShow">
<small-title
style="margin: 16px 0; padding-left: 8px"
:no-padding="true">
物料属性
</small-title>
<base-table
:table-props="tableProps"
:page="listQuery.pageNo"
:limit="listQuery.pageSize"
:add-button-show="isdetail ? null : '添加属性'"
@emitButtonClick="addNew()"
:table-data="materialAttrList">
<method-btn
v-if="!isdetail"
slot="handleBtn"
:width="120"
label="操作"
:method-list="tableBtn"
@clickBtn="handleClick" />
</base-table>
<pagination
v-show="listQuery.total > 0"
:total="listQuery.total"
:page.sync="listQuery.pageNo"
:limit.sync="listQuery.pageSize"
:page-sizes="[5, 10, 15]"
@pagination="getList" />
</div>
<div class="drawer-body__footer">
<el-button style="" @click="goback()">取消</el-button>
<el-button v-if="isdetail" type="primary" @click="goEdit()">
编辑
</el-button>
<el-button v-else type="primary" @click="dataFormSubmit()">确定</el-button>
</div>
</div>
<attr-add
v-if="addOrUpdateVisible"
ref="addOrUpdate"
:material-id="dataForm.id"
@refreshDataList="getList" />
</el-drawer>
</template>
<script>
import basicAdd from '../../core/mixins/basic-add';
import { createMaterial, updateMaterial, getMaterial, getCode, getSupplierList, getMaterialAttrList, deleteMaterialAttr } from "@/api/base/material";
import { listData } from "@/api/system/dict/data";
import SmallTitle from './SmallTitle';
import { parseTime } from '../../core/mixins/code-filter';
import attrAdd from './attr-add';
const tableBtn = [
{
type: 'edit',
btnName: '编辑',
},
{
type: 'delete',
btnName: '删除',
},
];
const tableProps = [
{
prop: 'createTime',
label: '添加时间',
filter: parseTime,
},
{
prop: 'attrName',
label: '属性名',
},
{
prop: 'attrValue',
label: '属性值',
},
];
export default {
mixins: [basicAdd],
components: { SmallTitle, attrAdd },
data() {
return {
tableBtn,
tableProps,
addOrUpdateVisible: false,
urlOptions: {
isGetCode: true,
codeURL: getCode,
createURL: createMaterial,
updateURL: updateMaterial,
infoURL: getMaterial,
},
listQuery: {
pageSize: 10,
pageNo: 1,
total: 0,
},
dataForm: {
id: undefined,
code: undefined,
name: '',
engName: '',
type: '',
spec: undefined,
supplierId: undefined,
remark: undefined,
unit: ''
},
materialList: [],
supplierList: [],
materialAttrList: [],
unitList: [],
visible: false,
isdetail: false,
idAttrShow: false,
dataRule: {
code: [{ required: true, message: "物料编码不能为空", trigger: "blur" }],
name: [{ required: true, message: "物料名称不能为空", trigger: "blur" }],
type: [{ required: true, message: "物料类型不能为空", trigger: "blur" }]
}
};
},
mounted() {
this.getDict()
},
methods: {
async getDict() {
//
const res = await listData({
pageNo: 1,
pageSize: 99,
dictType: 'material_type',
});
this.materialList = res.data.list.map(item => {
return {
label: item.label,
value: Number(item.value)
}
});
//
const supplierRes = await getSupplierList();
this.supplierList = supplierRes.data;
//
const unitRes = await listData({
pageNo: 1,
pageSize: 99,
dictType: 'goods_unit',
});
this.unitList = unitRes.data.list.map(item => {
return {
label: item.label,
value: Number(item.value)
}
});
},
initData() {
this.materialAttrList.splice(0);
this.listQuery.total = 0;
},
handleClick(raw) {
if (raw.type === 'delete') {
this.$confirm(
`确定对${
raw.data.attrName
? '[名称=' + raw.data.attrName + ']'
: '[序号=' + raw.data._pageIndex + ']'
}进行删除操作?`,
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
)
.then(() => {
deleteMaterialAttr(raw.data.id).then(({ data }) => {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.getList();
},
});
});
})
.catch(() => {});
} else {
this.addNew(raw.data.id);
}
},
getList() {
//
getMaterialAttrList({
...this.listQuery,
materialId: this.dataForm.id,
}).then((response) => {
this.materialAttrList = response.data.list;
this.listQuery.total = response.data.total;
});
},
init(id, isdetail) {
this.initData();
this.isdetail = isdetail || false;
this.dataForm.id = id || undefined;
this.visible = true;
if (id) {
this.idAttrShow = true
} else {
this.idAttrShow = false
}
this.$nextTick(() => {
this.$refs['dataForm'].resetFields();
if (this.dataForm.id) {
//
this.urlOptions.infoURL(id).then(response => {
this.dataForm = response.data;
});
//
this.getList();
} else {
if (this.urlOptions.isGetCode) {
this.getCode()
}
}
});
},
goback() {
this.$emit('refreshDataList');
this.visible = false;
// this.initData();
},
goEdit() {
this.isdetail = false;
},
// /
addNew(id) {
this.addOrUpdateVisible = true;
this.$nextTick(() => {
this.$refs.addOrUpdate.init(id);
});
}
}
};
</script>
<style scoped>
.drawer >>> .el-drawer {
border-radius: 8px 0 0 8px;
display: flex;
flex-direction: column;
}
.drawer >>> .el-form-item__label {
padding: 0;
}
.drawer >>> .el-drawer__header {
margin: 0;
padding: 32px 32px 24px;
border-bottom: 1px solid #dcdfe6;
}
.drawer >>> .el-drawer__body {
flex: 1;
height: 1px;
display: flex;
flex-direction: column;
}
.drawer >>> .content {
padding: 30px 24px;
flex: 1;
display: flex;
flex-direction: column;
/* height: 100%; */
}
.drawer >>> .visual-part {
flex: 1 auto;
max-height: 76vh;
overflow: hidden;
overflow-y: scroll;
padding-right: 10px; /* 调整滚动条样式 */
}
.drawer >>> .el-form,
.drawer >>> .attr-list {
padding: 0 16px;
}
.drawer-body__footer {
display: flex;
justify-content: flex-end;
padding: 18px;
}
</style>

View File

@ -0,0 +1,141 @@
<template>
<el-dialog
:visible.sync="visible"
:width="'35%'"
:append-to-body="true"
:close-on-click-modal="false"
class="dialog">
<template #title>
<slot name="title">
<div class="titleStyle">
{{ !dataForm.id ? '新增' : '编辑' }}
</div>
</slot>
</template>
<el-form
ref="dataForm"
:model="dataForm"
:rules="dataRule"
label-width="100px"
@keyup.enter.native="dataFormSubmit()">
<el-form-item label="属性名" prop="attrName">
<el-input
v-model="dataForm.attrName"
placeholder="请输入属性名"
clearable />
</el-form-item>
<el-form-item label="属性值" prop="attrValue">
<el-input
v-model="dataForm.attrValue"
placeholder="请输入属性值"
clearable />
</el-form-item>
</el-form>
<el-row style="text-align: right">
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
</el-row>
</el-dialog>
</template>
<script>
import {
createMaterialAttr,
updateMaterialAttr,
getMaterialAttr
} from '@/api/base/material';
export default {
props: {
materialId: {
type: String,
default: '',
},
},
data() {
return {
visible: false,
dataForm: {
id: undefined,
attrName: '',
attrValue: '',
},
dataRule: {
attrName: [{ required: true, message: '名称不能为空', trigger: 'blur' }],
},
};
},
methods: {
init(id) {
this.dataForm.id = id || '';
this.visible = true;
this.$nextTick(() => {
this.$refs['dataForm'].resetFields();
if (this.dataForm.id) {
getMaterialAttr({
id: this.dataForm.id
}).then((res) => {
const { attrName, attrValue } = res.data;
this.dataForm.attrName = attrName;
this.dataForm.attrValue = attrValue;
});
}
});
},
//
dataFormSubmit() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
//
if (this.dataForm.id) {
updateMaterialAttr({
...this.dataForm,
materialId: this.materialId,
}).then((response) => {
this.$modal.msgSuccess('修改成功');
this.visible = false;
this.$emit('refreshDataList');
});
return;
}
//
createMaterialAttr({
...this.dataForm,
materialId: this.materialId,
}).then((response) => {
this.$modal.msgSuccess('新增成功');
this.visible = false;
this.$emit('refreshDataList');
});
}
});
},
},
};
</script>
<style scoped>
.dialog >>> .el-dialog__body {
padding: 30px 24px;
}
.dialog >>> .el-dialog__header {
font-size: 16px;
color: rgba(0, 0, 0, 0.85);
font-weight: 500;
padding: 13px 24px;
border-bottom: 1px solid #e9e9e9;
}
.dialog >>> .el-dialog__header .titleStyle::before {
content: '';
display: inline-block;
width: 4px;
height: 16px;
background-color: #0b58ff;
border-radius: 1px;
margin-right: 8px;
position: relative;
top: 2px;
}
</style>

View File

@ -0,0 +1,233 @@
<template>
<div class="app-container">
<search-bar
:formConfigs="formConfig"
ref="searchBarForm"
@headBtnClick="buttonClick" />
<base-table
v-loading="dataListLoading"
:table-props="tableProps"
:page="listQuery.pageNo"
:limit="listQuery.pageSize"
:table-data="tableData">
<method-btn
v-if="tableBtn.length"
slot="handleBtn"
:width="220"
label="操作"
:method-list="tableBtn"
@clickBtn="handleClick" />
</base-table>
<pagination
:limit.sync="listQuery.pageSize"
:page.sync="listQuery.pageNo"
:total="listQuery.total"
@pagination="getDataList" />
<add-or-update
v-if="addOrUpdateVisible"
ref="addOrUpdate"
@refreshDataList="getDataList" />
</div>
</template>
<script>
import AddOrUpdate from './add-or-updata';
import basicPage from '../../core/mixins/basic-page';
import { parseTime } from '../../core/mixins/code-filter';
import {
getMaterialPage,
deleteMaterial
} from '@/api/base/material';
import { listData } from "@/api/system/dict/data";
const tableProps = [
{
prop: 'createTime',
label: '添加时间',
filter: parseTime
},
{
prop: 'code',
label: '物料编码'
},
{
prop: 'name',
label: '物料名称'
},
{
prop: 'engName',
label: '英文名称'
},
{
prop: 'abbr',
label: '缩写'
},
{
prop: 'materialType',
label: '物料类型'
},
{
prop: 'supplierName',
label: '供应商'
},
{
prop: 'remark',
label: '备注'
}
];
export default {
mixins: [basicPage],
data() {
return {
urlOptions: {
getDataListURL: getMaterialPage,
deleteURL: deleteMaterial
// exportURL: exportFactoryExcel,
},
tableProps,
tableBtn: [
this.$auth.hasPermi(`base:material:update`)
? {
type: 'edit',
btnName: '编辑',
}
: undefined,
this.$auth.hasPermi(`base:material:queryAttr`)
? {
type: 'search',
btnName: '查看属性',
}
: undefined,
this.$auth.hasPermi(`base:material:editAttr`)
? {
type: 'editAttr',
btnName: '编辑属性',
}
: undefined,
this.$auth.hasPermi(`base:material:delete`)
? {
type: 'delete',
btnName: '删除',
}
: undefined,
].filter((v)=>v),
tableData: [],
typeList: [],
formConfig: [
{
type: 'input',
label: '关键字',
placeholder: '物料名称',
param: 'name',
},
{
type: 'input',
label: '关键字',
placeholder: '物料编码',
param: 'code',
},
{
type: 'button',
btnName: '查询',
name: 'search',
color: 'primary',
},
{
type: 'separate',
},
{
type: this.$auth.hasPermi('base:material:create') ? 'button' : '',
btnName: '新增物料',
name: 'add',
color: 'success',
plain: true
},
],
};
},
components: {
AddOrUpdate,
},
created() {
this.getDict()
},
methods: {
async getDict() {
//
const res = await listData({
pageNo: 1,
pageSize: 99,
dictType: 'material_type',
});
this.typeList = res.data.list.map(item => {
return {
label: item.label,
value: Number(item.value)
}
});
},
otherMethods(val) {
if (val.type === 'search') {
this.addOrUpdateVisible = true;
this.addOrEditTitle = '详情';
this.$nextTick(() => {
this.$refs.addOrUpdate.init(val.data.id, true);
});
} else {
this.addOrEditTitle = '编辑';
this.addOrUpdateVisible = true;
this.$nextTick(() => {
this.$refs.addOrUpdate.init(val.data.id);
});
}
},
//
getDataList() {
this.dataListLoading = true;
this.urlOptions.getDataListURL(this.listQuery).then(response => {
this.tableData = response.data.records.map(item => {
this.typeList.filter(t => {
if (item.type === t.value) {
item.materialType = t.label
}
})
return item
});
this.listQuery.total = response.data.total;
this.dataListLoading = false;
});
},
buttonClick(val) {
switch (val.btnName) {
case 'search':
this.listQuery.pageNo = 1;
this.listQuery.pageSize = 10;
this.listQuery.name = val.name ? val.name : undefined;
this.listQuery.code = val.code ? val.code : undefined;
this.getDataList();
break;
case 'reset':
this.$refs.searchBarForm.resetForm();
this.listQuery = {
pageSize: 10,
pageNo: 1,
total: 1,
};
this.getDataList();
break;
case 'add':
this.addOrEditTitle = '新增';
this.addOrUpdateVisible = true;
this.addOrUpdateHandle();
break;
case 'export':
this.handleExport();
break;
default:
console.log(val);
}
},
},
};
</script>

View File

@ -0,0 +1,107 @@
<!--
* @Author: zwq
* @Date: 2021-11-18 14:16:25
* @LastEditors: DY
* @LastEditTime: 2023-10-24 18:34:07
* @Description:
-->
<template>
<el-form
:model="dataForm"
:rules="dataRule"
ref="dataForm"
@keyup.enter.native="dataFormSubmit()"
label-width="80px">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="物料名称" prop="materialId">
<el-select
v-model="dataForm.materialId"
placeholder="请选择物料"
@change="setMaterialCode">
<el-option
v-for="dict in materialList"
:key="dict.id"
:label="dict.name"
:value="dict.id" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="物料编码" prop="materialCode">
<el-input
v-model="dataForm.materialCode"
disabled
placeholder="请输入物料编码" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="批次号" prop="code">
<el-input v-model="dataForm.code" clearable placeholder="请输入批次号" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="批次名称" prop="name">
<el-input v-model="dataForm.name" clearable placeholder="请输入批次名称" />
</el-form-item>
</el-col>
</el-row>
<el-form-item label="备注" prop="remark">
<el-input v-model="dataForm.remark" clearable placeholder="请输入备注" />
</el-form-item>
</el-form>
</template>
<script>
import basicAdd from '../../core/mixins/basic-add';
import { createMaterialDate, updateMaterialDate, getMaterialDate, getCode } from "@/api/base/materialDate";
import { getMaterialList } from "@/api/base/material";
export default {
mixins: [basicAdd],
data() {
return {
urlOptions: {
isGetCode: true,
codeURL: getCode,
createURL: createMaterialDate,
updateURL: updateMaterialDate,
infoURL: getMaterialDate,
},
dataForm: {
id: undefined,
code: undefined,
name: undefined,
materialId: undefined,
materialCode: undefined,
remark: undefined,
},
materialList: [],
dataRule: {
materialId: [{ required: true, message: "物料不能为空", trigger: "blur" }],
code: [{ required: true, message: "工厂编码不能为空", trigger: "blur" }],
name: [{ required: true, message: "工厂名称不能为空", trigger: "blur" }],
}
};
},
mounted() {
this.getDict()
console.log('我看看', this.dataForm)
},
methods: {
async getDict() {
//
const res = await getMaterialList();
this.materialList = res.data;
},
setMaterialCode() {
const chooseM = this.materialList.filter(item => {
return item.id === this.dataForm.materialId
})
this.dataForm.materialCode = chooseM[0].code
}
},
};
</script>

View File

@ -0,0 +1,169 @@
<template>
<div class="app-container">
<search-bar
:formConfigs="formConfig"
ref="searchBarForm"
@headBtnClick="buttonClick" />
<base-table
v-loading="dataListLoading"
:table-props="tableProps"
:page="listQuery.pageNo"
:limit="listQuery.pageSize"
:table-data="tableData">
<method-btn
v-if="tableBtn.length"
slot="handleBtn"
:width="120"
label="操作"
:method-list="tableBtn"
@clickBtn="handleClick" />
</base-table>
<pagination
:limit.sync="listQuery.pageSize"
:page.sync="listQuery.pageNo"
:total="listQuery.total"
@pagination="getDataList" />
<base-dialog
:dialogTitle="addOrEditTitle"
:dialogVisible="addOrUpdateVisible"
@cancel="handleCancel"
@confirm="handleConfirm"
:before-close="handleCancel"
width="50%">
<add-or-update
ref="addOrUpdate"
@refreshDataList="successSubmit"></add-or-update>
</base-dialog>
</div>
</template>
<script>
import AddOrUpdate from './add-or-updata';
import basicPage from '../../core/mixins/basic-page';
import { parseTime } from '../../core/mixins/code-filter';
import {
getMaterDatePage,
deleteMaterialDate
} from '@/api/base/materialDate';
const tableProps = [
{
prop: 'createTime',
label: '添加时间',
filter: parseTime
},
{
prop: 'code',
label: '批次号'
},
{
prop: 'name',
label: '批次名称'
},
{
prop: 'materialCode',
label: '物料编码'
},
{
prop: 'materialName',
label: '物料名称'
},
];
export default {
mixins: [basicPage],
data() {
return {
urlOptions: {
getDataListURL: getMaterDatePage,
deleteURL: deleteMaterialDate,
// exportURL: exportFactoryExcel,
},
tableProps,
tableBtn: [
this.$auth.hasPermi(`base:material-date:update`)
? {
type: 'edit',
btnName: '编辑',
}
: undefined,
this.$auth.hasPermi(`base:material-date:delete`)
? {
type: 'delete',
btnName: '删除',
}
: undefined,
].filter((v)=>v),
tableData: [],
formConfig: [
{
type: 'input',
label: '批次名',
placeholder: '批次名',
param: 'name',
},
{
type: 'button',
btnName: '查询',
name: 'search',
color: 'primary',
},
{
type: 'separate',
},
{
type: this.$auth.hasPermi('base:material-date:create') ? 'button' : '',
btnName: '新增',
name: 'add',
color: 'success',
plain: true
},
],
};
},
components: {
AddOrUpdate,
},
created() {},
methods: {
//
getDataList() {
this.dataListLoading = true;
this.urlOptions.getDataListURL(this.listQuery).then(response => {
this.tableData = response.data.records;
this.listQuery.total = response.data.total;
this.dataListLoading = false;
});
},
buttonClick(val) {
switch (val.btnName) {
case 'search':
this.listQuery.pageNo = 1;
this.listQuery.pageSize = 10;
this.listQuery.name = val.name ? val.name : undefined;
this.getDataList();
break;
case 'reset':
this.$refs.searchBarForm.resetForm();
this.listQuery = {
pageSize: 10,
pageNo: 1,
total: 1,
};
this.getDataList();
break;
case 'add':
this.addOrEditTitle = '新增';
this.addOrUpdateVisible = true;
this.addOrUpdateHandle();
break;
case 'export':
this.handleExport();
break;
default:
console.log(val);
}
},
},
};
</script>

View File

@ -0,0 +1,469 @@
<!--
* @Author: zwq
* @Date: 2021-11-18 14:16:25
* @LastEditors: DY
* @LastEditTime: 2023-10-27 16:06:44
* @Description:
-->
<template>
<el-drawer
:visible.sync="visible"
:show-close="false"
:wrapper-closable="false"
class="drawer"
size="70%">
<small-title slot="title" :no-padding="true">
{{ isdetail ? '详情' : !dataForm.id ? '新增' : '编辑' }}
</small-title>
<div class="content">
<div class="visual-part">
<el-form
:model="dataForm"
:rules="dataRule"
ref="dataForm"
@keyup.enter.native="dataFormSubmit()"
label-width="100px"
label-position="top">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="产品名称" prop="productId">
<el-select
v-model="dataForm.productId"
filterable
:disabled="isdetail"
placeholder="请选择产品">
<el-option
v-for="dict in productList"
:key="dict.id"
:label="dict.name"
:value="dict.id" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="产品BOM编码" prop="code">
<el-input v-model="dataForm.code" disabled placeholder="请输入产品Bom编码" />
</el-form-item>
</el-col>
</el-row>
<el-form-item label="备注" prop="remark">
<el-input v-model="dataForm.remark" :disabled="isdetail" clearable placeholder="请输入备注" />
</el-form-item>
</el-form>
</div>
<div class="attr-list" v-if="idAttrShow">
<small-title
style="margin: 16px 0; padding-left: 8px"
:no-padding="true">
BOM明细
</small-title>
<!-- <base-table
:table-props="tableProps"
:page="listQuery.pageNo"
:limit="listQuery.pageSize"
:add-button-show="isdetail ? null : '添加属性'"
@emitButtonClick="addNew()"
:table-data="materialAttrList">
<method-btn
v-if="!isdetail"
slot="handleBtn"
:width="120"
label="操作"
:method-list="tableBtn"
@clickBtn="handleClick" />
</base-table> -->
<el-button v-show="!isdetail" type="success" size="small" style="float: right" @click="addRow()">添加一行</el-button>
<el-table
:data="tableData"
style="width: 100%">
<el-table-column type="index" label="序号" />
<el-table-column prop="createTime" label="添加时间">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column prop="materialId" label="物料名称">
<template slot-scope="scope">
<el-select
v-model="scope.row.materialId"
filterable
:disabled="!scope.row.isEdit"
placeholder="请选择物料"
@change="setCode(scope.row)">
<el-option
v-for="dict in materialList"
:key="dict.id"
:label="dict.name"
:value="dict.id" />
</el-select>
</template>
</el-table-column>
<el-table-column prop="materialCode" label="物料编码" />
<el-table-column prop="mUnit" label="单位" />
<el-table-column prop="num" label="数量">
<template slot-scope="scope">
<el-input v-model="scope.row.num" :disabled="!scope.row.isEdit"></el-input>
</template>
</el-table-column>
<el-table-column prop="remark" label="备注">
<template slot-scope="scope">
<el-input v-model="scope.row.remark" :disabled="!scope.row.isEdit"></el-input>
</template>
</el-table-column>
<el-table-column v-if="!isdetail" label="操作">
<template slot-scope="scope">
<el-tooltip v-if="!scope.row.isEdit" placement="top" content="编辑">
<el-button
type="text"
:style="{color:'#0B58FF'}"
size="mini"
@click="edit(scope.row)"
>
<!-- 此处的icon的名字命名为'table_'加上按钮的type -->
<svg-icon style="width: 18px; height: 18px" class="item-icon" icon-class="edit" />
<!-- <span>{{ item.btnName | i18nFilter }}</span> -->
</el-button>
</el-tooltip>
<el-button v-else type="primary" size="small" @click="saveData(scope.row)">保存</el-button>
<el-tooltip placement="top" content="删除">
<el-button
type="text"
:style="{color:'#FF5454'}"
size="mini"
@click="deleteDetail(scope.row)"
>
<!-- 此处的icon的名字命名为'table_'加上按钮的type -->
<svg-icon style="width: 18px; height: 18px" class="item-icon" icon-class="table_delete" />
<!-- <span>{{ item.btnName | i18nFilter }}</span> -->
</el-button>
</el-tooltip>
</template>
</el-table-column>
</el-table>
<pagination
v-show="listQuery.total > 0"
:total="listQuery.total"
:page.sync="listQuery.pageNo"
:limit.sync="listQuery.pageSize"
:page-sizes="[5, 10, 15]"
@pagination="getList" />
</div>
<div class="drawer-body__footer">
<el-button style="" @click="goback()">取消</el-button>
<el-button v-if="isdetail" type="primary" @click="goEdit()">
编辑
</el-button>
<el-button v-else type="primary" @click="dataFormSubmit()">确定</el-button>
</div>
</div>
<!-- <attr-add
v-if="addOrUpdateVisible"
ref="addOrUpdate"
:material-id="dataForm.id"
@refreshDataList="getList" /> -->
</el-drawer>
</template>
<script>
import basicAdd from '../../core/mixins/basic-add';
import { createMaterialPB, updateMaterialPB, getMaterialPB, getCode, getProList, getProBomList, createMaterialPBDet, updateMaterialPBDet, deleteMaterialPBDet } from "@/api/base/materialProductBom";
import { getMaterialList } from "@/api/base/material";
import { listData } from "@/api/system/dict/data";
import SmallTitle from '../material/SmallTitle';
import { parseTime } from '../../core/mixins/code-filter';
// import attrAdd from './attr-add';
const tableBtn = [
{
type: 'edit',
btnName: '编辑',
},
{
type: 'delete',
btnName: '删除',
},
];
const tableProps = [
{
prop: 'createTime',
label: '添加时间',
filter: parseTime,
},
{
prop: 'attrName',
label: '属性名',
},
{
prop: 'attrValue',
label: '属性值',
},
];
export default {
mixins: [basicAdd],
components: { SmallTitle },
data() {
return {
tableBtn,
tableProps,
addOrUpdateVisible: false,
urlOptions: {
isGetCode: true,
codeURL: getCode,
createURL: createMaterialPB,
updateURL: updateMaterialPB,
infoURL: getMaterialPB,
},
listQuery: {
pageSize: 10,
pageNo: 1,
total: 0,
},
dataForm: {
id: undefined,
code: undefined,
productId: '',
remark: undefined,
},
productList: [],
materialAttrList: [],
materialList: [],
tableData: [],
unitList: [],
visible: false,
isdetail: false,
idAttrShow: false,
dataRule: {
productId: [{ required: true, message: "产品不能为空", trigger: "blur" }]
}
};
},
mounted() {
this.getDict()
},
methods: {
async getDict() {
//
const proRes = await getProList();
this.productList = proRes.data;
//
const res = await getMaterialList();
this.materialList = res.data;
//
const unitRes = await listData({
pageNo: 1,
pageSize: 99,
dictType: 'goods_unit',
});
this.unitList = unitRes.data.list.map(item => {
return {
label: item.label,
value: Number(item.value)
}
});
},
initData() {
// this.materialAttrList.splice(0);
this.listQuery.total = 0;
},
deleteDetail(raw) {
this.$confirm(
`确定删除关于物料编码为${
raw.materialCode}的数据?`,
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
)
.then(() => {
deleteMaterialPBDet(raw.id).then(({ data }) => {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.getList();
},
});
});
})
.catch(() => {});
},
setCode(row) {
this.materialList.filter(item => {
if (row.materialId === item.id) {
row.materialCode = item.code
}
this.unitList.filter(u => {
if (item.unit === u.value) {
row.unit = u.value
row.mUnit = u.label
}
})
// return row.materialId === item.id
})
// row.materialCode = tempList[0].code
// row.unit = tempList[0].unit
console.log('row', row)
},
edit(row) {
row.isEdit = true
},
saveData(row) {
// this.$refs['dataForm'].validate((valid) => {
// if (valid) {
//
if (row.id) {
updateMaterialPBDet({
...row
}).then((response) => {
this.$modal.msgSuccess('修改成功');
// this.visible = false;
this.getList();
});
return;
}
//
createMaterialPBDet({
...row
}).then((response) => {
this.$modal.msgSuccess('新增成功');
// this.visible = false;
this.getList();
});
// }
// });
},
getList() {
// Bom
getProBomList({
...this.listQuery,
bomId: this.dataForm.id,
createTime: ['2023-10-26 00:00:00', '2023-10-27 12:00:00']
}).then((response) => {
this.tableData = response.data.records.map(item => {
this.unitList.filter(u => {
if (item.unit === u.value) {
item.mUnit = u.label
}
})
item.isEdit = false
return item
});
this.listQuery.total = response.data.total;
});
},
//
addRow() {
const row = {
bomId: this.dataForm.id,
materialId: '',
num: 0,
materialCode: undefined,
unit: undefined,
remark: '',
isEdit: true
}
this.tableData.push(row)
},
init(id, isdetail) {
this.initData();
this.isdetail = isdetail || false;
this.dataForm.id = id || undefined;
this.visible = true;
if (id) {
this.idAttrShow = true
} else {
this.idAttrShow = false
}
this.$nextTick(() => {
this.$refs['dataForm'].resetFields();
if (this.dataForm.id) {
//
this.urlOptions.infoURL(id).then(response => {
this.dataForm = response.data;
});
// Bom
this.getList();
} else {
if (this.urlOptions.isGetCode) {
this.getCode()
}
}
});
},
goback() {
this.$emit('refreshDataList');
this.visible = false;
// this.initData();
},
goEdit() {
this.isdetail = false;
},
// /
addNew(id) {
this.addOrUpdateVisible = true;
this.$nextTick(() => {
this.$refs.addOrUpdate.init(id);
});
}
}
};
</script>
<style scoped>
.drawer >>> .el-drawer {
border-radius: 8px 0 0 8px;
display: flex;
flex-direction: column;
}
.drawer >>> .el-form-item__label {
padding: 0;
}
.drawer >>> .el-drawer__header {
margin: 0;
padding: 32px 32px 24px;
border-bottom: 1px solid #dcdfe6;
}
.drawer >>> .el-drawer__body {
flex: 1;
height: 1px;
display: flex;
flex-direction: column;
}
.drawer >>> .content {
padding: 30px 24px;
flex: 1;
display: flex;
flex-direction: column;
/* height: 100%; */
}
.drawer >>> .visual-part {
flex: 1 auto;
max-height: 76vh;
overflow: hidden;
overflow-y: scroll;
padding-right: 10px; /* 调整滚动条样式 */
}
.drawer >>> .el-form,
.drawer >>> .attr-list {
padding: 0 16px;
}
.drawer-body__footer {
display: flex;
justify-content: flex-end;
padding: 18px;
}
</style>

View File

@ -0,0 +1,187 @@
<template>
<div class="app-container">
<search-bar
:formConfigs="formConfig"
ref="searchBarForm"
@headBtnClick="buttonClick" />
<base-table
v-loading="dataListLoading"
:table-props="tableProps"
:page="listQuery.pageNo"
:limit="listQuery.pageSize"
:table-data="tableData">
<method-btn
v-if="tableBtn.length"
slot="handleBtn"
:width="220"
label="操作"
:method-list="tableBtn"
@clickBtn="handleClick" />
</base-table>
<pagination
:limit.sync="listQuery.pageSize"
:page.sync="listQuery.pageNo"
:total="listQuery.total"
@pagination="getDataList" />
<add-or-update
v-if="addOrUpdateVisible"
ref="addOrUpdate"
@refreshDataList="getDataList" />
</div>
</template>
<script>
import AddOrUpdate from './add-or-updata';
import basicPage from '../../core/mixins/basic-page';
// import { parseTime } from '../../core/mixins/code-filter';
import {
getMaterialPBPage,
deleteMaterialPB
} from '@/api/base/materialProductBom';
const tableProps = [
{
prop: 'productName',
label: '产品名称'
},
{
prop: 'code',
label: '产品BOM编码'
},
{
prop: 'remark',
label: '备注'
}
];
export default {
mixins: [basicPage],
components: {
AddOrUpdate,
},
data() {
return {
urlOptions: {
getDataListURL: getMaterialPBPage,
deleteURL: deleteMaterialPB
// exportURL: exportFactoryExcel,
},
tableProps,
tableBtn: [
this.$auth.hasPermi(`base:material-product-bom:update`)
? {
type: 'edit',
btnName: '编辑',
}
: undefined,
this.$auth.hasPermi(`base:material-product-bom:queryMaterial`)
? {
type: 'search',
btnName: '查看物料',
}
: undefined,
this.$auth.hasPermi(`base:material-product-bom:editMaterial`)
? {
type: 'editMaterial',
btnName: '编辑物料',
}
: undefined,
this.$auth.hasPermi(`base:material-product-bom:delete`)
? {
type: 'delete',
btnName: '删除',
}
: undefined,
].filter((v)=>v),
tableData: [],
formConfig: [
{
type: 'input',
label: '关键字',
placeholder: '物料名称',
param: 'name',
},
{
type: 'input',
label: '关键字',
placeholder: '物料编码',
param: 'code',
},
{
type: 'button',
btnName: '查询',
name: 'search',
color: 'primary',
},
{
type: 'separate',
},
{
type: this.$auth.hasPermi('base:material:create') ? 'button' : '',
btnName: '新增',
name: 'add',
color: 'success',
plain: true
},
],
};
},
created() {},
methods: {
otherMethods(val) {
if (val.type === 'search') {
this.addOrUpdateVisible = true;
this.addOrEditTitle = '详情';
this.$nextTick(() => {
this.$refs.addOrUpdate.init(val.data.id, true);
});
} else {
this.addOrEditTitle = '编辑';
this.addOrUpdateVisible = true;
this.$nextTick(() => {
this.$refs.addOrUpdate.init(val.data.id);
});
}
},
//
getDataList() {
this.dataListLoading = true;
this.urlOptions.getDataListURL(this.listQuery).then(response => {
this.tableData = response.data.records;
this.listQuery.total = response.data.total;
this.dataListLoading = false;
});
},
buttonClick(val) {
switch (val.btnName) {
case 'search':
this.listQuery.pageNo = 1;
this.listQuery.pageSize = 10;
this.listQuery.name = val.name ? val.name : undefined;
this.listQuery.code = val.code ? val.code : undefined;
this.getDataList();
break;
case 'reset':
this.$refs.searchBarForm.resetForm();
this.listQuery = {
pageSize: 10,
pageNo: 1,
total: 1,
};
this.getDataList();
break;
case 'add':
this.addOrEditTitle = '新增';
this.addOrUpdateVisible = true;
this.addOrUpdateHandle();
break;
case 'export':
this.handleExport();
break;
default:
console.log(val);
}
},
},
};
</script>

View File

@ -0,0 +1,258 @@
<!--
* @Author: zwq
* @Date: 2021-11-18 14:16:25
* @LastEditors: DY
* @LastEditTime: 2023-10-26 09:43:51
* @Description:
-->
<template>
<el-form
:model="dataForm"
:rules="dataRule"
ref="dataForm"
@keyup.enter.native="dataFormSubmit()"
label-width="80px">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="物料名称" prop="materialId">
<el-select
v-model="dataForm.materialId"
placeholder="请选择物料"
clearable
filterable
@change="setCode"
>
<el-option
v-for="dict in materialList"
:key="dict.id"
:label="dict.name"
:value="dict.id" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="物料编码" prop="materialCode">
<el-input
v-model="dataForm.materialCode"
clearable
disabled
placeholder="请输入物料编码" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="批次号" prop="materialDateId">
<el-select
v-model="dataForm.materialDateId"
clearable
filterable
placeholder="请选择物料批次"
>
<el-option
v-for="dict in materialDateList"
:key="dict.id"
:label="dict.code"
:value="dict.id" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="使用设备" prop="equipmentId">
<el-select
v-model="dataForm.equipmentId"
clearable
filterable
placeholder="请选择使用设备">
<el-option
v-for="dict in eqList"
:key="dict.id"
:label="dict.name"
:value="dict.id" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="使用时间" prop="useTime">
<el-date-picker
v-model="dataForm.useTime"
type="datetime"
format='yyyy-MM-dd HH:mm:ss'
value-format='timestamp'
placeholder="选择日期时间" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="操作员" prop="userNames">
<el-select
v-model="dataForm.userNames"
clearable
filterable
multiple
placeholder="请选择操作员">
<el-option
v-for="dict in workersList"
:key="dict.id"
:label="dict.name"
:value="dict.name" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="使用数量" prop="num">
<el-input-number v-model="dataForm.num" clearable placeholder="请输入使用数量" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="数据来源" prop="source">
<el-select
v-model="dataForm.source"
clearable
placeholder="请选择数据来源">
<el-option
v-for="dict in this.dataSourceList"
:key="dict.id"
:label="dict.name"
:value="dict.id" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="备注" prop="remark">
<el-input v-model="dataForm.remark" clearable placeholder="请输入备注" />
</el-form-item>
</el-form>
</template>
<script>
import basicAdd from '../../core/mixins/basic-add';
import { createMaterialLog, updateMaterialLog, getMaterialLog, getEqListAll, getworkerAll } from "@/api/base/materialUseLog";
import { getMaterialList } from "@/api/base/material"
import { getMaterDateList } from "@/api/base/materialDate"
export default {
mixins: [basicAdd],
data() {
return {
urlOptions: {
createURL: createMaterialLog,
updateURL: updateMaterialLog,
infoURL: getMaterialLog
},
dataForm: {
id: undefined,
materialId: undefined,
materialCode: undefined,
materialDateId: undefined,
equipmentId: undefined,
userName: undefined,
userNames: [],
useTime: undefined,
address: undefined,
num: 0,
source: undefined,
remark: undefined
},
dataSourceList: [
{
id: 1,
name: '手动'
},
{
id: 2,
name: '自动'
}
],
materialList: [],
materialDateList: [],
eqList: [],
workersList: [],
dataRule: {
materialId: [{ required: true, message: "物料不能为空", trigger: "blur" }],
materialDateId: [{ required: true, message: "批次号不能为空", trigger: "blur" }],
useTime: [{ required: true, message: "使用时间不能为空", trigger: "blur" }],
userNames: [{ required: true, message: "操作员不能为空", trigger: "blur" }],
num: [{ required: true, message: "使用数量不能为空", trigger: "blur" }]
}
};
},
mounted() {
this.getDictData()
},
methods: {
async getDictData() {
const materRes = await getMaterialList()
this.materialList = materRes.data
console.log('你好', this.materialList)
const dateRes = await getMaterDateList()
this.materialDateList = dateRes.data
const eqRes = await getEqListAll()
this.eqList = eqRes.data
const workerRes = await getworkerAll()
this.workersList = workerRes.data
},
//
dataFormSubmit() {
this.dataForm.userName = this.dataForm.userNames.join(',')
this.$refs["dataForm"].validate((valid) => {
if (!valid) {
return false;
}
//
if (this.dataForm.id) {
this.urlOptions.updateURL(this.dataForm).then(response => {
this.$modal.msgSuccess("修改成功");
this.visible = false;
this.$emit("refreshDataList");
});
return;
}
//
this.urlOptions.createURL(this.dataForm).then(response => {
this.$modal.msgSuccess("新增成功");
this.visible = false;
this.$emit("refreshDataList");
});
});
},
init(id) {
this.dataForm.id = id || undefined;
this.visible = true;
this.$nextTick(() => {
this.$refs["dataForm"].resetFields();
if (this.dataForm.id) {
this.urlOptions.infoURL(id).then(response => {
this.dataForm.id = response.data.id
this.dataForm.materialCode = response.data.materialCode
this.dataForm.materialId = response.data.materialId
this.dataForm.materialDateId = response.data.materialDateId
this.dataForm.equipmentId = response.data.equipmentId
this.dataForm.useTime = response.data.useTime
// this.dataForm.userName = response.data.userName
this.dataForm.num = response.data.num
this.dataForm.source = response.data.source
this.dataForm.remark = response.data.remark
this.dataForm.userNames = response.data.userName.split(',')
console.log('打印', this.dataForm)
});
} else {
if (this.urlOptions.isGetCode) {
this.getCode()
}
}
});
},
setCode() {
const tempMaterial = this.materialList.filter(item =>{
return item.id === this.dataForm.materialId
})
this.dataForm.materialCode = tempMaterial[0].code
}
},
};
</script>

View File

@ -0,0 +1,212 @@
<template>
<div class="app-container">
<search-bar
:formConfigs="formConfig"
ref="searchBarForm"
@headBtnClick="buttonClick" />
<base-table
v-loading="dataListLoading"
:table-props="tableProps"
:page="listQuery.pageNo"
:limit="listQuery.pageSize"
:table-data="tableData">
<method-btn
v-if="tableBtn.length"
slot="handleBtn"
:width="120"
label="操作"
:method-list="tableBtn"
@clickBtn="handleClick" />
</base-table>
<pagination
:limit.sync="listQuery.pageSize"
:page.sync="listQuery.pageNo"
:total="listQuery.total"
@pagination="getDataList" />
<base-dialog
:dialogTitle="addOrEditTitle"
:dialogVisible="addOrUpdateVisible"
@cancel="handleCancel"
@confirm="handleConfirm"
:before-close="handleCancel"
width="50%">
<add-or-update
ref="addOrUpdate"
@refreshDataList="successSubmit"></add-or-update>
</base-dialog>
</div>
</template>
<script>
import AddOrUpdate from './add-or-updata';
import basicPage from '../../core/mixins/basic-page';
import { parseTime } from '../../core/mixins/code-filter';
import {
getMaterialLogPage,
deleteMaterialLog
} from '@/api/base/materialUseLog';
const tableProps = [
{
prop: 'materialName',
label: '物料名称'
},
{
prop: 'materialCode',
label: '物料编码'
},
{
prop: 'materialDateId',
label: '物料批次'
},
{
prop: 'equipName',
label: '使用设备'
},
{
prop: 'num',
label: '使用数量'
},
{
prop: 'useTime',
label: '使用时间',
filter: parseTime
},
{
prop: 'userName',
label: '操作人'
},
{
prop: 'source',
label: '数据来源',
filter: (val) => ['未知', '手动', '自动'][val]
},
{
prop: 'remark',
label: '备注'
}
];
export default {
mixins: [basicPage],
data() {
return {
urlOptions: {
getDataListURL: getMaterialLogPage,
deleteURL: deleteMaterialLog,
// exportURL: exportFactoryExcel,
},
tableProps,
tableBtn: [
this.$auth.hasPermi(`base:material-use-log:update`)
? {
type: 'edit',
btnName: '编辑',
}
: undefined,
this.$auth.hasPermi(`base:material-use-log:delete`)
? {
type: 'delete',
btnName: '删除',
}
: undefined,
].filter((v)=>v),
tableData: [],
listQuery: {
pageSize: 10,
pageNo: 1,
total: 1,
materialName: undefined,
useTime: []
},
formConfig: [
{
type: 'input',
label: '物料名称',
placeholder: '物料名称',
param: 'name',
},
{
type: 'datePicker',
label: '使用时间段',
dateType: 'datetimerange',
format: 'yyyy-MM-dd',
valueFormat: 'yyyy-MM-dd HH:mm:ss',
rangeSeparator: '-',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间',
width: 350,
param: 'time',
},
{
type: 'button',
btnName: '查询',
name: 'search',
color: 'primary'
},
{
type: 'separate',
},
{
type: this.$auth.hasPermi('base:material-use-log:create') ? 'button' : '',
btnName: '新增',
name: 'add',
color: 'success',
plain: true
},
],
};
},
components: {
AddOrUpdate,
},
created() {},
methods: {
//
getDataList() {
this.dataListLoading = true;
this.urlOptions.getDataListURL(this.listQuery).then(response => {
this.tableData = response.data.records;
this.listQuery.total = response.data.total;
this.dataListLoading = false;
});
},
buttonClick(val) {
switch (val.btnName) {
case 'search':
this.listQuery.pageNo = 1;
this.listQuery.pageSize = 10;
this.listQuery.materialName = val.name ? val.name : undefined;
if (val.time) {
this.listQuery.useTime[0] = val.time[0]
this.listQuery.useTime[1] = val.time[1]
} else {
this.listQuery.useTime = []
}
console.log('222', this.listQuery, val.time)
this.getDataList();
break;
case 'reset':
this.$refs.searchBarForm.resetForm();
this.listQuery = {
pageSize: 10,
pageNo: 1,
total: 1,
};
this.getDataList();
break;
case 'add':
this.addOrEditTitle = '新增';
this.addOrUpdateVisible = true;
this.addOrUpdateHandle();
break;
case 'export':
this.handleExport();
break;
default:
console.log(val);
}
},
},
};
</script>