ScanTaskBindUserDialog.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <el-dialog
  3. class="scan-task-bind-user-dialog"
  4. :visible.sync="modalIsShow"
  5. title="绑定扫描员"
  6. top="10vh"
  7. width="460px"
  8. :close-on-click-modal="false"
  9. :close-on-press-escape="false"
  10. append-to-body
  11. @open="visibleChange"
  12. >
  13. <el-form
  14. ref="modalFormComp"
  15. :model="modalForm"
  16. :rules="rules"
  17. label-width="100px"
  18. >
  19. <el-form-item prop="scanUserId" label="扫描员:">
  20. <el-select v-model="modalForm.scanUserId" placeholder="请选择扫描员">
  21. <el-option
  22. v-for="item in scanUserList"
  23. :key="item.id"
  24. :value="item.id"
  25. :label="item.name"
  26. >
  27. </el-option>
  28. </el-select>
  29. </el-form-item>
  30. </el-form>
  31. <div slot="footer">
  32. <el-button type="primary" :disabled="isSubmit" @click="submit"
  33. >确认</el-button
  34. >
  35. <el-button @click="cancel">取消</el-button>
  36. </div>
  37. </el-dialog>
  38. </template>
  39. <script>
  40. import { scanTaskBindUser } from "../api";
  41. import { roleUserListQuery } from "../../base/api";
  42. const initModalForm = {
  43. id: null,
  44. scanUserId: ""
  45. };
  46. export default {
  47. name: "scan-task-bind-user-dialog",
  48. props: {
  49. instance: {
  50. type: Object,
  51. default() {
  52. return {};
  53. }
  54. }
  55. },
  56. data() {
  57. return {
  58. modalIsShow: false,
  59. isSubmit: false,
  60. modalForm: { ...initModalForm },
  61. scanUserList: [],
  62. rules: {
  63. scanUserId: [
  64. {
  65. required: true,
  66. message: "请选择扫描员",
  67. trigger: "change"
  68. }
  69. ]
  70. }
  71. };
  72. },
  73. mounted() {
  74. // this.getScanUsers();
  75. },
  76. methods: {
  77. visibleChange() {
  78. this.modalForm = this.$objAssign(initModalForm, this.instance);
  79. },
  80. cancel() {
  81. this.modalIsShow = false;
  82. },
  83. open() {
  84. this.modalIsShow = true;
  85. },
  86. async getScanUsers() {
  87. const res = await roleUserListQuery({ roleType: "Scan" });
  88. this.scanUserList = res || [];
  89. },
  90. async submit() {
  91. const valid = await this.$refs.modalFormComp.validate().catch(() => {});
  92. if (!valid) return;
  93. if (this.isSubmit) return;
  94. this.isSubmit = true;
  95. let datas = { ...this.modalForm };
  96. const data = await scanTaskBindUser(datas).catch(() => {});
  97. this.isSubmit = false;
  98. if (!data) return;
  99. this.$message.success("绑定成功!");
  100. this.$emit("modified");
  101. this.cancel();
  102. }
  103. }
  104. };
  105. </script>