list.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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. </template>
  52. <a-col :md="6" :sm="24">
  53. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="outboundOrderList-refresh" style="margin-bottom: 15px;">查询</a-button>
  54. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="outboundOrderList-reset">重置</a-button>
  55. <a @click="advanced=!advanced" style="margin-left: 8px">
  56. {{ advanced ? '收起' : '展开' }}
  57. <a-icon :type="advanced ? 'up' : 'down'"/>
  58. </a>
  59. </a-col>
  60. </a-row>
  61. </a-form>
  62. </div>
  63. <!-- 列表 -->
  64. <div style="margin-bottom: 15px" v-if="$hasPermissions('B_stockOut')">
  65. <a-button type="primary" id="outboundOrder-export" :loading="loading" @click="handleOutbound()">批量出库</a-button>
  66. <span style="margin-left: 8px">
  67. <template v-if="hasSelected">{{ `已选 ${selectedRowKeys.length} 项` }}</template>
  68. </span>
  69. </div>
  70. <s-table
  71. class="sTable"
  72. ref="table"
  73. size="default"
  74. :row-selection="$hasPermissions('B_stockOut')?rowSelection:null"
  75. :rowKey="(record) => record.stockOutSn"
  76. :columns="columns"
  77. :data="loadData"
  78. :scroll="{ x: 1760, y: tableHeight }"
  79. bordered>
  80. <!-- 单号 -->
  81. <template slot="stockOutNo" slot-scope="text, record">
  82. <span v-if="record.stockOutNo" style="color: #ed1c24;cursor: pointer;" @click="handleDetail(record)">{{ record.stockOutNo }}</span>
  83. <span v-else>--</span>
  84. </template>
  85. <!-- 操作 -->
  86. <template slot="action" slot-scope="text, record">
  87. <a-button
  88. size="small"
  89. type="link"
  90. v-if="record.state=='WAIT'&&$hasPermissions('B_stockOut')"
  91. class="button-primary"
  92. @click="handleOutbound(record)"
  93. id="outboundOrderList-out-btn">出库</a-button>
  94. <span v-else>--</span>
  95. </template>
  96. </s-table>
  97. </a-spin>
  98. </a-card>
  99. </template>
  100. <script>
  101. import rangeDate from '@/views/common/rangeDate.vue'
  102. import { STable, VSelect } from '@/components'
  103. import { stockOutList, stockOutOut } from '@/api/stockOut'
  104. export default {
  105. components: { STable, VSelect, rangeDate },
  106. data () {
  107. return {
  108. spinning: false,
  109. advanced: false, // 高级搜索 展开/关闭
  110. tableHeight: 0, // 表格高度
  111. queryParam: { // 查询条件
  112. beginDate: '',
  113. endDate: '',
  114. demanderName: '', // 客户名称
  115. outBizType: undefined, // 出库类型
  116. stockOutNo: '',
  117. outBizNo: '',
  118. state: undefined // 状态
  119. },
  120. disabled: false, // 查询、重置按钮是否可操作
  121. columns: [
  122. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  123. { title: '审核时间', dataIndex: 'auditTime', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  124. { title: '出库单号', scopedSlots: { customRender: 'stockOutNo' }, width: 220, align: 'center' },
  125. { title: '业务单号', dataIndex: 'outBizNo', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  126. { title: '出库类型', dataIndex: 'outBizTypeDictValue', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  127. { title: '客户名称', dataIndex: 'demanderName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  128. { title: '数量', dataIndex: 'productTotalQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  129. { title: '售价', dataIndex: 'productTotalPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  130. { title: '出库时间', dataIndex: 'outTime', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  131. { title: '出库状态', dataIndex: 'stateDictValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  132. { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
  133. ],
  134. selectedRowKeys: [], // Check here to configure the default column
  135. selectedRows: [],
  136. loading: false,
  137. // 加载数据方法 必须为 Promise 对象
  138. loadData: parameter => {
  139. this.disabled = true
  140. if (this.tableHeight == 0) {
  141. this.tableHeight = window.innerHeight - 380
  142. }
  143. return stockOutList(Object.assign(parameter, this.queryParam)).then(res => {
  144. const data = res.data
  145. const no = (data.pageNo - 1) * data.pageSize
  146. for (var i = 0; i < data.list.length; i++) {
  147. data.list[i].no = no + i + 1
  148. }
  149. this.disabled = false
  150. return data
  151. })
  152. }
  153. }
  154. },
  155. computed: {
  156. hasSelected () {
  157. return this.selectedRowKeys.length > 0
  158. },
  159. rowSelection () {
  160. return {
  161. selectedRowKeys: this.selectedRowKeys,
  162. onChange: (selectedRowKeys, selectedRows) => {
  163. this.onChange(selectedRowKeys, selectedRows)
  164. },
  165. onSelect: (record, selected, selectedRows, nativeEvent) => {
  166. this.onSelectChange(record, selected, selectedRows, nativeEvent)
  167. },
  168. onSelectAll: (selected, selectedRows, changeRows) => {
  169. this.onSelectAllChange(selected, selectedRows, changeRows)
  170. },
  171. getCheckboxProps: record => ({
  172. props: {
  173. disabled: record.state == 'FINISH' // Column configuration not to be checked
  174. }
  175. })
  176. }
  177. }
  178. },
  179. methods: {
  180. // 时间 change
  181. dateChange (date) {
  182. this.queryParam.beginDate = date[0]
  183. this.queryParam.endDate = date[1]
  184. },
  185. // 重置
  186. resetSearchForm () {
  187. this.$refs.rangeDate.resetDate()
  188. this.queryParam.beginDate = ''
  189. this.queryParam.endDate = ''
  190. this.queryParam.demanderName = ''
  191. this.queryParam.outBizType = undefined
  192. this.queryParam.state = undefined
  193. this.queryParam.stockOutNo = ''
  194. this.queryParam.outBizNo = ''
  195. this.$refs.table.refresh(true)
  196. },
  197. // 详情
  198. handleDetail (row) {
  199. // 根据出库类型跳转对应页面
  200. if (row.outBizType == 'SALES' && this.$hasPermissions('B_dispatchDetail')) { // 销售出库
  201. this.$router.push({ path: `/salesManagement/pushOrderManagement/detail/${row.outBizSubSn}/stockOut` })
  202. } else if (row.outBizType == 'ALLOCATE' && this.$hasPermissions('M_transferOut_detail')) { // 调拨出库
  203. this.$router.push({ path: `/allocationManagement/transferOut/detail/${row.outBizSn}` })
  204. } else if (row.outBizType == 'CHECK_ORDER_OUT') { // 库存盘点盘亏
  205. }
  206. },
  207. // 出库/批量出库
  208. handleOutbound (row) {
  209. const _this = this
  210. let content = ''
  211. let params = []
  212. if (row) { // 单个出库
  213. content = '确认要出库吗?'
  214. params = [{
  215. stockOutSn: row.stockOutSn,
  216. outBizSn: row.outBizSn,
  217. outBizSubSn: row.outBizSubSn,
  218. outBizType: row.outBizType
  219. }]
  220. } else { // 批量出库
  221. content = '确认要批量出库吗?'
  222. if (this.selectedRowKeys.length < 1) {
  223. this.$message.warning('请在列表勾选后再进行批量操作!')
  224. return
  225. }
  226. params = []
  227. this.selectedRows.map(item => {
  228. params.push({
  229. stockOutSn: item.stockOutSn,
  230. outBizSn: item.outBizSn,
  231. outBizSubSn: item.outBizSubSn,
  232. outBizType: item.outBizType
  233. })
  234. })
  235. }
  236. this.$confirm({
  237. title: '提示',
  238. content: content,
  239. centered: true,
  240. onOk () {
  241. if (!row) { // 批量出库
  242. _this.loading = true
  243. }
  244. _this.spinning = true
  245. stockOutOut(params).then(res => {
  246. _this.loading = false
  247. if (res.status == 200) {
  248. if (!row) { // 批量出库
  249. _this.selectedRowKeys = []
  250. _this.selectedRows = []
  251. }
  252. _this.$message.success(res.message)
  253. _this.$refs.table.refresh()
  254. _this.spinning = false
  255. } else {
  256. _this.spinning = false
  257. }
  258. })
  259. }
  260. })
  261. },
  262. onChange (selectedRowKeys, selectedRows) {
  263. this.selectedRowKeys = selectedRowKeys
  264. },
  265. onSelectChange (record, selected, selectedRows, nativeEvent) {
  266. const _this = this
  267. if (selected) { // 选择
  268. this.selectedRows.push(record)
  269. } else { // 取消
  270. this.selectedRows.map((item, index) => {
  271. if (item.stockOutSn == record.stockOutSn) {
  272. _this.selectedRows.splice(index, 1)
  273. }
  274. })
  275. }
  276. },
  277. // 本页全选/取消全选
  278. onSelectAllChange (selected, selectedRows, changeRows) {
  279. const _this = this
  280. if (selected) { // 选择
  281. this.selectedRows = [...this.selectedRows, ...changeRows]
  282. } else { // 取消
  283. this.selectedRows.map((item, index) => {
  284. this.selectedRows.map((subItem, ind) => {
  285. if (item.stockOutSn == subItem.stockOutSn) {
  286. _this.selectedRows.splice(index, 1)
  287. }
  288. })
  289. })
  290. }
  291. }
  292. }
  293. }
  294. </script>