list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  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" @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="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="saleStatus"
  23. id="promotion-saleStatus"
  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" @click="$refs.table.refresh(true)">查询</a-button>
  32. <a-button style="margin-left: 8px" :disabled="disabled" @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" @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)" 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)" 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)" class="link-bule">{{ record.description }}</div>
  80. </template>
  81. <!-- 促销展示 -->
  82. <template slot="salesShow" slot-scope="text, record">
  83. <div @click="handleSaleShow(record)" 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. @click="promotionEdit(record)"
  100. v-if="(record.publishState=='UNPUBLISH' || record.publishState=='CLOSE') && $hasPermissions('B_promotionManagementEdit')"
  101. id="promotion-edit-btn">编辑</a-button>
  102. <a-button
  103. size="small"
  104. type="link"
  105. class="button-warning"
  106. @click="handleRelease(record,'edit')"
  107. 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')"
  108. id="promotion-modify-btn">发布修改</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-modify-btn">查看</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">发布</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">删除</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. import { STable, VSelect } from '@/components'
  150. import rangeDate from '@/views/common/rangeDate.vue'
  151. import lookUpCustomersModal from './lookUpCustomersModal'
  152. import promotionDescModal from './promotionDescModal'
  153. import promotionShowModal from './promotionShowModal'
  154. import addModal from './addModal'
  155. import detailModal from './detailModal'
  156. import { updateShowFlag } from '@/api/promoTerminal'
  157. import { promoActiveList, promoActiveDel } from '@/api/promoActive'
  158. export default {
  159. name: 'PromotionList',
  160. mixins: [commonMixin],
  161. components: { STable, VSelect, rangeDate, lookUpCustomersModal, promotionShowModal, promotionDescModal, addModal, detailModal },
  162. data () {
  163. return {
  164. spinning: false,
  165. tableHeight: 0,
  166. disabled: false, // 查询、重置按钮是否可操作
  167. openCustomerModal: false,
  168. openDescModal: false,
  169. openShowModal: false,
  170. openAddModal: false,
  171. openDetailModal: false,
  172. createDate: [], // 创建时间
  173. itemId: '',
  174. descCon: '', // 描述内容
  175. pageType: '', // 发布类型 add 促销发布 edit 发布修改
  176. dealerSn: [],
  177. // 查询参数
  178. queryParam: {
  179. beginDate: undefined,
  180. endDate: undefined,
  181. name: '',
  182. showFlag: undefined,
  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. data.list[i].isEnable = data.list[i].showFlag + '' === '1'
  198. }
  199. this.disabled = false
  200. }
  201. this.spinning = false
  202. return data
  203. })
  204. },
  205. columns: [
  206. { title: '序号', dataIndex: 'no', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  207. { title: '创建时间', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  208. { title: '促销名称', dataIndex: 'name', width: '12%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  209. { title: '标题', dataIndex: 'title', width: '12%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  210. { title: '促销时间', scopedSlots: { customRender: 'promotionTime' }, width: '8%', align: 'center' },
  211. { title: '参与客户', scopedSlots: { customRender: 'joinCustomers' }, width: '12%', align: 'center' },
  212. { title: '促销描述', scopedSlots: { customRender: 'salesDesc' }, width: '12%', align: 'center' },
  213. { title: '促销展示', scopedSlots: { customRender: 'salesShow' }, width: '6%', align: 'center' },
  214. // { slots: { title: 'arrowFalgTitle' }, scopedSlots: { customRender: 'arrowFalg' }, width: '6%', align: 'center' },
  215. { title: '促销状态', scopedSlots: { customRender: 'stateVal' }, width: '6%', align: 'center' },
  216. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  217. ]
  218. }
  219. },
  220. methods: {
  221. // 关闭添加促销活动弹窗
  222. closeAddModal () {
  223. this.openAddModal = false; this.itemId = ''
  224. },
  225. // 参与经销商
  226. handleCustomers (row) {
  227. this.openCustomerModal = true
  228. this.$nextTick(() => {
  229. this.$refs.lookUpCustomers.pageInit({ dealerSnList: row.dealerSnList ? row.dealerSnList : undefined, promoActiveSn: row.promoActiveSn })
  230. })
  231. },
  232. // 创建时间 change
  233. dateCreateChange (date) {
  234. this.queryParam.beginDate = date[0]
  235. this.queryParam.endDate = date[1]
  236. },
  237. // 促销展示
  238. handleSaleShow (record) {
  239. this.openShowModal = true
  240. this.$nextTick(() => {
  241. this.$refs.showModal.pageInit({ type: record.contentType, con: record.content })
  242. })
  243. },
  244. // 修改显示状态
  245. changeFlagHandle (record) {
  246. const _data = {
  247. sn: record.promoActiveSn,
  248. showFlag: record.isEnable ? '1' : '0'
  249. }
  250. this.spinning = true
  251. updateShowFlag(_data).then(res => {
  252. if (res.status == 200) {
  253. this.$message.success(res.message)
  254. this.$refs.table.refresh()
  255. this.spinning = false
  256. } else {
  257. this.$refs.table.refresh()
  258. this.spinning = false
  259. }
  260. })
  261. },
  262. // 促销编辑
  263. promotionEdit (item) {
  264. this.itemId = item.promoActiveSn
  265. this.$nextTick(() => {
  266. this.openAddModal = true
  267. })
  268. },
  269. // 促销描述
  270. promotionDesc (row) {
  271. this.descCon = row.description
  272. this.$nextTick(() => {
  273. this.openDescModal = true
  274. })
  275. },
  276. // 删除促销活动
  277. handleDel (row) {
  278. const _this = this
  279. this.$confirm({
  280. title: '提示',
  281. content: '点击确定,该内容将会被删除,不可再恢复!',
  282. centered: true,
  283. onOk () {
  284. _this.spinning = true
  285. promoActiveDel({ sn: row.promoActiveSn }).then(res => {
  286. if (res.status == 200) {
  287. _this.$message.success(res.message)
  288. _this.$refs.table.refresh()
  289. _this.spinning = false
  290. } else {
  291. _this.spinning = false
  292. }
  293. })
  294. }
  295. })
  296. },
  297. resetSearchForm () {
  298. this.$refs.rangeCreateDate.resetDate(this.createDate)
  299. this.queryParam.beginDate = undefined
  300. this.queryParam.endDate = undefined
  301. this.queryParam.name = ''
  302. this.queryParam.showFlag = undefined
  303. this.queryParam.publishState = undefined
  304. this.$refs.table.refresh(true)
  305. },
  306. // 促销发布
  307. handleRelease (row, type) {
  308. const newType = row.imageSet && row.imageSet.length > 0 ? 'edit' : type
  309. this.$router.push({ name: 'promotionManagementAdd', params: { sn: row.promoActiveSn, pageType: newType } })
  310. },
  311. // 打开详情
  312. handleSee (row) {
  313. this.openDetailModal = true
  314. this.itemId = row.promoActiveSn
  315. },
  316. // 关闭详情
  317. closeDetailModal () {
  318. this.openDetailModal = false
  319. this.itemId = ''
  320. },
  321. pageInit () {
  322. const _this = this
  323. this.$nextTick(() => { // 页面渲染完成后的回调
  324. _this.setTableH()
  325. })
  326. },
  327. setTableH () {
  328. const tableSearchH = this.$refs.tableSearch.offsetHeight
  329. this.tableHeight = window.innerHeight - tableSearchH - 240
  330. }
  331. },
  332. watch: {
  333. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  334. this.setTableH()
  335. }
  336. },
  337. mounted () {
  338. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  339. this.pageInit()
  340. this.resetSearchForm()
  341. }
  342. },
  343. activated () {
  344. // 如果是新页签打开,则重置当前页面
  345. if (this.$store.state.app.isNewTab) {
  346. this.pageInit()
  347. this.resetSearchForm()
  348. }
  349. // 仅刷新列表,不重置页面
  350. if (this.$store.state.app.updateList) {
  351. this.pageInit()
  352. this.$refs.table.refresh()
  353. }
  354. },
  355. beforeRouteEnter (to, from, next) {
  356. next(vm => {})
  357. }
  358. }
  359. </script>
  360. <style lang="less" scoped>
  361. .font1{
  362. color:#39f;
  363. }
  364. .desc{
  365. width: 100%;
  366. padding:0 10px;
  367. overflow: hidden;
  368. text-overflow: ellipsis;
  369. display: -webkit-box;
  370. box-sizing: border-box;
  371. -webkit-line-clamp: 3;
  372. -webkit-box-orient: vertical;
  373. }
  374. </style>