list.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <template>
  2. <a-card size="small" :bordered="false" class="outboundOrderList-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 :xl="6" :lg="6" :md="12" :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 :xl="6" :lg="6" :md="12" :sm="24">
  14. <a-form-item label="单位名称">
  15. <a-input id="outboundOrderList-demanderName" v-model="queryParam.demanderName" placeholder="请输入单位名称" allowClear />
  16. </a-form-item>
  17. </a-col>
  18. <a-col :xl="4" :lg="6" :md="6" :sm="8">
  19. <a-form-item label="出库类型">
  20. <v-select
  21. v-model="queryParam.outBizType"
  22. ref="outBizType"
  23. id="outboundOrderList-outBizType"
  24. code="OUT_STOCK_TYPE"
  25. isEnable
  26. placeholder="请选择出库类型"
  27. allowClear></v-select>
  28. </a-form-item>
  29. </a-col>
  30. <a-col :xl="4" :lg="6" :md="6" :sm="8">
  31. <a-form-item label="单据状态">
  32. <v-select
  33. v-model="queryParam.state"
  34. ref="state"
  35. id="outboundOrderList-state"
  36. code="OUT_STATE"
  37. placeholder="请选择单据状态"
  38. allowClear></v-select>
  39. </a-form-item>
  40. </a-col>
  41. <a-col :xl="4" :lg="6" :md="6" :sm="8">
  42. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="outboundOrderList-refresh" style="margin-bottom: 10px;">查询</a-button>
  43. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="outboundOrderList-reset">重置</a-button>
  44. </a-col>
  45. </a-row>
  46. </a-form>
  47. </div>
  48. <div v-if="$hasPermissions('B_outboundBatchOut')" style="margin-bottom: 10px">
  49. <a-button type="primary" id="outboundOrderList-export" :loading="loading" @click="handleOutbounds">批量出库</a-button>
  50. <span style="margin-left: 5px" v-if="$hasPermissions('B_outboundBatchOut')">
  51. <template v-if="hasSelected">
  52. {{ `已选 ${selectedRowKeys.length} 项` }}
  53. </template>
  54. </span>
  55. </div>
  56. <!-- 列表 -->
  57. <s-table
  58. class="sTable fixPagination"
  59. ref="table"
  60. :style="{ height: tableHeight+84.5+'px' }"
  61. size="small"
  62. :row-selection="$hasPermissions('B_outboundBatchOut') ? rowSelection : null"
  63. :rowKey="(record) => record.outBizSn"
  64. :columns="columns"
  65. :data="loadData"
  66. :scroll="{ y: tableHeight }"
  67. :defaultLoadData="false"
  68. bordered>
  69. <!-- 操作 -->
  70. <template slot="action" slot-scope="text, record">
  71. <a-button
  72. size="small"
  73. type="link"
  74. v-if="record.state=='WAIT'&&$hasPermissions('B_outboundOut')"
  75. class="button-primary"
  76. @click="handleOutbound(record)"
  77. id="outboundOrderList-out-btn">出库</a-button>
  78. <a-button
  79. size="small"
  80. type="link"
  81. v-if="$hasPermissions('B_outboundOrderDetail')"
  82. class="button-success"
  83. @click="handleDetail(record)"
  84. id="outboundOrderList-detail-btn">详情</a-button>
  85. <span v-if="!(record.state=='WAIT'&&$hasPermissions('B_outboundOut')) && !($hasPermissions('B_outboundOrderDetail'))">--</span>
  86. </template>
  87. </s-table>
  88. </a-spin>
  89. <!-- 详情 -->
  90. <a-modal
  91. centered
  92. class="outboundOrderDetail-modal"
  93. :footer="null"
  94. :maskClosable="false"
  95. :bodyStyle="{padding:'12px'}"
  96. title="详情"
  97. v-model="openModal"
  98. v-if="openModal"
  99. @cancle="cancleModal"
  100. width="80%">
  101. <div style="max-height: 700px;overflow-y: scroll;">
  102. <pushOrderDetailModal v-if="outBizType=='PURCHASE_RETURN'" :outBizSn="orderSn" />
  103. <salesDetailModal v-if="outBizType=='SALES'" :outBizSn="orderSn" />
  104. <urgentDetailModal v-if="outBizType=='DISPATCH_DEDUCT'" :outBizSn="orderSn" />
  105. <storeTransferOutDetailModal v-if="outBizType=='SHOP_CALL_OUT'" :outBizSn="orderSn" />
  106. <chainTransferOutDetailModal v-if="outBizType=='LINKAGE_CALL_OUT'" :outBizSn="orderSn" />
  107. <warehouseAllocationDetailModal v-if="outBizType=='WAREHOUSE_CALL_OUT'" :outBizSn="orderSn" />
  108. </div>
  109. </a-modal>
  110. </a-card>
  111. </template>
  112. <script>
  113. import moment from 'moment'
  114. import { STable, VSelect } from '@/components'
  115. import rangeDate from '@/views/common/rangeDate.vue'
  116. import pushOrderDetailModal from '@/views/purchasingManagement/purchaseReturn/detail.vue'
  117. import salesDetailModal from '@/views/salesManagement/salesQuery/detail.vue'
  118. import urgentDetailModal from '@/views/salesManagement/urgentItemsOffset/detail.vue'
  119. import storeTransferOutDetailModal from '@/views/allocationManagement/storeTransferOut/detail.vue'
  120. import chainTransferOutDetailModal from '@/views/allocationManagement/chainTransferOut/detail.vue'
  121. import warehouseAllocationDetailModal from '@/views/allocationManagement/warehouseAllocation/detail.vue'
  122. import { stockOutList, stockOutOut, stockOutBatchOut } from '@/api/stockOut'
  123. import getDate from '@/libs/getDate.js'
  124. export default {
  125. components: { STable, VSelect, rangeDate, pushOrderDetailModal, salesDetailModal, urgentDetailModal, storeTransferOutDetailModal, chainTransferOutDetailModal, warehouseAllocationDetailModal },
  126. data () {
  127. return {
  128. spinning: false,
  129. advanced: true, // 高级搜索 展开/关闭
  130. tableHeight: 0, // 表格高度
  131. time: [
  132. moment(getDate.getCurrMonthDays().starttime),
  133. moment(getDate.getCurrMonthDays().endtime)
  134. ],
  135. queryParam: { // 查询条件
  136. beginDate: getDate.getCurrMonthDays().starttime,
  137. endDate: getDate.getCurrMonthDays().endtime,
  138. demanderName: undefined, // 单位名称
  139. outBizType: undefined, // 出库类型
  140. state: undefined // 状态
  141. },
  142. disabled: false, // 查询、重置按钮是否可操作
  143. columns: [
  144. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  145. { title: '关联单号', dataIndex: 'outBizNo', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  146. { title: '出库类型', dataIndex: 'outBizTypeDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  147. { title: '单位名称', dataIndex: 'demanderName', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  148. { title: '总款数', dataIndex: 'productTotalCategory', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  149. { title: '总数量', dataIndex: 'productTotalQty', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  150. { title: '总售价', dataIndex: 'productTotalPrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  151. { title: '审核时间', dataIndex: 'auditTime', width: '12%', align: 'center', customRender: function (text) { return text || '--' }, sorter: true },
  152. { title: '出库时间', dataIndex: 'outTime', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  153. { title: '出库状态', dataIndex: 'stateDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' }, sorter: true },
  154. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  155. ],
  156. selectedRowKeys: [], // Check here to configure the default column
  157. selectedRows: [],
  158. loading: false,
  159. // 加载数据方法 必须为 Promise 对象
  160. loadData: parameter => {
  161. // 排序
  162. if (parameter.sortField == 'stateDictValue') {
  163. parameter.sortField = 'state'
  164. }
  165. this.disabled = true
  166. this.spinning = true
  167. return stockOutList(Object.assign(parameter, this.queryParam)).then(res => {
  168. let data
  169. if (res.status == 200) {
  170. data = res.data
  171. const no = (data.pageNo - 1) * data.pageSize
  172. for (var i = 0; i < data.list.length; i++) {
  173. data.list[i].no = no + i + 1
  174. }
  175. this.disabled = false
  176. }
  177. this.spinning = false
  178. return data
  179. })
  180. },
  181. openModal: false,
  182. orderSn: undefined,
  183. outBizType: null // 当前单子类型 SALES销售出库 ALLOCATE调拨出库
  184. }
  185. },
  186. computed: {
  187. hasSelected () {
  188. return this.selectedRowKeys.length > 0
  189. },
  190. rowSelection () {
  191. if (this.$hasPermissions('B_outboundBatchOut')) {
  192. return {
  193. selectedRowKeys: this.selectedRowKeys,
  194. onChange: (selectedRowKeys, selectedRows) => {
  195. this.selectedRowKeys = selectedRowKeys
  196. },
  197. onSelect: (record, selected, selectedRows, nativeEvent) => {
  198. this.onSelectChange(record, selected, selectedRows, nativeEvent)
  199. },
  200. onSelectAll: (selected, selectedRows, changeRows) => {
  201. this.onSelectAllChange(selected, selectedRows, changeRows)
  202. },
  203. getCheckboxProps: record => ({
  204. props: {
  205. disabled: record.state == 'FINISH'
  206. }
  207. })
  208. }
  209. } else {
  210. return null
  211. }
  212. }
  213. },
  214. methods: {
  215. detailPermissions (row) {
  216. let state = false
  217. // 根据出库类型和对应功能权限 判断是否有查看详情的权限
  218. if ((row.outBizType == 'PURCHASE_RETURN') && this.$hasPermissions('B_purchaseReturnDetail')) { // 采购退货
  219. state = true
  220. } else if ((row.outBizType == 'SALES') && this.$hasPermissions('B_salesDetail')) { // 销售
  221. state = true
  222. } else if ((row.outBizType == 'DISPATCH_DEDUCT') && this.$hasPermissions('M_urgentDetail')) { // 急件冲减
  223. state = true
  224. } else if ((row.outBizType == 'SHOP_CALL_OUT') && this.$hasPermissions('B_storeCallOutDetail')) { // 店内调出
  225. state = true
  226. } else if ((row.outBizType == 'LINKAGE_CALL_OUT') && this.$hasPermissions('B_allocLinkageOutDetail')) { // 连锁调出
  227. state = true
  228. } else if ((row.outBizType == 'WAREHOUSE_CALL_OUT') && this.$hasPermissions('B_warehouseAllocationDetail')) { // 仓库调出
  229. state = true
  230. }
  231. return state
  232. },
  233. // 时间 change
  234. dateChange (date) {
  235. this.queryParam.beginDate = date[0]
  236. this.queryParam.endDate = date[1]
  237. },
  238. filterOption (input, option) {
  239. return (
  240. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  241. )
  242. },
  243. // 重置
  244. resetSearchForm () {
  245. this.resetData()
  246. this.$refs.table.refresh(true)
  247. },
  248. // 重置数据
  249. resetData () {
  250. this.$refs.rangeDate.resetDate(this.time)
  251. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  252. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  253. this.queryParam.demanderName = undefined
  254. this.queryParam.outBizType = undefined
  255. this.queryParam.state = undefined
  256. },
  257. // 详情
  258. handleDetail (row) {
  259. this.outBizType = row.outBizType
  260. // 根据出库类型跳转对应页面
  261. if (row.outBizType == 'PURCHASE_RETURN') { // 采购退货
  262. // this.$router.push({ path: `/purchasingManagement/purchaseReturn/detail/${row.outBizSn}` })
  263. this.orderSn = row.outBizSn
  264. this.openModal = true
  265. } else if (row.outBizType == 'SPARE_PARTS_RETURN') { // 散件退货
  266. this.$message.warning('该出库类型对应页面未开发')
  267. } else if (row.outBizType == 'SALES') { // 销售
  268. // this.$router.push({ path: `/salesManagement/salesQuery/detail/${row.outBizSn}` })
  269. this.orderSn = row.outBizSn
  270. this.openModal = true
  271. } else if (row.outBizType == 'DISPATCH_DEDUCT') { // 急件冲减
  272. // this.$router.push({ path: `/salesManagement/urgentItemsOffset/detail/${row.outBizSn}` })
  273. this.orderSn = row.outBizSn
  274. this.openModal = true
  275. } else if (row.outBizType == 'SHOP_CALL_OUT') { // 店内调出
  276. // this.$router.push({ path: `/allocationManagement/storeTransferOut/detail/${row.outBizSn}` })
  277. this.orderSn = row.outBizSn
  278. this.openModal = true
  279. } else if (row.outBizType == 'CHECK_ORDER_OUT') { // 库存盘点盘亏
  280. this.$message.warning('该出库类型对应页面未开发')
  281. } else if (row.outBizType == 'LINKAGE_CALL_OUT') { // 连锁调出
  282. // this.$router.push({ path: `/allocationManagement/chainTransferOut/detail/${row.outBizSn}` })
  283. this.orderSn = row.outBizSn
  284. this.openModal = true
  285. } else if (row.outBizType == 'WAREHOUSE_CALL_OUT') { // 仓库调出
  286. // this.$router.push({ path: `/allocationManagement/warehouseAllocation/detail/${row.outBizSn}` })
  287. this.orderSn = row.outBizSn
  288. this.openModal = true
  289. } else {
  290. this.$message.warning('出库类型未知')
  291. }
  292. },
  293. // 关闭弹框
  294. cancleModal () {
  295. this.outBizType = null
  296. this.orderSn = undefined
  297. this.openModal = false
  298. },
  299. // 单个出库
  300. handleOutbound (row) {
  301. const _this = this
  302. this.$confirm({
  303. title: '提示',
  304. content: '确认要出库吗?',
  305. centered: true,
  306. onOk () {
  307. _this.spinning = true
  308. stockOutOut({ outBizSn: row.outBizSn, outStockEnum: row.outBizType }).then(res => {
  309. if (res.status == 200) {
  310. _this.$message.success(res.message)
  311. _this.$refs.table.refresh()
  312. _this.spinning = false
  313. } else {
  314. _this.spinning = false
  315. }
  316. })
  317. }
  318. })
  319. },
  320. // 批量出库
  321. handleOutbounds () {
  322. if (this.selectedRowKeys.length < 1) {
  323. this.$message.warning('请在列表勾选后再进行批量操作!')
  324. return
  325. }
  326. this.loading = true
  327. this.spinning = true
  328. const params = []
  329. this.selectedRows.map(item => {
  330. params.push({ outBizSn: item.outBizSn, outStockEnum: item.outBizType })
  331. })
  332. stockOutBatchOut(params).then(res => {
  333. this.loading = false
  334. if (res.status == 200) {
  335. this.$message.success(res.message)
  336. this.selectedRowKeys = []
  337. this.selectedRows = []
  338. this.$refs.table.refresh()
  339. this.spinning = false
  340. } else {
  341. this.spinning = false
  342. }
  343. })
  344. },
  345. onSelectChange (record, selected, selectedRows, nativeEvent) {
  346. if (selected) { // 选择
  347. this.selectedRows.push(record)
  348. } else { // 取消
  349. this.selectedRows = selectedRows
  350. }
  351. },
  352. // 本页全选/取消全选
  353. onSelectAllChange (selected, selectedRows, changeRows) {
  354. const _this = this
  355. if (selected) { // 选择
  356. this.selectedRows = [...this.selectedRows, ...changeRows]
  357. } else { // 取消
  358. const arrId = []
  359. this.selectedRows.map((item, index) => {
  360. this.selectedRows.map((subItem, ind) => {
  361. if (item.outBizSn == subItem.outBizSn) {
  362. arrId.push(index)
  363. }
  364. })
  365. })
  366. arrId.map((item, index) => {
  367. _this.selectedRows = _this.selectedRows.slice(item, item + 1)
  368. })
  369. }
  370. },
  371. pageInit () {
  372. const _this = this
  373. this.$nextTick(() => { // 页面渲染完成后的回调
  374. _this.setTableH()
  375. })
  376. this.selectedRowKeys = []
  377. this.selectedRows = []
  378. },
  379. setTableH () {
  380. const tableSearchH = this.$refs.tableSearch.offsetHeight
  381. this.tableHeight = window.innerHeight - tableSearchH - 245
  382. }
  383. },
  384. watch: {
  385. advanced (newValue, oldValue) {
  386. const _this = this
  387. setTimeout(() => {
  388. _this.setTableH()
  389. }, 400)
  390. },
  391. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  392. this.setTableH()
  393. }
  394. },
  395. mounted () {
  396. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  397. this.pageInit()
  398. this.resetSearchForm()
  399. }
  400. },
  401. activated () {
  402. // 如果是新页签打开,则重置当前页面
  403. if (this.$store.state.app.isNewTab) {
  404. this.resetData()
  405. if (this.$route.query.pageParams) {
  406. this.queryParam.state = this.$route.query.pageParams.state
  407. }
  408. this.pageInit()
  409. this.$refs.table.refresh(true)
  410. }
  411. },
  412. beforeRouteEnter (to, from, next) {
  413. next(vm => {})
  414. }
  415. }
  416. </script>