list.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <a-card size="small" :bordered="false" class="promotionRulesList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper">
  6. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="创建时间">
  10. <rangeDate ref="rangeDate" @change="dateChange" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="促销名称">
  15. <a-input id="promotionRulesList-name" v-model.trim="queryParam.name" allowClear placeholder="请输入促销名称"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="状态">
  20. <v-select code="ENABLE_FLAG" id="promotionRulesList-enabledFlag" v-model="queryParam.enabledFlag" allowClear placeholder="请选择状态"></v-select>
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="6" :sm="24">
  24. <a-button style="margin-bottom: 18px;" type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="promotionRulesList-refresh">查询</a-button>
  25. <a-button style="margin: 0 0 18px 8px" @click="resetSearchForm" :disabled="disabled" id="promotionRulesList-reset">重置</a-button>
  26. </a-col>
  27. </a-row>
  28. </a-form>
  29. </div>
  30. <!-- 操作按钮 -->
  31. <div class="table-operator">
  32. <a-button id="promotionRulesList-add" type="primary" v-if="$hasPermissions('B_promotionRules_add')" class="button-error" @click="openModal=true">新增</a-button>
  33. </div>
  34. <!-- 总计 -->
  35. <a-alert type="info" showIcon style="margin-bottom:15px">
  36. <div slot="message">合计: <strong>{{ total }}</strong>条</div>
  37. </a-alert>
  38. <!-- 列表 -->
  39. <s-table
  40. class="sTable"
  41. ref="table"
  42. size="default"
  43. :rowKey="(record) => record.id"
  44. :columns="columns"
  45. :data="loadData"
  46. :scroll="{ x: 1440, y: tableHeight }"
  47. bordered>
  48. <!-- 促销时间 -->
  49. <template slot="activeDate" slot-scope="text, record">
  50. <div v-if="record.activeDateEnable != '0'">
  51. <span v-if="record.activeDateStart || record.activeDateEnd">{{ record.activeDateStart }} 至 {{ record.activeDateEnd }}</span>
  52. <span v-else>--</span>
  53. </div>
  54. <span v-else>不限</span>
  55. </template>
  56. <!-- 状态 -->
  57. <template slot="enabledFlag" slot-scope="text, record">
  58. <a-switch
  59. v-if="$hasPermissions('B_promotionRules_enable')"
  60. id="promotionRulesList-enable"
  61. checkedChildren="启用"
  62. unCheckedChildren="禁用"
  63. @change="changeStatus(record)"
  64. :checked="record.enabledFlag == 1 ? true : false" />
  65. <span v-else :style="{color:(record.enabledFlag==1?'#00aa00':'#999')}"> {{ record.enabledFlag==1? '已启用': '已禁用' }} </span>
  66. </template>
  67. <!-- 操作 -->
  68. <template slot="action" slot-scope="text, record">
  69. <a-button
  70. size="small"
  71. type="link"
  72. v-if="record.enabledFlag != 1 && $hasPermissions('B_promotionRules_ruleSet')"
  73. class="button-primary"
  74. @click="handleRule(record)"
  75. id="promotionRulesList-rule-btn">规则设置</a-button>
  76. <a-button
  77. size="small"
  78. type="link"
  79. v-if="record.enabledFlag != 1 && $hasPermissions('B_promotionRules_edit')"
  80. class="button-info"
  81. @click="handleEdit(record)"
  82. id="promotionRulesList-edit-btn">编辑</a-button>
  83. <a-button
  84. size="small"
  85. type="link"
  86. v-if="$hasPermissions('B_promotionRules_detail')"
  87. class="button-success"
  88. @click="handleDetail(record)"
  89. id="promotionRulesList-detail-btn">详情</a-button>
  90. <span v-if="!(record.enabledFlag != 1 && $hasPermissions('B_promotionRules_ruleSet')) && !(record.enabledFlag != 1 && $hasPermissions('B_promotionRules_edit')) && !$hasPermissions('B_promotionRules_detail')">--</span>
  91. </template>
  92. </s-table>
  93. </a-spin>
  94. <!-- 新增 -->
  95. <basic-info-modal :openModal="openModal" :itemSn="itemSn" @ok="handleOk" @close="closeModal" />
  96. </a-card>
  97. </template>
  98. <script>
  99. import moment from 'moment'
  100. import { STable, VSelect } from '@/components'
  101. import rangeDate from '@/views/common/rangeDate.vue'
  102. import basicInfoModal from './basicInfoModal.vue'
  103. import { promoActiveList, promoActiveEnable } from '@/api/promoActive'
  104. export default {
  105. components: { STable, VSelect, basicInfoModal, rangeDate },
  106. data () {
  107. return {
  108. spinning: false,
  109. tableHeight: 0,
  110. queryParam: { // 查询条件
  111. beginDate: '',
  112. endDate: '',
  113. name: '', // 名称
  114. enabledFlag: undefined // 状态
  115. },
  116. disabled: false, // 查询、重置按钮是否可操作
  117. columns: [
  118. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  119. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  120. { title: '促销名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  121. { title: '促销时间', scopedSlots: { customRender: 'activeDate' }, width: 200, align: 'center' },
  122. { title: '参与客户', dataIndex: 'promoBuyerName', width: 220, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  123. { title: '备注', dataIndex: 'remark', width: 220, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  124. { title: '状态', scopedSlots: { customRender: 'enabledFlag' }, width: 140, align: 'center', fixed: 'right' },
  125. { title: '操作', scopedSlots: { customRender: 'action' }, width: 200, align: 'center', fixed: 'right' }
  126. ],
  127. // 加载数据方法 必须为 Promise 对象
  128. loadData: parameter => {
  129. this.disabled = true
  130. if (this.tableHeight == 0) {
  131. this.tableHeight = window.innerHeight - 450
  132. }
  133. return promoActiveList(Object.assign(parameter, this.queryParam)).then(res => {
  134. const data = res.data
  135. const no = (data.pageNo - 1) * data.pageSize
  136. for (var i = 0; i < data.list.length; i++) {
  137. data.list[i].no = no + i + 1
  138. let str = ''
  139. const promoBuyerList = data.list[i].promoBuyerList ? data.list[i].promoBuyerList : []
  140. promoBuyerList.map(item => {
  141. str += item.buyerName + ','
  142. })
  143. str = str.substr(0, str.length - 1)
  144. data.list[i].promoBuyerName = str || '全部客户'
  145. }
  146. this.total = data.count || 0
  147. this.disabled = false
  148. return data
  149. })
  150. },
  151. total: 0, // 总条数
  152. openModal: false, // 弹框
  153. itemSn: '' // 当前sn
  154. }
  155. },
  156. methods: {
  157. // 时间 change
  158. dateChange (date) {
  159. this.queryParam.beginDate = date[0] ? date[0] + ' 00:00:00' : ''
  160. this.queryParam.endDate = date[1] ? date[1] + ' 23:59:59' : ''
  161. },
  162. // 重置
  163. resetSearchForm () {
  164. this.$refs.rangeDate.resetDate()
  165. this.queryParam.beginDate = ''
  166. this.queryParam.endDate = ''
  167. this.queryParam.name = ''
  168. this.queryParam.enabledFlag = undefined
  169. this.$refs.table.refresh(true)
  170. },
  171. // 编辑
  172. handleEdit (row) {
  173. this.itemSn = row.promoActiveSn
  174. this.openModal = true
  175. },
  176. // 基本信息 保存
  177. handleOk (data) {
  178. this.$refs.table.refresh(true)
  179. },
  180. // 关闭弹框
  181. closeModal () {
  182. this.itemSn = ''
  183. this.openModal = false
  184. },
  185. // 详情
  186. handleDetail (row) {
  187. this.$router.push({ path: `/promotionRulesManagement/promotionRules/detail/${row.id}/${row.promoActiveSn}` })
  188. },
  189. // 规则设置
  190. handleRule (row) {
  191. this.$router.push({ path: `/promotionRulesManagement/promotionRules/rule/${row.id}/${row.promoActiveSn}` })
  192. },
  193. // 启用 禁用
  194. changeStatus (record) {
  195. const params = {
  196. sn: record.promoActiveSn,
  197. flag: record.enabledFlag == 1 ? '0' : '1'
  198. }
  199. this.spinning = true
  200. promoActiveEnable(params).then(res => {
  201. if (res.status == 200) {
  202. this.$message.success(res.message)
  203. this.$refs.table.refresh()
  204. this.spinning = false
  205. } else {
  206. this.$refs.table.refresh()
  207. this.spinning = false
  208. }
  209. })
  210. }
  211. }
  212. }
  213. </script>