list.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <a-card size="small" :bordered="false" class="storeAccount-wrap jg-page-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. <shelfSList v-model="queryParam.shelfSn" id="storeAccount-shelfName"></shelfSList>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="关联客户">
  15. <custList ref="custList" id="storeAccount-custList" @change="custChange" :isEnabled="true"></custList>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  19. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="storeAccount-refresh">查询</a-button>
  20. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="storeAccount-reset">重置</a-button>
  21. </a-col>
  22. </a-row>
  23. </a-form>
  24. </div>
  25. <!-- 统计 -->
  26. <div class="table-operator" style="margin-bottom:10px;">
  27. <div class="alert-message">
  28. 总充值:<strong>{{ totalData&&(totalData.totalRecharge || totalData.totalRecharge==0) ? toThousands(totalData.totalRecharge) : '--' }}</strong>;
  29. 已用充值:<strong>{{ totalData&&(totalData.usedRecharge || totalData.usedRecharge==0) ? toThousands(totalData.usedRecharge) : '--' }}</strong>;
  30. 充值余额:<strong>{{ totalData&&(totalData.rechargeBalance || totalData.rechargeBalance==0) ? toThousands(totalData.rechargeBalance) : '--' }}</strong>;
  31. 总抵扣:<strong>{{ totalData&&(totalData.totalGive || totalData.totalGive==0) ? toThousands(totalData.totalGive) : '--' }}</strong>;
  32. 已用抵扣:<strong>{{ totalData&&(totalData.usedDeduction || totalData.usedDeduction==0) ? toThousands(totalData.usedDeduction) : '--' }}</strong>;
  33. 抵扣余额:<strong>{{ totalData&&(totalData.giveBalance || totalData.giveBalance==0) ? toThousands(totalData.giveBalance) : '--' }}</strong>;
  34. </div>
  35. </div>
  36. <!-- 列表 -->
  37. <s-table
  38. class="sTable fixPagination"
  39. ref="table"
  40. :style="{ height: tableHeight+84.5+'px' }"
  41. size="small"
  42. :rowKey="(record) => record.id"
  43. :columns="columns"
  44. :data="loadData"
  45. :scroll="{ y: tableHeight }"
  46. :defaultLoadData="false"
  47. bordered>
  48. <!-- 充值余额 -->
  49. <template slot="rechargeBalance" slot-scope="text, record">
  50. <span class="table-td-link" :id="'storeAccount-recharge'+record.id" v-if="$hasPermissions('B_clearRecord')" @click="handleFlow(record,'1')">{{ (record.rechargeBalance||record.rechargeBalance==0)?toThousands(record.rechargeBalance):'--' }}</span>
  51. <span v-else>{{ (record.rechargeBalance||record.rechargeBalance==0)?toThousands(record.rechargeBalance):'--' }}</span>
  52. </template>
  53. <!-- 抵扣余额 -->
  54. <template slot="giveBalance" slot-scope="text, record">
  55. <span class="table-td-link" :id="'storeAccount-give'+record.id" v-if="$hasPermissions('B_clearRecord')" @click="handleFlow(record,'2')">{{ (record.giveBalance||record.giveBalance==0)?toThousands(record.giveBalance):'--' }}</span>
  56. <span v-else>{{ (record.giveBalance||record.giveBalance==0)?toThousands(record.giveBalance):'--' }}</span>
  57. </template>
  58. <!-- 操作 -->
  59. <template slot="action" slot-scope="text, record">
  60. <a-button
  61. :id="'storeAccount-clearRecord'+record.id"
  62. v-if="$hasPermissions('B_clearRecord')"
  63. size="small"
  64. type="link"
  65. class="button-primary"
  66. @click="handleClearRecord(record)">清零记录</a-button>
  67. <a-button
  68. :id="'storeAccount-ZeroClear-'+record.id"
  69. size="small"
  70. type="link"
  71. v-if="$hasPermissions('B_zeroClear')"
  72. class="button-error"
  73. @click="handleZeroClear(record)">清零</a-button>
  74. <span v-if="!$hasPermissions('B_clearRecord')&&!$hasPermissions('B_zeroClear')">--</span>
  75. </template>
  76. </s-table>
  77. </a-spin>
  78. <!-- 交易流水 -->
  79. <transaction-flow-modal :modalType="modalType" :itemInfo="itemInfo" :openModal="openFlowModal" @close="openFlowModal=false"></transaction-flow-modal>
  80. <!-- 清零 -->
  81. <zero-clearing-modal ref="zeroClearModal" :openModal="openZeroClearModal" @ok="$refs.table.refresh(true)" @close="openZeroClearModal=false"></zero-clearing-modal>
  82. <!-- 清零记录 -->
  83. <clear-record-modal ref="clearRecordModal" :openModal="openClearRecordModal" @close="openClearRecordModal=false"></clear-record-modal>
  84. </a-card>
  85. </template>
  86. <script>
  87. import { commonMixin } from '@/utils/mixin'
  88. // 组件
  89. import { STable } from '@/components'
  90. import custList from '@/views/common/custList.vue' // 客户列表组件
  91. import shelfSList from '@/views/common/shelfList' // 货架列表组件
  92. import transactionFlowModal from './transactionFlowModal.vue' // 交易流水弹框
  93. import zeroClearingModal from './zeroClearingModal.vue' // 清零弹框
  94. import clearRecordModal from './clearRecordModal.vue' // 清零记录弹框
  95. // 接口
  96. import { storeAccountList, storeAccountCount } from '@/api/storeAccount' // 接口api
  97. export default {
  98. components: { STable, custList, shelfSList, transactionFlowModal, zeroClearingModal, clearRecordModal },
  99. mixins: [commonMixin],
  100. data () {
  101. const _this = this
  102. return {
  103. spinning: false, // loading
  104. tableHeight: 0, // 表格高度
  105. disabled: false, // 查询、重置按钮是否可操作
  106. queryParam: {
  107. shelfSn: undefined, // 货架sn
  108. customerSn: undefined, // 关联客户sn
  109. customerName: undefined// 关联客户名称
  110. },
  111. time: [],
  112. modalType: '1',
  113. openFlowModal: false, // 打开 交易流水弹窗
  114. openZeroClearModal: false, // 打开 清零弹窗
  115. openClearRecordModal: false, // 打开 清零记录弹窗
  116. totalData: null, // 统计数据
  117. itemInfo: null, // 当前行数据
  118. // 列定义
  119. columns: [
  120. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  121. { title: '创建时间', dataIndex: 'createDate', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  122. { title: '货架名称', dataIndex: 'shelfName', width: '23%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  123. { title: '关联客户', dataIndex: 'customerName', width: '23%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  124. { title: '总充值', dataIndex: 'totalRecharge', width: '12%', align: 'right', customRender: function (text) { return (text || text == 0) ? _this.toThousands(text, 2) : '--' } },
  125. { title: '总抵扣', dataIndex: 'totalGive', width: '12%', align: 'right', customRender: function (text) { return (text || text == 0) ? _this.toThousands(text, 2) : '--' } },
  126. { title: '充值余额', dataIndex: 'rechargeBalance', width: '12%', align: 'right', scopedSlots: { customRender: 'rechargeBalance' } },
  127. { title: '抵扣余额', dataIndex: 'giveBalance', width: '12%', align: 'right', scopedSlots: { customRender: 'giveBalance' } },
  128. { title: '操作', scopedSlots: { customRender: 'action' }, width: '16%', align: 'center' }
  129. ],
  130. // 加载数据方法 必须为 Promise 对象
  131. loadData: parameter => {
  132. this.disabled = true
  133. this.spinning = true
  134. const params = Object.assign(parameter, this.queryParam)
  135. return storeAccountList(params).then(res => {
  136. let data
  137. if (res.status == 200) {
  138. data = res.data
  139. const no = (data.pageNo - 1) * data.pageSize
  140. for (var i = 0; i < data.list.length; i++) {
  141. data.list[i].no = no + i + 1
  142. }
  143. this.getCount(params)
  144. this.disabled = false
  145. }
  146. this.spinning = false
  147. return data
  148. })
  149. }
  150. }
  151. },
  152. methods: {
  153. // 统计
  154. getCount (val) {
  155. storeAccountCount(val).then(res => {
  156. if (res.status == 200) {
  157. this.totalData = res.data
  158. } else {
  159. this.totalData = null
  160. }
  161. })
  162. },
  163. // 交易流水 1 充值余额 2抵扣余额
  164. handleFlow (row, type) {
  165. this.modalType = type
  166. this.itemInfo = row
  167. this.openFlowModal = true
  168. },
  169. // 打开清零记录弹窗
  170. handleClearRecord (row) {
  171. this.$refs.clearRecordModal.pageInit(row)
  172. this.openClearRecordModal = true
  173. },
  174. // 打开清零弹窗
  175. handleZeroClear (record) {
  176. this.$refs.zeroClearModal.pageInit(record)
  177. this.$nextTick(() => {
  178. this.openZeroClearModal = true
  179. })
  180. },
  181. // 选择关联客户
  182. custChange (obj, row) {
  183. if (row) {
  184. this.queryParam.customerSn = row && row.customerSn || undefined
  185. this.queryParam.customerName = undefined
  186. } else {
  187. this.queryParam.customerName = obj || undefined
  188. this.queryParam.customerSn = undefined
  189. }
  190. },
  191. // 是否设置完成更改
  192. changeStatus (record) {
  193. const params = {
  194. shelfSn: record.shelfSn,
  195. finishFlag: record.finishFlag == 1 ? '0' : '1'
  196. }
  197. this.spinning = true
  198. modifFinishFlag(params).then(res => {
  199. if (res.status == 200) {
  200. this.$message.success(res.message)
  201. this.$refs.table.refresh()
  202. this.spinning = false
  203. } else {
  204. this.spinning = false
  205. }
  206. })
  207. },
  208. // 启用禁用
  209. enableShelf (record) {
  210. const params = {
  211. shelfSn: record.shelfSn,
  212. state: record.state == 'ENABLE' ? 'DISABLED' : 'ENABLE'
  213. }
  214. const _this = this
  215. _this.$confirm({
  216. title: '提示',
  217. content: <div style="text-align:center;">是否{(record.state == 'ENABLE' ? '停用' : '启用') + record.shelfName}</div>,
  218. centered: true,
  219. closable: true,
  220. class: 'confirm-center',
  221. onOk () {
  222. _this.updateState(params)
  223. }
  224. })
  225. },
  226. // 更改货架状态
  227. updateState (params) {
  228. this.spinning = true
  229. shelfModifState(params).then(res => {
  230. if (res.status == 200) {
  231. this.$message.success(res.message)
  232. this.$refs.table.refresh()
  233. this.spinning = false
  234. } else {
  235. this.spinning = false
  236. }
  237. this.showTip = false
  238. })
  239. },
  240. // 重置列表查询
  241. resetSearchForm () {
  242. this.queryParam.shelfSn = undefined
  243. this.queryParam.customerSn = undefined
  244. this.queryParam.customerName = undefined
  245. this.$refs.custList.resetForm()
  246. this.$refs.table.refresh(true)
  247. },
  248. // 计算表格高度
  249. setTableH () {
  250. const tableSearchH = this.$refs.tableSearch.offsetHeight
  251. this.tableHeight = window.innerHeight - tableSearchH - 240
  252. },
  253. // 初始化页面
  254. pageInit () {
  255. const _this = this
  256. this.$nextTick(() => { // 页面渲染完成后的回调
  257. _this.setTableH()
  258. })
  259. }
  260. },
  261. mounted () {
  262. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  263. this.pageInit()
  264. this.resetSearchForm()
  265. }
  266. },
  267. watch: {
  268. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  269. this.setTableH()
  270. }
  271. },
  272. activated () {
  273. // 如果是新页签打开,则重置当前页面
  274. if (this.$store.state.app.isNewTab) {
  275. this.pageInit()
  276. this.resetSearchForm()
  277. }
  278. // 仅刷新列表,不重置页面
  279. if (this.$store.state.app.updateList) {
  280. this.pageInit()
  281. this.$refs.table.refresh()
  282. }
  283. }
  284. }
  285. </script>