list.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. <template>
  2. <a-card size="small" :bordered="false" class="replenishmentManagementList-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="15">
  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="补货单号"><a-input id="replenishmentManagementList-replenishBillNo" v-model.trim="queryParam.replenishBillNo" allowClear placeholder="请输入补货单号" /></a-form-item>
  15. </a-col>
  16. <a-col :md="6" :sm="24">
  17. <a-form-item label="货架名称">
  18. <shelfSList ref="shelfList" @change="shelfChange" :itemSn="queryParam.shelfSn"></shelfSList>
  19. </a-form-item>
  20. </a-col>
  21. <template v-if="advanced">
  22. <a-col :md="6" :sm="24">
  23. <a-form-item label="产品编码"><a-input id="replenishmentManagementList-productCode" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码" /></a-form-item>
  24. </a-col>
  25. <a-col :md="6" :sm="24">
  26. <a-form-item label="产品名称">
  27. <a-input id="replenishmentManagementList-productName" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称" />
  28. </a-form-item>
  29. </a-col>
  30. </template>
  31. <a-col :md="6" :sm="24">
  32. <span class="table-page-search-submitButtons">
  33. <a-button type="info" style="margin-left: 5px" @click="taskIn" :disabled="disabled" >定时任务</a-button>
  34. <a-button type="primary" style="margin-left: 5px" @click="$refs.table.refresh(true)" :disabled="disabled" id="replenishmentManagementList-refresh">查询</a-button>
  35. <a-button style="margin-left: 5px" @click="resetSearchForm()" :disabled="disabled" id="replenishmentManagementList-reset">重置</a-button>
  36. <a @click="advanced = !advanced" style="margin-left: 5px">
  37. {{ advanced ? '收起' : '展开' }}
  38. <a-icon :type="advanced ? 'up' : 'down'" />
  39. </a>
  40. </span>
  41. </a-col>
  42. </a-row>
  43. </a-form>
  44. </div>
  45. <!-- 标签页 -->
  46. <a-tabs type="card" v-model="queryParam.bizType" @change="handleTabChange" class="replenishmentManagementList-tabs ">
  47. <a-tab-pane v-for="item in tabPaneData" :key="item.bizType">
  48. <p slot="tab">{{ item.bizName }}<span v-if="(item.countNum || item.countNum==0)&&item.bizName!='全部'">({{ 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+84.5+'px' }"
  55. size="small"
  56. :rowKey="(record) => record.id"
  57. :columns="columns"
  58. :data="loadData"
  59. :expandedRowKeys="expandedRowKeys"
  60. @expand="expandFun"
  61. :expandRowByClick="true"
  62. :scroll="{ y: tableHeight }"
  63. :showPagination="false"
  64. :defaultLoadData="false"
  65. bordered>
  66. <a-table
  67. v-if="listData&&listData[index]"
  68. slot="expandedRowRender"
  69. slot-scope="record, index"
  70. size="small"
  71. :rowKey="(record) => record.id"
  72. :columns="subColumns"
  73. :data-source="listData[index].subList"
  74. :pagination="false"
  75. :bordered="false"
  76. style="margin: 15px 10px;">
  77. </a-table>
  78. <!-- 操作 -->
  79. <template slot="action" slot-scope="text, record">
  80. <a-button v-if="record.billState=='WAIT_CONFIRM'" size="small" type="link" class="button-primary" @click.stop="handleConfirm(record)">确认</a-button>
  81. <a-button v-if="record.billState=='WAIT_OUT_STOCK'" size="small" type="link" class="button-primary" @click.stop="handlePrintSticker(record)">打印贴签</a-button>
  82. <a-button v-if="record.billState=='WAIT_OUT_STOCK'" size="small" type="link" class="button-primary" @click.stop="handleOutWarehousing(record)">出库</a-button>
  83. <a-button v-if="record.billState=='WAIT_CHECK'" size="small" type="link" class="button-primary" @click.stop="handlePutWarehousing(record)">签收</a-button>
  84. <a-button v-if="record.billState=='WAIT_CONFIRM' || record.billState=='WAIT_OUT_STOCK'" size="small" type="link" class="button-primary" @click.stop="handleCancelOrder(record)">取消补货单</a-button>
  85. </template>
  86. </s-table>
  87. <!-- 确认 -->
  88. <confirm-modal :openModal="openConfirmModal" :nowData="nowData" @ok="handleValidate" @close="handleCancel" />
  89. <!-- 库存不足,确认弹框 -->
  90. <stock-modal
  91. :openModal="openStockModal"
  92. :type="validateType"
  93. :params="paramsData"
  94. :listData="stockList"
  95. @ok="handleStockOk"
  96. @close="handleStockCancel" />
  97. <!-- 打印贴签 -->
  98. <print-sticker-modal :openModal="openPrintStickerModal" :nowData="nowData" @ok="handlePrintStickerOk" @close="handleCancel" />
  99. <!-- 出库 -->
  100. <out-warehousing-modal :openModal="openOutWarehousingModal" :nowData="nowData" @ok="handleOutWarehousingOk" @close="handleCancel" />
  101. <!-- 签收 -->
  102. <put-warehousing-modal :openModal="openPutWarehousingModal" :nowData="nowData" @ok="handlePutWarehousingOk" @close="handleCancel" />
  103. </a-spin>
  104. </a-card>
  105. </template>
  106. <script>
  107. import { commonMixin } from '@/utils/mixin'
  108. import { STable, VSelect } from '@/components'
  109. import getDate from '@/libs/getDate.js'
  110. import rangeDate from '@/views/common/rangeDate.vue'
  111. import shelfSList from '@/views/common/shelfList.vue'
  112. import confirmModal from './confirmModal.vue'
  113. import stockModal from './stockModal.vue'
  114. import printStickerModal from './printStickerModal.vue'
  115. import outWarehousingModal from './outWarehousingModal.vue'
  116. import putWarehousingModal from './putWarehousingModal.vue'
  117. import { shelfReplenishList, shelfReplenishDetailList, shelfReplenishCancel, shelfReplenishStateCount, shelfReplenishDetailStock, shelfReplenishConfirm, shelfReplenishTaskInsertBill } from '@/api/shelfReplenish'
  118. export default {
  119. components: { STable, VSelect, rangeDate, shelfSList, confirmModal, stockModal, printStickerModal, outWarehousingModal, putWarehousingModal },
  120. mixins: [commonMixin],
  121. data () {
  122. return {
  123. spinning: false,
  124. advanced: true, // 高级搜索 展开/关闭
  125. tableHeight: 0,
  126. disabled: false, // 查询、重置按钮是否可操作
  127. curBizType: 'ALL',
  128. time: [
  129. getDate.getCurrMonthDays().starttime,
  130. getDate.getCurrMonthDays().endtime
  131. ],
  132. // 查询参数
  133. queryParam: {
  134. beginDate: getDate.getCurrMonthDays().starttime,
  135. endDate: getDate.getCurrMonthDays().endtime,
  136. bizType: 'ALL',
  137. replenishBillNo: '',
  138. shelfSn: undefined,
  139. productCode: '',
  140. productName: ''
  141. },
  142. expandedRowKeys: [],
  143. columns: [
  144. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  145. { title: '创建时间', dataIndex: 'createDate', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  146. { title: '补货单号', dataIndex: 'replenishBillNo', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  147. { title: '货架名称', dataIndex: 'shelfInfo.shelfName', width: '25%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  148. { title: '状态', dataIndex: 'billStateDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  149. { title: '补货应发总量', dataIndex: 'totalQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  150. { title: '实发总量', dataIndex: 'totalConfirmQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  151. { title: '签收总量', dataIndex: 'totalPutQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  152. { title: '操作', scopedSlots: { customRender: 'action' }, width: '12%', align: 'left' }
  153. ],
  154. // 加载数据方法 必须为 Promise 对象
  155. loadData: parameter => {
  156. this.disabled = true
  157. this.spinning = true
  158. this.expandedRowKeys = []
  159. parameter.billState = this.queryParam.bizType == 'ALL' ? '' : this.queryParam.bizType
  160. const params = Object.assign(parameter, this.queryParam)
  161. delete params.index
  162. delete params.tableId
  163. delete params.bizType
  164. return shelfReplenishList(params).then(res => {
  165. let data
  166. if (res.status == 200) {
  167. data = res.data
  168. const no = (data.pageNo - 1) * data.pageSize
  169. for (var i = 0; i < data.list.length; i++) {
  170. data.list[i].no = no + i + 1
  171. data.list[i].subList = []
  172. }
  173. this.listData = data.list || []
  174. this.disabled = false
  175. }
  176. this.spinning = false
  177. return data
  178. })
  179. },
  180. subColumns: [
  181. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  182. { title: '产品编码', dataIndex: 'product.code', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  183. { title: '产品名称', dataIndex: 'product.name', width: '32%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  184. { title: '补货应发总量', dataIndex: 'qty', width: '12%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  185. { title: '实发总量', dataIndex: 'confirmQty', width: '12%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  186. { title: '签收总量', dataIndex: 'putQty', width: '12%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  187. { title: '单位', dataIndex: 'product.unit', width: '8%', align: 'center', customRender: function (text) { return text || '--' } }
  188. ],
  189. listData: [],
  190. tabPaneData: [],
  191. nowData: null,
  192. openConfirmModal: false,
  193. openStockModal: false,
  194. openPrintStickerModal: false,
  195. openOutWarehousingModal: false,
  196. openPutWarehousingModal: false,
  197. validateType: 'confirm',
  198. stockList: [],
  199. paramsData: null
  200. }
  201. },
  202. methods: {
  203. // 定时任务
  204. taskIn () {
  205. shelfReplenishTaskInsertBill().then(res => {
  206. this.$message.success(res.message)
  207. this.resetSearchForm()
  208. })
  209. },
  210. // 确认
  211. handleConfirm (row) {
  212. this.nowData = row
  213. this.openConfirmModal = true
  214. },
  215. // cancel
  216. handleCancel () {
  217. this.nowData = null
  218. this.openConfirmModal = false
  219. this.openStockModal = false
  220. this.openPrintStickerModal = false
  221. this.openOutWarehousingModal = false
  222. this.openPutWarehousingModal = false
  223. },
  224. // 库存不足 确认 ok
  225. handleStockOk (type, params) {
  226. this.openStockModal = false
  227. this.openConfirmModal = false
  228. this.openOutWarehousingModal = false
  229. if (type == 'confirm') { // 确认
  230. this.confirmFun(params)
  231. }
  232. },
  233. // 库存不足 确认 cancel
  234. handleStockCancel () {
  235. this.stockList = []
  236. this.validateType = 'confirm'
  237. this.openStockModal = false
  238. },
  239. // 打印贴签
  240. handlePrintSticker (row) {
  241. this.nowData = row
  242. this.openPrintStickerModal = true
  243. },
  244. // 打印贴签 ok
  245. handlePrintStickerOk () {
  246. },
  247. // 出库
  248. handleOutWarehousing (row) {
  249. this.nowData = row
  250. this.openOutWarehousingModal = true
  251. },
  252. // 出库 ok
  253. handleOutWarehousingOk () {
  254. this.nowData = null
  255. this.openOutWarehousingModal = false
  256. this.queryByTypeSum()
  257. },
  258. handleValidate (type, params) {
  259. // 校验产品库存是否足够
  260. shelfReplenishDetailStock(params).then(res => {
  261. if (res.status == 200) {
  262. if (res.data && res.data.length > 0) {
  263. this.stockList = res.data
  264. this.validateType = 'confirm'
  265. this.paramsData = params
  266. this.openStockModal = true
  267. } else {
  268. if (type == 'confirm') { // 确认
  269. this.confirmFun(params)
  270. }
  271. }
  272. }
  273. })
  274. },
  275. // 提交确认
  276. confirmFun (params) {
  277. shelfReplenishConfirm(params).then(res => {
  278. if (res.status == 200) {
  279. this.$message.success('确认补货成功')
  280. this.$refs.table.refresh(true)
  281. this.handleCancel()
  282. }
  283. })
  284. },
  285. // 签收
  286. handlePutWarehousing (row) {
  287. this.nowData = row
  288. this.openPutWarehousingModal = true
  289. },
  290. // 签收 ok
  291. handlePutWarehousingOk () {
  292. this.nowData = null
  293. this.openPutWarehousingModal = false
  294. this.queryByTypeSum()
  295. },
  296. // 取消补货单
  297. handleCancelOrder (row) {
  298. const _this = this
  299. this.$confirm({
  300. title: '提示',
  301. content: '确认取消补货单吗?',
  302. centered: true,
  303. onOk () {
  304. _this.spinning = true
  305. shelfReplenishCancel({ replenishBillSn: row.replenishBillSn }).then(res => {
  306. if (res.status == 200) {
  307. _this.$message.success(res.message)
  308. _this.$refs.table.refresh()
  309. _this.spinning = false
  310. } else {
  311. _this.spinning = false
  312. }
  313. })
  314. }
  315. })
  316. },
  317. // 货架 change
  318. shelfChange (obj) {
  319. this.queryParam.shelfSn = obj.key || undefined
  320. },
  321. expandFun (expanded, record) {
  322. if (expanded) {
  323. this.expandedRowKeys.push(record.id)
  324. this.getSubItem(record) // 获取表格内部数据
  325. } else {
  326. const i = this.expandedRowKeys.findIndex(item => item == record.id)
  327. this.expandedRowKeys.splice(i, 1)
  328. }
  329. },
  330. // 获取子节点数据
  331. getSubItem (record) {
  332. this.spinning = true
  333. shelfReplenishDetailList({ replenishBillSn: record.replenishBillSn }).then(res => {
  334. const ind = this.listData.findIndex(item => item.id == record.id)
  335. if (ind >= 0) {
  336. if (res.status == 200 && res.data && res.data.length) {
  337. res.data.map((item, index) => {
  338. item.no = index + 1
  339. })
  340. this.listData[ind].subList = res.data
  341. } else {
  342. this.listData[ind].subList = []
  343. }
  344. }
  345. this.spinning = false
  346. })
  347. },
  348. // 重置
  349. resetSearchForm () {
  350. this.resetData()
  351. this.$refs.table.refresh(true)
  352. },
  353. // 重置数据
  354. resetData () {
  355. this.$refs.rangeDate.resetDate(this.time)
  356. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  357. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  358. this.queryParam.bizType = this.curBizType
  359. this.queryParam.replenishBillNo = ''
  360. this.queryParam.shelfSn = undefined
  361. this.$refs.shelfList.resetForm()
  362. this.queryParam.productCode = ''
  363. this.queryParam.productName = ''
  364. },
  365. // 时间 change
  366. dateChange (date) {
  367. this.queryParam.beginDate = date[0] || null
  368. this.queryParam.endDate = date[1] || null
  369. },
  370. // 选择类型
  371. handleTabChange (key) {
  372. this.expandedRowKeys = []
  373. setTimeout(() => {
  374. this.queryParam.bizType = key
  375. this.$refs.table.refresh(true)
  376. this.curBizType = key
  377. }, 100)
  378. },
  379. // 客户 change
  380. custChange (obj) {
  381. this.queryParam.customerSn = obj.key || undefined
  382. },
  383. // 获取类型
  384. queryByTypeSum () {
  385. const params = JSON.parse(JSON.stringify(this.queryParam))
  386. delete params.bizType
  387. shelfReplenishStateCount(params).then(res => {
  388. if (res.data && res.status == 200) {
  389. this.tabPaneData = [
  390. { bizName: '全部', bizType: 'ALL', countNum: 0 },
  391. { bizName: '待确认', bizType: 'WAIT_CONFIRM', countNum: 0 },
  392. { bizName: '待出库', bizType: 'WAIT_OUT_STOCK', countNum: 0 },
  393. { bizName: '待签收', bizType: 'WAIT_CHECK', countNum: 0 },
  394. { bizName: '已完成', bizType: 'FINISH', countNum: 0 },
  395. { bizName: '已取消', bizType: 'CANCEL', countNum: 0 }
  396. ]
  397. this.queryParam.bizType = 'ALL'
  398. this.tabPaneData[1].countNum = res.data.WAIT_CONFIRM || 0
  399. this.tabPaneData[2].countNum = res.data.WAIT_OUT_STOCK || 0
  400. this.tabPaneData[3].countNum = res.data.WAIT_CHECK || 0
  401. this.tabPaneData[4].countNum = res.data.FINISH || 0
  402. this.tabPaneData[5].countNum = res.data.CANCEL || 0
  403. this.$refs.table.refresh()
  404. }
  405. })
  406. },
  407. setTableH () {
  408. const tableSearchH = this.$refs.tableSearch.offsetHeight
  409. this.tableHeight = window.innerHeight - tableSearchH - 240
  410. },
  411. pageInit () {
  412. const _this = this
  413. this.$nextTick(() => { // 页面渲染完成后的回调
  414. _this.setTableH()
  415. })
  416. this.queryByTypeSum()
  417. }
  418. },
  419. watch: {
  420. advanced (newValue, oldValue) {
  421. const _this = this
  422. this.$nextTick(() => { // 页面渲染完成后的回调
  423. _this.setTableH()
  424. })
  425. },
  426. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  427. this.setTableH()
  428. }
  429. },
  430. mounted () {
  431. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  432. this.resetData()
  433. this.pageInit()
  434. }
  435. },
  436. activated () {
  437. // 如果是新页签打开,则重置当前页面
  438. if (this.$store.state.app.isNewTab) {
  439. this.resetData()
  440. this.pageInit()
  441. }
  442. }
  443. }
  444. </script>
  445. <style lang="less">
  446. .replenishmentManagementList-wrap{
  447. .replenishmentManagementList-tabs.ant-tabs.ant-tabs-card .ant-tabs-bar{
  448. margin: 0 0 10px 0!important;
  449. }
  450. .replenishmentManagementList-tabs.ant-tabs.ant-tabs-card .ant-tabs-card-bar .ant-tabs-nav-container{
  451. height: 30px!important;
  452. }
  453. .replenishmentManagementList-tabs.ant-tabs.ant-tabs-card .ant-tabs-card-bar .ant-tabs-tab-active{
  454. height: 30px!important;
  455. }
  456. .replenishmentManagementList-tabs.ant-tabs.ant-tabs-card .ant-tabs-card-bar .ant-tabs-tab{
  457. line-height: 26px!important;
  458. height: 30px!important;
  459. }
  460. }
  461. </style>