editStock.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <div class="goodsAllocationSet-page">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="goodsAllocationSet-baseInfo" >
  5. <template slot="subTitle">
  6. <a href="javascript:;" @click="handleBack(0)"><a-icon type="left"></a-icon> 返回列表</a>
  7. <span style="margin: 0 15px;">{{ pageInfo &&pageInfo.providerName?pageInfo.providerName:'--' }}</span>
  8. <span>(调回单号:{{ pageInfo &&pageInfo.putBizNo?pageInfo.putBizNo:'--' }})</span>
  9. </template>
  10. </a-page-header>
  11. <a-card :bordered="false" size="small" class="goodsAllocationSet-baseInfo">
  12. <a-alert type="info" style="margin:10px 0">
  13. <div slot="message" >
  14. 入库总数量<strong>{{ pageInfo &&pageInfo.productTotalQty?pageInfo.productTotalQty:'--' }}</strong>,
  15. 入库总成本¥<strong>{{ pageInfo &&pageInfo.productTotalCost?pageInfo.productTotalCost:0 }}</strong>
  16. </div>
  17. </a-alert>
  18. <s-table
  19. class="sTable fixPagination"
  20. ref="table"
  21. size="small"
  22. rowKey="id"
  23. :showPagination="false"
  24. :columns="columns"
  25. :data="loadData"
  26. :defaultLoadData="true"
  27. bordered>
  28. <template slot="action" slot-scope="text, record">
  29. <a-cascader
  30. size="small"
  31. @change="e => changeWarehouseCascade(e, record)"
  32. v-model="record.warehouseCascade"
  33. expand-trigger="hover"
  34. :allowClear="false"
  35. :options="warehouseCascadeData"
  36. :fieldNames="{ label: 'name', value: 'sn', children: 'warehouseLocationList' }"
  37. id="bulkWarehousingOrderEdit-choose-warehouseCascade"
  38. placeholder="请选择仓库仓位"
  39. style="width: 100%;" />
  40. </template>
  41. <template slot="putCost" slot-scope="text, record">
  42. <a-input-number
  43. v-model="record.putCost"
  44. :precision="2"
  45. :min="0"
  46. placeholder="请输入入库单价"
  47. @blur="handleEdit(record.putCost,record)"></a-input-number>
  48. </template>
  49. </s-table>
  50. <div style="text-align: center;margin-top: 20px;">
  51. <a-button size="small" class="button-primary" type="primary" @click="handleBack(1)">确认入库</a-button>
  52. </div>
  53. </a-card>
  54. </a-spin>
  55. </div>
  56. </template>
  57. <script>
  58. import { commonMixin } from '@/utils/mixin'
  59. import { STable } from '@/components'
  60. import { warehouseCascadeList } from '@/api/warehouse'
  61. import { recallrStockDetail, recallrStockDetailList, updateSelective, confirmPutStock } from '@/api/shelfRecall.js'
  62. export default {
  63. mixins: [commonMixin],
  64. components: { STable },
  65. data () {
  66. return {
  67. spinning: false,
  68. disabled: false,
  69. isEdit: false, // 货位号是否为编辑
  70. openModal: false, // 货位模板弹窗初始状态
  71. stockPutTotal: 0, // 入库总数量
  72. stockPutAmount: 0, // 入库总成本
  73. formItemLayout: {
  74. labelCol: { span: 6 },
  75. wrapperCol: { span: 16 }
  76. },
  77. defaultWarehouseCascade: [],
  78. pageInfo: null,
  79. queryParam: {
  80. beginDate: '',
  81. endDate: '',
  82. payWay: undefined
  83. },
  84. settleData: null,
  85. // 表头
  86. columns: [
  87. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  88. { title: '产品编码', dataIndex: 'productCode', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  89. { title: '产品名称', dataIndex: 'productName', width: '20%', align: 'left', customRender: function (text) { return text || '--' } },
  90. { title: '入库数量', dataIndex: 'putQty', width: '7.5%', align: 'center', customRender: function (text) { return text || '--' } },
  91. { title: '单位', dataIndex: 'productUnit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  92. { title: '入库单价', scopedSlots: { customRender: 'putCost' }, width: '7.5%', align: 'center' },
  93. { title: '入库成本', dataIndex: 'putTotalCost', width: '25%', align: 'center', customRender: function (text) { return (text || text == 0) ? text : '--' } },
  94. { title: '操作', width: '15%', align: 'left', scopedSlots: { customRender: 'action' } }
  95. ],
  96. warehouseCascadeData: [], // 仓库仓位
  97. // 加载数据方法 必须为 Promise 对象
  98. loadData: parameter => {
  99. this.spinning = true
  100. return recallrStockDetailList({ stockPutSn: this.$route.params.stockPutSn }).then(res => {
  101. let data
  102. if (res.status == 200) {
  103. console.log(res, 'liebiao')
  104. data = res.data
  105. for (let i = 0; i < data.length; i++) {
  106. data[i].no = i + 1
  107. if (this.defaultWarehouseCascade.length > 0 && (!data[i].warehouseSn || !data[i].warehouseLocationSn)) {
  108. data[i].warehouseCascade = this.defaultWarehouseCascade
  109. data[i].warehouseSn = this.defaultWarehouseCascade[0]
  110. data[i].warehouseLocationSn = this.defaultWarehouseCascade[1]
  111. } else {
  112. data[i].warehouseCascade = [data[i].warehouseSn, data[i].warehouseLocationSn]
  113. }
  114. }
  115. }
  116. this.spinning = false
  117. return data
  118. })
  119. }
  120. }
  121. },
  122. methods: {
  123. handleBack (val) {
  124. if (val == 1) {
  125. const _this = this
  126. this.$confirm({
  127. title: '提示',
  128. content: '经销商库存将增加,确认入库吗?',
  129. centered: true,
  130. onOk () {
  131. _this.spinning = true
  132. confirmPutStock({ stockPutSn: _this.$route.params.stockPutSn }).then(res => {
  133. _this.$message.warning(res.message)
  134. _this.spinning = false
  135. _this.$router.push({ path: '/numsGoodsShelves/recallStockManagement/list' })
  136. })
  137. }
  138. })
  139. } else {
  140. this.$router.push({ path: '/numsGoodsShelves/recallStockManagement/list' })
  141. }
  142. },
  143. // 入库信息的查询
  144. getStockInfo () {
  145. recallrStockDetail({ stockPutSn: this.$route.params.stockPutSn }).then(res => {
  146. if (res.status == 200) {
  147. this.pageInfo = res.data
  148. } else {
  149. this.pageInfo = null
  150. }
  151. })
  152. },
  153. // 更新列表数据
  154. updateSelectData (ajaxData) {
  155. updateSelective(ajaxData).then(res => {
  156. if (res.status == 200) {
  157. this.$refs.table.refresh()
  158. this.getStockInfo()
  159. }
  160. })
  161. },
  162. // 修改入库单价
  163. handleEdit (costPrice, opt) {
  164. this.updateSelectData({ id: opt.id, putCost: costPrice })
  165. },
  166. changeWarehouseCascade (val, opt) {
  167. this.updateSelectData({ id: opt.id, warehouseSn: val[0], warehouseLocationSn: val[1] })
  168. // let loadData
  169. // if (type == 'dealerProduct') { // 全部产品
  170. // loadData = this.loadDataSource[ind]
  171. // } else if (type == 'sparePartsPurDetail') { // 已选产品
  172. // loadData = this.chooseLoadDataSource[ind]
  173. // }
  174. // if (val.length < 2) {
  175. // this.$message.warning('当前仓库无仓位,请选择其他仓库')
  176. // const warehouseSnBackups = loadData.warehouseSnBackups || undefined
  177. // const warehouseLocationSnBackups = loadData.warehouseLocationSnBackups || undefined
  178. // loadData.warehouseSn = warehouseSnBackups
  179. // loadData.warehouseLocationSn = warehouseLocationSnBackups
  180. // if (warehouseSnBackups || warehouseLocationSnBackups) {
  181. // loadData.warehouseCascade = [warehouseSnBackups, warehouseLocationSnBackups]
  182. // } else {
  183. // loadData.warehouseCascade = undefined
  184. // }
  185. // } else {
  186. // loadData.warehouseSn = val[0] ? val[0] : ''
  187. // loadData.warehouseLocationSn = val[1] ? val[1] : ''
  188. // if (type == 'sparePartsPurDetail') { // 已选产品
  189. // loadData = this.chooseLoadDataSource[ind]
  190. // // this.handleAdd(loadData, 'edit')
  191. // }
  192. // }
  193. },
  194. // 仓库仓位 级联 列表
  195. getWarehouseCascade () {
  196. const _this = this
  197. warehouseCascadeList({}).then(res => {
  198. if (res.status == 200) {
  199. res.data.filter(item => {
  200. // 过滤默认仓库
  201. if (item.defaultFlag == 1 && item.wasteFlag == 0) { // defaultFlag为1,且不是废品仓
  202. _this.defaultWarehouseCascade[0] = item.warehouseSn
  203. // 过滤默认仓位
  204. item.warehouseLocationList.filter(subItem => {
  205. if (subItem.defaultFlag == 1 && subItem.wasteFlag == 0) {
  206. _this.defaultWarehouseCascade[1] = subItem.warehouseLocationSn
  207. _this.$refs.table.refresh(true)
  208. }
  209. })
  210. }
  211. })
  212. console.log(this.defaultWarehouseCascade)
  213. res.data.map(item => {
  214. item.sn = item.warehouseSn
  215. if (item.warehouseLocationList) {
  216. item.warehouseLocationList.map(subItem => {
  217. subItem.sn = subItem.warehouseLocationSn
  218. })
  219. }
  220. })
  221. this.warehouseCascadeData = res.data
  222. } else {
  223. this.warehouseCascadeData = []
  224. }
  225. })
  226. },
  227. // 查看详情
  228. handleDetail (row) {
  229. this.settleData = row
  230. this.openModal = true
  231. }
  232. },
  233. mounted () {
  234. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  235. this.getStockInfo()
  236. this.getWarehouseCascade()
  237. // this.$refs.table.refresh()
  238. }
  239. },
  240. activated () {
  241. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  242. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  243. this.getStockInfo()
  244. this.getWarehouseCascade()
  245. // this.$refs.table.refresh()
  246. }
  247. }
  248. }
  249. </script>
  250. <style lang="less">
  251. .goodsAllocationSet-page{
  252. position: relative;
  253. height: 100%;
  254. padding-bottom: 51px;
  255. box-sizing: border-box;
  256. .goodsAllocationSet-baseInfo{
  257. margin-bottom: 10px;
  258. }
  259. .bzj-collapse{
  260. margin-top: 10px;
  261. .ant-collapse-content-box{
  262. padding: 10px !important;
  263. }
  264. }
  265. }
  266. </style>