list.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <a-card size="small" :bordered="false" class="backorderList-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="rangeDate" @change="dateChange" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="客户名称">
  15. <custList ref="custList" id="backorderList-buyerSn" @change="custChange"></custList>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="backorderList-refresh">查询</a-button>
  20. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="backorderList-reset">重置</a-button>
  21. </a-col>
  22. </a-row>
  23. </a-form>
  24. </div>
  25. <!-- 列表 -->
  26. <s-table
  27. class="sTable fixPagination"
  28. ref="table"
  29. :style="{ height: tableHeight+84.5+'px' }"
  30. size="small"
  31. :rowKey="(record) => record.id"
  32. :columns="columns"
  33. :data="loadData"
  34. :scroll="{ y: tableHeight }"
  35. :defaultLoadData="false"
  36. bordered>
  37. <!-- 操作 -->
  38. <template slot="action" slot-scope="text, record">
  39. <a-button size="small" type="link" @click="handleDetail(record)" v-if="$hasPermissions('B_oosDetail')" id="backorderList-detail-btn">详情</a-button>
  40. <span v-else>--</span>
  41. </template>
  42. </s-table>
  43. </a-spin>
  44. <!-- 详情 -->
  45. <backorder-detail-modal :openModal="openModal" :itemSn="itemSn" @close="closeModal" />
  46. </a-card>
  47. </template>
  48. <script>
  49. import rangeDate from '@/views/common/rangeDate.vue'
  50. import custList from '@/views/common/custList.vue'
  51. import { STable, VSelect } from '@/components'
  52. import backorderDetailModal from './detailModal.vue'
  53. import { oosList } from '@/api/oos'
  54. export default {
  55. components: { STable, VSelect, custList, backorderDetailModal, rangeDate },
  56. data () {
  57. return {
  58. spinning: false,
  59. tableHeight: 0, // 表格高度
  60. queryParam: { // 查询条件
  61. beginDate: '',
  62. endDate: '',
  63. buyerSn: undefined
  64. },
  65. disabled: false, // 查询、重置按钮是否可操作
  66. // 加载数据方法 必须为 Promise 对象
  67. loadData: parameter => {
  68. this.disabled = true
  69. this.spinning = true
  70. return oosList(Object.assign(parameter, this.queryParam)).then(res => {
  71. const data = res.data
  72. const no = (data.pageNo - 1) * data.pageSize
  73. for (var i = 0; i < data.list.length; i++) {
  74. data.list[i].no = no + i + 1
  75. }
  76. this.disabled = false
  77. this.spinning = false
  78. return data
  79. })
  80. },
  81. openModal: false,
  82. itemSn: ''
  83. }
  84. },
  85. computed: {
  86. columns () {
  87. const arr = [
  88. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  89. { title: '创建时间', dataIndex: 'createDate', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  90. { title: '销售单号', dataIndex: 'salesBillNo', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  91. { title: '客户名称', dataIndex: 'dealerName', width: '20%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  92. { title: '缺货款数', dataIndex: 'totalCategory', width: '11%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  93. { title: '缺货数量', dataIndex: 'totalQty', width: '11%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  94. // { title: '缺货金额', dataIndex: 'totalAmount', width: '11%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  95. { title: '操作', scopedSlots: { customRender: 'action' }, width: '11%', align: 'center' }
  96. ]
  97. if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
  98. arr.splice(6, 0, { title: '缺货金额', dataIndex: 'totalAmount', width: '11%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  99. }
  100. return arr
  101. }
  102. },
  103. methods: {
  104. // 时间 change
  105. dateChange (date) {
  106. this.queryParam.beginDate = date[0]
  107. this.queryParam.endDate = date[1]
  108. },
  109. custChange (obj) {
  110. this.queryParam.buyerSn = obj.key
  111. },
  112. // 重置
  113. resetSearchForm () {
  114. this.$refs.rangeDate.resetDate()
  115. this.queryParam.beginDate = ''
  116. this.queryParam.endDate = ''
  117. this.queryParam.buyerSn = undefined
  118. this.$refs.custList.resetForm()
  119. this.$refs.table.refresh(true)
  120. },
  121. // 关闭
  122. closeModal () {
  123. this.itemSn = ''
  124. this.openModal = false
  125. },
  126. // 详情
  127. handleDetail (row) {
  128. this.itemSn = row.oosBillSn
  129. this.openModal = true
  130. },
  131. pageInit () {
  132. const _this = this
  133. this.$nextTick(() => { // 页面渲染完成后的回调
  134. _this.setTableH()
  135. })
  136. },
  137. setTableH () {
  138. const tableSearchH = this.$refs.tableSearch.offsetHeight
  139. this.tableHeight = window.innerHeight - tableSearchH - 195
  140. }
  141. },
  142. watch: {
  143. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  144. this.setTableH()
  145. }
  146. },
  147. mounted () {
  148. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  149. this.pageInit()
  150. this.resetSearchForm()
  151. }
  152. },
  153. activated () {
  154. // 如果是新页签打开,则重置当前页面
  155. if (this.$store.state.app.isNewTab) {
  156. this.pageInit()
  157. this.resetSearchForm()
  158. }
  159. // 仅刷新列表,不重置页面
  160. if (this.$store.state.app.updateList) {
  161. this.pageInit()
  162. this.$refs.table.refresh()
  163. }
  164. },
  165. beforeRouteEnter (to, from, next) {
  166. next(vm => {})
  167. }
  168. }
  169. </script>