CreditCardEquity.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <template>
  2. <div class="credit-card-equity">
  3. <el-card>
  4. <div class="search-section" slot="header">
  5. <div class="search-row">
  6. <el-form :model="searchForm" label-width="80px" inline>
  7. <el-form-item label="权益名称:">
  8. <el-input v-model="searchForm.equityName" placeholder="请输入" style="width: 150px"></el-input>
  9. </el-form-item>
  10. <div class="button-group" style="margin-left: 20px;">
  11. <el-button type="primary" @click="handleSearch">查询</el-button>
  12. <el-button @click="handleReset">重置</el-button>
  13. </div>
  14. </el-form>
  15. </div>
  16. </div>
  17. <el-table :data="filteredTableData" stripe style="width: 100%">
  18. <el-table-column label="操作" width="280" fixed="left">
  19. <template slot-scope="scope">
  20. <div class="row-actions">
  21. <el-popover
  22. placement="bottom"
  23. trigger="click"
  24. width="240"
  25. @show="onAdjustOrderShow(scope.$index)"
  26. :ref="`adjustPopover-${scope.$index}`"
  27. >
  28. <div class="adjust-order-form">
  29. <div class="adjust-order-title">调整显示顺序</div>
  30. <div class="adjust-order-tip">移动端权益首页和列表页按照该顺序展示</div>
  31. <div class="adjust-order-input">
  32. <span>调整到第</span>
  33. <el-input-number
  34. v-model.number="adjustOrderPosition"
  35. :min="1"
  36. :max="tableData.length"
  37. size="mini"
  38. :controls="false"
  39. style="width: 70px;margin: 0 6px;"
  40. />
  41. <span>位</span>
  42. </div>
  43. <div class="adjust-order-actions">
  44. <el-button size="mini" @click="closeAdjustOrder(scope.$index)">取消</el-button>
  45. <el-button size="mini" type="primary" @click="confirmAdjustOrder(scope.$index)">确定</el-button>
  46. </div>
  47. </div>
  48. <el-button slot="reference" type="text" size="small">调整显示顺序</el-button>
  49. </el-popover>
  50. <el-button type="text" size="small" @click="openShowPagesDialog(scope.row)">设置显示页面</el-button>
  51. <el-popover
  52. placement="bottom"
  53. trigger="click"
  54. :ref="`morePopover-${scope.$index}`"
  55. >
  56. <div class="more-actions-menu">
  57. <div
  58. class="more-actions-item"
  59. @click="openLinkDialogFromMore(scope.row, scope.$index)"
  60. >生成链接</div>
  61. </div>
  62. <el-button slot="reference" type="text" size="small" icon="el-icon-more"></el-button>
  63. </el-popover>
  64. </div>
  65. </template>
  66. </el-table-column>
  67. <el-table-column prop="equityName" label="权益名称" min-width="220" show-overflow-tooltip></el-table-column>
  68. <el-table-column label="显示页面" min-width="240">
  69. <template slot-scope="scope">
  70. <template v-if="visiblePages(scope.row).length">
  71. <el-tag
  72. v-for="page in visiblePages(scope.row)"
  73. :key="page"
  74. size="small"
  75. style="margin-right: 4px;"
  76. >{{ page }}</el-tag>
  77. </template>
  78. <span v-else class="empty-text">-</span>
  79. </template>
  80. </el-table-column>
  81. </el-table>
  82. <div class="pagination-section">
  83. <span>Total {{ filteredTableData.length }}</span>
  84. <el-pagination
  85. layout="prev, pager, next, sizes, jumper"
  86. :page-size="10"
  87. :page-sizes="[10, 20, 50]"
  88. :total="filteredTableData.length"
  89. ></el-pagination>
  90. </div>
  91. </el-card>
  92. <show-pages-dialog
  93. :visible.sync="showPagesDialogVisible"
  94. :row="showPagesRow"
  95. @confirm="onShowPagesConfirm"
  96. ></show-pages-dialog>
  97. <equity-link-dialog
  98. :visible.sync="linkDialogVisible"
  99. :id="linkTargetId"
  100. path-name="equity/credit"
  101. title="生成信用卡权益链接"
  102. ></equity-link-dialog>
  103. </div>
  104. </template>
  105. <script>
  106. import ShowPagesDialog from '@/components/ShowPagesDialog.vue'
  107. import EquityLinkDialog from '@/components/EquityLinkDialog.vue'
  108. export default {
  109. name: 'CreditCardEquity',
  110. components: { ShowPagesDialog, EquityLinkDialog },
  111. data() {
  112. return {
  113. searchForm: {
  114. equityName: ''
  115. },
  116. showPagesDialogVisible: false,
  117. showPagesRow: null,
  118. linkDialogVisible: false,
  119. linkTargetId: '',
  120. adjustOrderPosition: 1,
  121. tableData: [
  122. {
  123. equityName: '白金卡机场贵宾厅',
  124. productId: 'CC001',
  125. skuNo: 'CCSKU001',
  126. merchantName: '环亚机场贵宾',
  127. createTime: '2026-01-10 09:32:15',
  128. showOnHome: '显示',
  129. showOnAssembly: '不显示',
  130. assemblyPages: []
  131. },
  132. {
  133. equityName: '钻石卡高尔夫体验',
  134. productId: 'CC002',
  135. skuNo: 'CCSKU002',
  136. merchantName: '尊享高尔夫俱乐部',
  137. createTime: '2026-01-15 14:08:42',
  138. showOnHome: '显示',
  139. showOnAssembly: '不显示',
  140. assemblyPages: []
  141. },
  142. {
  143. equityName: '金卡洗车服务',
  144. productId: 'CC003',
  145. skuNo: 'CCSKU003',
  146. merchantName: '车之家精洗服务',
  147. createTime: '2026-02-01 11:20:05',
  148. showOnHome: '显示',
  149. showOnAssembly: '不显示',
  150. assemblyPages: []
  151. }
  152. ]
  153. }
  154. },
  155. computed: {
  156. visiblePages() {
  157. return row => {
  158. const pages = []
  159. if (row.showOnHome === '显示') pages.push("权益首页/列表页")
  160. if (row.showOnAssembly === '显示' && Array.isArray(row.assemblyPages)) {
  161. pages.push(...row.assemblyPages)
  162. }
  163. return pages
  164. }
  165. },
  166. filteredTableData() {
  167. return this.tableData.filter(item => {
  168. if (this.searchForm.equityName && !item.equityName.includes(this.searchForm.equityName)) return false
  169. return true
  170. })
  171. }
  172. },
  173. methods: {
  174. handleSearch() {
  175. this.$message.success('已搜索')
  176. },
  177. handleReset() {
  178. this.searchForm = {
  179. equityName: ''
  180. }
  181. },
  182. openShowPagesDialog(row) {
  183. this.showPagesRow = row
  184. this.showPagesDialogVisible = true
  185. },
  186. showLinkDialog(row) {
  187. this.linkTargetId = row.productId
  188. this.linkDialogVisible = true
  189. },
  190. openLinkDialogFromMore(row, index) {
  191. const moreRef = this.getPopoverInstance(`morePopover-${index}`)
  192. if (moreRef) {
  193. moreRef.doClose()
  194. }
  195. this.showLinkDialog(row)
  196. },
  197. onShowPagesConfirm(values) {
  198. if (this.showPagesRow) {
  199. this.$set(this.showPagesRow, 'showOnHome', values.showOnHome)
  200. this.$set(this.showPagesRow, 'showOnAssembly', values.showOnAssembly)
  201. this.$set(this.showPagesRow, 'assemblyPages', [...values.assemblyPages])
  202. this.$message.success('显示页面已更新')
  203. }
  204. },
  205. getPopoverInstance(name) {
  206. const ref = this.$refs[name]
  207. if (!ref) return null
  208. return Array.isArray(ref) ? ref[0] : ref
  209. },
  210. onAdjustOrderShow(index) {
  211. this.adjustOrderPosition = index + 1
  212. },
  213. closeAdjustOrder(index) {
  214. const adjustRef = this.getPopoverInstance(`adjustPopover-${index}`)
  215. if (adjustRef) {
  216. adjustRef.doClose()
  217. }
  218. },
  219. confirmAdjustOrder(index) {
  220. const target = Number(this.adjustOrderPosition)
  221. if (!target || target < 1 || target > this.tableData.length) {
  222. this.$message.warning('请输入有效的顺序位置')
  223. return
  224. }
  225. const targetIndex = target - 1
  226. if (targetIndex !== index) {
  227. const moved = this.tableData.splice(index, 1)[0]
  228. this.tableData.splice(targetIndex, 0, moved)
  229. }
  230. this.$message.success('顺序已调整')
  231. this.closeAdjustOrder(index)
  232. }
  233. }
  234. }
  235. </script>
  236. <style scoped>
  237. .credit-card-equity {
  238. padding: 0;
  239. }
  240. .search-section {
  241. display: flex;
  242. flex-direction: column;
  243. }
  244. .search-row {
  245. margin-bottom: 15px;
  246. }
  247. .search-row .el-form {
  248. display: flex;
  249. flex-wrap: wrap;
  250. gap: 0;
  251. }
  252. .search-row .el-form-item {
  253. margin-right: 0;
  254. margin-bottom: 0;
  255. }
  256. .button-group {
  257. display: flex;
  258. gap: 5px;
  259. }
  260. .pagination-section {
  261. display: flex;
  262. justify-content: flex-end;
  263. align-items: center;
  264. gap: 20px;
  265. margin-top: 20px;
  266. }
  267. .row-actions {
  268. display: flex;
  269. align-items: center;
  270. gap: 12px;
  271. }
  272. .empty-text {
  273. color: #c0c4cc;
  274. }
  275. .row-actions .el-button + .el-button {
  276. margin-left: 0;
  277. }
  278. </style>
  279. <style>
  280. .more-actions-menu {
  281. display: flex;
  282. flex-direction: column;
  283. margin: -12px;
  284. }
  285. .more-actions-item {
  286. padding: 8px 16px;
  287. cursor: pointer;
  288. font-size: 14px;
  289. color: #606266;
  290. }
  291. .more-actions-item:hover {
  292. background: #f5f7fa;
  293. color: #409eff;
  294. }
  295. .adjust-order-form {
  296. display: flex;
  297. flex-direction: column;
  298. gap: 12px;
  299. }
  300. .adjust-order-title {
  301. font-size: 14px;
  302. font-weight: 500;
  303. color: #303133;
  304. }
  305. .adjust-order-tip {
  306. font-size: 12px;
  307. color: #909399;
  308. line-height: 1.5;
  309. padding: 8px 10px;
  310. background: #f5f7fa;
  311. border-radius: 4px;
  312. }
  313. .adjust-order-input {
  314. display: flex;
  315. align-items: center;
  316. font-size: 14px;
  317. color: #606266;
  318. }
  319. .adjust-order-actions {
  320. display: flex;
  321. justify-content: flex-end;
  322. gap: 8px;
  323. }
  324. </style>