hupeng
5 years ago
15 changed files with 706 additions and 208 deletions
@ -0,0 +1,131 @@
|
||||
<template> |
||||
<div class="app-container"> |
||||
<!--工具栏--> |
||||
<div class="head-container"> |
||||
<!-- 新增 --> |
||||
<div style="display: inline-block;margin: 0px 2px;"> |
||||
<el-button |
||||
v-permission="['admin','YXSYSTEMGROUPDATA_ALL','YXSYSTEMGROUPDATA_CREATE']" |
||||
class="filter-item" |
||||
size="mini" |
||||
type="primary" |
||||
icon="el-icon-plus" |
||||
@click="add" |
||||
>新增</el-button> |
||||
</div> |
||||
</div> |
||||
<!--表单组件--> |
||||
<eForm ref="form" :is-add="isAdd" /> |
||||
<!--表格渲染--> |
||||
<el-table v-loading="loading" :data="data" size="small" style="width: 100%;"> |
||||
<el-table-column prop="id" label="ID" /> |
||||
<el-table-column prop="map.price" label="额度" /> |
||||
<el-table-column prop="map.give_price" label="赠送" /> |
||||
<el-table-column prop="sort" label="排序" /> |
||||
<el-table-column label="状态" align="center"> |
||||
<template slot-scope="scope"> |
||||
<div> |
||||
<el-tag v-if="scope.row.status === 1" style="cursor: pointer" :type="''">显示</el-tag> |
||||
<el-tag v-else style="cursor: pointer" :type=" 'info' ">不显示</el-tag> |
||||
</div> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column v-if="checkPermission(['admin','YXSYSTEMGROUPDATA_ALL','YXSYSTEMGROUPDATA_EDIT','YXSYSTEMGROUPDATA_DELETE'])" label="操作" width="150px" align="center"> |
||||
<template slot-scope="scope"> |
||||
<el-button v-permission="['admin','YXSYSTEMGROUPDATA_ALL','YXSYSTEMGROUPDATA_EDIT']" size="mini" type="primary" icon="el-icon-edit" @click="edit(scope.row)" /> |
||||
<el-popover |
||||
:ref="scope.row.id" |
||||
v-permission="['admin','YXSYSTEMGROUPDATA_ALL','YXSYSTEMGROUPDATA_DELETE']" |
||||
placement="top" |
||||
width="180" |
||||
> |
||||
<p>确定删除本条数据吗?</p> |
||||
<div style="text-align: right; margin: 0"> |
||||
<el-button size="mini" type="text" @click="$refs[scope.row.id].doClose()">取消</el-button> |
||||
<el-button :loading="delLoading" type="primary" size="mini" @click="subDelete(scope.row.id)">确定</el-button> |
||||
</div> |
||||
<el-button slot="reference" type="danger" icon="el-icon-delete" size="mini" /> |
||||
</el-popover> |
||||
</template> |
||||
</el-table-column> |
||||
</el-table> |
||||
<!--分页组件--> |
||||
<el-pagination |
||||
:total="total" |
||||
:current-page="page + 1" |
||||
style="margin-top: 8px;" |
||||
layout="total, prev, pager, next, sizes" |
||||
@size-change="sizeChange" |
||||
@current-change="pageChange" |
||||
/> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import checkPermission from '@/utils/permission' |
||||
import initData from '@/mixins/crud' |
||||
import { del } from '@/api/yxSystemGroupData' |
||||
import eForm from './rechargeform' |
||||
export default { |
||||
components: { eForm }, |
||||
mixins: [initData], |
||||
data() { |
||||
return { |
||||
delLoading: false |
||||
} |
||||
}, |
||||
created() { |
||||
this.$nextTick(() => { |
||||
this.init() |
||||
}) |
||||
}, |
||||
methods: { |
||||
checkPermission, |
||||
beforeInit() { |
||||
this.url = 'api/yxSystemGroupData' |
||||
const sort = 'id,desc' |
||||
this.params = { page: this.page, size: this.size, sort: sort, groupName: 'recharge_price_ways' } |
||||
return true |
||||
}, |
||||
subDelete(id) { |
||||
this.delLoading = true |
||||
del(id).then(res => { |
||||
this.delLoading = false |
||||
this.$refs[id].doClose() |
||||
this.dleChangePage() |
||||
this.init() |
||||
this.$notify({ |
||||
title: '删除成功', |
||||
type: 'success', |
||||
duration: 2500 |
||||
}) |
||||
}).catch(err => { |
||||
this.delLoading = false |
||||
this.$refs[id].doClose() |
||||
console.log(err.response.data.message) |
||||
}) |
||||
}, |
||||
add() { |
||||
this.isAdd = true |
||||
this.$refs.form.dialog = true |
||||
}, |
||||
edit(data) { |
||||
this.isAdd = false |
||||
const _this = this.$refs.form |
||||
_this.form = { |
||||
id: data.id, |
||||
groupName: data.groupName, |
||||
day: data.map.day, |
||||
sign_num: data.map.sign_num, |
||||
sort: data.sort, |
||||
status: data.status |
||||
} |
||||
_this.dialog = true |
||||
} |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<style scoped> |
||||
|
||||
</style> |
@ -0,0 +1,110 @@
|
||||
<template> |
||||
<el-dialog :append-to-body="true" :close-on-click-modal="false" :before-close="cancel" :visible.sync="dialog" :title="isAdd ? '新增' : '编辑'" width="500px"> |
||||
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="100px"> |
||||
<el-form-item label="额度"> |
||||
<el-input v-model="form.price" style="width: 300px;" /> |
||||
</el-form-item> |
||||
<el-form-item label="赠送"> |
||||
<el-input v-model="form.give_price" style="width: 300px;" /> |
||||
</el-form-item> |
||||
<el-form-item label="排序"> |
||||
<el-input v-model="form.sort" style="width: 300px;" /> |
||||
</el-form-item> |
||||
<el-form-item label="是否显示"> |
||||
<el-radio v-model="form.status" :label="1">是</el-radio> |
||||
<el-radio v-model="form.status" :label="0" style="width: 200px;">否</el-radio> |
||||
</el-form-item> |
||||
</el-form> |
||||
<div slot="footer" class="dialog-footer"> |
||||
<!--<el-input v-model="form.groupName" />--> |
||||
<el-button type="text" @click="cancel">取消</el-button> |
||||
<el-button :loading="loading" type="primary" @click="doSubmit">确认</el-button> |
||||
</div> |
||||
</el-dialog> |
||||
</template> |
||||
|
||||
<script> |
||||
import { add, edit } from '@/api/yxSystemGroupData' |
||||
import picUpload from '@/components/pic-upload' |
||||
export default { |
||||
components: { picUpload }, |
||||
props: { |
||||
isAdd: { |
||||
type: Boolean, |
||||
required: true |
||||
} |
||||
}, |
||||
data() { |
||||
return { |
||||
loading: false, dialog: false, |
||||
form: { |
||||
id: '', |
||||
groupName: 'recharge_price_ways', |
||||
price: 1, |
||||
give_price: 0, |
||||
sort: 0, |
||||
status: 1 |
||||
}, |
||||
rules: { |
||||
} |
||||
} |
||||
}, |
||||
methods: { |
||||
cancel() { |
||||
this.resetForm() |
||||
}, |
||||
doSubmit() { |
||||
this.loading = true |
||||
if (this.isAdd) { |
||||
this.doAdd() |
||||
} else this.doEdit() |
||||
}, |
||||
doAdd() { |
||||
add(this.form).then(res => { |
||||
this.resetForm() |
||||
this.$notify({ |
||||
title: '添加成功', |
||||
type: 'success', |
||||
duration: 2500 |
||||
}) |
||||
this.loading = false |
||||
this.$parent.init() |
||||
}).catch(err => { |
||||
this.loading = false |
||||
console.log(err.response.data.message) |
||||
}) |
||||
}, |
||||
doEdit() { |
||||
edit(this.form).then(res => { |
||||
this.resetForm() |
||||
this.$notify({ |
||||
title: '修改成功', |
||||
type: 'success', |
||||
duration: 2500 |
||||
}) |
||||
this.loading = false |
||||
this.$parent.init() |
||||
}).catch(err => { |
||||
this.loading = false |
||||
console.log(err.response.data.message) |
||||
}) |
||||
}, |
||||
resetForm() { |
||||
this.dialog = false |
||||
this.$refs['form'].resetFields() |
||||
this.form = { |
||||
id: '', |
||||
groupName: 'recharge_price_ways', |
||||
price: 1, |
||||
give_price: 0, |
||||
sort: 0, |
||||
status: 1 |
||||
} |
||||
} |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<style scoped> |
||||
|
||||
</style> |
@ -0,0 +1,171 @@
|
||||
<template> |
||||
<div class="app-container"> |
||||
<!--工具栏--> |
||||
<div class="head-container"> |
||||
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="150px"> |
||||
<el-form-item label="门店名称" prop="name"> |
||||
<el-input v-model="form.name" style="width: 370px;" /> |
||||
</el-form-item> |
||||
<el-form-item label="门店简介" prop="introduction"> |
||||
<el-input v-model="form.introduction" style="width: 370px;" /> |
||||
</el-form-item> |
||||
<el-form-item label="门店手机" prop="phone"> |
||||
<el-input v-model="form.phone" style="width: 370px;" /> |
||||
</el-form-item> |
||||
<el-form-item label="门店地址" prop="address"> |
||||
<el-input v-model="form.address" style="width: 370px;" /> |
||||
<el-button :loading="loading" size="medium" type="primary" @click="getL(form.address)">获取经纬度</el-button> |
||||
</el-form-item> |
||||
<el-form-item label="门店logo" prop="image"> |
||||
<MaterialList v-model="form.imageArr" style="width: 370px" type="image" :num="1" :width="150" :height="150" /> |
||||
</el-form-item> |
||||
<el-form-item label="纬度" prop="latitude"> |
||||
<el-input v-model="form.latitude" :disabled="true" style="width: 370px;" /> |
||||
</el-form-item> |
||||
<el-form-item label="经度" prop="longitude"> |
||||
<el-input v-model="form.longitude" :disabled="true" style="width: 370px;" /> |
||||
</el-form-item> |
||||
<el-form-item label="核销时效" prop="validTime"> |
||||
<el-date-picker |
||||
@change="getTimeT" |
||||
style="width: 370px;" |
||||
v-model="form.validTimeArr" |
||||
type="daterange" |
||||
range-separator="-" |
||||
start-placeholder="开始日期" |
||||
end-placeholder="结束日期"> |
||||
</el-date-picker> |
||||
</el-form-item> |
||||
<el-form-item label="营业时间" prop="dayTime"> |
||||
<el-time-picker |
||||
@change="getTime" |
||||
style="width: 370px;" |
||||
is-range |
||||
v-model="form.dayTimeArr" |
||||
range-separator="-" |
||||
start-placeholder="开始时间" |
||||
end-placeholder="结束时间" |
||||
placeholder="选择时间范围"> |
||||
</el-time-picker> |
||||
</el-form-item> |
||||
<el-form-item label=""> |
||||
<el-button :loading="loading" size="medium" type="primary" @click="doSubmit">保存配置</el-button> |
||||
</el-form-item> |
||||
</el-form> |
||||
</div> |
||||
</div> |
||||
</template> |
||||
|
||||
|
||||
<script> |
||||
import { get, update, getL } from '@/api/yxSystemStore' |
||||
import MaterialList from '@/components/material' |
||||
import { parseTime } from '@/utils/index' |
||||
export default { |
||||
name: 'YxSystemStore', |
||||
components: { MaterialList }, |
||||
data() { |
||||
return { |
||||
loading: false, |
||||
form: { id:null, name: '', introduction: '', phone: '', address: '', detailedAddress: '', image: '' , |
||||
latitude: '', longitude: '', validTime: '', dayTime: '', validTimeStart: null, validTimeEnd: null, |
||||
dayTimeStart: null, dayTimeEnd: null, dayTimeArr: [new Date(),new Date()], validTimeArr: [], imageArr: []}, |
||||
rules: { |
||||
name: [ |
||||
{ required: true, message: '门店名称不能为空', trigger: 'blur' } |
||||
], |
||||
introduction: [ |
||||
{ required: true, message: '简介不能为空', trigger: 'blur' } |
||||
], |
||||
phone: [ |
||||
{ required: true, message: '手机号码不能为空', trigger: 'blur' } |
||||
], |
||||
address: [ |
||||
{ required: true, message: '省市区不能为空', trigger: 'blur' } |
||||
], |
||||
latitude: [ |
||||
{ required: true, message: '纬度不能为空', trigger: 'blur' } |
||||
], |
||||
longitude: [ |
||||
{ required: true, message: '经度不能为空', trigger: 'blur' } |
||||
], |
||||
validTime: [ |
||||
{ required: true, message: '核销有效日期不能为空', trigger: 'blur' } |
||||
], |
||||
dayTime: [ |
||||
{ required: true, message: '每日营业开关时间不能为空', trigger: 'blur' } |
||||
] |
||||
} |
||||
|
||||
} |
||||
}, |
||||
watch: { |
||||
'form.imageArr': function(val) { |
||||
console.log(222) |
||||
if (val) { |
||||
console.log(val) |
||||
this.form.image = val.join(',') |
||||
} |
||||
} |
||||
}, |
||||
created() { |
||||
this.init() |
||||
}, |
||||
methods: { |
||||
init() { |
||||
get().then(res => { |
||||
if(res.content.length > 0){ |
||||
const con = res.content[0] |
||||
this.form = con |
||||
this.form.imageArr = [con.image] |
||||
|
||||
this.form.dayTimeArr = [con.dayTimeStart,con.dayTimeEnd] |
||||
this.form.validTimeArr = [con.validTimeStart,con.validTimeEnd] |
||||
} |
||||
|
||||
}) |
||||
}, |
||||
doSubmit() { |
||||
this.$refs['form'].validate((valid) => { |
||||
if (valid) { |
||||
this.loading = true |
||||
this.form.image = this.form.imageArr.join(',') |
||||
update(this.form).then(res => { |
||||
this.$notify({ |
||||
title: '保存成功', |
||||
type: 'success', |
||||
duration: 2500 |
||||
}) |
||||
this.loading = false |
||||
}).catch(err => { |
||||
this.loading = false |
||||
console.log(err.response.data.message) |
||||
}) |
||||
} else { |
||||
return false |
||||
} |
||||
}) |
||||
}, |
||||
getTime(t) { |
||||
this.form.dayTimeStart = t[0] |
||||
this.form.dayTimeEnd = t[1] |
||||
this.form.dayTime = parseTime(t[0],'{h}:{i}:{s}') + ' - ' + parseTime(t[1],'{h}:{i}:{s}') |
||||
}, |
||||
getTimeT(t) { |
||||
this.form.validTimeStart = t[0] |
||||
this.form.validTimeEnd = t[1] |
||||
this.form.validTime = parseTime(t[0],'{y}-{m}-{d}') + ' - ' + parseTime(t[1],'{y}-{m}-{d}') |
||||
}, |
||||
getL(addr) { |
||||
getL({addr}).then(res => { |
||||
this.form.latitude = res.result.location.lat |
||||
this.form.longitude = res.result.location.lng |
||||
}) |
||||
} |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<style scoped> |
||||
|
||||
</style> |
Loading…
Reference in new issue