list.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="searchBoxNormal">
  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="outboundOrderList-demanderName" v-model.trim="queryParam.demanderName" allowClear placeholder="请输入客户名称"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  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. placeholder="请选择出库类型"
  26. allowClear></v-select>
  27. </a-form-item>
  28. </a-col>
  29. <template v-if="advanced">
  30. <a-col :md="6" :sm="24">
  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 :md="6" :sm="24">
  42. <a-form-item label="发货状态">
  43. <v-select
  44. v-model="queryParam.sendFlag"
  45. ref="sendFlag"
  46. id="outboundOrderList-sendFlag"
  47. code="SEND_FLAG"
  48. placeholder="请选择发货状态"
  49. allowClear></v-select>
  50. </a-form-item>
  51. </a-col>
  52. <a-col :md="6" :sm="24">
  53. <a-form-item label="业务单号">
  54. <a-input id="outboundOrderList-outBizNo" v-model.trim="queryParam.outBizNo" allowClear placeholder="请输入业务单号"/>
  55. </a-form-item>
  56. </a-col>
  57. <a-col :md="6" :sm="24">
  58. <a-form-item label="出库单号">
  59. <a-input id="outboundOrderList-stockOutNo" v-model.trim="queryParam.stockOutNo" allowClear placeholder="请输入出库单号"/>
  60. </a-form-item>
  61. </a-col>
  62. <a-col :md="6" :sm="24">
  63. <a-form-model-item label="所在区域">
  64. <subarea id="outboundOrderList-subarea" ref="subarea" @change="subareaChange"></subarea>
  65. </a-form-model-item>
  66. </a-col>
  67. <a-col :md="6" :sm="24">
  68. <a-form-model-item label="地区" prop="shippingAddrProvinceSn">
  69. <Area id="outboundOrderList-shippingAddrProvinceSn" v-model="queryParam.shippingAddrProvinceSn" placeholder="请选择省"></Area>
  70. </a-form-model-item>
  71. </a-col>
  72. <a-col :md="6" :sm="24" v-show="isShowWarehouse">
  73. <a-form-model-item label="仓库">
  74. <chooseWarehouse ref="warehouse" v-model="queryParam.warehouseSn" :isPermission="true"></chooseWarehouse>
  75. </a-form-model-item>
  76. </a-col>
  77. </template>
  78. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  79. <a-button type="primary" @click="searchTable" :disabled="disabled" id="outboundOrderList-refresh">查询</a-button>
  80. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="outboundOrderList-reset">重置</a-button>
  81. <a @click="advanced=!advanced" style="margin-left: 5px">
  82. {{ advanced ? '收起' : '展开' }}
  83. <a-icon :type="advanced ? 'up' : 'down'"/>
  84. </a>
  85. </a-col>
  86. </a-row>
  87. </a-form>
  88. </div>
  89. </a-card>
  90. <a-card size="small" :bordered="false" class="outboundOrderList-wrap">
  91. <a-spin :spinning="spinning" tip="Loading...">
  92. <!-- 列表 -->
  93. <div style="margin-bottom: 10px">
  94. <a-button
  95. type="primary"
  96. v-if="$hasPermissions('B_stockOut')"
  97. id="outboundOrder-export"
  98. :loading="loading"
  99. @click="handleOutbound()">批量出库</a-button>
  100. <a-button
  101. type="primary"
  102. v-if="$hasPermissions('B_stockSend')"
  103. class="button-info"
  104. id="outboundOrder-send"
  105. :loading="loading"
  106. @click="handleSendGood()">批量发货</a-button>
  107. <span style="margin-left: 5px">
  108. <template v-if="rowSelectionInfo && rowSelectionInfo.selectedRowKeys.length>0">{{ `已选 ${rowSelectionInfo.selectedRowKeys.length} 项` }}</template>
  109. </span>
  110. </div>
  111. <s-table
  112. class="sTable fixPagination"
  113. ref="table"
  114. :style="{ height: tableHeight+70+'px' }"
  115. size="small"
  116. :rowKey="(record) => record.stockOutSn"
  117. rowKeyName="stockOutSn"
  118. :row-selection="($hasPermissions('B_stockOut')||$hasPermissions('B_stockSend'))?{ columnWidth: 40, getCheckboxProps: record => ({ props: { disabled: record.state == 'CANCEL' } }) }:null"
  119. @rowSelection="rowSelectionFun"
  120. :columns="columns"
  121. :data="loadData"
  122. :scroll="{ y: tableHeight }"
  123. :defaultLoadData="false"
  124. bordered>
  125. <!-- 单号 -->
  126. <template slot="stockOutNo" slot-scope="text, record">
  127. <span v-if="record.stockOutNo && detailPermissions(record)" class="link-bule" @click="handleDetail(record)">{{ record.stockOutNo }}</span>
  128. <span v-else-if="record.stockOutNo && !detailPermissions(record)">{{ record.stockOutNo }}</span>
  129. <span v-else>--</span>
  130. </template>
  131. <!-- 操作 -->
  132. <template slot="action" slot-scope="text, record">
  133. <a-button
  134. size="small"
  135. type="link"
  136. v-if="record.state=='WAIT'&&$hasPermissions('B_stockOut')"
  137. class="button-primary"
  138. @click="handleOutbound(record)"
  139. id="outboundOrderList-out-btn">出库</a-button>
  140. <a-button
  141. size="small"
  142. type="link"
  143. class="button-primary"
  144. v-if="record.sendFlag==0&&$hasPermissions('B_stockSend')"
  145. @click="handleSendGood(record)"
  146. id="outboundOrderList-sendBill">发货</a-button>
  147. <span v-if="record.sendFlag==1&&record.state=='FINISH'">--</span>
  148. </template>
  149. </s-table>
  150. </a-spin>
  151. <!-- 详情 -->
  152. <a-modal
  153. centered
  154. v-drag
  155. class="outboundOrderDetail-modal"
  156. :footer="null"
  157. :maskClosable="false"
  158. title="详情"
  159. v-model="openModal"
  160. v-if="openModal"
  161. @cancel="cancleModal"
  162. width="70%">
  163. <div>
  164. <pushOrderDetailModal v-if="outBizType=='SALES'" :outBizSubSn="orderSn" />
  165. <allocationDetailModal v-if="outBizType=='ALLOCATE'" :outBizSn="orderSn" />
  166. </div>
  167. </a-modal>
  168. <!-- 发货信息 -->
  169. <sendGoodModal
  170. v-drag
  171. ref="detailModal"
  172. modalTit="新增发货单"
  173. :openModal="showDetailModal"
  174. @ok="sendSuccess"
  175. @cancel="showDetailModal=false"></sendGoodModal>
  176. </a-card>
  177. </div>
  178. </template>
  179. <script>
  180. import { commonMixin } from '@/utils/mixin'
  181. import moment from 'moment'
  182. import rangeDate from '@/views/common/rangeDate.vue'
  183. import getDate from '@/libs/getDate.js'
  184. import subarea from '@/views/common/subarea.js'
  185. import Area from '@/views/common/area.js'
  186. import pushOrderDetailModal from '@/views/salesManagement/pushOrderManagement/detailForOut.vue'
  187. import allocationDetailModal from '@/views/allocationManagement/transferOut/detail.vue'
  188. import sendGoodModal from './sendGoodModal.vue'
  189. import { STable, VSelect } from '@/components'
  190. import chooseWarehouse from '@/views/common/chooseWarehouse'
  191. import { stockOutList, stockOutOut } from '@/api/stockOut'
  192. import { getCustomerInfo, validateStockOut } from '@/api/sendBill'
  193. export default {
  194. name: 'OutboundOrderList',
  195. mixins: [commonMixin],
  196. components: { STable, VSelect, rangeDate, pushOrderDetailModal, allocationDetailModal, subarea, Area, sendGoodModal, chooseWarehouse },
  197. data () {
  198. return {
  199. spinning: false,
  200. advanced: true, // 高级搜索 展开/关闭
  201. tableHeight: 0,
  202. time: [
  203. moment(getDate.getThreeMonthDays().starttime, 'YYYY-MM-DD'),
  204. moment(getDate.getCurrMonthDays().endtime, 'YYYY-MM-DD')
  205. ],
  206. queryParam: { // 查询条件
  207. beginDate: getDate.getThreeMonthDays().starttime,
  208. endDate: getDate.getCurrMonthDays().endtime,
  209. demanderName: '', // 客户名称
  210. outBizType: undefined, // 出库类型
  211. stockOutNo: '',
  212. outBizNo: '',
  213. state: undefined, // 状态
  214. subareaArea: {
  215. subareaSn: undefined,
  216. subareaAreaSn: undefined
  217. },
  218. shippingAddrProvinceSn: undefined,
  219. sendFlag: undefined,
  220. warehouseSn: undefined
  221. },
  222. disabled: false, // 查询、重置按钮是否可操作
  223. loading: false,
  224. // 加载数据方法 必须为 Promise 对象
  225. loadData: parameter => {
  226. this.disabled = true
  227. this.spinning = true
  228. return stockOutList(Object.assign(parameter, this.queryParam)).then(res => {
  229. let data
  230. if (res.status == 200) {
  231. data = res.data
  232. const no = (data.pageNo - 1) * data.pageSize
  233. for (var i = 0; i < data.list.length; i++) {
  234. data.list[i].no = no + i + 1
  235. }
  236. this.disabled = false
  237. }
  238. this.spinning = false
  239. return data
  240. })
  241. },
  242. openModal: false,
  243. orderSn: undefined,
  244. outBizType: null, // 当前单子类型 SALES销售出库 ALLOCATE调拨出库
  245. rowSelectionInfo: null,
  246. showDetailModal: false
  247. }
  248. },
  249. computed: {
  250. columns () {
  251. const arr = [
  252. { title: '创建时间', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  253. { title: '审核时间', dataIndex: 'auditTime', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  254. { title: '出库单号', scopedSlots: { customRender: 'stockOutNo' }, width: '10%', align: 'center' },
  255. { title: '业务单号', dataIndex: 'outBizNo', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  256. { title: '出库类型', dataIndex: 'outBizTypeDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  257. { title: '客户名称', dataIndex: 'demanderName', width: '22%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  258. // { title: '仓库', dataIndex: 'warehouseName', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  259. { title: '数量', dataIndex: 'productTotalQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  260. // { title: '售价', dataIndex: 'productTotalPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  261. { title: '出库时间', dataIndex: 'outTime', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  262. { title: '出库状态', dataIndex: 'stateDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  263. { title: '发货状态', dataIndex: 'sendFlagDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  264. { title: '操作', scopedSlots: { customRender: 'action' }, width: '7%', align: 'center' }
  265. ]
  266. if (this.isShowWarehouse) {
  267. arr.splice(6, 0, { title: '仓库', dataIndex: 'warehouseName', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true })
  268. }
  269. if (this.$hasPermissions('M_outboundOrderList_salesPrice')) { // 售价权限
  270. arr.splice(this.isShowWarehouse ? 8 : 7, 0, { title: '售价', dataIndex: 'productTotalPrice', width: '6%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  271. }
  272. return arr
  273. }
  274. },
  275. methods: {
  276. // 表格选中项
  277. rowSelectionFun (obj) {
  278. this.rowSelectionInfo = obj || null
  279. },
  280. detailPermissions (row) {
  281. let state = false
  282. // 根据出库类型和对应功能权限 判断是否有查看详情的权限
  283. if (row.outBizType == 'SALES' && this.$hasPermissions('B_dispatchDetail')) { // 销售出库
  284. state = true
  285. } else if (row.outBizType == 'ALLOCATE' && this.$hasPermissions('M_transferOut_detail')) { // 调拨出库
  286. state = true
  287. }
  288. return state
  289. },
  290. // 时间 change
  291. dateChange (date) {
  292. this.queryParam.beginDate = date[0]
  293. this.queryParam.endDate = date[1]
  294. },
  295. searchTable () {
  296. this.$refs.table.clearSelected() // 清空表格选中项
  297. this.$refs.table.refresh(true)
  298. },
  299. subareaChange (val) {
  300. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  301. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  302. },
  303. // 重置
  304. resetSearchForm () {
  305. this.$refs.rangeDate.resetDate(this.time)
  306. this.queryParam.beginDate = getDate.getThreeMonthDays().starttime
  307. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  308. this.queryParam.demanderName = ''
  309. this.queryParam.outBizType = undefined
  310. this.queryParam.state = undefined
  311. this.queryParam.stockOutNo = ''
  312. this.queryParam.outBizNo = ''
  313. this.queryParam.subareaArea.subareaSn = undefined
  314. this.queryParam.subareaArea.subareaAreaSn = undefined
  315. this.queryParam.shippingAddrProvinceSn = undefined
  316. this.queryParam.sendFlag = undefined
  317. this.queryParam.warehouseSn = undefined
  318. if (this.advanced) {
  319. this.$refs.subarea.clearData()
  320. }
  321. this.$refs.table.refresh(true)
  322. },
  323. // 详情
  324. handleDetail (row) {
  325. this.outBizType = row.outBizType
  326. // 根据出库类型跳转对应页面
  327. if (row.outBizType == 'SALES' && this.$hasPermissions('B_dispatchDetail')) { // 销售出库
  328. this.orderSn = row.outBizSubSn
  329. this.openModal = true
  330. } else if (row.outBizType == 'ALLOCATE' && this.$hasPermissions('M_transferOut_detail')) { // 调拨出库
  331. this.orderSn = row.outBizSn
  332. this.openModal = true
  333. } else if (row.outBizType == 'CHECK_ORDER_OUT') { // 库存盘点盘亏
  334. }
  335. },
  336. // 关闭弹框
  337. cancleModal () {
  338. this.outBizType = null
  339. this.orderSn = undefined
  340. this.openModal = false
  341. },
  342. // 出库/批量出库
  343. handleOutbound (row) {
  344. const _this = this
  345. let content = ''
  346. let params = []
  347. if (row) { // 单个出库
  348. content = '确认要出库吗?'
  349. params = [{
  350. stockOutSn: row.stockOutSn,
  351. outBizSn: row.outBizSn,
  352. outBizSubSn: row.outBizSubSn,
  353. outBizType: row.outBizType
  354. }]
  355. } else { // 批量出库
  356. content = '确认要批量出库吗?'
  357. const selectKeys = this.rowSelectionInfo ? this.rowSelectionInfo.selectedRowKeys : []
  358. if (!this.rowSelectionInfo || (selectKeys.length < 1)) {
  359. this.$message.warning('请在列表勾选后再进行批量操作!')
  360. return
  361. }
  362. // 判断是否右已出库的
  363. const list = this.rowSelectionInfo ? this.rowSelectionInfo.selectedRows : []
  364. const hasOut = list.find(item => item.state == 'FINISH')
  365. if (hasOut) {
  366. this.$info({
  367. title: '操作提示',
  368. centered: true,
  369. content: '已出库的数据无需再次出库,请重新选择!'
  370. })
  371. return
  372. }
  373. params = []
  374. // 根据审核时间排序
  375. list.sort(function (a, b) {
  376. const t1 = new Date(a.auditTime).getTime()
  377. const t2 = new Date(b.auditTime).getTime()
  378. return t2 - t1
  379. })
  380. list.map(item => {
  381. params.push({
  382. stockOutSn: item.stockOutSn,
  383. outBizSn: item.outBizSn,
  384. outBizSubSn: item.outBizSubSn,
  385. outBizType: item.outBizType
  386. })
  387. })
  388. }
  389. this.$confirm({
  390. title: '提示',
  391. content: content,
  392. centered: true,
  393. onOk () {
  394. if (!row) { // 批量出库
  395. _this.loading = true
  396. }
  397. _this.spinning = true
  398. stockOutOut(params).then(res => {
  399. _this.loading = false
  400. if (res.status == 200) {
  401. if (!row) { // 批量出库
  402. _this.$refs.table.clearSelected() // 清空表格选中项
  403. }
  404. _this.$message.success(res.message)
  405. _this.$refs.table.refresh()
  406. _this.spinning = false
  407. } else {
  408. _this.spinning = false
  409. }
  410. })
  411. }
  412. })
  413. },
  414. // 获取客户信息
  415. async getCustome (data, stockOutSnList) {
  416. this.spinning = true
  417. const customer = await getCustomerInfo({ stockOutSnList: stockOutSnList })
  418. const validRet = await validateStockOut({ stockOutSnList, ...customer.data })
  419. if (validRet.status == 200) {
  420. this.showDetailModal = true
  421. this.$refs.detailModal.setData(data, customer.data)
  422. this.spinning = false
  423. }
  424. },
  425. // 发货/批量发货
  426. handleSendGood (row) {
  427. const _this = this
  428. let stockOutSnList = []
  429. if (row) { // 单发货
  430. stockOutSnList = [row.stockOutSn]
  431. this.getCustome([row], stockOutSnList)
  432. } else { // 批量发货
  433. const list = _this.rowSelectionInfo ? _this.rowSelectionInfo.selectedRows : []
  434. const slen = list.length
  435. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && slen < 1)) {
  436. _this.$message.warning('请在列表勾选后再进行批量操作!')
  437. return
  438. }
  439. // 根据审核时间排序
  440. list.sort(function (a, b) {
  441. const t1 = new Date(a.auditTime).getTime()
  442. const t2 = new Date(b.auditTime).getTime()
  443. return t2 - t1
  444. })
  445. // 判断是否选择相同的客户
  446. const demanderName = list[0].demanderName
  447. const haseq = list.filter(item => item.demanderName == demanderName)
  448. const hasSend = list.find(item => item.sendFlag == 1)
  449. if (haseq.length == slen && !hasSend) {
  450. // 获取客户信息
  451. list.map(item => {
  452. stockOutSnList.push(item.stockOutSn)
  453. })
  454. _this.getCustome(list, stockOutSnList)
  455. } else {
  456. this.$info({
  457. title: '操作提示',
  458. centered: true,
  459. content: hasSend ? '已发货的数据不能再次发货,请重新选择' : '您所选择的出库单,不属于同一个客户,无法批量发货,请重新选择。只能针对一个客户的出库单进行批量发货。'
  460. })
  461. }
  462. }
  463. },
  464. // 发货成功
  465. sendSuccess () {
  466. this.showDetailModal = false
  467. this.$refs.table.refresh()
  468. this.$refs.table.clearSelected()
  469. },
  470. pageInit () {
  471. const _this = this
  472. this.$nextTick(() => { // 页面渲染完成后的回调
  473. _this.setTableH()
  474. })
  475. this.rowSelectionInfo = null
  476. this.$refs.table.clearSelected()
  477. },
  478. setTableH () {
  479. const tableSearchH = this.$refs.tableSearch.offsetHeight
  480. this.tableHeight = window.innerHeight - tableSearchH - 243
  481. }
  482. },
  483. watch: {
  484. advanced (newValue, oldValue) {
  485. const _this = this
  486. this.$nextTick(() => { // 页面渲染完成后的回调
  487. _this.setTableH()
  488. })
  489. },
  490. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  491. this.setTableH()
  492. }
  493. },
  494. mounted () {
  495. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  496. this.pageInit()
  497. this.resetSearchForm()
  498. }
  499. },
  500. activated () {
  501. // 如果是新页签打开,则重置当前页面
  502. if (this.$store.state.app.isNewTab) {
  503. this.pageInit()
  504. this.resetSearchForm()
  505. }
  506. // 仅刷新列表,不重置页面
  507. if (this.$store.state.app.updateList) {
  508. this.pageInit()
  509. this.$refs.table.refresh()
  510. }
  511. },
  512. beforeRouteEnter (to, from, next) {
  513. next(vm => {})
  514. }
  515. }
  516. </script>
  517. <style lang="less">
  518. .outboundOrderList-wrap{
  519. .sTable{
  520. margin-top: 8px;
  521. }
  522. }
  523. </style>