BusMarketMemberForm.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  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 label="关联租户" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tenantId">
  13. <a-input v-model="model.tenantId" 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="hotelId">
  18. <a-input v-model="model.hotelId" placeholder="请输入关联酒店" ></a-input>
  19. </a-form-model-item>
  20. </a-col> -->
  21. <a-col :span="24">
  22. <a-form-model-item
  23. label="会员名称"
  24. :labelCol="labelCol"
  25. :wrapperCol="wrapperCol"
  26. prop="name"
  27. >
  28. <a-input
  29. v-model="model.name"
  30. placeholder="请输入会员名称"
  31. ></a-input>
  32. </a-form-model-item>
  33. </a-col>
  34. <a-col :span="24">
  35. <a-form-model-item
  36. label="选择类型"
  37. :labelCol="labelCol"
  38. :wrapperCol="wrapperCol"
  39. prop="type"
  40. >
  41. <a-radio-group v-model="model.type">
  42. <a-radio :value="0">会员折扣</a-radio>
  43. <a-radio :value="1">房价方案</a-radio>
  44. </a-radio-group>
  45. </a-form-model-item>
  46. </a-col>
  47. <a-col :span="24" v-show="model.type == 0">
  48. <a-form-model-item
  49. label="会员折扣"
  50. :labelCol="labelCol"
  51. :wrapperCol="wrapperCol"
  52. prop="discount"
  53. >
  54. <a-input-number
  55. v-model="model.discount"
  56. :min="1"
  57. :max="100"
  58. style="width: 20%"
  59. :precision="0"
  60. />%
  61. </a-form-model-item>
  62. </a-col>
  63. <a-col :span="24" v-show="model.type == 1">
  64. <a-form-model-item
  65. label="房价方案"
  66. :labelCol="labelCol"
  67. :wrapperCol="wrapperCol"
  68. prop="schemeId"
  69. >
  70. <a-select
  71. v-model="model.schemeId"
  72. placeholder="请选择"
  73. style="width: 120px"
  74. :allowClear="true"
  75. >
  76. <a-select-option
  77. :value="item.value"
  78. v-for="(item, index) in roomPlans"
  79. :key="index"
  80. >{{ item.label }}</a-select-option
  81. >
  82. </a-select>
  83. </a-form-model-item>
  84. </a-col>
  85. <a-col :span="24">
  86. <a-form-model-item
  87. label="是否需要支付"
  88. :labelCol="labelCol"
  89. :wrapperCol="wrapperCol"
  90. prop="payFlag"
  91. >
  92. <a-radio-group v-model="model.payFlag">
  93. <a-radio :value="0">否</a-radio>
  94. <a-radio :value="1">是</a-radio>
  95. </a-radio-group>
  96. </a-form-model-item>
  97. </a-col>
  98. <a-col :span="24" v-if="model.payFlag == 1">
  99. <a-form-model-item
  100. label="支付费用"
  101. :labelCol="labelCol"
  102. :wrapperCol="wrapperCol"
  103. prop="payAmount"
  104. :rules="[
  105. { required: true, message: '请输入支付费用', trigger: 'blur' },
  106. ]"
  107. >
  108. <a-input-number
  109. v-model="model.payAmount"
  110. placeholder="请输入支付费用"
  111. style="width: 100%"
  112. />
  113. </a-form-model-item>
  114. </a-col>
  115. <a-col :span="24">
  116. <a-form-model-item
  117. label="积分购买"
  118. :labelCol="labelCol"
  119. :wrapperCol="wrapperCol"
  120. prop="payIntegral"
  121. >
  122. <a-input-number
  123. v-model="model.payIntegral"
  124. placeholder="购买会员卡所需积分"
  125. style="width: 100%"
  126. />
  127. </a-form-model-item>
  128. </a-col>
  129. <a-col :span="24">
  130. <a-form-model-item
  131. label="是否可以储值"
  132. :labelCol="labelCol"
  133. :wrapperCol="wrapperCol"
  134. prop="payStored"
  135. >
  136. <a-radio-group v-model="model.payStored">
  137. <a-radio :value="0">否</a-radio>
  138. <a-radio :value="1">是</a-radio>
  139. </a-radio-group>
  140. </a-form-model-item>
  141. </a-col>
  142. <a-col :span="24">
  143. <a-form-model-item
  144. label="等级"
  145. :labelCol="labelCol"
  146. :wrapperCol="wrapperCol"
  147. prop="level"
  148. >
  149. <a-input-number
  150. v-model="model.level"
  151. placeholder="请输入等级"
  152. style="width: 20%"
  153. :precision="0"
  154. />
  155. </a-form-model-item>
  156. </a-col>
  157. <a-col :span="24">
  158. <a-form-model-item
  159. label="会员优惠"
  160. :labelCol="labelCol"
  161. :wrapperCol="wrapperCol"
  162. prop="hyyh"
  163. >每一积分可抵扣金额
  164. <a-input-number
  165. v-model="model.hyyh"
  166. style="width: 20%"
  167. :min="0"
  168. :max="1000000"
  169. />元
  170. </a-form-model-item>
  171. </a-col>
  172. <a-col :span="24">
  173. <a-form-model-item
  174. label="自动续期"
  175. :labelCol="labelCol"
  176. :wrapperCol="wrapperCol"
  177. prop="renewal"
  178. >
  179. <a-checkbox
  180. @change="(e) => (model.renewal = e.target.checked)"
  181. :checked="model.renewal"
  182. >
  183. 充值自动续期
  184. </a-checkbox>
  185. <a-input-number
  186. v-model="model.renewalDay"
  187. style="width: 20%"
  188. :min="1"
  189. :max="1000000"
  190. :precision="0"
  191. />天
  192. </a-form-model-item>
  193. </a-col>
  194. <a-col :span="24">
  195. <a-form-model-item
  196. label="积分设置"
  197. :labelCol="labelCol"
  198. :wrapperCol="wrapperCol"
  199. prop="tenantPointsChecked"
  200. >
  201. <a-checkbox
  202. @change="(e) => (model.tenantPointsChecked = e.target.checked)"
  203. :checked="model.tenantPointsChecked"
  204. >
  205. 客房积分模式
  206. </a-checkbox>
  207. <block v-show="model.tenantPointsChecked">
  208. <a-radio-group v-model="model.tenantPoints">
  209. <a-radio :value="1">所有的消费转成积分</a-radio>
  210. <a-radio :value="2">只房费转成积分</a-radio> </a-radio-group
  211. ><br />
  212. 每消费
  213. <a-input-number
  214. v-model="model.tenantRoomIntegral"
  215. style="width: 20%"
  216. :min="1"
  217. :max="1000000"
  218. :precision="0"
  219. />元,积
  220. <a-input-number
  221. v-model="model.addTenantRoomIntegral"
  222. style="width: 20%"
  223. :min="1"
  224. :max="1000000"
  225. :precision="0"
  226. />分</block
  227. ><br />
  228. <a-checkbox
  229. @change="(e) => (model.roomIntegralChecked = e.target.checked)"
  230. :checked="model.roomIntegralChecked"
  231. >
  232. 按储值卡支付积分
  233. </a-checkbox>
  234. <block v-show="model.roomIntegralChecked">
  235. 每消费
  236. <a-input-number
  237. v-model="model.roomIntegral"
  238. style="width: 20%"
  239. :min="1"
  240. :max="1000000"
  241. :precision="0"
  242. />元,积
  243. <a-input-number
  244. v-model="model.addRoomIntegral"
  245. style="width: 20%"
  246. :min="1"
  247. :max="1000000"
  248. :precision="0"
  249. />分</block
  250. ><br />
  251. <a-checkbox
  252. @change="(e) => (model.dayIntegralChecked = e.target.checked)"
  253. :checked="model.dayIntegralChecked"
  254. >
  255. 按入住天数积分
  256. </a-checkbox>
  257. <block v-show="model.dayIntegralChecked">
  258. 每入住
  259. <a-input-number
  260. v-model="model.dayIntegral"
  261. style="width: 20%"
  262. :min="1"
  263. :max="1000000"
  264. :precision="0"
  265. />天,积
  266. <a-input-number
  267. v-model="model.addDayIntegral"
  268. style="width: 20%"
  269. :min="1"
  270. :max="1000000"
  271. :precision="0"
  272. />分</block
  273. ><br />
  274. <a-checkbox
  275. @change="(e) => (model.rechargeChecked = e.target.checked)"
  276. :checked="model.rechargeChecked"
  277. >
  278. 启用储值赠送
  279. </a-checkbox>
  280. <block v-show="model.rechargeChecked">
  281. 每充值
  282. <a-input-number
  283. v-model="model.rechargeIntegral"
  284. style="width: 20%"
  285. :min="1"
  286. :max="1000000"
  287. :precision="0"
  288. />元,积
  289. <a-input-number
  290. v-model="model.addRechargeIntegral"
  291. style="width: 20%"
  292. :min="1"
  293. :max="1000000"
  294. :precision="0"
  295. />分</block
  296. ><br />
  297. <a-checkbox
  298. @change="(e) => (model.upLevelChecked = e.target.checked)"
  299. :checked="model.upLevelChecked"
  300. >
  301. 积分满足
  302. </a-checkbox>
  303. <block v-show="model.upLevelChecked">
  304. <a-input-number
  305. v-model="model.upLevelIntegral"
  306. style="width: 20%"
  307. :min="1"
  308. :max="1000000"
  309. :precision="0"
  310. />分,自动升级为
  311. <a-select
  312. v-model="model.upLevel"
  313. placeholder="请选择"
  314. style="width: 120px"
  315. :allowClear="true"
  316. >
  317. <a-select-option
  318. :value="item.value"
  319. v-for="(item, index) in members"
  320. :key="index"
  321. >{{ item.label }}</a-select-option
  322. >
  323. </a-select></block
  324. ><br />
  325. <a-checkbox
  326. @change="(e) => (model.subLevelChecked = e.target.checked)"
  327. :checked="model.subLevelChecked"
  328. >
  329. 升级扣除相应积分
  330. </a-checkbox>
  331. <block v-show="model.subLevelChecked">
  332. ,扣减相应积分为
  333. <a-input-number
  334. v-model="model.subLevelIntegral"
  335. style="width: 20%"
  336. :min="1"
  337. :max="1000000"
  338. :precision="0"
  339. /></block>
  340. </a-form-model-item>
  341. </a-col>
  342. <a-col :span="24">
  343. <a-form-model-item
  344. label="会员图标"
  345. :labelCol="labelCol"
  346. :wrapperCol="wrapperCol"
  347. prop="icon"
  348. >
  349. <!-- <a-input
  350. v-model="model.icon"
  351. placeholder="请输入会员图标"
  352. ></a-input> -->
  353. <a-input
  354. placeholder="点击选择图标"
  355. v-model="model.icon"
  356. :readOnly="true"
  357. >
  358. <a-icon slot="addonAfter" type="setting" @click="selectIcons" />
  359. </a-input>
  360. </a-form-model-item>
  361. </a-col>
  362. <a-col :span="24">
  363. <a-form-model-item
  364. label="卡片背景"
  365. :labelCol="labelCol"
  366. :wrapperCol="wrapperCol"
  367. prop="bgImage"
  368. >
  369. <j-image-upload
  370. class="avatar-uploader"
  371. text="上传"
  372. v-model="model.bgImage"
  373. ></j-image-upload>
  374. </a-form-model-item>
  375. </a-col>
  376. <a-col :span="24">
  377. <a-form-model-item
  378. label="卡片描述"
  379. :labelCol="labelCol"
  380. :wrapperCol="wrapperCol"
  381. prop="content"
  382. >
  383. <a-textarea
  384. v-model="model.content"
  385. rows="4"
  386. placeholder="请输入卡片描述"
  387. />
  388. </a-form-model-item>
  389. </a-col>
  390. </a-row>
  391. </a-form-model>
  392. <icons
  393. @choose="handleIconChoose"
  394. @close="handleIconCancel"
  395. :iconChooseVisible="iconChooseVisible"
  396. ></icons>
  397. </j-form-container>
  398. </a-spin>
  399. </template>
  400. <script>
  401. import { getRoomPlans,getSelectList } from "@/api/api";
  402. import { httpAction, getAction } from "@/api/manage";
  403. import { validateDuplicateValue } from "@/utils/util";
  404. import Icons from "./icon/Icons";
  405. export default {
  406. name: "BusMarketMemberForm",
  407. components: { Icons },
  408. props: {
  409. disabled: {
  410. type: Boolean,
  411. default: false,
  412. required: false,
  413. },
  414. },
  415. data() {
  416. return {
  417. model: {
  418. id: "",
  419. hotelId: 0,
  420. type: 0,
  421. discount: 1,
  422. payFlag: 0,
  423. payIntegral: 0,
  424. payStored: 0,
  425. level: 1,
  426. renewal: false,
  427. tenantPointsChecked: false,
  428. roomIntegralChecked: false,
  429. dayIntegralChecked: false,
  430. rechargeChecked: false,
  431. upLevelChecked: false,
  432. subLevelChecked: false,
  433. tenant_points: 1,
  434. },
  435. labelCol: {
  436. xs: { span: 24 },
  437. sm: { span: 5 },
  438. },
  439. wrapperCol: {
  440. xs: { span: 24 },
  441. sm: { span: 16 },
  442. },
  443. confirmLoading: false,
  444. validatorRules: {
  445. name: [{ required: true, message: "请输入会员名称!" }],
  446. // payAmount: [{ required: true, message: "请输入支付费用!" }],
  447. level: [{ required: true, message: "请输入等级!" }],
  448. icon: [{ required: true, message: "请上传会员图标!" }],
  449. },
  450. url: {
  451. add: "/org.jeecg.modules.business/busMarketMember/add",
  452. edit: "/org.jeecg.modules.business/busMarketMember/edit",
  453. queryById: "/org.jeecg.modules.business/busMarketMember/queryById",
  454. },
  455. iconChooseVisible: false,
  456. roomPlans: [],
  457. members: [],
  458. };
  459. },
  460. computed: {
  461. formDisabled() {
  462. return this.disabled;
  463. },
  464. },
  465. created() {
  466. var _info = JSON.parse(localStorage.getItem("storeInfo"));
  467. if (_info) {
  468. this.model.hotelId = _info.id;
  469. this.initData();
  470. }
  471. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  472. },
  473. methods: {
  474. initData() {
  475. getRoomPlans(this.model.hotelId, null).then((res) => {
  476. if (res.success) {
  477. this.roomPlans = res.result;
  478. }
  479. });
  480. },
  481. selectIcons() {
  482. this.iconChooseVisible = true;
  483. },
  484. handleIconCancel() {
  485. this.iconChooseVisible = false;
  486. },
  487. handleIconChoose(value) {
  488. console.log(value);
  489. this.model.icon = value;
  490. this.iconChooseVisible = false;
  491. },
  492. add() {
  493. this.edit(this.modelDefault);
  494. },
  495. edit(record) {
  496. this.model = Object.assign({}, record);
  497. this.visible = true;
  498. getSelectList({ id: this.model.id }).then((res) => {
  499. if (res.success) {
  500. this.members = res.result;
  501. }
  502. });
  503. },
  504. submitForm() {
  505. const that = this;
  506. // 触发表单验证
  507. this.$refs.form.validate((valid) => {
  508. if (valid) {
  509. that.confirmLoading = true;
  510. let httpurl = "";
  511. let method = "";
  512. if (!this.model.id) {
  513. httpurl += this.url.add;
  514. method = "post";
  515. } else {
  516. httpurl += this.url.edit;
  517. method = "put";
  518. }
  519. if (this.model.payFlag == 0) {
  520. this.model.payAmount = 0;
  521. }
  522. httpAction(httpurl, this.model, method)
  523. .then((res) => {
  524. if (res.success) {
  525. that.$message.success(res.message);
  526. that.$emit("ok");
  527. } else {
  528. that.$message.warning(res.message);
  529. }
  530. })
  531. .finally(() => {
  532. that.confirmLoading = false;
  533. });
  534. }
  535. });
  536. },
  537. },
  538. };
  539. </script>
  540. <style scoped>
  541. .avatar-uploader > .ant-upload {
  542. width: 104px;
  543. height: 104px;
  544. }
  545. </style>