CustomerForm.vue 7.6 KB

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