list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <a-card size="small" :bordered="false" class="financialCollectionList-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. <rangeDate ref="rangeAuditDate" :value="auditDate" @change="dateAuditChange" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="经销商名称">
  15. <a-input id="financialCollectionList-buyerName" v-model.trim="queryParam.buyerName" allowClear placeholder="请输入经销商名称"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="商户级别">
  20. <v-select
  21. v-model="queryParam.dealerLevel"
  22. ref="dealerLevel"
  23. id="financialCollectionList-dealerLevel"
  24. code="DEALER_LEVEL"
  25. placeholder="请选择商户级别"
  26. allowClear></v-select>
  27. </a-form-item>
  28. </a-col>
  29. <template v-if="advanced">
  30. <a-col :md="6" :sm="24">
  31. <a-form-item label="收款方式">
  32. <v-select
  33. v-model="queryParam.settleStyleSn"
  34. ref="settleStyleSn"
  35. id="financialCollectionList-settleStyleSn"
  36. code="SETTLE_STYLE"
  37. placeholder="请选择收款方式"
  38. allowClear></v-select>
  39. </a-form-item>
  40. </a-col>
  41. <a-col :md="6" :sm="24">
  42. <a-form-item label="区域">
  43. <subarea id="financialCollectionList-subarea" v-model="queryParam.subareaSn"></subarea>
  44. </a-form-item>
  45. </a-col>
  46. <a-col :md="6" :sm="24">
  47. <a-form-item label="业务状态">
  48. <v-select
  49. v-model="queryParam.billStatus"
  50. ref="billStatus"
  51. id="financialCollectionList-billStatus"
  52. code="SALES_RECEIVE_LIST_STATUS"
  53. placeholder="请选择业务状态"
  54. allowClear></v-select>
  55. </a-form-item>
  56. </a-col>
  57. <a-col :md="6" :sm="24">
  58. <a-form-item label="财务状态">
  59. <v-select
  60. v-model="queryParam.financialStatus"
  61. ref="financialStatus"
  62. id="financialCollectionList-financialStatus"
  63. code="FINANCIAL_RECEIVE_STATUS"
  64. placeholder="请选择财务状态"
  65. allowClear></v-select>
  66. </a-form-item>
  67. </a-col>
  68. <a-col :md="6" :sm="24">
  69. <a-form-item label="收款时间">
  70. <rangeDate ref="rangeSettleDate" @change="dateSettleChange" />
  71. </a-form-item>
  72. </a-col>
  73. <a-col :md="12" :sm="24">
  74. <a-row>
  75. <a-form-item label="经销商地区">
  76. <a-col span="7">
  77. <a-form-item prop="dealerProvinceSn" style="margin: 0;">
  78. <a-select v-model="queryParam.dealerProvinceSn" allowClear @change="getCityList" placeholder="请选择省">
  79. <a-select-option v-for="item in addrProvinceList" :value="item.id" :key="item.id + 'a'">{{ item.name }}</a-select-option>
  80. </a-select>
  81. </a-form-item>
  82. </a-col>
  83. <a-col span="7" offset="1">
  84. <a-form-item prop="dealerCitySn" style="margin: 0;">
  85. <a-select v-model="queryParam.dealerCitySn" allowClear @change="getAreaList" placeholder="请选择市">
  86. <a-select-option v-for="item in addrCityList" :value="item.id" :key="item.id + 'b'">{{ item.name }}</a-select-option>
  87. </a-select>
  88. </a-form-item>
  89. </a-col>
  90. <a-col span="7" offset="1">
  91. <a-form-item prop="dealerCountySn" style="margin: 0;">
  92. <a-select v-model="queryParam.dealerCountySn" allowClear placeholder="请选择区/县">
  93. <a-select-option v-for="item in addrDistrictList" :value="item.id" :key="item.id + 'c'">{{ item.name }}</a-select-option>
  94. </a-select>
  95. </a-form-item>
  96. </a-col>
  97. </a-form-item>
  98. </a-row>
  99. </a-col>
  100. </template>
  101. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  102. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="financialCollectionList-refresh">查询</a-button>
  103. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="financialCollectionList-reset">重置</a-button>
  104. <a @click="advanced=!advanced" style="margin-left: 5px">
  105. {{ advanced ? '收起' : '展开' }}
  106. <a-icon :type="advanced ? 'up' : 'down'"/>
  107. </a>
  108. </a-col>
  109. </a-row>
  110. </a-form>
  111. </div>
  112. <!-- 列表 -->
  113. <s-table
  114. class="sTable fixPagination"
  115. ref="table"
  116. :style="{ height: tableHeight+84.5+'px' }"
  117. size="small"
  118. :rowKey="(record) => record.id"
  119. :columns="columns"
  120. :data="loadData"
  121. :scroll="{ y: tableHeight }"
  122. :defaultLoadData="false"
  123. bordered>
  124. <!-- 单号 -->
  125. <template slot="salesBillNo" slot-scope="text, record">
  126. <span :class="$hasPermissions('B_salesDetail')?'active':'common'" @click="handleDetail(record)">{{ record.salesBillNo }}</span>
  127. </template>
  128. <!-- 操作 -->
  129. <template slot="action" slot-scope="text, record">
  130. <a-button
  131. size="small"
  132. type="link"
  133. v-if="record.financialStatus=='WAIT' && $hasPermissions('B_financialCollection_receipt')"
  134. class="button-warning"
  135. @click="handleAudit(record)"
  136. id="financialCollectionList-audit-btn">收款</a-button>
  137. <span v-else>--</span>
  138. </template>
  139. </s-table>
  140. </a-spin>
  141. </a-card>
  142. </template>
  143. <script>
  144. import moment from 'moment'
  145. import getDate from '@/libs/getDate.js'
  146. import { STable, VSelect } from '@/components'
  147. import rangeDate from '@/views/common/rangeDate.vue'
  148. import subarea from '@/views/common/subarea.js'
  149. import { getArea } from '@/api/data'
  150. import { salesReceiptList, salesReceipt } from '@/api/sales'
  151. export default {
  152. components: { STable, VSelect, subarea, rangeDate },
  153. data () {
  154. return {
  155. spinning: false,
  156. tableHeight: 0,
  157. queryParam: { // 查询条件
  158. beginAuditDate: getDate.getThreeMonthDays().starttime,
  159. endAuditDate: getDate.getCurrMonthDays().endtime,
  160. beginSettleDate: '',
  161. endSettleDate: '',
  162. buyerName: '',
  163. dealerLevel: undefined,
  164. settleStyleSn: undefined,
  165. subareaSn: undefined,
  166. billStatus: undefined,
  167. financialStatus: undefined,
  168. dealerProvinceSn: undefined,
  169. dealerCitySn: undefined,
  170. dealerCountySn: undefined
  171. },
  172. disabled: false, // 查询、重置按钮是否可操作
  173. auditDate: [
  174. moment(getDate.getThreeMonthDays().starttime, 'YYYY-MM-DD'),
  175. moment(getDate.getCurrMonthDays().endtime, 'YYYY-MM-DD')
  176. ], // 审核时间
  177. advanced: false,
  178. // 加载数据方法 必须为 Promise 对象
  179. loadData: parameter => {
  180. this.disabled = true
  181. this.spinning = true
  182. return salesReceiptList(Object.assign(parameter, this.queryParam)).then(res => {
  183. const data = res.data
  184. const no = (data.pageNo - 1) * data.pageSize
  185. for (var i = 0; i < data.list.length; i++) {
  186. data.list[i].no = no + i + 1
  187. }
  188. this.total = data.count || 0
  189. this.disabled = false
  190. this.spinning = false
  191. return data
  192. })
  193. },
  194. total: 0, // 合计
  195. addrProvinceList: [], // 省下拉
  196. addrCityList: [], // 市下拉
  197. addrDistrictList: [] // 区下拉
  198. }
  199. },
  200. // 根据权限显示列表字段
  201. computed: {
  202. columns () {
  203. const arr = [
  204. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  205. { title: '审核时间', dataIndex: 'auditDate', width: '11.5%', align: 'center', customRender: function (text) { return text || '--' } },
  206. { title: '销售单号', scopedSlots: { customRender: 'salesBillNo' }, width: '15%', align: 'center' },
  207. { title: '经销商名称', dataIndex: 'buyerName', align: 'center', width: '12%', customRender: function (text) { return text || '--' }, ellipsis: true },
  208. { title: '商户级别', dataIndex: 'dealerEntity.dealerLevelDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  209. { title: '销售数量', dataIndex: 'totalQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  210. // { title: '订单金额', dataIndex: 'totalAmount', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  211. { title: '收款时间', dataIndex: 'settleDate', width: '11.5%', align: 'center', customRender: function (text) { return text || '--' } },
  212. { title: '收款方式', dataIndex: 'settleStyleSnDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  213. { title: '备注', dataIndex: 'remarks', width: '8%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  214. { title: '业务状态', dataIndex: 'billStatusDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  215. { title: '财务状态', dataIndex: 'financialStatusDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  216. { title: '操作', scopedSlots: { customRender: 'action' }, width: '4%', align: 'center' }
  217. ]
  218. if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
  219. arr.splice(6, 0, { title: '订单金额', dataIndex: 'totalAmount', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  220. }
  221. return arr
  222. }
  223. },
  224. methods: {
  225. // 审核时间 change
  226. dateAuditChange (date) {
  227. this.queryParam.beginAuditDate = date[0]
  228. this.queryParam.endAuditDate = date[1]
  229. },
  230. // 收款时间 change
  231. dateSettleChange (date) {
  232. this.queryParam.beginSettleDate = date[0]
  233. this.queryParam.endSettleDate = date[1]
  234. },
  235. // 重置
  236. resetSearchForm () {
  237. this.$refs.rangeAuditDate.resetDate(this.auditDate)
  238. if (this.advanced) { // 查询条件未展开时,该组件未渲染
  239. this.$refs.rangeSettleDate.resetDate()
  240. }
  241. this.queryParam.beginAuditDate = getDate.getThreeMonthDays().starttime
  242. this.queryParam.endAuditDate = getDate.getCurrMonthDays().endtime
  243. this.queryParam.beginSettleDate = ''
  244. this.queryParam.endSettleDate = ''
  245. this.queryParam.buyerName = ''
  246. this.queryParam.dealerLevel = undefined
  247. this.queryParam.settleStyleSn = undefined
  248. this.queryParam.subareaSn = undefined
  249. this.queryParam.billStatus = undefined
  250. this.queryParam.financialStatus = undefined
  251. this.queryParam.dealerProvinceSn = undefined
  252. this.queryParam.dealerCitySn = undefined
  253. this.queryParam.dealerCountySn = undefined
  254. this.$refs.table.refresh(true)
  255. },
  256. // 详情
  257. handleDetail (row) {
  258. if (this.$hasPermissions('B_salesDetail')) {
  259. this.$router.push({ name: 'salesDetail', params: { sn: row.salesBillSn } })
  260. }
  261. },
  262. // 收款
  263. handleAudit (row) {
  264. const _this = this
  265. this.$confirm({
  266. title: '提示',
  267. content: '确认要收款吗?',
  268. centered: true,
  269. onOk () {
  270. _this.spinning = true
  271. salesReceipt({ sn: row.salesBillSn }).then(res => {
  272. if (res.status == 200) {
  273. _this.$message.success(res.message)
  274. _this.$refs.table.refresh()
  275. _this.spinning = false
  276. } else {
  277. _this.spinning = false
  278. }
  279. })
  280. }
  281. })
  282. },
  283. // 获取城市列表
  284. getCityList (val) {
  285. this.addrCityList = []
  286. this.addrDistrictList = []
  287. this.queryParam.dealerCitySn = undefined
  288. this.queryParam.dealerCountySn = undefined
  289. if (val) {
  290. this.getArea('city', val)
  291. }
  292. },
  293. // 获取区县列表
  294. getAreaList (val) {
  295. this.addrDistrictList = []
  296. this.queryParam.dealerCountySn = undefined
  297. if (val) {
  298. this.getArea('district', val)
  299. }
  300. },
  301. // 省/市/区
  302. getArea (leve, sn) {
  303. let params
  304. if (leve == 'province') {
  305. params = { type: '2' }
  306. } else {
  307. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  308. }
  309. getArea(params).then(res => {
  310. if (res.status == 200) {
  311. if (leve == 'province') {
  312. this.addrProvinceList = res.data || []
  313. } else if (leve == 'city') {
  314. this.addrCityList = res.data || []
  315. } else if (leve == 'district') {
  316. this.addrDistrictList = res.data || []
  317. }
  318. } else {
  319. if (leve == 'province') {
  320. this.addrProvinceList = []
  321. } else if (leve == 'city') {
  322. this.addrCityList = []
  323. } else if (leve == 'district') {
  324. this.addrDistrictList = []
  325. }
  326. }
  327. })
  328. },
  329. pageInit () {
  330. const _this = this
  331. this.$nextTick(() => { // 页面渲染完成后的回调
  332. _this.setTableH()
  333. })
  334. this.getArea('province')
  335. },
  336. setTableH () {
  337. const tableSearchH = this.$refs.tableSearch.offsetHeight
  338. this.tableHeight = window.innerHeight - tableSearchH - 195
  339. }
  340. },
  341. watch: {
  342. advanced (newValue, oldValue) {
  343. const _this = this
  344. setTimeout(() => {
  345. _this.setTableH()
  346. }, 400)
  347. },
  348. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  349. this.setTableH()
  350. }
  351. },
  352. mounted () {
  353. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  354. this.pageInit()
  355. this.resetSearchForm()
  356. }
  357. },
  358. activated () {
  359. // 如果是新页签打开,则重置当前页面
  360. if (this.$store.state.app.isNewTab) {
  361. this.pageInit()
  362. this.resetSearchForm()
  363. }
  364. // 仅刷新列表,不重置页面
  365. if (this.$store.state.app.updateList) {
  366. this.pageInit()
  367. this.$refs.table.refresh()
  368. }
  369. },
  370. beforeRouteEnter (to, from, next) {
  371. next(vm => {})
  372. }
  373. }
  374. </script>
  375. <style lang="less">
  376. .financialCollectionList-wrap{
  377. .active{
  378. color: #ed1c24;
  379. cursor: pointer;
  380. }
  381. .common{
  382. color: rgba(0, 0, 0, 0.65);
  383. }
  384. }
  385. </style>