更新停车场配置

feature/0423
Wayne 11 months ago
parent 418a9d9cea
commit 3715f7cb6c
  1. 9
      src/api/store/shop/index.js
  2. 15
      src/views/store/shop/Create.vue
  3. 12
      src/views/store/shop/Index.vue
  4. 2
      src/views/store/shop/Update.vue
  5. 124
      src/views/store/shop/UpdateParking.vue

@ -7,6 +7,7 @@ const api = {
detail: '/shop/detail', detail: '/shop/detail',
add: '/shop/add', add: '/shop/add',
edit: '/shop/edit', edit: '/shop/edit',
updateParking: '/shop/updateParking',
delete: '/shop/delete' delete: '/shop/delete'
} }
@ -61,6 +62,14 @@ export function edit (data) {
}) })
} }
export function updateParking (data) {
return axios({
url: api.updateParking,
method: 'post',
data
})
}
/** /**
* 删除记录 * 删除记录
* @param {*} data * @param {*} data

@ -109,21 +109,6 @@
</div> </div>
</a-form-item> </a-form-item>
<!-- <a-form-item label="停车场名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input
placeholder="请输入停车场名称"
v-decorator="['parking_name']"
/>
</a-form-item>
<a-form-item label="停车场描述" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-textarea :autoSize="{ minRows: 4 }" v-decorator="['parking_desc']" />
</a-form-item>
<a-form-item label="停车场坐标" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input placeholder="请选择停车场坐标" v-decorator="['parking_coordinate']" />
<Getpoint @setCoordinate="setParkingCoordinate" />
</a-form-item> -->
<a-form-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol"> <a-form-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-radio-group v-decorator="['status', { initialValue: 1, rules: [{ required: true }] }]"> <a-radio-group v-decorator="['status', { initialValue: 1, rules: [{ required: true }] }]">
<a-radio :value="1">启用</a-radio> <a-radio :value="1">启用</a-radio>

@ -53,21 +53,26 @@
</span> </span>
<!-- 操作 --> <!-- 操作 -->
<div class="actions" slot="action" slot-scope="text, item"> <div class="actions" slot="action" slot-scope="text, item">
<a @click="handleParking(item)">停车场配置</a>
<a v-if="$auth('/store/shop/update')" @click="handleEdit(item)">编辑</a> <a v-if="$auth('/store/shop/update')" @click="handleEdit(item)">编辑</a>
<a v-action:delete @click="handleDelete(item)">删除</a> <a v-action:delete @click="handleDelete(item)">删除</a>
</div> </div>
</s-table> </s-table>
<UpdateParking ref="UpdateParking" @handleSubmit="handleRefresh" />
</a-card> </a-card>
</template> </template>
<script> <script>
import * as Api from '@/api/store/shop' import * as Api from '@/api/store/shop'
import { STable } from '@/components' import { STable } from '@/components'
import UpdateParking from './UpdateParking'
export default { export default {
name: 'Index', name: 'Index',
components: { components: {
STable STable,
UpdateParking
}, },
data () { data () {
return { return {
@ -173,6 +178,11 @@ export default {
}) })
}, },
//
handleParking (item) {
this.$refs.UpdateParking.edit(item)
},
/** /**
* 刷新列表 * 刷新列表
* @param Boolean bool 强制刷新到第一页 * @param Boolean bool 强制刷新到第一页

@ -222,7 +222,7 @@ export default {
form.setFieldsValue(pick(record, [ form.setFieldsValue(pick(record, [
'shop_name', 'logo_image_id', 'linkman', 'phone', 'shop_name', 'logo_image_id', 'linkman', 'phone',
'shop_hours', 'address', 'summary', 'cascader', 'shop_hours', 'address', 'summary', 'cascader',
'coordinate', 'sort', 'is_check', 'status', 'is_main', 'shop_image_id', 'remark' 'coordinate', 'sort', 'is_check', 'status', 'is_main'
])) ]))
}) })

@ -0,0 +1,124 @@
<template>
<a-modal
:title="title"
:width="1100"
:visible="visible"
:confirmLoading="confirmLoading"
:maskClosable="false"
:destroyOnClose="true"
@ok="handleSubmit"
@cancel="handleCancel"
>
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form-item label="停车场名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input
placeholder="请输入停车场名称"
v-decorator="['parking_name']"
/>
</a-form-item>
<a-form-item label="停车场描述" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-textarea :autoSize="{ minRows: 4 }" v-decorator="['parking_desc']" />
</a-form-item>
<a-form-item label="停车场坐标" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input placeholder="请选择停车场坐标" v-decorator="['parking_coordinate']" />
<Getpoint @setCoordinate="setCoordinate" />
</a-form-item>
</a-form>
</a-spin>
</a-modal>
</template>
<script>
import pick from 'lodash.pick'
import * as Api from '@/api/store/shop'
import { SelectImage, Getpoint } from '@/components'
export default {
components: {
SelectImage,
Getpoint
},
data () {
return {
//
title: '停车场配置',
//
labelCol: { span: 3 },
//
wrapperCol: { span: 20 },
// modal()
visible: false,
// modal() loading
confirmLoading: false,
//
form: this.$form.createForm(this),
//
record: {}
}
},
methods: {
//
edit (record) {
//
this.visible = true
//
this.record = record
this.record['parking_coordinate'] = [record.parking_latitude, record.parking_longitude].join(',')
//
this.setFieldsValue()
},
//
setFieldsValue () {
const { record, form: { setFieldsValue } } = this
this.$nextTick(() => {
setFieldsValue(pick(record, ['parking_name', 'parking_desc', 'parking_coordinate']))
})
},
//
handleSubmit (e) {
e.preventDefault()
//
const { form: { validateFields } } = this
validateFields((errors, values) => {
// api
!errors && this.onFormSubmit(values)
})
},
//
handleCancel () {
this.visible = false
this.form.resetFields()
},
// api
onFormSubmit (values) {
this.confirmLoading = true
Api.updateParking({ shopId: this.record.shop_id, form: values })
.then(result => {
//
this.$message.success(result.message, 1.5)
//
this.handleCancel()
//
this.$emit('handleSubmit', values)
})
.finally(() => this.confirmLoading = false)
},
setCoordinate (coordinate) {
const { form, $nextTick } = this
$nextTick(() => {
form.setFieldsValue({ parking_coordinate: coordinate })
})
}
}
}
</script>
Loading…
Cancel
Save