list.vue 16 KB

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