hberp/hb_client/src/views/wpm/operation.vue

186 lines
5.6 KiB
Python

<template>
<div class="app-container">
<el-card class="box-card">
<el-tabs
type="border-card"
@tab-click="handleClick"
>
<el-tab-pane
v-for="item in processOption"
:key="item.name"
:label="item.name"
:name="item.id"
:closable="item.close"
>
<el-table
:data="operationList.results"
border
fit
stripe
style="width: 100%"
height="100"
highlight-current-row
v-el-height-adaptive-table="{bottomOffset: 50}"
>
<el-table-column type="index" width="50"/>
<el-table-column label="子工序工序">
<template slot-scope="scope">{{ scope.row.step_.name }}</template>
</el-table-column>
<el-table-column label="是否提交">
<template slot-scope="scope">
<el-span v-if="scope.row.is_submited"></el-span>
<el-span v-else></el-span>
</template>
</el-table-column>
<el-table-column label="创建人">
<template slot-scope="scope">
{{scope.row.create_by_.username}}
</template>
</el-table-column>
<el-table-column label="过程记录表">
<template v-if="scope.row.record_" slot-scope="scope">
<el-tag
v-for="item in scope.row.record_"
:key="item.id"
:label="item.name"
:value="item.id"
>
{{item.name}}
</el-tag>
</template>
</el-table-column>
<el-table-column label="产品数量">
<template slot-scope="scope">
{{ scope.row.count_work }}
</template>
</el-table-column>
<el-table-column label="生产设备">
<template slot-scope="scope" v-if="scope.row.equip_">
<el-tag v-for="item in scope.row.equip_"
:key="item.id"
:label="item.number"
:value="item.id">{{item.number}}
</el-tag>
</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="100px">
<template slot-scope="scope">
<el-link
v-if="checkPermission(['operation_create'])&&scope.row.is_submited"
type="primary"
@click="handleoperation(scope)"
>
前往查看
</el-link>
<el-link
v-if="checkPermission(['operation_create'])&&!scope.row.is_submited"
type="primary"
@click="handleoperation(scope)"
>
前往操作
</el-link>
<el-link
v-if="checkPermission(['operation_delete'])"
type="danger"
@click="handleDelete(scope)"
>
删除
</el-link>
</template>
</el-table-column>
</el-table>
<pagination
v-show="operationList.count > 0"
:total="operationList.count"
:page.sync="listQuery.page"
:limit.sync="listQuery.page_size"
@pagination="getList"
/>
</el-tab-pane>
</el-tabs>
</el-card>
</div>
</template>
<script>
import {getoperationList, deleteOperation} from "@/api/wpm";
import checkPermission from "@/utils/permission";
import {getProcessList, getStepLists} from "@/api/mtm";
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
export default {
components: {Pagination},
data() {
return {
operationList: {
count: 0,
},
listQuery: {
page: 1,
page_size: 20,
},
processOption: "",
};
},
computed: {},
watch: {},
created() {
this.id = this.$route.params.id;
this.getProcessList()
},
methods: {
checkPermission,
handleoperation(scope) {
this.$router.push({name: "operationdo", params: {id: scope.row.id},})
},
//大工序工序渲染
getProcessList() {
getProcessList({page: 0}).then((response) => {
if (response.data) {
this.processOption = response.data;
}
});
},
getList() {
getoperationList(this.listQuery).then((response) => {
if (response.data) {
this.operationList = response.data;
}
});
},
//选项卡切换
handleClick(tab) {
this.process = tab.name;
this.listQuery.step__process = tab.name;
this.getList();
},
//操作记录删除
handleDelete(scope) {
this.$confirm("确认该操作删除?", "警告", {
confirmButtonText: "确认",
cancelButtonText: "取消",
type: "error",
})
.then(async () => {
await deleteOperation(scope.row.id);
this.getList();
this.$message.success("成功");
})
.catch((err) => {
this.$message.error(err);
});
},
},
};
</script>