Commit 07042656 by 吕明尚

新增/修改房间时添加增加套餐功能

parent 8b898627
...@@ -33,6 +33,14 @@ export function addPack(data) { ...@@ -33,6 +33,14 @@ export function addPack(data) {
}) })
} }
export function insertPack(data) {
return request({
url: '/system/pack/add',
method: 'post',
data: data
})
}
// 修改套餐 // 修改套餐
export function updatePack(data) { export function updatePack(data) {
return request({ return request({
......
...@@ -58,28 +58,28 @@ ...@@ -58,28 +58,28 @@
v-hasPermi="['system:pack:add']" v-hasPermi="['system:pack:add']"
>新增</el-button> >新增</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <!-- <el-col :span="1.5">-->
<el-button <!-- <el-button-->
type="success" <!-- type="success"-->
plain <!-- plain-->
icon="el-icon-edit" <!-- icon="el-icon-edit"-->
size="mini" <!-- size="mini"-->
:disabled="single" <!-- :disabled="single"-->
@click="handleUpdate" <!-- @click="handleUpdate"-->
v-hasPermi="['system:pack:edit']" <!-- v-hasPermi="['system:pack:edit']"-->
>修改</el-button> <!-- >修改</el-button>-->
</el-col> <!-- </el-col>-->
<el-col :span="1.5"> <!-- <el-col :span="1.5">-->
<el-button <!-- <el-button-->
type="danger" <!-- type="danger"-->
plain <!-- plain-->
icon="el-icon-delete" <!-- icon="el-icon-delete"-->
size="mini" <!-- size="mini"-->
:disabled="multiple" <!-- :disabled="multiple"-->
@click="handleDelete" <!-- @click="handleDelete"-->
v-hasPermi="['system:pack:remove']" <!-- v-hasPermi="['system:pack:remove']"-->
>删除</el-button> <!-- >删除</el-button>-->
</el-col> <!-- </el-col>-->
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="warning" type="warning"
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
</el-row> </el-row>
<el-table v-loading="loading" :data="packList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="packList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" /> <!-- <el-table-column type="selection" width="55" align="center" />-->
<el-table-column label="套餐名称" align="center" prop="name" /> <el-table-column label="套餐名称" align="center" prop="name" />
<el-table-column label="时长" align="center" prop="duration" /> <el-table-column label="时长" align="center" prop="duration" />
<el-table-column label="金额" align="center" prop="price" /> <el-table-column label="金额" align="center" prop="price" />
...@@ -305,13 +305,12 @@ export default { ...@@ -305,13 +305,12 @@ export default {
roomnNameStr = `是否确认删除${row.name}数据及其关联的房间${str}下的绑定套餐?` roomnNameStr = `是否确认删除${row.name}数据及其关联的房间${str}下的绑定套餐?`
} }
this.$modal.confirm(roomnNameStr).then((result) =>{ this.$modal.confirm(roomnNameStr).then((result) =>{
return delPack(ids); return delPack(row.id);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.$modal.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => {});
}); });
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
......
...@@ -218,8 +218,8 @@ ...@@ -218,8 +218,8 @@
:value="item.id" :value="item.id"
></el-option> ></el-option>
</el-select> </el-select>
<el-button type="primary" icon="el-icon-circle-plus" @change="packAdd"/> <!-- <el-button type="primary" icon="el-icon-circle-plus" @change="packAdd"/>-->
<!-- <i class="el-icon-circle-plus" style="font-size: 32px;color: #1c84c6;margin-left:4px;" @change="packAdd"></i>--> <i class="el-icon-circle-plus" style="font-size: 32px;color: #1c84c6;margin-left:4px;" @click="packAdd"></i>
</div> </div>
</el-form-item> </el-form-item>
<el-form-item label="备注" prop="remark"> <el-form-item label="备注" prop="remark">
...@@ -232,30 +232,30 @@ ...@@ -232,30 +232,30 @@
</div> </div>
</el-dialog> </el-dialog>
<!-- 添加或修改套餐对话框 --> <!-- 添加或修改套餐对话框 -->
<el-dialog :title="packTitle" :visible.sync="packOpen" width="500px"> <el-dialog :title="packTitle" :visible.sync="packOpen" width="80%px" append-to-bod>
<el-form ref="form" :model="packFrom" label-width="120px"> <el-form ref="packForm" :model="packForm" label-width="120px">
<el-form-item label="套餐名称" prop="name"> <el-form-item label="套餐名称" prop="name">
<el-input v-model="packFrom.name" placeholder="请输入套餐名称" /> <el-input v-model="packForm.name" placeholder="请输入套餐名称" />
</el-form-item> </el-form-item>
<el-form-item label="时长" prop="duration"> <el-form-item label="时长" prop="duration">
<el-input v-model="packFrom.duration" placeholder="请输入时长" /> <el-input v-model="packForm.duration" placeholder="请输入时长" />
</el-form-item> </el-form-item>
<el-form-item label="金额" prop="price"> <el-form-item label="金额" prop="price">
<el-input v-model="packFrom.price" placeholder="请输入金额" /> <el-input v-model="packForm.price" placeholder="请输入金额" />
</el-form-item> </el-form-item>
<el-form-item label="套餐开始时段" prop="packaStartPeriod"> <el-form-item label="套餐开始时段" prop="packaStartPeriod">
<el-input v-model="packFrom.packaStartPeriod" placeholder="请输入套餐开始时段" /> <el-input v-model="packForm.packaStartPeriod" placeholder="请输入套餐开始时段" />
</el-form-item> </el-form-item>
<el-form-item label="套餐结束时段" prop="packaEndPeriod"> <el-form-item label="套餐结束时段" prop="packaEndPeriod">
<el-input v-model="packFrom.packaEndPeriod" placeholder="请输入套餐结束时段" /> <el-input v-model="packForm.packaEndPeriod" placeholder="请输入套餐结束时段" />
</el-form-item> </el-form-item>
<el-form-item label="备注" prop="remark"> <el-form-item label="备注" prop="remark">
<el-input v-model="packFrom.remark" type="textarea" placeholder="请输入内容" /> <el-input v-model="packForm.remark" type="textarea" placeholder="请输入内容" />
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button> <el-button type="primary" @click="submitPackForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button> <el-button @click="packCancel">取 消</el-button>
</div> </div>
</el-dialog> </el-dialog>
...@@ -265,7 +265,7 @@ ...@@ -265,7 +265,7 @@
<script> <script>
import { listRoom, getRoom, delRoom, addRoom, updateRoom } from "@/api/system/room"; import { listRoom, getRoom, delRoom, addRoom, updateRoom } from "@/api/system/room";
import { allList } from '@/api/system/store' import { allList } from '@/api/system/store'
import { query } from '@/api/system/pack' import {insertPack, query} from '@/api/system/pack'
export default { export default {
name: "Room", name: "Room",
...@@ -317,7 +317,7 @@ export default { ...@@ -317,7 +317,7 @@ export default {
}, },
// 表单参数 // 表单参数
form: {}, form: {},
packFrom: {}, packForm: {},
// 表单校验 // 表单校验
rules: { rules: {
storeId: [ storeId: [
...@@ -335,18 +335,12 @@ export default { ...@@ -335,18 +335,12 @@ export default {
created() { created() {
this.onGetAllStoreList() this.onGetAllStoreList()
this.onPackList() this.onPackList()
},
mounted() {
console.log(this.dict)
}, },
methods: { methods: {
onChange(e){ onChange(e){
console.log(e)
this.form.facilities = e.join() this.form.facilities = e.join()
}, },
onChangePackId(e){ onChangePackId(e){
console.log(e)
this.form.packIds = e.join() this.form.packIds = e.join()
}, },
onGetAllStoreList(){ onGetAllStoreList(){
...@@ -367,11 +361,9 @@ export default { ...@@ -367,11 +361,9 @@ export default {
}, },
value: obj.id.toString(), value: obj.id.toString(),
label: obj.name+'-'+'时段'+obj.packaStartPeriod+'-'+obj.packaEndPeriod, label: obj.name+'-'+'时段'+obj.packaStartPeriod+'-'+obj.packaEndPeriod,
} }
}) })
console.log(this.packList,9090999) this.$forceUpdate();
this.getList(); this.getList();
}) })
}, },
...@@ -396,8 +388,13 @@ export default { ...@@ -396,8 +388,13 @@ export default {
this.open = false; this.open = false;
this.reset(); this.reset();
}, },
packCancel() {
this.packOpen = false;
this.packReset();
},
// 表单重置 // 表单重置
reset() { reset() {
this.packIds = []
this.facilities = [] this.facilities = []
this.form = { this.form = {
id: null, id: null,
...@@ -410,6 +407,7 @@ export default { ...@@ -410,6 +407,7 @@ export default {
info: null, info: null,
status: "0", status: "0",
price: null, price: null,
packIds:'',
doorLockCode: null, doorLockCode: null,
electricControlCode: null, electricControlCode: null,
password: null, password: null,
...@@ -424,7 +422,7 @@ export default { ...@@ -424,7 +422,7 @@ export default {
this.resetForm("form"); this.resetForm("form");
}, },
packReset() { packReset() {
this.packFrom = { this.packForm = {
id: null, id: null,
name: null, name: null,
duration: null, duration: null,
...@@ -437,7 +435,7 @@ export default { ...@@ -437,7 +435,7 @@ export default {
updateTime: null, updateTime: null,
remark: null remark: null
}; };
this.resetForm("packFrom"); this.resetForm("packForm");
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
...@@ -477,11 +475,7 @@ export default { ...@@ -477,11 +475,7 @@ export default {
this.facilities = this.form.facilities.split(",") this.facilities = this.form.facilities.split(",")
} }
if(this.form.packIds){ if(this.form.packIds){
//字符串转数字 this.packIds = this.form.packIds.split(",").map(item=>Number(item))
var int = this.form.packIds.split(",")
this.packIds = int.map((item) => {
return Number(item);
});
} }
this.open = true; this.open = true;
this.title = "修改房间"; this.title = "修改房间";
...@@ -492,14 +486,17 @@ export default { ...@@ -492,14 +486,17 @@ export default {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
if (this.form.id != null) { if (this.form.id != null) {
if(this.packIds.length){
this.form.packIds = this.packIds.join();
}
updateRoom(this.form).then(response => { updateRoom(this.form).then(response => {
this.$modal.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
} else { } else {
if(this.form.packIds){ if(this.packIds.length){
this.packIds = this.form.packIds.split(",") this.form.packIds = this.packIds.join();
} }
addRoom(this.form).then(response => { addRoom(this.form).then(response => {
this.$modal.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
...@@ -525,7 +522,21 @@ export default { ...@@ -525,7 +522,21 @@ export default {
this.download('system/room/export', { this.download('system/room/export', {
...this.queryParams ...this.queryParams
}, `room_${new Date().getTime()}.xlsx`) }, `room_${new Date().getTime()}.xlsx`)
} },
submitPackForm() {
this.$refs["packForm"].validate(valid => {
if (valid) {
insertPack(this.packForm).then(response => {
this.$modal.msgSuccess("新增成功");
this.packOpen = false;
this.onPackList();
this.$nextTick(() => {
this.packIds.push(response.data)
});
});
}
});
},
} }
}; };
</script> </script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment