更新服务相关逻辑

feature/0423
Wayne 1 year ago
parent c4e96754b8
commit a54300ef0d
  1. 84
      src/views/server/Index.vue

@ -30,14 +30,22 @@
<a-radio-button value="2">已下架</a-radio-button> <a-radio-button value="2">已下架</a-radio-button>
</a-radio-group> </a-radio-group>
</div> </div>
<a-button v-if="$auth('/goods/create')" class="fl-l" type="primary" icon="plus" @click="handleCreate()" <a-button
>新增服务</a-button v-if="$auth('/goods/create')"
class="fl-l"
type="primary"
icon="plus"
@click="handleCreate()"
>新增服务</a-button
> >
<div v-if="selectedRowKeys.length" class="button-group"> <div v-if="selectedRowKeys.length" class="button-group">
<a-button-group class="ml-10"> <a-button-group class="ml-10">
<a-button v-action:status icon="arrow-up" @click="handleUpdateStatus(selectedRowKeys, true)">上架</a-button> <a-button v-action:status icon="arrow-up" @click="handleUpdateStatus(selectedRowKeys, true)">上架</a-button>
<a-button v-action:status icon="arrow-down" @click="handleUpdateStatus(selectedRowKeys, false)" <a-button
>下架</a-button v-action:status
icon="arrow-down"
@click="handleUpdateStatus(selectedRowKeys, false)"
>下架</a-button
> >
<a-button v-action:delete icon="delete" @click="handleDelete(selectedRowKeys)">删除</a-button> <a-button v-action:delete icon="delete" @click="handleDelete(selectedRowKeys)">删除</a-button>
</a-button-group> </a-button-group>
@ -73,11 +81,11 @@
class="cur-p" class="cur-p"
:color="text == 1 ? 'green' : 'red'" :color="text == 1 ? 'green' : 'red'"
@click="handleUpdateStatus([item.server_id], text != 1)" @click="handleUpdateStatus([item.server_id], text != 1)"
>{{ text == 1 ? '上架' : '下架' }}</a-tag >{{ text == 1 ? '上架' : '下架' }}</a-tag
> >
</span> </span>
<!-- 操作项 --> <!-- 操作项 -->
<span class="actions" slot="action" slot-scope="item"> <span class="actions" slot="action" slot-scope="text, item">
<a style="margin-right: 8px" @click="handleEdit(item)">编辑</a> <a style="margin-right: 8px" @click="handleEdit(item)">编辑</a>
<a @click="handleDelete([item.server_id])">删除</a> <a @click="handleDelete([item.server_id])">删除</a>
</span> </span>
@ -96,53 +104,53 @@ import Edit from './modules/Edit'
const columns = [ const columns = [
{ {
title: '服务ID', title: '服务ID',
dataIndex: 'server_id', dataIndex: 'server_id'
}, },
{ {
title: '服务图片', title: '服务图片',
dataIndex: 'server_image', dataIndex: 'server_image',
scopedSlots: { customRender: 'server_image' }, scopedSlots: { customRender: 'server_image' }
}, },
{ {
title: '服务名称', title: '服务名称',
dataIndex: 'server_name', dataIndex: 'server_name',
scopedSlots: { customRender: 'server_name' }, scopedSlots: { customRender: 'server_name' }
}, },
{ {
title: '服务分类', title: '服务分类',
dataIndex: 'server_category', dataIndex: 'server_category',
scopedSlots: { customRender: 'server_category' }, scopedSlots: { customRender: 'server_category' }
}, },
{ {
title: '服务价格', title: '服务价格',
dataIndex: 'server_price', dataIndex: 'server_price',
scopedSlots: { customRender: 'server_price' }, scopedSlots: { customRender: 'server_price' }
}, },
{ {
title: '划线价格', title: '划线价格',
dataIndex: 'line_price', dataIndex: 'line_price',
scopedSlots: { customRender: 'line_price' }, scopedSlots: { customRender: 'line_price' }
}, },
{ {
title: '状态', title: '状态',
dataIndex: 'status', dataIndex: 'status',
scopedSlots: { customRender: 'status' }, scopedSlots: { customRender: 'status' }
}, },
{ {
title: '排序', title: '排序',
dataIndex: 'sort', dataIndex: 'sort'
}, },
{ {
title: '添加时间', title: '添加时间',
width: '180px', width: '180px',
dataIndex: 'create_time', dataIndex: 'create_time'
}, },
{ {
title: '操作', title: '操作',
dataIndex: 'action', dataIndex: 'action',
width: '150px', width: '150px',
scopedSlots: { customRender: 'action' }, scopedSlots: { customRender: 'action' }
}, }
] ]
export default { export default {
@ -151,9 +159,9 @@ export default {
ContentHeader, ContentHeader,
STable, STable,
Add, Add,
Edit, Edit
}, },
data() { data () {
return { return {
// //
searchForm: this.$form.createForm(this), searchForm: this.$form.createForm(this),
@ -177,10 +185,10 @@ export default {
return Api.serverList({ ...param, ...this.queryParam }).then((response) => { return Api.serverList({ ...param, ...this.queryParam }).then((response) => {
return response.data.list return response.data.list
}) })
}, }
} }
}, },
created() { created () {
// //
if (this.$route.query.status) { if (this.$route.query.status) {
this.queryParam.status = this.$route.query.status this.queryParam.status = this.$route.query.status
@ -189,37 +197,37 @@ export default {
this.getCategoryList() this.getCategoryList()
}, },
computed: { computed: {
rowSelection() { rowSelection () {
return { return {
selectedRowKeys: this.selectedRowKeys, selectedRowKeys: this.selectedRowKeys,
onChange: this.onSelectChange, onChange: this.onSelectChange
} }
}, }
}, },
methods: { methods: {
// //
onSelectChange(selectedRowKeys) { onSelectChange (selectedRowKeys) {
this.selectedRowKeys = selectedRowKeys this.selectedRowKeys = selectedRowKeys
}, },
// tab // tab
handleTabs(e) { handleTabs (e) {
this.queryParam.status = e.target.value this.queryParam.status = e.target.value
this.handleRefresh(true) this.handleRefresh(true)
}, },
// //
handleSearch(e) { handleSearch (e) {
this.handleRefresh(true) this.handleRefresh(true)
}, },
// //
handleReset() { handleReset () {
this.searchForm.resetFields() this.searchForm.resetFields()
}, },
// //
getCategoryList() { getCategoryList () {
this.isLoading = true this.isLoading = true
Api.categoryList() Api.categoryList()
.then((result) => { .then((result) => {
@ -229,7 +237,7 @@ export default {
}, },
// () // ()
handleUpdateStatus(serverIds, state = true) { handleUpdateStatus (serverIds, state = true) {
this.isLoading = true this.isLoading = true
Api.serverStatus({ serverIds, state }) Api.serverStatus({ serverIds, state })
.then((result) => { .then((result) => {
@ -243,28 +251,28 @@ export default {
}, },
// //
handleDelete(serverId) { handleDelete (serverId) {
const app = this const app = this
const modal = this.$confirm({ const modal = this.$confirm({
title: '您确定要删除该记录吗?', title: '您确定要删除该记录吗?',
content: '删除后不可恢复', content: '删除后不可恢复',
onOk() { onOk () {
return Api.deleteServer({ serverId }) return Api.deleteServer({ serverId })
.then((result) => { .then((result) => {
app.$message.success(result.message, 1.5) app.$message.success(result.message, 1.5)
app.handleRefresh() app.handleRefresh()
}) })
.finally((result) => modal.destroy()) .finally((result) => modal.destroy())
}, }
}) })
}, },
// //
handleCreate() { handleCreate () {
this.$refs.AddRef.add() this.$refs.AddRef.add()
}, },
// //
async handleEdit(record) { async handleEdit (record) {
// //
this.$refs.EditRef.edit(record) this.$refs.EditRef.edit(record)
}, },
@ -272,11 +280,11 @@ export default {
* 刷新列表 * 刷新列表
* @param Boolean bool 强制刷新到第一页 * @param Boolean bool 强制刷新到第一页
*/ */
handleRefresh(bool = false) { handleRefresh (bool = false) {
this.selectedRowKeys = [] this.selectedRowKeys = []
this.$refs.table.refresh(bool) this.$refs.table.refresh(bool)
}, }
}, }
} }
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>

Loading…
Cancel
Save