editStock.vue 10 KB

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