list.vue 17 KB

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