list.vue 7.1 KB

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