zhiliangguanli
This commit is contained in:
parent
f2f9ba0e35
commit
8a27610586
|
@ -0,0 +1,59 @@
|
|||
import request from '@/utils/request'
|
||||
//标准规范
|
||||
export function getStandardList(query) {
|
||||
return request({
|
||||
url: '/qm/standard/',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
export function createStandard(data) {
|
||||
return request({
|
||||
url: '/qm/standard/',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
export function updateStandard(id, data) {
|
||||
return request({
|
||||
url: `/qm/standard/${id}/`,
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
||||
export function deleteStandard(id, data) {
|
||||
return request({
|
||||
url: `/qm/standard/${id}/`,
|
||||
method: 'delete',
|
||||
data
|
||||
})
|
||||
}
|
||||
//检测项目
|
||||
export function getTestitemList(query) {
|
||||
return request({
|
||||
url: '/qm/testitem/',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
export function createTestitem(data) {
|
||||
return request({
|
||||
url: '/qm/testitem/',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
export function updateTestitem(id, data) {
|
||||
return request({
|
||||
url: `/qm/testitem/${id}/`,
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
||||
export function deleteTestitem(id, data) {
|
||||
return request({
|
||||
url: `/qm/testitem/${id}/`,
|
||||
method: 'delete',
|
||||
data
|
||||
})
|
||||
}
|
|
@ -179,22 +179,22 @@ export const asyncRoutes = [
|
|||
}
|
||||
,
|
||||
{
|
||||
path: '/sam',
|
||||
path: '/qm',
|
||||
component: Layout,
|
||||
redirect: '/sam/customer',
|
||||
name: 'sam',
|
||||
redirect: '/qm/standard',
|
||||
name: 'qm',
|
||||
meta: { title: '质量管理', icon: 'example', perms: ['equipment_set'] },
|
||||
children: [
|
||||
{
|
||||
path: 'customer',
|
||||
name: 'customer',
|
||||
component: () => import('@/views/sam/customer'),
|
||||
path: 'standard',
|
||||
name: 'standard',
|
||||
component: () => import('@/views/qm/standard'),
|
||||
meta: { title: '标准', icon: 'example', perms: ['index_manage'] }
|
||||
},
|
||||
{
|
||||
path: 'contract',
|
||||
name: 'contract',
|
||||
component: () => import('@/views/sam/contract'),
|
||||
path: 'testitem',
|
||||
name: 'testitem',
|
||||
component: () => import('@/views/qm/testitem'),
|
||||
meta: { title: '检测项目', icon: 'example', perms: ['index_manage'] }
|
||||
}
|
||||
]
|
||||
|
|
|
@ -0,0 +1,286 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<el-card>
|
||||
<div>
|
||||
<el-input
|
||||
v-model="listQuery.search"
|
||||
placeholder="标准名称"
|
||||
style="width: 300px"
|
||||
class="filter-item"
|
||||
@keyup.enter.native="handleFilter"
|
||||
/>
|
||||
<el-button
|
||||
class="filter-item"
|
||||
type="primary"
|
||||
icon="el-icon-search"
|
||||
@click="handleFilter"
|
||||
>搜索</el-button
|
||||
>
|
||||
<el-button
|
||||
class="filter-item"
|
||||
type="primary"
|
||||
icon="el-icon-refresh-left"
|
||||
@click="resetFilter"
|
||||
>重置</el-button
|
||||
>
|
||||
</div>
|
||||
<div style="margin-top: 10px">
|
||||
<el-button type="primary" icon="el-icon-plus" @click="handleCreate"
|
||||
>新增标准</el-button
|
||||
>
|
||||
</div>
|
||||
</el-card>
|
||||
<el-card style="margin-top: 10px">
|
||||
<el-table
|
||||
v-loading="listLoading"
|
||||
:data="standardList.results"
|
||||
border
|
||||
fit
|
||||
stripe
|
||||
highlight-current-row
|
||||
max-height="600"
|
||||
>
|
||||
<el-table-column type="index" width="50" />
|
||||
<el-table-column label="标准名称">
|
||||
<template slot-scope="scope">{{ scope.row.name }}</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="标准编号">
|
||||
<template slot-scope="scope">{{ scope.row.number }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="是否启用">
|
||||
<template slot-scope="scope">
|
||||
<el-tag v-if="scope.row.enabled===true">是</el-tag>
|
||||
<el-tag v-else>否</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="标准文件">
|
||||
<template slot-scope="scope" v-if="scope.row.file_">
|
||||
<el-link :href="scope.row.file_.path" >{{scope.row.file_.name}}</el-link>
|
||||
</template>
|
||||
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="center"
|
||||
label="操作"
|
||||
width="220px"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
|
||||
<el-link
|
||||
v-if="checkPermission(['warehouse_update'])"
|
||||
@click="handleEdit(scope)"
|
||||
>编辑</el-link
|
||||
>
|
||||
<el-link
|
||||
v-if="checkPermission(['warehouse_delete'])"
|
||||
type="danger"
|
||||
@click="handleDelete(scope)"
|
||||
>删除</el-link
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination
|
||||
v-show="standardList.count > 0"
|
||||
:total="standardList.count"
|
||||
:page.sync="listQuery.page"
|
||||
:limit.sync="listQuery.page_size"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</el-card>
|
||||
<el-dialog
|
||||
:visible.sync="dialogVisible"
|
||||
:title="dialogType === 'edit' ? '编辑标准' : '新增标准'"
|
||||
>
|
||||
<el-form
|
||||
ref="Form"
|
||||
:model="standard"
|
||||
label-width="80px"
|
||||
label-position="right"
|
||||
:rules="rule1"
|
||||
>
|
||||
<el-form-item label="标准名称" prop="name">
|
||||
<el-input v-model="standard.name" placeholder="标准名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="标准编号" prop="number">
|
||||
<el-input v-model="standard.number" placeholder="标准编号" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="是否启用" prop="enabled">
|
||||
<el-switch v-model="standard.enabled"></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item label="指导书" prop="template" v-if="dialogVisible">
|
||||
<el-upload
|
||||
ref="upload"
|
||||
:action="upUrl"
|
||||
:on-preview="handlePreview"
|
||||
:on-success="handleUpSuccess"
|
||||
:on-remove="handleRemove"
|
||||
:headers="upHeaders"
|
||||
:file-list="fileList"
|
||||
:limit="1"
|
||||
accept=".doc,.docx,.xls,.xlsx,.ppt,.pptx"
|
||||
>
|
||||
<el-button size="small" type="primary">上传文件</el-button>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
<div style="text-align: right">
|
||||
<el-button type="danger" @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="confirm('Form')">确认</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { getStandardList, createStandard,updateStandard,deleteStandard} from "@/api/qm";
|
||||
import checkPermission from "@/utils/permission";
|
||||
import { upUrl, upHeaders } from "@/api/file";
|
||||
|
||||
import { genTree } from "@/utils";
|
||||
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
|
||||
const defaultestandard = {
|
||||
};
|
||||
export default {
|
||||
components: { Pagination },
|
||||
data() {
|
||||
return {
|
||||
standard: defaultestandard,
|
||||
contractList: {
|
||||
count: 0,
|
||||
},
|
||||
upHeaders: upHeaders(),
|
||||
upUrl: upUrl(),
|
||||
fileList:[],
|
||||
listQuery: {
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
},
|
||||
options:[],
|
||||
listLoading: true,
|
||||
dialogVisible: false,
|
||||
enabled:false,
|
||||
dialogType: "new",
|
||||
rule1: {
|
||||
name: [{ required: true, message: "请输入", trigger: "blur" }],
|
||||
number: [{ required: true, message: "请输入", trigger: "blur" }],
|
||||
},
|
||||
};
|
||||
},
|
||||
computed: {},
|
||||
watch: {},
|
||||
created() {
|
||||
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
checkPermission,
|
||||
|
||||
getList() {
|
||||
this.listLoading = true;
|
||||
getStandardList(this.listQuery).then((response) => {
|
||||
if (response.data) {
|
||||
this.standardList = response.data;
|
||||
}
|
||||
this.listLoading = false;
|
||||
});
|
||||
},
|
||||
|
||||
handlePreview(file) {
|
||||
if ("url" in file) {
|
||||
window.open(file.url);
|
||||
} else {
|
||||
window.open(file.response.data.path);
|
||||
}
|
||||
},
|
||||
handleUpSuccess(res, file, filelist) {
|
||||
this.standard.file = res.data.id;
|
||||
},
|
||||
handleRemove(file, filelist){
|
||||
this.standard.file = null;
|
||||
},
|
||||
|
||||
handleFilter() {
|
||||
this.listQuery.page = 1;
|
||||
this.getList();
|
||||
},
|
||||
resetFilter() {
|
||||
this.listQuery = {
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
}
|
||||
this.getList();
|
||||
},
|
||||
handleCreate() {
|
||||
this.standard = Object.assign({}, defaultestandard);
|
||||
this.dialogType = "new";
|
||||
this.dialogVisible = true;
|
||||
this.fileList=[];
|
||||
this.$nextTick(() => {
|
||||
this.$refs["Form"].clearValidate();
|
||||
});
|
||||
},
|
||||
|
||||
handleEdit(scope) {
|
||||
this.standard = Object.assign({}, scope.row); // copy obj
|
||||
this.dialogType = "edit";
|
||||
this.dialogVisible = true;
|
||||
if (this.standard.file) {
|
||||
this.fileList = [
|
||||
{
|
||||
name:this.standard.file_.name,
|
||||
url: this.standard.file_.path,
|
||||
},
|
||||
];
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
this.$refs["Form"].clearValidate();
|
||||
});
|
||||
},
|
||||
handleDelete(scope) {
|
||||
this.$confirm("确认删除?", "警告", {
|
||||
confirmButtonText: "确认",
|
||||
cancelButtonText: "取消",
|
||||
type: "error",
|
||||
})
|
||||
.then(async () => {
|
||||
await deleteStandard(scope.row.id);
|
||||
this.getList();
|
||||
this.$message.success("成功");
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
});
|
||||
},
|
||||
|
||||
async confirm(form) {
|
||||
this.$refs[form].validate((valid) => {
|
||||
if (valid) {
|
||||
const isEdit = this.dialogType === "edit";
|
||||
if (isEdit) {
|
||||
updateStandard(this.standard.id, this.standard).then((res) => {
|
||||
if (res.code >= 200) {
|
||||
this.getList();
|
||||
this.dialogVisible = false;
|
||||
this.$message.success("成功");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
createStandard(this.standard).then((res) => {
|
||||
if (res.code >= 200) {
|
||||
this.getList();
|
||||
this.dialogVisible = false;
|
||||
this.$message.success("成功");
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,258 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<el-card>
|
||||
<div>
|
||||
<el-input
|
||||
v-model="listQuery.search"
|
||||
placeholder="项目名称"
|
||||
style="width: 300px"
|
||||
class="filter-item"
|
||||
@keyup.enter.native="handleFilter"
|
||||
/>
|
||||
<el-button
|
||||
class="filter-item"
|
||||
type="primary"
|
||||
icon="el-icon-search"
|
||||
@click="handleFilter"
|
||||
>搜索</el-button
|
||||
>
|
||||
<el-button
|
||||
class="filter-item"
|
||||
type="primary"
|
||||
icon="el-icon-refresh-left"
|
||||
@click="resetFilter"
|
||||
>重置</el-button
|
||||
>
|
||||
</div>
|
||||
<div style="margin-top: 10px">
|
||||
<el-button type="primary" icon="el-icon-plus" @click="handleCreate"
|
||||
>新增项目</el-button
|
||||
>
|
||||
</div>
|
||||
</el-card>
|
||||
<el-card style="margin-top: 10px">
|
||||
<el-table
|
||||
v-loading="listLoading"
|
||||
:data="testitemList.results"
|
||||
border
|
||||
fit
|
||||
stripe
|
||||
highlight-current-row
|
||||
max-height="600"
|
||||
>
|
||||
<el-table-column type="index" width="50" />
|
||||
<el-table-column label="项目名称">
|
||||
<template slot-scope="scope">{{ scope.row.name }}</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="条款号">
|
||||
<template slot-scope="scope">{{ scope.row.term_number }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="标准名称">
|
||||
<template slot-scope="scope">{{ scope.row.standard_.name }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="标准编号">
|
||||
<template slot-scope="scope">{{ scope.row.standard_.number }}</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="创建时间">
|
||||
<template slot-scope="scope">{{ scope.row.create_time }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="center"
|
||||
label="操作"
|
||||
width="220px"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
|
||||
<el-link
|
||||
v-if="checkPermission(['warehouse_update'])"
|
||||
@click="handleEdit(scope)"
|
||||
>编辑</el-link
|
||||
>
|
||||
<el-link
|
||||
v-if="checkPermission(['warehouse_delete'])"
|
||||
type="danger"
|
||||
@click="handleDelete(scope)"
|
||||
>删除</el-link
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination
|
||||
v-show="testitemList.count > 0"
|
||||
:total="testitemList.count"
|
||||
:page.sync="listQuery.page"
|
||||
:limit.sync="listQuery.page_size"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</el-card>
|
||||
<el-dialog
|
||||
:visible.sync="dialogVisible"
|
||||
:title="dialogType === 'edit' ? '编辑项目' : '新增项目'"
|
||||
>
|
||||
<el-form
|
||||
ref="Form"
|
||||
:model="testitem"
|
||||
label-width="80px"
|
||||
label-position="right"
|
||||
:rules="rule1"
|
||||
>
|
||||
<el-form-item label="项目名称" prop="name">
|
||||
<el-input v-model="testitem.name" placeholder="项目名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="条款号" prop="term_number">
|
||||
<el-input v-model="testitem.term_number" placeholder="条款号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="标准" prop="standard">
|
||||
<el-select style="width: 100%" v-model="testitem.standard" placeholder="请选择">
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
|
||||
</el-form>
|
||||
<div style="text-align: right">
|
||||
<el-button type="danger" @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="confirm('Form')">确认</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { getTestitemList, createTestitem,updateTestitem,deleteTestitem,getStandardList } from "@/api/qm";
|
||||
import checkPermission from "@/utils/permission";
|
||||
|
||||
|
||||
import { genTree } from "@/utils";
|
||||
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
|
||||
const defaultetestitem = {
|
||||
};
|
||||
export default {
|
||||
components: { Pagination },
|
||||
data() {
|
||||
return {
|
||||
testitem: defaultetestitem,
|
||||
testitemList: {
|
||||
count: 0,
|
||||
},
|
||||
listQuery: {
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
},
|
||||
options:[],
|
||||
listLoading: true,
|
||||
dialogVisible: false,
|
||||
dialogType: "new",
|
||||
rule1: {
|
||||
name: [{ required: true, message: "请输入", trigger: "blur" }],
|
||||
term_number: [{ required: true, message: "请输入", trigger: "blur" }],
|
||||
},
|
||||
};
|
||||
},
|
||||
computed: {},
|
||||
watch: {},
|
||||
created() {
|
||||
this.getList();
|
||||
this.getLists()
|
||||
},
|
||||
methods: {
|
||||
checkPermission,
|
||||
//列表
|
||||
getList() {
|
||||
this.listLoading = true;
|
||||
getTestitemList(this.listQuery).then((response) => {
|
||||
if (response.data) {
|
||||
this.testitemList = response.data;
|
||||
}
|
||||
this.listLoading = false;
|
||||
});
|
||||
},
|
||||
|
||||
getLists() {
|
||||
|
||||
getStandardList({pageoff:true}).then((response) => {
|
||||
|
||||
this.options = genTree(response.data);
|
||||
|
||||
});
|
||||
},
|
||||
|
||||
handleFilter() {
|
||||
this.listQuery.page = 1;
|
||||
this.getList();
|
||||
},
|
||||
resetFilter() {
|
||||
this.listQuery = {
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
}
|
||||
this.getList();
|
||||
},
|
||||
handleCreate() {
|
||||
this.testitem = Object.assign({}, defaultetestitem);
|
||||
this.dialogType = "new";
|
||||
this.dialogVisible = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs["Form"].clearValidate();
|
||||
});
|
||||
},
|
||||
|
||||
handleEdit(scope) {
|
||||
this.testitem = Object.assign({}, scope.row); // copy obj
|
||||
this.dialogType = "edit";
|
||||
this.dialogVisible = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs["Form"].clearValidate();
|
||||
});
|
||||
},
|
||||
handleDelete(scope) {
|
||||
this.$confirm("确认删除?", "警告", {
|
||||
confirmButtonText: "确认",
|
||||
cancelButtonText: "取消",
|
||||
type: "error",
|
||||
})
|
||||
.then(async () => {
|
||||
await deleteTestitem(scope.row.id);
|
||||
this.getList();
|
||||
this.$message.success("成功");
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
});
|
||||
},
|
||||
|
||||
async confirm(form) {
|
||||
this.$refs[form].validate((valid) => {
|
||||
if (valid) {
|
||||
const isEdit = this.dialogType === "edit";
|
||||
if (isEdit) {
|
||||
updateTestitem(this.testitem.id, this.testitem).then((res) => {
|
||||
if (res.code >= 200) {
|
||||
this.getList();
|
||||
this.dialogVisible = false;
|
||||
this.$message.success("成功");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
createTestitem(this.testitem).then((res) => {
|
||||
if (res.code >= 200) {
|
||||
this.getList();
|
||||
this.dialogVisible = false;
|
||||
this.$message.success("成功");
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
Loading…
Reference in New Issue