list.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. let data
  72. if (res.status == 200) {
  73. data = res.data
  74. const no = (data.pageNo - 1) * data.pageSize
  75. for (var i = 0; i < data.list.length; i++) {
  76. data.list[i].no = no + i + 1
  77. }
  78. this.disabled = false
  79. }
  80. this.spinning = false
  81. return data
  82. })
  83. },
  84. openModal: false,
  85. itemSn: ''
  86. }
  87. },
  88. computed: {
  89. columns () {
  90. const arr = [
  91. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  92. { title: '创建时间', dataIndex: 'createDate', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  93. { title: '销售单号', dataIndex: 'salesBillNo', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  94. { title: '客户名称', dataIndex: 'dealerName', width: '20%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  95. { title: '缺货款数', dataIndex: 'totalCategory', width: '11%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  96. { title: '缺货数量', dataIndex: 'totalQty', width: '11%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  97. // { title: '缺货金额', dataIndex: 'totalAmount', width: '11%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  98. { title: '操作', scopedSlots: { customRender: 'action' }, width: '11%', align: 'center' }
  99. ]
  100. if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
  101. arr.splice(6, 0, { title: '缺货金额', dataIndex: 'totalAmount', width: '11%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  102. }
  103. return arr
  104. }
  105. },
  106. methods: {
  107. // 时间 change
  108. dateChange (date) {
  109. this.queryParam.beginDate = date[0]
  110. this.queryParam.endDate = date[1]
  111. },
  112. custChange (obj) {
  113. this.queryParam.buyerSn = obj.key
  114. },
  115. // 重置
  116. resetSearchForm () {
  117. this.$refs.rangeDate.resetDate()
  118. this.queryParam.beginDate = ''
  119. this.queryParam.endDate = ''
  120. this.queryParam.buyerSn = undefined
  121. this.$refs.custList.resetForm()
  122. this.$refs.table.refresh(true)
  123. },
  124. // 关闭
  125. closeModal () {
  126. this.itemSn = ''
  127. this.openModal = false
  128. },
  129. // 详情
  130. handleDetail (row) {
  131. this.itemSn = row.oosBillSn
  132. this.openModal = true
  133. },
  134. pageInit () {
  135. const _this = this
  136. this.$nextTick(() => { // 页面渲染完成后的回调
  137. _this.setTableH()
  138. })
  139. },
  140. setTableH () {
  141. const tableSearchH = this.$refs.tableSearch.offsetHeight
  142. this.tableHeight = window.innerHeight - tableSearchH - 195
  143. }
  144. },
  145. watch: {
  146. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  147. this.setTableH()
  148. }
  149. },
  150. mounted () {
  151. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  152. this.pageInit()
  153. this.resetSearchForm()
  154. }
  155. },
  156. activated () {
  157. // 如果是新页签打开,则重置当前页面
  158. if (this.$store.state.app.isNewTab) {
  159. this.pageInit()
  160. this.resetSearchForm()
  161. }
  162. // 仅刷新列表,不重置页面
  163. if (this.$store.state.app.updateList) {
  164. this.pageInit()
  165. this.$refs.table.refresh()
  166. }
  167. },
  168. beforeRouteEnter (to, from, next) {
  169. next(vm => {})
  170. }
  171. }
  172. </script>