list.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. <template>
  2. <a-card size="small" :bordered="false" class="promotionList-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="5" :sm="24">
  9. <a-form-item label="创建时间">
  10. <rangeDate ref="rangeDate" @change="dateChange" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="5" :sm="24">
  14. <a-form-item label="促销名称">
  15. <a-input id="promotionList-title" v-model.trim="queryParam.title" allowClear placeholder="请输入促销名称"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="5" :sm="24">
  19. <a-form-item label="发布状态">
  20. <v-select
  21. v-model="queryParam.enabledFlag"
  22. ref="enabledFlag"
  23. id="promotionList-enabledFlag"
  24. code="PUBLISH_STATE"
  25. placeholder="请选择发布状态"
  26. allowClear></v-select>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="5" :sm="24">
  30. <a-form-item label="活动状态">
  31. <v-select
  32. v-model="queryParam.state"
  33. ref="state"
  34. id="promotionList-state"
  35. code="PROMOTION_STATE"
  36. placeholder="请选择活动状态"
  37. allowClear
  38. ></v-select>
  39. </a-form-item>
  40. </a-col>
  41. <a-col :md="4" :sm="24">
  42. <span class="table-page-search-submitButtons">
  43. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="promotionList-refresh">查询</a-button>
  44. <a-button style="margin-left: 5px" @click="resetSearchForm()" :disabled="disabled" id="promotionList-reset">重置</a-button>
  45. <!-- <a-button
  46. style="margin-left: 10px"
  47. type="primary"
  48. class="button-warning"
  49. @click="handleExport"
  50. :disabled="disabled"
  51. :loading="exportLoading"
  52. >导出</a-button> -->
  53. <!-- v-if="$hasPermissions('B_promotionListExport')" -->
  54. </span>
  55. </a-col>
  56. </a-row>
  57. </a-form>
  58. </div>
  59. <!-- 操作按钮 -->
  60. <div class="table-operator">
  61. <!-- v-if="$hasPermissions('B_promotionListAdd')" -->
  62. <a-button id="promotionList-add" type="primary" class="button-error" @click="handleAdd">新增</a-button>
  63. </div>
  64. <!-- 列表 -->
  65. <s-table
  66. class="sTable fixPagination"
  67. ref="table"
  68. :style="{ height: tableHeight+84.5+'px' }"
  69. size="small"
  70. :rowKey="(record) => record.sparePartsReturnNo"
  71. :columns="columns"
  72. :data="loadData"
  73. :scroll="{ y: tableHeight }"
  74. :defaultLoadData="false"
  75. bordered>
  76. <!-- 促销名称 -->
  77. <template slot="promotionName" slot-scope="text, record">
  78. <div class="link-bule nameBox text-overflows2" @click="handleDetail(record)">{{ record.title }}</div>
  79. </template>
  80. <!-- 促销时间-->
  81. <template slot="promotionTime" slot-scope="text, record">
  82. <div>{{ record.promotionDateStart }}-{{ record.promotionDateEnd }}</div>
  83. </template>
  84. <!-- 参与客户 -->
  85. <template slot="joinCustomers" slot-scope="text, record">
  86. <div @click="handleCustomers(record)">共有<span style="color:#39f;vertical-align:top;">{{ record.dealerSnList?record.dealerSnList.length:0 }}</span>个客户</div>
  87. </template>
  88. <!-- 发布状态 -->
  89. <template slot="releaseStatus" slot-scope="text, record">
  90. <a-switch
  91. id="promotionList-enable"
  92. @change="changeStatus(record)"
  93. :disabled="record.state!='NOT_START' && record.state!='RUNNING'"
  94. :checked="record.enabledFlag == 1 ? true : false"></a-switch>
  95. </template>
  96. <!-- 操作 -->
  97. <!-- state 待提交:WAIT_SUBMIT 待审核:WAIT_AUDIT 未开始:NOT_START 进行中:RUNNING 审核不通过:AUDIT_REJECT 已结束:IS_OVER -->
  98. <template slot="action" slot-scope="text, record">
  99. <a-button
  100. size="small"
  101. type="link"
  102. class="button-warning"
  103. @click="handleSetRules(record)"
  104. v-if="record.state =='WAIT_SUBMIT'||record.state == 'AUDIT_REJECT'"
  105. id="allocateBillList-examine-btn">规则设置</a-button>
  106. <a-button
  107. size="small"
  108. type="link"
  109. v-if="record.state == 'WAIT_SUBMIT' ||record.state == 'AUDIT_REJECT'"
  110. @click="handleEdit(record)"
  111. class="button-info"
  112. id="promotionList-edit-btn">编辑</a-button>
  113. <a-button
  114. size="small"
  115. type="link"
  116. v-if="record.state == 'WAIT_AUDIT'"
  117. @click="handleCheck(record)"
  118. class="button-info"
  119. id="promotionList-edit-btn">审核</a-button>
  120. <a-button
  121. size="small"
  122. type="link"
  123. v-if="record.state == 'NOT_START' || record.state=='RUNNING'"
  124. @click="handleTime(record)"
  125. class="button-info"
  126. id="promotionList-edit-btn">促销时间变更</a-button>
  127. <a-button
  128. size="small"
  129. type="link"
  130. v-if="record.state == 'NO_START' || record.state=='RUNNING'"
  131. @click="handleEnd(record)"
  132. class="button-info"
  133. id="promotionList-edit-btn">终止</a-button>
  134. <a-button
  135. size="small"
  136. type="link"
  137. v-if="record.state == 'WAIT_SUBMIT'||record.state == 'AUDIT_REJECT'"
  138. @click="handleDel(record)"
  139. class="button-error"
  140. id="promotionList-del-btn">删除</a-button>
  141. <div v-if="record.state == 'IS_OVER'">--</div>
  142. </template>
  143. </s-table>
  144. </a-spin>
  145. <!-- 参与客户 -->
  146. <lookUp-customers-modal ref="lookUpCustomers" :openModal="openCustomerModal" @close="openCustomerModal = false"></lookUp-customers-modal>
  147. <!-- 新增/编辑弹窗-->
  148. <add-modal v-drag :itemSn="itemSn" :openModal="openModal" @ok="handleOk" @close="openModal=false" />
  149. <!-- 促销时间变更 -->
  150. <edit-active-end-time ref="editTime" v-drag :openModal="editEndModal" @ok="$refs.table.refresh()" @close="editEndModal=false" />
  151. <!-- 审核弹窗 -->
  152. <a-modal
  153. :closable="false"
  154. v-model="openAuditModal"
  155. :footer="null"
  156. width="416px"
  157. centered>
  158. <div style="display:flex;margin:30px 0 20px 20px;">
  159. <a-icon type="question-circle" :style="{fontSize:'23px',color:'#faad14'}"/>
  160. <div style="margin-left:10px;">
  161. <p style="font-size:16px;font-wight:bold;">提示</p>
  162. <p>请点击下方按钮确认操作?</p>
  163. </div>
  164. </div>
  165. <!-- 按钮 -->
  166. <div style="text-align: right;">
  167. <a-button
  168. id="auditModal-cancel"
  169. class="button-cancel"
  170. @click="closeAuditModal"
  171. style="margin-right: 15px;">审核不通过</a-button>
  172. <a-button
  173. type="primary"
  174. id="auditModal-save"
  175. class="button-primary"
  176. @click="handleAuditModal"
  177. >审核通过</a-button>
  178. </div>
  179. </a-modal>
  180. </a-card>
  181. </template>
  182. <script>
  183. import { commonMixin } from '@/utils/mixin'
  184. import { STable, VSelect } from '@/components'
  185. import addModal from './addModal.vue'
  186. import lookUpCustomersModal from '../promotionManagement/lookUpCustomersModal'
  187. import rangeDate from '@/views/common/rangeDate.vue'
  188. import editActiveEndTime from './editActiveEndTime.vue'
  189. import supplier from '@/views/common/supplier.js'
  190. import warehouse from '@/views/common/chooseWarehouse.js'
  191. import { dealerPromotionList, dealerPromotionDel, modifyEnabledFlag, promotionAudit, promotionIsOver } from '@/api/promotion'
  192. export default {
  193. name: 'PromotionManagementList',
  194. mixins: [commonMixin],
  195. components: { STable, supplier, VSelect, rangeDate, warehouse, lookUpCustomersModal, addModal, editActiveEndTime },
  196. data () {
  197. return {
  198. spinning: false,
  199. disabled: false, // 查询、重置按钮是否可操作
  200. openModal: false, // 新增弹框是否显示
  201. openCustomerModal: false, // 参与客户弹窗
  202. editEndModal: false, // 更改促销时间
  203. openDetailModal: false, // 详情弹窗
  204. tableHeight: 0,
  205. // 查询参数
  206. queryParam: {
  207. beginDate: undefined,
  208. endDate: undefined,
  209. title: '',
  210. enabledFlag: undefined, // 发布状态
  211. state: undefined
  212. },
  213. columns: [
  214. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  215. { title: '创建时间', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  216. { title: '促销名称', scopedSlots: { customRender: 'promotionName' }, width: '18%', align: 'center' },
  217. { title: '促销简称', dataIndex: 'description', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  218. { title: '促销时间', scopedSlots: { customRender: 'promotionTime' }, width: '13%', align: 'center' },
  219. { title: '参与客户', scopedSlots: { customRender: 'joinCustomers' }, width: '7%', align: 'center', ellipsis: true },
  220. { title: '促销描述', dataIndex: 'content', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  221. { title: '活动状态', dataIndex: 'stateDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  222. { title: '发布状态', scopedSlots: { customRender: 'releaseStatus' }, width: '7%', align: 'center', ellipsis: true },
  223. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  224. ],
  225. // 加载数据方法 必须为 Promise 对象
  226. loadData: parameter => {
  227. this.disabled = true
  228. this.spinning = true
  229. return dealerPromotionList(Object.assign(parameter, this.queryParam)).then(res => {
  230. let data
  231. if (res.status == 200) {
  232. data = res.data
  233. const no = (data.pageNo - 1) * data.pageSize
  234. for (var i = 0; i < data.list.length; i++) {
  235. data.list[i].no = no + i + 1
  236. }
  237. this.disabled = false
  238. }
  239. this.spinning = false
  240. return data
  241. })
  242. },
  243. itemSn: null, // 经销商促销活动SN
  244. openAuditModal: false // 审核弹窗
  245. }
  246. },
  247. methods: {
  248. // 详情
  249. handleDetail (row) {
  250. this.$router.push({ name: 'dealerPromotionManagementDetail', query: { sn: row.promotionSn } })
  251. },
  252. // 创建时间
  253. dateChange (date) {
  254. this.queryParam.beginDate = date[0]
  255. this.queryParam.endDate = date[1]
  256. },
  257. // 新增
  258. handleAdd () {
  259. this.itemSn = null
  260. this.openModal = true
  261. },
  262. // 参与客户
  263. handleCustomers (row) {
  264. this.openCustomerModal = true
  265. this.$nextTick(() => {
  266. this.$refs.lookUpCustomers.pageInit({ dealerSnList: row.dealerSnList })
  267. })
  268. },
  269. // 基本信息 保存
  270. handleOk () {
  271. this.itemSn = null
  272. this.resetSearchForm()
  273. },
  274. // 编辑
  275. handleEdit (row) {
  276. this.openModal = true
  277. this.itemSn = row.promotionSn
  278. },
  279. // 发布状态
  280. changeStatus (record) {
  281. const params = {
  282. promotionSn: record.promotionSn,
  283. enabledFlag: record.enabledFlag == 1 ? '0' : '1'
  284. }
  285. this.spinning = true
  286. modifyEnabledFlag(params).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.$refs.table.refresh()
  293. this.spinning = false
  294. }
  295. })
  296. },
  297. // 规则设置
  298. handleSetRules (row) {
  299. this.$router.push({ name: 'dealerPromotionManagementRule', query: { type: 'rule', sn: row.promotionSn } })
  300. },
  301. // 审核
  302. handleCheck (row) {
  303. const _this = this
  304. _this.itemSn = row.promotionSn
  305. _this.openAuditModal = true
  306. },
  307. handleAuditModal () {
  308. this.handleAudit({ promotionSn: this.itemSn, auditFlag: 1 })
  309. },
  310. closeAuditModal () {
  311. this.handleAudit({ promotionSn: this.itemSn, auditFlag: 0 })
  312. },
  313. handleAudit (ajaxData) {
  314. const _this = this
  315. _this.spinning = true
  316. promotionAudit(ajaxData).then(res => {
  317. if (res.status == 200) {
  318. _this.$message.success(res.message)
  319. _this.$refs.table.refresh()
  320. }
  321. _this.itemSn = null
  322. _this.openAuditModal = false
  323. _this.spinning = false
  324. })
  325. },
  326. // 促销时间变更
  327. handleTime (row) {
  328. this.editEndModal = true
  329. const showData = {
  330. sn: row.promotionSn,
  331. name: row.title,
  332. timeStart: row.promotionDateStart,
  333. timeEnd: row.promotionDateEnd
  334. }
  335. this.$refs.editTime.setData(showData)
  336. },
  337. // 终止
  338. handleEnd (row) {
  339. const _this = this
  340. this.$confirm({
  341. title: '提示',
  342. content: '确定要终止该促销?',
  343. centered: true,
  344. onOk () {
  345. _this.spinning = true
  346. promotionIsOver({ sn: row.promotionSn }).then(res => {
  347. if (res.status == 200) {
  348. _this.$message.success(res.message)
  349. _this.$refs.table.refresh()
  350. _this.spinning = false
  351. } else {
  352. _this.spinning = false
  353. }
  354. })
  355. }
  356. })
  357. },
  358. // 关闭采购退货详情弹框
  359. closeDetailModal () {
  360. this.itemSn = null
  361. this.openDetailModal = false
  362. },
  363. // 删除
  364. handleDel (row) {
  365. const _this = this
  366. this.$confirm({
  367. title: '提示',
  368. content: '确认要删除该活动吗?',
  369. centered: true,
  370. onOk () {
  371. _this.spinning = true
  372. dealerPromotionDel({ sn: row.promotionSn }).then(res => {
  373. if (res.status == 200) {
  374. _this.$message.success(res.message)
  375. _this.$refs.table.refresh()
  376. _this.spinning = false
  377. } else {
  378. _this.spinning = false
  379. }
  380. })
  381. }
  382. })
  383. },
  384. // 重置
  385. resetSearchForm () {
  386. this.queryParam = {
  387. beginDate: undefined,
  388. endDate: undefined,
  389. title: '',
  390. enabledFlag: undefined, // 发布状态
  391. state: undefined
  392. }
  393. this.$refs.rangeDate.resetDate()
  394. this.$refs.table.refresh(true)
  395. },
  396. pageInit () {
  397. const _this = this
  398. this.$nextTick(() => { // 页面渲染完成后的回调
  399. _this.setTableH()
  400. })
  401. this.openModal = false
  402. this.openDetailModal = false
  403. this.itemSn = null
  404. this.rowSelectionInfo = null
  405. this.$refs.table.clearTable()
  406. },
  407. setTableH () {
  408. const tableSearchH = this.$refs.tableSearch.offsetHeight
  409. this.tableHeight = window.innerHeight - tableSearchH - 240
  410. }
  411. },
  412. watch: {
  413. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  414. this.setTableH()
  415. }
  416. },
  417. mounted () {
  418. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  419. this.pageInit()
  420. this.resetSearchForm()
  421. }
  422. },
  423. activated () {
  424. // 如果是新页签打开,则重置当前页面
  425. if (this.$store.state.app.isNewTab) {
  426. this.pageInit()
  427. this.resetSearchForm()
  428. }
  429. // 仅刷新列表,不重置页面
  430. if (this.$store.state.app.updateList) {
  431. this.pageInit()
  432. this.$refs.table.refresh()
  433. }
  434. },
  435. beforeRouteEnter (to, from, next) {
  436. next(vm => {})
  437. }
  438. }
  439. </script>
  440. <style lang="less" scoped>
  441. .promotionList-wrap{
  442. .nameBox{
  443. padding:0 5px;
  444. }
  445. }
  446. </style>