BusMeetingRoomScheduleEditForm.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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="name"
  17. >
  18. <a-input
  19. v-model="model.name"
  20. placeholder="请输入公司名称"
  21. ></a-input>
  22. </a-form-model-item>
  23. </a-col>
  24. <a-col :span="24">
  25. <a-form-model-item
  26. label="会议主题"
  27. :labelCol="labelCol"
  28. :wrapperCol="wrapperCol"
  29. prop="theme"
  30. >
  31. <a-input
  32. v-model="model.theme"
  33. placeholder="请输入会议主题"
  34. ></a-input>
  35. </a-form-model-item>
  36. </a-col>
  37. <a-col :span="24">
  38. <a-form-model-item
  39. label="预定人姓名"
  40. :labelCol="labelCol"
  41. :wrapperCol="wrapperCol"
  42. prop="destinedName"
  43. >
  44. <a-input
  45. v-model="model.destinedName"
  46. placeholder="请输入预定人姓名"
  47. style="width: 100%"
  48. />
  49. </a-form-model-item>
  50. </a-col>
  51. <a-col :span="24">
  52. <a-form-model-item
  53. label="联系电话"
  54. :labelCol="labelCol"
  55. :wrapperCol="wrapperCol"
  56. prop="mobile"
  57. >
  58. <a-input
  59. v-model="model.mobile"
  60. placeholder="请输入联系电话"
  61. style="width: 100%"
  62. />
  63. </a-form-model-item>
  64. </a-col>
  65. <a-col :span="24">
  66. <a-form-model-item
  67. label="备注"
  68. :labelCol="labelCol"
  69. :wrapperCol="wrapperCol"
  70. prop="remark"
  71. >
  72. <a-textarea
  73. v-model="model.remark"
  74. rows="4"
  75. placeholder="请输入备注"
  76. />
  77. </a-form-model-item>
  78. </a-col>
  79. </a-row>
  80. </a-form-model>
  81. </j-form-container>
  82. </a-spin>
  83. </template>
  84. <script>
  85. import { httpAction, getAction } from "@/api/manage";
  86. import { validateDuplicateValue } from "@/utils/util";
  87. export default {
  88. name: "BusMeetingRoomForm",
  89. components: {},
  90. props: {
  91. //表单禁用
  92. disabled: {
  93. type: Boolean,
  94. default: false,
  95. required: false,
  96. },
  97. },
  98. data() {
  99. return {
  100. model: { detailList: [{}] },
  101. labelCol: {
  102. xs: { span: 24 },
  103. sm: { span: 5 },
  104. },
  105. wrapperCol: {
  106. xs: { span: 24 },
  107. sm: { span: 16 },
  108. },
  109. labelCol2: {
  110. xs: { span: 7 },
  111. sm: { span: 10 },
  112. },
  113. wrapperCol2: {
  114. xs: { span: 7 },
  115. sm: { span: 11 },
  116. },
  117. confirmLoading: false,
  118. validatorRules: {
  119. name: [{ required: true, message: "请输入名称!" }],
  120. theme: [{ required: true, message: "请输入会议主题!" }],
  121. destinedName: [{ required: true, message: "请输入预定人姓名!" }],
  122. mobile: [{ required: true, message: "请输入联系电话!" }],
  123. },
  124. url: {
  125. add: "/business/busMeetingRoomSchedule/create",
  126. edit: "/business/busMeetingRoomSchedule/edit",
  127. queryById: "/business/busMeetingRoomSchedule/queryById",
  128. },
  129. meetingRoomList: [],
  130. timeSpanList: [
  131. { id: 1, name: "上午" },
  132. { id: 2, name: "下午" },
  133. { id: 3, name: "晚上" },
  134. ],
  135. };
  136. },
  137. computed: {
  138. formDisabled() {
  139. return this.disabled;
  140. },
  141. },
  142. created() {
  143. getAction("/business/busMeetingRoom/list", {
  144. pageNo: 1,
  145. pageSize: 100,
  146. stauts: 1,
  147. }).then((res) => {
  148. if (res.success) {
  149. this.meetingRoomList = res.result.records;
  150. }
  151. });
  152. var _info = JSON.parse(localStorage.getItem("storeInfo"));
  153. if (_info) {
  154. this.model.hotelId = _info.id;
  155. }
  156. //备份model原始值
  157. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  158. },
  159. methods: {
  160. puls() {
  161. this.model.detailList.push({ });
  162. },
  163. remove(index) {
  164. this.model.detailList.splice(index, 1);
  165. },
  166. add() {
  167. this.edit(this.modelDefault);
  168. },
  169. edit(record) {
  170. this.model = Object.assign({}, record);
  171. this.visible = true;
  172. },
  173. submitForm() {
  174. const that = this;
  175. // 触发表单验证
  176. this.$refs.form.validate((valid) => {
  177. if (valid) {
  178. that.confirmLoading = true;
  179. let httpurl = "";
  180. let method = "";
  181. if (!this.model.id) {
  182. httpurl += this.url.add;
  183. method = "post";
  184. } else {
  185. httpurl += this.url.edit;
  186. method = "put";
  187. }
  188. httpAction(httpurl, this.model, method)
  189. .then((res) => {
  190. if (res.success) {
  191. that.$message.success(res.message);
  192. console.log(1)
  193. that.$emit("ok",this.model);
  194. // that.$parent.modalFormOk2(this.model);
  195. } else {
  196. that.$message.warning(res.message);
  197. }
  198. })
  199. .finally(() => {
  200. that.confirmLoading = false;
  201. });
  202. }
  203. });
  204. },
  205. },
  206. };
  207. </script>
  208. <style scoped>
  209. .dynamic-delete-button {
  210. cursor: pointer;
  211. position: relative;
  212. top: 10px;
  213. margin-left: 5px;
  214. font-size: 18px;
  215. color: #1890ff;
  216. transition: all 0.3s;
  217. }
  218. .dynamic-delete-button:hover {
  219. color: #777;
  220. }
  221. .dynamic-delete-button[disabled] {
  222. cursor: not-allowed;
  223. opacity: 0.5;
  224. }
  225. </style>