list.vue 7.7 KB

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