list.vue 16 KB

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