list.vue 19 KB

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