list.vue 15 KB

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