You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zhishifufei_php/application/merchant/view/kefu/_speechcraft/add_speech.php

93 lines
3.4 KiB

9 months ago
{extend name="public/container"}
{block name='head_top'}
<style>
</style>
{/block}
{block name='content'}
<div class="layui-fluid">
<div class="layui-card">
<div class="layui-card-body">
<form class="layui-form" id="form">
<div class="layui-form-item required">
<label class="layui-form-label">话术分类:</label>
<div class="layui-input-block">
<select name="cate_id">
{volist name="cate" id="vo"}
<option value="{$vo.id}" {if condition="$vo.id == $speech.cate_id"}selected{/if}>{$vo.name}</option>
{/volist}
</select>
</div>
</div>
<div class="layui-form-item required">
<label class="layui-form-label">话术标题:</label>
<div class="layui-input-block">
<input type="text" name="title" autocomplete="off" placeholder="请输入话术标题" maxlength="30" class="layui-input" value="{$speech.title}">
</div>
</div>
<div class="layui-form-item required">
<label class="layui-form-label">话术内容:</label>
<div class="layui-input-block">
<textarea name="message" autocomplete="off" placeholder="请输入话术内容" class="layui-textarea">{$speech.message}</textarea>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">排序:</label>
<div class="layui-input-inline">
<input type="number" name="sort" autocomplete="off" min="0" class="layui-input" step="1" value="{$speech.sort}">
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button type="submit" class="layui-btn layui-btn-normal">提交</button>
</div>
</div>
</form>
</div>
</div>
</div>
<script type="text/javascript" src="{__ADMIN_PATH}js/layuiList.js"></script>
{/block}
{block name='script'}
<script>
layList.form.render();
$("#form").submit((e) => {
e.preventDefault();
const title = e.target.title.value.trim();
const message = e.target.message.value.trim();
const cate_id = e.target.cate_id.value;
const sort = e.target.sort.value;
const loadIdx = layer.load(1);
$.ajax({
method: "POST",
url: "{:Url('save_speech', [ 'id' => $id ])}",
data: {
title,
message,
cate_id,
sort
},
dataType: "json",
success(res) {
layer.close(loadIdx);
if (res.code === 200) {
layer.msg(res.msg, () => {
const index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
});
} else {
layer.msg(res.msg);
}
},
error(err) {
layer.close(loadIdx);
console.log(err);
layer.msg(err.msg);
}
});
});
</script>
{/block}