waiterForm.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <a-spin :spinning="confirmLoading">
  3. <j-form-container :disabled="formDisabled">
  4. <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
  5. <a-row>
  6. <a-col :span="24">
  7. <a-form-model-item label="服务员工号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="workNo">
  8. <a-input v-model="model.workNo" placeholder="请输入服务员工号" ></a-input>
  9. </a-form-model-item>
  10. </a-col>
  11. <a-col :span="24">
  12. <a-form-model-item label="服务员姓名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="name">
  13. <a-input v-model="model.name" placeholder="请输入服务员姓名" ></a-input>
  14. </a-form-model-item>
  15. </a-col>
  16. <a-col :span="24">
  17. <a-form-model-item label="身份证号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="idCard">
  18. <a-input v-model="model.idCard" placeholder="请输入身份证号" ></a-input>
  19. </a-form-model-item>
  20. </a-col>
  21. <a-col :span="24">
  22. <a-form-model-item label="手机号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="phone">
  23. <a-input v-model="model.phone" placeholder="请输入手机号" ></a-input>
  24. </a-form-model-item>
  25. </a-col>
  26. <a-col :span="24">
  27. <a-form-model-item label="性别" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sex">
  28. <!-- <a-input-number v-model="model.sex" placeholder="请输入性别(0-默认未知,1-男,2-女)" style="width: 100%" />-->
  29. <j-dict-select-tag v-model="model.sex" placeholder="请选择性别" dictCode="sex"/>
  30. </a-form-model-item>
  31. </a-col>
  32. <a-col :span="24">
  33. <a-form-model-item
  34. :labelCol="labelCol"
  35. :wrapperCol="wrapperCol"
  36. label="是否有效"
  37. prop="status">
  38. <a-switch checkedChildren="有效" unCheckedChildren="无效" v-model="model.status"/>
  39. </a-form-model-item>
  40. </a-col>
  41. <a-col :span="24">
  42. <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remarks">
  43. <a-input v-model="model.remarks" placeholder="请输入备注" ></a-input>
  44. </a-form-model-item>
  45. </a-col>
  46. </a-row>
  47. </a-form-model>
  48. </j-form-container>
  49. </a-spin>
  50. </template>
  51. <script>
  52. import { httpAction, getAction } from '@/api/manage'
  53. import { validateDuplicateValue } from '@/utils/util'
  54. export default {
  55. name: 'waiterForm',
  56. components: {},
  57. props: {
  58. //表单禁用
  59. disabled: {
  60. type: Boolean,
  61. default: false,
  62. required: false
  63. }
  64. },
  65. data() {
  66. return {
  67. model: {},
  68. labelCol: {
  69. xs: {span: 24},
  70. sm: {span: 5},
  71. },
  72. wrapperCol: {
  73. xs: {span: 24},
  74. sm: {span: 16},
  75. },
  76. confirmLoading: false,
  77. validatorRules: {
  78. workNo: [
  79. {required: true, message: '请输入服务员工号!'},
  80. ],
  81. name: [
  82. {required: true, message: '请输入服务员姓名!'},
  83. ],
  84. idCard: [
  85. {required: true, message: '请输入身份证号!'},
  86. ],
  87. phone: [
  88. {required: true, message: '请输入手机号!'},
  89. ],
  90. sex: [
  91. {required: true, message: '请选择服务员性别!'},
  92. ],
  93. status: [
  94. {required: true, message: '请选择服务员是否有效!'},
  95. ],
  96. },
  97. url: {
  98. add: "/business/busWaiter/add",
  99. edit: "/business/busWaiter/edit",
  100. queryById: "/business/busWaiter/queryById"
  101. }
  102. }
  103. },
  104. computed: {
  105. formDisabled() {
  106. return this.disabled
  107. },
  108. },
  109. created() {
  110. //备份model原始值
  111. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  112. },
  113. methods: {
  114. add() {
  115. //初始化默认值
  116. this.edit(this.modelDefault);
  117. this.edit({status: true});
  118. },
  119. edit(record) {
  120. this.model = Object.assign({}, record);
  121. this.visible = true;
  122. if (record.status == 1) {
  123. this.model.status = true;
  124. } else {
  125. this.model.status = false;
  126. }
  127. },
  128. submitForm() {
  129. const that = this;
  130. // 触发表单验证
  131. this.$refs.form.validate(valid => {
  132. if (valid) {
  133. that.confirmLoading = true;
  134. let httpurl = '';
  135. let method = '';
  136. if (!this.model.id) {
  137. httpurl += this.url.add;
  138. var info = JSON.parse(localStorage.getItem("storeInfo"));
  139. this.model.hotelId = info.id;
  140. method = 'post';
  141. } else {
  142. httpurl += this.url.edit;
  143. method = 'put';
  144. }
  145. if (this.model.status) {
  146. this.model.status = 1;
  147. } else {
  148. this.model.status = 0;
  149. }
  150. httpAction(httpurl, this.model, method).then((res) => {
  151. if (res.success) {
  152. that.$message.success(res.message);
  153. that.$emit('ok');
  154. } else {
  155. that.$message.warning(res.message);
  156. }
  157. }).finally(() => {
  158. that.confirmLoading = false;
  159. })
  160. }
  161. })
  162. },
  163. }
  164. }
  165. </script>