From fcbba75febaa36d23c6c49473ab5bcee0e1a2c04 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期二, 08 四月 2025 09:37:11 +0800
Subject: [PATCH] 检验项目新增是否委托要求字段
---
src/views/business/reliabilityPlan/plan.vue | 179 ++++++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 145 insertions(+), 34 deletions(-)
diff --git a/src/views/business/reliabilityPlan/plan.vue b/src/views/business/reliabilityPlan/plan.vue
index 279d2d2..3574af0 100644
--- a/src/views/business/reliabilityPlan/plan.vue
+++ b/src/views/business/reliabilityPlan/plan.vue
@@ -3,42 +3,45 @@
<div class="search">
<span></span>
<div class="btn">
- <el-button type="primary" size="small" @click="openAdd" v-if="planState != 1">鏂板</el-button>
- <el-button type="primary" size="small" @click="isEdit = true" v-if="planState != 1">缂栬緫</el-button>
- <el-button type="primary" size="small" @click="save" :loading="saveLoading" v-if="planState != 1">淇濆瓨</el-button>
+ <el-button type="primary" size="small" @click="openAdd" v-if="planState == 0">鏂板</el-button>
+ <el-button type="primary" size="small" @click="isEdit = true" v-if="planState == 0">缂栬緫</el-button>
+ <el-button type="primary" size="small" @click="save" :loading="saveLoading" v-if="planState == 0">淇濆瓨</el-button>
<el-button size="small" @click="goback">杩斿洖</el-button>
</div>
</div>
<el-table :data="tableData" style="width: 100%">
- <el-table-column prop="date" label="妫�娴嬮」" width="180">
- </el-table-column>
- <el-table-column prop="name" label="娴嬭瘯鏍囧噯" width="180">
+ <el-table-column prop="inspectionItem" label="妫�娴嬮」" width="180">
<template slot-scope="scope">
- <el-select v-model="scope.row.name" placeholder="璇烽�夋嫨" v-if="isEdit" size="small">
- <el-option v-for="item in standardList" :key="item.value" :label="item.label" :value="item.value">
- </el-option>
- </el-select>
- <span v-else>{{ scope.row.name }}</span>
+ <span>{{ scope.row.inspectionItem }}</span>
</template>
</el-table-column>
- <el-table-column prop="address" label="棰戞">
+ <el-table-column prop="standard" label="娴嬭瘯鏍囧噯" width="180">
<template slot-scope="scope">
- <el-select v-model="scope.row.name" placeholder="璇烽�夋嫨" v-if="isEdit" size="small">
+ <el-select v-model="scope.row.standard" placeholder="璇烽�夋嫨" v-if="isEdit" size="small">
+ <el-option v-for="item in codeList" :key="item.id" :label="item.label" :value="item.standard">
+ </el-option>
+ </el-select>
+ <span v-else>{{ scope.row.standard }}</span>
+ </template>
+ </el-table-column>
+ <el-table-column prop="frequency" label="棰戞">
+ <template slot-scope="scope">
+ <el-select v-model="scope.row.frequency" placeholder="璇烽�夋嫨" v-if="isEdit" size="small">
<el-option v-for="item in dict.type.planned_frequency" :key="item.value" :label="item.label"
:value="item.value">
</el-option>
</el-select>
- <span v-else>{{ scope.row.name }}</span>
+ <dict-tag v-else :options="dict.type.planned_frequency" :value="scope.row.frequency" />
</template>
</el-table-column>
- <el-table-column prop="address" label="澶囨敞">
+ <el-table-column prop="remark" label="澶囨敞">
<template slot-scope="scope">
- <el-input size="small" placeholder="璇疯緭鍏�" v-model="scope.row.address" v-if="isEdit">
+ <el-input size="small" placeholder="璇疯緭鍏�" v-model="scope.row.remark" v-if="isEdit">
</el-input>
- <span v-else>{{ scope.row.address }}</span>
+ <span v-else>{{ scope.row.remark }}</span>
</template>
</el-table-column>
- <el-table-column fixed="right" label="鎿嶄綔" width="100" v-if="planState != 1">
+ <el-table-column fixed="right" label="鎿嶄綔" width="100" v-if="planState == 0">
<template slot-scope="scope">
<el-button type="text" size="small" @click="handleDelete(scope.row)" style="color: red;">鍒犻櫎</el-button>
</template>
@@ -48,25 +51,26 @@
<el-form :model="addForm" ref="addForm" :rules="addRules" label-position="right" label-width="120px">
<el-form-item label="妫�楠岄」" prop="name">
<el-select v-model="addForm.name" placeholder="璇烽�夋嫨" size="small" style="width: 100%;">
- <el-option v-for="item in itemList" :key="item.value" :label="item.label" :value="item.value">
+ <el-option v-for="item in itemList" :key="item.id" :label="item.inspectionItem"
+ :value="item.inspectionItem">
</el-option>
</el-select>
</el-form-item>
- <el-form-item label="娴嬭瘯鏍囧噯" prop="number">
- <el-select v-model="addForm.name" placeholder="璇烽�夋嫨" size="small" style="width: 100%;">
- <el-option v-for="item in standardList" :key="item.value" :label="item.label" :value="item.value">
+ <el-form-item label="娴嬭瘯鏍囧噯" prop="standard">
+ <el-select v-model="addForm.standard" placeholder="璇烽�夋嫨" size="small" style="width: 100%;">
+ <el-option v-for="item in codeList" :key="item.id" :label="item.label" :value="item.standard">
</el-option>
</el-select>
</el-form-item>
- <el-form-item label="棰戞" prop="number">
- <el-select v-model="addForm.name" placeholder="璇烽�夋嫨" size="small" style="width: 100%;">
+ <el-form-item label="棰戞" prop="frequency">
+ <el-select v-model="addForm.frequency" placeholder="璇烽�夋嫨" size="small" style="width: 100%;">
<el-option v-for="item in dict.type.planned_frequency" :key="item.value" :label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
- <el-form-item label="澶囨敞" prop="number">
- <el-input size="small" placeholder="璇疯緭鍏�" v-model="addForm.address">
+ <el-form-item label="澶囨敞" prop="remark">
+ <el-input size="small" placeholder="璇疯緭鍏�" v-model="addForm.remark">
</el-input>
</el-form-item>
</el-form>
@@ -79,15 +83,15 @@
</template>
<script>
+import { selectProductItem, itemList, codeList, addOrUpdateItem, deleteItem, materialItem, materialCodeList } from "@/api/business/reliabilityPlan";
+
export default {
dicts: ["planned_frequency"],
data() {
return {
- tableData: [
- {}
- ],
+ tableData: [],
+ codeList: [],//鏍囧噯鍒楄〃
isEdit: false,
- standardList: [],//鏍囧噯鍒楄〃
saveLoading: false,
addForm: {},
addRules: {
@@ -104,15 +108,100 @@
const { id, type, state } = this.$route.query
this.planId = id;
this.planType = type;
- this.planState = state
+ this.planState = state;
+ this.getTableData();
+ this.getItemList();
+ this.getCodeList();
},
methods: {
+ getTableData() {
+ selectProductItem({
+ rePlanId: this.planId,
+ type: this.planType
+ }).then(res => {
+ if (res.code === 200) {
+ this.tableData = res.data || [];
+ }
+ }).catch(err => {
+ console.error('鑾峰彇鏁版嵁澶辫触:', err);
+ });
+ },
+
+ // 鑾峰彇妫�楠岄」鍒楄〃
+ getItemList() {
+ const api = this.planType === '鎴愬搧' ? itemList : materialItem;
+ api({ rePlanId: this.planId }).then(res => {
+ if (res.code === 200) {
+ this.itemList = res.data.map(item => ({
+ label: item.inspectionItem,
+ value: item.id,
+ inspectionItem: item.inspectionItem
+ })) || [];
+ }
+ }).catch(err => {
+ console.error('鑾峰彇妫�楠岄」鍒楄〃澶辫触:', err);
+ });
+ },
+
+ // 鑾峰彇娴嬭瘯鏍囧噯鍒楄〃
+ getCodeList() {
+ const api = this.planType === '鎴愬搧' ? codeList : materialCodeList;
+ api({ rePlanId: this.planId }).then(res => {
+ if (res.code === 200) {
+ this.codeList = res.data ? res.data.map(item => ({
+ label: item.standard,
+ value: item.id,
+ standard: item.standard
+ })) : [];
+ }
+ }).catch(err => {
+ console.error('鑾峰彇娴嬭瘯鏍囧噯鍒楄〃澶辫触:', err);
+ });
+ },
// 鍒犻櫎
- handleDelete(row) { },
+ handleDelete(row) {
+ this.$modal.confirm('鏄惁纭鍒犻櫎璇ユ楠岄」锛�').then(() => {
+ deleteItem({ id: row.id }).then(res => {
+ if (res.code === 200) {
+ this.$message.success('鍒犻櫎鎴愬姛');
+ this.getTableData();
+ }
+ }).catch(err => {
+ console.error('鍒犻櫎澶辫触:', err);
+ });
+ }).catch(() => { });
+ },
// 淇濆瓨
save() {
this.saveLoading = true;
- this.isEdit = false
+ const promises = this.tableData.map(item => {
+ const params = {
+ id: item.id,
+ rePlanId: this.planId,
+ inspectionItem: item.inspectionItem,
+ standard: item.standard,
+ frequency: item.frequency,
+ remark: item.remark,
+ type: this.planType
+ };
+ return addOrUpdateItem(params);
+ });
+
+ Promise.all(promises)
+ .then(responses => {
+ if (responses.every(res => res.code === 200)) {
+ this.$message.success('淇濆瓨鎴愬姛');
+ this.isEdit = false;
+ this.getTableData();
+ }
+ })
+ .catch(err => {
+ console.error('淇濆瓨澶辫触:', err);
+ this.$message.error('淇濆瓨澶辫触');
+ })
+ .finally(() => {
+ this.saveLoading = false;
+ });
},
goback() {
this.$tab.closePage();
@@ -121,7 +210,29 @@
this.addForm = {}
this.addDia = true;
},
- submitProduct() { }
+ submitProduct(formName) {
+ this.$refs[formName].validate((valid) => {
+ if (valid) {
+ const params = {
+ rePlanId: this.planId,
+ inspectionItem: this.addForm.name,
+ standard: this.addForm.standard,
+ frequency: this.addForm.frequency,
+ remark: this.addForm.remark,
+ type: this.planType
+ }
+ addOrUpdateItem(params).then(res => {
+ if (res.code === 200) {
+ this.$message.success('淇濆瓨鎴愬姛');
+ this.addDia = false;
+ this.getTableData();
+ }
+ }).catch(err => {
+ console.error('淇濆瓨澶辫触:', err);
+ });
+ }
+ });
+ }
}
}
</script>
--
Gitblit v1.9.3