list.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  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.publishStatus"
  22. ref="publishStatus"
  23. id="promotionList-publishStatus"
  24. code="SPARE_PARTS_RETURN_REASON"
  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="SPARE_PARTS_RETURN_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. v-if="record.enabledFlag"
  92. id="promotionList-enable"
  93. @change="changeStatus(record)"
  94. :checked="record.enabledFlag == 1 ? true : false"></a-switch>
  95. </template>
  96. <!-- 操作 -->
  97. <!-- state 待提交 WAIT_SUBMIT 待审核 WAIT_AUDIT 未开始 NO_START 进行中 A_FOOT 已完结 FINISH 审核不通过 AUDIT_REJECT -->
  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'"
  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 == 'NO_START' || record.state=='A_FOOT'"
  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=='A_FOOT'"
  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 == 'FINISH'">--</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 v-drag :openModal="editEndModal" @ok="handleEditOk" @close="editEndModal=false" />
  151. </a-card>
  152. </template>
  153. <script>
  154. import { commonMixin } from '@/utils/mixin'
  155. import { STable, VSelect } from '@/components'
  156. import addModal from './addModal.vue'
  157. import lookUpCustomersModal from '../promotionManagement/lookUpCustomersModal'
  158. // import detailModal from './detailModal.vue'
  159. import rangeDate from '@/views/common/rangeDate.vue'
  160. // import chooseDepartUserModal from './chooseDepartUserModal.vue'
  161. import editActiveEndTime from './editActiveEndTime.vue'
  162. import reportModal from '@/views/common/reportModal.vue'
  163. import { hdExportExcel } from '@/libs/exportExcel'
  164. import supplier from '@/views/common/supplier.js'
  165. import warehouse from '@/views/common/chooseWarehouse.js'
  166. import { dealerPromotionList, dealerPromotionDel, sparePartsReturnExportDetail, againSubmit } from '@/api/promotion'
  167. export default {
  168. name: 'PromotionManagementList',
  169. mixins: [commonMixin],
  170. components: { STable, supplier, VSelect, reportModal, rangeDate, warehouse, lookUpCustomersModal, addModal, editActiveEndTime },
  171. data () {
  172. return {
  173. spinning: false,
  174. disabled: false, // 查询、重置按钮是否可操作
  175. openModal: false, // 新增弹框是否显示
  176. openCustomerModal: false, // 参与客户弹窗
  177. editEndModal: false,
  178. openDetailModal: false, // 详情弹窗
  179. showExport: false,
  180. exportLoading: false,
  181. tableHeight: 0,
  182. // 查询参数
  183. queryParam: {
  184. beginDate: undefined,
  185. endDate: undefined,
  186. title: '',
  187. publishStatus: undefined, // 发布状态
  188. state: undefined
  189. },
  190. columns: [
  191. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  192. { title: '创建时间', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  193. { title: '促销名称', scopedSlots: { customRender: 'promotionName' }, width: '14%', align: 'center' },
  194. { title: '促销时间', scopedSlots: { customRender: 'promotionTime' }, width: '15%', align: 'center' },
  195. { title: '参与客户', scopedSlots: { customRender: 'joinCustomers' }, width: '12%', align: 'center', ellipsis: true },
  196. { title: '促销描述', dataIndex: 'description', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  197. { title: '活动状态', dataIndex: 'stateDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  198. { title: '发布状态', scopedSlots: { customRender: 'releaseStatus' }, width: '9%', align: 'center', ellipsis: true },
  199. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  200. ],
  201. // 加载数据方法 必须为 Promise 对象
  202. loadData: parameter => {
  203. this.disabled = true
  204. this.spinning = true
  205. return dealerPromotionList(Object.assign(parameter, this.queryParam)).then(res => {
  206. let data
  207. if (res.status == 200) {
  208. data = res.data
  209. const no = (data.pageNo - 1) * data.pageSize
  210. for (var i = 0; i < data.list.length; i++) {
  211. data.list[i].no = no + i + 1
  212. }
  213. this.disabled = false
  214. }
  215. this.spinning = false
  216. return data
  217. })
  218. },
  219. itemSnSh: null,
  220. itemSn: null, // 经销商促销活动SN
  221. auditTime: null// 审核时间
  222. }
  223. },
  224. methods: {
  225. // 详情
  226. handleDetail (row) {
  227. this.$router.push({ name: 'dealerPromotionManagementDetail', query: { sn: row.promotionSn } })
  228. },
  229. // 创建时间
  230. dateChange (date) {
  231. this.queryParam.beginDate = date[0]
  232. this.queryParam.endDate = date[1]
  233. },
  234. // 导出
  235. handleExport () {
  236. const _this = this
  237. _this.$store.state.app.curActionPermission = 'B_promotionListExport'
  238. _this.exportLoading = true
  239. _this.spinning = true
  240. hdExportExcel(sparePartsReturnExportDetail, _this.queryParam, '采购退货', function () {
  241. _this.exportLoading = false
  242. _this.spinning = false
  243. _this.showExport = true
  244. _this.$store.state.app.curActionPermission = ''
  245. })
  246. },
  247. // 新增
  248. handleAdd () {
  249. this.itemSn = null
  250. this.openModal = true
  251. },
  252. // 参与客户
  253. handleCustomers (row) {
  254. this.openCustomerModal = true
  255. // this.$nextTick(() => {
  256. // this.$refs.lookUpCustomers.pageInit({ dealerSnList: row.promoBuyerSnSet ? row.promoBuyerSnSet : undefined, promoActiveSn: row.promoActiveSn })
  257. // })
  258. },
  259. // 基本信息 保存
  260. handleOk () {
  261. this.itemSn = null
  262. this.resetSearchForm()
  263. },
  264. // 编辑
  265. handleEdit (row) {
  266. this.openModal = true
  267. this.itemSn = row.promotionSn
  268. },
  269. // 发布状态
  270. changeStatus (record) {
  271. const params = {
  272. id: record.id,
  273. flag: record.loginFlag == 1 ? '0' : '1'
  274. }
  275. this.spinning = true
  276. dealerUserEnable(params).then(res => {
  277. if (res.status == 200) {
  278. this.$message.success(res.message)
  279. this.$refs.table.refresh()
  280. this.spinning = false
  281. } else {
  282. this.$refs.table.refresh()
  283. this.spinning = false
  284. }
  285. })
  286. },
  287. // 规则设置
  288. handleSetRules (row) {
  289. this.$router.push({ name: 'dealerPromotionManagementRule', query: { type: 'rule', sn: row.promotionSn } })
  290. },
  291. // 审核
  292. handleCheck (row) {
  293. const _this = this
  294. this.$confirm({
  295. title: '提示',
  296. content: '请点击下方按钮确认操作?',
  297. cancelText: '审核不通过',
  298. okText: '审核通过',
  299. centered: true,
  300. closable: true,
  301. onOk () {
  302. _this.spinning = true
  303. sparePartsReturnDelete({ sn: row.sparePartsReturnSn }).then(res => {
  304. if (res.status == 200) {
  305. _this.$message.success(res.message)
  306. _this.$refs.table.refresh()
  307. _this.spinning = false
  308. } else {
  309. _this.spinning = false
  310. }
  311. })
  312. },
  313. onCancel (e) {
  314. console.log('不通过', e)
  315. }
  316. })
  317. },
  318. // 促销时间变更
  319. handleTime () {
  320. this.editEndModal = true
  321. },
  322. handleEditOk () {},
  323. // 终止
  324. handleEnd (row) {
  325. const _this = this
  326. this.$confirm({
  327. title: '提示',
  328. content: '确定要终止该促销?',
  329. centered: true,
  330. onOk () {
  331. _this.spinning = true
  332. sparePartsReturnDelete({ sn: row.sparePartsReturnSn }).then(res => {
  333. if (res.status == 200) {
  334. _this.$message.success(res.message)
  335. _this.$refs.table.refresh()
  336. _this.spinning = false
  337. } else {
  338. _this.spinning = false
  339. }
  340. })
  341. }
  342. })
  343. },
  344. // 再次提交
  345. handleResubmit (row) {
  346. const _this = this
  347. this.$confirm({
  348. title: '操作提示',
  349. content: '系统将自动生成一个新的采购退货单,新单据中的产品申退数量将以最大可用库存为准,最大可用库存为0时,系统将强制删除已选的对应产品。您可以对新单据进行编辑、提交等操作,原单据保持不变,确认操作吗?',
  350. centered: true,
  351. onOk () {
  352. _this.spinning = true
  353. againSubmit({ sparePartsReturnSn: row.sparePartsReturnSn }).then(res => {
  354. if (res.status == 200) {
  355. _this.$message.success(res.message)
  356. _this.$refs.table.refresh()
  357. _this.spinning = false
  358. } else {
  359. _this.spinning = false
  360. }
  361. })
  362. }
  363. })
  364. },
  365. // 关闭采购退货详情弹框
  366. closeDetailModal () {
  367. this.itemSn = null
  368. this.openDetailModal = false
  369. },
  370. // 删除
  371. handleDel (row) {
  372. const _this = this
  373. this.$confirm({
  374. title: '提示',
  375. content: '确认要删除该活动吗?',
  376. centered: true,
  377. onOk () {
  378. _this.spinning = true
  379. dealerPromotionDel({ sn: row.promotionSn }).then(res => {
  380. if (res.status == 200) {
  381. _this.$message.success(res.message)
  382. _this.$refs.table.refresh()
  383. _this.spinning = false
  384. } else {
  385. _this.spinning = false
  386. }
  387. })
  388. }
  389. })
  390. },
  391. // 重置
  392. resetSearchForm () {
  393. this.queryParam = {
  394. beginDate: undefined,
  395. endDate: undefined,
  396. sparePartsReturnNo: undefined,
  397. supplierSn: undefined,
  398. returnReason: undefined,
  399. warehouseSn: undefined, // 仓库
  400. state: undefined
  401. }
  402. this.$refs.rangeDate.resetDate()
  403. this.$refs.table.refresh(true)
  404. },
  405. pageInit () {
  406. const _this = this
  407. this.$nextTick(() => { // 页面渲染完成后的回调
  408. _this.setTableH()
  409. })
  410. this.openModal = false
  411. this.openDetailModal = false
  412. this.itemSn = null
  413. this.rowSelectionInfo = null
  414. this.$refs.table.clearTable()
  415. },
  416. setTableH () {
  417. const tableSearchH = this.$refs.tableSearch.offsetHeight
  418. this.tableHeight = window.innerHeight - tableSearchH - 240
  419. }
  420. },
  421. watch: {
  422. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  423. this.setTableH()
  424. }
  425. },
  426. mounted () {
  427. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  428. this.pageInit()
  429. this.resetSearchForm()
  430. }
  431. },
  432. activated () {
  433. // 如果是新页签打开,则重置当前页面
  434. if (this.$store.state.app.isNewTab) {
  435. this.pageInit()
  436. this.resetSearchForm()
  437. }
  438. // 仅刷新列表,不重置页面
  439. if (this.$store.state.app.updateList) {
  440. this.pageInit()
  441. this.$refs.table.refresh()
  442. }
  443. },
  444. beforeRouteEnter (to, from, next) {
  445. next(vm => {})
  446. }
  447. }
  448. </script>
  449. <style lang="less">
  450. .promotionList-wrap{
  451. .nameBox{
  452. padding:0 5px;
  453. }
  454. .common{
  455. color: rgba(0, 0, 0);
  456. }
  457. }
  458. </style>