list.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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" @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. <a-input id="outboundOrderList-outBizNo" v-model.trim="queryParam.outBizNo" allowClear placeholder="请输入业务单号"/>
  44. </a-form-item>
  45. </a-col>
  46. <a-col :md="6" :sm="24">
  47. <a-form-item label="出库单号">
  48. <a-input id="outboundOrderList-stockOutNo" v-model.trim="queryParam.stockOutNo" allowClear placeholder="请输入出库单号"/>
  49. </a-form-item>
  50. </a-col>
  51. <a-col :md="6" :sm="24">
  52. <a-form-model-item label="所在区域">
  53. <subarea id="outboundOrderList-subarea" v-model="queryParam.subareaSn"></subarea>
  54. </a-form-model-item>
  55. </a-col>
  56. <a-col :md="6" :sm="24">
  57. <a-form-model-item label="地区">
  58. <a-form-model-item prop="shippingAddrProvinceSn">
  59. <a-select id="outboundOrderList-shippingAddrProvinceSn" allowClear v-model="queryParam.shippingAddrProvinceSn" placeholder="请选择省">
  60. <a-select-option v-for="item in addrProvinceList" :value="item.areaSn" :key="item.areaSn + 'a'">{{ item.name }}</a-select-option>
  61. </a-select>
  62. </a-form-model-item>
  63. </a-form-model-item>
  64. </a-col>
  65. </template>
  66. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  67. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="outboundOrderList-refresh">查询</a-button>
  68. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="outboundOrderList-reset">重置</a-button>
  69. <a @click="advanced=!advanced" style="margin-left: 5px">
  70. {{ advanced ? '收起' : '展开' }}
  71. <a-icon :type="advanced ? 'up' : 'down'"/>
  72. </a>
  73. </a-col>
  74. </a-row>
  75. </a-form>
  76. </div>
  77. <!-- 列表 -->
  78. <div style="margin-bottom: 10px" v-if="$hasPermissions('B_stockOut')">
  79. <a-button type="primary" class="button-error" id="outboundOrder-export" :loading="loading" @click="handleOutbound()">批量出库</a-button>
  80. <span style="margin-left: 5px">
  81. <template v-if="hasSelected">{{ `已选 ${selectedRowKeys.length} 项` }}</template>
  82. </span>
  83. </div>
  84. <s-table
  85. class="sTable fixPagination"
  86. ref="table"
  87. :style="{ height: tableHeight+84.5+'px' }"
  88. size="small"
  89. :row-selection="$hasPermissions('B_stockOut')?rowSelection:null"
  90. :rowKey="(record) => record.stockOutSn"
  91. :columns="columns"
  92. :data="loadData"
  93. :scroll="{ y: tableHeight }"
  94. :defaultLoadData="false"
  95. bordered>
  96. <!-- 单号 -->
  97. <template slot="stockOutNo" slot-scope="text, record">
  98. <span v-if="record.stockOutNo" :class="detailPermissions(record)?'active':'common'" @click="handleDetail(record)">{{ record.stockOutNo }}</span>
  99. <span v-else>--</span>
  100. </template>
  101. <!-- 操作 -->
  102. <template slot="action" slot-scope="text, record">
  103. <a-button
  104. size="small"
  105. type="link"
  106. v-if="record.state=='WAIT'&&$hasPermissions('B_stockOut')"
  107. class="button-primary"
  108. @click="handleOutbound(record)"
  109. id="outboundOrderList-out-btn">出库</a-button>
  110. <span v-else>--</span>
  111. </template>
  112. </s-table>
  113. </a-spin>
  114. <!-- 详情 -->
  115. <a-modal
  116. centered
  117. class="outboundOrderDetail-modal"
  118. :footer="null"
  119. :maskClosable="false"
  120. title="详情"
  121. v-model="openModal"
  122. v-if="openModal"
  123. @cancle="cancleModal"
  124. width="80%">
  125. <div style="max-height: 700px;overflow-y: scroll;">
  126. <pushOrderDetailModal v-if="outBizType=='SALES'" :outBizSubSn="orderSn" />
  127. <allocationDetailModal v-if="outBizType=='ALLOCATE'" :outBizSn="orderSn" />
  128. </div>
  129. </a-modal>
  130. </a-card>
  131. </template>
  132. <script>
  133. import rangeDate from '@/views/common/rangeDate.vue'
  134. import subarea from '@/views/common/subarea.js'
  135. import { getArea } from '@/api/data'
  136. import pushOrderDetailModal from '@/views/salesManagement/pushOrderManagement/detail.vue'
  137. import allocationDetailModal from '@/views/allocationManagement/transferOut/detail.vue'
  138. import { STable, VSelect } from '@/components'
  139. import { stockOutList, stockOutOut } from '@/api/stockOut'
  140. export default {
  141. components: { STable, VSelect, rangeDate, pushOrderDetailModal, allocationDetailModal, subarea },
  142. data () {
  143. return {
  144. spinning: false,
  145. advanced: false, // 高级搜索 展开/关闭
  146. tableHeight: 0,
  147. queryParam: { // 查询条件
  148. beginDate: '',
  149. endDate: '',
  150. demanderName: '', // 客户名称
  151. outBizType: undefined, // 出库类型
  152. stockOutNo: '',
  153. outBizNo: '',
  154. state: undefined, // 状态
  155. subareaSn: undefined,
  156. shippingAddrProvinceSn: undefined
  157. },
  158. disabled: false, // 查询、重置按钮是否可操作
  159. selectedRowKeys: [], // Check here to configure the default column
  160. selectedRows: [],
  161. loading: false,
  162. // 加载数据方法 必须为 Promise 对象
  163. loadData: parameter => {
  164. this.disabled = true
  165. this.spinning = true
  166. return stockOutList(Object.assign(parameter, this.queryParam)).then(res => {
  167. const data = res.data
  168. const no = (data.pageNo - 1) * data.pageSize
  169. for (var i = 0; i < data.list.length; i++) {
  170. data.list[i].no = no + i + 1
  171. }
  172. this.disabled = false
  173. this.spinning = false
  174. return data
  175. })
  176. },
  177. addrProvinceList: [], // 省下拉
  178. openModal: false,
  179. orderSn: undefined,
  180. outBizType: null // 当前单子类型 SALES销售出库 ALLOCATE调拨出库
  181. }
  182. },
  183. computed: {
  184. columns () {
  185. const arr = [
  186. { title: '创建时间', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  187. { title: '审核时间', dataIndex: 'auditTime', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  188. { title: '出库单号', scopedSlots: { customRender: 'stockOutNo' }, width: '15%', align: 'center' },
  189. { title: '业务单号', dataIndex: 'outBizNo', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  190. { title: '出库类型', dataIndex: 'outBizTypeDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  191. { title: '客户名称', dataIndex: 'demanderName', width: '12%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  192. { title: '数量', dataIndex: 'productTotalQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  193. // { title: '售价', dataIndex: 'productTotalPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  194. { title: '出库时间', dataIndex: 'outTime', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  195. { title: '出库状态', dataIndex: 'stateDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  196. { title: '操作', scopedSlots: { customRender: 'action' }, width: '7%', align: 'center' }
  197. ]
  198. if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
  199. arr.splice(7, 0, { title: '售价', dataIndex: 'productTotalPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  200. }
  201. return arr
  202. },
  203. hasSelected () {
  204. return this.selectedRowKeys.length > 0
  205. },
  206. rowSelection () {
  207. return {
  208. selectedRowKeys: this.selectedRowKeys,
  209. onChange: (selectedRowKeys, selectedRows) => {
  210. this.onChange(selectedRowKeys, selectedRows)
  211. },
  212. onSelect: (record, selected, selectedRows, nativeEvent) => {
  213. this.onSelectChange(record, selected, selectedRows, nativeEvent)
  214. },
  215. onSelectAll: (selected, selectedRows, changeRows) => {
  216. this.onSelectAllChange(selected, selectedRows, changeRows)
  217. },
  218. getCheckboxProps: record => ({
  219. props: {
  220. disabled: record.state == 'FINISH' // Column configuration not to be checked
  221. }
  222. })
  223. }
  224. }
  225. },
  226. methods: {
  227. detailPermissions (row) {
  228. let state = false
  229. // 根据出库类型和对应功能权限 判断是否有查看详情的权限
  230. if (row.outBizType == 'SALES' && this.$hasPermissions('B_dispatchDetail')) { // 销售出库
  231. state = true
  232. } else if (row.outBizType == 'ALLOCATE' && this.$hasPermissions('M_transferOut_detail')) { // 调拨出库
  233. state = true
  234. }
  235. return state
  236. },
  237. // 时间 change
  238. dateChange (date) {
  239. this.queryParam.beginDate = date[0]
  240. this.queryParam.endDate = date[1]
  241. },
  242. // 重置
  243. resetSearchForm () {
  244. this.$refs.rangeDate.resetDate()
  245. this.queryParam.beginDate = ''
  246. this.queryParam.endDate = ''
  247. this.queryParam.demanderName = ''
  248. this.queryParam.outBizType = undefined
  249. this.queryParam.state = undefined
  250. this.queryParam.stockOutNo = ''
  251. this.queryParam.outBizNo = ''
  252. this.queryParam.subareaSn = undefined
  253. this.queryParam.shippingAddrProvinceSn = undefined
  254. this.$refs.table.refresh(true)
  255. },
  256. // 详情
  257. handleDetail (row) {
  258. this.outBizType = row.outBizType
  259. // 根据出库类型跳转对应页面
  260. if (row.outBizType == 'SALES' && this.$hasPermissions('B_dispatchDetail')) { // 销售出库
  261. // this.$router.push({ path: `/salesManagement/pushOrderManagement/detail/${row.outBizSubSn}/stockOut` })
  262. this.orderSn = row.outBizSubSn
  263. this.openModal = true
  264. } else if (row.outBizType == 'ALLOCATE' && this.$hasPermissions('M_transferOut_detail')) { // 调拨出库
  265. // this.$router.push({ path: `/allocationManagement/transferOut/detail/${row.outBizSn}` })
  266. this.orderSn = row.outBizSn
  267. this.openModal = true
  268. } else if (row.outBizType == 'CHECK_ORDER_OUT') { // 库存盘点盘亏
  269. }
  270. },
  271. // 关闭弹框
  272. cancleModal () {
  273. this.outBizType = null
  274. this.orderSn = undefined
  275. this.openModal = false
  276. },
  277. // 出库/批量出库
  278. handleOutbound (row) {
  279. const _this = this
  280. let content = ''
  281. let params = []
  282. if (row) { // 单个出库
  283. content = '确认要出库吗?'
  284. params = [{
  285. stockOutSn: row.stockOutSn,
  286. outBizSn: row.outBizSn,
  287. outBizSubSn: row.outBizSubSn,
  288. outBizType: row.outBizType
  289. }]
  290. } else { // 批量出库
  291. content = '确认要批量出库吗?'
  292. if (this.selectedRowKeys.length < 1) {
  293. this.$message.warning('请在列表勾选后再进行批量操作!')
  294. return
  295. }
  296. params = []
  297. this.selectedRows.map(item => {
  298. params.push({
  299. stockOutSn: item.stockOutSn,
  300. outBizSn: item.outBizSn,
  301. outBizSubSn: item.outBizSubSn,
  302. outBizType: item.outBizType
  303. })
  304. })
  305. }
  306. this.$confirm({
  307. title: '提示',
  308. content: content,
  309. centered: true,
  310. onOk () {
  311. if (!row) { // 批量出库
  312. _this.loading = true
  313. }
  314. _this.spinning = true
  315. stockOutOut(params).then(res => {
  316. _this.loading = false
  317. if (res.status == 200) {
  318. if (!row) { // 批量出库
  319. _this.selectedRowKeys = []
  320. _this.selectedRows = []
  321. }
  322. _this.$message.success(res.message)
  323. _this.$refs.table.refresh()
  324. _this.spinning = false
  325. } else {
  326. _this.spinning = false
  327. }
  328. })
  329. }
  330. })
  331. },
  332. onChange (selectedRowKeys, selectedRows) {
  333. this.selectedRowKeys = selectedRowKeys
  334. },
  335. onSelectChange (record, selected, selectedRows, nativeEvent) {
  336. if (selected) { // 选择
  337. this.selectedRows.push(record)
  338. } else { // 取消
  339. this.selectedRows = selectedRows
  340. }
  341. },
  342. // 本页全选/取消全选
  343. onSelectAllChange (selected, selectedRows, changeRows) {
  344. const _this = this
  345. if (selected) { // 选择
  346. this.selectedRows = [...this.selectedRows, ...changeRows]
  347. } else { // 取消
  348. const arrId = []
  349. this.selectedRows.map((item, index) => {
  350. this.selectedRows.map((subItem, ind) => {
  351. if (item.stockOutSn == subItem.stockOutSn) {
  352. arrId.push(index)
  353. }
  354. })
  355. })
  356. arrId.map((item, index) => {
  357. _this.selectedRows = _this.selectedRows.slice(item, item + 1)
  358. })
  359. }
  360. },
  361. // 省/市/区
  362. getArea (leve, sn) {
  363. let params
  364. if (leve == 'province') {
  365. params = { type: '2' }
  366. } else {
  367. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  368. }
  369. getArea(params).then(res => {
  370. if (res.status == 200) {
  371. if (leve == 'province') {
  372. this.addrProvinceList = res.data || []
  373. } else if (leve == 'city') {
  374. this.addrCityList = res.data || []
  375. } else if (leve == 'district') {
  376. this.addrDistrictList = res.data || []
  377. }
  378. } else {
  379. if (leve == 'province') {
  380. this.addrProvinceList = []
  381. } else if (leve == 'city') {
  382. this.addrCityList = []
  383. } else if (leve == 'district') {
  384. this.addrDistrictList = []
  385. }
  386. }
  387. })
  388. },
  389. pageInit () {
  390. const _this = this
  391. this.$nextTick(() => { // 页面渲染完成后的回调
  392. _this.setTableH()
  393. })
  394. this.getArea('province')
  395. },
  396. setTableH () {
  397. const tableSearchH = this.$refs.tableSearch.offsetHeight
  398. this.tableHeight = window.innerHeight - tableSearchH - 235
  399. }
  400. },
  401. watch: {
  402. advanced (newValue, oldValue) {
  403. const _this = this
  404. setTimeout(() => {
  405. _this.setTableH()
  406. }, 400)
  407. },
  408. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  409. this.setTableH()
  410. }
  411. },
  412. mounted () {
  413. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  414. this.pageInit()
  415. this.resetSearchForm()
  416. }
  417. },
  418. activated () {
  419. // 如果是新页签打开,则重置当前页面
  420. if (this.$store.state.app.isNewTab) {
  421. this.pageInit()
  422. this.resetSearchForm()
  423. }
  424. // 仅刷新列表,不重置页面
  425. if (this.$store.state.app.updateList) {
  426. this.pageInit()
  427. this.$refs.table.refresh()
  428. }
  429. },
  430. beforeRouteEnter (to, from, next) {
  431. next(vm => {})
  432. }
  433. }
  434. </script>
  435. <style lang="less">
  436. .outboundOrderList-wrap{
  437. .active{
  438. color: #ed1c24;
  439. cursor: pointer;
  440. }
  441. .common{
  442. color: rgba(0, 0, 0, 0.65);
  443. }
  444. }
  445. </style>