feat: app
This commit is contained in:
@@ -208,16 +208,16 @@ layui.use(['table', 'form', 'layer'], function () {
|
|||||||
'</select></div></div>'
|
'</select></div></div>'
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
// Channel ID block: App=auto UUID (readonly); old=auto 32-hex (readonly); new=X.Y.ZZ input
|
// Channel ID block: App=UUID (blank=auto); old=32-hex (blank=auto); new=X.Y.ZZ input
|
||||||
var isOld = values.builder_type === 'old';
|
var isOld = values.builder_type === 'old';
|
||||||
var channelBlock = creating
|
var channelBlock = creating
|
||||||
? (isApp
|
? (isApp
|
||||||
? '<div class="layui-form-item"><label class="layui-form-label">渠道 ID</label><div class="layui-input-block">' +
|
? '<div class="layui-form-item"><label class="layui-form-label">渠道 ID</label><div class="layui-input-block">' +
|
||||||
'<input name="channel_id" class="layui-input" readonly id="LAY-ch-id-input" value="' + (values.channel_id || '') + '" placeholder="自动生成 UUID">' +
|
'<input name="channel_id" class="layui-input" maxlength="64" id="LAY-ch-id-input" style="width:70%;display:inline-block;" value="' + (values.channel_id || '') + '" placeholder="留空自动生成 UUID">' +
|
||||||
'<button type="button" class="layui-btn layui-btn-primary" id="LAY-ch-rand" style="margin-left:6px;">随机</button></div></div>'
|
'<button type="button" class="layui-btn layui-btn-primary" id="LAY-ch-rand" style="margin-left:6px;">随机</button></div></div>'
|
||||||
: (isOld
|
: (isOld
|
||||||
? '<div class="layui-form-item"><label class="layui-form-label">渠道 ID</label><div class="layui-input-block">' +
|
? '<div class="layui-form-item"><label class="layui-form-label">渠道 ID</label><div class="layui-input-block">' +
|
||||||
'<input name="channel_id" class="layui-input" readonly id="LAY-ch-id-input" style="width:70%;display:inline-block;" value="' + (values.channel_id || '') + '" placeholder="自动生成 32 位 hex">' +
|
'<input name="channel_id" class="layui-input" maxlength="64" id="LAY-ch-id-input" style="width:70%;display:inline-block;" value="' + (values.channel_id || '') + '" placeholder="留空自动生成 32 位 hex">' +
|
||||||
'<button type="button" class="layui-btn layui-btn-primary" id="LAY-ch-rand" style="margin-left:6px;">随机</button></div></div>'
|
'<button type="button" class="layui-btn layui-btn-primary" id="LAY-ch-rand" style="margin-left:6px;">随机</button></div></div>'
|
||||||
: '<div class="layui-form-item"><label class="layui-form-label">渠道 ID</label><div class="layui-input-block">' +
|
: '<div class="layui-form-item"><label class="layui-form-label">渠道 ID</label><div class="layui-input-block">' +
|
||||||
'<input name="channel_id" class="layui-input" maxlength="6" id="LAY-ch-id-input" style="width:70%;display:inline-block;" value="' + (values.channel_id || '') + '" placeholder="例如 A.B.C1 或 3.1.07">' +
|
'<input name="channel_id" class="layui-input" maxlength="6" id="LAY-ch-id-input" style="width:70%;display:inline-block;" value="' + (values.channel_id || '') + '" placeholder="例如 A.B.C1 或 3.1.07">' +
|
||||||
@@ -262,7 +262,7 @@ layui.use(['table', 'form', 'layer'], function () {
|
|||||||
if (res.code === 0) $('#LAY-ch-form input[name=channel_id]').val(res.data.channel_id);
|
if (res.code === 0) $('#LAY-ch-form input[name=channel_id]').val(res.data.channel_id);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
// Auto-generate UUID when switching to App; 32-hex when switching to Old
|
// Update channel ID input hints when switching builder type (blank = auto-generate)
|
||||||
form.on('select(LAY-ch-builder-type)', function (data) {
|
form.on('select(LAY-ch-builder-type)', function (data) {
|
||||||
var v = data.value;
|
var v = data.value;
|
||||||
var isAppNow = v === 'app';
|
var isAppNow = v === 'app';
|
||||||
@@ -271,21 +271,11 @@ layui.use(['table', 'form', 'layer'], function () {
|
|||||||
$('.LAY-ch-new-only').toggle(!isAppNow); // template shown for new + old
|
$('.LAY-ch-new-only').toggle(!isAppNow); // template shown for new + old
|
||||||
var idInput = $('#LAY-ch-id-input');
|
var idInput = $('#LAY-ch-id-input');
|
||||||
if (isAppNow) {
|
if (isAppNow) {
|
||||||
idInput.attr('readonly', true).attr('maxlength', '').attr('placeholder', '自动生成 UUID');
|
idInput.attr('maxlength', '').attr('placeholder', '留空自动生成 UUID');
|
||||||
if (!idInput.val()) {
|
|
||||||
$.getJSON(@json(route('admin.channels.randomId')) + '?builder_type=app', function (res) {
|
|
||||||
if (res.code === 0) idInput.val(res.data.channel_id);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if (isOldNow) {
|
} else if (isOldNow) {
|
||||||
idInput.attr('readonly', true).attr('maxlength', '').attr('placeholder', '自动生成 32 位 hex');
|
idInput.attr('maxlength', '').attr('placeholder', '留空自动生成 32 位 hex');
|
||||||
if (!idInput.val()) {
|
|
||||||
$.getJSON(@json(route('admin.channels.randomId')) + '?builder_type=old', function (res) {
|
|
||||||
if (res.code === 0) idInput.val(res.data.channel_id);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
idInput.removeAttr('readonly').attr('maxlength', '6').attr('placeholder', '例如 A.B.C1 或 3.1.07').val('');
|
idInput.attr('maxlength', '6').attr('placeholder', '例如 A.B.C1 或 3.1.07').val('');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -310,7 +300,7 @@ layui.use(['table', 'form', 'layer'], function () {
|
|||||||
CorunaFilterOptions.apply(form);
|
CorunaFilterOptions.apply(form);
|
||||||
}
|
}
|
||||||
table.reload('LAY-ch-list');
|
table.reload('LAY-ch-list');
|
||||||
showCreateResult(res, data.channel_id);
|
showCreateResult(res, data.channel_id || (res.data && res.data.channel_id) || '');
|
||||||
},
|
},
|
||||||
error: function (xhr) {
|
error: function (xhr) {
|
||||||
layer.close(load);
|
layer.close(load);
|
||||||
|
|||||||
Reference in New Issue
Block a user