<template>
|
<div class="qualityInspection viewWrap">
|
<h2>品质检查项目</h2>
|
<ProductList ref="productList"></ProductList>
|
<!-- 搜索功能区 -->
|
<div class="wrap">
|
<div class="searchWrap">
|
<div class="searchItem">
|
<span class="searchTitle">产品</span>
|
<el-select
|
v-model="proId"
|
placeholder="请选择"
|
style="width:220px;"
|
clearable
|
@focus="onShowProductList1"
|
ref="productList1"
|
>
|
<el-option
|
v-for="(item, index) in selectData"
|
:key="index"
|
:label="`${item.name} / ${item.type}`"
|
:value="item.id"
|
>
|
</el-option>
|
</el-select>
|
</div>
|
<div class="searchButton">
|
<el-button type="primary" @click="onGetSearchData">查询</el-button>
|
<el-button @click="onClearSearchData">清空</el-button>
|
</div>
|
</div>
|
</div>
|
|
<!-- 数据功能按钮区 -->
|
<el-button
|
type="primary"
|
icon="el-icon-plus"
|
style="width: 100px; margin-top: 20px;"
|
@click="handleFormDataAdd"
|
>添加</el-button
|
>
|
|
<!-- 数据表格区 -->
|
<el-table
|
stripe
|
:data="tableData"
|
height="0"
|
style="margin-top: 20px;"
|
>
|
<el-table-column type="index" label="序号"> </el-table-column>
|
<el-table-column prop="proName" label="产品"> </el-table-column>
|
<el-table-column prop="proType" label="型号"> </el-table-column>
|
<el-table-column prop="item" label="品质检查项目"> </el-table-column>
|
<el-table-column prop="sort" label="排序"> </el-table-column>
|
<el-table-column prop="disabled" label="状态" width="180">
|
<template slot-scope="scope">
|
<el-switch
|
v-model="scope.row.disabled"
|
active-color="#ff0000"
|
active-text="禁用"
|
inactive-color="#409EFF"
|
inactive-text="启用"
|
@change="handleDisabled(scope.row)"
|
>
|
</el-switch>
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" width="100">
|
<template slot-scope="scope">
|
<el-button
|
icon="el-icon-edit"
|
@click.native.prevent="handleFormDataEdit(scope.row)"
|
type="text"
|
size="small"
|
>
|
编辑
|
</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<!-- 分页组件 -->
|
<el-pagination
|
style="margin-top: 20px;"
|
@size-change="onGetTableData"
|
@current-change="onGetTableData"
|
:current-page.sync="pageCurr"
|
:page-size.sync="pageSize"
|
:page-sizes="[10, 20, 50, 100]"
|
layout="total, sizes, prev, pager, next, jumper"
|
:total="total"
|
>
|
</el-pagination>
|
|
<!-- 表单 -->
|
<el-dialog
|
title="品质检查项目"
|
:visible.sync="showFromData"
|
width="600px"
|
:before-close="handleFormDataClose"
|
>
|
<el-form
|
:model="formData"
|
:rules="formRules"
|
ref="formData"
|
label-width="140px"
|
>
|
<el-form-item label="ID" prop="id" style="display: none;">
|
<el-input
|
style="width:320px;"
|
v-model="formData.id"
|
disabled
|
></el-input>
|
</el-form-item>
|
<el-form-item label="产品" prop="proId">
|
<el-select
|
v-model="formData.proId"
|
placeholder="请选择"
|
style="width:320px;"
|
clearable
|
@focus="onShowProductList2"
|
ref="productList2"
|
>
|
<el-option
|
v-for="(item, index) in selectData"
|
:key="index"
|
:label="`${item.name} / ${item.type}`"
|
:value="item.id"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="品检项目" prop="item">
|
<el-input
|
style="width:320px;"
|
v-model="formData.item"
|
clearable
|
></el-input>
|
</el-form-item>
|
<el-form-item label="排序" prop="sort">
|
<el-input-number v-model="formData.sort" style="width:320px;"></el-input-number>
|
</el-form-item>
|
</el-form>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="handleFormDataClose">取 消</el-button>
|
<el-button type="primary" @click="handleFormDataSubmit"
|
>确 定</el-button
|
>
|
</span>
|
</el-dialog>
|
</div>
|
</template>
|
|
<style lang="less" scoped>
|
.qualityInspection {
|
padding: 20px;
|
}
|
</style>
|
|
<script>
|
import ProductList from '@/components/ProductList'
|
|
export default {
|
name: "qualityInspection",
|
components: {
|
ProductList,
|
},
|
data() {
|
return {
|
proId: null,
|
pageSize: 10,
|
pageCurr: 1,
|
total: 0,
|
tableData: [],
|
showFromData: false,
|
formData: {
|
id: null,
|
item: null,
|
proId: null,
|
sort: null,
|
},
|
formRules: {
|
reason: [{ required: true, message: "必填项", trigger: "blur" }],
|
proId: [{ required: true, message: "必填项", trigger: "blur" }],
|
},
|
selectData: [],
|
};
|
},
|
computed: {},
|
mounted() {
|
this.onGetTableData();
|
this.onGetSelectData()
|
},
|
methods: {
|
// 执行条件查询
|
onGetSearchData: function() {
|
this.pageCurr = 1;
|
this.onGetTableData();
|
},
|
// 清空查询条件
|
onClearSearchData: function() {
|
this.proId = null;
|
this.pageCurr = 1;
|
this.onGetTableData();
|
},
|
// 获取表格数据
|
onGetTableData: function() {
|
var that = this;
|
var data = {
|
proId: this.proId,
|
pageSize: this.pageSize,
|
pageCurr: this.pageCurr,
|
};
|
that
|
.$axiosAdmin({
|
method: "post",
|
url: "platform/items/some",
|
data: JSON.stringify(data),
|
})
|
.then((res) => {
|
if (res.success == true) {
|
that.tableData = res.content.obj;
|
that.total = res.content.itemTotal;
|
} else {
|
that.$alert(res.content, "提示", {
|
confirmButtonText: "确定",
|
});
|
}
|
})
|
.catch((err) => {
|
console.log(err);
|
});
|
},
|
// 删除确认
|
handleDelete(row) {
|
this.$confirm(`此操作将删除该不合格原因 , 是否继续?`, "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
})
|
.then(() => {
|
this.onDelete(row);
|
})
|
.catch(() => {
|
this.$message({
|
type: "info",
|
message: "已取消",
|
});
|
});
|
},
|
// 执行删除
|
onDelete: function(row) {
|
var that = this;
|
var params = {
|
id: row.id,
|
};
|
that
|
.$axiosAdmin({
|
method: "get",
|
url: "platform/items/delete",
|
params: params,
|
})
|
.then((res) => {
|
if (res.success == true) {
|
that.$message({
|
type: "success",
|
message: "已成功",
|
});
|
} else {
|
that.$alert(res.content, "提示", {
|
confirmButtonText: "确定",
|
});
|
}
|
that.onGetTableData();
|
})
|
.catch((err) => {
|
console.log(err);
|
});
|
},
|
// 添加
|
handleFormDataAdd: function() {
|
this.onGetSelectData();
|
this.formData.id = null;
|
this.formData.item = null;
|
this.formData.proId = null;
|
this.formData.sort = null;
|
this.showFromData = true;
|
},
|
// 关闭
|
handleFormDataClose: function() {
|
this.formData.id = null;
|
this.formData.item = null;
|
this.formData.proId = null;
|
this.formData.sort = null;
|
this.showFromData = false;
|
this.$refs["formData"].resetFields();
|
},
|
// 编辑
|
handleFormDataEdit: function(row) {
|
this.onGetSelectData();
|
this.formData.id = row.id;
|
this.formData.item = row.item;
|
this.formData.proId = row.proId;
|
this.formData.sort = row.sort;
|
this.showFromData = true;
|
},
|
// 提交数据确认
|
handleFormDataSubmit: function() {
|
this.$confirm(`此操作将保存并更新数据, 是否继续?`, "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
})
|
.then(() => {
|
this.onFormDataSubmit();
|
})
|
.catch(() => {
|
this.$message({
|
type: "info",
|
message: "已取消",
|
});
|
});
|
},
|
// 提交数据
|
onFormDataSubmit: function() {
|
var that = this;
|
var url, data;
|
if (this.formData.id) {
|
url = "platform/items/update";
|
data = {
|
id: this.formData.id,
|
item: this.formData.item,
|
sort: this.formData.sort,
|
proId: this.formData.proId,
|
sort: this.formData.sort,
|
};
|
} else {
|
url = "platform/items/save";
|
data = {
|
item: this.formData.item,
|
sort: this.formData.sort,
|
proId: this.formData.proId,
|
sort: this.formData.sort,
|
};
|
}
|
that
|
.$axiosAdmin({
|
method: "post",
|
url: url,
|
data: JSON.stringify(data),
|
})
|
.then((res) => {
|
if (res.success == true) {
|
that.$message({
|
type: "success",
|
message: "已成功",
|
});
|
that.handleFormDataClose();
|
that.onGetTableData();
|
} else {
|
that.$alert(res.content, "提示", {
|
confirmButtonText: "确定",
|
});
|
}
|
})
|
.catch((err) => {
|
console.log(err);
|
});
|
},
|
// 状态变更确认
|
handleDisabled(row) {
|
this.$confirm(`此操作将变更本条数据的状态, 是否继续?`, "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
})
|
.then(() => {
|
this.onDisabled(row);
|
})
|
.catch(() => {
|
this.onGetTableData();
|
this.$message({
|
type: "info",
|
message: "已取消",
|
});
|
});
|
},
|
// 执行状态变更
|
onDisabled: function(row) {
|
var that = this;
|
var data = {
|
id: row.id,
|
disabled: row.disabled,
|
};
|
that
|
.$axiosAdmin({
|
method: "post",
|
url: "platform/items/disabled",
|
data: JSON.stringify(data),
|
})
|
.then((res) => {
|
if (res.success == true) {
|
that.$message({
|
type: "success",
|
message: "已成功",
|
});
|
} else {
|
that.$alert(res.content, "提示", {
|
confirmButtonText: "确定",
|
});
|
}
|
that.onGetTableData();
|
})
|
.catch((err) => {
|
console.log(err);
|
that.onGetTableData();
|
});
|
},
|
// 获取产品数据
|
onGetSelectData: function() {
|
var that = this;
|
that
|
.$axiosAdmin({
|
method: "get",
|
url: "platform/product/all",
|
})
|
.then((res) => {
|
if (res.success == true) {
|
this.selectData = res.content;
|
} else {
|
that.$alert(res.content, "提示", {
|
confirmButtonText: "确定",
|
});
|
}
|
})
|
.catch((err) => {
|
console.log(err);
|
});
|
},
|
onShowProductList1: function () {
|
this.$refs.productList1.blur()
|
this.$refs.productList.show((res) => {
|
if (!res) return;
|
this.proId = res.id
|
})
|
},
|
onShowProductList2: function () {
|
this.$refs.productList2.blur()
|
this.$refs.productList.show((res) => {
|
if (!res) return;
|
this.formData.proId = res.id
|
})
|
},
|
},
|
};
|
</script>
|