list.vue 6.5 KB

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