list.vue 7.4 KB

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