123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <template>
- <el-dialog
- class="scan-task-bind-user-dialog"
- :visible.sync="modalIsShow"
- title="绑定扫描员"
- top="10vh"
- width="460px"
- :close-on-click-modal="false"
- :close-on-press-escape="false"
- append-to-body
- @open="visibleChange"
- >
- <el-form
- ref="modalFormComp"
- :model="modalForm"
- :rules="rules"
- label-width="100px"
- >
- <el-form-item prop="scanUserId" label="扫描员:">
- <el-select v-model="modalForm.scanUserId" placeholder="请选择扫描员">
- <el-option
- v-for="item in scanUserList"
- :key="item.id"
- :value="item.id"
- :label="item.name"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-form>
- <div slot="footer">
- <el-button type="primary" :disabled="isSubmit" @click="submit"
- >确认</el-button
- >
- <el-button @click="cancel">取消</el-button>
- </div>
- </el-dialog>
- </template>
- <script>
- import { scanTaskBindUser } from "../api";
- import { roleUserListQuery } from "../../base/api";
- const initModalForm = {
- id: null,
- scanUserId: ""
- };
- export default {
- name: "scan-task-bind-user-dialog",
- props: {
- instance: {
- type: Object,
- default() {
- return {};
- }
- }
- },
- data() {
- return {
- modalIsShow: false,
- isSubmit: false,
- modalForm: { ...initModalForm },
- scanUserList: [],
- rules: {
- scanUserId: [
- {
- required: true,
- message: "请选择扫描员",
- trigger: "change"
- }
- ]
- }
- };
- },
- mounted() {
- // this.getScanUsers();
- },
- methods: {
- visibleChange() {
- this.modalForm = this.$objAssign(initModalForm, this.instance);
- },
- cancel() {
- this.modalIsShow = false;
- },
- open() {
- this.modalIsShow = true;
- },
- async getScanUsers() {
- const res = await roleUserListQuery({ roleType: "Scan" });
- this.scanUserList = res || [];
- },
- async submit() {
- const valid = await this.$refs.modalFormComp.validate().catch(() => {});
- if (!valid) return;
- if (this.isSubmit) return;
- this.isSubmit = true;
- let datas = { ...this.modalForm };
- const data = await scanTaskBindUser(datas).catch(() => {});
- this.isSubmit = false;
- if (!data) return;
- this.$message.success("绑定成功!");
- this.$emit("modified");
- this.cancel();
- }
- }
- };
- </script>
|