list.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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="6" :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="6" :sm="24">
  14. <a-form-item label="货架名称">
  15. <shelfSList ref="shelfSList" :showAll="true" mode="multiple" v-model="queryParam.shelfSnList"></shelfSList>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="下单时间">
  20. <rangeDate ref="rangeDate" :value="time" @change="dateChange" />
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="订单状态">
  25. <v-select
  26. v-model="queryParam.billState"
  27. ref="billState"
  28. id="shelfOrder-billState"
  29. code="ORDER_BILL_STATE"
  30. placeholder="请选择订单状态"
  31. allowClear></v-select>
  32. </a-form-item>
  33. </a-col>
  34. <a-col :md="6" :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 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,
  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. openModal: false,
  121. countData: null
  122. }
  123. },
  124. methods: {
  125. // 时间 change
  126. dateChange (date) {
  127. this.queryParam.orderStartDate = date[0] || null
  128. this.queryParam.orderEndDate = date[1] || null
  129. },
  130. handleDetail (data) {
  131. this.$router.push({ name: 'shelfOrderDetail', params: { sn: data.orderBillSn } })
  132. },
  133. orderBillQueryCount (params) {
  134. orderBillQueryCount(params).then(res => {
  135. this.countData = res.data || null
  136. })
  137. },
  138. // 重置
  139. resetSearchForm (flag) {
  140. this.time = []
  141. this.$refs.rangeDate.resetDate(this.time)
  142. this.queryParam.orderStartDate = ''
  143. this.queryParam.orderEndDate = ''
  144. this.queryParam.orderBillNo = ''
  145. this.queryParam.billState = undefined
  146. console.log(flag)
  147. if (this.$route.query && this.$route.query.bizType == 'SHELF_WARN' && flag == 1) {
  148. this.queryParam.shelfSnList = [this.$route.query.shelfSn]
  149. } else {
  150. this.queryParam.shelfSnList = undefined
  151. }
  152. this.$refs.table.refresh(true)
  153. },
  154. setTableH () {
  155. const tableSearchH = this.$refs.tableSearch.offsetHeight
  156. this.tableHeight = window.innerHeight - tableSearchH - 235
  157. },
  158. pageInit () {
  159. const _this = this
  160. this.$nextTick(() => { // 页面渲染完成后的回调
  161. _this.setTableH()
  162. })
  163. }
  164. },
  165. mounted () {
  166. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  167. this.pageInit()
  168. this.resetSearchForm(1)
  169. }
  170. },
  171. watch: {
  172. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  173. this.setTableH()
  174. }
  175. },
  176. activated () {
  177. // 如果是新页签打开,则重置当前页面
  178. if (this.$store.state.app.isNewTab || this.$route.query && this.$route.query.bizType == 'SHELF_WARN') {
  179. this.pageInit()
  180. this.resetSearchForm(1)
  181. }
  182. // 仅刷新列表,不重置页面
  183. if (this.$store.state.app.updateList) {
  184. this.pageInit()
  185. this.$refs.table.refresh()
  186. }
  187. }
  188. }
  189. </script>