list.vue 16 KB

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