list.vue 19 KB

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