list.vue 16 KB

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