物资删除时加一个4位数验证码避免误删

main
15036302109 9 months ago
parent 86a6a30a01
commit 9fb2245f1c

@ -429,6 +429,17 @@
<el-button @click="outCancel"> </el-button>
</div>
</el-dialog>
<el-dialog title="确认删除" :visible.sync="deleteDialogVisible" width="30%">
<p>物资名称: {{ materialName }}</p>
<p>物资数量: {{ materialQuantity }}</p>
<p>验证码: {{ captcha }}</p>
<el-input v-model="captchaInput" placeholder="请输入验证码"></el-input>
<span slot="footer" class="dialog-footer">
<el-button @click="deleteDialogVisible = false">取消</el-button>
<el-button type="primary" @click="confirmDelete"></el-button>
</span>
</el-dialog>
</div>
</template>
@ -535,6 +546,13 @@
outOpen:false,
outMaterialId:null,
outForm:{},
//
captcha: null,
captchaInput: null,
materialName: '',
materialQuantity: '',
deleteDialogVisible: false,
materialToDelete: null,
//
rules: {
materialQuantity: [
@ -680,6 +698,12 @@
this.open = false;
this.reset();
},
generateCaptcha() {
this.captcha = Math.floor(1000 + Math.random() * 9000);
},
validateCaptcha() {
return this.captchaInput == this.captcha;
},
outCancel() {
this.outOpen = false;
this.outReset();
@ -800,6 +824,25 @@
},
/** 删除按钮操作 */
handleDelete(row) {
this.materialToDelete = row;
this.materialName = row.materialName;
this.materialQuantity = row.materialQuantity;
this.generateCaptcha();
this.deleteDialogVisible = true;
},
confirmDelete() {
if (this.validateCaptcha()) {
delEhsMaterial(this.materialToDelete.materialId).then(() => {
this.getList();
this.$message.success("删除成功");
this.captchaInput = null;
this.deleteDialogVisible = false;
});
} else {
this.$message.error('验证码错误');
}
},
/* handleDelete(row) {
const materialIds = row.materialId || this.ids;
const materialName = row.materialName;
const materialQuantity = row.materialQuantity;
@ -809,7 +852,7 @@
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
}, */
/** 导出按钮操作 */
handleExport() {
this.download('ehsMaterial/ehsMaterial/export', {

Loading…
Cancel
Save