CleanRoomForm.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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="waiterId"
  17. >
  18. <a-select placeholder="服务员" v-model="model.waiterId">
  19. <a-select-option
  20. :value="item.id"
  21. v-for="(item, index) in busWaiterList"
  22. :key="item.id"
  23. >
  24. {{ item.name }}
  25. </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="remark"
  35. >
  36. <a-textarea
  37. v-model="model.remark"
  38. rows="4"
  39. placeholder="请输入备注"
  40. />
  41. </a-form-model-item>
  42. </a-col>
  43. </a-row>
  44. </a-form-model>
  45. </j-form-container>
  46. </a-spin>
  47. </template>
  48. <script>
  49. import { httpAction, getAction } from "@/api/manage";
  50. import { validateDuplicateValue } from "@/utils/util";
  51. export default {
  52. name: "BusMeetingRoomForm",
  53. components: {},
  54. props: {
  55. //表单禁用
  56. disabled: {
  57. type: Boolean,
  58. default: false,
  59. required: false,
  60. },
  61. },
  62. data() {
  63. return {
  64. model: {},
  65. labelCol: {
  66. xs: { span: 24 },
  67. sm: { span: 5 },
  68. },
  69. wrapperCol: {
  70. xs: { span: 24 },
  71. sm: { span: 16 },
  72. },
  73. confirmLoading: false,
  74. validatorRules: {
  75. waiterId: [{ required: true, message: "请选择服务员!" }],
  76. },
  77. url: {
  78. add: "/fw/fwRoomClean/add",
  79. edit: "/fw/fwRoomClean/edit",
  80. queryById: "/fw/fwRoomClean/queryById",
  81. },
  82. busWaiterList:[]
  83. };
  84. },
  85. computed: {
  86. formDisabled() {
  87. return this.disabled;
  88. },
  89. },
  90. created() {
  91. var _info = JSON.parse(localStorage.getItem("storeInfo"));
  92. if (_info) {
  93. this.model.hotelId = _info.id;
  94. }
  95. //备份model原始值
  96. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  97. getAction("/business/busWaiter/list", {
  98. hotelId: _info.id,
  99. pageNo: 1,
  100. pageSize: 99999,
  101. }).then((res) => {
  102. if (res.success) {
  103. this.busWaiterList = res.result.records;
  104. }
  105. });
  106. },
  107. methods: {
  108. onChange(date, dateString) {
  109. console.log(date, dateString);
  110. },
  111. add(record) {
  112. this.modelDefault = Object.assign(this.modelDefault, record);
  113. this.edit(this.modelDefault);
  114. },
  115. edit(record) {
  116. this.model = Object.assign({}, record);
  117. this.visible = true;
  118. },
  119. submitForm() {
  120. const that = this;
  121. // 触发表单验证
  122. this.$refs.form.validate((valid) => {
  123. if (valid) {
  124. that.confirmLoading = true;
  125. let httpurl = "";
  126. let method = "";
  127. if (!this.model.id) {
  128. httpurl += this.url.add;
  129. method = "post";
  130. } else {
  131. httpurl += this.url.edit;
  132. method = "put";
  133. }
  134. httpAction(httpurl, this.model, method)
  135. .then((res) => {
  136. if (res.success) {
  137. that.$message.success(res.message);
  138. that.$emit("ok");
  139. } else {
  140. that.$message.warning(res.message);
  141. }
  142. })
  143. .finally(() => {
  144. that.confirmLoading = false;
  145. });
  146. }
  147. });
  148. },
  149. },
  150. };
  151. </script>