list.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <a-card size="small" :bordered="false" class="jg-page-wrap promotionInfoList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" 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="5" :sm="24">
  9. <a-form-item label="发布时间">
  10. <rangeDate ref="rangeDate" :value="time" @change="dateChange" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="5" :sm="24">
  14. <a-form-item label="促销名称">
  15. <a-input id="promotionInfoList-promoName" v-model.trim="queryParam.promoName" allowClear placeholder="请输入促销名称"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="5" :sm="24">
  19. <a-form-item label="促销类型">
  20. <v-select
  21. v-model="queryParam.promoType"
  22. ref="sourceType"
  23. id="promotionInfoList-promoType"
  24. code="SHOP_PROMO_PROMO_TYPE"
  25. placeholder="请选择促销类型"
  26. allowClear></v-select>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="5" :sm="24">
  30. <a-form-item label="促销状态">
  31. <v-select
  32. v-model="queryParam.promoState"
  33. ref="sourceType"
  34. id="promotionInfoList-promoState"
  35. code="SHOP_PROMO_PROMO_STATE"
  36. placeholder="请选择促销状态"
  37. allowClear></v-select>
  38. </a-form-item>
  39. </a-col>
  40. <a-col :md="4" :sm="24">
  41. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="promotionInfoList-refresh">查询</a-button>
  42. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="promotionInfoList-reset">重置</a-button>
  43. </a-col>
  44. </a-row>
  45. </a-form>
  46. </div>
  47. <!-- 列表 -->
  48. <s-table
  49. class="sTable fixPagination"
  50. ref="table"
  51. :style="{ height: tableHeight+84.5+'px' }"
  52. size="small"
  53. :rowKey="(record) => record.id"
  54. :columns="columns"
  55. :data="loadData"
  56. :scroll="{ y: tableHeight }"
  57. :defaultLoadData="false"
  58. bordered>
  59. <!-- 促销时间 -->
  60. <template slot="promotionTime" slot-scope="text, record">
  61. <span>{{ record.promoStartDate }}至{{ record.promoEndDate }}</span>
  62. </template>
  63. <!-- 促销展示 -->
  64. <template slot="salesShow" slot-scope="text, record">
  65. <div @click="handleDescModal(record)" v-if="record.imageUrl">
  66. <img :src="record.imageUrl" alt="图片走丢啦" width="60" />
  67. </div>
  68. <span v-else>--</span>
  69. </template>
  70. <!-- 操作 -->
  71. <!-- state HAVE_RELEASE 已开启 IS_OVER已结束 IS_CLOSE 已关闭 NOT_RELEASE 未开启 -->
  72. <template slot="action" slot-scope="text, record">
  73. <a-button
  74. size="small"
  75. type="link"
  76. class="button-primary"
  77. @click="handleOpenOrClose(record,'1')"
  78. v-if="record.dealerOpenFlag==='1'&&record.dealerOpenState=='0'&&(record.promoState=='IS_CLOSE'||record.promoState=='NOT_RELEASE')&&$hasPermissions('B_publishActiveBtn')"
  79. id="productOnlineInfoList-detail-btn">开启</a-button>
  80. <a-button
  81. size="small"
  82. type="link"
  83. class="button-primary"
  84. v-if="record.dealerOpenFlag==='1'&&record.dealerOpenState=='1'&&record.promoState=='HAVE_RELEASE'&&$hasPermissions('B_closeActiveBtn')"
  85. @click="handleOpenOrClose(record,'0')"
  86. id="productOnlineInfoList-detail-btn">关闭</a-button>
  87. <a-button
  88. size="small"
  89. type="link"
  90. class="button-primary"
  91. v-if="record.dealerEditFlag==='1'&&record.dealerPublishState!='END'&&$hasPermissions('B_promoActiveEditBtn')"
  92. @click="handleEdit(record,'edit')">编辑</a-button>
  93. <a-button
  94. size="small"
  95. type="link"
  96. class="button-success"
  97. v-if="$hasPermissions('B_promoActiveSeeBtn')"
  98. @click="handleSee(record)">查看</a-button>
  99. </template>
  100. </s-table>
  101. </a-spin>
  102. <!-- 促销展示 -->
  103. <promotion-desc-modal :con="descInfo" :openModal="openDescModal" @close="openDescModal = false"/>
  104. <!-- 查看 -->
  105. <detail-Modal :openModal="openDetailModal" :itemSn="itemId" @close="closeDetailModal" @ok="$refs.table.refresh()" />
  106. </a-card>
  107. </template>
  108. <script>
  109. import { commonMixin } from '@/utils/mixin'
  110. import { STable, VSelect } from '@/components'
  111. import rangeDate from '@/views/common/rangeDate.vue'
  112. import promotionDescModal from './promotionDescModal'
  113. import promotionShowModal from './promotionShowModal'
  114. import detailModal from './detailModal'
  115. import { shopPromoList, openOrCloseActive } from '@/api/shopPromo'
  116. import { closeActive } from '@/api/promoActive'
  117. export default {
  118. name: 'UrgentOffsetList',
  119. components: { STable, VSelect, rangeDate, promotionDescModal, promotionShowModal, detailModal },
  120. mixins: [commonMixin],
  121. data () {
  122. return {
  123. spinning: false,
  124. tableHeight: 0,
  125. openDescModal: false, // 促销描述弹窗
  126. openShowModal: false, // 促销展示弹窗
  127. time: [],
  128. queryParam: { // 查询条件
  129. beginDate: undefined,
  130. endDate: undefined,
  131. promoName: '', // 促销名称
  132. promoType: '', // 促销类型
  133. promoState: undefined// 促销状态
  134. },
  135. descInfo: '', // 促销描述
  136. itemId: null, // 促销当前行sn
  137. disabled: false, // 查询、重置按钮是否可操作
  138. openDetailModal: false,
  139. columns: [
  140. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  141. { title: '发布时间', dataIndex: 'createDate', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  142. { title: '促销名称', dataIndex: 'promoName', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  143. { title: '促销时间', scopedSlots: { customRender: 'promotionTime' }, width: '20%', align: 'center' },
  144. { title: '促销类型', dataIndex: 'promoTypeDictValue', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  145. { title: '促销展示', scopedSlots: { customRender: 'salesShow' }, width: '10%', align: 'center' },
  146. { title: '状态', dataIndex: 'promoStateDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  147. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  148. ],
  149. // 加载数据方法 必须为 Promise 对象
  150. loadData: parameter => {
  151. this.disabled = true
  152. this.spinning = true
  153. return shopPromoList(Object.assign(parameter, this.queryParam)).then(res => {
  154. let data
  155. if (res.status == 200) {
  156. data = res.data
  157. const no = (data.pageNo - 1) * data.pageSize
  158. for (var i = 0; i < data.list.length; i++) {
  159. data.list[i].no = no + i + 1
  160. data.list[i].images = data.list[i].images ? data.list[i].images.split(',') : []
  161. }
  162. this.disabled = false
  163. }
  164. this.spinning = false
  165. return data
  166. })
  167. }
  168. }
  169. },
  170. methods: {
  171. // 打开详情
  172. handleSee (row) {
  173. this.openDetailModal = true
  174. this.itemId = row.promoSn
  175. },
  176. // 关闭详情
  177. closeDetailModal () {
  178. this.openDetailModal = false
  179. this.itemId = ''
  180. },
  181. // 时间 change
  182. dateChange (date) {
  183. this.queryParam.beginDate = date[0]
  184. this.queryParam.endDate = date[1]
  185. },
  186. // 查看促销描述
  187. handleDescModal (row) {
  188. this.descInfo = row.imageUrl
  189. const _this = this
  190. this.$nextTick(() => {
  191. _this.openDescModal = true
  192. })
  193. },
  194. // 促销展示
  195. handleSaleShow (row) {
  196. const _this = this
  197. _this.openShowModal = true
  198. this.$nextTick(() => {
  199. _this.$refs.promotionShow.getDetail({ id: row.promoActiveSn, showType: row.contentType })
  200. })
  201. },
  202. // 开启
  203. handleOpenOrClose (row, val) {
  204. const _this = this
  205. this.$confirm({
  206. title: '提示',
  207. content: '促销活动一旦' + (val == '1' ? '开启' : '关闭') + ',客户' + (val == '1' ? '可' : '无法') + '参与活动。确认' + (val == '1' ? '开启' : '关闭') + '吗?',
  208. centered: true,
  209. onOk () {
  210. _this.spinning = true
  211. openOrCloseActive({ promoSn: row.promoSn, dealerOpenState: val }).then(res => {
  212. if (res.status == 200) {
  213. _this.$message.success(res.message)
  214. _this.$refs.table.refresh()
  215. _this.spinning = false
  216. } else {
  217. _this.spinning = false
  218. }
  219. })
  220. }
  221. })
  222. },
  223. // 关闭
  224. handleClose (row) {
  225. const _this = this
  226. this.$confirm({
  227. title: '提示',
  228. content: '促销活动一旦,客户无法参与活动。确认关闭吗?',
  229. centered: true,
  230. onOk () {
  231. _this.spinning = true
  232. closeActive({ sn: row.promoActiveSn }).then(res => {
  233. if (res.status == 200) {
  234. _this.$message.success(res.message)
  235. _this.$refs.table.refresh()
  236. _this.spinning = false
  237. } else {
  238. _this.spinning = false
  239. }
  240. })
  241. }
  242. })
  243. },
  244. // 编辑
  245. handleEdit (row, type) {
  246. const _this = this
  247. if (row.dealerPublishState === 'PUBLISH' && type === 'edit') {
  248. _this.$warning({
  249. title: '提示',
  250. content: '请先关闭活动,活动关闭后可编辑活动'
  251. })
  252. } else {
  253. const nameInfo = type === 'edit' ? 'promotionInfoEdit' : 'promotionInfoDetail'
  254. _this.$router.push({ name: nameInfo, params: { sn: row.promoActiveSn, pageType: type } })
  255. }
  256. },
  257. // 重置
  258. resetSearchForm () {
  259. this.$refs.rangeDate.resetDate(this.time)
  260. this.queryParam.beginDate = undefined
  261. this.queryParam.endDate = undefined
  262. this.queryParam.promoName = ''
  263. this.queryParam.promoType = undefined
  264. this.queryParam.promoState = undefined
  265. this.$refs.table.refresh(true)
  266. },
  267. pageInit () {
  268. const _this = this
  269. this.$nextTick(() => { // 页面渲染完成后的回调
  270. _this.setTableH()
  271. })
  272. },
  273. setTableH () {
  274. const tableSearchH = this.$refs.tableSearch.offsetHeight
  275. this.tableHeight = window.innerHeight - tableSearchH - 203
  276. }
  277. },
  278. mounted () {
  279. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  280. this.pageInit()
  281. this.resetSearchForm()
  282. }
  283. },
  284. watch: {
  285. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  286. this.setTableH()
  287. }
  288. },
  289. activated () {
  290. // 如果是新页签打开,则重置当前页面
  291. if (this.$store.state.app.isNewTab) {
  292. this.pageInit()
  293. this.resetSearchForm()
  294. }
  295. // 只刷新列表
  296. if (this.$store.state.app.updateList) {
  297. this.pageInit()
  298. this.$refs.table.refresh()
  299. }
  300. },
  301. beforeRouteEnter (to, from, next) {
  302. next(vm => {})
  303. }
  304. }
  305. </script>
  306. <style lang="less">
  307. .promotionInfoList-wrap{
  308. .red{
  309. color: #ed1c24;
  310. }
  311. .green{
  312. color: #19be6b;
  313. }
  314. .font1{
  315. color:#39f;
  316. }
  317. .desc{
  318. width: 100%;
  319. overflow: hidden;
  320. text-overflow: ellipsis;
  321. display: -webkit-box;
  322. -webkit-line-clamp: 3;
  323. -webkit-box-orient: vertical;
  324. }
  325. }
  326. </style>