zhaoxiaolin 10 months ago
parent 4fea860a8c
commit 0dc3252cdd

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询不良类型维护列表
export function listDefectType(query) {
return request({
url: '/quality/defectType/list',
method: 'get',
params: query
});
}
// 查询不良类型维护详细
export function getDefectType(faultId) {
return request({
url: '/quality/defectType/' + faultId,
method: 'get'
});
}
// 新增不良类型维护
export function addDefectType(data) {
return request({
url: '/quality/defectType',
method: 'post',
data: data
});
}
// 修改不良类型维护
export function updateDefectType(data) {
return request({
url: '/quality/defectType',
method: 'put',
data: data
});
}
// 删除不良类型维护
export function delDefectType(faultId) {
return request({
url: '/quality/defectType/' + faultId,
method: 'delete'
});
}

@ -0,0 +1,385 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="不良类型" prop="defectType">
<el-select v-model="queryParams.defectType" placeholder="请选择不良类型" clearable>
<el-option
v-for="dict in dict.type.quc_defect_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="不良名称" prop="defectSubclass">
<el-input
v-model="queryParams.defectSubclass"
placeholder="请输入不良名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="创建时间" prop="createTime">
<el-date-picker
v-model="queryParams.createTimeArray"
type="daterange"
align="right"
unlink-panels
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd"
:picker-options="pickerOptions">
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['quality:defectType:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['quality:defectType:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['quality:defectType:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['quality:defectType:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="defectTypeList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column width="60" align="center" label="序号" type="index"></el-table-column>
<el-table-column v-if="false" label="主键" align="center" prop="defectId" />
<el-table-column width="150" label="不良类型编码" align="center" prop="defectCode" />
<el-table-column width="150" label="不良类型" align="center" prop="defectType" >
<template slot-scope="scope">
<dict-tag :options="dict.type.quc_defect_type" :value="scope.row.defectType"/>
</template>
</el-table-column>
<el-table-column width="150" label="不良名称" align="center" prop="defectSubclass" />
<el-table-column width="180" label="备注" align="center" prop="defectRemark" />
<el-table-column width="100" label="创建人" align="center" prop="createBy" />
<el-table-column width="180" label="创建时间" align="center" prop="createTime">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column width="100" label="更新人" align="center" prop="updateBy" />
<el-table-column width="180" label="更新时间" align="center" prop="updateTime">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column width="180" label="操作" align="center" class-name="small-padding fixed-width" fixed="right">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['quality:defectType:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['quality:defectType:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改不良类型维护对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item v-if="false" label="不良类型编码" prop="defectCode">
<el-input v-model="form.defectCode" placeholder="请输入不良类型编码" />
</el-form-item>
<el-form-item label="不良类型" prop="defectType">
<el-select v-model="form.defectType" placeholder="请选择不良类型" clearable style="width:100%">
<el-option
v-for="dict in dict.type.quc_defect_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="不良名称" prop="defectSubclass">
<el-input v-model="form.defectSubclass" placeholder="请输入不良名称" />
</el-form-item>
<el-form-item label="备注" prop="defectRemark">
<el-input v-model="form.defectRemark" placeholder="请输入备注" />
</el-form-item>
</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>
<script>
import { listDefectType, getDefectType, delDefectType, addDefectType, updateDefectType } from "@/api/quality/defectType";
export default {
name: "DefectType",
dicts: ['quc_defect_type'],
data() {
return {
//
pickerOptions: {
shortcuts: [{
text: '最近一周',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
picker.$emit('pick', [start, end]);
}
}, {
text: '最近一个月',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
picker.$emit('pick', [start, end]);
}
}, {
text: '最近三个月',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
picker.$emit('pick', [start, end]);
}
}]
},
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
defectTypeList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
defectCode: null,
defectType: null,
defectSubclass: null,
defectRemark: null,
factoryCode: null,
attr1: null,
attr2: null,
attr3: null,
delFlag: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
createTimeArray: [],
updateTimeArray: [],
},
//
form: {},
//
rules: {
}
};
},
created() {
this.getList();
},
methods: {
/** 查询不良类型维护列表 */
getList() {
this.loading = true;
listDefectType(this.queryParams).then(response => {
this.defectTypeList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
defectId: null,
defectCode: null,
defectType: null,
defectSubclass: null,
defectRemark: null,
factoryCode: null,
attr1: null,
attr2: null,
attr3: null,
delFlag: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
//
this.queryParams.createTimeArray = [];
this.queryParams.updateTimeArray = [];
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.defectId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加不良类型维护";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const defectId = row.defectId || this.ids
getDefectType(defectId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改不良类型维护";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.defectId != null) {
updateDefectType(this.form).then(response => {
if (response.code != 500) {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}
});
} else {
addDefectType(this.form).then(response => {
if (response.code != 500) {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const defectIds = row.defectId || this.ids;
var defectCodes = '';
//
for (let i = 0; i < this.defectTypeList.length; i++) {
for (let j = 0; j < defectIds.length; j++) {
if (defectIds[j] == this.defectTypeList[i].defectId) {
defectCodes = defectCodes + this.defectTypeList[i].defectCode + ',';
}
}
}
if (defectCodes == '') {
for (let i = 0; i < this.defectTypeList.length; i++) {
if (defectIds == this.defectTypeList[i].defectId) {
defectCodes = this.defectTypeList[i].defectCode;
}
}
}
this.$modal.confirm('是否确认删除不良类型维护编号为"' + defectCodes + '"的数据项?').then(function() {
return deldefectType(defectIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('device/defectType/export', {
...this.queryParams
}, `defectType_${new Date().getTime()}.xlsx`)
}
}
};
</script>
Loading…
Cancel
Save