feat: 出入库页面基本完成

This commit is contained in:
caoqianming 2023-10-25 17:33:39 +08:00
parent e5f3d24205
commit c456086901
8 changed files with 708 additions and 105 deletions

View File

@ -72,11 +72,19 @@ export default {
);
}
},
do: {
name: "创建",
item: {
name: "获取记录详情",
req: async function(id){
return await http.get(
`${config.API_URL}/inm/mio/${id}/`
);
}
},
create: {
name: "通用创建",
req: async function(data){
return await http.post(
`${config.API_URL}/inm/mio/do/`,
`${config.API_URL}/inm/mio/`,
data);
}
},

View File

@ -851,6 +851,17 @@ const routes = [
"perms": ["inm"]
},
"component": "inm/mio"
},
{
"name": "mioitem",
"path": "/inm/mioitem",
"meta": {
"title": "出入库记录明细",
"icon": "el-icon-cellphone",
"perms": ["inm"],
"hidden": true,
},
"component": "inm/mioitem"
}
]

View File

@ -2,18 +2,23 @@
<el-container>
<el-header>
<div class="left-panel">
<el-input v-model="query.search" placeholder="名称" clearable style="margin-right: 5px;"></el-input>
</div>
<div class="right-panel">
<el-input v-model="query.search" placeholder="物料名" clearable style="margin-right: 5px;"></el-input>
<el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button>
</div>
</el-header>
<el-main class="nopadding">
<scTable ref="table" :apiObj="apiObj" row-key="id" stripe :params="query">
<scTable ref="table" :apiObj="apiObj" row-key="id" stripe :params="params">
<el-table-column type="index" width="50" />
<el-table-column label="物料批次" prop="batch">
</el-table-column>
<el-table-column label="物料名称" prop="material_name">
</el-table-column>
<el-table-column label="规格型号" prop="material.model">
<el-table-column label="规格型号">
<template #default="scope">
{{ scope.row.specification }}
</template>
</el-table-column>
<el-table-column label="仓库" prop="warehouse_name">
</el-table-column>
@ -29,11 +34,9 @@ export default {
data() {
return {
apiObj: this.$API.inm.warehouse.batch,
query: {
page: 1,
page_size: 20
},
params: { count__gte: 1 },
selection: [],
query: {}
};
},
methods: {

View File

@ -2,12 +2,25 @@
<el-container>
<el-header>
<div class="left-panel">
<el-button type="primary" icon="el-icon-plus">
新增出/入库
</el-button>
<el-button type="primary" @click="add('do_in')">生产入库</el-button>
<el-button type="primary" @click="add('do_out')">生产领料</el-button>
<el-divider direction="vertical"></el-divider>
<el-button type="primary" @click="add('pur_in')">采购入库</el-button>
<el-button type="primary" @click="add('sale_out')">销售发货</el-button>
<el-divider direction="vertical"></el-divider>
<el-button type="primary" @click="add('other_in')">其他入库</el-button>
<el-button type="primary" @click="add('other_out')">其他出库</el-button>
<el-select v-model="query.type" clearable style="width: 120px; margin-left: 2px" placeholder="出入库类型"
@change="handleQuery">
<el-option v-for="item in cateOptions" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
<el-select v-model="query.state" clearable style="width: 120px; margin-left: 2px" placeholder="状态"
@change="handleQuery">
<el-option v-for="item in stateOptions" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
</div>
<div class="right-panel">
<el-input v-model="query.search" placeholder="名称" clearable style="margin-right: 5px;"></el-input>
<el-input v-model="query.search" placeholder="编号" clearable style="margin-right: 5px;"></el-input>
<el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button>
</div>
</el-header>
@ -15,16 +28,16 @@
<scTable ref="table" :apiObj="apiObj" row-key="id" stripe>
<el-table-column type="index" width="50" />
<el-table-column label="记录编号" prop="number"></el-table-column>
<el-table-column label="记录状态">
<template #default="scope">
{{ stateDict[scope.row.state] }}
</template>
</el-table-column>
<el-table-column label="出/入库类型">
<template #default="scope">
{{ typeDict[scope.row.type] }}
</template>
</el-table-column>
<el-table-column label="记录状态">
<template #default="scope">
{{ stateDict[scope.row.state] }}
</template>
</el-table-column>
<el-table-column label="出/入库日期" prop="inout_date">
</el-table-column>
@ -34,17 +47,17 @@
</el-table-column>
<el-table-column label="操作" fixed="right" align="center" width="150px">
<template #default="scope">
<el-link type="primary" @click="table_edit(scope.row)">
<el-button link type="primary" @click="table_detail(scope.row)">
查看
</el-link>
<el-divider direction="vertical"></el-divider>
<el-link type="primary" @click="table_submit(scope.row)" v-auth="'mio.submit'">
</el-button>
<el-button link type="primary" @click="table_submit(scope.row)" v-auth="'mio.submit'"
v-if="scope.row.state == 10">
提交
</el-link>
<el-divider direction="vertical"></el-divider>
<el-link type="danger" @click="table_del(scope.row)" v-auth="'mio.delete'">
</el-button>
<el-button link type="danger" @click="table_del(scope.row)" v-auth="'mio.delete'"
v-if="scope.row.state == 10">
删除
</el-link>
</el-button>
</template>
</el-table-column>
</scTable>
@ -52,63 +65,25 @@
</el-container>
<save-dialog v-if="dialog.save" ref="saveDialog" @success="handleSaveSuccess"
@closed="dialog.save = false"></save-dialog>
<!-- 生产领料/生产入库 -->
<el-Dialog :title="typeDict[mode]" v-model="visible">
<el-form ref="dialogForm" :model="form" :rules="rules" label-width="80px">
<el-row>
<el-col :md="12" :sm="24">
<el-form-item label="编号" prop="type">
<el-radio-group v-model="form.type">
<el-radio :label="10">准入</el-radio>
<el-radio :label="20">禁入</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="类型" prop="obj_cate">
<el-select v-model="form.obj_cate" style="width: 100%">
<el-option v-for="item in cateOptions" :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="do_user">
<span style="display:flex">
<el-input readonly v-model="form.employee_name"></el-input>
<ehsEpSelect :multiple="false" @submit="getEmployee" />
</span>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="所属车间" prop="dept">
<el-cascader v-model="form.dept" :options="deptOptions" :props="groupsProps" clearable style="width: 100%">
</el-cascader>
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<el-button type="primary" :loading="isSaveing" @click="submit">
保存
</el-button>
<el-button @click="visible = false">取消</el-button>
</template>
</el-Dialog>
</template>
<script>
import saveDialog from "./warehouse_form.vue";
import saveDialog from "./mio_form.vue";
export default {
name: "rparty",
name: "mio",
components: {
saveDialog,
saveDialog
},
data() {
return {
mode: 'do_out',
stateDict: {
10: '创建中',
20: '已提交'
},
stateOptions: [
{ id: 10, name: '创建中' },
{ id: 20, name: '已提交' },
],
typeDict: {
'do_out': '生产领料',
'sale_out': '销售发货',
@ -134,44 +109,31 @@ export default {
form: {
},
visible: false,
apiObj: this.$API.inm.mio.list,
selection: [],
types_: {
1: "生产领料",
2: "销售提货",
3: "采购入库",
4: "生产入库",
5: "其他入库",
6: "其他出库",
},
rules: {
// do_user: [{required: true, message: "", trigger: "blur"}],
number: [{ required: true, message: "请输入编号", trigger: "blur" }],
// belong_dept: [{required: true, message: "", trigger: "blur"}],
},
};
},
methods: {
//
add() {
add(type) {
this.dialog.save = true;
this.$nextTick(() => {
this.$refs.saveDialog.open("add");
this.$refs.saveDialog.open("add", type);
});
},
//
table_edit(row) {
this.dialog.save = true;
this.$nextTick(() => {
this.$refs.saveDialog.open("edit").setData(row);
this.$refs.saveDialog.open("edit", type).setData(row);
});
},
//
table_show(row) {
this.dialog.save = true;
this.$nextTick(() => {
this.$refs.saveDialog.open("show").setData(row);
table_detail(row) {
this.$router.push({
name: "mioitem",
query: { mio: row.id }
});
},
//
@ -194,20 +156,15 @@ export default {
this.$refs.table.refresh()
})
},
//
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 = {};
},
handleSaveSuccess() {
this.$refs.table.refresh()
}
},
};
</script>

192
src/views/inm/mio_form.vue Normal file
View File

@ -0,0 +1,192 @@
<template>
<el-dialog :title="titleMap[form.type]" v-model="visible" :size="1000" destroy-on-close @closed="$emit('closed')">
<el-form ref="dialogForm" :model="form" :rules="rules" label-width="120px">
<el-form-item label="编号" prop="number">
<el-input v-model="form.number" placeholder="编号" />
</el-form-item>
<el-form-item label="出入库日期">
<el-date-picker v-model="form.inout_date" type="date" placeholder="出入库日期" value-format="YYYY-MM-DD"
style="width:100%">
</el-date-picker>
</el-form-item>
<el-form-item label="采购订单" v-if="form.type == 'pur_in'">
<el-select v-model="form.pu_order" clearable style="width: 100%;">
<el-option v-for="item in puOrderOptions" :key="item.id" :label="item.number"
:value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="供应商" v-if="form.type == 'other_in'">
<el-select v-model="form.supplier" clearable style="width: 100%;">
<el-option v-for="item in supplierOptions" :key="item.id" :label="item.name"
:value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="销售订单" v-if="form.type == 'sale_out'">
<el-select v-model="form.order" clearable style="width: 100%;">
<el-option v-for="item in orderOptions" :key="item.id" :label="item.number"
:value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="客户" v-if="form.type == 'other_out'">
<el-select v-model="form.customer" clearable style="width: 100%;">
<el-option v-for="item in customerOptions" :key="item.id" :label="item.name"
:value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="执行车间" v-if="form.type == 'do_in' || form.type == 'do_out'">
<el-select v-model="form.belong_dept" clearable style="width: 100%;" @change="deptChange">
<el-option v-for="item in deptOptions" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="执行人" v-if="form.type == 'do_in' || form.type == 'do_out'">
<el-select v-model="form.do_user" clearable style="width: 100%;">
<el-option v-for="item in userOptions" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
</el-form-item>
</el-form>
<template #footer>
<el-button type="primary" :loading="isSaveing" @click="submit">
保存
</el-button>
<el-button @click="dialogVisible = false">取消</el-button>
</template>
</el-dialog>
</template>
<script>
const defaultForm = {
"state": 10,
"type": "do_in"
}
export default {
emits: ["success", "closed"],
props: {
},
data() {
return {
type: 'do_in',
loading: false,
mode: "add",
titleMap: {
'do_out': '生产领料',
'sale_out': '销售发货',
'pur_in': '采购入库',
'do_in': '生产入库',
'other_in': '其他入库',
'other_out': '其他出库',
},
form: {},
rules: {
material: [{ required: true, message: "请选择所需产品", trigger: "blur" }],
},
visible: false,
isSaveing: false,
options: [],
setFiltersVisible: false,
deptOptions: [],
userOptions: [],
orderOptions: [],
puOrderOptions: [],
supplierOptions: [],
customerOptions: []
};
},
mounted() {
},
methods: {
init() {
var type = this.form.type
if (type == 'pur_in') {
this.getPuOrderOptions()
}
else if (type == 'sale_out') {
this.getOrderOptions()
}
else if (type == 'do_in' || type == 'do_out') {
this.getDeptOptions()
}
else if (type == 'other_in') {
this.getSupplierOptions()
}
else if (type == 'other_out') {
this.getCustomerOptions()
}
},
getSupplierOptions() {
this.$API.pum.supplier.list.req({ page: 0 }).then(res => {
this.supplierOptions = res
})
},
getCustomerOptions() {
this.$API.sam.customer.list.req({ page: 0 }).then(res => {
this.customerOptions = res
})
},
getDeptOptions() {
this.$API.system.dept.list.req({ page: 0, type__in: 'dept' }).then((res) => {
this.deptOptions = res
});
},
getPuOrderOptions() {
this.$API.pum.order.list.req({ page: 0, type__in: '20,30' }).then(res => {
this.puOrderOptions = res
})
},
getOrderOptions() {
this.$API.sam.order.list.req({ page: 0, type__in: '20,30' }).then(res => {
this.orderOptions = res
})
},
deptChange(val) {
this.$API.system.user.list.req({ depts: val, page: 0 }).then(res => {
this.userOptions = res
})
},
//
open(mode = "add", type = "") {
this.mode = mode;
this.form.type = type;
if (mode == 'add') {
this.init()
}
this.visible = true;
return this;
},
//
submit() {
this.$refs.dialogForm.validate(async (valid) => {
if (valid) {
this.isSaveing = true;
try {
var res;
if (this.mode == "add") {
res = await this.$API.inm.mio.create.req(this.form);
} else if (this.mode == "edit") {
res = await this.$API.inm.mio.update.req(this.form.id, this.form);
}
this.isSaveing = false;
this.$emit("success", this.form, this.mode);
this.visible = false;
this.$message.success("操作成功");
} catch (err) {
console.log(err)
//
this.isSaveing = false;
return err;
}
}
});
},
//
setData(data) {
Object.assign(this.form, data);
},
//
setFilters(filters) {
this.selectionFilters = filters;
this.setFiltersVisible = true;
},
},
};
</script>
<style></style>

158
src/views/inm/mioitem.vue Normal file
View File

@ -0,0 +1,158 @@
<template>
<div style="padding: 8px">
<div>
<el-card style="width: 100%" header="基本信息" shadow="hover">
<el-descriptions>
<el-descriptions-item label="编号">{{ mioObj.number }}</el-descriptions-item>
<el-descriptions-item label="出入库类型">{{ typeDict[mioObj.type] }}</el-descriptions-item>
<el-descriptions-item label="状态">{{ stateDict[mioObj.state] }}</el-descriptions-item>
<el-descriptions-item label="部门/车间">{{ mioObj.belong_dept_name }}</el-descriptions-item>
<el-descriptions-item label="执行人">{{ mioObj.do_user_name }}</el-descriptions-item>
<el-descriptions-item label="创建时间">{{ mioObj.create_time }}</el-descriptions-item>
<el-descriptions-item label="采购订单">{{ mioObj.order_number }}</el-descriptions-item>
<el-descriptions-item label="销售订单">{{ mioObj.pu_order_number }}</el-descriptions-item>
<el-descriptions-item label="供应商/客户">{{ mioObj.supplier_name }}{{
mioObj.customer_name }}</el-descriptions-item>
</el-descriptions>
<el-button type="primary" @click="mioSubmit" v-auth="'mio.submit'" v-if="mioObj.state == 10">
提交
</el-button>
</el-card>
</div>
<div style="height:8px"></div>
<div>
<el-card style="width: 100%" header="物料明细" shadow="hover">
<div>
<el-button type="primary" icon="el-icon-plus" @click="table_add" v-if="mioObj.state == 10"></el-button>
</div>
<scTable ref="table" :apiObj="apiObj" row-key="id" stripe :params="params" hidePagination hideDo>
<el-table-column type="index" width="50" />
<el-table-column label="物料" prop="material" show-overflow-tooltip>
<template #default="scope">
<span v-if="scope.row.material_"> {{ scope.row.material_.name }}</span>
</template>
</el-table-column>
<el-table-column label="批次号" prop="batch">
</el-table-column>
<el-table-column label="仓库" prop="warehouse_name">
</el-table-column>
<el-table-column label="数量" prop="count">
</el-table-column>
<el-table-column label="创建时间" prop="create_time" show-overflow-tooltip>
</el-table-column>
<el-table-column label="操作" fixed="right" align="center" width="100px">
<template #default="scope">
<el-link type="danger" @click="table_del(scope.row)" v-if="mioObj.state == 10">
删除
</el-link>
</template>
</el-table-column>
</scTable>
</el-card>
</div>
</div>
<save-dialog v-if="dialog.save" ref="saveDialog" :mioId="mioId" :belongDeptId="belongDeptId" :mioObj="mioObj"
@success="handleSaveSuccess" @closed="dialog.save = false"></save-dialog>
</template>
<script>
import saveDialog from "./mioitem_form.vue";
export default {
name: "mioitem",
components: {
saveDialog,
},
data() {
return {
dialog: {
save: false,
},
apiObj: null,
params: {},
mioId: '',
mioObj: {},
selection: [],
stateDict: {
10: '创建中',
20: '已提交'
},
typeDict: {
'do_out': '生产领料',
'sale_out': '销售发货',
'pur_in': '采购入库',
'do_in': '生产入库',
'other_in': '其他入库',
'other_out': '其他出库',
},
};
},
mounted() {
this.mioId = this.$route.query.mio;
this.params.mio = this.$route.query.mio;
this.apiObj = this.$API.inm.mioitem.list;
this.getMio();
},
methods: {
getMio() {
this.$API.inm.mio.item.req(this.mioId).then((res) => {
this.mioObj = res;
this.belongDeptId = res.belong_dept
})
},
//
table_add() {
this.dialog.save = true;
this.$nextTick(() => {
this.$refs.saveDialog.open("add", this.mioObj.type);
});
},
//
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);
});
},
//
table_del(row) {
this.$confirm(`确定删除吗?`, "提示", {
type: "warning",
}).then(() => {
this.$API.inm.mioitem.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 = {};
},
mioSubmit() {
this.$API.inm.mio.submit.req(this.mioObj.id).then(res => {
this.$message.success("提交成功");
this.mioObj = res
})
}
},
};
</script>

View File

@ -0,0 +1,274 @@
<template>
<el-dialog :title="titleMap[form.type]" v-model="visible" :size="1000" destroy-on-close @closed="$emit('closed')">
<el-form ref="dialogForm" :model="form" :rules="rules" label-width="120px">
<el-form-item label="物料">
<el-select v-model="selectMaterial" value-key="id" clearable style="width: 100%;"
@change="selectMaterialChange">
<el-option v-for="item in materialOptions" :key="item.id" :label="item.number" :value="item">
<span style="float: left">{{ item.number }}</span>
<span style="
float: right;
color: var(--el-text-color-secondary);
font-size: 13px;
">{{ item.name }}</span>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="仓库批次号">
<el-select v-model="selectBatch" value-key="id" clearable style="width: 100%;" @change="selectBatchChange"
@clear="selectBatchClear" :disabled="selectBatchDisable">
<el-option v-for="item in batchOptions" :key="item.id" :label="item.batch" :value="item">
<span style="float: left">{{ item.batch }}</span>
<span style="
float: right;
color: var(--el-text-color-secondary);
font-size: 13px;
">{{ item.count }} -- {{ item.warehouse_name }}</span>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="新批次号">
<el-input v-model="form.batch" placeholder="手动输入新批次" :disabled="inputBatchDisable" />
</el-form-item>
<el-form-item label="仓库">
<el-select v-model="form.warehouse" clearable style="width: 100%;" :disabled="warehouseDisable">
<el-option v-for="item in warehouseOptions" :key="item.id" :label="item.name"
:value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="数量">
<el-input-number v-model="form.count" :min="1" style="width: 100%;" />
</el-form-item>
<div v-if="assembShow">
<el-row v-for="item in components" v-bind:key="item" style="margin-bottom:8px">
<el-col :span="12">
{{ item.number }} - {{ item.name }}
</el-col>
<el-col :span="12">
<el-select v-model="item.batch" clearable style="width: 100%;">
<el-option v-for="itemx in item.batchOptions" :key="itemx.id" :label="itemx.batch"
:value="itemx.batch">
<span style="float: left">{{ itemx.batch }}</span>
<span style="
float: right;
color: var(--el-text-color-secondary);
font-size: 13px;
">{{ itemx.count }}</span>
</el-option>
</el-select>
</el-col>
</el-row>
</div>
</el-form>
<template #footer>
<el-button type="primary" :loading="isSaveing" @click="submit">
保存
</el-button>
<el-button @click="dialogVisible = false">取消</el-button>
</template>
</el-dialog>
</template>
<script>
const defaultForm = {
"state": 10,
"type": "do_in"
}
export default {
emits: ["success", "closed"],
props: {
mioId: { type: String, default: '' },
belongDeptId: { type: String, default: null },
mioObj: { type: Object }
},
data() {
return {
type: 'do_in',
loading: false,
mode: "add",
titleMap: {
'do_out': '生产领料',
'sale_out': '销售发货',
'pur_in': '采购入库',
'do_in': '生产入库',
'other_in': '其他入库',
'other_out': '其他出库',
},
form: {},
rules: {
material: [{ required: true, message: "请选择所需产品", trigger: "blur" }],
},
visible: false,
isSaveing: false,
materialOptions: [],
batchOptions: [],
setFiltersVisible: false,
warehouseOptions: [],
warehouseDisable: false,
selectBatchDisable: false,
assembShow: false,
selectMaterial: null,
selectBatch: null,
components: [],
};
},
mounted() {
},
methods: {
init() {
this.getMaterialOptions()
this.getWarehouseOptions()
},
getWarehouseOptions() {
this.$API.inm.warehouse.list.req({ page: 0 }).then(res => {
this.warehouseOptions = res
})
},
getMaterialOptions() {
var type = this.form.type
var query
if (type == 'do_out') {
query = { page: 0, type__in: '10, 20, 30', is_hidden: false, is_assemb: false }
this.inputBatchDisable = true
}
else if (type == 'do_in') {
query = { page: 0, type__in: '10, 20', is_hidden: false }
this.inputBatchDisable = false
}
else if (type == 'pur_in') {
query = { page: 0, type__in: 30, is_hidden: false, pu_orderitem_material__pu_order: this.mioObj.pu_order }
this.inputBatchDisable = false
}
else if (type == 'sale_out') {
query = { page: 0, type__in: 10, is_hidden: false, orderitem_material__order: this.mioObj.order }
this.inputBatchDisable = true
}
else {
query = { page: 0 }
}
this.$API.mtm.material.list.req(query).then(res => {
this.materialOptions = res
})
},
async initAssemb(item) {
this.selectBatchDisable = true
this.assembShow = true
this.components = []
var id__in = Object.keys(item.components).join(',')
if (id__in.length > 0) {
var res = await this.$API.mtm.material.list.req({ page: 0, id__in: id__in })
this.components = res
for (var i = 0; i < this.components.length; i++) {
var res2 = await this.$API.wpm.wmaterial.list.req({ page: 0, material: this.components[i].id, belong_dept: this.belongDeptId, count__gte: 1 })
this.components[i].batchOptions = res2
}
}
},
getBatchOptions() {
this.$API.inm.warehouse.batch.req({ page: 0, material: this.form.material, count__gte: 1 }).then(res => {
this.batchOptions = res
if (res.length == 0) {
this.selectBatchDisable = true
} else {
this.selectBatchDisable = false
}
})
},
selectMaterialChange(item) {
var that = this
var type = this.form.type
var material = item.id
that.form.material = material
if (type == 'do_in') {
if (item.is_assemb) {
this.initAssemb(item)
} else {
this.selectBatchDisable = false
this.components = []
this.assembShow = false
this.getBatchOptions()
}
}
else {
this.getBatchOptions()
}
},
getItem(options, id) {
for (var i = 0; i < options.length; i++) {
if (options[i].id == id) {
return options[i]
}
}
},
selectBatchChange(item) {
// var item = this.getItem(this.batchOptions, id)
this.form.batch = item.batch
this.form.warehouse = item.warehouse
this.warehouseDisable = true
this.inputBatchDisable = true
},
selectBatchClear() {
this.form.batch = ''
this.form.warehouse = ''
this.warehouseDisable = false
this.inputBatchDisable = false
},
//
open(mode = "add", type = "") {
this.mode = mode;
this.form.type = type;
if (mode == 'add') {
this.init()
}
this.visible = true;
return this;
},
//
submit() {
this.$refs.dialogForm.validate(async (valid) => {
if (valid) {
this.isSaveing = true;
this.form.mio = this.mioId;
if (this.components.length > 0) {
this.form.assemb = []
for (var i = 0; i < this.components.length; i++) {
this.form.assemb.push({ 'material': this.components[i].id, 'batch': this.components[i].batch })
}
}
try {
var res;
if (this.mode == "add") {
res = await this.$API.inm.mioitem.create.req(this.form);
} else if (this.mode == "edit") {
res = await this.$API.inm.mioitem.update.req(this.form.id, this.form);
}
this.isSaveing = false;
this.$emit("success", this.form, this.mode);
this.visible = false;
this.$message.success("操作成功");
} catch (err) {
console.log(err)
//
this.isSaveing = false;
return err;
}
}
});
},
//
setData(data) {
Object.assign(this.form, data);
},
//
setFilters(filters) {
this.selectionFilters = filters;
this.setFiltersVisible = true;
},
},
};
</script>
<style></style>

View File

@ -2,11 +2,11 @@
<el-container>
<el-header>
<div class="left-panel">
<el-input v-model="query.search" placeholder="名称" clearable style="margin-right: 5px;"></el-input>
<el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button>
<el-button type="primary" icon="el-icon-plus" @click="add"></el-button>
</div>
<div class="right-panel">
<el-button type="primary" icon="el-icon-plus" @click="add"></el-button>
<!-- <el-input v-model="query.search" placeholder="名称" clearable style="margin-right: 5px;"></el-input>
<el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button> -->
</div>
</el-header>
<el-main class="nopadding">