Commit 4862a8572440d23c6353c9e5b018a20e4660890d
1 parent
395a7a30
feat: 校验规则
Showing
1 changed file
with
42 additions
and
7 deletions
src/views/scheduling/scheduling/index.vue
| @@ -358,7 +358,11 @@ function handleAdd() { | @@ -358,7 +358,11 @@ function handleAdd() { | ||
| 358 | /** 修改按钮操作 */ | 358 | /** 修改按钮操作 */ |
| 359 | function handleUpdate(row) { | 359 | function handleUpdate(row) { |
| 360 | reset(); | 360 | reset(); |
| 361 | - const _id = row.id || ids.value | 361 | + const _id = getIds(row); |
| 362 | + // const _ids = row ? row.id : ids.value; | ||
| 363 | + if (!validIds(_id)) { | ||
| 364 | + return; | ||
| 365 | + } | ||
| 362 | getScheduling(_id).then(response => { | 366 | getScheduling(_id).then(response => { |
| 363 | form.value = response.data; | 367 | form.value = response.data; |
| 364 | open.value = true; | 368 | open.value = true; |
| @@ -366,11 +370,35 @@ function handleUpdate(row) { | @@ -366,11 +370,35 @@ function handleUpdate(row) { | ||
| 366 | }); | 370 | }); |
| 367 | } | 371 | } |
| 368 | 372 | ||
| 373 | +/** | ||
| 374 | + * 验证id | ||
| 375 | + * @param {*} ids | ||
| 376 | + */ | ||
| 377 | +function validIds(ids) { | ||
| 378 | + console.log("validIds", ids); | ||
| 379 | + if (!(ids instanceof Array)) { | ||
| 380 | + ids = [ids]; | ||
| 381 | + console.log('array', ids); | ||
| 382 | + } | ||
| 383 | + console.log(ids); | ||
| 384 | + for (let i = 0; i < ids.length; i++) { | ||
| 385 | + if (ids[i] === 0) { | ||
| 386 | + proxy.$modal.msgError("不允许对系统默认的排班规则进行修改"); | ||
| 387 | + return false; | ||
| 388 | + } | ||
| 389 | + } | ||
| 390 | + return true; | ||
| 391 | + | ||
| 392 | +} | ||
| 393 | + | ||
| 369 | /** 提交按钮 */ | 394 | /** 提交按钮 */ |
| 370 | function submitForm() { | 395 | function submitForm() { |
| 371 | proxy.$refs["schedulingRef"].validate(valid => { | 396 | proxy.$refs["schedulingRef"].validate(valid => { |
| 372 | if (valid) { | 397 | if (valid) { |
| 373 | if (form.value.id != null) { | 398 | if (form.value.id != null) { |
| 399 | + if (!validIds([form.value.id])) { | ||
| 400 | + return; | ||
| 401 | + } | ||
| 374 | updateScheduling(form.value).then(response => { | 402 | updateScheduling(form.value).then(response => { |
| 375 | proxy.$modal.msgSuccess("修改成功"); | 403 | proxy.$modal.msgSuccess("修改成功"); |
| 376 | open.value = false; | 404 | open.value = false; |
| @@ -389,11 +417,12 @@ function submitForm() { | @@ -389,11 +417,12 @@ function submitForm() { | ||
| 389 | 417 | ||
| 390 | /** 删除按钮操作 */ | 418 | /** 删除按钮操作 */ |
| 391 | function handleDelete(row) { | 419 | function handleDelete(row) { |
| 392 | - | ||
| 393 | - // proxy.$modal.msgSuccess("规则删除暂时停用防止误操作"); | ||
| 394 | - console.log(row); | ||
| 395 | - const deletePrompt = row.ruleName ? "是否确认删除规则名称为" + row.ruleName + "的数据项?" : "是否确认该规则?"; | ||
| 396 | - const _ids = row.id || ids.value; | 420 | + const deletePrompt = row.ruleName ? "是否确认删除规则名称为" + row.ruleName + "的数据项?" : "是否确认删除该规则?"; |
| 421 | + const _ids = getIds(row); | ||
| 422 | + console.log("handleDelete", ids.value); | ||
| 423 | + if (!validIds(_ids)) { | ||
| 424 | + return; | ||
| 425 | + } | ||
| 397 | proxy.$modal.confirm(deletePrompt).then(function () { | 426 | proxy.$modal.confirm(deletePrompt).then(function () { |
| 398 | return delScheduling(_ids); | 427 | return delScheduling(_ids); |
| 399 | }).then(() => { | 428 | }).then(() => { |
| @@ -402,7 +431,6 @@ function handleDelete(row) { | @@ -402,7 +431,6 @@ function handleDelete(row) { | ||
| 402 | }).catch(() => { }); | 431 | }).catch(() => { }); |
| 403 | 432 | ||
| 404 | } | 433 | } |
| 405 | - | ||
| 406 | /** 导出按钮操作 */ | 434 | /** 导出按钮操作 */ |
| 407 | function handleExport() { | 435 | function handleExport() { |
| 408 | proxy.download('scheduling/scheduling/export', { | 436 | proxy.download('scheduling/scheduling/export', { |
| @@ -410,5 +438,12 @@ function handleExport() { | @@ -410,5 +438,12 @@ function handleExport() { | ||
| 410 | }, `scheduling_${new Date().getTime()}.xlsx`) | 438 | }, `scheduling_${new Date().getTime()}.xlsx`) |
| 411 | } | 439 | } |
| 412 | 440 | ||
| 441 | +function getIds(row) { | ||
| 442 | + if (row && row.ruleName) { | ||
| 443 | + return row.id; | ||
| 444 | + } else { | ||
| 445 | + return ids.value; | ||
| 446 | + } | ||
| 447 | +} | ||
| 413 | getList(); | 448 | getList(); |
| 414 | </script> | 449 | </script> |