list.vue 19 KB

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