list.vue 16 KB

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