list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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="6" :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="6" :sm="24">
  14. <a-form-item label="促销名称">
  15. <a-input id="promotion-promotionName" 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
  21. v-model="queryParam.publishState"
  22. ref="publishState"
  23. id="promotion-publishState"
  24. code="PROMO_STATE"
  25. placeholder="请选择促销状态"
  26. allowClear></v-select>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="6" :sm="24">
  30. <span class="table-page-search-submitButtons">
  31. <a-button type="primary" :disabled="disabled" id="promotion-refresh" @click="$refs.table.refresh(true)">查询</a-button>
  32. <a-button style="margin-left: 8px" :disabled="disabled" id="promotion-reset" @click="resetSearchForm()">重置</a-button>
  33. </span>
  34. </a-col>
  35. </a-row>
  36. </a-form>
  37. </div>
  38. </a-card>
  39. <!-- 列表 -->
  40. <a-card size="small" :bordered="false">
  41. <a-spin :spinning="spinning" tip="Loading...">
  42. <!-- 操作按钮 -->
  43. <div class="table-operator" v-if="$hasPermissions('B_promotionManagementAdd')">
  44. <a-button type="primary" id="promotion-add-btn" @click="openAddModal = true">新增</a-button>
  45. </div>
  46. <s-table
  47. class="sTable fixPagination"
  48. ref="table"
  49. :style="{ height: tableHeight+70+'px' }"
  50. size="small"
  51. :rowKey="(record) => record.id"
  52. :columns="columns"
  53. :data="loadData"
  54. :scroll="{ y: tableHeight }"
  55. :defaultLoadData="false"
  56. bordered>
  57. <!-- 促销状态 -->
  58. <template slot="stateVal" slot-scope="text, record">
  59. <span>{{ record.publishState==='UNPUBLISH'?'未发布':record.publishState==='PUBLISH'?'已发布':record.publishState==='CLOSE'?'已关闭':'已结束' }}</span>
  60. </template>
  61. <!-- 促销时间 -->
  62. <template slot="promotionTime" slot-scope="text, record">
  63. <span>{{ record.activeDateStart }}至{{ record.activeDateEnd }}</span>
  64. </template>
  65. <!-- 参与客户 -->
  66. <template slot="joinCustomers" slot-scope="text, record">
  67. <span @click="handleCustomers(record)" :id="'promotion-seeDealerInfo-'+record.id" v-if="record.dealerSnList&&record.dealerSnList.length>0">共有<span class="link-bule">{{ record.dealerSnList.length }}</span>个客户</span>
  68. <span v-else>共有0个客户</span>
  69. </template>
  70. <!-- 促销描述 -->
  71. <template slot="salesDesc" slot-scope="text, record">
  72. <a-tooltip placement="rightBottom" v-if="record.description&&record.description.length>14">
  73. <template slot="title">
  74. <span>{{ record.description }}</span>
  75. </template>
  76. <div @click="promotionDesc(record)" :id="'promotion-description-'+record.id" class="link-bule">{{ record.description }}</div>
  77. </a-tooltip>
  78. <div v-else-if="!record.description" class="desc">--</div>
  79. <div v-else @click="promotionDesc(record)" :id="'promotion-description-'+record.id" class="link-bule">{{ record.description }}</div>
  80. </template>
  81. <!-- 促销展示 -->
  82. <template slot="salesShow" slot-scope="text, record">
  83. <div @click="handleSaleShow(record)" :id="'promotion-seeImgInfo-'+record.id" v-if="record.contentType!='LINK'&&record.imageSet && record.imageSet.length>0">
  84. <img :src="record.imageSet[0]" alt="图片走丢啦" width="60" />
  85. </div>
  86. <div v-else-if="record.contentType=='LINK'&&record.imageSet && record.imageSet.length>0">
  87. <img :src="record.imageSet[0]" alt="图片走丢啦" width="60" />
  88. </div>
  89. <span v-else>--</span>
  90. </template>
  91. <!-- 操作 -->
  92. <!-- state状态 END已结束 CLOSE已关闭 PUBLISH 已发布 UNPUBLISH 未发布 -->
  93. <template slot="action" slot-scope="text, record">
  94. <div>
  95. <a-button
  96. size="small"
  97. type="link"
  98. class="button-warning"
  99. :id="'promotion-edit-btn-'+record.id"
  100. @click="promotionEdit(record)"
  101. v-if="(record.publishState=='UNPUBLISH' || record.publishState=='CLOSE') && $hasPermissions('B_promotionManagementEdit')">编辑</a-button>
  102. <a-button
  103. size="small"
  104. type="link"
  105. class="button-warning"
  106. :id="'promotion-modify-btn-'+record.id"
  107. @click="handleRelease(record,'edit')"
  108. v-if="((record.publishState=='PUBLISH'&&record.content!='/pagesB/promoDetail')||(record.publishState=='PUBLISH'&&record.content==='/pagesB/promoDetail'&&record.dealerEditFlag==='0') || record.publishState=='CLOSE')&&$hasPermissions('B_promotionManagementContent')">发布修改</a-button>
  109. <a-button
  110. size="small"
  111. type="link"
  112. class="button-success"
  113. @click="handleSee(record)"
  114. v-if="(record.publishState=='PUBLISH' || record.publishState=='END')&&$hasPermissions('B_promotionManagementDetail')"
  115. :id="'promotion-seeDetail-btn-'+record.id">查看</a-button>
  116. <a-button
  117. size="small"
  118. type="link"
  119. class="button-info"
  120. @click="handleRelease(record,'add')"
  121. v-if="record.publishState=='UNPUBLISH'&&$hasPermissions('B_promotionManagementContent')"
  122. :id="'promotion-release-btn-'+record.id">发布</a-button>
  123. <a-button
  124. size="small"
  125. type="link"
  126. class="button-error"
  127. v-if="record.publishState=='UNPUBLISH'&&$hasPermissions('B_promotionManagementDel')"
  128. @click="handleDel(record)"
  129. :id="'promotion-del-btn-'+record.id">删除</a-button>
  130. </div>
  131. </template>
  132. </s-table>
  133. </a-spin>
  134. <!-- 参与客户 -->
  135. <lookUp-customers-modal ref="lookUpCustomers" :openModal="openCustomerModal" @close="openCustomerModal = false"></lookUp-customers-modal>
  136. <!-- 促销描述 -->
  137. <promotion-desc-modal :openModal="openDescModal" :con="descCon" @close="openDescModal = false;descCon=''"></promotion-desc-modal>
  138. <!-- 促销展示 -->
  139. <promotion-show-modal ref="showModal" :openModal="openShowModal" @close="openShowModal = false"></promotion-show-modal>
  140. <!-- 新增 -->
  141. <addModal :openModal="openAddModal" :itemId="itemId" @close="closeAddModal" @ok="$refs.table.refresh()"></addModal>
  142. <!-- 查看 -->
  143. <detail-Modal :openModal="openDetailModal" :itemSn="itemId" @close="closeDetailModal" @ok="$refs.table.refresh()" />
  144. </a-card>
  145. </div>
  146. </template>
  147. <script>
  148. import { commonMixin } from '@/utils/mixin'
  149. // 组件
  150. import { STable, VSelect } from '@/components'
  151. import rangeDate from '@/views/common/rangeDate.vue'
  152. import lookUpCustomersModal from './lookUpCustomersModal'
  153. import promotionDescModal from './promotionDescModal'
  154. import promotionShowModal from './promotionShowModal'
  155. import addModal from './addModal'
  156. import detailModal from './detailModal'
  157. // 接口
  158. import { promoActiveList, promoActiveDel } from '@/api/promoActive'
  159. export default {
  160. name: 'PromotionList',
  161. mixins: [commonMixin],
  162. components: { STable, VSelect, rangeDate, lookUpCustomersModal, promotionShowModal, promotionDescModal, addModal, detailModal },
  163. data () {
  164. return {
  165. spinning: false,
  166. tableHeight: 0, // 表格高度
  167. disabled: false, // 查询、重置按钮是否可操作
  168. openCustomerModal: false, // 打开参与客户弹窗
  169. openDescModal: false, // 打开促销描述弹窗
  170. openShowModal: false, // 打开促销展示弹窗
  171. openAddModal: false, // 打开新增弹窗
  172. openDetailModal: false, // 打开详情弹窗
  173. createDate: [], // 创建时间
  174. itemId: '', // 当前活动sn
  175. descCon: '', // 描述内容
  176. pageType: '', // 发布类型 add 促销发布 edit 发布修改
  177. dealerSn: [], // 经销商sn
  178. // 查询参数
  179. queryParam: {
  180. beginDate: undefined, // 促销开始时间
  181. endDate: undefined, // 促销结束时间
  182. name: '', // 促销名称
  183. publishState: undefined// 是否发布
  184. },
  185. // 加载数据方法 必须为 Promise 对象
  186. loadData: parameter => {
  187. this.disabled = true
  188. this.spinning = true
  189. const params = Object.assign(parameter, this.queryParam)
  190. return promoActiveList(params).then(res => {
  191. let data
  192. if (res.status == 200) {
  193. data = res.data
  194. const no = (data.pageNo - 1) * data.pageSize
  195. for (var i = 0; i < data.list.length; i++) {
  196. data.list[i].no = no + i + 1
  197. }
  198. this.disabled = false
  199. }
  200. this.spinning = false
  201. return data
  202. })
  203. },
  204. columns: [// 表头
  205. { title: '序号', dataIndex: 'no', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  206. { title: '创建时间', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  207. { title: '促销名称', dataIndex: 'name', width: '12%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  208. { title: '标题', dataIndex: 'title', width: '12%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  209. { title: '促销时间', scopedSlots: { customRender: 'promotionTime' }, width: '8%', align: 'center' },
  210. { title: '参与客户', scopedSlots: { customRender: 'joinCustomers' }, width: '12%', align: 'center' },
  211. { title: '促销描述', scopedSlots: { customRender: 'salesDesc' }, width: '12%', align: 'center' },
  212. { title: '促销展示', scopedSlots: { customRender: 'salesShow' }, width: '6%', align: 'center' },
  213. // { slots: { title: 'arrowFalgTitle' }, scopedSlots: { customRender: 'arrowFalg' }, width: '6%', align: 'center' },
  214. { title: '促销状态', scopedSlots: { customRender: 'stateVal' }, width: '6%', align: 'center' },
  215. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  216. ]
  217. }
  218. },
  219. methods: {
  220. // 关闭添加促销活动弹窗
  221. closeAddModal () {
  222. this.openAddModal = false; this.itemId = ''
  223. },
  224. // 参与经销商
  225. handleCustomers (row) {
  226. this.openCustomerModal = true
  227. this.$nextTick(() => {
  228. this.$refs.lookUpCustomers.pageInit({ dealerSnList: row.dealerSnList ? row.dealerSnList : undefined, promoActiveSn: row.promoActiveSn })
  229. })
  230. },
  231. // 创建时间 change
  232. dateCreateChange (date) {
  233. this.queryParam.beginDate = date[0]
  234. this.queryParam.endDate = date[1]
  235. },
  236. // 促销展示
  237. handleSaleShow (record) {
  238. this.openShowModal = true
  239. this.$nextTick(() => {
  240. this.$refs.showModal.pageInit({ type: record.contentType, con: record.content })
  241. })
  242. },
  243. // 促销编辑
  244. promotionEdit (item) {
  245. this.itemId = item.promoActiveSn
  246. this.$nextTick(() => {
  247. this.openAddModal = true
  248. })
  249. },
  250. // 促销描述
  251. promotionDesc (row) {
  252. this.descCon = row.description
  253. this.$nextTick(() => {
  254. this.openDescModal = true
  255. })
  256. },
  257. // 删除促销活动
  258. handleDel (row) {
  259. const _this = this
  260. this.$confirm({
  261. title: '提示',
  262. content: '点击确定,该内容将会被删除,不可再恢复!',
  263. centered: true,
  264. onOk () {
  265. _this.spinning = true
  266. promoActiveDel({ sn: row.promoActiveSn }).then(res => {
  267. if (res.status == 200) {
  268. _this.$message.success(res.message)
  269. _this.$refs.table.refresh()
  270. _this.spinning = false
  271. } else {
  272. _this.spinning = false
  273. }
  274. })
  275. }
  276. })
  277. },
  278. // 重置
  279. resetSearchForm () {
  280. this.$refs.rangeCreateDate.resetDate(this.createDate)
  281. this.queryParam.beginDate = undefined
  282. this.queryParam.endDate = undefined
  283. this.queryParam.name = ''
  284. this.queryParam.publishState = undefined
  285. this.$refs.table.refresh(true)
  286. },
  287. // 促销发布
  288. handleRelease (row, type) {
  289. const newType = row.imageSet && row.imageSet.length > 0 ? 'edit' : type
  290. this.$router.push({ name: 'promotionManagementAdd', params: { sn: row.promoActiveSn, pageType: newType } })
  291. },
  292. // 打开详情
  293. handleSee (row) {
  294. this.openDetailModal = true
  295. this.itemId = row.promoActiveSn
  296. },
  297. // 关闭详情
  298. closeDetailModal () {
  299. this.openDetailModal = false
  300. this.itemId = ''
  301. },
  302. // 初始化
  303. pageInit () {
  304. const _this = this
  305. this.$nextTick(() => { // 页面渲染完成后的回调
  306. _this.setTableH()
  307. })
  308. },
  309. // 计算表格高度
  310. setTableH () {
  311. const tableSearchH = this.$refs.tableSearch.offsetHeight
  312. this.tableHeight = window.innerHeight - tableSearchH - 240
  313. }
  314. },
  315. watch: {
  316. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  317. this.setTableH()
  318. }
  319. },
  320. mounted () {
  321. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  322. this.pageInit()
  323. this.resetSearchForm()
  324. }
  325. },
  326. activated () {
  327. // 如果是新页签打开,则重置当前页面
  328. if (this.$store.state.app.isNewTab) {
  329. this.pageInit()
  330. this.resetSearchForm()
  331. }
  332. // 仅刷新列表,不重置页面
  333. if (this.$store.state.app.updateList) {
  334. this.pageInit()
  335. this.$refs.table.refresh()
  336. }
  337. },
  338. beforeRouteEnter (to, from, next) {
  339. next(vm => {})
  340. }
  341. }
  342. </script>
  343. <style lang="less" scoped>
  344. .font1{
  345. color:#39f;
  346. }
  347. .desc{
  348. width: 100%;
  349. padding:0 10px;
  350. overflow: hidden;
  351. text-overflow: ellipsis;
  352. display: -webkit-box;
  353. box-sizing: border-box;
  354. -webkit-line-clamp: 3;
  355. -webkit-box-orient: vertical;
  356. }
  357. </style>