ModifyGradingUser.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <Modal
  3. class="modify-grading-user"
  4. v-model="modalIsShow"
  5. :title="title"
  6. :mask-closable="false"
  7. @on-visible-change="visibleChange"
  8. >
  9. <Form
  10. ref="modalFormComp"
  11. :model="modalForm"
  12. :rules="rules"
  13. :key="modalForm.id"
  14. :label-width="80"
  15. >
  16. <FormItem prop="loginName" label="账号">
  17. <Input
  18. v-model.trim="modalForm.loginName"
  19. placeholder="请输入账号"
  20. clearable
  21. ></Input>
  22. </FormItem>
  23. <FormItem prop="password" label="密码">
  24. <Input
  25. v-model.trim="modalForm.password"
  26. placeholder="请输入密码"
  27. readonly
  28. ></Input>
  29. </FormItem>
  30. <FormItem prop="name" label="姓名">
  31. <Input
  32. v-model.trim="modalForm.name"
  33. placeholder="请输入姓名"
  34. clearable
  35. ></Input>
  36. </FormItem>
  37. <FormItem prop="role" label="角色">
  38. <Select v-model="modalForm.role" placeholder="请选择角色">
  39. <Option
  40. v-for="(val, key) in ROLE_TYPE"
  41. :key="key"
  42. :value="key"
  43. :label="val"
  44. ></Option>
  45. </Select>
  46. </FormItem>
  47. <FormItem
  48. prop="markRight"
  49. label="权限"
  50. v-if="modalForm.role === 'MARKER'"
  51. >
  52. <Select v-model="modalForm.markRight" placeholder="请选择权限">
  53. <Option
  54. v-for="(val, key) in MARKER_RIGHT_TYPE"
  55. :key="key"
  56. :value="key"
  57. :label="val"
  58. ></Option>
  59. </Select>
  60. </FormItem>
  61. <FormItem
  62. prop="weight"
  63. label="权重"
  64. v-if="
  65. modalForm.role === 'MARKER' &&
  66. modalForm.markRight &&
  67. modalForm.markRight !== 'ALLOW_SCORING'
  68. "
  69. >
  70. <InputNumber
  71. v-model.trim="modalForm.weight"
  72. :min="1"
  73. :max="100"
  74. :precision="2"
  75. placeholder="请输入权重"
  76. style="width: 120px"
  77. ></InputNumber>
  78. </FormItem>
  79. <FormItem v-if="modalForm.role === 'MARK_LEADER'">
  80. <Checkbox v-model="modalForm.oneClickLevel">是否一键定档</Checkbox
  81. ><br />
  82. <Checkbox v-model="modalForm.standardVolume">是否设立标准卷</Checkbox
  83. ><br />
  84. <Checkbox v-model="modalForm.levelCallback"
  85. >是否建议档位打回档</Checkbox
  86. >
  87. </FormItem>
  88. </Form>
  89. <div slot="footer">
  90. <Button type="text" @click="cancel">取消</Button>
  91. <Button type="primary" :disabled="isSubmit" @click="submit">确认</Button>
  92. </div>
  93. </Modal>
  94. </template>
  95. <script>
  96. import { updateGradingUser } from "@/api";
  97. import { commonCode, password, numberValidator } from "@/plugins/formRules";
  98. import { ROLE_TYPE, MARKER_RIGHT_TYPE } from "@/constants/enumerate";
  99. const initModalForm = {
  100. id: "",
  101. workId: "",
  102. subject: "",
  103. loginName: "",
  104. password: "123456",
  105. name: "",
  106. role: null,
  107. markRight: null,
  108. weight: null,
  109. oneClickLevel: false,
  110. standardVolume: false,
  111. levelCallback: false
  112. };
  113. export default {
  114. name: "modify-grading-user",
  115. props: {
  116. instance: {
  117. type: Object,
  118. default() {
  119. return {};
  120. }
  121. }
  122. },
  123. computed: {
  124. isEdit() {
  125. return !!this.instance.id;
  126. },
  127. title() {
  128. return (this.isEdit ? "编辑" : "新增") + "评卷账号";
  129. }
  130. },
  131. data() {
  132. return {
  133. modalIsShow: false,
  134. isSubmit: false,
  135. ROLE_TYPE,
  136. MARKER_RIGHT_TYPE,
  137. modalForm: { ...initModalForm },
  138. rules: {
  139. loginName: commonCode({ prop: "账号" }),
  140. password,
  141. name: [
  142. {
  143. required: true,
  144. min: 2,
  145. max: 20,
  146. message: "请输入姓名,长度2-20个字符",
  147. trigger: "change"
  148. }
  149. ],
  150. role: [
  151. {
  152. required: true,
  153. message: "请选择角色",
  154. trigger: "change"
  155. }
  156. ],
  157. markRight: [
  158. {
  159. required: true,
  160. message: "请选择权限",
  161. trigger: "change"
  162. }
  163. ],
  164. weight: numberValidator("请输入权重")
  165. }
  166. };
  167. },
  168. methods: {
  169. initData(val) {
  170. this.modalForm = this.$objAssign(initModalForm, val);
  171. },
  172. visibleChange(visible) {
  173. if (visible) {
  174. this.initData(this.instance);
  175. }
  176. },
  177. cancel() {
  178. this.modalIsShow = false;
  179. },
  180. open() {
  181. this.modalIsShow = true;
  182. },
  183. async submit() {
  184. const valid = await this.$refs.modalFormComp.validate();
  185. if (!valid) return;
  186. if (this.isSubmit) return;
  187. this.isSubmit = true;
  188. let result = true;
  189. await updateGradingUser(this.modalForm).catch(() => {
  190. result = false;
  191. });
  192. this.isSubmit = false;
  193. if (!result) return;
  194. this.$Message.success(this.title + "成功!");
  195. this.$emit("modified");
  196. this.cancel();
  197. }
  198. }
  199. };
  200. </script>