list.vue 9.8 KB

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