list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <template>
  2. <a-card size="small" :bordered="false" class="accountManagementList-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="36">
  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 allowClear placeholder="请输入调回单号" v-model.tirm="queryParam.recallBillNo"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="货架名称">
  20. <shelfList v-model="queryParam.shelfSn"></shelfList>
  21. </a-form-item>
  22. </a-col>
  23. <template v-if="advanced">
  24. <a-col :md="6" :sm="24">
  25. <a-form-item label="产品编码">
  26. <a-input allowClear placeholder="请输入产品编码" v-model.tirm="queryParam.productCode"/>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="6" :sm="24">
  30. <a-form-item label="产品名称">
  31. <a-input allowClear placeholder="请输入产品名称" v-model.tirm="queryParam.productName"/>
  32. </a-form-item>
  33. </a-col>
  34. </template>
  35. <a-col :md="6" :sm="24">
  36. <a-button type="primary" @click="getSumByType" :disabled="disabled" id="outboundOrderList-refresh" >查询</a-button>
  37. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="outboundOrderList-reset">重置</a-button>
  38. <a @click="advanced=!advanced" style="margin-left: 5px" v-if="activeKey==0">
  39. {{ advanced ? '收起' : '展开' }}
  40. <a-icon :type="advanced ? 'up' : 'down'"/>
  41. </a>
  42. </a-col>
  43. </a-row>
  44. </a-form>
  45. </div>
  46. <a-tabs type="card" v-model="queryParam.bizType" @change="tabChange" class="replenishmentManagementList-tabs">
  47. <a-tab-pane v-for="item in tabsList" :key="item.code">
  48. <p slot="tab">{{ item.name }}<span v-if="item.countNum&&item.code=='WAIT_CONFIRM'" style="color:red">({{ item.countNum }})</span></p>
  49. </a-tab-pane>
  50. </a-tabs>
  51. <s-table
  52. class="sTable fixPagination"
  53. ref="table"
  54. :style="{ height: tableHeight+77+'px' }"
  55. size="small"
  56. :rowKey="(record) => record.id"
  57. :columns="columns"
  58. :data="loadData"
  59. :scroll="{ y:tableHeight }"
  60. :expandedRowKeys="expandedRowKeys"
  61. @expand="expandFun"
  62. :expandRowByClick="true"
  63. :defaultLoadData="false"
  64. bordered>
  65. <template slot="action" slot-scope="text, record">
  66. <a-button
  67. size="small"
  68. type="link"
  69. v-if="record.billState=='WAIT_CONFIRM'"
  70. class="button-primary"
  71. @click.stop="handleRecall(record)"
  72. id="shelfMonitoringList-warehousing-btn">退库</a-button>
  73. <a-button
  74. size="small"
  75. v-if="record.billState=='WAIT_CONFIRM'"
  76. type="link"
  77. class="button-primary"
  78. @click.stop="handleCancel(record)"
  79. id="shelfMonitoringList-warehousing-btn">取消调回单</a-button>
  80. <span v-if="record.billState!='WAIT_CONFIRM'" style="display: inline-block;margin-left: 7px;">--</span>
  81. </template>
  82. <a-table
  83. v-if="innerData&&innerData[index]"
  84. size="small"
  85. class="inner-table"
  86. slot-scope="record,index"
  87. slot="expandedRowRender"
  88. :rowKey="(record) => record.id"
  89. :columns="innerColumns"
  90. :data-source="innerData[index].innerData"
  91. :pagination="false"
  92. >
  93. </a-table>
  94. </s-table>
  95. </a-spin>
  96. <!-- 退库 -->
  97. <recallModal :isOpenModal="showModal" :currentData="currentData" @close="showModal=false" @refresh="$refs.table.refresh(true)"></recallModal>
  98. </a-card>
  99. </template>
  100. <script>
  101. import { commonMixin } from '@/utils/mixin'
  102. import moment from 'moment'
  103. import rangeDate from '@/views/common/rangeDate.vue'
  104. import { STable } from '@/components'
  105. import recallModal from './recallModal.vue'
  106. import getDate from '@/libs/getDate.js'
  107. import { toThousands } from '@/libs/tools.js'
  108. import shelfList from '@/views/common/shelfList'
  109. import { shelfRecallList, shelfRecallDetailList, shelfRecallCancel, shelfRecallStateCount } from '@/api/shelfRecall.js'
  110. export default {
  111. components: { STable, recallModal, rangeDate, shelfList },
  112. mixins: [commonMixin],
  113. data () {
  114. return {
  115. spinning: false,
  116. disabled: false,
  117. tableHeight: 0,
  118. showModal: false,
  119. advanced: false,
  120. currentData: null,
  121. activeKey: 0, // 默认的tab
  122. tabsList: [],
  123. currentType: 'ALL',
  124. expandedRowKeys: [],
  125. time: [
  126. getDate.getCurrMonthDays().starttime,
  127. getDate.getCurrMonthDays().endtime
  128. ],
  129. queryParam: {
  130. beginDate: getDate.getCurrMonthDays().starttime, // 开始时间
  131. endDate: getDate.getCurrMonthDays().endtime, // 结束时间
  132. recallBillNo: '',
  133. shelfSn: undefined, // 数字货架sn
  134. bizType: 'ALL'
  135. },
  136. columns: [
  137. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  138. { title: '创建时间', dataIndex: 'createDate', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  139. { title: '调回单号', dataIndex: 'recallBillNo', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  140. { title: '货架名称', dataIndex: 'shelfInfo.shelfName', width: '25%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  141. { title: '状态', dataIndex: 'billStateDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  142. { title: '调回总量', dataIndex: 'totalQty', width: '9%', align: 'center', customRender: function (text) { return (text || text == 0) ? toThousands(text) : '--' } },
  143. { title: '实退总量', dataIndex: 'totalConfirmQty', width: '9%', align: 'center', customRender: function (text) { return (text || text == 0) ? toThousands(text) : '--' } },
  144. { title: '操作', width: '10%', align: 'left', scopedSlots: { customRender: 'action' } }
  145. ],
  146. innerColumns: [
  147. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  148. { title: '产品编码', dataIndex: 'product.code', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  149. { title: '产品名称', dataIndex: 'product.name', width: '30%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  150. { title: '调回数量', dataIndex: 'qty', width: '15%', align: 'center', customRender: function (text) { return (text || text == 0) ? toThousands(text) : '--' } },
  151. { title: '实退数量', dataIndex: 'confirmQty', width: '15%', align: 'center', customRender: function (text) { return (text || text == 0) ? toThousands(text) : '--' } },
  152. { title: '单位', dataIndex: 'product.unit', width: '15%', align: 'center', customRender: function (text) { return text || '--' } }
  153. ],
  154. innerData: [],
  155. // 加载数据方法 必须为 Promise 对象
  156. loadData: parameter => {
  157. this.disabled = true
  158. this.spinning = true
  159. this.expandedRowKeys = []
  160. parameter.billState = this.queryParam.bizType == 'ALL' ? '' : this.queryParam.bizType
  161. const params = Object.assign(parameter, this.queryParam)
  162. delete params.index
  163. delete params.tableId
  164. delete params.bizType
  165. return shelfRecallList(Object.assign(parameter, params)).then(res => {
  166. let data
  167. if (res.status == 200) {
  168. data = res.data
  169. const no = (data.pageNo - 1) * data.pageSize
  170. for (var i = 0; i < data.list.length; i++) {
  171. data.list[i].no = no + i + 1
  172. data.list[i].innerData = []
  173. }
  174. this.innerData = data.list || []
  175. this.disabled = false
  176. }
  177. this.spinning = false
  178. return data
  179. })
  180. }
  181. }
  182. },
  183. methods: {
  184. // 时间改变
  185. dateChange (date) {
  186. this.queryParam.beginDate = date[0]
  187. this.queryParam.endDate = date[1]
  188. },
  189. // 禁止选择今天之后的日期
  190. disabledDate (current) {
  191. return current && current > moment().endOf('day')
  192. },
  193. // 切换tab
  194. tabChange (key) {
  195. console.log(key)
  196. this.expandedRowKeys = []
  197. setTimeout(() => {
  198. this.queryParam.bizType = key
  199. this.$refs.table.refresh(true)
  200. this.currentType = key
  201. }, 100)
  202. },
  203. // 获取各类型下的数量
  204. getSumByType () {
  205. const params = JSON.parse(JSON.stringify(this.queryParam))
  206. params.billState = ''
  207. delete params.bizType
  208. shelfRecallStateCount(params).then(res => {
  209. if (res.status == 200) {
  210. this.tabsList = [
  211. { code: 'ALL', name: '全部', countNum: 0 }, { code: 'WAIT_CONFIRM', name: '待退库', countNum: 0 }, { code: 'FINISH', name: '已完成', countNum: 0 }, { code: 'CANCEL', name: '已取消', countNum: 0 }
  212. ]
  213. // this.queryParam.bizType = 'ALL'
  214. this.tabsList[1].countNum = res.data.WAIT_CONFIRM || 0
  215. this.tabsList[2].countNum = res.data.FINISH || 0
  216. this.tabsList[3].countNum = res.data.CANCEL || 0
  217. this.$refs.table.refresh(true)
  218. }
  219. })
  220. },
  221. // 点击行或图标触发接口
  222. expandFun (expanded, record) {
  223. if (expanded) {
  224. this.expandedRowKeys.push(record.id)
  225. this.getinnerData(record) // 获取表格内部数据
  226. } else {
  227. const i = this.expandedRowKeys.findIndex(item => item == record.id)
  228. this.expandedRowKeys.splice(i, 1)
  229. }
  230. },
  231. // 获取子表格数据
  232. getinnerData (record) {
  233. this.spinning = true
  234. shelfRecallDetailList({ recallBillSn: record.recallBillSn }).then(res => {
  235. const ind = this.innerData.findIndex(item => item.id == record.id)
  236. if (ind >= 0) {
  237. if (res.status == 200 && res.data && res.data.length) {
  238. res.data.map((item, index) => {
  239. item.no = index + 1
  240. })
  241. this.innerData[ind].innerData = res.data
  242. } else {
  243. this.innerData[ind].innerData = []
  244. }
  245. }
  246. this.spinning = false
  247. })
  248. },
  249. // 重置
  250. resetSearchForm () {
  251. // this.$refs.rangeDate.resetDate(this.time)
  252. // this.queryParam.billState = this.currentType
  253. // this.queryParam = {
  254. this.resetData()
  255. this.getSumByType()
  256. },
  257. resetData () {
  258. this.$refs.rangeDate.resetDate(this.time)
  259. this.queryParam.bizType = 'ALL'
  260. this.queryParam = {
  261. beginDate: getDate.getCurrMonthDays().starttime, // 开始时间
  262. endDate: getDate.getCurrMonthDays().endtime, // 结束时间
  263. recallBillNo: '', // 调回单号
  264. shelfSn: undefined // 数字货架sn
  265. }
  266. },
  267. // 退库
  268. handleRecall (row) {
  269. this.showModal = true
  270. this.currentData = row
  271. },
  272. // 取消掉回单
  273. handleCancel (row) {
  274. const _this = this
  275. this.$confirm({
  276. title: '提示',
  277. content: '确定取消调回单吗?',
  278. centered: true,
  279. onOk: () => {
  280. _this.spinning = true
  281. shelfRecallCancel({ recallBillSn: row.recallBillSn }).then(res => {
  282. if (res.status == 200) {
  283. _this.$message.success(res.message)
  284. _this.spinning = false
  285. _this.$refs.table.refresh()
  286. } else {
  287. _this.spinning = false
  288. }
  289. })
  290. }
  291. })
  292. },
  293. setTableH () {
  294. const tableSearchH = this.$refs.tableSearch.offsetHeight
  295. this.tableHeight = window.innerHeight - tableSearchH - 265
  296. },
  297. pageInit () {
  298. const _this = this
  299. this.$nextTick(() => { // 页面渲染完成后的回调
  300. _this.setTableH()
  301. })
  302. this.getSumByType()
  303. }
  304. },
  305. mounted () {
  306. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  307. this.pageInit()
  308. this.resetData()
  309. }
  310. },
  311. watch: {
  312. advanced (newValue, oldValue) {
  313. const _this = this
  314. setTimeout(() => {
  315. _this.setTableH()
  316. }, 400)
  317. },
  318. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  319. this.setTableH()
  320. }
  321. },
  322. activated () {
  323. // 如果是新页签打开,则重置当前页面
  324. if (this.$store.state.app.isNewTab) {
  325. this.pageInit()
  326. this.resetData()
  327. }
  328. // 仅刷新列表,不重置页面
  329. if (this.$store.state.app.updateList) {
  330. this.pageInit()
  331. this.$refs.table.refresh()
  332. }
  333. },
  334. beforeRouteEnter (to, from, next) {
  335. next(vm => {})
  336. }
  337. }
  338. </script>
  339. <style lang="less">
  340. .accountManagementList-wrap{
  341. .inner-table{
  342. background-color: #fff;
  343. border-bottom: 1px solid #eee;
  344. .ant-table{
  345. margin: 10px 100px;
  346. border-bottom: 1px solid #eee;
  347. }
  348. }
  349. }
  350. </style>