spring
2025-04-02 235f0b0e3605082bb2127dc6d87f4a7eef33c6de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<template>
  <div>
    <el-dialog title="厂家要求值绑定" :visible.sync="isShow" width="800px" @close="$emit('closeBindPartDialog')">
      <div class="body" v-if="isShow" style="height: 500px; overflow-y: auto; padding: 5px 0">
        <el-table ref="bindPartTable" :data="bindPartData" v-loading="bindPartTableLoading" highlight-current-row
          style="width: 100%">
          <el-table-column type="index" width="70" label="序号"></el-table-column>
          <el-table-column property="supplierName" label="厂家" width="200"></el-table-column>
          <el-table-column property="ask" label="要求值"></el-table-column>
          <el-table-column property="tell" label="要求描述"></el-table-column>
          <el-table-column label="操作" width="100">
            <template slot-scope="scope">
              <el-button type="text" size="small" @click="updateBind(scope.row, 'edit')">编辑</el-button>
              <el-button type="text" size="small" @click="deleteBind(scope.row)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <!--      <div class="page" v-if="bindPartData.length > 0">-->
      <!--        <el-pagination @size-change="sizeChange" @current-change="currentChange" :current-page="page.current"-->
      <!--                       :page-size="20" layout="prev, pager, next, jumper"-->
      <!--                       :total="bindPartData.length">-->
      <!--        </el-pagination>-->
      <!--      </div>-->
      <span slot="footer" class="dialog-footer">
        <el-button @click="$emit('closeBindPartDialog')">取 消</el-button>
        <el-button type="primary" @click="addBindPart('add')" :loading="addBindLoad">新 增</el-button>
      </span>
    </el-dialog>
    <el-dialog title="厂家要求值绑定" :visible.sync="addBindSupplierDensityDialog" v-if="addBindSupplierDensityDialog"
      width="400px" @close="closeBindPartDialog" :close-on-click-modal="false">
      <div class="body" v-if="addBindSupplierDensityDialog">
        <el-form label-position="right" label-width="100px" ref="bindSupplierDensityData" :rules="bindPartDataRules"
          :model="bindSupplierDensityData">
          <el-form-item label="厂家:" prop="supplierName">
            <el-input v-model="bindSupplierDensityData.supplierName" size="small"></el-input>
          </el-form-item>
          <el-form-item label="要求值:" prop="ask">
            <el-input v-model="bindSupplierDensityData.ask" size="small"></el-input>
          </el-form-item>
          <el-form-item label="要求描述:" prop="tell">
            <el-input v-model="bindSupplierDensityData.tell" size="small"></el-input>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="closeBindPartDialog">取 消</el-button>
        <el-button type="primary" @click="submitBind" :loading="bindLoad">确 认</el-button>
      </span>
    </el-dialog>
  </div>
</template>
 
<script>
import {
  selectSupplierAsk,
  addProductSupplierAsk,
  updateProductSupplierAsk,
  deleteProductSupplierAsk,
} from "@/api/standard/standardLibrary";
 
export default {
  name: "bindSupplierDensityDialogAsk",
  props: {
    bindSupplierDensityDialog: {
      type: Boolean,
      default: () => false,
    },
    currentRow: {
      // 选择本条数据的信息
      type: Object,
      default: () => { },
    },
  },
  data() {
    // 这里存放数据
    return {
      isShow: this.bindSupplierDensityDialog,
      bindPartData: [],
      addBindSupplierDensityDialog: false,
      bindSupplierDensityData: {
        supplierName: null, // 厂家
        ask: null,
        tell: null,
        supplierAskId: null,
      },
      bindPartDataRules: {
        supplierName: [
          { required: true, message: "请填写厂家名称", trigger: "blur" },
        ],
        ask: [{ required: true, message: "请填写要求值", trigger: "blur" }],
        tell: [{ required: true, message: "请填写要求描述", trigger: "blur" }],
      },
      bindLoad: false,
      upIndex: 0,
      addBindLoad: false,
      entity: {
        productListId: "",
      },
      page: {
        current: 1,
        size: 20,
      },
      bindPartTableLoading: false,
      buttonType: "",
    };
  },
  mounted() {
    this.entity.productListId = this.currentRow.id;
    this.searchTableData();
  },
  // 方法集合
  methods: {
    searchTableData() {
      this.bindPartTableLoading = true;
      selectSupplierAsk(this.entity)
        .then((res) => {
          if (res.code === 200) {
            this.bindPartData = res.data;
          }
          this.bindPartTableLoading = false;
        })
        .catch((err) => {
          console.log(err);
          this.bindPartTableLoading = false;
        });
    },
    updateBind(row, type) {
      this.buttonType = type;
      this.addBindSupplierDensityDialog = true;
      this.bindSupplierDensityData = { ...row };
    },
    deleteBind(row) {
      this.$confirm("是否删除当前数据?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          deleteProductSupplierAsk({ supplierAskId: row.supplierAskId })
            .then((res) => {
              this.$message.success("删除成功");
              this.searchTableData();
            })
            .catch((e) => {
              this.$message.error("删除失败");
            });
        })
        .catch(() => { });
    },
    sizeChange(val) {
      this.page.size = val;
    },
    currentChange(val) {
      this.page.current = val;
    },
    addBindPart(type) {
      this.buttonType = type;
      this.addBindSupplierDensityDialog = true;
    },
    // 提交零件绑定
    submitBind() {
      this.$refs["bindSupplierDensityData"].validate((valid) => {
        if (valid) {
          // 根据类型判断是检验对象零件绑定还是产品维护零件绑定
          const str = JSON.stringify({
            productListId: this.entity.productListId,
            supplierName: this.bindSupplierDensityData.supplierName,
            ask: this.bindSupplierDensityData.ask,
            tell: this.bindSupplierDensityData.tell,
            supplierAskId: this.bindSupplierDensityData.supplierAskId,
          });
          this.bindLoad = true;
          if (this.buttonType === "add") {
            addProductSupplierAsk({ str })
              .then((res) => {
                this.bindLoad = false;
                if (res.code === 200) {
                  this.$refs["bindSupplierDensityData"].resetFields();
                  this.addBindSupplierDensityDialog = false;
                  this.$message.success("操作成功");
                  this.searchTableData();
                  this.$emit('refreshList')
                }
              })
              .catch((err) => {
                this.bindLoad = false;
                console.log(err);
              });
          } else {
            updateProductSupplierAsk({ str })
              .then((res) => {
                this.bindLoad = false;
                if (res.code === 200) {
                  this.$refs["bindSupplierDensityData"].resetFields();
                  this.addBindSupplierDensityDialog = false;
                  this.$message.success("操作成功");
                  this.searchTableData();
                  this.$emit('refreshList')
                }
              })
              .catch((err) => {
                this.bindLoad = false;
                console.log(err);
              });
          }
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    closeBindPartDialog() {
      this.$refs["bindSupplierDensityData"].resetFields();
      this.bindSupplierDensityData = {};
      this.addBindSupplierDensityDialog = false;
    },
  },
};
</script>
 
<style scoped>
.page {
  width: 100%;
  height: 30px;
  text-align: right;
  margin-top: 10px;
}
</style>