CustomerForm.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <a-spin :spinning="confirmLoading">
  3. <j-form-container :disabled="formDisabled">
  4. <a-form-model
  5. ref="form"
  6. :model="model"
  7. :rules="validatorRules"
  8. slot="detail"
  9. >
  10. <a-row>
  11. <a-col :span="24">
  12. <a-form-model-item
  13. label="证件类型"
  14. :labelCol="labelCol"
  15. :wrapperCol="wrapperCol"
  16. prop="certType"
  17. >
  18. <a-select
  19. v-model="model.certType"
  20. style="width: 100%"
  21. placeholder="证件类型"
  22. :allowClear="true"
  23. >
  24. <a-select-option :value="1">身份证</a-select-option>
  25. <a-select-option :value="2">护照</a-select-option>
  26. </a-select>
  27. </a-form-model-item>
  28. </a-col>
  29. <a-col :span="24">
  30. <a-form-model-item
  31. label="姓名"
  32. :labelCol="labelCol"
  33. :wrapperCol="wrapperCol"
  34. prop="customerName"
  35. >
  36. <a-auto-complete
  37. v-model="model.customerName"
  38. placeholder="联系人"
  39. @search="handleSearch"
  40. @select="(e) => handleSelectMember(e)"
  41. >
  42. <template slot="dataSource">
  43. <a-select-option v-for="item in customerList" :key="item.id"
  44. >{{ item.name }}-{{ item.phone }}</a-select-option
  45. >
  46. </template>
  47. </a-auto-complete>
  48. </a-form-model-item>
  49. </a-col>
  50. <a-col :span="24">
  51. <a-form-model-item
  52. label="性别"
  53. :labelCol="labelCol"
  54. :wrapperCol="wrapperCol"
  55. prop="gender"
  56. >
  57. <a-radio-group v-model="model.gender">
  58. <a-radio :value="1">男</a-radio>
  59. <a-radio :value="2">女</a-radio>
  60. </a-radio-group>
  61. </a-form-model-item>
  62. </a-col>
  63. <a-col :span="24">
  64. <a-form-model-item
  65. label="手机号"
  66. :labelCol="labelCol"
  67. :wrapperCol="wrapperCol"
  68. prop="phone"
  69. >
  70. <a-input
  71. v-model="model.phone"
  72. placeholder="请输入手机号"
  73. ></a-input>
  74. </a-form-model-item>
  75. </a-col>
  76. <a-col :span="24">
  77. <a-form-model-item
  78. label="证件号"
  79. :labelCol="labelCol"
  80. :wrapperCol="wrapperCol"
  81. prop="certNo"
  82. >
  83. <a-input
  84. v-model="model.certNo"
  85. placeholder="请输入证件号"
  86. ></a-input>
  87. </a-form-model-item>
  88. </a-col>
  89. <!-- <a-col :span="24">
  90. <a-form-model-item label="地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="address">
  91. <a-input v-model="model.address" placeholder="请输入地址" ></a-input>
  92. </a-form-model-item>
  93. </a-col> -->
  94. </a-row>
  95. </a-form-model>
  96. </j-form-container>
  97. </a-spin>
  98. </template>
  99. <script>
  100. import { httpAction, getAction } from "@/api/manage";
  101. import { validateDuplicateValue } from "@/utils/util";
  102. export default {
  103. name: "BusMemberCardForm",
  104. components: {},
  105. props: {
  106. //表单禁用
  107. disabled: {
  108. type: Boolean,
  109. default: false,
  110. required: false,
  111. },
  112. },
  113. data() {
  114. return {
  115. model: { payType: 1, livingOrderId: "",certType:1,gender:1 },
  116. labelCol: {
  117. xs: { span: 24 },
  118. sm: { span: 5 },
  119. },
  120. wrapperCol: {
  121. xs: { span: 24 },
  122. sm: { span: 16 },
  123. },
  124. confirmLoading: false,
  125. validatorRules: {
  126. mobile: [
  127. {
  128. required: true,
  129. pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
  130. message: "请输入手机号!",
  131. },
  132. ],
  133. cardNo: [{ required: true, message: "请输入会员卡号!" }],
  134. gradeId: [{ required: true, message: "请输入等级类型!" }],
  135. payType: [{ required: true, message: "请输入付款类型!" }],
  136. paymentMethod: [{ required: true, message: "请输入付款方式!" }],
  137. customerName: [{ required: true, message: "请输入会员姓名!" }],
  138. sex: [{ required: true, message: "请输入性别!" }],
  139. certificateType: [{ required: true, message: "请输入证件类型!" }],
  140. validity: [{ required: true, message: "请输入有效期!" }],
  141. },
  142. url: {
  143. add: "/business/busRoomBookingOrders/booking-to-live",
  144. edit: "/business/busMemberCard/edit",
  145. queryById: "/business/busMemberCard/queryById",
  146. },
  147. gradeList: [],
  148. paymentMethodList: [],
  149. staffList: [],
  150. customerList: [],
  151. oldcustomerList: [],
  152. };
  153. },
  154. computed: {
  155. formDisabled() {
  156. return this.disabled;
  157. },
  158. },
  159. created() {
  160. var _info = JSON.parse(localStorage.getItem("storeInfo"));
  161. if (_info) {
  162. this.model.hotelId = _info.id;
  163. }
  164. //备份model原始值
  165. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  166. this.getbusCustomer();
  167. },
  168. methods: {
  169. handleSearch(value) {
  170. let result;
  171. if (!value) {
  172. result = this.oldcustomerList;
  173. } else {
  174. result = this.oldcustomerList.filter((t) => t.name.includes(value));
  175. }
  176. this.customerList = result;
  177. },
  178. handleSelectMember(e) {
  179. var find = this.customerList.find((t) => t.id === e);
  180. this.model.phone = find.phone;
  181. this.model.customerName = find.name;
  182. this.model.customerId = find.id;
  183. },
  184. getbusCustomer() {
  185. getAction("/bus/busCustomer/list", {}).then((res) => {
  186. if (res.success) {
  187. this.customerList = res.result.records;
  188. this.oldcustomerList = JSON.parse(JSON.stringify(this.customerList));
  189. }
  190. });
  191. },
  192. add(livingOrderId,roomId) {
  193. this.modelDefault.livingOrderId = livingOrderId;
  194. this.modelDefault.roomId = roomId;
  195. this.edit(this.modelDefault);
  196. },
  197. edit(record) {
  198. this.model = Object.assign({}, record);
  199. this.visible = true;
  200. },
  201. submitForm() {
  202. const that = this;
  203. // 触发表单验证
  204. this.$refs.form.validate((valid) => {
  205. if (valid) {
  206. that.confirmLoading = true;
  207. // var customers = [];
  208. // customers.push({
  209. // certNo: this.model.certNo,
  210. // certType: this.model.certType,
  211. // customerId: this.model.customerId,
  212. // customerName: this.model.customerName,
  213. // gender: this.model.gender,
  214. // phone: this.model.phone,
  215. // roomId: this.model.roomId,
  216. // });
  217. httpAction("/business/busLivingCustomer/add", this.model, "post")
  218. .then((res) => {
  219. if (res.success) {
  220. that.$message.success("入住成功");
  221. that.$emit("ok");
  222. } else {
  223. that.$message.warning(res.message);
  224. }
  225. })
  226. .finally(() => {
  227. that.confirmLoading = false;
  228. });
  229. }
  230. });
  231. },
  232. },
  233. };
  234. </script>