list.vue 7.3 KB

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