114 lines
4.6 KiB
PHP
Executable File
114 lines
4.6 KiB
PHP
Executable File
<form id="vue-app-edit" class="am-form am-form-horizontal" action="" data-auto="true" method="post" style="width: 90%;padding-top: 10px">
|
|
<div class="am-form-group">
|
|
<label class="am-para-label">标题:</label>
|
|
<div class="am-para-input">
|
|
<input type="text" placeholder="输入标题" name="title" v-model="info.title">
|
|
</div>
|
|
</div>
|
|
<div class="am-form-group">
|
|
<label class="am-para-label">品牌车系:</label>
|
|
<div class="am-para-input">
|
|
<select name="brand_id" v-model="info.brand_id" style="display: inline; width: 120px;">
|
|
<option value="0">请选择</option>
|
|
<option :value="i" v-for="(v,i) in brandAry">{{v}}</option>
|
|
</select>
|
|
<select name="s_id" v-model="info.s_id" style="display: inline; width: 120px;">
|
|
<option value="0">请选择</option>
|
|
<option :value="i" v-for="(v,i) in seryAry">{{v}}</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="am-form-group">
|
|
<label class="am-para-label">价格:</label>
|
|
<div class="am-para-input w150">
|
|
<input type="text" placeholder="输入价格" name="number" v-model="info.price">
|
|
</div>
|
|
</div>
|
|
<div class="am-form-group">
|
|
<label class="am-para-label">描述:</label>
|
|
<div class="am-para-input">
|
|
<textarea name="content" id="editor" v-model="info.descrip"></textarea>
|
|
</div>
|
|
</div>
|
|
<div class="am-form-group" style="margin-bottom: 2rem">
|
|
<div class="am-para-input">
|
|
<button class="am-btn am-btn-secondary" type="button" @click="saveEdit()">保存</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
<script>
|
|
$(document).ready(function () {
|
|
require(['ckeditor'], function (ckeditor) {
|
|
window.createEditor('[name="content"]');
|
|
});
|
|
vue_obj = new Vue({
|
|
el: '#vue-app-edit',
|
|
data: {
|
|
brandAry: [],
|
|
info:[],
|
|
seryAry: [],
|
|
},
|
|
mounted: function () {
|
|
this.info = <?=json_encode($info,JSON_UNESCAPED_UNICODE)?>;
|
|
this.brandAry = <?=json_encode($brandAry,JSON_UNESCAPED_UNICODE)?>;
|
|
},
|
|
methods: {
|
|
saveEdit: function(){
|
|
var action = '';
|
|
this.info.descrip = CKEDITOR.instances.editor.getData();
|
|
if(this.info.id){
|
|
action = 'auto/options/edit'
|
|
}else{
|
|
action = 'auto/options/add'
|
|
}
|
|
$.post(action,this.info,function(result){
|
|
if (result.code) {
|
|
layer.msg(result.msg, {time: 2000, icon: 1}, function () {
|
|
$.form.reload();
|
|
});
|
|
} else {
|
|
layer.msg(result.msg, {icon: 2});
|
|
}
|
|
},'json')
|
|
}
|
|
},
|
|
watch: {
|
|
'info.brand_id': function (nv, ov) {
|
|
var vm = this;
|
|
vm.seryAry = {};
|
|
if (nv > 0) {
|
|
$.ajax({
|
|
url: '/auto/series/json_lists',
|
|
type: 'post',
|
|
dataType: 'json',
|
|
data: {brand_id: nv},
|
|
beforeSend: function () {
|
|
},
|
|
success: function (data) {
|
|
if (1 == data.code) {
|
|
var lists = data.data.list;
|
|
var seryAry = {};
|
|
for (var i in lists) {
|
|
var row = lists[i];
|
|
seryAry[row.id] = row.name;
|
|
}
|
|
vm.seryAry = seryAry;
|
|
if (vm.info.s_id > 0 && undefined == seryAry[vm.info.s_id]) {
|
|
vm.info.s_id = '';
|
|
}
|
|
}
|
|
},
|
|
complete: function () {
|
|
loading = 0;
|
|
layer.closeAll('loading');
|
|
}
|
|
});
|
|
} else {
|
|
vm.params.s_id = '';
|
|
}
|
|
}
|
|
}
|
|
})
|
|
});
|
|
</script>
|