159 lines
6.2 KiB
PHP
Executable File
159 lines
6.2 KiB
PHP
Executable File
<form id="vue-app" 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-inline w150">
|
|
<select name="status" v-model="info.brand_id">
|
|
<option value="">请选择</option>
|
|
<option :value="v.id" v-for="(v,i) in brandAry">{{v.name}}</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="am-form-group">
|
|
<label class="am-para-label">车系:</label>
|
|
<div class="am-para-input w200">
|
|
<select v-model="info.s_id">
|
|
<option value="">请选择</option>
|
|
<option v-for="item in seryAry" :value="item.id">
|
|
{{item.name}}
|
|
</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="am-form-group">
|
|
<label class="am-para-label">类型:</label>
|
|
<div class="am-para-input w200">
|
|
<select v-model="info.type">
|
|
<option v-for="(item,index) in type_arr" :value="index">
|
|
{{item}}
|
|
</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<!--颜色-->
|
|
<template v-if="info.type==0">
|
|
<div class="am-form-group">
|
|
<label class="am-para-label">图片:</label>
|
|
<div class="am-para-input">
|
|
<div class="am-form-group am-form-file">
|
|
<button type="button" class="am-btn am-btn-default am-btn-sm"
|
|
data-file="1" data-type="jpg,png,gif,png,jpeg"
|
|
data-uptype="qiniu" data-field="img"><i class="am-icon-cloud-upload"></i> 选择要上传的文件
|
|
</button>
|
|
<input type="hidden" name="img" class="layui-input" value="" id="value_img">
|
|
<img data-tips-image style="height:auto;max-height:32px;max-width:32px"
|
|
:src="info.jsondata.s_img"/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="am-form-group">
|
|
<label class="am-para-label">颜色代码:</label>
|
|
<div class="am-para-input w200">
|
|
<input type="text" placeholder="输入颜色代码" name="" v-model="info.jsondata.code">
|
|
<span>(例如:#fff)</span>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
<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 () {
|
|
vue_obj = new Vue({
|
|
el: '#vue-app',
|
|
data: {
|
|
info:[],
|
|
brandAry:[],
|
|
seryAry:[],
|
|
type_arr:[]
|
|
},
|
|
mounted: function () {
|
|
this.info = <?=json_encode($info)?>;
|
|
this.type_arr = <?=json_encode($type_arr)?>;
|
|
this.init_brands();
|
|
},
|
|
methods: {
|
|
init_brands:function(){
|
|
var vm = this;
|
|
$.ajax({
|
|
url: '/auto/brand/json_lists',
|
|
type: 'post',
|
|
dataType: 'json',
|
|
data: {status:1},
|
|
beforeSend: function () {},
|
|
success: function (data) {
|
|
if (1 == data.code) {
|
|
vm.brandAry = data.data.list;
|
|
}
|
|
},
|
|
complete: function () {}
|
|
});
|
|
},
|
|
saveEdit: function(){
|
|
var action = '';
|
|
if(this.info.id){
|
|
action = 'auto/attr/edit'
|
|
}else{
|
|
action = 'auto/attr/add'
|
|
}
|
|
var img = $("#value_img").val();
|
|
if(img){
|
|
this.info.jsondata.img = $("#value_img").val();
|
|
}
|
|
$.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;
|
|
vm.seryAry = lists;
|
|
var s_id = '';
|
|
for(var i in lists){
|
|
var sery = lists[i];
|
|
if(vm.info.s_id == sery.id){
|
|
s_id = vm.info.s_id;
|
|
break;
|
|
}
|
|
}
|
|
vm.info.s_id = s_id;
|
|
}
|
|
},
|
|
complete: function () {
|
|
loading = 0;
|
|
layer.closeAll('loading');
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
})
|
|
});
|
|
</script>
|