list.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="promotion-wrap searchBoxNormal">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" id="promotion-form" @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 id="promotion-createDate" ref="rangeCreateDate" :value="createDate" @change="dateCreateChange" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="5" :sm="24">
  14. <a-form-item label="促销名称">
  15. <a-input id="promotion-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="promotionType"
  23. id="promotion-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="promoState"
  34. id="promotion-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. <div class="table-page-search-submitButtons">
  42. <a-button type="primary" :disabled="disabled" id="promotion-refresh" @click="$refs.table.refresh(true)">查询</a-button>
  43. <a-button style="margin-left: 8px" :disabled="disabled" id="promotion-reset" @click="resetSearchForm()">重置</a-button>
  44. </div>
  45. </a-col>
  46. </a-row>
  47. </a-form>
  48. </div>
  49. </a-card>
  50. <!-- 列表 -->
  51. <a-card size="small" :bordered="false">
  52. <a-spin :spinning="spinning" tip="Loading...">
  53. <!-- 操作按钮 -->
  54. <div class="table-operator" v-if="$hasPermissions('B_promoActivitiesAdd')">
  55. <!-- <a-button type="primary" class="button-info" id="promotion-add1-btn" @click="handleEdit('BUY_PROD_GIVE_PROD')">买产品送产品</a-button> -->
  56. <a-button type="primary" class="button-info" id="promotion-add2-btn" @click="handleEdit('PROMO_PROD')">特价产品</a-button>
  57. <a-button type="primary" class="button-info" id="promotion-add3-btn" @click="handleEdit('BUY_PROD_GIVE_VALID')">买产品返代金券</a-button>
  58. </div>
  59. <s-table
  60. class="sTable fixPagination"
  61. ref="table"
  62. :style="{ height: tableHeight+70+'px' }"
  63. size="small"
  64. :rowKey="(record) => record.id"
  65. :columns="columns"
  66. :data="loadData"
  67. :scroll="{ y: tableHeight }"
  68. :defaultLoadData="false"
  69. bordered>
  70. <!-- 促销名称 -->
  71. <template slot="promotionName" slot-scope="text, record">
  72. <div :id="'promotion-info-'+record.id" v-if="$hasPermissions('B_promoActivitiesDetail')" class="link-bule nameBox text-overflows2" @click="handleDetail(record)">{{ record.promoName }}</div>
  73. <div v-else class="nameBox text-overflows2">{{ record.promoName }}</div>
  74. </template>
  75. <!-- 促销时间 -->
  76. <template slot="promotionTime" slot-scope="text, record">
  77. <span>{{ record.promoStartDate }}至{{ record.promoEndDate }}</span>
  78. </template>
  79. <!-- 参与经销商 -->
  80. <template slot="joinCustomers" slot-scope="text, record">
  81. <span @click="handleCustomers(record)" :id="'promotion-seeDealerInfo-'+record.id" v-if="record.allDealerFlag&&record.allDealerFlag!='1'">共有<span class="link-bule">{{ record.dealerSnList.length }}</span>个客户</span>
  82. <span v-else>全部经销商</span>
  83. </template>
  84. <!-- 促销类型 -->
  85. <template slot="salesDesc" slot-scope="text, record">
  86. <a-tooltip placement="rightBottom" v-if="record.description&&record.description.length>14">
  87. <template slot="title">
  88. <span>{{ record.description }}</span>
  89. </template>
  90. <div @click="promotionDesc(record)" :id="'promotion-description-'+record.id" class="link-bule">{{ record.description }}</div>
  91. </a-tooltip>
  92. <div v-else-if="!record.description" class="desc">--</div>
  93. <div v-else @click="promotionDesc(record)" :id="'promotion-description1-'+record.id" class="link-bule">{{ record.description }}</div>
  94. </template>
  95. <!-- 操作 -->
  96. <!-- promoState状态 END已结束 HAVE_DISCARD已废弃 HAVE_RELEASE 已发布 NOT_RELEASE 未发布 -->
  97. <template slot="action" slot-scope="text, record">
  98. <div>
  99. <a-button
  100. size="small"
  101. type="link"
  102. class="button-warning"
  103. :id="'promotion-edit-btn-'+record.id"
  104. @click="handleEdit('edit',record)"
  105. v-if="(record.promoState=='NOT_RELEASE') && $hasPermissions('B_promoActivitiesEdit')">编辑</a-button>
  106. <a-button
  107. size="small"
  108. type="link"
  109. class="button-warning"
  110. :id="'promotion-abandon-btn-'+record.id"
  111. v-if="(record.promoState=='HAVE_RELEASE') && $hasPermissions('B_promoActivitiesAbandon')"
  112. @click="handleAbandon(record)">废弃</a-button>
  113. <a-button
  114. size="small"
  115. type="link"
  116. class="button-warning"
  117. :id="'promotion-img-btn-'+record.id"
  118. v-if="(record.promoState=='HAVE_RELEASE') && $hasPermissions('B_promoActivitiesImg')"
  119. @click="handleSet(record)">轮播图</a-button>
  120. <a-button
  121. size="small"
  122. type="link"
  123. class="button-info"
  124. @click="handleRelease(record)"
  125. v-if="record.promoState=='NOT_RELEASE'&&$hasPermissions('B_promoActivitiesRelease')"
  126. :id="'promotion-release-btn-'+record.id">发布</a-button>
  127. <a-button
  128. size="small"
  129. type="link"
  130. class="button-error"
  131. v-if="record.promoState=='NOT_RELEASE'&&$hasPermissions('B_promoActivitiesDel')"
  132. @click="handleDel(record)"
  133. :id="'promotion-del-btn-'+record.id">删除</a-button>
  134. </div>
  135. </template>
  136. </s-table>
  137. </a-spin>
  138. <!-- 参与经销商 -->
  139. <lookUp-customers-modal ref="lookUpCustomers" :openModal="openCustomerModal" @close="openCustomerModal = false"></lookUp-customers-modal>
  140. <!-- 详情 -->
  141. <detail-Modal :openModal="openDetailModal" :itemSn="itemId" @close="closeDetailModal" @ok="$refs.table.refresh()" />
  142. <!-- 轮播图修改弹窗 -->
  143. <a-modal
  144. closable
  145. v-model="openSetImgModal"
  146. :footer="null"
  147. width="416px"
  148. centered>
  149. <div style="display:flex;margin:30px 0 20px 20px;">
  150. <a-icon type="question-circle" :style="{fontSize:'20px',color:'#faad14'}"/>
  151. <div style="margin-left:10px;margin-top:-3px;">
  152. <p style="font-size:16px;font-wight:bold;">设置</p>
  153. <p>确定设为首页轮播图吗?</p>
  154. </div>
  155. </div>
  156. <!-- 按钮 -->
  157. <div style="text-align: right;">
  158. <a-button
  159. id="auditModal-cancel"
  160. type="primary"
  161. @click="handleSetModal('0')"
  162. style="margin-right: 15px;">取消</a-button>
  163. <a-button
  164. type="primary"
  165. id="auditModal-save"
  166. class="button-info"
  167. @click="handleSetModal('1')"
  168. >确定</a-button>
  169. </div>
  170. </a-modal>
  171. </a-card>
  172. </div>
  173. </template>
  174. <script>
  175. import { commonMixin } from '@/utils/mixin'
  176. // 组件
  177. import { STable, VSelect } from '@/components'
  178. import rangeDate from '@/views/common/rangeDate.vue'
  179. import lookUpCustomersModal from './lookUpCustomersModal'
  180. import detailModal from './detailModal'
  181. // 接口
  182. import { shopPromoActiveList, shopPromoDel, shopPromoRelease, shopPromoDiscard, updateShopBanner } from '@/api/shopPromo'
  183. export default {
  184. name: 'PromotionalActivitiesList',
  185. mixins: [commonMixin],
  186. components: { STable, VSelect, rangeDate, lookUpCustomersModal, detailModal },
  187. data () {
  188. return {
  189. spinning: false,
  190. tableHeight: 0, // 表格高度
  191. disabled: false, // 查询、重置按钮是否可操作
  192. openCustomerModal: false, // 打开参与经销商弹窗
  193. openDetailModal: false, // 打开详情弹窗
  194. createDate: [], // 创建时间
  195. openSetImgModal: false, // 设置首页轮播图弹窗
  196. // 查询参数
  197. queryParam: {
  198. beginDate: undefined, // 促销开始时间
  199. endDate: undefined, // 促销结束时间
  200. promoName: '', // 促销名称
  201. promoType: undefined, // 促销类型
  202. promoState: undefined// 是否发布
  203. },
  204. itemId: '', // 当前活动sn
  205. itemObj: null, // 促销活动当前行信息
  206. // 加载数据方法 必须为 Promise 对象
  207. loadData: parameter => {
  208. this.disabled = true
  209. this.spinning = true
  210. const params = Object.assign(parameter, this.queryParam)
  211. return shopPromoActiveList(params).then(res => {
  212. let data
  213. if (res.status == 200) {
  214. data = res.data
  215. const no = (data.pageNo - 1) * data.pageSize
  216. for (var i = 0; i < data.list.length; i++) {
  217. data.list[i].no = no + i + 1
  218. }
  219. this.disabled = false
  220. }
  221. this.spinning = false
  222. return data
  223. })
  224. },
  225. // 表头
  226. columns: [
  227. { title: '序号', dataIndex: 'no', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  228. { title: '创建时间', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  229. { title: '促销名称', scopedSlots: { customRender: 'promotionName' }, width: '18%', align: 'left' },
  230. { title: '促销时间', scopedSlots: { customRender: 'promotionTime' }, width: '18%', align: 'center' },
  231. { title: '参与经销商', scopedSlots: { customRender: 'joinCustomers' }, width: '8%', align: 'center' },
  232. { title: '促销类型', dataIndex: 'promoTypeDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  233. { title: '加盟商编辑', dataIndex: 'dealerEditFlag', width: '6%', align: 'center', customRender: function (text) { return (text ? text == '1' ? '是' : '否' : '--') } },
  234. { title: '首页轮播图', dataIndex: 'shopBannerFlag', width: '6%', align: 'center', customRender: function (text) { return (text ? text == '1' ? '是' : '否' : '--') } },
  235. { title: '促销状态', dataIndex: 'promoStateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  236. { title: '操作', scopedSlots: { customRender: 'action' }, width: '11%', align: 'center' }
  237. ]
  238. }
  239. },
  240. methods: {
  241. // 创建时间 change
  242. dateCreateChange (date) {
  243. this.queryParam.beginDate = date[0]
  244. this.queryParam.endDate = date[1]
  245. },
  246. // 参与经销商
  247. handleCustomers (row) {
  248. this.openCustomerModal = true
  249. this.$nextTick(() => {
  250. this.$refs.lookUpCustomers.pageInit({ dealerSnList: row.dealerSnList ? row.dealerSnList : undefined, promoActiveSn: row.promoActiveSn })
  251. })
  252. },
  253. // 新增 编辑
  254. handleEdit (type, row) {
  255. if (type === 'edit') {
  256. this.$router.push({ name: 'promotionalEditActivity', params: { pageType: type, sn: row.promoSn } })
  257. } else {
  258. this.$router.push({ name: 'promotionalAddActivity', params: { pageType: type } })
  259. }
  260. },
  261. // 删除促销活动
  262. handleDel (row) {
  263. const _this = this
  264. this.$confirm({
  265. title: '提示',
  266. content: '点击确定,该内容将会被删除,不可再恢复!',
  267. centered: true,
  268. onOk () {
  269. _this.spinning = true
  270. shopPromoDel({ promoSn: row.promoSn }).then(res => {
  271. if (res.status == 200) {
  272. _this.$message.success(res.message)
  273. _this.$refs.table.refresh()
  274. _this.spinning = false
  275. } else {
  276. _this.spinning = false
  277. }
  278. })
  279. }
  280. })
  281. },
  282. // 废弃
  283. handleAbandon (row) {
  284. const _this = this
  285. this.$confirm({
  286. title: '提示',
  287. content: '确认要废弃该促销活动吗?',
  288. centered: true,
  289. onOk () {
  290. _this.spinning = true
  291. shopPromoDiscard({ promoSn: row.promoSn }).then(res => {
  292. if (res.status == 200) {
  293. _this.$message.success(res.message)
  294. _this.$refs.table.refresh()
  295. _this.spinning = false
  296. } else {
  297. _this.spinning = false
  298. }
  299. })
  300. }
  301. })
  302. },
  303. // 重置
  304. resetSearchForm () {
  305. this.createDate = []
  306. this.$refs.rangeCreateDate.resetDate([])
  307. this.queryParam.beginDate = undefined
  308. this.queryParam.endDate = undefined
  309. this.queryParam.promoName = ''
  310. this.queryParam.promoType = undefined
  311. this.queryParam.promoState = undefined
  312. this.$refs.table.refresh(true)
  313. },
  314. // 促销发布
  315. handleRelease (row, type) {
  316. const _this = this
  317. this.$confirm({
  318. title: '提示',
  319. content: '确认要发布该促销活动吗?',
  320. centered: true,
  321. onOk () {
  322. _this.spinning = true
  323. shopPromoRelease({ promoSn: row.promoSn }).then(res => {
  324. if (res.status == 200) {
  325. _this.$message.success(res.message)
  326. _this.$refs.table.refresh()
  327. _this.spinning = false
  328. } else {
  329. _this.spinning = false
  330. }
  331. })
  332. }
  333. })
  334. },
  335. // 打开 设置轮播图弹窗
  336. handleSet (row) {
  337. this.itemObj = row
  338. this.openSetImgModal = true
  339. },
  340. // 设置轮播图
  341. handleSetModal (val) {
  342. const _this = this
  343. _this.spinning = true
  344. updateShopBanner({ promoSn: _this.itemObj.promoSn, shopBannerFlag: val }).then(res => {
  345. if (res.status == 200) {
  346. _this.$message.success(res.message)
  347. _this.$refs.table.refresh()
  348. _this.openSetImgModal = false
  349. _this.itemObj = null
  350. _this.spinning = false
  351. } else {
  352. _this.spinning = false
  353. }
  354. })
  355. },
  356. // 打开详情
  357. handleDetail (row) {
  358. this.openDetailModal = true
  359. this.itemId = row.promoSn
  360. },
  361. // 关闭详情
  362. closeDetailModal () {
  363. this.openDetailModal = false
  364. this.itemId = ''
  365. },
  366. // 初始化
  367. pageInit () {
  368. const _this = this
  369. this.$nextTick(() => { // 页面渲染完成后的回调
  370. _this.setTableH()
  371. })
  372. },
  373. // 计算表格高度
  374. setTableH () {
  375. const tableSearchH = this.$refs.tableSearch.offsetHeight
  376. this.tableHeight = window.innerHeight - tableSearchH - 240
  377. }
  378. },
  379. watch: {
  380. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  381. this.setTableH()
  382. }
  383. },
  384. mounted () {
  385. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  386. this.pageInit()
  387. this.resetSearchForm()
  388. }
  389. },
  390. activated () {
  391. // 如果是新页签打开,则重置当前页面
  392. if (this.$store.state.app.isNewTab) {
  393. this.pageInit()
  394. this.resetSearchForm()
  395. }
  396. // 仅刷新列表,不重置页面
  397. if (this.$store.state.app.updateList) {
  398. this.pageInit()
  399. this.$refs.table.refresh()
  400. }
  401. },
  402. beforeRouteEnter (to, from, next) {
  403. next(vm => {})
  404. }
  405. }
  406. </script>
  407. <style lang="less" scoped>
  408. .font1{
  409. color:#39f;
  410. }
  411. .desc{
  412. width: 100%;
  413. padding:0 10px;
  414. overflow: hidden;
  415. text-overflow: ellipsis;
  416. display: -webkit-box;
  417. box-sizing: border-box;
  418. -webkit-line-clamp: 3;
  419. -webkit-box-orient: vertical;
  420. }
  421. </style>