修复礼物编辑回显

This commit is contained in:
liaozetao
2024-01-30 12:44:04 +08:00
parent 33b4714552
commit c125c1ad54
2 changed files with 67 additions and 31 deletions

View File

@@ -18,7 +18,7 @@ export default {
setDef: function (idstr, defval) { setDef: function (idstr, defval) {
for (let i = 0, len = $(idstr + ' option').length; i < len; i++) { for (let i = 0, len = $(idstr + ' option').length; i < len; i++) {
let $option = $(idstr + ' option:eq(' + i + ')'); let $option = $(idstr + ' option:eq(' + i + ')');
if ($option.val() == defval) { if ($option && $option.val() == defval) {
$option.prop('selected', true); $option.prop('selected', true);
} else { } else {
$option.prop('selected', false); $option.prop('selected', false);

View File

@@ -211,14 +211,14 @@
<div class="form-group" v-if="gift.subGiftType == 1"> <div class="form-group" v-if="gift.subGiftType == 1">
<label for="baseGiftId" class="col-sm-3 control-label">需要的基础解锁礼物</label> <label for="baseGiftId" class="col-sm-3 control-label">需要的基础解锁礼物</label>
<div class="col-sm-8"> <div class="col-sm-8">
<select name="baseGiftId" id="baseGiftId" data-btn-class="btn-warning" class="form-control"> <select name="baseGiftId" id="baseGiftId" data-btn-class="btn-warning" class="form-control" v-model="gift.baseGiftId">
</select> </select>
</div> </div>
</div> </div>
<div class="form-group" v-if="gift.subGiftType == 1"> <div class="form-group" v-if="gift.subGiftType == 1">
<label for="unlockNum" class="col-sm-3 control-label">需要的该基础礼物个数</label> <label for="unlockNum" class="col-sm-3 control-label">需要的该基础礼物个数</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input type="number" class="form-control" name="unlockNum" id="unlockNum" min="1"> <input type="number" class="form-control" name="unlockNum" id="unlockNum" min="1" v-model="gift.unlockNum">
</div> </div>
</div> </div>
</div> </div>
@@ -227,7 +227,7 @@
<div class="form-group"> <div class="form-group">
<label for="sendDressType" class="col-sm-3 control-label">送礼者获得装扮类型</label> <label for="sendDressType" class="col-sm-3 control-label">送礼者获得装扮类型</label>
<div class="col-sm-8"> <div class="col-sm-8">
<select name="sendDressType" id="sendDressType" data-btn-class="btn-warning" class="form-control" @change="changeDressType('send')"> <select name="sendDressType" id="sendDressType" data-btn-class="btn-warning" class="form-control" @change="changeDressType('send')" v-model="gift.sendDressType">
<option value=""></option> <option value=""></option>
<option value="HEADWEAR">头像装饰</option> <option value="HEADWEAR">头像装饰</option>
<option value="CHATBUBBLE">气泡装饰</option> <option value="CHATBUBBLE">气泡装饰</option>
@@ -246,13 +246,13 @@
<div class="form-group"> <div class="form-group">
<label for="sendDressTime" class="col-sm-3 control-label">送礼者获得装扮时长</label> <label for="sendDressTime" class="col-sm-3 control-label">送礼者获得装扮时长</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input type="number" class="form-control" name="sendDressTime" id="sendDressTime" min="1"> <input type="number" class="form-control" name="sendDressTime" id="sendDressTime" min="1" v-model="gift.sendDressTime">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="receiveDressType" class="col-sm-3 control-label">收礼者获得装扮类型</label> <label for="receiveDressType" class="col-sm-3 control-label">收礼者获得装扮类型</label>
<div class="col-sm-8"> <div class="col-sm-8">
<select name="receiveDressType" id="receiveDressType" data-btn-class="btn-warning" class="form-control" @change="changeDressType('receive')"> <select name="receiveDressType" id="receiveDressType" data-btn-class="btn-warning" class="form-control" @change="changeDressType('receive')" v-model="gift.receiveDressType">
<option value=""></option> <option value=""></option>
<option value="HEADWEAR">头像装饰</option> <option value="HEADWEAR">头像装饰</option>
<option value="CHATBUBBLE">气泡装饰</option> <option value="CHATBUBBLE">气泡装饰</option>
@@ -271,15 +271,15 @@
<div class="form-group"> <div class="form-group">
<label for="receiveDressTime" class="col-sm-3 control-label">收礼者获得装扮时长</label> <label for="receiveDressTime" class="col-sm-3 control-label">收礼者获得装扮时长</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input type="number" class="form-control" name="receiveDressTime" id="receiveDressTime" min="1"> <input type="number" class="form-control" name="receiveDressTime" id="receiveDressTime" min="1" v-model="gift.receiveDressTime">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="dressBanner" class="col-sm-3 control-label">礼物介绍banner</label> <label for="dressBanner" class="col-sm-3 control-label">礼物介绍banner</label>
<div class="col-sm-8"> <div class="col-sm-8">
<img src="" id="dressBannerImage" style="width:250px;height:90px;" alt=""> <img :src="gift.dressBanner" id="dressBannerImage" style="width:250px;height:90px;" alt="">
<input type="file" id="dressBannerFile" name="uploadFile"/> <input type="file" id="dressBannerFile" name="uploadFile"/>
<input type="hidden" id="dressBanner" name="dressBanner" class="form-control validate[required]" /> <input type="hidden" id="dressBanner" name="dressBanner" class="form-control" v-model="gift.dressBanner"/>
<span class="btn col-sm-4" id="dressBannerUploadInfo" style="color:red;"></span> <span class="btn col-sm-4" id="dressBannerUploadInfo" style="color:red;"></span>
</div> </div>
</div> </div>
@@ -292,7 +292,7 @@
<div class="form-group"> <div class="form-group">
<label for="bannerSkipUrl" class="col-sm-3 control-label">礼物介绍banner跳转</label> <label for="bannerSkipUrl" class="col-sm-3 control-label">礼物介绍banner跳转</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input type="text" class="form-control" name="bannerSkipUrl" id="bannerSkipUrl"> <input type="text" class="form-control" name="bannerSkipUrl" id="bannerSkipUrl" v-model="gift.bannerSkipUrl">
</div> </div>
</div> </div>
</div> </div>
@@ -696,6 +696,16 @@ export default {
giftId: null, giftId: null,
giftType: 2, giftType: 2,
subGiftType: 0, subGiftType: 0,
baseGiftId: null,
unlockNum: 0,
sendDressType: '',
sendDressId: null,
sendDressTime: 0,
receiveDressType: '',
receiveDressId: null,
receiveDressTime: 0,
dressBanner: '',
bannerSkipUrl: '',
}, },
}; };
}, },
@@ -742,7 +752,9 @@ export default {
methods: { methods: {
changeDressType(type) { changeDressType(type) {
let options = []; let options = [];
let dressType = $('#' + type + 'DressType').val(); console.log(type);
let dressType = this.gift[type + 'DressType'];
console.log(dressType);
if (dressType == 'NAMEPLATE') { if (dressType == 'NAMEPLATE') {
$.ajax({ $.ajax({
type: "get", type: "get",
@@ -822,23 +834,27 @@ export default {
} }
let $dressId = $('#' + type + 'DressId'); let $dressId = $('#' + type + 'DressId');
let dressId = $('#' + type + 'DressIdBak').val(); let dressId = $('#' + type + 'DressIdBak').val();
console.log(dressId);
$dressId.children().remove(); $dressId.children().remove();
console.log(options); console.log(options);
if (options.length > 0) { setTimeout(() => {
for (let j = 0; j < options.length; j++) { if (options.length > 0) {
var option = options[j]; for (let j = 0; j < options.length; j++) {
var $option = $('<option/>'); var option = options[j];
$option.attr('value', option.value); var $option = $('<option/>');
$option.attr('data-id', option.value); $option.attr('value', option.value);
$option.attr('data-name', option.text); $option.attr('data-id', option.value);
if (dressId && dressId == option.value) { $option.attr('data-name', option.text);
$option.attr('selected', true); if (dressId && dressId == option.value) {
$option.attr('selected', true);
}
$option.html(option.text);
$dressId.append($option);
} }
$option.html(option.text); ComboboxHelper.build(options, '#' + type + 'DressId', dressId);
$dressId.append($option);
} }
ComboboxHelper.build(options, '#' + type + 'DressId', dressId); }, 1000);
}
}, },
giftUnlockList() { giftUnlockList() {
getGiftUnlockList().then(res => { getGiftUnlockList().then(res => {
@@ -849,7 +865,7 @@ export default {
value: e.giftId, value: e.giftId,
}; };
}); });
ComboboxHelper.setDef(lockGifts, '#baseGiftId', null); ComboboxHelper.build(lockGifts, '#baseGiftId', null);
}); });
}, },
levelList() { levelList() {
@@ -1134,6 +1150,8 @@ export default {
$this.gift.giftId = null; $this.gift.giftId = null;
$this.gift.giftType = 2; $this.gift.giftType = 2;
$this.gift.subGiftType = 0; $this.gift.subGiftType = 0;
$this.gift.sendDressType = '';
$this.gift.receiveDressType = '';
$("#giftForm")[0].reset(); $("#giftForm")[0].reset();
$('#picUrl').val(''); $('#picUrl').val('');
$('#picImage').attr("src", ''); $('#picImage').attr("src", '');
@@ -1428,6 +1446,7 @@ export default {
url: "/admin/gift/get.action", url: "/admin/gift/get.action",
data: { id: id }, data: { id: id },
dataType: "json", dataType: "json",
async: false,
success: function (json) { success: function (json) {
let entity = json.entity; let entity = json.entity;
if (json.roomFreeGiftConfig) { if (json.roomFreeGiftConfig) {
@@ -1438,6 +1457,18 @@ export default {
$("#resetTimeCron").val(json.roomFreeGiftConfig.resetTimeCron); $("#resetTimeCron").val(json.roomFreeGiftConfig.resetTimeCron);
} }
if (json.entity) { if (json.entity) {
$this.gift.giftId = entity.giftId;
$this.gift.giftType = entity.giftType;
$this.gift.subGiftType = entity.subGiftType;
$this.gift.baseGiftId = entity.baseGiftId;
$this.gift.sendDressType = entity.sendDressType;
$this.gift.sendDressId = entity.sendDressId;
$this.gift.sendDressTime = entity.sendDressTime;
$this.gift.receiveDressType = entity.receiveDressType;
$this.gift.receiveDressId = entity.receiveDressId;
$this.gift.receiveDressTime = entity.receiveDressTime;
$this.gift.dressBanner = entity.dressBanner;
$this.gift.bannerSkipUrl = entity.bannerSkipUrl;
$("#giftId").val(json.entity.giftId); $("#giftId").val(json.entity.giftId);
$("#giftName").val(json.entity.giftName); $("#giftName").val(json.entity.giftName);
$("#goldPrice").val(json.entity.goldPrice); $("#goldPrice").val(json.entity.goldPrice);
@@ -1532,15 +1563,12 @@ export default {
$('#subGiftType').val(entity.subGiftType); $('#subGiftType').val(entity.subGiftType);
$('#baseGiftId').val(entity.baseGiftId); $('#baseGiftId').val(entity.baseGiftId);
$('#unlockNum').val(entity.unlockNum); $('#unlockNum').val(entity.unlockNum);
$this.gift.giftId = entity.giftId;
$this.gift.giftType = entity.giftType;
$this.gift.subGiftType = entity.subGiftType;
$('#sendDressType').val(entity.sendDressType); $('#sendDressType').val(entity.sendDressType);
$('#sendDressId').val(entity.sendDressId); $('#sendDressId').val(entity.sendDressId);
$('#sendDressTime').val(entity.sendDressTime); $('#sendDressTime').val(entity.sendDressTime);
$('#receiveDressType').val(entity.receiveDressType); $('#receiveDressType').val(entity.receiveDressType);
$('#receiveDressId').val(entity.receiveDressId); $('#receiveDressId').val(entity.receiveDressId);
$('#receiveDressTime').val(entity.receiveDressTime); $('#receiveDressTime').val(entity.receiveDressTime);
$("#dressBannerFile").val(''); $("#dressBannerFile").val('');
$('#dressBanner').val(entity.dressBanner); $('#dressBanner').val(entity.dressBanner);
$('#dressBannerImage').attr("src", entity.dressBanner); $('#dressBannerImage').attr("src", entity.dressBanner);
@@ -1549,9 +1577,19 @@ export default {
} else { } else {
$("#dressBannerUploadInfo").html('未上传'); $("#dressBannerUploadInfo").html('未上传');
} }
$("#giftTagFile").val('');
$('#giftTag').val(entity.giftTag);
$('#giftTagImage').attr("src", entity.giftTag);
if (entity.giftTag != null && entity.giftTag != 'undefined' && entity.giftTag != '') {
$("#giftTagUploadInfo").html('已上传');
} else {
$("#giftTagUploadInfo").html('未上传');
}
$('#bannerSkipUrl').val(entity.bannerSkipUrl); $('#bannerSkipUrl').val(entity.bannerSkipUrl);
$('#sendDressIdBak').val(entity.sendDressId); $('#sendDressIdBak').val(entity.sendDressId);
$('#receiveDressIdBak').val(entity.receiveDressId); $('#receiveDressIdBak').val(entity.receiveDressId);
// 打开编辑弹窗
$("#giftModal").modal('show');
if (entity.giftType == 16) { if (entity.giftType == 16) {
$('#giftType').attr('disabled', 'disabled'); $('#giftType').attr('disabled', 'disabled');
$('#subGiftType').attr('disabled', 'disabled'); $('#subGiftType').attr('disabled', 'disabled');
@@ -1561,8 +1599,6 @@ export default {
$this.changeDressType('send'); $this.changeDressType('send');
$this.changeDressType('receive'); $this.changeDressType('receive');
} }
// 打开编辑弹窗
$("#giftModal").modal('show');
} else { } else {
$("#tipMsg").text("获取菜单信息出错"); $("#tipMsg").text("获取菜单信息出错");
$("#tipModal").modal('show'); $("#tipModal").modal('show');