更新服务相关逻辑

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

Loading…
Cancel
Save