fix:光子物料
This commit is contained in:
parent
110bc149d8
commit
75c2ebcadf
|
@ -0,0 +1,264 @@
|
|||
<template>
|
||||
<el-dialog
|
||||
:title="titleMap[mode]"
|
||||
v-model="visible"
|
||||
:size="1000"
|
||||
destroy-on-close
|
||||
@closed="$emit('closed')"
|
||||
>
|
||||
<el-container v-loading="loading">
|
||||
<el-main style="padding: 0 20px 20px 20px">
|
||||
<el-form
|
||||
ref="dialogForm"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
label-width="120px"
|
||||
>
|
||||
<el-row>
|
||||
<el-col :md="12" :sm="24">
|
||||
<el-form-item label="物料类别" prop="type">
|
||||
<el-select
|
||||
v-model="form.type"
|
||||
placeholder="物料类别"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
@change="typeChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :md="12" :sm="24">
|
||||
<el-form-item label="物料编号" prop="number">
|
||||
<el-input
|
||||
v-model="form.number"
|
||||
placeholder="物料编号"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :md="12" :sm="24" prop="name">
|
||||
<el-form-item label="物料名称">
|
||||
<el-input
|
||||
v-model="form.name"
|
||||
placeholder="物料名称"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :md="12" :sm="24">
|
||||
<el-form-item label="规格">
|
||||
<el-input
|
||||
v-model="form.specification"
|
||||
placeholder="规格"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :md="12" :sm="24">
|
||||
<el-form-item label="型号">
|
||||
<el-input
|
||||
v-model="form.model"
|
||||
placeholder="型号"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :md="12" :sm="24">
|
||||
<el-form-item label="已到工序" prop="process">
|
||||
<el-select
|
||||
v-model="form.process"
|
||||
placeholder="已到工序"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in processOptions"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :md="12" :sm="24">
|
||||
<el-form-item label="安全库存" prop="count_safe">
|
||||
<el-input-number
|
||||
v-model="form.count_safe"
|
||||
:min="0"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- 光芯 -->
|
||||
<el-col :md="12" :sm="24">
|
||||
<el-form-item label="物料单价">
|
||||
<el-input-number
|
||||
v-model="form.unit_price"
|
||||
:min="0"
|
||||
controls-position="right"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :md="12" :sm="24">
|
||||
<el-form-item label="是否隐藏" prop="is_hidden">
|
||||
<el-switch v-model="form.is_hidden" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</el-main>
|
||||
<el-footer>
|
||||
<el-button type="primary" :loading="isSaveing" @click="submit"
|
||||
>保存</el-button
|
||||
>
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
</el-footer>
|
||||
</el-container>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
emits: ["success", "closed"],
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
mode: "add",
|
||||
titleMap: {
|
||||
add: "新增物料",
|
||||
edit: "编辑物料",
|
||||
show: "查看物料",
|
||||
},
|
||||
form: {},
|
||||
rules: {
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入物料名称",
|
||||
trigger: "blur",
|
||||
},
|
||||
],
|
||||
type: [
|
||||
{
|
||||
required: true,
|
||||
message: "请选择物料类别",
|
||||
trigger: "blur",
|
||||
},
|
||||
],
|
||||
number: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入物料编号",
|
||||
trigger: "blur",
|
||||
},
|
||||
],
|
||||
},
|
||||
visible: false,
|
||||
isSaveing: false,
|
||||
|
||||
options: [
|
||||
{ id: 10, name: "成品" },
|
||||
{ id: 20, name: "半成品" },
|
||||
{ id: 30, name: "主要原料" },
|
||||
{ id: 40, name: "辅助材料" },
|
||||
],
|
||||
handle_user: [],
|
||||
selectionFilters: [],
|
||||
materialOptions: [],
|
||||
setFiltersVisible: false,
|
||||
processOptions: [],
|
||||
componentList: [{ id: "", count: 1 }],
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.getProcessOptions();
|
||||
},
|
||||
methods: {
|
||||
getProcessOptions() {
|
||||
this.$API.mtm.process.list.req({ page: 0 }).then((res) => {
|
||||
this.processOptions = res;
|
||||
});
|
||||
},
|
||||
//显示
|
||||
open(mode = "add", type) {
|
||||
this.mode = mode;
|
||||
this.visible = true;
|
||||
return this;
|
||||
},
|
||||
getMaterial(val) {
|
||||
let that = this;
|
||||
let query = {};
|
||||
query.type = val;
|
||||
query.page = 0;
|
||||
query.is_hidden = false;
|
||||
this.$API.mtm.material.list.req(query).then((res) => {
|
||||
that.materialOptions = [];
|
||||
res.forEach((item) => {
|
||||
item.label =
|
||||
item.name + "—" + item.specification + "/" + item.model;
|
||||
});
|
||||
that.materialOptions = res;
|
||||
});
|
||||
},
|
||||
typeChange(val) {
|
||||
this.getMaterial(val);
|
||||
},
|
||||
//提交
|
||||
submit() {
|
||||
this.$refs.dialogForm.validate(async (valid) => {
|
||||
if (valid) {
|
||||
this.isSaveing = true;
|
||||
if (this.mode == "add") {
|
||||
this.$API.mtm.material.create
|
||||
.req(this.form)
|
||||
.then((res) => {
|
||||
this.isSaveing = false;
|
||||
this.$emit("success", this.form, this.mode);
|
||||
this.visible = false;
|
||||
this.$message.success("操作成功");
|
||||
})
|
||||
.catch(() => {
|
||||
this.isSaveing = false;
|
||||
this.visible = false;
|
||||
});
|
||||
} else if (this.mode == "edit") {
|
||||
this.$API.mtm.material.update
|
||||
.req(this.form.id, this.form)
|
||||
.then((res) => {
|
||||
this.isSaveing = false;
|
||||
this.$emit("success", this.form, this.mode);
|
||||
this.visible = false;
|
||||
this.$message.success("操作成功");
|
||||
})
|
||||
.catch(() => {
|
||||
this.isSaveing = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
//表单注入数据
|
||||
setData(data) {
|
||||
Object.assign(this.form, data);
|
||||
this.getMaterial(data.type);
|
||||
},
|
||||
|
||||
//设置过滤项
|
||||
setFilters(filters) {
|
||||
this.selectionFilters = filters;
|
||||
this.setFiltersVisible = true;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
.deleteIcons {
|
||||
color: #f56c6c;
|
||||
font-size: 25px;
|
||||
line-height: 34px;
|
||||
height: 34px;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,326 @@
|
|||
<template>
|
||||
<el-container>
|
||||
<el-header>
|
||||
<div class="left-panel">
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="el-icon-plus"
|
||||
@click="add"
|
||||
v-auth="'material.create'"
|
||||
>新增</el-button
|
||||
>
|
||||
<scFileImport
|
||||
:templateUrl="materialTemplate"
|
||||
accept=".xlsx"
|
||||
:apiObj="$API.common.upload"
|
||||
@success="upSuccess"
|
||||
>
|
||||
</scFileImport>
|
||||
</div>
|
||||
<div class="right-panel">
|
||||
<el-input
|
||||
v-model="query.search"
|
||||
placeholder="名称"
|
||||
clearable
|
||||
></el-input>
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="el-icon-search"
|
||||
@click="handleQuery"
|
||||
></el-button>
|
||||
</div>
|
||||
</el-header>
|
||||
<el-main class="nopadding">
|
||||
<el-container>
|
||||
<el-header>
|
||||
<el-tabs
|
||||
v-model="activeName"
|
||||
class="demo-tabs"
|
||||
@tab-click="handleClick"
|
||||
type="card"
|
||||
>
|
||||
<el-tab-pane
|
||||
v-for="item in tabOptions"
|
||||
v-bind:key="item.name"
|
||||
:label="item.label"
|
||||
:name="item.name"
|
||||
>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<el-checkbox
|
||||
v-model="showHidden"
|
||||
label="显示隐式物料"
|
||||
@change="hiddenChange"
|
||||
/>
|
||||
</el-header>
|
||||
<el-main class="nopadding">
|
||||
<scTable
|
||||
ref="table"
|
||||
:apiObj="apiObj"
|
||||
row-key="id"
|
||||
stripe
|
||||
@row-click="rowClick"
|
||||
>
|
||||
<el-table-column type="index" width="50" />
|
||||
<el-table-column label="物料编号" prop="number">
|
||||
</el-table-column>
|
||||
<el-table-column label="物料名称" prop="name">
|
||||
</el-table-column>
|
||||
<el-table-column label="规格" prop="specification">
|
||||
</el-table-column>
|
||||
<el-table-column label="型号" prop="model">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="物料特征"
|
||||
prop="type"
|
||||
width="230"
|
||||
>
|
||||
<template #default="scope">
|
||||
<span
|
||||
><el-tag>{{
|
||||
typeOptions[scope.row.type]
|
||||
}}</el-tag>
|
||||
<el-tag
|
||||
type="warning"
|
||||
v-if="scope.row.is_assemb"
|
||||
effect="plain"
|
||||
>组</el-tag
|
||||
>
|
||||
<el-tag
|
||||
type="warning"
|
||||
v-if="scope.row.process_name"
|
||||
effect="plain"
|
||||
>{{ scope.row.process_name }}</el-tag
|
||||
>
|
||||
<el-tag
|
||||
type="warning"
|
||||
v-if="scope.row.is_hidden"
|
||||
effect="plain"
|
||||
>隐</el-tag
|
||||
></span
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="计量单位"
|
||||
prop="unit"
|
||||
width="80"
|
||||
>
|
||||
</el-table-column>
|
||||
<el-table-column label="总库存" prop="count" width="80">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="安全库存"
|
||||
prop="count_safe"
|
||||
width="80"
|
||||
>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="materialType == ''"
|
||||
label="操作"
|
||||
fixed="right"
|
||||
align="center"
|
||||
width="140"
|
||||
>
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="table_edit(scope.row)"
|
||||
v-auth="'material.update'"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="warning"
|
||||
@click="table_copy(scope.row)"
|
||||
v-auth="'material.create'"
|
||||
>
|
||||
复制
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
@click="table_del(scope.row)"
|
||||
v-auth="'material.delete'"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</scTable>
|
||||
</el-main>
|
||||
</el-container>
|
||||
</el-main>
|
||||
</el-container>
|
||||
<save-dialog
|
||||
v-if="dialog.save"
|
||||
ref="saveDialog"
|
||||
@success="handleSaveSuccess"
|
||||
@closed="dialog.save = false"
|
||||
></save-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import saveDialog from "./materials_form_gx.vue";
|
||||
import scFileImport from "@/components/scFileImport";
|
||||
import scFileExport from "@/components/scFileExport";
|
||||
import { ElLoading } from "element-plus";
|
||||
|
||||
export default {
|
||||
name: "rparty",
|
||||
props: {
|
||||
materialType: {
|
||||
//当作选择页面时传参
|
||||
type: String,
|
||||
default() {
|
||||
return "";
|
||||
},
|
||||
},
|
||||
},
|
||||
components: {
|
||||
saveDialog,
|
||||
scFileImport,
|
||||
scFileExport,
|
||||
ElLoading,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
materialTemplate: "/media/template/material.xlsx",
|
||||
dialog: {
|
||||
save: false,
|
||||
},
|
||||
apiObj: null,
|
||||
query: { type: 10, is_hidden: false },
|
||||
activeName: "主要原料",
|
||||
selection: [],
|
||||
state_: {
|
||||
10: "完好",
|
||||
20: "限用",
|
||||
30: "在修",
|
||||
40: "禁用",
|
||||
},
|
||||
tabOptions: [
|
||||
{ label: "成品", name: 10 },
|
||||
{ label: "半成品", name: 20 },
|
||||
{ label: "主要原料", name: 30 },
|
||||
{ label: "辅助材料", name: 40 },
|
||||
],
|
||||
typeOptions: {
|
||||
10: "成品",
|
||||
20: "半成品",
|
||||
30: "主要原料",
|
||||
40: "辅助材料",
|
||||
},
|
||||
materialId: "",
|
||||
materialName: "",
|
||||
showHidden: false,
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
console.log("materialType", this.materialType);
|
||||
this.apiObj = this.$API.mtm.material.list;
|
||||
this.$refs.table.queryData(this.query);
|
||||
},
|
||||
methods: {
|
||||
rowClick(row) {
|
||||
console.log("rowClick", row);
|
||||
this.materialId = row.id;
|
||||
this.materialName = row.full_name;
|
||||
this.$emit("choseChange", row.id);
|
||||
},
|
||||
handleClick(pane, ev) {
|
||||
this.query.type = pane.props.name;
|
||||
this.query.page = 1;
|
||||
this.$refs.table.queryData(this.query);
|
||||
},
|
||||
//添加
|
||||
add() {
|
||||
this.dialog.save = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.saveDialog.open("add");
|
||||
});
|
||||
},
|
||||
table_copy(row) {
|
||||
this.dialog.save = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.saveDialog.open("add").setData(row);
|
||||
});
|
||||
},
|
||||
//编辑
|
||||
table_edit(row) {
|
||||
this.dialog.save = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.saveDialog.open("edit").setData(row);
|
||||
});
|
||||
},
|
||||
//查看
|
||||
table_show(row) {
|
||||
this.dialog.save = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.saveDialog.open("show").setData(row);
|
||||
});
|
||||
},
|
||||
//删除
|
||||
async table_del(row) {
|
||||
this.$confirm(`确定删除吗?`, "提示", {
|
||||
type: "warning",
|
||||
})
|
||||
.then(() => {
|
||||
this.$API.mtm.material.delete
|
||||
.req(row.id)
|
||||
.then((res) => {
|
||||
this.$message.success("删除成功");
|
||||
this.$refs.table.refresh();
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
return err;
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
},
|
||||
|
||||
//本地更新数据
|
||||
handleSaveSuccess(data, mode) {
|
||||
if (mode == "add") {
|
||||
this.$refs.table.refresh();
|
||||
} else if (mode == "edit") {
|
||||
this.$refs.table.refresh();
|
||||
}
|
||||
},
|
||||
handleQuery() {
|
||||
this.$refs.table.queryData(this.query);
|
||||
},
|
||||
resetQuery() {
|
||||
this.query = {};
|
||||
},
|
||||
upSuccess(res, close) {
|
||||
close();
|
||||
const loading = ElLoading.service({
|
||||
fullscreen: true,
|
||||
text: "解析中...请稍等",
|
||||
});
|
||||
this.$API.mtm.material.daoru
|
||||
.req({ path: res.path })
|
||||
.then((res) => {
|
||||
loading.close();
|
||||
this.$message.success("导入成功");
|
||||
this.$refs.table.queryData(this.query);
|
||||
})
|
||||
.catch((err) => {
|
||||
loading.close();
|
||||
});
|
||||
},
|
||||
hiddenChange(val) {
|
||||
if (val) {
|
||||
this.query.is_hidden = "";
|
||||
} else {
|
||||
this.query.is_hidden = false;
|
||||
}
|
||||
this.$refs.table.queryData(this.query);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
Loading…
Reference in New Issue