list.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <a-card size="small" :bordered="false" class="jg-page-wrap purchaseOutOfStock-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" :value="time" @change="dateChange" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="供应商名称">
  15. <a-input id="outOfStockList-purchaseTargetName" v-model.trim="queryParam.purchaseTargetName" placeholder="请输入客户名称" allowClear />
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="采购单号">
  20. <a-input id="outOfStockList-purchaseBillNo" v-model.trim="queryParam.purchaseBillNo" placeholder="请输入采购单号" allowClear />
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  24. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="purchaseOutOfStock-refresh">查询</a-button>
  25. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="purchaseOutOfStock-reset">重置</a-button>
  26. <a-button
  27. type="primary"
  28. style="margin-left: 5px"
  29. @click="handleExport"
  30. :disabled="disabled"
  31. :loading="exportLoading"
  32. v-if="$hasPermissions('B_isExport')"
  33. class="button-warning"
  34. id="inventoryWarningList-export-btn">导出</a-button>
  35. </a-col>
  36. </a-row>
  37. </a-form>
  38. </div>
  39. <!-- 合计 -->
  40. <a-alert type="info" style="margin-bottom:10px" v-if="countData">
  41. <div class="ftext" slot="message">
  42. 缺货总款数:<strong>{{ countData.totalCount || countData.totalCount==0 ? countData.totalCount : '--' }}</strong>;
  43. 缺货总数量:<strong>{{ countData.totalQty || countData.totalQty==0 ? countData.totalQty : '--' }}</strong>;
  44. <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
  45. 缺货总金额:<strong>{{ countData.totalAmount || countData.totalAmount==0 ? toThousands(countData.totalAmount) : '--' }}</strong>。
  46. </div>
  47. </div>
  48. </a-alert>
  49. <!-- 列表 -->
  50. <s-table
  51. class="sTable fixPagination"
  52. ref="table"
  53. :style="{ height: tableHeight+84.5+'px' }"
  54. size="small"
  55. :rowKey="(record) => record.id"
  56. :columns="columns"
  57. :data="loadData"
  58. :scroll="{ y: tableHeight }"
  59. :defaultLoadData="false"
  60. bordered>
  61. <!-- 操作 -->
  62. <template slot="action" slot-scope="text, record">
  63. <a-button
  64. size="small"
  65. type="link"
  66. class="button-success"
  67. v-if="$hasPermissions('B_purchaseOutOfStockDetail')"
  68. @click="handleDetail(record)"
  69. id="purchaseOutOfStock-edit-btn">详情</a-button>
  70. </template>
  71. </s-table>
  72. </a-spin>
  73. <!-- 查看详情 -->
  74. <detail-modal ref="outOfStockDetail" v-drag :openModal="openModal" :objItem="detailObj" @close="closeModal" />
  75. </a-card>
  76. </template>
  77. <script>
  78. import { commonMixin } from '@/utils/mixin'
  79. import { STable, VSelect } from '@/components'
  80. import rangeDate from '@/views/common/rangeDate.vue'
  81. import { outOfStockList, outOfStockExportDetail, outOfStockQueryCount } from '@/api/oos'
  82. import custList from '@/views/common/custList.vue'
  83. import detailModal from './detailModal.vue'
  84. import { downloadExcel } from '@/libs/JGPrint.js'
  85. export default {
  86. name: 'PurchaseOutOfStock',
  87. components: { STable, VSelect, rangeDate, custList, detailModal },
  88. mixins: [commonMixin],
  89. data () {
  90. return {
  91. spinning: false,
  92. queryParam: { // 查询条件
  93. beginDate: undefined,
  94. endDate: undefined,
  95. purchaseTargetName: '',
  96. purchaseBillNo: ''
  97. },
  98. detailObj: undefined, // 详情统计内容
  99. openModal: false,
  100. disabled: false, // 查询、重置按钮是否可操作
  101. tableHeight: 0,
  102. time: [],
  103. countData: null,
  104. exportLoading: false, // 导出loading
  105. // 加载数据方法 必须为 Promise 对象
  106. loadData: parameter => {
  107. this.disabled = true
  108. this.spinning = true
  109. const params = Object.assign(parameter, this.queryParam)
  110. return outOfStockList(params).then(res => {
  111. let data
  112. if (res.status == 200) {
  113. data = res.data
  114. const no = (data.pageNo - 1) * data.pageSize
  115. for (var i = 0; i < data.list.length; i++) {
  116. data.list[i].no = no + i + 1
  117. }
  118. this.getCount(params)
  119. this.disabled = false
  120. }
  121. this.spinning = false
  122. return data
  123. })
  124. }
  125. }
  126. },
  127. computed: {
  128. columns () {
  129. const _this = this
  130. const arr = [
  131. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  132. { title: '创建时间', dataIndex: 'createDate', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  133. { title: '采购单号', dataIndex: 'purchaseBillNo', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  134. { title: '供应商', dataIndex: 'purchaseTargetName', width: '18%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  135. { title: '缺货款数', dataIndex: 'totalCategory', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  136. { title: '缺货数量', dataIndex: 'totalQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  137. { title: '缺货金额', dataIndex: 'totalAmount', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } },
  138. { title: '操作', scopedSlots: { customRender: 'action' }, width: '13%', align: 'center' }
  139. ]
  140. return arr
  141. }
  142. },
  143. methods: {
  144. // 统计
  145. getCount (params) {
  146. outOfStockQueryCount(params).then(res => {
  147. if (res.status == 200) {
  148. this.countData = res.data
  149. } else {
  150. this.countData = null
  151. }
  152. })
  153. },
  154. // 导出
  155. handleExport () {
  156. const _this = this
  157. _this.exportLoading = true
  158. outOfStockExportDetail(_this.queryParam).then(res => {
  159. downloadExcel(res, '采购缺货列表')
  160. _this.exportLoading = false
  161. })
  162. },
  163. // 关闭详情弹窗
  164. closeModal () {
  165. this.openModal = false
  166. this.detailObj = undefined
  167. },
  168. // 时间 change
  169. dateChange (date) {
  170. this.queryParam.beginDate = date[0]
  171. this.queryParam.endDate = date[1]
  172. },
  173. // 重置
  174. resetSearchForm () {
  175. this.$refs.rangeDate.resetDate(this.time)
  176. this.queryParam.beginDate = undefined
  177. this.queryParam.endDate = undefined
  178. this.queryParam.purchaseTargetName = ''
  179. this.queryParam.purchaseBillNo = ''
  180. this.$refs.table.refresh(true)
  181. },
  182. // 详情
  183. handleDetail (row) {
  184. this.openModal = true
  185. this.detailObj = row
  186. const _this = this
  187. _this.$nextTick(() => {
  188. _this.$refs.outOfStockDetail.pageInit()
  189. })
  190. },
  191. pageInit () {
  192. const _this = this
  193. this.$nextTick(() => { // 页面渲染完成后的回调
  194. _this.setTableH()
  195. })
  196. _this.resetSearchForm()
  197. },
  198. setTableH () {
  199. const tableSearchH = this.$refs.tableSearch.offsetHeight
  200. this.tableHeight = window.innerHeight - tableSearchH - 235
  201. }
  202. },
  203. watch: {
  204. advanced (newValue, oldValue) {
  205. const _this = this
  206. this.$nextTick(() => { // 页面渲染完成后的回调
  207. _this.setTableH()
  208. })
  209. },
  210. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  211. this.setTableH()
  212. }
  213. },
  214. activated () {
  215. this.pageInit()
  216. },
  217. beforeRouteEnter (to, from, next) {
  218. next(vm => {})
  219. }
  220. }
  221. </script>