list.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <a-card size="small" :bordered="false" class="shelfOrder-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="5" :sm="24">
  9. <a-form-item label="订单编号">
  10. <a-input id="shelfOrder-orderBillNo" v-model.trim="queryParam.orderBillNo" allowClear placeholder="请输入订单编号" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="5" :sm="24">
  14. <a-form-item label="货架名称">
  15. <shelfSList id="shelfOrder-shelfname" ref="shelfSList" :showAll="true" mode="multiple" v-model="queryParam.shelfSnList"></shelfSList>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="5" :sm="24">
  19. <a-form-item label="订单状态">
  20. <v-select
  21. v-model="queryParam.billState"
  22. ref="billState"
  23. id="shelfOrder-billState"
  24. code="ORDER_BILL_STATE"
  25. placeholder="请选择订单状态"
  26. allowClear></v-select>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="5" :sm="24">
  30. <a-form-item label="下单时间">
  31. <rangeDate id="shelfOrder-time" ref="rangeDate" :value="time" @change="dateChange" />
  32. </a-form-item>
  33. </a-col>
  34. <a-col :md="4" :sm="24" style="margin-bottom: 10px">
  35. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="shelfOrder-refresh">查询</a-button>
  36. <a-button style="margin-left: 5px" @click="resetSearchForm(0)" :disabled="disabled" id="shelfOrder-reset">重置</a-button>
  37. </a-col>
  38. </a-row>
  39. </a-form>
  40. </div>
  41. <!-- 提示 -->
  42. <a-alert type="info" style="margin-bottom: 10px" v-if="countData">
  43. <div slot="message">总款数:{{ countData.productCategory }};总数量:{{ countData.totalQty }};总结算金额:{{ countData&&(countData.settleAmount||countData.settleAmount==0)?toThousands(countData.settleAmount,2):'--' }};</div>
  44. </a-alert>
  45. <!-- 列表 -->
  46. <s-table
  47. class="sTable fixPagination"
  48. ref="table"
  49. :style="{ height: tableHeight+84.5+'px' }"
  50. size="small"
  51. :rowKey="(record) => record.id"
  52. :columns="columns"
  53. :data="loadData"
  54. :scroll="{ y: tableHeight }"
  55. :defaultLoadData="false"
  56. bordered>
  57. <template slot="orderBillNo" slot-scope="text, record">
  58. <span class="table-td-link" @click="handleDetail(record)">{{ record.orderBillNo }}</span>
  59. </template>
  60. <!-- 操作 -->
  61. <template slot="action" slot-scope="text, record">
  62. <a-button :id="'shelfOrder-shelf-set-'+record.id" size="small" type="link" class="button-primary" @click="handleSet(record)">设置</a-button>
  63. </template>
  64. </s-table>
  65. </a-spin>
  66. </a-card>
  67. </template>
  68. <script>
  69. import { commonMixin } from '@/utils/mixin'
  70. import { STable, VSelect } from '@/components'
  71. import shelfSList from '@/views/common/shelfList'
  72. import rangeDate from '@/views/common/rangeDate.vue'
  73. import { orderBillQueryPage, orderBillQueryCount } from '@/api/shelf'
  74. export default {
  75. components: { STable, VSelect, shelfSList, rangeDate },
  76. mixins: [commonMixin],
  77. data () {
  78. const _this = this
  79. return {
  80. spinning: false,
  81. tableHeight: 0,
  82. disabled: false, // 查询、重置按钮是否可操作
  83. time: [],
  84. queryParam: {
  85. orderStartDate: '', // 开始时间
  86. orderEndDate: '', // 结束时间
  87. shelfSnList: undefined, // 货架sn
  88. orderBillNo: '', // 订单编号
  89. billState: undefined // 单据状态
  90. },
  91. columns: [
  92. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  93. { title: '订单编号', scopedSlots: { customRender: 'orderBillNo' }, width: '15%', align: 'center' },
  94. { title: '货架名称', dataIndex: 'shelfName', width: '34%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  95. { title: '总款数', dataIndex: 'productCategory', align: 'center', width: '8%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  96. { title: '总数量', dataIndex: 'totalQty', align: 'center', width: '8%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  97. { title: '总结算金额', dataIndex: 'settleAmount', align: 'right', width: '8%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } },
  98. { title: '下单时间', dataIndex: 'createDate', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  99. { title: '订单状态', dataIndex: 'billStateDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } }
  100. ],
  101. // 加载数据方法 必须为 Promise 对象
  102. loadData: parameter => {
  103. this.disabled = true
  104. this.spinning = true
  105. this.orderBillQueryCount(Object.assign(parameter, this.queryParam))
  106. return orderBillQueryPage(Object.assign(parameter, this.queryParam)).then(res => {
  107. let data
  108. if (res.status == 200) {
  109. data = res.data
  110. const no = (data.pageNo - 1) * data.pageSize
  111. for (var i = 0; i < data.list.length; i++) {
  112. data.list[i].no = no + i + 1
  113. }
  114. this.disabled = false
  115. }
  116. this.spinning = false
  117. return data
  118. })
  119. },
  120. countData: null // 统计数据
  121. }
  122. },
  123. methods: {
  124. // 选择时间 change
  125. dateChange (date) {
  126. this.queryParam.orderStartDate = date[0] || null
  127. this.queryParam.orderEndDate = date[1] || null
  128. },
  129. // 查看详情
  130. handleDetail (data) {
  131. this.$router.push({ name: 'shelfOrderDetail', params: { sn: data.orderBillSn } })
  132. },
  133. // 获取统计数据
  134. orderBillQueryCount (params) {
  135. orderBillQueryCount(params).then(res => {
  136. this.countData = res.data || null
  137. })
  138. },
  139. // 重置
  140. resetSearchForm (flag) {
  141. this.time = []
  142. this.$refs.rangeDate.resetDate(this.time)
  143. this.queryParam.orderStartDate = ''
  144. this.queryParam.orderEndDate = ''
  145. this.queryParam.orderBillNo = ''
  146. this.queryParam.billState = undefined
  147. // 如果从货架监控打开的,设置默认值
  148. if (this.$route.query && this.$route.query.bizType == 'SHELF_WARN' && flag == 1) {
  149. this.queryParam.shelfSnList = [this.$route.query.shelfSn]
  150. } else {
  151. this.queryParam.shelfSnList = undefined
  152. }
  153. this.$refs.table.refresh(true)
  154. },
  155. // 表格高度计算
  156. setTableH () {
  157. const tableSearchH = this.$refs.tableSearch.offsetHeight
  158. this.tableHeight = window.innerHeight - tableSearchH - 235
  159. },
  160. // 初始化页面
  161. pageInit () {
  162. const _this = this
  163. this.$nextTick(() => { // 页面渲染完成后的回调
  164. _this.setTableH()
  165. })
  166. }
  167. },
  168. mounted () {
  169. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  170. this.pageInit()
  171. this.resetSearchForm(1)
  172. }
  173. },
  174. watch: {
  175. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  176. this.setTableH()
  177. }
  178. },
  179. activated () {
  180. // 如果是新页签打开,则重置当前页面
  181. if (this.$store.state.app.isNewTab || this.$route.query && this.$route.query.bizType == 'SHELF_WARN') {
  182. this.pageInit()
  183. this.resetSearchForm(1)
  184. }
  185. // 仅刷新列表,不重置页面
  186. if (this.$store.state.app.updateList) {
  187. this.pageInit()
  188. this.$refs.table.refresh()
  189. }
  190. }
  191. }
  192. </script>