更新物料、班组、仓库
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<!--
|
||||
* @Author: zwq
|
||||
* @Date: 2021-11-18 14:16:25
|
||||
* @LastEditors: DY
|
||||
* @LastEditTime: 2023-11-16 09:14:35
|
||||
* @LastEditors: zwq
|
||||
* @LastEditTime: 2024-07-03 14:19:01
|
||||
* @Description:
|
||||
-->
|
||||
<template>
|
||||
@@ -62,7 +62,7 @@
|
||||
<svg-icon style="width: 18px; height: 18px" class="item-icon" icon-class="edit" />
|
||||
</el-button>
|
||||
</el-tooltip> -->
|
||||
|
||||
|
||||
<!-- <el-tooltip placement="top" content="删除">
|
||||
<el-button
|
||||
type="text"
|
||||
@@ -105,7 +105,7 @@
|
||||
<script>
|
||||
import basicAdd from '../../core/mixins/basic-add';
|
||||
import { getConOrderList, createConCoreWOr, getCoreWO } from '@/api/base/coreWorkOrder';
|
||||
import SmallTitle from '../material/SmallTitle';
|
||||
import SmallTitle from '../coreWorkOrder/SmallTitle';
|
||||
// import { parseTime } from '../../core/mixins/code-filter';
|
||||
// import attrAdd from './attr-add';
|
||||
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
<!--
|
||||
* @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>
|
||||
@@ -1,459 +1,223 @@
|
||||
<!--
|
||||
* @Author: zwq
|
||||
* @Date: 2021-11-18 14:16:25
|
||||
* @LastEditors: DY
|
||||
* @LastEditTime: 2023-11-27 15:26:12
|
||||
* @LastEditors: zwq
|
||||
* @LastEditTime: 2024-07-08 16:52:34
|
||||
* @Description:
|
||||
-->
|
||||
<template>
|
||||
<el-drawer
|
||||
:visible.sync="visible"
|
||||
:show-close="false"
|
||||
:wrapper-closable="isdetail"
|
||||
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"
|
||||
style="width: 100%"
|
||||
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"
|
||||
style="width: 100%"
|
||||
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"
|
||||
style="width: 100%"
|
||||
placeholder="请选择物料单位">
|
||||
<el-option
|
||||
v-for="dict in getDictDatas('unit_dict')"
|
||||
: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>
|
||||
|
||||
<div v-if="!isdetail" class="action_btn">
|
||||
<template>
|
||||
<span style="display: inline-block;">
|
||||
<el-button type="text" @click="addNew()" icon="el-icon-plus">新增</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</div>
|
||||
<base-table
|
||||
:table-props="tableProps"
|
||||
:page="listQuery.pageNo"
|
||||
:limit="listQuery.pageSize"
|
||||
: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 v-if="!isdetail" class="drawer-body__footer">
|
||||
<el-button style="" @click="goback()">取消</el-button>
|
||||
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<attr-add
|
||||
v-if="addOrUpdateVisible"
|
||||
ref="addOrUpdate"
|
||||
:material-id="dataForm.id"
|
||||
@refreshDataList="getList" />
|
||||
</el-drawer>
|
||||
<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="8">
|
||||
<el-form-item label="物料产品名称" prop="name">
|
||||
<el-input
|
||||
v-model="dataForm.name"
|
||||
clearable
|
||||
placeholder="请输入物料产品名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="物料产品编码" prop="code">
|
||||
<el-input
|
||||
v-model="dataForm.code"
|
||||
clearable
|
||||
placeholder="请输入物料产品编码" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="物料产品类型" prop="typeId">
|
||||
<treeselect
|
||||
v-model="dataForm.typeId"
|
||||
:options="deptOptions"
|
||||
:normalizer="normalizer"
|
||||
@select="setShowTime"
|
||||
:show-count="true"
|
||||
:appendToBody="true"
|
||||
z-index="99999"
|
||||
placeholder="选择物料产品类型" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="单位" prop="unit">
|
||||
<el-select
|
||||
v-model="dataForm.unit"
|
||||
filterable
|
||||
style="width: 100%"
|
||||
placeholder="请选择单位">
|
||||
<el-option
|
||||
v-for="dict in getDictDatas(DICT_TYPE.UNIT_DICT)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="规格" prop="specifications">
|
||||
<el-input
|
||||
v-model="dataForm.specifications"
|
||||
clearable
|
||||
placeholder="请输入规格" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="供应商" prop="supplierId">
|
||||
<el-select
|
||||
v-model="dataForm.supplierId"
|
||||
filterable
|
||||
clearable
|
||||
:style="{ width: '100%' }"
|
||||
placeholder="请选择供应商">
|
||||
<el-option
|
||||
v-for="item in supplierArr"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8" v-if="showTime">
|
||||
<el-form-item label="生产单位用时" prop="processTime">
|
||||
<el-input
|
||||
v-model.number="dataForm.processTime"
|
||||
type="number"
|
||||
clearable
|
||||
placeholder="请输入产线生产单位用时" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input
|
||||
v-model="dataForm.remark"
|
||||
clearable
|
||||
placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</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';
|
||||
import { getDictDatas } from "@/utils/dict";
|
||||
|
||||
const tableBtn = [
|
||||
{
|
||||
type: 'edit',
|
||||
btnName: '编辑',
|
||||
},
|
||||
{
|
||||
type: 'delete',
|
||||
btnName: '删除',
|
||||
},
|
||||
];
|
||||
const tableProps = [
|
||||
{
|
||||
prop: 'createTime',
|
||||
label: '添加时间',
|
||||
filter: parseTime,
|
||||
},
|
||||
{
|
||||
prop: 'attrName',
|
||||
label: '属性名',
|
||||
},
|
||||
{
|
||||
prop: 'attrValue',
|
||||
label: '属性值',
|
||||
},
|
||||
];
|
||||
import { getTreeArr } from '../mixins/code-filter';
|
||||
import {
|
||||
createProductMaterial,
|
||||
updateProductMaterial,
|
||||
getProductMaterial,
|
||||
getProductMaterialCode,
|
||||
getSupplierList,
|
||||
getMaterialTree,
|
||||
} from '@/api/base/material';
|
||||
import Treeselect from '@riophae/vue-treeselect';
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css';
|
||||
|
||||
export default {
|
||||
mixins: [basicAdd],
|
||||
components: { SmallTitle, attrAdd },
|
||||
components: {
|
||||
Treeselect,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
tableBtn,
|
||||
tableProps,
|
||||
addOrUpdateVisible: false,
|
||||
urlOptions: {
|
||||
isGetCode: true,
|
||||
codeURL: getCode,
|
||||
createURL: createMaterial,
|
||||
updateURL: updateMaterial,
|
||||
infoURL: getMaterial,
|
||||
},
|
||||
listQuery: {
|
||||
pageSize: 10,
|
||||
pageNo: 1,
|
||||
total: 0,
|
||||
isGetCode: true,
|
||||
codeURL: getProductMaterialCode,
|
||||
createURL: createProductMaterial,
|
||||
updateURL: updateProductMaterial,
|
||||
infoURL: getProductMaterial,
|
||||
},
|
||||
deptOptions: undefined,
|
||||
showTime: false,
|
||||
dataForm: {
|
||||
id: undefined,
|
||||
code: undefined,
|
||||
name: '',
|
||||
engName: '',
|
||||
type: '',
|
||||
spec: undefined,
|
||||
id: undefined,
|
||||
code: undefined,
|
||||
name: '',
|
||||
typeId: undefined,
|
||||
unit: undefined,
|
||||
specifications: undefined,
|
||||
supplierId: undefined,
|
||||
remark: undefined,
|
||||
unit: ''
|
||||
processTime: 0,
|
||||
remark: undefined,
|
||||
},
|
||||
materialList: [],
|
||||
supplierList: [],
|
||||
materialAttrList: [],
|
||||
unitList: [],
|
||||
visible: false,
|
||||
isdetail: false,
|
||||
idAttrShow: false,
|
||||
supplierArr: [],
|
||||
treeArr: [],
|
||||
dataRule: {
|
||||
code: [{ required: true, message: "物料编码不能为空", trigger: "blur" }],
|
||||
name: [{ required: true, message: "物料名称不能为空", trigger: "blur" }],
|
||||
type: [{ required: true, message: "物料类型不能为空", trigger: "blur" }]
|
||||
}
|
||||
code: [{ required: true, message: '编号不能为空', trigger: 'blur' }],
|
||||
name: [{ required: true, message: '名称不能为空', trigger: 'blur' }],
|
||||
typeId: [
|
||||
{
|
||||
required: true,
|
||||
message: '物料产品类型不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.getDict()
|
||||
},
|
||||
mounted() {},
|
||||
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}"的数据项?`,
|
||||
'提示',
|
||||
{
|
||||
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;
|
||||
init(id) {
|
||||
this.dataForm.id = id || '';
|
||||
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;
|
||||
if (this.dataForm.unit) {
|
||||
this.dataForm.unit = String(this.dataForm.unit)
|
||||
}
|
||||
});
|
||||
// 获取物料的属性列表
|
||||
this.getList();
|
||||
this.urlOptions.infoURL(id).then((response) => {
|
||||
this.dataForm = response.data;
|
||||
this.setDataForm();
|
||||
});
|
||||
} else {
|
||||
if (this.urlOptions.isGetCode) {
|
||||
this.getCode()
|
||||
}
|
||||
this.getCode();
|
||||
this.setDataForm();
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
// 表单提交
|
||||
dataFormSubmit() {
|
||||
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.idAttrShow = true
|
||||
this.$emit("refreshDataList");
|
||||
});
|
||||
});
|
||||
},
|
||||
goback() {
|
||||
this.$emit('refreshDataList');
|
||||
this.visible = false;
|
||||
// this.initData();
|
||||
},
|
||||
goEdit() {
|
||||
this.isdetail = false;
|
||||
},
|
||||
// 新增 / 修改
|
||||
addNew(id) {
|
||||
this.addOrUpdateVisible = true;
|
||||
typeId(typeId, product) {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.addOrUpdate.init(id);
|
||||
this.dataForm.typeId = typeId || undefined;
|
||||
this.showTime = product || false;
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
setDataForm() {
|
||||
getSupplierList().then((res) => {
|
||||
this.supplierArr = res.data;
|
||||
});
|
||||
// 下拉树结构
|
||||
getMaterialTree().then((response) => {
|
||||
this.deptOptions = [];
|
||||
this.deptOptions.push(...this.handleTree(response.data, 'id'));
|
||||
this.$nextTick(() => {
|
||||
if (this.dataForm.id) {
|
||||
this.treeArr = [];
|
||||
this.treeArr = getTreeArr(response.data);//解构,树结构变为普通数组
|
||||
this.showTime = this.treeArr.find(
|
||||
(item) => item.id == this.dataForm.typeId
|
||||
).product;
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
/** 转换菜单数据结构 */
|
||||
normalizer(node) {
|
||||
if (node.children && !node.children.length) {
|
||||
delete node.children;
|
||||
}
|
||||
return {
|
||||
id: node.id,
|
||||
label: node.name,
|
||||
children: node.children,
|
||||
};
|
||||
},
|
||||
setShowTime(node) {
|
||||
this.showTime = node.product || false;
|
||||
},
|
||||
},
|
||||
};
|
||||
</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;
|
||||
}
|
||||
.action_btn {
|
||||
float: right;
|
||||
margin: -40px 15px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.add {
|
||||
color: #0b58ff;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,141 +0,0 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
:visible.sync="visible"
|
||||
:width="'30%'"
|
||||
: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="70px"
|
||||
@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>
|
||||
@@ -1,32 +1,135 @@
|
||||
<!--
|
||||
* @Author: zwq
|
||||
* @Date: 2024-07-01 14:54:06
|
||||
* @LastEditors: zwq
|
||||
* @LastEditTime: 2024-07-08 15:12:18
|
||||
* @Description:
|
||||
-->
|
||||
<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" />
|
||||
<add-or-update
|
||||
v-if="addOrUpdateVisible"
|
||||
ref="addOrUpdate"
|
||||
@refreshDataList="getDataList" />
|
||||
<div style="display: flex; gap: 16px; flex: 1; background: #eff1f6">
|
||||
<div
|
||||
class="app-container"
|
||||
style="background: white; width: 280px; border-radius: 8px">
|
||||
<div class="head-container">
|
||||
<el-input
|
||||
v-model="treeName"
|
||||
placeholder="请输入名称"
|
||||
clearable
|
||||
size="small"
|
||||
prefix-icon="el-icon-search"
|
||||
style="margin-bottom: 20px" />
|
||||
</div>
|
||||
<div class="head-container">
|
||||
<el-tree
|
||||
v-loading="treeLoading"
|
||||
element-loading-text="拼命加载中"
|
||||
element-loading-spinner="el-icon-loading"
|
||||
element-loading-background="rgba(0, 0, 0, 0.8)"
|
||||
:data="deptOptions1"
|
||||
:props="defaultProps"
|
||||
node-key="id"
|
||||
:expand-on-click-node="false"
|
||||
:filter-node-method="filterNode"
|
||||
ref="tree"
|
||||
default-expand-all
|
||||
highlight-current
|
||||
@node-click="handleNodeClick">
|
||||
<span class="custom-tree-node" slot-scope="{ node, data }">
|
||||
<span>{{ node.label }}</span>
|
||||
<span style="float: right" v-if="data.parentId !== -1">
|
||||
<el-button
|
||||
class="btnHover"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
size="mini"
|
||||
v-if="data.parentId !== 0"
|
||||
@click="() => edit(node, data)" />
|
||||
<el-button
|
||||
class="btnHover"
|
||||
type="text"
|
||||
icon="el-icon-circle-plus-outline"
|
||||
size="mini"
|
||||
@click="() => append(data)" />
|
||||
<el-button
|
||||
class="btnHover"
|
||||
type="text"
|
||||
icon="el-icon-remove-outline"
|
||||
size="mini"
|
||||
v-if="data.parentId !== 0"
|
||||
@click="() => remove(node, data)" />
|
||||
</span>
|
||||
</span>
|
||||
</el-tree>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="app-container"
|
||||
style="background: #fff; border-radius: 8px; width: 1px; flex: 1">
|
||||
<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="80"
|
||||
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>
|
||||
|
||||
<!-- 添加或修改菜单对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="700px">
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="父类型">
|
||||
<treeselect
|
||||
v-model="form.parentId"
|
||||
:options="deptOptions"
|
||||
:normalizer="normalizer"
|
||||
:show-count="true"
|
||||
:appendToBody="true"
|
||||
z-index="99999"
|
||||
placeholder="选择父类型" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -34,97 +137,129 @@
|
||||
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";
|
||||
import { publicFormatter } from '@/utils/dict';
|
||||
import {
|
||||
getProductMaterialPage,
|
||||
deleteProductMaterial,
|
||||
getMaterialTree,
|
||||
createMaterialTree,
|
||||
updateMaterialTree,
|
||||
deleteMaterialTree,
|
||||
} from '@/api/base/material';
|
||||
import Treeselect from '@riophae/vue-treeselect';
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css';
|
||||
|
||||
const tableProps = [
|
||||
{
|
||||
prop: 'createTime',
|
||||
label: '添加时间',
|
||||
filter: parseTime
|
||||
},
|
||||
{
|
||||
prop: 'code',
|
||||
label: '物料编码'
|
||||
filter: parseTime,
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
prop: 'name',
|
||||
label: '物料名称'
|
||||
label: '物料产品名称',
|
||||
},
|
||||
{
|
||||
prop: 'engName',
|
||||
label: '英文名称'
|
||||
prop: 'code',
|
||||
label: '物料产品编码',
|
||||
},
|
||||
{
|
||||
prop: 'type',
|
||||
label: '物料类型',
|
||||
filter: publicFormatter('material_type')
|
||||
prop: 'typeNameChain',
|
||||
label: '物料产品类型',
|
||||
},
|
||||
{
|
||||
prop: 'unit',
|
||||
label: '单位',
|
||||
filter: publicFormatter('unit_dict'),
|
||||
width: 60,
|
||||
},
|
||||
{
|
||||
prop: 'specifications',
|
||||
label: '规格',
|
||||
},
|
||||
{
|
||||
prop: 'supplierName',
|
||||
label: '供应商'
|
||||
label: '供应商',
|
||||
},
|
||||
{
|
||||
prop: 'remark',
|
||||
label: '备注'
|
||||
}
|
||||
label: '备注',
|
||||
},
|
||||
];
|
||||
|
||||
export default {
|
||||
mixins: [basicPage],
|
||||
name: '',
|
||||
components: {
|
||||
AddOrUpdate,
|
||||
Treeselect,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 部门树选项
|
||||
treeName: undefined,
|
||||
deptOptions: undefined,
|
||||
deptOptions1: undefined,
|
||||
treeLoading: false,
|
||||
defaultProps: {
|
||||
children: 'children',
|
||||
label: 'name',
|
||||
},
|
||||
// 弹出层标题
|
||||
title: '',
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 表单参数
|
||||
form: {
|
||||
id: undefined,
|
||||
parentId: undefined,
|
||||
name: undefined,
|
||||
defaultType: false,
|
||||
},
|
||||
// 表单校验
|
||||
rules: {
|
||||
name: [{ required: true, message: '名称不能为空', trigger: 'blur' }],
|
||||
},
|
||||
urlOptions: {
|
||||
getDataListURL: getMaterialPage,
|
||||
deleteURL: deleteMaterial
|
||||
// exportURL: exportFactoryExcel,
|
||||
getDataListURL: getProductMaterialPage,
|
||||
deleteURL: deleteProductMaterial,
|
||||
},
|
||||
tableProps,
|
||||
tableBtn: [
|
||||
this.$auth.hasPermi(`base:material:queryAttr`)
|
||||
? {
|
||||
type: 'detail',
|
||||
btnName: '查看属性',
|
||||
}
|
||||
: undefined,
|
||||
this.$auth.hasPermi(`base:material:update`)
|
||||
this.$auth.hasPermi(`base:core-product:update`)
|
||||
? {
|
||||
type: 'edit',
|
||||
btnName: '编辑',
|
||||
}
|
||||
: undefined,
|
||||
// this.$auth.hasPermi(`base:material:editAttr`)
|
||||
// ? {
|
||||
// type: 'editAttr',
|
||||
// btnName: '编辑属性',
|
||||
// }
|
||||
// : undefined,
|
||||
this.$auth.hasPermi(`base:material:delete`)
|
||||
this.$auth.hasPermi(`base:core-product:delete`)
|
||||
? {
|
||||
type: 'delete',
|
||||
btnName: '删除',
|
||||
}
|
||||
: undefined,
|
||||
].filter((v)=>v),
|
||||
].filter((v) => v),
|
||||
tableData: [],
|
||||
typeList: [],
|
||||
formConfig: [
|
||||
{
|
||||
type: 'input',
|
||||
label: '物料名称',
|
||||
placeholder: '物料名称',
|
||||
label: '物料产品名称',
|
||||
placeholder: '物料产品名称',
|
||||
param: 'name',
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
label: '物料编码',
|
||||
placeholder: '物料编码',
|
||||
label: '物料产品编号',
|
||||
placeholder: '物料产品编号',
|
||||
param: 'code',
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
label: '物料产品类型',
|
||||
param: 'type',
|
||||
disabled: true,
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
btnName: '查询',
|
||||
@@ -139,63 +274,43 @@ export default {
|
||||
btnName: '新增',
|
||||
name: 'add',
|
||||
color: 'success',
|
||||
plain: true
|
||||
plain: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
components: {
|
||||
AddOrUpdate,
|
||||
watch: {
|
||||
// 根据名称筛选部门树
|
||||
treeName(val) {
|
||||
this.$refs.tree.filter(val);
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.getDict()
|
||||
this.getDataList();
|
||||
this.getTreeselect();
|
||||
},
|
||||
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)
|
||||
}
|
||||
});
|
||||
// 删除
|
||||
deleteHandle(id, name, index) {
|
||||
this.$confirm(`是否确认删除物料产品名称为"${name}"的数据项`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
})
|
||||
.then(() => {
|
||||
this.urlOptions.deleteURL(id).then(({ data }) => {
|
||||
this.$message({
|
||||
message: '操作成功',
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.getDataList();
|
||||
},
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
},
|
||||
otherMethods(val) {
|
||||
if (val.type === 'detail') {
|
||||
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':
|
||||
@@ -205,19 +320,13 @@ export default {
|
||||
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();
|
||||
this.$nextTick(() => {
|
||||
this.$refs.addOrUpdate.init();
|
||||
this.$refs.addOrUpdate.typeId(this.listQuery.typeId,this.listQuery.product);
|
||||
});
|
||||
break;
|
||||
case 'export':
|
||||
this.handleExport();
|
||||
@@ -226,27 +335,126 @@ export default {
|
||||
console.log(val);
|
||||
}
|
||||
},
|
||||
// 删除
|
||||
deleteHandle(id, name, index) {
|
||||
this.$confirm(`是否删除物料名称为"${name}"的数据项?`, "提示", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
})
|
||||
.then(() => {
|
||||
this.urlOptions.deleteURL(id).then(({ data }) => {
|
||||
this.$message({
|
||||
message: "操作成功",
|
||||
type: "success",
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.getDataList();
|
||||
},
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(() => { });
|
||||
}
|
||||
|
||||
/** 树操作 */
|
||||
|
||||
// 查询下拉树结构
|
||||
getTreeselect() {
|
||||
this.treeLoading = true;
|
||||
getMaterialTree().then((response) => {
|
||||
// treeArr[0].push(...this.handleTree(response.data, 'id'));
|
||||
// 处理 deptOptions 参数
|
||||
this.deptOptions = [];
|
||||
this.treeLoading = false;
|
||||
this.deptOptions.push(...this.handleTree(response.data, 'id'));
|
||||
const arr = [{ name: '全部', parentId: -1 }];
|
||||
this.deptOptions1 = arr.concat(this.deptOptions);
|
||||
});
|
||||
},
|
||||
// 筛选节点
|
||||
filterNode(value, data) {
|
||||
if (!value) return true;
|
||||
return data.name.indexOf(value) !== -1;
|
||||
},
|
||||
// 节点单击事件
|
||||
handleNodeClick(data) {
|
||||
this.listQuery.typeId = data.id || undefined;
|
||||
this.listQuery.product = data.product;
|
||||
this.$refs.searchBarForm.formInline.type = data.name || undefined;
|
||||
},
|
||||
// 新增节点
|
||||
append(data) {
|
||||
this.open = true;
|
||||
this.title = '新增物料产品类型';
|
||||
this.form.id = undefined;
|
||||
this.form.parentId = data.id;
|
||||
},
|
||||
// 删除节点
|
||||
remove(node, data) {
|
||||
this.$confirm(`是否确认删除名称为"${data.name}"的数据项`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
})
|
||||
.then(() => {
|
||||
deleteMaterialTree(data.id).then(({ data }) => {
|
||||
this.$message({
|
||||
message: '操作成功',
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.getTreeselect();
|
||||
},
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
},
|
||||
// 编辑节点
|
||||
edit(node, data) {
|
||||
this.open = true;
|
||||
this.title = '编辑物料产品类型';
|
||||
this.form.id = data.id;
|
||||
this.form.name = data.name;
|
||||
this.form.parentId = data.parentId;
|
||||
},
|
||||
|
||||
/** 转换菜单数据结构 */
|
||||
normalizer(node) {
|
||||
if (node.children && !node.children.length) {
|
||||
delete node.children;
|
||||
}
|
||||
return {
|
||||
id: node.id,
|
||||
label: node.name,
|
||||
children: node.children,
|
||||
};
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
id: undefined,
|
||||
parentId: 0,
|
||||
name: undefined,
|
||||
defaultType: false,
|
||||
};
|
||||
this.resetForm('form');
|
||||
},
|
||||
// 表单提交
|
||||
submitForm() {
|
||||
this.$refs['form'].validate((valid) => {
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
// 修改的提交
|
||||
if (this.form.id) {
|
||||
updateMaterialTree(this.form).then((response) => {
|
||||
this.$modal.msgSuccess('修改成功');
|
||||
this.cancel();
|
||||
this.getTreeselect();
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 添加的提交
|
||||
createMaterialTree(this.form).then((response) => {
|
||||
this.$modal.msgSuccess('新增成功');
|
||||
this.cancel();
|
||||
this.getTreeselect();
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.btnHover:hover {
|
||||
color: #67c23a;
|
||||
transform: scale(1.5);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<!--
|
||||
* @Author: zwq
|
||||
* @Date: 2021-11-18 14:16:25
|
||||
* @LastEditors: DY
|
||||
* @LastEditTime: 2023-11-27 19:50:36
|
||||
* @LastEditors: zwq
|
||||
* @LastEditTime: 2024-07-09 09:59:11
|
||||
* @Description:
|
||||
-->
|
||||
<template>
|
||||
@@ -107,10 +107,9 @@
|
||||
|
||||
<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 { createMaterialPB, updateMaterialPB, getMaterialPB, getCode, getProBomList, createMaterialPBDet, updateMaterialPBDet, deleteMaterialPBDet } from "@/api/base/materialProductBom";
|
||||
import { getMaterialTree,getMaterialList } from '@/api/base/material';
|
||||
import SmallTitle from '../coreWorkOrder/SmallTitle';
|
||||
import { parseTime } from '../../core/mixins/code-filter';
|
||||
import attrAdd from './attr-add';
|
||||
import { publicFormatter } from '@/utils/dict';
|
||||
@@ -183,7 +182,6 @@ export default {
|
||||
productList: [],
|
||||
materialAttrList: [],
|
||||
tableData: [],
|
||||
unitList: [],
|
||||
visible: false,
|
||||
isdetail: false,
|
||||
idAttrShow: false,
|
||||
@@ -213,7 +211,7 @@ export default {
|
||||
if (this.dataForm.id) {
|
||||
this.urlOptions.updateURL(this.dataForm).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.visible = false;
|
||||
this.visible = false;
|
||||
this.$emit("refreshDataList");
|
||||
});
|
||||
return;
|
||||
@@ -229,21 +227,14 @@ export default {
|
||||
});
|
||||
},
|
||||
async getDict() {
|
||||
// 产品列表
|
||||
const proRes = await getProList();
|
||||
this.productList = proRes.data;
|
||||
// 物料单位列表
|
||||
const unitRes = await listData({
|
||||
pageNo: 1,
|
||||
pageSize: 99,
|
||||
dictType: 'unit_dict',
|
||||
});
|
||||
this.unitList = unitRes.data.list.map(item => {
|
||||
return {
|
||||
label: item.label,
|
||||
value: Number(item.value)
|
||||
}
|
||||
});
|
||||
const materRes = await getMaterialTree();
|
||||
let typeId = materRes.data[0].product?materRes.data[0].id:materRes.data[1].id
|
||||
const listQuery= {
|
||||
typeId:typeId
|
||||
}
|
||||
const materData = await getMaterialList(listQuery);
|
||||
this.productList = [];
|
||||
this.productList = materData.data;
|
||||
},
|
||||
initData() {
|
||||
// this.materialAttrList.splice(0);
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getMaterialList } from '@/api/base/material';
|
||||
import { getMaterialTree,getMaterialList } from '@/api/base/material';
|
||||
import { createMaterialPBDet, updateMaterialPBDet, getMaterialPBDet } from "@/api/base/materialProductBom";
|
||||
|
||||
export default {
|
||||
@@ -117,8 +117,14 @@ export default {
|
||||
methods: {
|
||||
async getDict() {
|
||||
// 物料列表
|
||||
const res = await getMaterialList();
|
||||
this.materialList = res.data;
|
||||
const materRes = await getMaterialTree();
|
||||
let typeId = materRes.data[0].product?materRes.data[1].id:materRes.data[0].id
|
||||
const listQuery= {
|
||||
typeId:typeId
|
||||
}
|
||||
const materData = await getMaterialList(listQuery);
|
||||
this.materialList = [];
|
||||
this.materialList = materData.data;
|
||||
},
|
||||
init(id) {
|
||||
this.dataForm.id = id || '';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<!--
|
||||
* @Author: zwq
|
||||
* @Date: 2021-11-18 14:16:25
|
||||
* @LastEditors: DY
|
||||
* @LastEditTime: 2023-11-27 19:57:23
|
||||
* @LastEditors: zwq
|
||||
* @LastEditTime: 2024-07-09 09:58:24
|
||||
* @Description:
|
||||
-->
|
||||
<template>
|
||||
@@ -22,8 +22,7 @@
|
||||
clearable
|
||||
filterable
|
||||
@change="setCode"
|
||||
style="width: 100%"
|
||||
>
|
||||
style="width: 100%">
|
||||
<el-option
|
||||
v-for="dict in materialList"
|
||||
:key="dict.id"
|
||||
@@ -42,14 +41,13 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="批次号" prop="materialDateId">
|
||||
<el-form-item label="物料批次" prop="materialDateId">
|
||||
<el-select
|
||||
v-model="dataForm.materialDateId"
|
||||
clearable
|
||||
filterable
|
||||
placeholder="请选择物料批次"
|
||||
style="width: 100%"
|
||||
>
|
||||
style="width: 100%">
|
||||
<el-option
|
||||
v-for="dict in materialDateList"
|
||||
:key="dict.id"
|
||||
@@ -81,8 +79,8 @@
|
||||
<el-date-picker
|
||||
v-model="dataForm.useTime"
|
||||
type="datetime"
|
||||
format='yyyy-MM-dd HH:mm:ss'
|
||||
value-format='timestamp'
|
||||
format="yyyy-MM-dd HH:mm:ss"
|
||||
value-format="timestamp"
|
||||
placeholder="选择日期时间" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -98,8 +96,8 @@
|
||||
<el-option
|
||||
v-for="dict in workersList"
|
||||
:key="dict.id"
|
||||
:label="dict.name"
|
||||
:value="dict.name" />
|
||||
:label="dict.nickname"
|
||||
:value="dict.nickname" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -107,7 +105,12 @@
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="使用数量" prop="num">
|
||||
<el-input-number v-model="dataForm.num" clearable controls-position="right" placeholder="请输入使用数量" style="width: 100%" />
|
||||
<el-input-number
|
||||
v-model="dataForm.num"
|
||||
clearable
|
||||
controls-position="right"
|
||||
placeholder="请输入使用数量"
|
||||
style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
@@ -126,7 +129,10 @@
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="dataForm.remark" clearable placeholder="请输入备注" />
|
||||
<el-input
|
||||
v-model="dataForm.remark"
|
||||
clearable
|
||||
placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@@ -135,9 +141,15 @@
|
||||
|
||||
<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"
|
||||
import {
|
||||
createMaterialLog,
|
||||
updateMaterialLog,
|
||||
getMaterialLog,
|
||||
getEqListAll,
|
||||
} from '@/api/base/materialUseLog';
|
||||
import { getMaterialTree,getMaterialList } from '@/api/base/material';
|
||||
import { getMaterDateList } from '@/api/base/materialDate';
|
||||
import { listSimpleUsers } from '@/api/system/user';
|
||||
|
||||
export default {
|
||||
mixins: [basicAdd],
|
||||
@@ -146,115 +158,127 @@ export default {
|
||||
urlOptions: {
|
||||
createURL: createMaterialLog,
|
||||
updateURL: updateMaterialLog,
|
||||
infoURL: getMaterialLog
|
||||
infoURL: getMaterialLog,
|
||||
},
|
||||
dataForm: {
|
||||
id: undefined,
|
||||
id: undefined,
|
||||
materialId: undefined,
|
||||
materialCode: undefined,
|
||||
materialCode: undefined,
|
||||
materialDateId: undefined,
|
||||
equipmentId: undefined,
|
||||
userName: undefined,
|
||||
userName: undefined,
|
||||
userNames: [],
|
||||
useTime: new Date().getTime(),
|
||||
address: undefined,
|
||||
address: undefined,
|
||||
num: 0,
|
||||
source: undefined,
|
||||
remark: undefined
|
||||
remark: undefined,
|
||||
},
|
||||
dataSourceList: [
|
||||
{
|
||||
id: 1,
|
||||
name: '手动'
|
||||
name: '手动',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'PDA'
|
||||
}
|
||||
name: 'PDA',
|
||||
},
|
||||
],
|
||||
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" }]
|
||||
}
|
||||
materialId: [
|
||||
{ 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()
|
||||
this.getDictData();
|
||||
},
|
||||
methods: {
|
||||
async getDictData() {
|
||||
const materRes = await getMaterialList()
|
||||
this.materialList = materRes.data
|
||||
const dateRes = await getMaterDateList()
|
||||
this.materialDateList = dateRes.data
|
||||
const eqRes = await getEqListAll()
|
||||
this.eqList = eqRes.data
|
||||
const workerRes = await getworkerAll()
|
||||
this.workersList = workerRes.data
|
||||
const materRes = await getMaterialTree();
|
||||
let typeId = materRes.data[0].product?materRes.data[1].id:materRes.data[0].id
|
||||
const listQuery= {
|
||||
typeId:typeId
|
||||
}
|
||||
const materData = await getMaterialList(listQuery);
|
||||
this.materialList = [];
|
||||
this.materialList = materData.data;
|
||||
const dateRes = await getMaterDateList();
|
||||
this.materialDateList = dateRes.data;
|
||||
const eqRes = await getEqListAll();
|
||||
this.eqList = eqRes.data;
|
||||
const workerRes = await listSimpleUsers();
|
||||
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");
|
||||
});
|
||||
});
|
||||
},
|
||||
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.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.$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(',')
|
||||
});
|
||||
} else {}
|
||||
});
|
||||
},
|
||||
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(',');
|
||||
});
|
||||
} else {
|
||||
}
|
||||
});
|
||||
},
|
||||
setCode() {
|
||||
const tempMaterial = this.materialList.filter(item =>{
|
||||
return item.id === this.dataForm.materialId
|
||||
})
|
||||
this.dataForm.materialCode = tempMaterial[0].code
|
||||
getMaterDateList({materialId: this.dataForm.materialId}).then(res =>{
|
||||
this.materialDateList = res.data
|
||||
})
|
||||
}
|
||||
const tempMaterial = this.materialList.filter((item) => {
|
||||
return item.id === this.dataForm.materialId;
|
||||
});
|
||||
this.dataForm.materialCode = tempMaterial[0].code;
|
||||
getMaterDateList({ materialId: this.dataForm.materialId }).then((res) => {
|
||||
this.materialDateList = res.data;
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* @Author: zwq
|
||||
* @Date: 2022-08-24 11:19:43
|
||||
* @LastEditors: zhp
|
||||
* @LastEditTime: 2023-11-24 09:29:36
|
||||
* @LastEditors: zwq
|
||||
* @LastEditTime: 2024-07-05 10:10:12
|
||||
* @Description:
|
||||
*/
|
||||
export default {
|
||||
@@ -53,11 +53,12 @@ export default {
|
||||
this.listQuery.pageNo = val;
|
||||
this.getDataList();
|
||||
},
|
||||
// 新增 / 修改
|
||||
addOrUpdateHandle(id) {
|
||||
// 新增
|
||||
addOrUpdateHandle() {
|
||||
this.addOrEditTitle = '新增';
|
||||
this.addOrUpdateVisible = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.addOrUpdate.init(id);
|
||||
this.$refs.addOrUpdate.init();
|
||||
});
|
||||
},
|
||||
cancel(id) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
/*
|
||||
* @Date: 2020-12-29 16:49:28
|
||||
* @LastEditors: DY
|
||||
* @LastEditTime: 2023-09-12 11:13:34
|
||||
* @LastEditors: zwq
|
||||
* @LastEditTime: 2024-07-08 16:27:39
|
||||
* @FilePath: \basic-admin\src\filters\basicData\index.js
|
||||
* @Description:
|
||||
*/
|
||||
@@ -33,7 +33,7 @@ export function parseTime(time, pattern) {
|
||||
if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
|
||||
time = parseInt(time)
|
||||
} else if (typeof time === 'string') {
|
||||
time = time.replace(new RegExp(/-/gm), '/').replace('T', ' ').replace(new RegExp(/\.\d{3}/gm),'');
|
||||
time = time.replace(new RegExp(/-/gm), '/').replace('T', ' ').replace(new RegExp(/\.\d{3}/gm), '');
|
||||
}
|
||||
if ((typeof time === 'number') && (time.toString().length === 10)) {
|
||||
time = time * 1000
|
||||
@@ -62,6 +62,22 @@ export function parseTime(time, pattern) {
|
||||
})
|
||||
return time_str
|
||||
}
|
||||
// 遍历树结构返回数组
|
||||
export function getTreeArr(arr) {
|
||||
let result =[]
|
||||
arr.forEach(item => {
|
||||
if(item.children && item.children.length>0){
|
||||
let {children,...obj} = item
|
||||
result.push(obj)
|
||||
result = result.concat(getTreeArr(children))
|
||||
}else{
|
||||
let {children,...obj} = item
|
||||
result.push(obj)
|
||||
}
|
||||
});
|
||||
return result
|
||||
}
|
||||
|
||||
export default function (dictTable) {
|
||||
return function (val) {
|
||||
return table?.[dictTable]?.[val]
|
||||
|
||||
Reference in New Issue
Block a user