ViewNewStoreDialog.vue
4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<template>
<el-dialog
title="查看新店设置"
:visible.sync="visible"
width="900px"
:close-on-click-modal="false"
@close="close"
>
<div v-loading="loading">
<el-table :data="list" border stripe>
<el-table-column label="保护开始时间" width="150">
<template slot-scope="scope">
{{ formatTime(scope.row.bhkssj) }}
</template>
</el-table-column>
<el-table-column label="保护结束时间" width="150">
<template slot-scope="scope">
{{ formatTime(scope.row.bhjssj) }}
</template>
</el-table-column>
<el-table-column prop="sm" label="说明" />
<el-table-column label="创建时间" width="150">
<template slot-scope="scope">
{{ formatTime(scope.row.cjsj) }}
</template>
</el-table-column>
<el-table-column label="是否启用" width="100">
<template slot-scope="scope">
<el-tag :type="scope.row.sfqy === 1 ? 'success' : 'danger'" size="small">
{{ scope.row.sfqy === 1 ? '启用' : '禁用' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="阶段" width="80">
<template slot-scope="scope">
{{ scope.row.stage==1 ? '第一阶段' : scope.row.stage==2 ? '第二阶段' : scope.row.stage == 3 ? '第三阶段' : '无' }}
</template>
</el-table-column>
<el-table-column label="操作" width="100" align="left">
<template slot-scope="scope">
<el-button
type="danger"
size="mini"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<div v-if="list.length === 0" class="empty-data">
<i class="el-icon-info"></i>
<p>暂无新店设置数据</p>
</div>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="close">关闭</el-button>
</div>
</el-dialog>
</template>
<script>
import request from '@/utils/request'
export default {
name: 'ViewNewStoreDialog',
data() {
return {
visible: false,
loading: false,
list: [],
storeId: null
}
},
methods: {
init(storeId) {
this.storeId = storeId
this.visible = true
this.loadData()
},
loadData() {
this.loading = true
request({
url: '/api/Extend/lqmdxdbhsj',
method: 'GET',
data: {
mdid: this.storeId
}
}).then(res => {
this.list = res.data.list || []
this.loading = false
}).catch(err => {
this.$message.error('获取数据失败')
this.loading = false
})
},
formatTime(timestamp) {
if (!timestamp) return '无'
const date = new Date(timestamp)
return date.toLocaleString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
})
},
handleDelete(row) {
this.$confirm('此操作将永久删除该新店设置, 是否继续?', '提示', {
type: 'warning'
}).then(() => {
request({
url: `/api/Extend/lqmdxdbhsj/${row.F_Id}`,
method: 'DELETE'
}).then(res => {
if (res.code === 200) {
this.$message.success(res.msg || '删除成功')
this.loadData()
} else {
this.$message.error(res.msg || '删除失败')
}
}).catch(err => {
this.$message.error('删除失败')
console.error(err)
})
}).catch(() => {
// 用户取消删除
})
},
close() {
this.visible = false
this.list = []
this.storeId = null
}
}
}
</script>
<style scoped>
.empty-data {
text-align: center;
padding: 40px 0;
color: #909399;
}
.empty-data i {
font-size: 48px;
margin-bottom: 16px;
display: block;
}
.empty-data p {
margin: 0;
font-size: 14px;
}
</style>