list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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_promotionManagementAdd')"
  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')&&$hasPermissions('B_promotionManagementContent')"
  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. <span v-if="record.publishState=='End'">--</span>
  131. </div>
  132. </template>
  133. </s-table>
  134. </a-spin>
  135. <!-- 参与客户 -->
  136. <lookUp-customers-modal ref="lookUpCustomers" :openModal="openCustomerModal" @close="openCustomerModal = false"></lookUp-customers-modal>
  137. <!-- 促销描述 -->
  138. <promotion-desc-modal :openModal="openDescModal" :con="descCon" @close="openDescModal = false;descCon=''"></promotion-desc-modal>
  139. <!-- 促销展示 -->
  140. <promotion-show-modal ref="showModal" :openModal="openShowModal" @close="openShowModal = false"></promotion-show-modal>
  141. <!-- 新增 -->
  142. <addModal :openModal="openAddModal" :itemId="itemId" @close="closeAddModal" @ok="$refs.table.refresh()"></addModal>
  143. <!-- 查看 -->
  144. <detail-Modal :openModal="openDetailModal" :itemSn="itemId" @close="closeDetailModal" @ok="$refs.table.refresh()" />
  145. </a-card>
  146. </div>
  147. </template>
  148. <script>
  149. import { commonMixin } from '@/utils/mixin'
  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. import { updateShowFlag } from '@/api/promoTerminal'
  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: '',
  175. descCon: '', // 描述内容
  176. pageType: '', // 发布类型 add 促销发布 edit 发布修改
  177. dealerSn: [],
  178. // 查询参数
  179. queryParam: {
  180. beginDate: undefined,
  181. endDate: undefined,
  182. name: '',
  183. showFlag: undefined,
  184. publishState: undefined
  185. },
  186. // 加载数据方法 必须为 Promise 对象
  187. loadData: parameter => {
  188. this.disabled = true
  189. this.spinning = true
  190. const params = Object.assign(parameter, this.queryParam)
  191. return promoActiveList(params).then(res => {
  192. let data
  193. if (res.status == 200) {
  194. data = res.data
  195. const no = (data.pageNo - 1) * data.pageSize
  196. for (var i = 0; i < data.list.length; i++) {
  197. data.list[i].no = no + i + 1
  198. data.list[i].isEnable = data.list[i].showFlag + '' === '1'
  199. }
  200. this.disabled = false
  201. }
  202. this.spinning = false
  203. return data
  204. })
  205. },
  206. columns: [
  207. { title: '序号', dataIndex: 'no', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  208. { title: '创建时间', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  209. { title: '促销名称', dataIndex: 'name', width: '12%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  210. { title: '标题', dataIndex: 'title', width: '12%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  211. { title: '促销时间', scopedSlots: { customRender: 'promotionTime' }, width: '8%', align: 'center' },
  212. { title: '参与客户', scopedSlots: { customRender: 'joinCustomers' }, width: '12%', align: 'center' },
  213. { title: '促销描述', scopedSlots: { customRender: 'salesDesc' }, width: '12%', align: 'center' },
  214. { title: '促销展示', scopedSlots: { customRender: 'salesShow' }, width: '6%', align: 'center' },
  215. // { slots: { title: 'arrowFalgTitle' }, scopedSlots: { customRender: 'arrowFalg' }, width: '6%', align: 'center' },
  216. { title: '促销状态', scopedSlots: { customRender: 'stateVal' }, width: '6%', align: 'center' },
  217. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  218. ]
  219. }
  220. },
  221. methods: {
  222. // 关闭添加促销活动弹窗
  223. closeAddModal () {
  224. this.openAddModal = false; this.itemId = ''
  225. },
  226. // 参与经销商
  227. handleCustomers (row) {
  228. this.openCustomerModal = true
  229. this.$nextTick(() => {
  230. this.$refs.lookUpCustomers.pageInit({ dealerSnList: row.dealerSnList ? row.dealerSnList : undefined, promoActiveSn: row.promoActiveSn })
  231. })
  232. },
  233. // 创建时间 change
  234. dateCreateChange (date) {
  235. this.queryParam.beginDate = date[0]
  236. this.queryParam.endDate = date[1]
  237. },
  238. // 促销展示
  239. handleSaleShow (record) {
  240. this.openShowModal = true
  241. this.$nextTick(() => {
  242. this.$refs.showModal.pageInit({ type: record.contentType, con: record.content })
  243. })
  244. },
  245. // 修改显示状态
  246. changeFlagHandle (record) {
  247. const _data = {
  248. sn: record.promoActiveSn,
  249. showFlag: record.isEnable ? '1' : '0'
  250. }
  251. this.spinning = true
  252. updateShowFlag(_data).then(res => {
  253. if (res.status == 200) {
  254. this.$message.success(res.message)
  255. this.$refs.table.refresh()
  256. this.spinning = false
  257. } else {
  258. this.$refs.table.refresh()
  259. this.spinning = false
  260. }
  261. })
  262. },
  263. // 促销编辑
  264. promotionEdit (item) {
  265. this.itemId = item.promoActiveSn
  266. this.$nextTick(() => {
  267. this.openAddModal = true
  268. })
  269. },
  270. // 促销描述
  271. promotionDesc (row) {
  272. this.descCon = row.description
  273. this.$nextTick(() => {
  274. this.openDescModal = true
  275. })
  276. },
  277. // 删除促销活动
  278. handleDel (row) {
  279. const _this = this
  280. this.$confirm({
  281. title: '提示',
  282. content: '点击确定,该内容将会被删除,不可再恢复!',
  283. centered: true,
  284. onOk () {
  285. _this.spinning = true
  286. promoActiveDel({ sn: row.promoActiveSn }).then(res => {
  287. if (res.status == 200) {
  288. _this.$message.success(res.message)
  289. _this.$refs.table.refresh()
  290. _this.spinning = false
  291. } else {
  292. _this.spinning = false
  293. }
  294. })
  295. }
  296. })
  297. },
  298. resetSearchForm () {
  299. this.$refs.rangeCreateDate.resetDate(this.createDate)
  300. this.queryParam.beginDate = undefined
  301. this.queryParam.endDate = undefined
  302. this.queryParam.name = ''
  303. this.queryParam.showFlag = undefined
  304. this.queryParam.publishState = undefined
  305. this.$refs.table.refresh(true)
  306. },
  307. // 促销发布
  308. handleRelease (row, type) {
  309. const newType = row.imageSet && row.imageSet.length > 0 ? 'edit' : type
  310. this.$router.push({ name: 'promotionManagementAdd', params: { sn: row.promoActiveSn, pageType: newType } })
  311. },
  312. // 打开详情
  313. handleSee (row) {
  314. this.openDetailModal = true
  315. this.itemId = row.promoActiveSn
  316. },
  317. // 关闭详情
  318. closeDetailModal () {
  319. this.openDetailModal = false
  320. this.itemId = ''
  321. },
  322. pageInit () {
  323. const _this = this
  324. this.$nextTick(() => { // 页面渲染完成后的回调
  325. _this.setTableH()
  326. })
  327. },
  328. setTableH () {
  329. const tableSearchH = this.$refs.tableSearch.offsetHeight
  330. this.tableHeight = window.innerHeight - tableSearchH - 240
  331. }
  332. },
  333. watch: {
  334. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  335. this.setTableH()
  336. }
  337. },
  338. mounted () {
  339. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  340. this.pageInit()
  341. this.resetSearchForm()
  342. }
  343. },
  344. activated () {
  345. // 如果是新页签打开,则重置当前页面
  346. if (this.$store.state.app.isNewTab) {
  347. this.pageInit()
  348. this.resetSearchForm()
  349. }
  350. // 仅刷新列表,不重置页面
  351. if (this.$store.state.app.updateList) {
  352. this.pageInit()
  353. this.$refs.table.refresh()
  354. }
  355. },
  356. beforeRouteEnter (to, from, next) {
  357. next(vm => {})
  358. }
  359. }
  360. </script>
  361. <style lang="less" scoped>
  362. .font1{
  363. color:#39f;
  364. }
  365. .desc{
  366. width: 100%;
  367. padding:0 10px;
  368. overflow: hidden;
  369. text-overflow: ellipsis;
  370. display: -webkit-box;
  371. box-sizing: border-box;
  372. -webkit-line-clamp: 3;
  373. -webkit-box-orient: vertical;
  374. }
  375. </style>