| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- <template>
- <a-spin :spinning="confirmLoading">
- <j-form-container :disabled="formDisabled">
- <a-form-model
- ref="form"
- :model="model"
- :rules="validatorRules"
- slot="detail"
- >
- <a-form-model-item
- label="房间楼层"
- :labelCol="labelCol"
- :wrapperCol="wrapperCol"
- prop="floorId"
- >
- <a-select
- placeholder="请选择"
- style="width: 200px"
- v-model="model.floorId"
- @change="onFloorChange($event)"
- >
- <template v-for="item in buildingTreeData">
- <a-select-opt-group v-if="item.children" :key="item.id">
- <span slot="label"><a-icon type="tags" />{{ item.name }}</span>
- <a-select-option
- :value="child.id"
- v-for="child in item.children"
- :key="child.id"
- >
- {{ child.name }}
- </a-select-option>
- </a-select-opt-group>
- </template>
- </a-select>
- </a-form-model-item>
- <a-form-model-item
- label="房间房型"
- :labelCol="labelCol"
- :wrapperCol="wrapperCol"
- prop="layoutId"
- >
- <a-select
- placeholder="请选择"
- style="width: 200px"
- v-model="model.layoutId"
- >
- <a-select-option
- :value="item.id"
- v-for="item in layouts"
- :key="item.id"
- >
- {{ item.name }}
- </a-select-option>
- </a-select>
- </a-form-model-item>
- <a-form-model-item
- label="房间前缀"
- :labelCol="labelCol"
- :wrapperCol="wrapperCol"
- prop="prefix"
- >
- <a-input
- style="width: 50%"
- v-model="model.prefix"
- placeholder="请填写房间前缀"
- />
- </a-form-model-item>
- <a-form-model-item
- label="房间房号"
- :labelCol="labelCol"
- :wrapperCol="wrapperCol"
- prop="name"
- >
- <a-input
- style="width: 50%"
- v-model="model.name"
- placeholder="请填写房号"
- />
- </a-form-model-item>
- <a-form-model-item
- label="房间描述"
- :labelCol="labelCol"
- :wrapperCol="wrapperCol"
- prop="remark"
- >
- <a-textarea
- style="width: 50%"
- v-model="model.remark"
- placeholder="请填写房间描述"
- />
- </a-form-model-item>
- </a-form-model>
- </j-form-container>
- </a-spin>
- </template>
- <script>
- import { getRoomPlans, getSelectList } from "@/api/api";
- import { buildingTree } from "@/api/roomBuildingApi";
- import { getAllLayouts } from "../../../../../api/roomLayout";
- import { httpAction, getAction } from "@/api/manage";
- import { validateDuplicateValue } from "@/utils/util";
- export default {
- name: "BusMarketMemberForm",
- props: {
- disabled: {
- type: Boolean,
- default: false,
- required: false,
- },
- },
- data() {
- return {
- model: {
- id: "",
- floorId: undefined,
- buildId: null,
- layoutId: undefined,
- prefix: null,
- name: null,
- remark: null,
- },
- labelCol: {
- xs: { span: 24 },
- sm: { span: 5 },
- },
- wrapperCol: {
- xs: { span: 24 },
- sm: { span: 16 },
- },
- confirmLoading: false,
- validatorRules: {
- name: [{ required: true, message: "请输入房型!" }],
- floorId: [{ required: true, message: "请选择楼层!" }],
- layoutId: [{ required: true, message: "请选择房型!" }],
- },
- url: {
- add: "/rooms/cesRooms/save",
- edit: "/rooms/cesRooms/modify",
- queryById: "/rooms/cesRooms/queryById",
- },
- iconChooseVisible: false,
- roomPlans: [],
- members: [],
- buildingTreeData: [],
- layouts: [],
- };
- },
- computed: {
- formDisabled() {
- return this.disabled;
- },
- },
- created() {
- buildingTree().then((res) => {
- if (res.code == 200) {
- this.buildingTreeData = res.result;
- }
- });
- getAllLayouts().then((res) => {
- if (res.code == 200) {
- this.layouts = res.result.records;
- }
- });
- var _info = JSON.parse(localStorage.getItem("storeInfo"));
- if (_info) {
- this.model.hotelId = _info.id;
- this.initData();
- }
- this.modelDefault = JSON.parse(JSON.stringify(this.model));
- },
- methods: {
- // 下拉框改变之后找到楼栋id
- onFloorChange(e) {
- this.buildingTreeData.forEach((s) => {
- if (s.children) {
- s.children.forEach((t) => {
- if (t.id == e) this.model.buildId = s.id;
- });
- }
- });
- },
- initData() {
- getRoomPlans(this.model.hotelId, null).then((res) => {
- if (res.success) {
- this.roomPlans = res.result;
- }
- });
- },
- selectIcons() {
- this.iconChooseVisible = true;
- },
- handleIconCancel() {
- this.iconChooseVisible = false;
- },
- handleIconChoose(value) {
- console.log(value);
- this.model.icon = value;
- this.iconChooseVisible = false;
- },
- add() {
- this.edit(this.modelDefault);
- },
- edit(record) {
- this.model = Object.assign({}, record);
- this.visible = true;
- getSelectList({ id: this.model.id }).then((res) => {
- if (res.success) {
- this.members = res.result;
- }
- });
- },
- submitForm() {
- const that = this;
- // 触发表单验证
- this.$refs.form.validate((valid) => {
- if (valid) {
- that.confirmLoading = true;
- let httpurl = "";
- let method = "";
- if (!this.model.id) {
- httpurl += this.url.add;
- method = "post";
- } else {
- httpurl += this.url.edit;
- method = "put";
- }
- if (this.model.payFlag == 0) {
- this.model.payAmount = 0;
- }
- httpAction(httpurl, this.model, method)
- .then((res) => {
- if (res.success) {
- that.$message.success(res.message);
- that.$emit("ok");
- } else {
- that.$message.warning(res.message);
- }
- })
- .finally(() => {
- that.confirmLoading = false;
- });
- }
- });
- },
- },
- };
- </script>
- <style scoped>
- .avatar-uploader > .ant-upload {
- width: 104px;
- height: 104px;
- }
- </style>
|