list.vue 12 KB

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