feat:添加工装列表,并在wprList中可以选择工装后保存
This commit is contained in:
parent
562b6bda4a
commit
37b7ac12d0
|
|
@ -590,4 +590,40 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
//工装
|
||||||
|
tooling: {
|
||||||
|
list: {
|
||||||
|
name: "列表",
|
||||||
|
req: async function (data) {
|
||||||
|
return await http.get(`${config.API_URL}/mtm/tooling/`, data);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
item: {
|
||||||
|
name: "详情",
|
||||||
|
req: async function (id) {
|
||||||
|
return await http.get(`${config.API_URL}/mtm/tooling/${id}/`);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
create: {
|
||||||
|
name: "创建",
|
||||||
|
req: async function (data) {
|
||||||
|
return await http.post(`${config.API_URL}/mtm/tooling/`, data);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
update: {
|
||||||
|
name: "更新",
|
||||||
|
req: async function (id, data) {
|
||||||
|
return await http.put(
|
||||||
|
`${config.API_URL}/mtm/tooling/${id}/`,
|
||||||
|
data
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
delete: {
|
||||||
|
name: "删除",
|
||||||
|
req: async function (id) {
|
||||||
|
return await http.delete(`${config.API_URL}/mtm/tooling/${id}/`);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -683,6 +683,12 @@ export default {
|
||||||
return await http.get(`${config.API_URL}/wpmw/wpr/${id}/`);
|
return await http.get(`${config.API_URL}/wpmw/wpr/${id}/`);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
update:{
|
||||||
|
name: "更新",
|
||||||
|
req: async function (id,data) {
|
||||||
|
return await http.patch(`${config.API_URL}/wpmw/wpr/${id}/`, data);
|
||||||
|
},
|
||||||
|
},
|
||||||
newNumber: {
|
newNumber: {
|
||||||
name: "最新编号",
|
name: "最新编号",
|
||||||
req: async function (data) {
|
req: async function (data) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,116 @@
|
||||||
|
<template>
|
||||||
|
<el-container>
|
||||||
|
<el-header>
|
||||||
|
<div class="left-panel">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-plus"
|
||||||
|
v-auth="'tooling.create'"
|
||||||
|
@click="add"
|
||||||
|
>新增</el-button>
|
||||||
|
</div>
|
||||||
|
<div class="right-panel">
|
||||||
|
<el-input
|
||||||
|
v-model="query.search"
|
||||||
|
placeholder="工装名称/编号"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
></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
|
||||||
|
:query="query"
|
||||||
|
>
|
||||||
|
<el-table-column type="index" width="50" />
|
||||||
|
<el-table-column label="工装名称" prop="name" show-overflow-tooltip></el-table-column>
|
||||||
|
<el-table-column label="工装编号" prop="code" show-overflow-tooltip></el-table-column>
|
||||||
|
<el-table-column label="备注" prop="remark" show-overflow-tooltip></el-table-column>
|
||||||
|
<el-table-column label="操作" fixed="right" align="left" width="100">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
@click="table_edit(scope.row)"
|
||||||
|
v-auth="'tooling.update'"
|
||||||
|
>编辑</el-button>
|
||||||
|
<el-popconfirm
|
||||||
|
title="确定删除吗?"
|
||||||
|
@confirm="table_del(scope.row)"
|
||||||
|
v-auth="'tooling.delete'"
|
||||||
|
>
|
||||||
|
<template #reference>
|
||||||
|
<el-button link type="danger">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-popconfirm>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</scTable>
|
||||||
|
</el-main>
|
||||||
|
<save-dialog
|
||||||
|
v-if="dialog.save"
|
||||||
|
ref="saveDialog"
|
||||||
|
@success="handleSaveSuccess"
|
||||||
|
@closed="dialog.save = false"
|
||||||
|
></save-dialog>
|
||||||
|
</el-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import saveDialog from "./tooling_form.vue";
|
||||||
|
export default {
|
||||||
|
name: "工装管理",
|
||||||
|
components: {
|
||||||
|
saveDialog,
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
apiObj: this.$API.mtm.tooling.list,
|
||||||
|
query: {},
|
||||||
|
dialog: {
|
||||||
|
save: false,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
add() {
|
||||||
|
this.dialog.save = true;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.saveDialog.open("add");
|
||||||
|
});
|
||||||
|
},
|
||||||
|
table_edit(row) {
|
||||||
|
this.dialog.save = true;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.saveDialog.open("edit").setData(row);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
async table_del(row) {
|
||||||
|
this.$API.mtm.tooling.delete
|
||||||
|
.req(row.id)
|
||||||
|
.then(() => {
|
||||||
|
this.$message.success("删除成功");
|
||||||
|
this.$refs.table.refresh();
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
return err;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleSaveSuccess() {
|
||||||
|
this.$refs.table.refresh();
|
||||||
|
},
|
||||||
|
handleQuery() {
|
||||||
|
this.$refs.table.queryData(this.query);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
@ -0,0 +1,116 @@
|
||||||
|
<template>
|
||||||
|
<el-dialog
|
||||||
|
:title="titleMap[mode]"
|
||||||
|
v-model="visible"
|
||||||
|
width="600px"
|
||||||
|
destroy-on-close
|
||||||
|
@closed="$emit('closed')"
|
||||||
|
>
|
||||||
|
<el-container v-loading="isSaveing">
|
||||||
|
<el-main style="padding: 0 20px 20px 20px">
|
||||||
|
<el-form
|
||||||
|
ref="dialogForm"
|
||||||
|
:model="form"
|
||||||
|
:rules="rules"
|
||||||
|
:disabled="mode == 'show'"
|
||||||
|
label-width="100px"
|
||||||
|
>
|
||||||
|
<el-row>
|
||||||
|
<el-col :md="12" :sm="24">
|
||||||
|
<el-form-item label="工装名称" prop="name">
|
||||||
|
<el-input v-model="form.name" clearable></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :md="12" :sm="24">
|
||||||
|
<el-form-item label="工装编号" prop="code">
|
||||||
|
<el-input v-model="form.code" clearable></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :md="24" :sm="24">
|
||||||
|
<el-form-item label="备注" prop="note">
|
||||||
|
<el-input
|
||||||
|
v-model="form.note"
|
||||||
|
clearable
|
||||||
|
></el-input>
|
||||||
|
</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: {
|
||||||
|
name: "",
|
||||||
|
code: "",
|
||||||
|
note: "",
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
name: [{ required: true, message: "请输入工装名称" }],
|
||||||
|
code: [{ required: true, message: "请输入工装编号" }],
|
||||||
|
},
|
||||||
|
visible: false,
|
||||||
|
isSaveing: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
open(mode = "add") {
|
||||||
|
this.mode = mode;
|
||||||
|
this.visible = true;
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
submit() {
|
||||||
|
this.$refs.dialogForm.validate(async (valid) => {
|
||||||
|
if (valid) {
|
||||||
|
this.isSaveing = true;
|
||||||
|
if (this.mode == "add") {
|
||||||
|
this.$API.mtm.tooling.create
|
||||||
|
.req(this.form)
|
||||||
|
.then(() => {
|
||||||
|
this.isSaveing = false;
|
||||||
|
this.$emit("success");
|
||||||
|
this.visible = false;
|
||||||
|
this.$message.success("操作成功");
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.isSaveing = false;
|
||||||
|
});
|
||||||
|
} else if (this.mode == "edit") {
|
||||||
|
this.$API.mtm.tooling.update
|
||||||
|
.req(this.form.id, this.form)
|
||||||
|
.then(() => {
|
||||||
|
this.isSaveing = false;
|
||||||
|
this.$emit("success");
|
||||||
|
this.visible = false;
|
||||||
|
this.$message.success("操作成功");
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.isSaveing = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
setData(data) {
|
||||||
|
Object.assign(this.form, data);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
@ -74,7 +74,7 @@
|
||||||
clearable
|
clearable
|
||||||
size="small"
|
size="small"
|
||||||
style="width:100%"
|
style="width:100%"
|
||||||
@change="handleToolingChange(scope.row, scope.row.tooling)"
|
@change="handleToolingChange(scope.row)"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in toolingOptions"
|
v-for="item in toolingOptions"
|
||||||
|
|
@ -210,13 +210,13 @@ export default {
|
||||||
},
|
},
|
||||||
getToolingOptions(){
|
getToolingOptions(){
|
||||||
let that = this;
|
let that = this;
|
||||||
that.$API.mtm.material.list.req({type: 60, page: 0}).then((res) => {
|
that.$API.mtm.tooling.list.req({ page: 0}).then((res) => {
|
||||||
that.toolingOptions = Array.isArray(res) ? res : (res.results || []);
|
that.toolingOptions = Array.isArray(res) ? res : (res.results || []);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleToolingChange(row, toolingId){
|
handleToolingChange(row){
|
||||||
let that = this;
|
let that = this;
|
||||||
that.$API.wpm.wpr.patch.req(row.id, { tooling: toolingId || null }).then(() => {
|
that.$API.wpm.wpr.update.req(row.id,{tooling:row.tooling}).then(() => {
|
||||||
that.$message.success("工装更新成功");
|
that.$message.success("工装更新成功");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue